@cloud-app-dev/vidc 4.0.17 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dumirc.ts +1 -1
- package/.eslintrc.js +3 -0
- package/.fatherrc.ts +0 -6
- package/es/AppContext/Sync.d.ts +7 -0
- package/es/AppContext/Sync.js +44 -0
- package/es/AppContext/index.d.ts +17 -0
- package/es/AppContext/index.js +154 -0
- package/es/AppContext/interface.d.ts +42 -0
- package/es/AppContext/static.d.ts +8 -0
- package/es/AppContext/static.js +9 -0
- package/es/CheckGroupFixed/demo.d.ts +2 -0
- package/es/CheckGroupFixed/demo.js +20 -0
- package/es/CheckGroupFixed/index.d.ts +22 -0
- package/es/CheckGroupFixed/index.js +150 -0
- package/es/CheckGroupFixed/style.d.ts +6 -0
- package/es/CheckGroupFixed/style.js +9 -0
- package/es/Config/index.d.ts +4 -0
- package/es/Config/index.js +77 -0
- package/es/Config/interface.d.ts +65 -0
- package/es/Config/utils.d.ts +4 -0
- package/es/Config/utils.js +33 -0
- package/es/CustomRenderSelect/index.d.ts +13 -0
- package/es/CustomRenderSelect/index.js +86 -0
- package/es/DBTools/index.d.ts +25 -0
- package/es/DBTools/index.js +336 -0
- package/es/DisableMark/index.d.ts +8 -0
- package/es/DisableMark/index.js +25 -0
- package/es/DomMove/demo.d.ts +1 -0
- package/es/DomMove/demo.js +19 -0
- package/es/DomMove/index.d.ts +16 -0
- package/es/DomMove/index.js +148 -0
- package/es/DomMove/utils.d.ts +8 -0
- package/es/DomMove/utils.js +33 -0
- package/es/Drag/DragAndDropItem.d.ts +4 -0
- package/es/Drag/DragAndDropItem.js +133 -0
- package/es/Drag/DropItem.d.ts +4 -0
- package/es/Drag/DropItem.js +50 -0
- package/es/Drag/index.d.ts +7 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/DynamicGridList/demo.d.ts +2 -0
- package/es/DynamicGridList/demo.js +86 -0
- package/es/DynamicGridList/index.d.ts +27 -0
- package/es/DynamicGridList/index.js +71 -0
- package/es/DynamicList/demo.d.ts +1 -0
- package/es/DynamicList/demo.js +45 -0
- package/es/DynamicList/index.d.ts +30 -0
- package/es/DynamicList/index.js +98 -0
- package/es/DynamicList/interface.d.ts +19 -0
- package/es/DynamicList/utils.d.ts +4 -0
- package/es/DynamicList/utils.js +6 -0
- package/es/ErrorFallback/index.d.ts +8 -0
- package/es/ErrorFallback/index.js +38 -0
- package/es/ErrorFallback/inerface.d.ts +48 -0
- package/es/EventTools/index.d.ts +3 -0
- package/es/EventTools/index.js +12 -0
- package/es/FrontendPlayer/index.d.ts +4 -0
- package/es/FrontendPlayer/index.js +2 -0
- package/es/GridList/data.d.ts +16 -0
- package/es/GridList/data.js +609 -0
- package/es/GridList/demo.d.ts +2 -0
- package/es/GridList/demo.js +89 -0
- package/es/GridList/hook.d.ts +13 -0
- package/es/GridList/hook.js +270 -0
- package/es/GridList/index.d.ts +14 -0
- package/es/GridList/index.js +51 -0
- package/es/GridList/interface.d.ts +59 -0
- package/es/GridList/utils.d.ts +9 -0
- package/es/GridList/utils.js +42 -0
- package/es/HightLevel/index.d.ts +8 -0
- package/es/HightLevel/index.js +20 -0
- package/es/IconFont/index.d.ts +12 -0
- package/es/IconFont/index.js +63 -0
- package/es/InstanceHistory/index.d.ts +3 -0
- package/es/InstanceHistory/index.js +7 -0
- package/es/LabelValue/index.d.ts +14 -0
- package/es/LabelValue/index.js +35 -0
- package/es/List/demo.d.ts +2 -0
- package/es/List/demo.js +25 -0
- package/es/List/index.d.ts +27 -0
- package/es/List/index.js +38 -0
- package/es/ListWithSizeAnimate/demo.d.ts +1 -0
- package/es/ListWithSizeAnimate/demo.js +128 -0
- package/es/ListWithSizeAnimate/index.d.ts +13 -0
- package/es/ListWithSizeAnimate/index.js +106 -0
- package/es/LoaderScript/index.d.ts +47 -0
- package/es/LoaderScript/index.js +38 -0
- package/es/LoaderScript/utils.d.ts +13 -0
- package/es/LoaderScript/utils.js +179 -0
- package/es/Picture/component/DefaultRects/RectInfo.d.ts +7 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +90 -0
- package/es/Picture/component/DefaultRects/index.d.ts +11 -0
- package/es/Picture/component/DefaultRects/index.js +58 -0
- package/es/Picture/component/DefaultRects/style.d.ts +10 -0
- package/es/Picture/component/DefaultRects/style.js +28 -0
- package/es/Picture/component/DefaultRects/utils.d.ts +2 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.d.ts +11 -0
- package/es/Picture/component/DrawRect/index.js +54 -0
- package/es/Picture/component/RectMenu/index.d.ts +10 -0
- package/es/Picture/component/RectMenu/index.js +84 -0
- package/es/Picture/component/RectMenu/utils.d.ts +12 -0
- package/es/Picture/component/RectMenu/utils.js +19 -0
- package/es/Picture/component/Tools/index.d.ts +11 -0
- package/es/Picture/component/Tools/index.js +105 -0
- package/es/Picture/component/Tools/style.d.ts +2 -0
- package/es/Picture/component/Tools/style.js +5 -0
- package/es/Picture/component/WheelScale/index.d.ts +6 -0
- package/es/Picture/component/WheelScale/index.js +29 -0
- package/es/Picture/demo.d.ts +1 -0
- package/es/Picture/demo.js +114 -0
- package/es/Picture/index.d.ts +17 -0
- package/es/Picture/index.js +356 -0
- package/es/Picture/interface.d.ts +196 -0
- package/es/Picture/loadCaptureRectImage.d.ts +3 -0
- package/es/Picture/loadCaptureRectImage.js +99 -0
- package/es/Picture/useDraw.d.ts +1 -0
- package/es/Picture/useDraw.js +103 -0
- package/es/Picture/utils.d.ts +26 -0
- package/es/Picture/utils.js +143 -0
- package/es/Player/api/index.d.ts +68 -0
- package/es/Player/api/index.js +309 -0
- package/es/Player/context.d.ts +21 -0
- package/es/Player/context.js +25 -0
- package/es/Player/contraller_bar/bar.d.ts +8 -0
- package/es/Player/contraller_bar/bar.js +32 -0
- package/es/Player/contraller_bar/contraller_event.d.ts +6 -0
- package/es/Player/contraller_bar/contraller_event.js +52 -0
- package/es/Player/contraller_bar/index.d.ts +13 -0
- package/es/Player/contraller_bar/index.js +39 -0
- package/es/Player/contraller_bar/left_bar.d.ts +10 -0
- package/es/Player/contraller_bar/left_bar.js +97 -0
- package/es/Player/contraller_bar/right_bar.d.ts +8 -0
- package/es/Player/contraller_bar/right_bar.js +36 -0
- package/es/Player/contraller_bar/time.d.ts +2 -0
- package/es/Player/contraller_bar/time.js +24 -0
- package/es/Player/contraller_bar/useBarStatus.d.ts +2 -0
- package/es/Player/contraller_bar/useBarStatus.js +43 -0
- package/es/Player/contraller_bar/volume.d.ts +8 -0
- package/es/Player/contraller_bar/volume.js +70 -0
- package/es/Player/demo.d.ts +2 -0
- package/es/Player/demo.js +289 -0
- package/es/Player/empty.d.ts +1 -0
- package/es/Player/empty.js +5 -0
- package/es/Player/event/errorEvent.d.ts +14 -0
- package/es/Player/event/errorEvent.js +88 -0
- package/es/Player/event/eventName.d.ts +18 -0
- package/es/Player/event/eventName.js +30 -0
- package/es/Player/event/index.d.ts +24 -0
- package/es/Player/event/index.js +205 -0
- package/es/Player/fps_play.d.ts +10 -0
- package/es/Player/fps_play.js +88 -0
- package/es/Player/frontend_player.d.ts +7 -0
- package/es/Player/frontend_player.js +71 -0
- package/es/Player/frontend_timeline.d.ts +8 -0
- package/es/Player/frontend_timeline.js +153 -0
- package/es/Player/iconfont.d.ts +4 -0
- package/es/Player/iconfont.js +21 -0
- package/es/Player/index.d.ts +2 -0
- package/es/Player/index.js +2 -0
- package/es/Player/live_heart.d.ts +8 -0
- package/es/Player/live_heart.js +45 -0
- package/es/Player/message.d.ts +3 -0
- package/es/Player/message.js +147 -0
- package/es/Player/player.d.ts +233 -0
- package/es/Player/segment_player.d.ts +8 -0
- package/es/Player/segment_player.js +229 -0
- package/es/Player/segment_timeline.d.ts +10 -0
- package/es/Player/segment_timeline.js +200 -0
- package/es/Player/single_player.d.ts +4 -0
- package/es/Player/single_player.js +278 -0
- package/es/Player/style/iconfont.js +43 -0
- package/es/Player/timeline.d.ts +7 -0
- package/es/Player/timeline.js +104 -0
- package/es/Player/util.d.ts +43 -0
- package/es/Player/util.js +189 -0
- package/es/PlayerExt/demo.d.ts +2 -0
- package/es/PlayerExt/demo.js +170 -0
- package/es/PlayerExt/index.d.ts +47 -0
- package/es/PlayerExt/index.js +212 -0
- package/es/Progress/index.d.ts +10 -0
- package/es/Progress/index.js +60 -0
- package/es/ROI/demo.d.ts +2 -0
- package/es/ROI/demo.js +17 -0
- package/es/ROI/index.d.ts +32 -0
- package/es/ROI/index.js +67 -0
- package/es/RefDrawer/Footer.d.ts +9 -0
- package/es/RefDrawer/Footer.js +27 -0
- package/es/RefDrawer/demo.d.ts +3 -0
- package/es/RefDrawer/demo.js +32 -0
- package/es/RefDrawer/index.d.ts +26 -0
- package/es/RefDrawer/index.js +73 -0
- package/es/RefModal/demo.d.ts +2 -0
- package/es/RefModal/demo.js +32 -0
- package/es/RefModal/index.d.ts +17 -0
- package/es/RefModal/index.js +71 -0
- package/es/ScreenPlayer/Live.d.ts +8 -0
- package/es/ScreenPlayer/Live.js +219 -0
- package/es/ScreenPlayer/LiveTools.d.ts +33 -0
- package/es/ScreenPlayer/LiveTools.js +172 -0
- package/es/ScreenPlayer/PlayerWithExt.d.ts +34 -0
- package/es/ScreenPlayer/PlayerWithExt.js +241 -0
- package/es/ScreenPlayer/RatePick.d.ts +7 -0
- package/es/ScreenPlayer/RatePick.js +35 -0
- package/es/ScreenPlayer/Record.d.ts +8 -0
- package/es/ScreenPlayer/Record.js +452 -0
- package/es/ScreenPlayer/RecordTools.d.ts +38 -0
- package/es/ScreenPlayer/RecordTools.js +214 -0
- package/es/ScreenPlayer/ScreenSelect.d.ts +6 -0
- package/es/ScreenPlayer/ScreenSelect.js +59 -0
- package/es/ScreenPlayer/SegmentTimeLine.d.ts +16 -0
- package/es/ScreenPlayer/SegmentTimeLine.js +44 -0
- package/es/ScreenPlayer/TimeMode.d.ts +6 -0
- package/es/ScreenPlayer/TimeMode.js +34 -0
- package/es/ScreenPlayer/TimeSelect.d.ts +6 -0
- package/es/ScreenPlayer/TimeSelect.js +99 -0
- package/es/ScreenPlayer/containerStyle.d.ts +13 -0
- package/es/ScreenPlayer/containerStyle.js +32 -0
- package/es/ScreenPlayer/demo.d.ts +1 -0
- package/es/ScreenPlayer/demo.js +19 -0
- package/es/ScreenPlayer/demo2.d.ts +1 -0
- package/es/ScreenPlayer/demo2.js +196 -0
- package/es/ScreenPlayer/index.d.ts +6 -0
- package/es/ScreenPlayer/index.js +9 -0
- package/es/ScreenPlayer/interface.d.ts +216 -0
- package/es/ScreenPlayer/useTimeSlider.d.ts +25 -0
- package/es/ScreenPlayer/useTimeSlider.js +451 -0
- package/es/ScreenPlayer/useVideoFit.d.ts +5 -0
- package/es/ScreenPlayer/useVideoFit.js +35 -0
- package/es/ScreenPlayer/utils.d.ts +17 -0
- package/es/ScreenPlayer/utils.js +85 -0
- package/es/SegmentPlayer/index.d.ts +2 -0
- package/es/SegmentPlayer/index.js +2 -0
- package/es/Service/http.d.ts +6 -0
- package/es/Service/http.js +125 -0
- package/es/Service/index.d.ts +3 -0
- package/es/Service/index.js +10 -0
- package/es/Service/interface.d.ts +22 -0
- package/es/Service/middleware.d.ts +5 -0
- package/es/Service/middleware.js +15 -0
- package/es/SocketEmitter/eventEmitter.d.ts +27 -0
- package/es/SocketEmitter/eventEmitter.js +88 -0
- package/es/SocketEmitter/index.d.ts +24 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/TableLayout/index.d.ts +9 -0
- package/es/TableLayout/index.js +32 -0
- package/es/Timeout/index.d.ts +31 -0
- package/es/Timeout/index.js +69 -0
- package/es/cache/index.d.ts +34 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.d.ts +1 -0
- package/es/copy/index.js +9 -0
- package/es/core.d.ts +0 -0
- package/es/getThemeStyle/index.d.ts +2 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.d.ts +52 -0
- package/es/index.js +52 -0
- package/es/likeGo/index.d.ts +2 -0
- package/es/likeGo/index.js +31 -0
- package/es/likeGoSync/index.d.ts +2 -0
- package/es/likeGoSync/index.js +10 -0
- package/es/logger/index.d.ts +7 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.d.ts +1 -0
- package/es/nextTick/index.js +3 -0
- package/es/recorder/demo.d.ts +2 -0
- package/es/recorder/demo.js +200 -0
- package/es/recorder/index.d.ts +294 -0
- package/es/recorder/index.js +991 -0
- package/es/submidstr/index.d.ts +5 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.d.ts +11 -0
- package/es/treeHelper/index.js +189 -0
- package/es/typings.d.ts +2 -0
- package/es/useDrawROI/index.d.ts +16 -0
- package/es/useDrawROI/index.js +318 -0
- package/es/useEventEmitterHandle/index.d.ts +2 -0
- package/es/useEventEmitterHandle/index.js +17 -0
- package/es/useHistory/index.d.ts +3 -0
- package/es/useHistory/index.js +9 -0
- package/es/useHistory/interface.d.ts +3 -0
- package/es/useInfiniteScroll/index.d.ts +16 -0
- package/es/useInfiniteScroll/index.js +102 -0
- package/es/useRafInterval/index.d.ts +5 -0
- package/es/useRafInterval/index.js +70 -0
- package/es/useSimpleState/index.d.ts +3 -0
- package/es/useSimpleState/index.js +35 -0
- package/es/useVirtualList/index.d.ts +13 -0
- package/es/useVirtualList/index.js +136 -0
- package/es/utils.d.ts +14 -0
- package/es/utils.js +46 -0
- package/es/uuid/index.d.ts +5 -0
- package/es/uuid/index.js +6 -0
- package/package.json +16 -21
- package/release-build.sh +2 -0
- package/scripts/{entry.js → entry.mjs} +4 -6
- package/{icon-fix.js → scripts/icon-fix.mjs} +4 -3
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ILabelValueProps {
|
|
3
|
+
label?: any;
|
|
4
|
+
value?: any;
|
|
5
|
+
emptyValue?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
noWrap?: boolean;
|
|
8
|
+
noColon?: boolean;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
labelStyle?: React.CSSProperties;
|
|
11
|
+
valueStyle?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
declare function LabelValue({ label, value, emptyValue, className, style, labelStyle, valueStyle, noWrap, noColon }: ILabelValueProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default LabelValue;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { css } from '@emotion/css';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
var classname = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n font-size: var(--fs-small);\n span {\n &:first-child {\n padding-right: 4px;\n color: var(--color4);\n white-space: nowrap;\n }\n\n &:last-child {\n flex: 1;\n color: var(--color6);\n\n &.no-wrap {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n }\n }\n"])));
|
|
8
|
+
function LabelValue(_ref) {
|
|
9
|
+
var label = _ref.label,
|
|
10
|
+
value = _ref.value,
|
|
11
|
+
_ref$emptyValue = _ref.emptyValue,
|
|
12
|
+
emptyValue = _ref$emptyValue === void 0 ? '-' : _ref$emptyValue,
|
|
13
|
+
_ref$className = _ref.className,
|
|
14
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
15
|
+
style = _ref.style,
|
|
16
|
+
labelStyle = _ref.labelStyle,
|
|
17
|
+
valueStyle = _ref.valueStyle,
|
|
18
|
+
_ref$noWrap = _ref.noWrap,
|
|
19
|
+
noWrap = _ref$noWrap === void 0 ? false : _ref$noWrap,
|
|
20
|
+
noColon = _ref.noColon;
|
|
21
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
22
|
+
className: "".concat(classname, " ").concat(className),
|
|
23
|
+
style: style,
|
|
24
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
25
|
+
style: labelStyle,
|
|
26
|
+
children: [label, noColon ? '' : ':']
|
|
27
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
28
|
+
title: value,
|
|
29
|
+
className: "".concat(noWrap ? 'no-wrap' : ''),
|
|
30
|
+
style: valueStyle,
|
|
31
|
+
children: value || emptyValue
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export default LabelValue;
|
package/es/List/demo.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import List from "./index";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
var defaultList = Array.from(new Array(10000)).map(function (_, i) {
|
|
5
|
+
return {
|
|
6
|
+
name: "\u6211\u662F\u5217\u8868".concat(i),
|
|
7
|
+
id: i
|
|
8
|
+
};
|
|
9
|
+
});
|
|
10
|
+
export default (function () {
|
|
11
|
+
return /*#__PURE__*/_jsx("div", {
|
|
12
|
+
style: {
|
|
13
|
+
width: 300,
|
|
14
|
+
height: 600
|
|
15
|
+
},
|
|
16
|
+
children: /*#__PURE__*/_jsx(List, {
|
|
17
|
+
list: defaultList,
|
|
18
|
+
renderItem: function renderItem(item) {
|
|
19
|
+
return /*#__PURE__*/_jsx("div", {
|
|
20
|
+
children: item.name
|
|
21
|
+
}, item.id);
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ListProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* @description 列表数据
|
|
5
|
+
* @default []
|
|
6
|
+
*/
|
|
7
|
+
list: Array<T>;
|
|
8
|
+
/**
|
|
9
|
+
* @description 列表类名
|
|
10
|
+
* @default ''
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* @description 列表样式
|
|
15
|
+
* @default -
|
|
16
|
+
*/
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
/**
|
|
19
|
+
* @description 列表自定义渲染
|
|
20
|
+
* @default -
|
|
21
|
+
*/
|
|
22
|
+
renderItem: (item: T, index: number) => JSX.Element;
|
|
23
|
+
rowHeight?: number;
|
|
24
|
+
renderHeaderExt?: () => JSX.Element;
|
|
25
|
+
}
|
|
26
|
+
declare function List<T>({ className, style, renderItem, list, rowHeight, renderHeaderExt }: ListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default List;
|
package/es/List/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { css } from '@emotion/css';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
var listWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n height: 100%;\n overflow: hidden;\n cursor: auto;\n border: 1px solid var(--gray2);\n flex-direction: column;\n"])));
|
|
8
|
+
var listlayout = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1;\n overflow: hidden;\n"])));
|
|
9
|
+
var vidcSimpleListLayout = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n overflow: auto;\n contain: strict;\n"])));
|
|
10
|
+
function List(_ref) {
|
|
11
|
+
var className = _ref.className,
|
|
12
|
+
style = _ref.style,
|
|
13
|
+
renderItem = _ref.renderItem,
|
|
14
|
+
list = _ref.list,
|
|
15
|
+
_ref$rowHeight = _ref.rowHeight,
|
|
16
|
+
rowHeight = _ref$rowHeight === void 0 ? 30 : _ref$rowHeight,
|
|
17
|
+
renderHeaderExt = _ref.renderHeaderExt;
|
|
18
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
19
|
+
className: "".concat(listWrapper, " ").concat(className),
|
|
20
|
+
style: style,
|
|
21
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
22
|
+
children: renderHeaderExt === null || renderHeaderExt === void 0 ? void 0 : renderHeaderExt()
|
|
23
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
24
|
+
className: listlayout,
|
|
25
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
26
|
+
className: vidcSimpleListLayout,
|
|
27
|
+
style: {
|
|
28
|
+
contentVisibility: 'auto',
|
|
29
|
+
containIntrinsicSize: list.length * rowHeight
|
|
30
|
+
},
|
|
31
|
+
children: list.map(function (ele, index) {
|
|
32
|
+
return renderItem(ele, index);
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export default List;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function App(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
/* eslint-disable react/button-has-type */
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
9
|
+
import React, { useRef } from 'react';
|
|
10
|
+
import ListWithSizeAnimate from "./index";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
function random(low, high) {
|
|
14
|
+
return Math.floor(Math.random() * high) + low;
|
|
15
|
+
}
|
|
16
|
+
var IMAGES = function IMAGES() {
|
|
17
|
+
return Array.from({
|
|
18
|
+
length: 20
|
|
19
|
+
}, function (_, index) {
|
|
20
|
+
var width = 300;
|
|
21
|
+
var height = random(200, 300);
|
|
22
|
+
return {
|
|
23
|
+
url: "https://picsum.photos/id/".concat(index + 1, "/").concat(width, "/").concat(height, ".jpg"),
|
|
24
|
+
width: width,
|
|
25
|
+
height: height
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
function loadPage(d) {
|
|
30
|
+
console.log(d);
|
|
31
|
+
if (!d) {
|
|
32
|
+
// eslint-disable-next-line no-param-reassign
|
|
33
|
+
d = {};
|
|
34
|
+
}
|
|
35
|
+
var resultData = IMAGES();
|
|
36
|
+
d.page ? d.page++ : d.page = 1;
|
|
37
|
+
d.list ? d.list = [].concat(_toConsumableArray(d.list), _toConsumableArray(resultData)) : d.list = resultData;
|
|
38
|
+
return new Promise(function (resolve) {
|
|
39
|
+
console.log(d.page);
|
|
40
|
+
setTimeout(function () {
|
|
41
|
+
return resolve(d);
|
|
42
|
+
}, 5000);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export default function App() {
|
|
46
|
+
var ref = useRef(null);
|
|
47
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
48
|
+
style: {
|
|
49
|
+
width: '100%',
|
|
50
|
+
height: 800,
|
|
51
|
+
position: 'relative'
|
|
52
|
+
},
|
|
53
|
+
children: [/*#__PURE__*/_jsx(ListWithSizeAnimate, {
|
|
54
|
+
ref: ref,
|
|
55
|
+
header: /*#__PURE__*/_jsx("div", {
|
|
56
|
+
children: /*#__PURE__*/_jsxs("ul", {
|
|
57
|
+
children: [/*#__PURE__*/_jsx("li", {
|
|
58
|
+
children: "\u6761\u4EF61"
|
|
59
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
60
|
+
children: "\u6761\u4EF62"
|
|
61
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
62
|
+
children: "\u6761\u4EF63"
|
|
63
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
64
|
+
children: "\u6761\u4EF63"
|
|
65
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
66
|
+
children: "\u6761\u4EF63"
|
|
67
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
68
|
+
children: "\u6761\u4EF63"
|
|
69
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
70
|
+
children: "\u6761\u4EF63"
|
|
71
|
+
})]
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
itemKey: "url",
|
|
75
|
+
itemHeight: 300,
|
|
76
|
+
itemWidth: 250,
|
|
77
|
+
renderItem: function renderItem(image) {
|
|
78
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
79
|
+
style: {
|
|
80
|
+
border: '1px solid gray',
|
|
81
|
+
height: '100%',
|
|
82
|
+
display: 'flex',
|
|
83
|
+
flexDirection: 'column'
|
|
84
|
+
},
|
|
85
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
86
|
+
style: {
|
|
87
|
+
flex: 1,
|
|
88
|
+
overflow: 'hidden'
|
|
89
|
+
},
|
|
90
|
+
children: /*#__PURE__*/_jsx("img", {
|
|
91
|
+
src: image.url,
|
|
92
|
+
alt: "",
|
|
93
|
+
style: {
|
|
94
|
+
objectFit: 'cover',
|
|
95
|
+
display: 'block',
|
|
96
|
+
width: '100%',
|
|
97
|
+
height: '100%'
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
101
|
+
children: "\u6807\u9898"
|
|
102
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
103
|
+
children: "\u63CF\u8FF0"
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
loadPage: loadPage,
|
|
108
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
109
|
+
style: {
|
|
110
|
+
height: 100,
|
|
111
|
+
backgroundColor: 'green'
|
|
112
|
+
},
|
|
113
|
+
children: "\u68C0\u7D22\u6761\u4EF6"
|
|
114
|
+
})
|
|
115
|
+
}), /*#__PURE__*/_jsx("button", {
|
|
116
|
+
style: {
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
bottom: 30,
|
|
119
|
+
right: 30
|
|
120
|
+
},
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
var _ref$current;
|
|
123
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.backTop();
|
|
124
|
+
},
|
|
125
|
+
children: "\u8FD4\u56DE\u9876\u90E8"
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IDynamicGridListProps } from '../DynamicGridList';
|
|
3
|
+
interface IListWithSizeAnimateProps<T> extends IDynamicGridListProps<T> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
header?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface IListWithSizeAnimateRef {
|
|
8
|
+
open: () => void;
|
|
9
|
+
close: () => void;
|
|
10
|
+
backTop: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare const ListWithSizeAnimate: React.ForwardRefExoticComponent<IListWithSizeAnimateProps<unknown> & React.RefAttributes<IListWithSizeAnimateRef>>;
|
|
13
|
+
export default ListWithSizeAnimate;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["header", "children"];
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
19
|
+
import { css } from '@emotion/css';
|
|
20
|
+
import { useEventListener } from 'ahooks';
|
|
21
|
+
import React, { useImperativeHandle, useMemo, useRef } from 'react';
|
|
22
|
+
import DynamicGridList from "../DynamicGridList";
|
|
23
|
+
import useSimpleState from "../useSimpleState";
|
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
var listWithSizeAnimateLayout = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n width: 100%;\n height: 100%;\n overflow: hidden;\n flex-direction: column;\n"])));
|
|
27
|
+
var istAnimateHeader = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transition: max-height 0.2s;\n"])));
|
|
28
|
+
var listAnimateContent = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n flex: 1;\n display: flex;\n overflow: hidden;\n transition: height 0.2s;\n flex-direction: column;\n"])));
|
|
29
|
+
var dynamicGridList = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 1;\n"])));
|
|
30
|
+
var ListWithSizeAnimate = /*#__PURE__*/React.forwardRef(function ListWithSizeAnimate(_ref, forwardRef) {
|
|
31
|
+
var _ref$current2;
|
|
32
|
+
var header = _ref.header,
|
|
33
|
+
children = _ref.children,
|
|
34
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
var _useSimpleState = useSimpleState({
|
|
36
|
+
open: true
|
|
37
|
+
}),
|
|
38
|
+
_useSimpleState2 = _slicedToArray(_useSimpleState, 2),
|
|
39
|
+
state = _useSimpleState2[0],
|
|
40
|
+
updateState = _useSimpleState2[1];
|
|
41
|
+
var ref = useRef(null);
|
|
42
|
+
var headerHeight = useMemo(function () {
|
|
43
|
+
return state.open ? 1000 : 0;
|
|
44
|
+
}, [state.open]);
|
|
45
|
+
useEventListener('scroll', function () {
|
|
46
|
+
var _ref$current;
|
|
47
|
+
var ele = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector('.dynamic-grid-list');
|
|
48
|
+
if ((ele === null || ele === void 0 ? void 0 : ele.scrollTop) === 0) {
|
|
49
|
+
updateState({
|
|
50
|
+
open: true
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
state.open && updateState({
|
|
54
|
+
open: false
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
target: (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.querySelector('.dynamic-grid-list')
|
|
59
|
+
});
|
|
60
|
+
useImperativeHandle(forwardRef, function () {
|
|
61
|
+
return {
|
|
62
|
+
open: function open() {
|
|
63
|
+
return updateState({
|
|
64
|
+
open: true
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
close: function close() {
|
|
68
|
+
return updateState({
|
|
69
|
+
open: false
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
backTop: function backTop() {
|
|
73
|
+
var _ref$current3, _ref$current3$querySe;
|
|
74
|
+
return (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : (_ref$current3$querySe = _ref$current3.querySelector('.dynamic-grid-list')) === null || _ref$current3$querySe === void 0 ? void 0 : _ref$current3$querySe.scrollTo({
|
|
75
|
+
top: 0
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
+
[]);
|
|
82
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
83
|
+
className: listWithSizeAnimateLayout,
|
|
84
|
+
ref: ref,
|
|
85
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
86
|
+
className: istAnimateHeader,
|
|
87
|
+
style: {
|
|
88
|
+
maxHeight: headerHeight,
|
|
89
|
+
overflow: !state.open ? 'hidden' : undefined
|
|
90
|
+
},
|
|
91
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
92
|
+
className: "list-animate-header-content",
|
|
93
|
+
children: header
|
|
94
|
+
})
|
|
95
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
96
|
+
className: listAnimateContent,
|
|
97
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
98
|
+
className: "list-animate-content-ext",
|
|
99
|
+
children: children
|
|
100
|
+
}), /*#__PURE__*/_jsx(DynamicGridList, _objectSpread(_objectSpread({}, props), {}, {
|
|
101
|
+
className: dynamicGridList
|
|
102
|
+
}))]
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
export default ListWithSizeAnimate;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IOptionsLoader {
|
|
3
|
+
scripts?: string[];
|
|
4
|
+
styles?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface ILoaderProps {
|
|
7
|
+
/**
|
|
8
|
+
* @description 脚本加载数据源
|
|
9
|
+
* @default []
|
|
10
|
+
* @type {scripts?:string[],styles?:string[]}
|
|
11
|
+
*/
|
|
12
|
+
options: IOptionsLoader[];
|
|
13
|
+
/**
|
|
14
|
+
* @description 加载后初始化组件
|
|
15
|
+
* @default null
|
|
16
|
+
*/
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* @description 加载后初始化组件
|
|
20
|
+
* @default null
|
|
21
|
+
*/
|
|
22
|
+
Spin?: React.ReactNode | null;
|
|
23
|
+
}
|
|
24
|
+
export interface ILoaderProps {
|
|
25
|
+
/**
|
|
26
|
+
* @description 脚本加载数据源
|
|
27
|
+
* @default []
|
|
28
|
+
*/
|
|
29
|
+
options: IOptionsLoader[];
|
|
30
|
+
/**
|
|
31
|
+
* @description 加载后初始化组件
|
|
32
|
+
* @default null
|
|
33
|
+
*/
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* @description 加载后初始化组件
|
|
37
|
+
* @default null
|
|
38
|
+
*/
|
|
39
|
+
Spin?: React.ReactNode | null;
|
|
40
|
+
/**
|
|
41
|
+
* @description 加载完成触发事件
|
|
42
|
+
* @default -
|
|
43
|
+
*/
|
|
44
|
+
onLoadEnd?: () => Promise<null>;
|
|
45
|
+
}
|
|
46
|
+
declare function LoaderScripts({ options, children, Spin, onLoadEnd }: ILoaderProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export default LoaderScripts;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import { createAsyncIterable, runAsyncIterable } from "./utils";
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
function LoaderScripts(_ref) {
|
|
12
|
+
var _ref$options = _ref.options,
|
|
13
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
14
|
+
children = _ref.children,
|
|
15
|
+
_ref$Spin = _ref.Spin,
|
|
16
|
+
Spin = _ref$Spin === void 0 ? null : _ref$Spin,
|
|
17
|
+
onLoadEnd = _ref.onLoadEnd;
|
|
18
|
+
var _useState = useState(false),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
initStatus = _useState2[0],
|
|
21
|
+
setInitStatus = _useState2[1];
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
if (options.length === 0) {
|
|
24
|
+
return setInitStatus(true);
|
|
25
|
+
}
|
|
26
|
+
runAsyncIterable(createAsyncIterable(options), function (index) {
|
|
27
|
+
return console.debug('LoaderScript -> Iterable加载完成!', options[index]);
|
|
28
|
+
}, function () {
|
|
29
|
+
return onLoadEnd ? onLoadEnd().then(function () {
|
|
30
|
+
return setInitStatus(true);
|
|
31
|
+
}) : setInitStatus(true);
|
|
32
|
+
});
|
|
33
|
+
}, [onLoadEnd, options]);
|
|
34
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
35
|
+
children: !initStatus ? Spin : children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export default LoaderScripts;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IOptionsLoader } from '.';
|
|
2
|
+
export declare const loadScript: (url: string) => Promise<unknown>;
|
|
3
|
+
export declare const loaderCss: (href: string) => Promise<unknown>;
|
|
4
|
+
export declare function createAsyncIterable(options: IOptionsLoader[]): {
|
|
5
|
+
[Symbol.asyncIterator](): {
|
|
6
|
+
i: number;
|
|
7
|
+
next(): Promise<{
|
|
8
|
+
value: number;
|
|
9
|
+
done: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function runAsyncIterable(Iterables: any, runtime?: (conf: any) => void, callback?: () => void): void;
|