@aliyun-obv/app-loader
Advanced tools
Comparing version 0.3.11 to 0.3.12
@@ -53,3 +53,3 @@ var __defProp = Object.defineProperty; | ||
var _a, _b, _c; | ||
import React, { forwardRef, useState, useCallback, useEffect, Suspense, useRef } from "react"; | ||
import React, { useMemo, forwardRef, useState, useCallback, useEffect, Suspense, useRef } from "react"; | ||
import ReactDOM from "react-dom"; | ||
@@ -490,4 +490,40 @@ const topWindowKey = "__CONSOLE_OBVIZ_APP__"; | ||
} | ||
function Skeleton({ | ||
count = 1, | ||
duration = 1.2, | ||
width = "100%", | ||
height, | ||
circle = false, | ||
style: customStyle, | ||
className: customClassName, | ||
theme = "light" | ||
}) { | ||
const defaultStyle = useMemo(() => { | ||
return __spreadValues({ | ||
animation: `${void 0} ${duration}s ease-in-out infinite` | ||
}, customStyle); | ||
}, [customStyle, duration]); | ||
const elements = useMemo(() => { | ||
const els = []; | ||
for (let i = 0; i < count; i++) { | ||
const style = __spreadValues({}, defaultStyle); | ||
style.width = width; | ||
if (height !== null) { | ||
style.height = height; | ||
} | ||
if (width !== null && height !== null && circle) { | ||
style.borderRadius = "50%"; | ||
} | ||
els.push( | ||
/* @__PURE__ */ React.createElement("span", { key: i, className: `${void 0} ${customClassName}`, style }, "") | ||
); | ||
} | ||
return els; | ||
}, [circle, count, customClassName, defaultStyle, height, width]); | ||
return /* @__PURE__ */ React.createElement("span", { className: `${void 0} ${theme === "dark" ? void 0 : void 0}` }, elements); | ||
} | ||
function _Application(_d, ref) { | ||
var _e = _d, { appInfo, exportName } = _e, props = __objRest(_e, ["appInfo", "exportName"]); | ||
var _a2; | ||
const showLoading = (_a2 = appInfo == null ? void 0 : appInfo.showLoading) != null ? _a2 : false; | ||
const [appCom, setAppCom] = useState({ current: null }); | ||
@@ -504,2 +540,5 @@ const init = useCallback(() => __async(this, null, function* () { | ||
if (appCom == null || appCom.current == null) { | ||
if (showLoading === true) { | ||
return /* @__PURE__ */ React.createElement("div", { style: { padding: "20px" } }, /* @__PURE__ */ React.createElement(Skeleton, { width: "100%", count: 3 })); | ||
} | ||
return null; | ||
@@ -506,0 +545,0 @@ } |
@@ -10,2 +10,6 @@ export interface IOBSApp { | ||
slsEnv?: boolean; | ||
/** | ||
* 是否需要显示 loading 效果 | ||
*/ | ||
showLoading?: boolean; | ||
} | ||
@@ -12,0 +16,0 @@ export interface IOBSAppInner extends IOBSApp { |
import React from 'react'; | ||
export type LazyComponent<T extends React.ComponentType<any>> = React.ExoticComponent<React.ComponentPropsWithRef<T>>; | ||
export type LazyComponent<T extends React.ComponentType<any>, K = {}> = React.ExoticComponent<React.ComponentPropsWithRef<T> & K>; | ||
export type FilteredValueOfKey<T, K extends keyof T, U> = T[K] extends U ? T[K] : never; | ||
export declare function ObvizAsyncComponent<O, T extends React.ComponentType<any>, K extends keyof O>(factory: () => Promise<O>, exportName: K): LazyComponent<FilteredValueOfKey<O, K, T>>; | ||
export interface LoaderAppProps { | ||
appProps?: { | ||
baseRouter?: string; | ||
}; | ||
} | ||
export declare function ObvizAsyncComponent<O, T extends React.ComponentType<any>, K extends keyof O>(factory: () => Promise<O>, exportName: K): LazyComponent<FilteredValueOfKey<O, K, T>, LoaderAppProps>; |
@@ -17,3 +17,3 @@ { | ||
"devDependencies": {}, | ||
"version": "0.3.11" | ||
"version": "0.3.12" | ||
} |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
85000
29
1553
6