@cloudbase/weda-ui 2.0.10 → 2.0.26
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/README.md +1 -0
- package/package.json +47 -36
- package/src/configs/components/button.json +60 -13
- package/src/configs/components/calendar.json +3 -3
- package/src/configs/components/carousel.json +57 -47
- package/src/configs/components/chart/bar.json +4 -13
- package/src/configs/components/chart/line.json +4 -13
- package/src/configs/components/chart/pie.json +3 -10
- package/src/configs/components/chart/statisticsCard.json +1 -4
- package/src/configs/components/container.json +1 -3
- package/src/configs/components/dataView.json +7 -15
- package/src/configs/components/drawer.json +24 -6
- package/src/configs/components/form/form.json +19 -0
- package/src/configs/components/form/input.json +20 -5
- package/src/configs/components/form/location.json +51 -48
- package/src/configs/components/form/radio.json +1 -3
- package/src/configs/components/form/richText.json +14 -14
- package/src/configs/components/form/select.json +62 -82
- package/src/configs/components/form/textarea.json +14 -1
- package/src/configs/components/form/uploader.json +64 -64
- package/src/configs/components/form/uploaderFile.json +1 -2
- package/src/configs/components/graphicCard.json +44 -45
- package/src/configs/components/image.json +44 -40
- package/src/configs/components/link.json +5 -10
- package/src/configs/components/listView.json +2 -8
- package/src/configs/components/lottery.json +7 -3
- package/src/configs/components/modal.json +26 -21
- package/src/configs/components/navLayout.json +68 -68
- package/src/configs/components/navigationBar.json +4 -1
- package/src/configs/components/richtextview.json +1 -1
- package/src/configs/components/scrollVeiw.json +14 -42
- package/src/configs/components/swiper.json +9 -9
- package/src/configs/components/wedaVideo.json +89 -0
- package/src/configs/components/wxOpenApi/phone.json +7 -21
- package/src/configs/components/wxOpenApi/phoneCode.json +7 -19
- package/src/configs/components/wxOpenApi/share.json +14 -24
- package/src/configs/components/wxOpenApi/userInfo.json +9 -27
- package/src/configs/index.js +2 -0
- package/src/mp/components/button/index.js +1 -1
- package/src/mp/components/button/index.wxml +19 -19
- package/src/mp/components/calendar/index.js +68 -38
- package/src/mp/components/calendar/index.json +3 -2
- package/src/mp/components/calendar/index.wxml +5 -7
- package/src/mp/components/calendar/index.wxss +17 -16
- package/src/mp/components/carousel/index.json +1 -1
- package/src/mp/components/carousel/index.wxml +2 -2
- package/src/mp/components/chart/bar/index.js +1 -2
- package/src/mp/components/chart/bar/index.wxml +1 -1
- package/src/mp/components/chart/common/config/bar.js +1 -1
- package/src/mp/components/chart/common/core/eChartBar.js +29 -34
- package/src/mp/components/chart/common/core/eChartBase.js +46 -32
- package/src/mp/components/chart/common/core/eChartLine.js +34 -40
- package/src/mp/components/chart/common/core/eChartPie.js +12 -9
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
- package/src/mp/components/chart/line/index.js +2 -2
- package/src/mp/components/chart/line/index.wxml +1 -1
- package/src/mp/components/chart/pie/index.js +1 -1
- package/src/mp/components/chart/pie/index.wxml +1 -2
- package/src/mp/components/chart/statisticsCard/index.wxss +7 -10
- package/src/mp/components/dataView/index.wxml +2 -14
- package/src/mp/components/form/checkbox/index.js +15 -7
- package/src/mp/components/form/checkbox/index.wxml +13 -25
- package/src/mp/components/form/form/index.wxml +3 -3
- package/src/mp/components/form/formcell/index.wxml +9 -9
- package/src/mp/components/form/formcell/index.wxss +6 -1
- package/src/mp/components/form/input/index.js +4 -4
- package/src/mp/components/form/input/index.wxml +24 -31
- package/src/mp/components/form/input/index.wxss +9 -3
- package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.wxml +6 -6
- package/src/mp/components/form/location/index.js +7 -1
- package/src/mp/components/form/location/index.json +1 -1
- package/src/mp/components/form/location/index.wxml +6 -10
- package/src/mp/components/form/radio/index.js +14 -6
- package/src/mp/components/form/radio/index.wxml +12 -24
- package/src/mp/components/form/select/index.js +157 -98
- package/src/mp/components/form/select/index.wxml +11 -39
- package/src/mp/components/form/select/index.wxss +10 -1
- package/src/mp/components/form/select/region/index.js +18 -12
- package/src/mp/components/form/switch/index.wxml +11 -18
- package/src/mp/components/form/textarea/index.js +6 -0
- package/src/mp/components/form/textarea/index.wxml +2 -17
- package/src/mp/components/form/textarea/index.wxss +5 -0
- package/src/mp/components/form/tips/index.wxml +1 -3
- package/src/mp/components/form/uploader/index.js +1 -1
- package/src/mp/components/form/uploader/index.wxml +3 -20
- package/src/mp/components/form/uploader/weui-uploader.js +210 -200
- package/src/mp/components/form/uploader/weui-uploader.json +6 -6
- package/src/mp/components/form/uploader/weui-uploader.wxml +38 -38
- package/src/mp/components/form/uploaderFile/index.js +5 -4
- package/src/mp/components/form/uploaderFile/index.wxml +40 -41
- package/src/mp/components/graphicCard/index.js +35 -35
- package/src/mp/components/graphicCard/index.wxml +2 -6
- package/src/mp/components/graphicCard/index.wxss +6 -6
- package/src/mp/components/image/index.wxml +9 -20
- package/src/mp/components/image/index.wxss +3 -1
- package/src/mp/components/listView/index.wxml +5 -7
- package/src/mp/components/listView/index.wxss +2 -2
- package/src/mp/components/lottery/index.wxml +1 -3
- package/src/mp/components/lottery/index.wxss +31 -25
- package/src/mp/components/navLayout/index.js +9 -12
- package/src/mp/components/navLayout/index.wxml +2 -4
- package/src/mp/components/navLayout/index.wxss +10 -10
- package/src/mp/components/navigationBar/index.json +1 -2
- package/src/mp/components/navigationBar/index.wxml +43 -51
- package/src/mp/components/navigationBar/index.wxss +10 -10
- package/src/mp/components/richText/index.wxml +1 -1
- package/src/mp/components/richText/index.wxss +7 -5
- package/src/mp/components/swiper/index.wxml +1 -9
- package/src/mp/components/tabs/index.js +14 -10
- package/src/mp/components/tabs/index.json +1 -1
- package/src/mp/components/tabs/index.wxml +3 -21
- package/src/mp/components/tabs/index.wxss +1 -2
- package/src/mp/components/text/index.wxml +1 -6
- package/src/mp/components/text/index.wxss +1 -1
- package/src/mp/components/wedaVideo/index.js +86 -0
- package/src/mp/components/wedaVideo/index.json +4 -0
- package/src/mp/components/wedaVideo/index.wxml +4 -0
- package/src/mp/components/wedaVideo/index.wxss +20 -0
- package/src/mp/components/wxOpenApi/phone/index.js +1 -9
- package/src/mp/components/wxOpenApi/phone/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/share/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +3 -13
- package/src/mp/index.json +1 -0
- package/src/mp/style/weda-ui.wxss +24 -9
- package/src/mp/utils/deepEqual.js +37 -37
- package/src/mp/utils/destr.js +41 -40
- package/src/mp/utils/dr_square_point.js +10 -6
- package/src/setupTests.js +13 -13
- package/src/web/actions/showModal/index.tsx +5 -4
- package/src/web/components/button/index.tsx +44 -40
- package/src/web/components/calendar/index.css +99 -65
- package/src/web/components/carousel/index.tsx +1 -1
- package/src/web/components/chart/common/config/bar.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +28 -34
- package/src/web/components/chart/common/core/eChartBase.ts +55 -42
- package/src/web/components/chart/common/core/eChartLine.js +34 -40
- package/src/web/components/chart/common/core/eChartPie.js +12 -9
- package/src/web/components/chart/common/core/type.ts +23 -23
- package/src/web/components/chart/common/echart.css +12 -12
- package/src/web/components/chart/common/echarts.ts +3 -5
- package/src/web/components/chart/common/useChart.tsx +34 -16
- package/src/web/components/chart/statisticsCard/index.css +9 -8
- package/src/web/components/container/index.tsx +3 -4
- package/src/web/components/drawer/index.tsx +15 -4
- package/src/web/components/form/checkbox/index.tsx +32 -31
- package/src/web/components/form/enumSelect/NormalSelect.tsx +0 -2
- package/src/web/components/form/form/index.css +3 -6
- package/src/web/components/form/form/index.tsx +7 -6
- package/src/web/components/form/formcell/index.css +11 -18
- package/src/web/components/form/formcell/index.tsx +3 -7
- package/src/web/components/form/input/index.css +8 -4
- package/src/web/components/form/input/index.tsx +61 -53
- package/src/web/components/form/location/common/mapChoose.css +13 -11
- package/src/web/components/form/location/common/selectModal.jsx +2 -11
- package/src/web/components/form/location/common/useLocationInfo.js +4 -0
- package/src/web/components/form/location/components/LocationH5/index.css +19 -20
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +11 -1
- package/src/web/components/form/location/components/LocationPC/Header.jsx +0 -13
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +14 -5
- package/src/web/components/form/radio/index.tsx +32 -26
- package/src/web/components/form/renderDecorator.tsx +23 -26
- package/src/web/components/form/select/h5.tsx +155 -104
- package/src/web/components/form/select/index.css +9 -3
- package/src/web/components/form/select/index.tsx +76 -49
- package/src/web/components/form/select/region/index.ts +101 -80
- package/src/web/components/form/select/year.tsx +2 -0
- package/src/web/components/form/switch/index.tsx +40 -40
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +39 -26
- package/src/web/components/form/types.d.ts +10 -10
- package/src/web/components/form/uploader/index.css +10 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +29 -26
- package/src/web/components/form/uploader/uploader.pc.tsx +3 -6
- package/src/web/components/form/uploaderFile/index.css +24 -23
- package/src/web/components/form/uploaderFile/index.jsx +0 -5
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +24 -15
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +21 -13
- package/src/web/components/graphicCard/index.css +6 -6
- package/src/web/components/image/image.tsx +2 -2
- package/src/web/components/image/index.css +9 -7
- package/src/web/components/image/index.tsx +29 -12
- package/src/web/components/index.js +1 -0
- package/src/web/components/link/index.tsx +13 -13
- package/src/web/components/listView/index.css +8 -8
- package/src/web/components/lottery/index.css +43 -37
- package/src/web/components/lottery/index.tsx +3 -3
- package/src/web/components/modal/index.tsx +34 -34
- package/src/web/components/navLayout/index.css +25 -25
- package/src/web/components/navLayout/index.tsx +1 -1
- package/src/web/components/navigationBar/index.css +26 -26
- package/src/web/components/navigationBar/index.tsx +2 -2
- package/src/web/components/picker/datePicker.tsx +3 -3
- package/src/web/components/picker/picker.tsx +3 -3
- package/src/web/components/picker/timePicker.tsx +1 -1
- package/src/web/components/richText/index.jsx +41 -46
- package/src/web/components/richTextView/index.css +7 -3
- package/src/web/components/richTextView/index.tsx +4 -6
- package/src/web/components/scrollView/index.tsx +2 -2
- package/src/web/components/slot/index.tsx +3 -4
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/index.tsx +33 -15
- package/src/web/components/tabs/index.css +2 -3
- package/src/web/components/tabs/index.tsx +6 -6
- package/src/web/components/tabs/tabs.h5.tsx +17 -12
- package/src/web/components/tabs/tabs.pc.tsx +45 -34
- package/src/web/components/text/index.css +1 -1
- package/src/web/components/text/index.tsx +13 -14
- package/src/web/components/wedaVideo/index.css +42 -0
- package/src/web/components/wedaVideo/index.tsx +208 -0
- package/src/web/utils/constant.ts +2 -1
- package/src/web/utils/isObjectEqual.js +2 -1
- package/src/web/utils/loading-fallback.tsx +2 -2
- package/src/web/utils/lodash.ts +1 -1
- package/src/web/utils/platform.js +13 -0
- package/src/web/utils/useSetState.ts +6 -2
- package/src/web/weda-ui.css +23 -8
- package/src/docs/common/format.tsx +0 -112
- package/src/docs/common/tableView.css +0 -164
- package/src/docs/common/tableView.tsx +0 -273
- package/src/docs/compsdocs/chart/Bar.mdx +0 -159
- package/src/docs/compsdocs/chart/Line.mdx +0 -100
- package/src/docs/compsdocs/chart/Pie.mdx +0 -83
- package/src/docs/compsdocs/chart/_category_.json +0 -1
- package/src/docs/compsdocs/chart/statisticsCard.mdx +0 -51
- package/src/docs/compsdocs/database/DataView.mdx +0 -33
- package/src/docs/compsdocs/database/ListView.mdx +0 -33
- package/src/docs/compsdocs/database/_category_.json +0 -1
- package/src/docs/compsdocs/form/Form.mdx +0 -35
- package/src/docs/compsdocs/form/FormCheckbox.mdx +0 -35
- package/src/docs/compsdocs/form/FormDate.mdx +0 -30
- package/src/docs/compsdocs/form/FormEmail.mdx +0 -30
- package/src/docs/compsdocs/form/FormImageUploader.mdx +0 -31
- package/src/docs/compsdocs/form/FormInput.mdx +0 -30
- package/src/docs/compsdocs/form/FormLocation.mdx +0 -64
- package/src/docs/compsdocs/form/FormPhone.mdx +0 -30
- package/src/docs/compsdocs/form/FormRadio.mdx +0 -35
- package/src/docs/compsdocs/form/FormRegion.mdx +0 -30
- package/src/docs/compsdocs/form/FormSelect.mdx +0 -36
- package/src/docs/compsdocs/form/FormSwitch.mdx +0 -30
- package/src/docs/compsdocs/form/FormTextarea.mdx +0 -30
- package/src/docs/compsdocs/form/FormTime.mdx +0 -30
- package/src/docs/compsdocs/form/FormUploadFile.mdx +0 -30
- package/src/docs/compsdocs/form/FormUrl.mdx +0 -30
- package/src/docs/compsdocs/form/_category_.json +0 -1
- package/src/docs/compsdocs/grid/Card.mdx +0 -32
- package/src/docs/compsdocs/grid/Container.mdx +0 -42
- package/src/docs/compsdocs/grid/Footer.mdx +0 -31
- package/src/docs/compsdocs/grid/GridLayout.mdx +0 -32
- package/src/docs/compsdocs/grid/Header.mdx +0 -31
- package/src/docs/compsdocs/grid/Layout.mdx +0 -25
- package/src/docs/compsdocs/grid/List.mdx +0 -31
- package/src/docs/compsdocs/grid/ScrollView.mdx +0 -37
- package/src/docs/compsdocs/grid/Swiper.mdx +0 -58
- package/src/docs/compsdocs/grid/_category_.json +0 -1
- package/src/docs/compsdocs/media/Icon.mdx +0 -31
- package/src/docs/compsdocs/media/Image.mdx +0 -55
- package/src/docs/compsdocs/media/_category_.json +0 -1
- package/src/docs/compsdocs/model/ModelCreate.mdx +0 -20
- package/src/docs/compsdocs/model/ModelDetail.mdx +0 -20
- package/src/docs/compsdocs/model/ModelTable.mdx +0 -24
- package/src/docs/compsdocs/model/ModelUpdate.mdx +0 -21
- package/src/docs/compsdocs/model/PageLayout.mdx +0 -21
- package/src/docs/compsdocs/model/_category_.json +0 -1
- package/src/docs/compsdocs/navmenu/Classification.mdx +0 -38
- package/src/docs/compsdocs/navmenu/NavBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -30
- package/src/docs/compsdocs/navmenu/TabBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +0 -29
- package/src/docs/compsdocs/navmenu/_category_.json +0 -1
- package/src/docs/compsdocs/senior/Lottery.mdx +0 -48
- package/src/docs/compsdocs/senior/Modal.mdx +0 -58
- package/src/docs/compsdocs/senior/SlotMachine.mdx +0 -52
- package/src/docs/compsdocs/senior/_category_.json +0 -1
- package/src/docs/compsdocs/show/Calendar.mdx +0 -29
- package/src/docs/compsdocs/show/Divider.mdx +0 -31
- package/src/docs/compsdocs/show/GraphicCard.mdx +0 -30
- package/src/docs/compsdocs/show/Item.mdx +0 -32
- package/src/docs/compsdocs/show/ItemList.mdx +0 -47
- package/src/docs/compsdocs/show/Media.mdx +0 -25
- package/src/docs/compsdocs/show/StatusTip.mdx +0 -25
- package/src/docs/compsdocs/show/Swiper.mdx +0 -33
- package/src/docs/compsdocs/show/Tabs.mdx +0 -38
- package/src/docs/compsdocs/show/_category_.json +0 -1
- package/src/docs/compsdocs/show/button.mdx +0 -25
- package/src/docs/compsdocs/text/Link.mdx +0 -43
- package/src/docs/compsdocs/text/RichTextView.mdx +0 -36
- package/src/docs/compsdocs/text/Text.mdx +0 -31
- package/src/docs/compsdocs/text/Title.mdx +0 -32
- package/src/docs/compsdocs/text/_category_.json +0 -1
- package/src/docs/compsdocs/wxOpen/Phone.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/Share.mdx +0 -46
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/_category_.json +0 -4
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCustomCompareEffect,
|
|
3
|
+
useMountEffect,
|
|
4
|
+
useSyncedRef,
|
|
5
|
+
} from '@react-hookz/web';
|
|
2
6
|
import * as React from 'react';
|
|
3
7
|
import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
|
|
4
8
|
import classNames from '../../utils/classnames';
|
|
@@ -6,7 +10,6 @@ import isObjectEqual from '../../utils/isObjectEqual';
|
|
|
6
10
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
7
11
|
import { PropsType } from './index';
|
|
8
12
|
|
|
9
|
-
|
|
10
13
|
export default function TabsPc({
|
|
11
14
|
tabs = [],
|
|
12
15
|
selectedIndex,
|
|
@@ -16,48 +19,56 @@ export default function TabsPc({
|
|
|
16
19
|
isMultipleSlot = true,
|
|
17
20
|
...restProps
|
|
18
21
|
}: PropsType) {
|
|
19
|
-
|
|
20
22
|
const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
|
|
21
23
|
const _tabs = React.useMemo(() => {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return (
|
|
25
|
+
Array.isArray(tabs) &&
|
|
26
|
+
tabs.length &&
|
|
27
|
+
tabs.map((item, index) => {
|
|
28
|
+
return {
|
|
29
|
+
id: index.toString(),
|
|
30
|
+
label: item.title,
|
|
31
|
+
value: item.value,
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
);
|
|
29
35
|
}, [tabs]);
|
|
30
36
|
|
|
31
37
|
const eventsRef = useSyncedRef(events);
|
|
32
|
-
useCustomCompareEffect(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
useCustomCompareEffect(
|
|
39
|
+
() => {
|
|
40
|
+
eventsRef.current &&
|
|
41
|
+
eventsRef.current.change({
|
|
42
|
+
id: _tabs[activeIndex]?.id,
|
|
43
|
+
label: _tabs[activeIndex]?.label,
|
|
44
|
+
value: _tabs[activeIndex]?.value,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
[activeIndex, _tabs],
|
|
48
|
+
isObjectEqual
|
|
49
|
+
);
|
|
39
50
|
const onActive = (e) => {
|
|
40
51
|
setActiveIndex(e.id);
|
|
41
52
|
};
|
|
42
53
|
return (
|
|
43
54
|
<ConfigProvider classPrefix="wedatea2td">
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
id={item.id}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
<TeaTabs
|
|
56
|
+
style={style}
|
|
57
|
+
tabs={_tabs}
|
|
58
|
+
activeId={String(activeIndex)}
|
|
59
|
+
onActive={onActive}
|
|
60
|
+
className={classNames('weda-tabs_pc', {
|
|
61
|
+
[className]: className,
|
|
62
|
+
})}
|
|
63
|
+
>
|
|
64
|
+
{_tabs?.map((item, index) => (
|
|
65
|
+
<TabPanel key={item.id} id={item.id}>
|
|
66
|
+
{isMultipleSlot
|
|
67
|
+
? restProps[`panel${index + 1}`]
|
|
68
|
+
: restProps['panel1']}
|
|
57
69
|
</TabPanel>
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
</
|
|
61
|
-
</ConfigProvider>
|
|
70
|
+
))}
|
|
71
|
+
</TeaTabs>
|
|
72
|
+
</ConfigProvider>
|
|
62
73
|
);
|
|
63
74
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import classNames from '../../utils/classnames';
|
|
3
|
-
import { CommonPropsType, unknownFunction } from '../../types';
|
|
3
|
+
import type { CommonPropsType, unknownFunction } from '../../types';
|
|
4
4
|
import './index.css';
|
|
5
5
|
|
|
6
6
|
export interface PropsType extends CommonPropsType {
|
|
7
|
-
text: string
|
|
8
|
-
level: string
|
|
9
|
-
maxLines: number
|
|
10
|
-
space: boolean
|
|
11
|
-
userSelect: boolean
|
|
12
|
-
textAlign: string
|
|
13
|
-
textColor: string
|
|
14
|
-
contenteditable: HTMLParagraphElement['contentEditable']
|
|
15
|
-
onInput: unknownFunction
|
|
16
|
-
onBlur: unknownFunction
|
|
17
|
-
|
|
7
|
+
text: string;
|
|
8
|
+
level: string;
|
|
9
|
+
maxLines: number;
|
|
10
|
+
space: boolean;
|
|
11
|
+
userSelect: boolean;
|
|
12
|
+
textAlign: string;
|
|
13
|
+
textColor: string;
|
|
14
|
+
contenteditable: HTMLParagraphElement['contentEditable'];
|
|
15
|
+
onInput: unknownFunction;
|
|
16
|
+
onBlur: unknownFunction;
|
|
18
17
|
}
|
|
19
18
|
export default function Text({
|
|
20
19
|
text,
|
|
@@ -28,7 +27,7 @@ export default function Text({
|
|
|
28
27
|
level,
|
|
29
28
|
contenteditable,
|
|
30
29
|
onInput,
|
|
31
|
-
onBlur
|
|
30
|
+
onBlur,
|
|
32
31
|
}: PropsType) {
|
|
33
32
|
const textStyle: React.CSSProperties = {
|
|
34
33
|
WebkitLineClamp: maxLines,
|
|
@@ -38,7 +37,7 @@ export default function Text({
|
|
|
38
37
|
if (!userSelect) {
|
|
39
38
|
textStyle.userSelect = 'none';
|
|
40
39
|
}
|
|
41
|
-
const levelName =
|
|
40
|
+
const levelName = level === '0' || !level ? '' : `level_${level}`;
|
|
42
41
|
|
|
43
42
|
const inlineStyle = React.useMemo(
|
|
44
43
|
() => ({ ...textStyle, ...style }),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.weda-ui_video {
|
|
2
|
+
height: 500px;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
background-color: #000;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.weda-ui_video-h5 {
|
|
9
|
+
height: 250px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.weda-ui_video_control .vjs-control-bar {
|
|
13
|
+
background: none !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.weda-ui_video__video-wrap {
|
|
17
|
+
padding-top: 0 !important;
|
|
18
|
+
height: 100% !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.vjs-paused .vjs-big-play-button,
|
|
22
|
+
.vjs-paused.vjs-has-started .vjs-big-play-button {
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.vjs-slider-vertical .vjs-volume-level:before {
|
|
27
|
+
left: -0.5em !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.weda-ui_video__video-loading {
|
|
31
|
+
position: absolute;
|
|
32
|
+
z-index: 100;
|
|
33
|
+
left: 0;
|
|
34
|
+
top: 0;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: 100%;
|
|
37
|
+
background-color: #000;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
color: #fff;
|
|
42
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import videojs from 'video.js';
|
|
3
|
+
import 'video.js/dist/video-js.css';
|
|
4
|
+
import './index.css';
|
|
5
|
+
import { usePlatform, isCloudFileID, isInIde } from '../../utils/platform';
|
|
6
|
+
import { getTempFileURL } from '../../utils/tcb';
|
|
7
|
+
import classNames from '../../utils/classnames';
|
|
8
|
+
import type { CommonPropsType } from '../../types';
|
|
9
|
+
import { ConfigProvider, Icon } from 'tea-component';
|
|
10
|
+
|
|
11
|
+
const { useEffect, useRef, useMemo, useState } = React;
|
|
12
|
+
export interface VideoProps {
|
|
13
|
+
videoDataSource: string;
|
|
14
|
+
posterImage: string;
|
|
15
|
+
autoPlay: boolean;
|
|
16
|
+
loopPlay: boolean;
|
|
17
|
+
mutePlay: boolean;
|
|
18
|
+
controlBarStatus: boolean;
|
|
19
|
+
startTime: number;
|
|
20
|
+
endTime: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type WedaVideoProps = Partial<CommonPropsType & VideoProps>;
|
|
24
|
+
|
|
25
|
+
const MimetypesKind = {
|
|
26
|
+
opus: 'video/ogg',
|
|
27
|
+
ogv: 'video/ogg',
|
|
28
|
+
mp4: 'video/mp4',
|
|
29
|
+
mov: 'video/mp4',
|
|
30
|
+
m4v: 'video/mp4',
|
|
31
|
+
mkv: 'video/x-matroska',
|
|
32
|
+
m4a: 'audio/mp4',
|
|
33
|
+
mp3: 'audio/mpeg',
|
|
34
|
+
aac: 'audio/aac',
|
|
35
|
+
caf: 'audio/x-caf',
|
|
36
|
+
flac: 'audio/flac',
|
|
37
|
+
oga: 'audio/ogg',
|
|
38
|
+
wav: 'audio/wav',
|
|
39
|
+
m3u8: 'application/x-mpegURL',
|
|
40
|
+
jpg: 'image/jpeg',
|
|
41
|
+
jpeg: 'image/jpeg',
|
|
42
|
+
gif: 'image/gif',
|
|
43
|
+
png: 'image/png',
|
|
44
|
+
svg: 'image/svg+xml',
|
|
45
|
+
webp: 'image/webp',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const CLASS_PREFIX = 'weda-ui_video';
|
|
49
|
+
|
|
50
|
+
const WedaVideo: React.FC<WedaVideoProps> = ({
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
id,
|
|
54
|
+
videoDataSource,
|
|
55
|
+
posterImage,
|
|
56
|
+
autoPlay,
|
|
57
|
+
loopPlay,
|
|
58
|
+
mutePlay,
|
|
59
|
+
controlBarStatus,
|
|
60
|
+
startTime,
|
|
61
|
+
endTime,
|
|
62
|
+
}) => {
|
|
63
|
+
const platform = usePlatform();
|
|
64
|
+
const cls = classNames({
|
|
65
|
+
[className]: className,
|
|
66
|
+
[CLASS_PREFIX]: true,
|
|
67
|
+
[`${CLASS_PREFIX}-h5`]: platform === 'h5',
|
|
68
|
+
'weda-ui_video_control': !controlBarStatus,
|
|
69
|
+
});
|
|
70
|
+
const videoRef = useRef<HTMLVideoElement>(null);
|
|
71
|
+
const playerRef = useRef(null);
|
|
72
|
+
|
|
73
|
+
const [realSrc, setRealSrc] = useState(null);
|
|
74
|
+
const [videoModalStatus, setVideoModalStatus] = useState(true);
|
|
75
|
+
const [videoErrMsg, setVideoErrMsg] = useState('');
|
|
76
|
+
|
|
77
|
+
const videoType = useMemo(() => {
|
|
78
|
+
return realSrc?.substring(realSrc.lastIndexOf('.') + 1).toLowerCase();
|
|
79
|
+
}, [realSrc]);
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
async function getCloudUrl(fileID) {
|
|
83
|
+
if (isCloudFileID(fileID)) {
|
|
84
|
+
try {
|
|
85
|
+
const fileSrc = await getTempFileURL(fileID);
|
|
86
|
+
setVideoErrMsg('');
|
|
87
|
+
setRealSrc(fileSrc);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error('getCloudUrl error', err);
|
|
90
|
+
setVideoErrMsg('获取云文件资源失败');
|
|
91
|
+
setRealSrc('');
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
setRealSrc(videoDataSource);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
getCloudUrl(videoDataSource);
|
|
98
|
+
}, [videoDataSource]);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const videoElement = videoRef.current;
|
|
102
|
+
if (!playerRef.current) {
|
|
103
|
+
const videoOptions = {
|
|
104
|
+
poster: posterImage,
|
|
105
|
+
autoplay: autoPlay, //自动播放
|
|
106
|
+
bigPlayButton: true, //全屏按钮
|
|
107
|
+
loop: loopPlay, //循环播放
|
|
108
|
+
muted: mutePlay, // 是否静音
|
|
109
|
+
controls: controlBarStatus, //显示控制栏
|
|
110
|
+
language: 'zh-CN', // 设置语言
|
|
111
|
+
fluid: true, // 自适应宽高
|
|
112
|
+
controlBar: {
|
|
113
|
+
children: [
|
|
114
|
+
{ name: 'playToggle' }, // 底部暂停按钮
|
|
115
|
+
{ name: 'currentTimeDisplay' }, // 当前已播放时间
|
|
116
|
+
{ name: 'progressControl' }, // 进度条
|
|
117
|
+
{ name: 'durationDisplay' }, // 总时间
|
|
118
|
+
{
|
|
119
|
+
name: 'volumePanel', // 音量控制
|
|
120
|
+
inline: false, // 不使用水平方式
|
|
121
|
+
},
|
|
122
|
+
{ name: 'FullscreenToggle' }, // 全屏按钮
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
sources: [
|
|
126
|
+
{
|
|
127
|
+
src: realSrc || 'no',
|
|
128
|
+
type: MimetypesKind[videoType] || 'video/mp4',
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
playerRef.current = videojs(videoElement, videoOptions, () => {
|
|
133
|
+
players.currentTime(startTime); //指定播放时间
|
|
134
|
+
setVideoModalStatus(false);
|
|
135
|
+
setVideoErrMsg('');
|
|
136
|
+
});
|
|
137
|
+
const players = playerRef.current;
|
|
138
|
+
// 指定结束时间
|
|
139
|
+
if (endTime) {
|
|
140
|
+
players.on('timeupdate', () => {
|
|
141
|
+
//播放时间改变
|
|
142
|
+
const currentTime = players.currentTime();
|
|
143
|
+
if (startTime >= endTime) return;
|
|
144
|
+
if (currentTime > endTime) {
|
|
145
|
+
players.currentTime(startTime);
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
!loopPlay && players.pause();
|
|
148
|
+
}, 200);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
players.on('canplaythrough', function () {
|
|
153
|
+
setVideoModalStatus(false);
|
|
154
|
+
setVideoErrMsg('');
|
|
155
|
+
});
|
|
156
|
+
players.on('error', function () {
|
|
157
|
+
let errorMsg = `视频资源加载出错,错误信息:${
|
|
158
|
+
players?.error().message
|
|
159
|
+
}`;
|
|
160
|
+
let pattern = new RegExp('^(((https?)://)|/resources/)[^\\s]+$');
|
|
161
|
+
if (
|
|
162
|
+
isInIde() &&
|
|
163
|
+
!pattern.test(videoDataSource) &&
|
|
164
|
+
!isCloudFileID(videoDataSource)
|
|
165
|
+
) {
|
|
166
|
+
errorMsg = '请在预览区查看视频效果';
|
|
167
|
+
}
|
|
168
|
+
console.log('player error', errorMsg);
|
|
169
|
+
setVideoErrMsg(errorMsg);
|
|
170
|
+
setVideoModalStatus(true);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}, [videoRef]);
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
// 切换视频源
|
|
177
|
+
if (playerRef.current && videoType) {
|
|
178
|
+
let srcOption = [
|
|
179
|
+
{
|
|
180
|
+
src: realSrc,
|
|
181
|
+
type: MimetypesKind[videoType],
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
playerRef.current.src(srcOption);
|
|
185
|
+
playerRef.current.load(realSrc);
|
|
186
|
+
}
|
|
187
|
+
}, [realSrc]);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
191
|
+
<div className={cls} id={id} style={style} data-testid="wedaVideo">
|
|
192
|
+
<div data-vjs-player>
|
|
193
|
+
<video
|
|
194
|
+
ref={videoRef}
|
|
195
|
+
className={`video-js vjs-big-play-centered ${CLASS_PREFIX}__video-wrap`}
|
|
196
|
+
/>
|
|
197
|
+
</div>
|
|
198
|
+
{videoModalStatus && (
|
|
199
|
+
<div className={`${CLASS_PREFIX}__video-loading`}>
|
|
200
|
+
{realSrc === null ? <Icon type="loading" /> : videoErrMsg}
|
|
201
|
+
</div>
|
|
202
|
+
)}
|
|
203
|
+
</div>
|
|
204
|
+
</ConfigProvider>
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default WedaVideo;
|
|
@@ -4,7 +4,8 @@ export const TitleType = {
|
|
|
4
4
|
NONE: 'none',
|
|
5
5
|
} as const;
|
|
6
6
|
|
|
7
|
-
export const LOAD_ERR_IMG_BASE64 =
|
|
7
|
+
export const LOAD_ERR_IMG_BASE64 =
|
|
8
|
+
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMjUuMzIgMTYuMzU5N0MyNi4wNzY0IDE2LjM1OTcgMjYuODI1NCAxNi41MDg3IDI3LjUyNDMgMTYuNzk4MUMyOC4yMjMxIDE3LjA4NzYgMjguODU4MSAxNy41MTE5IDI5LjM5MjkgMTguMDQ2OEMyOS45Mjc4IDE4LjU4MTYgMzAuMzUyMSAxOS4yMTY2IDMwLjY0MTYgMTkuOTE1NEMzMC45MzEgMjAuNjE0MyAzMS4wOCAyMS4zNjMzIDMxLjA4IDIyLjExOTdDMzEuMDggMjIuODc2MSAzMC45MzEgMjMuNjI1MSAzMC42NDE2IDI0LjMyMzlDMzAuMzUyMSAyNS4wMjI4IDI5LjkyNzggMjUuNjU3OCAyOS4zOTI5IDI2LjE5MjZDMjguODU4MSAyNi43Mjc1IDI4LjIyMzEgMjcuMTUxOCAyNy41MjQzIDI3LjQ0MTJDMjYuODI1NCAyNy43MzA3IDI2LjA3NjQgMjcuODc5NyAyNS4zMiAyNy44Nzk3QzIzLjc5MjQgMjcuODc5NyAyMi4zMjczIDI3LjI3MjggMjEuMjQ3MSAyNi4xOTI2QzIwLjE2NjkgMjUuMTEyNCAxOS41NiAyMy42NDczIDE5LjU2IDIyLjExOTdDMTkuNTYgMjAuNTkyIDIwLjE2NjkgMTkuMTI3IDIxLjI0NzEgMTguMDQ2OEMyMi4zMjczIDE2Ljk2NjUgMjMuNzkyNCAxNi4zNTk3IDI1LjMyIDE2LjM1OTdaTTI4IDMuNTU5NjlWMTQuODc2OEMyNy4xNzc3IDE0LjU4NjYgMjYuMTkyIDE0LjQzODggMjUuMzIgMTQuNDM5N0MyNC4wMzEgMTQuNDM5NyAyMi44MTU3IDE0Ljc1NzEgMjEuNzQ4OCAxNS4zMTg0TDIwLjc5NTIgMTMuMTU5N0wxNi4wMjU5IDIwLjAyNzVMOC40NDU3NiAxNi40NDFMMy41NiAyMy4zOTk3SDE3Ljc0NjJDMTcuOTg2NyAyNC44MjkgMTguNjI4MiAyNi4xNjA2IDE5LjU5NTggMjcuMjM5N0gxVjMuNTU5NjlIMjhaTTI1Ljk2IDI0LjAzOTdIMjQuNjhWMjUuMzE5N0gyNS45NlYyNC4wMzk3Wk0yNS45NiAxOC45MTk3SDI0LjY4VjIzLjM5OTdIMjUuOTZWMTguOTE5N1pNNi4xMiAxMC41OTk3QzYuMTIgMTEuOTk4MSA3LjE5OTA0IDEzLjEwODUgOC42MDc2OCAxMy4xNTg0QzEwLjAyMDggMTMuMjA3NyAxMS4yNCAxMi4wNDggMTEuMjQgMTAuNTk5N0MxMS4yNCA5LjI0NjA5IDEwLjA2NDMgOC4wODU3NyA4Ljc1MjMyIDguMDQwOTdDNy4yOTU2OCA3Ljk5MTY5IDYuMTIgOS4xNTEzNyA2LjEyIDEwLjU5OTdaIiBmaWxsPSIjQkNDNEQwIj48L3BhdGg+Cjwvc3ZnPgo=' as const;
|
|
8
9
|
|
|
9
10
|
export const REL_DICT = {
|
|
10
11
|
equal: 'eq', // 等于
|
|
@@ -7,7 +7,8 @@ export function serde(a) {
|
|
|
7
7
|
const isObj = (a) => typeof a === 'object' && a !== null;
|
|
8
8
|
|
|
9
9
|
export default function (a, b, shouldSerde = false) {
|
|
10
|
-
if(shouldSerde && isObj(a) && isObj(b)) {
|
|
10
|
+
if (shouldSerde && isObj(a) && isObj(b)) {
|
|
11
|
+
// for Proxy created by mbox
|
|
11
12
|
return isEqual(serde(a), serde(b));
|
|
12
13
|
}
|
|
13
14
|
return isEqual(a, b);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
export const fallback =
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const fallback = <div>组件加载中...</div>;
|
package/src/web/utils/lodash.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// https://github.com/lodash/lodash/blob/4.17.15/lodash.js#L11973
|
|
2
|
-
export const isNil = (val: any): val is
|
|
2
|
+
export const isNil = (val: any): val is null | undefined => val == null;
|
|
@@ -141,3 +141,16 @@ const reg =
|
|
|
141
141
|
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
|
142
142
|
|
|
143
143
|
export const isUrl = (path) => reg.test(path);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* 生成随机数
|
|
147
|
+
*/
|
|
148
|
+
export const randomUuid = () => {
|
|
149
|
+
var s = [];
|
|
150
|
+
var hexDigits = '0123456789abcdef';
|
|
151
|
+
for (var i = 0; i < 32; i++) {
|
|
152
|
+
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
|
153
|
+
}
|
|
154
|
+
var uuid = s.join('');
|
|
155
|
+
return uuid;
|
|
156
|
+
};
|
|
@@ -6,9 +6,13 @@ export const useSetState = <T extends object>(
|
|
|
6
6
|
const [state, set] = useState<T>(initialState);
|
|
7
7
|
const setState = useCallback((patch) => {
|
|
8
8
|
set((prevState) =>
|
|
9
|
-
Object.assign(
|
|
9
|
+
Object.assign(
|
|
10
|
+
{},
|
|
11
|
+
prevState,
|
|
12
|
+
patch instanceof Function ? patch(prevState) : patch
|
|
13
|
+
)
|
|
10
14
|
);
|
|
11
15
|
}, []);
|
|
12
16
|
|
|
13
17
|
return [state, setState];
|
|
14
|
-
};
|
|
18
|
+
};
|
package/src/web/weda-ui.css
CHANGED
|
@@ -40,19 +40,13 @@ body .weda-ui {
|
|
|
40
40
|
background-color: var(--weui-TAG-TEXT-BLUE);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.weda-ui .wedatea2td-form__controls {
|
|
44
|
-
font-size: 1rem;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
43
|
@media (min-width: 1024px) {
|
|
48
44
|
.weda-ui .weui-cells {
|
|
49
45
|
/* prettier-ignore */
|
|
50
|
-
font-size:
|
|
46
|
+
font-size: 1em;
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
@media (min-width: 1024px) {
|
|
54
|
-
.weda-ui .weui-cell {
|
|
55
|
-
}
|
|
56
50
|
.weui .weui-cell_active:active {
|
|
57
51
|
background-color: unset !important;
|
|
58
52
|
}
|
|
@@ -67,5 +61,26 @@ body .weda-ui {
|
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
.weda-ui .weui-cell {
|
|
70
|
-
font-size:
|
|
64
|
+
font-size: inherit; /* 要让内联样式生效 */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.weda-ui .weui-cells {
|
|
68
|
+
font-size: 1em;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.weui-picker a:link:hover {
|
|
72
|
+
text-decoration: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.weda-formcells__pc.vertical .wedatea2td-form__label label {
|
|
76
|
+
width: auto; /* vertcal 情况下label不固定宽度 */
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.weda-ui .weui-btn_input-clear {
|
|
80
|
+
visibility: hidden; /* visibilty 防止居中而且宽度auto时,出现输入时宽度抖动 */
|
|
81
|
+
display: inline;
|
|
82
|
+
}
|
|
83
|
+
.weui-input:focus:not(:placeholder-shown) + .weui-btn_input-clear {
|
|
84
|
+
visibility: visible;
|
|
85
|
+
display: inline;
|
|
71
86
|
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
export interface ICompsConfig {
|
|
2
|
-
type: String;
|
|
3
|
-
name: string;
|
|
4
|
-
title: string;
|
|
5
|
-
description: string;
|
|
6
|
-
'x-platforms': string[];
|
|
7
|
-
default: string;
|
|
8
|
-
platforms: string;
|
|
9
|
-
'x-index': number;
|
|
10
|
-
}
|
|
11
|
-
export type TCompsConfig = ICompsConfig;
|
|
12
|
-
|
|
13
|
-
export const sortBy = (props) => {
|
|
14
|
-
return function (a, b) {
|
|
15
|
-
return a[props] - b[props];
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const objFormat = (args: any, type, origin) => {
|
|
20
|
-
//判断属性title值是否为拓展写法
|
|
21
|
-
const uuidReg = /(?<=text)\('(.*)(?=',)/;
|
|
22
|
-
let transformData: any = [];
|
|
23
|
-
for (let i in args) {
|
|
24
|
-
if (type && type == 'event') {
|
|
25
|
-
transformData.push({
|
|
26
|
-
name: origin == 'lowCode' ? args[i]?.name : args[i]?.title,
|
|
27
|
-
title: origin == 'lowCode' ? args[i]?.eventName : args[i]?.name,
|
|
28
|
-
description: args[i]?.remarks || '-',
|
|
29
|
-
platforms: args[i]['x-platforms']
|
|
30
|
-
? args[i]['x-platforms'].indexOf('MP') > -1
|
|
31
|
-
? '小程序端'
|
|
32
|
-
: args[i]['x-platforms'].indexOf('WEB') > -1
|
|
33
|
-
? 'web端'
|
|
34
|
-
: '兼容三端'
|
|
35
|
-
: '兼容三端',
|
|
36
|
-
});
|
|
37
|
-
} else if (type && type == 'attribute' && args[i].type != 'slot') {
|
|
38
|
-
if (
|
|
39
|
-
args[i]?.display == false ||
|
|
40
|
-
args[i]?.isReactNode == true ||
|
|
41
|
-
args[i]['x-component'] == 'sub-category-title' ||
|
|
42
|
-
args[i]['x-component'] == 'Divider'
|
|
43
|
-
) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
transformData.push({
|
|
47
|
-
code: i,
|
|
48
|
-
title: args[i].title.indexOf('{{')!=-1?args[i]?.title.match(uuidReg)[1]:args[i]?.title,
|
|
49
|
-
description: args[i]?.remarks || '-',
|
|
50
|
-
type: args[i]?.type || '-',
|
|
51
|
-
default: JSON.stringify(args[i]?.default) || '-',
|
|
52
|
-
'x-index': args[i]['x-index'] ? args[i]['x-index'] : 999999,
|
|
53
|
-
'x-category': args[i]['x-category']
|
|
54
|
-
? args[i]['x-category']
|
|
55
|
-
: '基础属性',
|
|
56
|
-
});
|
|
57
|
-
} else if (type && type == 'slot' && args[i].type == 'slot') {
|
|
58
|
-
transformData.push({
|
|
59
|
-
code: i,
|
|
60
|
-
title: args[i]?.title,
|
|
61
|
-
description: args[i]?.description || '-',
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (type && type == 'attribute') transformData.sort(sortBy('x-index'));
|
|
67
|
-
|
|
68
|
-
if (type && type == 'attribute') {
|
|
69
|
-
transformData = groupByType(transformData, 'x-category');
|
|
70
|
-
}
|
|
71
|
-
return transformData;
|
|
72
|
-
};
|
|
73
|
-
function groupByType(arr, param) {
|
|
74
|
-
var map = {};
|
|
75
|
-
var dest = [];
|
|
76
|
-
var structureMap = [];
|
|
77
|
-
var storgeType = [];
|
|
78
|
-
for (var i = 0; i < arr.length; i++) {
|
|
79
|
-
var ai = arr[i];
|
|
80
|
-
if (ai[param] && !map[ai[param]]) {
|
|
81
|
-
dest.push({
|
|
82
|
-
name: ai[param],
|
|
83
|
-
data: [ai],
|
|
84
|
-
});
|
|
85
|
-
map[ai[param]] = ai;
|
|
86
|
-
} else if (!ai[param]) {
|
|
87
|
-
dest.push({
|
|
88
|
-
name: '基础属性',
|
|
89
|
-
data: [ai],
|
|
90
|
-
});
|
|
91
|
-
map[ai[param]] = ai;
|
|
92
|
-
} else {
|
|
93
|
-
for (var j = 0; j < dest.length; j++) {
|
|
94
|
-
var dj = dest[j];
|
|
95
|
-
if (dj.name == ai[param]) {
|
|
96
|
-
dj.data.push(ai);
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
for (var k = 0; k < dest.length; k++) {
|
|
103
|
-
if (k == 0 && dest[k]?.name != '基础属性') {
|
|
104
|
-
storgeType = storgeType.concat(dest[k]?.data);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
structureMap = structureMap.concat(dest[k]?.data);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
storgeType.length != 0 ? structureMap.push(...storgeType) : null;
|
|
111
|
-
return structureMap;
|
|
112
|
-
}
|