@cloudbase/weda-ui 2.0.11 → 2.0.12
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 +5 -4
- 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 +6 -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 +43 -44
- 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 +66 -67
- 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 +86 -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/docs/common/format.tsx +4 -1
- package/src/docs/common/tableView.css +3 -3
- package/src/docs/common/tableView.tsx +18 -8
- package/src/docs/compsdocs/form/FormLocation.mdx +1 -1
- package/src/docs/compsdocs/form/FormSelect.mdx +0 -1
- package/src/docs/compsdocs/grid/Card.mdx +0 -1
- package/src/docs/compsdocs/grid/Container.mdx +0 -1
- package/src/docs/compsdocs/grid/GridLayout.mdx +0 -1
- package/src/docs/compsdocs/grid/ScrollView.mdx +2 -2
- package/src/docs/compsdocs/grid/Swiper.mdx +1 -2
- package/src/docs/compsdocs/media/Icon.mdx +1 -1
- package/src/docs/compsdocs/media/Image.mdx +6 -6
- package/src/docs/compsdocs/model/ModelCreate.mdx +24 -0
- package/src/docs/compsdocs/model/ModelDetail.mdx +24 -0
- package/src/docs/compsdocs/model/ModelTable.mdx +133 -1
- package/src/docs/compsdocs/model/ModelUpdate.mdx +24 -1
- package/src/docs/compsdocs/navmenu/Classification.mdx +2 -3
- package/src/docs/compsdocs/navmenu/NavBar.mdx +14 -5
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -1
- package/src/docs/compsdocs/navmenu/TabBar.mdx +3 -3
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +1 -1
- package/src/docs/compsdocs/senior/Lottery.mdx +3 -6
- package/src/docs/compsdocs/senior/Modal.mdx +2 -3
- package/src/docs/compsdocs/senior/SlotMachine.mdx +2 -5
- package/src/docs/compsdocs/senior/_category_.json +1 -1
- package/src/docs/compsdocs/show/GraphicCard.mdx +0 -1
- package/src/docs/compsdocs/show/Item.mdx +0 -1
- package/src/docs/compsdocs/show/ItemList.mdx +1 -0
- package/src/docs/compsdocs/show/Tabs.mdx +2 -3
- package/src/docs/compsdocs/text/Link.mdx +1 -1
- package/src/docs/compsdocs/text/RichTextView.mdx +1 -2
- package/src/docs/compsdocs/text/Text.mdx +1 -1
- package/src/docs/compsdocs/text/Title.mdx +1 -2
- package/src/docs/compsdocs/wxOpen/Phone.mdx +1 -2
- package/src/docs/compsdocs/wxOpen/Share.mdx +0 -1
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +1 -2
- package/src/mp/components/calendar/index.json +1 -1
- package/src/mp/components/calendar/index.wxml +5 -27
- package/src/mp/components/carousel/index.json +1 -1
- package/src/mp/components/carousel/index.wxml +3 -30
- package/src/mp/components/chart/bar/index.wxml +1 -6
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +2 -19
- package/src/mp/components/chart/line/index.wxml +1 -6
- package/src/mp/components/chart/pie/index.wxml +1 -6
- package/src/mp/components/chart/statisticsCard/index.wxml +1 -5
- package/src/mp/components/dataView/index.wxml +1 -13
- package/src/mp/components/form/checkbox/index.wxml +3 -18
- package/src/mp/components/form/formcell/index.wxss +5 -0
- package/src/mp/components/form/input/index.wxml +3 -16
- package/src/mp/components/form/input/index.wxss +7 -1
- package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.wxml +11 -58
- 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 +7 -43
- package/src/mp/components/form/radio/index.wxml +2 -14
- package/src/mp/components/form/select/index.wxml +3 -33
- package/src/mp/components/form/select/index.wxss +9 -0
- package/src/mp/components/form/switch/index.wxml +2 -13
- package/src/mp/components/form/textarea/index.wxml +4 -23
- package/src/mp/components/form/textarea/index.wxss +5 -0
- package/src/mp/components/form/uploader/index.wxml +2 -20
- package/src/mp/components/form/uploader/weui-uploader.json +6 -6
- package/src/mp/components/form/uploader/weui-uploader.wxml +10 -53
- package/src/mp/components/form/uploaderFile/index.wxml +14 -71
- package/src/mp/components/graphicCard/index.js +9 -11
- package/src/mp/components/graphicCard/index.wxml +6 -34
- package/src/mp/components/image/index.wxml +3 -21
- package/src/mp/components/listView/index.wxml +8 -33
- package/src/mp/components/lottery/index.wxml +7 -31
- package/src/mp/components/navLayout/index.js +9 -12
- package/src/mp/components/navLayout/index.wxml +6 -30
- package/src/mp/components/navigationBar/index.json +1 -2
- package/src/mp/components/navigationBar/index.wxml +29 -146
- package/src/mp/components/swiper/index.wxml +1 -14
- package/src/mp/components/tabs/index.json +1 -1
- package/src/mp/components/tabs/index.wxml +3 -22
- package/src/mp/components/text/index.wxml +1 -7
- 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 +1 -11
- package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +1 -11
- package/src/mp/components/wxOpenApi/share/index.wxml +1 -11
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +1 -10
- package/src/mp/index.json +1 -0
- package/src/mp/style/weda-ui.wxss +12 -4
- package/src/web/actions/showModal/index.tsx +5 -4
- package/src/web/components/calendar/index.css +81 -34
- package/src/web/components/chart/common/core/eChartBase.ts +55 -42
- 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/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 +2 -1
- package/src/web/components/form/formcell/index.css +5 -3
- package/src/web/components/form/formcell/index.tsx +2 -6
- package/src/web/components/form/input/index.css +4 -4
- package/src/web/components/form/input/index.tsx +61 -53
- 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 +0 -1
- 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 +1 -1
- package/src/web/components/form/select/index.css +9 -0
- package/src/web/components/form/select/index.tsx +75 -48
- 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 +26 -25
- package/src/web/components/form/types.d.ts +10 -10
- package/src/web/components/form/uploaderFile/index.jsx +0 -5
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +15 -11
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +14 -9
- 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 +28 -11
- package/src/web/components/index.js +1 -0
- package/src/web/components/link/index.tsx +12 -12
- package/src/web/components/lottery/index.css +43 -37
- package/src/web/components/lottery/index.tsx +2 -2
- package/src/web/components/modal/index.tsx +34 -34
- package/src/web/components/picker/datePicker.tsx +3 -3
- package/src/web/components/picker/picker.tsx +3 -3
- package/src/web/components/richText/index.jsx +41 -46
- 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 +1 -1
- 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/wedaVideo/index.css +42 -0
- package/src/web/components/wedaVideo/index.tsx +198 -0
- package/src/web/utils/constant.ts +2 -1
- package/src/web/utils/loading-fallback.tsx +2 -2
- package/src/web/utils/lodash.ts +1 -1
- package/src/web/utils/useSetState.ts +6 -2
- package/src/web/weda-ui.css +13 -0
|
@@ -2,10 +2,14 @@ import * as React from 'react';
|
|
|
2
2
|
import { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import classNames from '../../utils/classnames';
|
|
4
4
|
import Swipe from 'react-easy-swipe';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
useDebouncedCallback,
|
|
7
|
+
useEventListener,
|
|
8
|
+
useResizeObserver,
|
|
9
|
+
} from '@react-hookz/web';
|
|
6
10
|
|
|
7
11
|
import './index.css';
|
|
8
|
-
import { CommonPropsType } from '../../types';
|
|
12
|
+
import type { CommonPropsType } from '../../types';
|
|
9
13
|
|
|
10
14
|
export interface PropsType extends CommonPropsType {
|
|
11
15
|
/**
|
|
@@ -180,7 +184,16 @@ export default function Swiper({
|
|
|
180
184
|
>
|
|
181
185
|
{itemsClone[itemCount - 1]}
|
|
182
186
|
{React.Children.map(children, (x, i) => {
|
|
183
|
-
return
|
|
187
|
+
return (
|
|
188
|
+
<SwiperItem
|
|
189
|
+
height={height}
|
|
190
|
+
setHeight={setHeight}
|
|
191
|
+
currentIndex={currentIndex}
|
|
192
|
+
index={i}
|
|
193
|
+
>
|
|
194
|
+
{x}
|
|
195
|
+
</SwiperItem>
|
|
196
|
+
);
|
|
184
197
|
})}
|
|
185
198
|
{itemsClone[0]}
|
|
186
199
|
</Swipe>
|
|
@@ -234,21 +247,26 @@ export default function Swiper({
|
|
|
234
247
|
}
|
|
235
248
|
|
|
236
249
|
const SwiperItem: React.FC<{
|
|
237
|
-
setHeight: React.Dispatch<React.SetStateAction<number
|
|
238
|
-
currentIndex: number
|
|
239
|
-
index: number
|
|
240
|
-
height: number
|
|
241
|
-
children?: React.ReactNode
|
|
242
|
-
}> = ({height, setHeight, children, currentIndex, index}) => {
|
|
250
|
+
setHeight: React.Dispatch<React.SetStateAction<number>>;
|
|
251
|
+
currentIndex: number;
|
|
252
|
+
index: number;
|
|
253
|
+
height: number;
|
|
254
|
+
children?: React.ReactNode;
|
|
255
|
+
}> = ({ height, setHeight, children, currentIndex, index }) => {
|
|
243
256
|
const firstChildRef = useRef<HTMLDivElement>(null);
|
|
244
|
-
const syncHeight = useDebouncedCallback(
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
const syncHeight = useDebouncedCallback(
|
|
258
|
+
(e) => {
|
|
259
|
+
setHeight(e.contentRect.height);
|
|
260
|
+
},
|
|
261
|
+
[setHeight],
|
|
262
|
+
500,
|
|
263
|
+
2000
|
|
264
|
+
); // 必须debounce延迟,让resize完成后再设置高度
|
|
247
265
|
|
|
248
266
|
// 因为有loading 所以得用resizeobserver
|
|
249
267
|
// @ts-ignore
|
|
250
268
|
useResizeObserver(firstChildRef, (e) => {
|
|
251
|
-
if(currentIndex === index) {
|
|
269
|
+
if (currentIndex === index) {
|
|
252
270
|
syncHeight(e);
|
|
253
271
|
}
|
|
254
272
|
});
|
|
@@ -263,11 +281,11 @@ const SwiperItem: React.FC<{
|
|
|
263
281
|
<div
|
|
264
282
|
ref={firstChildRef}
|
|
265
283
|
style={{
|
|
266
|
-
height: height > 0 ? '100%' : 'auto'
|
|
284
|
+
height: height > 0 ? '100%' : 'auto',
|
|
267
285
|
}}
|
|
268
286
|
>
|
|
269
287
|
{children}
|
|
270
288
|
</div>
|
|
271
289
|
</div>
|
|
272
290
|
);
|
|
273
|
-
};
|
|
291
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import loadable from '@loadable/component';
|
|
3
|
-
import { CommonPropsType } from '../../types';
|
|
2
|
+
// import loadable from '@loadable/component';
|
|
3
|
+
import type { CommonPropsType } from '../../types';
|
|
4
4
|
import { usePlatform } from '../../utils/platform';
|
|
5
|
-
import { fallback } from '../../utils/loading-fallback';
|
|
5
|
+
// import { fallback } from '../../utils/loading-fallback';
|
|
6
6
|
import TabsH5 from './tabs.h5';
|
|
7
7
|
import TabsPc from './tabs.pc';
|
|
8
8
|
|
|
@@ -17,9 +17,9 @@ export interface PropsType extends CommonPropsType {
|
|
|
17
17
|
// @deprecated
|
|
18
18
|
name?: string;
|
|
19
19
|
}[];
|
|
20
|
-
selectedIndex: number|string
|
|
21
|
-
isMultipleSlot: boolean
|
|
22
|
-
[key: string]: React.ReactNode
|
|
20
|
+
selectedIndex: number | string;
|
|
21
|
+
isMultipleSlot: boolean;
|
|
22
|
+
[key: string]: React.ReactNode;
|
|
23
23
|
// [panel: `panel${number}`]: React.ReactNode; // require typescript@4.4
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -3,8 +3,12 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
3
3
|
import './index.css';
|
|
4
4
|
import classNames from '../../utils/classnames';
|
|
5
5
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
6
|
-
import {PropsType} from './index';
|
|
7
|
-
import {
|
|
6
|
+
import { PropsType } from './index';
|
|
7
|
+
import {
|
|
8
|
+
useCustomCompareEffect,
|
|
9
|
+
usePrevious,
|
|
10
|
+
useSyncedRef,
|
|
11
|
+
} from '@react-hookz/web';
|
|
8
12
|
import isObjectEqual from '../../utils/isObjectEqual';
|
|
9
13
|
|
|
10
14
|
export default function TabsH5({
|
|
@@ -17,27 +21,28 @@ export default function TabsH5({
|
|
|
17
21
|
...restProps
|
|
18
22
|
}: PropsType) {
|
|
19
23
|
const [currentIndex, setCurrentIndex] = useSyncValue(
|
|
20
|
-
typeof selectedIndex === 'string' ?
|
|
21
|
-
parseInt(selectedIndex) : selectedIndex
|
|
24
|
+
typeof selectedIndex === 'string' ? parseInt(selectedIndex) : selectedIndex
|
|
22
25
|
);
|
|
23
26
|
const stickyStyle = useMemo(() => {
|
|
24
27
|
const length = tabs.length;
|
|
25
28
|
return {
|
|
26
|
-
width: `${1 / length * 100}%`,
|
|
27
|
-
transform: `translate3d( ${currentIndex * 100}%, 0, 0)
|
|
29
|
+
width: `${(1 / length) * 100}%`,
|
|
30
|
+
transform: `translate3d( ${currentIndex * 100}%, 0, 0)`,
|
|
28
31
|
};
|
|
29
32
|
}, [tabs, currentIndex]);
|
|
30
33
|
|
|
31
34
|
const eventRef = useSyncedRef(events);
|
|
32
|
-
useCustomCompareEffect(
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
+
useCustomCompareEffect(
|
|
36
|
+
() => {
|
|
37
|
+
eventRef.current.change({
|
|
35
38
|
id: currentIndex,
|
|
36
39
|
label: tabs[currentIndex]?.title,
|
|
37
40
|
value: tabs[currentIndex]?.value,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
[currentIndex, tabs],
|
|
44
|
+
isObjectEqual
|
|
45
|
+
);
|
|
41
46
|
return (
|
|
42
47
|
<div
|
|
43
48
|
data-testid="tabs"
|
|
@@ -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
|
}
|
|
@@ -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,198 @@
|
|
|
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 } 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
|
+
setVideoErrMsg(
|
|
158
|
+
`视频资源加载出错,错误信息:${players?.error().message}`
|
|
159
|
+
);
|
|
160
|
+
setVideoModalStatus(true);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}, [videoRef]);
|
|
164
|
+
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
// 切换视频源
|
|
167
|
+
if (playerRef.current && videoType) {
|
|
168
|
+
let srcOption = [
|
|
169
|
+
{
|
|
170
|
+
src: realSrc,
|
|
171
|
+
type: MimetypesKind[videoType],
|
|
172
|
+
},
|
|
173
|
+
];
|
|
174
|
+
playerRef.current.src(srcOption);
|
|
175
|
+
playerRef.current.load(realSrc);
|
|
176
|
+
}
|
|
177
|
+
}, [realSrc]);
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<ConfigProvider classPrefix="wedatea2td">
|
|
181
|
+
<div className={cls} id={id} style={style} data-testid="wedaVideo">
|
|
182
|
+
<div data-vjs-player>
|
|
183
|
+
<video
|
|
184
|
+
ref={videoRef}
|
|
185
|
+
className={`video-js vjs-big-play-centered ${CLASS_PREFIX}__video-wrap`}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
{videoModalStatus && (
|
|
189
|
+
<div className={`${CLASS_PREFIX}__video-loading`}>
|
|
190
|
+
{realSrc === null ? <Icon type="loading" /> : videoErrMsg}
|
|
191
|
+
</div>
|
|
192
|
+
)}
|
|
193
|
+
</div>
|
|
194
|
+
</ConfigProvider>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
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', // 等于
|
|
@@ -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;
|
|
@@ -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
|
@@ -73,3 +73,16 @@ body .weda-ui {
|
|
|
73
73
|
.weui-picker a:link:hover {
|
|
74
74
|
text-decoration: none;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
.wedatea2td-form.wedatea2td-form--vertical .wedatea2td-form__label label {
|
|
78
|
+
width: auto; /* vertcal 情况下label不固定宽度 */
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.weda-ui .weui-btn_input-clear {
|
|
82
|
+
visibility: hidden; /* visibilty 防止居中而且宽度auto时,出现输入时宽度抖动 */
|
|
83
|
+
display: inline;
|
|
84
|
+
}
|
|
85
|
+
.weui-input:focus:not(:placeholder-shown) + .weui-btn_input-clear {
|
|
86
|
+
visibility: visible;
|
|
87
|
+
display: inline;
|
|
88
|
+
}
|