@cloudbase/weda-ui 2.0.9 → 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.
Files changed (235) hide show
  1. package/README.md +1 -0
  2. package/package.json +13 -5
  3. package/src/configs/components/button.json +60 -13
  4. package/src/configs/components/calendar.json +3 -3
  5. package/src/configs/components/carousel.json +57 -47
  6. package/src/configs/components/chart/bar.json +4 -13
  7. package/src/configs/components/chart/line.json +4 -13
  8. package/src/configs/components/chart/pie.json +3 -10
  9. package/src/configs/components/chart/statisticsCard.json +1 -4
  10. package/src/configs/components/container.json +1 -3
  11. package/src/configs/components/dataView.json +7 -15
  12. package/src/configs/components/drawer.json +24 -6
  13. package/src/configs/components/form/form.json +19 -0
  14. package/src/configs/components/form/input.json +20 -5
  15. package/src/configs/components/form/location.json +51 -48
  16. package/src/configs/components/form/radio.json +1 -3
  17. package/src/configs/components/form/richText.json +14 -14
  18. package/src/configs/components/form/select.json +62 -82
  19. package/src/configs/components/form/textarea.json +6 -1
  20. package/src/configs/components/form/uploader.json +64 -64
  21. package/src/configs/components/form/uploaderFile.json +1 -2
  22. package/src/configs/components/graphicCard.json +43 -44
  23. package/src/configs/components/image.json +44 -40
  24. package/src/configs/components/link.json +5 -10
  25. package/src/configs/components/listView.json +2 -8
  26. package/src/configs/components/lottery.json +7 -3
  27. package/src/configs/components/modal.json +26 -21
  28. package/src/configs/components/navLayout.json +66 -67
  29. package/src/configs/components/navigationBar.json +4 -1
  30. package/src/configs/components/richtextview.json +1 -1
  31. package/src/configs/components/scrollVeiw.json +14 -42
  32. package/src/configs/components/swiper.json +9 -9
  33. package/src/configs/components/wedaVideo.json +86 -0
  34. package/src/configs/components/wxOpenApi/phone.json +7 -21
  35. package/src/configs/components/wxOpenApi/phoneCode.json +7 -19
  36. package/src/configs/components/wxOpenApi/share.json +14 -24
  37. package/src/configs/components/wxOpenApi/userInfo.json +9 -27
  38. package/src/configs/index.js +2 -0
  39. package/src/docs/common/format.tsx +4 -1
  40. package/src/docs/common/tableView.css +3 -3
  41. package/src/docs/common/tableView.tsx +18 -8
  42. package/src/docs/compsdocs/form/FormLocation.mdx +1 -1
  43. package/src/docs/compsdocs/form/FormSelect.mdx +0 -1
  44. package/src/docs/compsdocs/grid/Card.mdx +0 -1
  45. package/src/docs/compsdocs/grid/Container.mdx +0 -1
  46. package/src/docs/compsdocs/grid/GridLayout.mdx +0 -1
  47. package/src/docs/compsdocs/grid/ScrollView.mdx +2 -2
  48. package/src/docs/compsdocs/grid/Swiper.mdx +1 -2
  49. package/src/docs/compsdocs/media/Icon.mdx +1 -1
  50. package/src/docs/compsdocs/media/Image.mdx +6 -6
  51. package/src/docs/compsdocs/model/ModelCreate.mdx +24 -0
  52. package/src/docs/compsdocs/model/ModelDetail.mdx +24 -0
  53. package/src/docs/compsdocs/model/ModelTable.mdx +133 -1
  54. package/src/docs/compsdocs/model/ModelUpdate.mdx +24 -1
  55. package/src/docs/compsdocs/navmenu/Classification.mdx +2 -3
  56. package/src/docs/compsdocs/navmenu/NavBar.mdx +14 -5
  57. package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -1
  58. package/src/docs/compsdocs/navmenu/TabBar.mdx +3 -3
  59. package/src/docs/compsdocs/navmenu/TabBarItem.mdx +1 -1
  60. package/src/docs/compsdocs/senior/Lottery.mdx +3 -6
  61. package/src/docs/compsdocs/senior/Modal.mdx +2 -3
  62. package/src/docs/compsdocs/senior/SlotMachine.mdx +2 -5
  63. package/src/docs/compsdocs/senior/_category_.json +1 -1
  64. package/src/docs/compsdocs/show/GraphicCard.mdx +0 -1
  65. package/src/docs/compsdocs/show/Item.mdx +0 -1
  66. package/src/docs/compsdocs/show/ItemList.mdx +1 -0
  67. package/src/docs/compsdocs/show/Tabs.mdx +2 -3
  68. package/src/docs/compsdocs/text/Link.mdx +1 -1
  69. package/src/docs/compsdocs/text/RichTextView.mdx +1 -2
  70. package/src/docs/compsdocs/text/Text.mdx +1 -1
  71. package/src/docs/compsdocs/text/Title.mdx +1 -2
  72. package/src/docs/compsdocs/wxOpen/Phone.mdx +1 -2
  73. package/src/docs/compsdocs/wxOpen/Share.mdx +0 -1
  74. package/src/docs/compsdocs/wxOpen/UserInfo.mdx +1 -2
  75. package/src/mp/components/button/index.js +1 -1
  76. package/src/mp/components/button/index.wxml +19 -19
  77. package/src/mp/components/calendar/index.js +64 -37
  78. package/src/mp/components/calendar/index.json +1 -1
  79. package/src/mp/components/calendar/index.wxml +4 -6
  80. package/src/mp/components/carousel/index.json +1 -1
  81. package/src/mp/components/carousel/index.wxml +2 -2
  82. package/src/mp/components/chart/bar/index.js +1 -2
  83. package/src/mp/components/chart/bar/index.wxml +1 -1
  84. package/src/mp/components/chart/common/config/bar.js +1 -1
  85. package/src/mp/components/chart/common/core/eChartBar.js +29 -34
  86. package/src/mp/components/chart/common/core/eChartBase.js +46 -32
  87. package/src/mp/components/chart/common/core/eChartLine.js +34 -40
  88. package/src/mp/components/chart/common/core/eChartPie.js +12 -9
  89. package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
  90. package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
  91. package/src/mp/components/chart/line/index.js +2 -2
  92. package/src/mp/components/chart/line/index.wxml +1 -1
  93. package/src/mp/components/chart/pie/index.js +1 -1
  94. package/src/mp/components/chart/pie/index.wxml +1 -2
  95. package/src/mp/components/dataView/index.wxml +2 -14
  96. package/src/mp/components/form/checkbox/index.js +10 -6
  97. package/src/mp/components/form/checkbox/index.wxml +13 -25
  98. package/src/mp/components/form/form/index.wxml +3 -3
  99. package/src/mp/components/form/formcell/index.wxml +9 -9
  100. package/src/mp/components/form/formcell/index.wxss +6 -1
  101. package/src/mp/components/form/input/index.js +3 -3
  102. package/src/mp/components/form/input/index.wxml +24 -31
  103. package/src/mp/components/form/input/index.wxss +9 -3
  104. package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
  105. package/src/mp/components/form/location/components/mapChoose/index.wxml +6 -6
  106. package/src/mp/components/form/location/index.js +7 -1
  107. package/src/mp/components/form/location/index.json +1 -1
  108. package/src/mp/components/form/location/index.wxml +6 -10
  109. package/src/mp/components/form/radio/index.js +9 -5
  110. package/src/mp/components/form/radio/index.wxml +12 -24
  111. package/src/mp/components/form/select/index.js +156 -97
  112. package/src/mp/components/form/select/index.wxml +11 -39
  113. package/src/mp/components/form/select/index.wxss +14 -3
  114. package/src/mp/components/form/select/region/index.js +18 -12
  115. package/src/mp/components/form/switch/index.wxml +11 -18
  116. package/src/mp/components/form/textarea/index.wxml +2 -17
  117. package/src/mp/components/form/textarea/index.wxss +5 -0
  118. package/src/mp/components/form/tips/index.wxml +1 -3
  119. package/src/mp/components/form/uploader/index.js +1 -1
  120. package/src/mp/components/form/uploader/index.wxml +3 -20
  121. package/src/mp/components/form/uploader/weui-uploader.js +210 -200
  122. package/src/mp/components/form/uploader/weui-uploader.json +6 -6
  123. package/src/mp/components/form/uploader/weui-uploader.wxml +38 -38
  124. package/src/mp/components/form/uploaderFile/index.js +5 -4
  125. package/src/mp/components/form/uploaderFile/index.wxml +40 -41
  126. package/src/mp/components/graphicCard/index.js +35 -35
  127. package/src/mp/components/graphicCard/index.wxml +2 -6
  128. package/src/mp/components/image/index.wxml +9 -20
  129. package/src/mp/components/image/index.wxss +3 -1
  130. package/src/mp/components/listView/index.wxml +5 -7
  131. package/src/mp/components/lottery/index.wxml +1 -3
  132. package/src/mp/components/lottery/index.wxss +31 -25
  133. package/src/mp/components/navLayout/index.js +9 -12
  134. package/src/mp/components/navLayout/index.wxml +2 -4
  135. package/src/mp/components/navigationBar/index.json +1 -2
  136. package/src/mp/components/navigationBar/index.wxml +43 -51
  137. package/src/mp/components/swiper/index.wxml +1 -9
  138. package/src/mp/components/tabs/index.js +14 -10
  139. package/src/mp/components/tabs/index.json +1 -1
  140. package/src/mp/components/tabs/index.wxml +3 -21
  141. package/src/mp/components/text/index.wxml +1 -6
  142. package/src/mp/components/text/index.wxss +1 -1
  143. package/src/mp/components/wedaVideo/index.js +86 -0
  144. package/src/mp/components/wedaVideo/index.json +4 -0
  145. package/src/mp/components/wedaVideo/index.wxml +4 -0
  146. package/src/mp/components/wedaVideo/index.wxss +20 -0
  147. package/src/mp/components/wxOpenApi/phone/index.js +1 -9
  148. package/src/mp/components/wxOpenApi/phone/index.wxml +3 -14
  149. package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
  150. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +3 -14
  151. package/src/mp/components/wxOpenApi/share/index.wxml +3 -14
  152. package/src/mp/components/wxOpenApi/userInfo/index.wxml +3 -13
  153. package/src/mp/index.json +1 -0
  154. package/src/mp/style/weda-ui.wxss +20 -7
  155. package/src/mp/utils/deepEqual.js +37 -37
  156. package/src/mp/utils/destr.js +41 -40
  157. package/src/mp/utils/dr_square_point.js +10 -6
  158. package/src/setupTests.js +13 -13
  159. package/src/web/actions/showModal/index.tsx +5 -4
  160. package/src/web/components/button/index.tsx +44 -40
  161. package/src/web/components/calendar/index.css +81 -34
  162. package/src/web/components/carousel/index.tsx +1 -1
  163. package/src/web/components/chart/common/config/bar.js +1 -1
  164. package/src/web/components/chart/common/core/eChartBar.js +28 -34
  165. package/src/web/components/chart/common/core/eChartBase.ts +55 -42
  166. package/src/web/components/chart/common/core/eChartLine.js +34 -40
  167. package/src/web/components/chart/common/core/eChartPie.js +12 -9
  168. package/src/web/components/chart/common/core/type.ts +23 -23
  169. package/src/web/components/chart/common/echart.css +12 -12
  170. package/src/web/components/chart/common/echarts.ts +3 -5
  171. package/src/web/components/chart/common/useChart.tsx +34 -16
  172. package/src/web/components/container/index.tsx +3 -4
  173. package/src/web/components/drawer/index.tsx +15 -4
  174. package/src/web/components/form/checkbox/index.tsx +32 -31
  175. package/src/web/components/form/enumSelect/NormalSelect.tsx +0 -2
  176. package/src/web/components/form/form/index.css +3 -6
  177. package/src/web/components/form/form/index.tsx +7 -6
  178. package/src/web/components/form/formcell/index.css +10 -4
  179. package/src/web/components/form/formcell/index.tsx +3 -7
  180. package/src/web/components/form/input/index.css +4 -4
  181. package/src/web/components/form/input/index.tsx +61 -53
  182. package/src/web/components/form/location/common/selectModal.jsx +2 -11
  183. package/src/web/components/form/location/common/useLocationInfo.js +4 -0
  184. package/src/web/components/form/location/components/LocationH5/index.css +0 -1
  185. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +11 -1
  186. package/src/web/components/form/location/components/LocationPC/Header.jsx +0 -13
  187. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +14 -5
  188. package/src/web/components/form/radio/index.tsx +32 -26
  189. package/src/web/components/form/renderDecorator.tsx +23 -26
  190. package/src/web/components/form/select/h5.tsx +154 -103
  191. package/src/web/components/form/select/index.css +9 -3
  192. package/src/web/components/form/select/index.tsx +75 -48
  193. package/src/web/components/form/select/region/index.ts +101 -80
  194. package/src/web/components/form/select/year.tsx +2 -0
  195. package/src/web/components/form/switch/index.tsx +40 -40
  196. package/src/web/components/form/textarea/index.css +4 -0
  197. package/src/web/components/form/textarea/index.tsx +27 -26
  198. package/src/web/components/form/types.d.ts +10 -10
  199. package/src/web/components/form/uploader/uploader.h5.tsx +26 -20
  200. package/src/web/components/form/uploaderFile/index.jsx +0 -5
  201. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +15 -11
  202. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +14 -9
  203. package/src/web/components/image/image.tsx +2 -2
  204. package/src/web/components/image/index.css +9 -7
  205. package/src/web/components/image/index.tsx +29 -12
  206. package/src/web/components/index.js +1 -0
  207. package/src/web/components/link/index.tsx +13 -13
  208. package/src/web/components/lottery/index.css +43 -37
  209. package/src/web/components/lottery/index.tsx +2 -2
  210. package/src/web/components/modal/index.tsx +34 -34
  211. package/src/web/components/navLayout/index.tsx +1 -1
  212. package/src/web/components/navigationBar/index.tsx +2 -2
  213. package/src/web/components/picker/datePicker.tsx +3 -3
  214. package/src/web/components/picker/picker.tsx +3 -3
  215. package/src/web/components/picker/timePicker.tsx +1 -1
  216. package/src/web/components/richText/index.jsx +41 -46
  217. package/src/web/components/richTextView/index.tsx +4 -6
  218. package/src/web/components/scrollView/index.tsx +2 -2
  219. package/src/web/components/slot/index.tsx +3 -4
  220. package/src/web/components/swiper/index.css +1 -1
  221. package/src/web/components/swiper/index.tsx +33 -15
  222. package/src/web/components/tabs/index.css +1 -1
  223. package/src/web/components/tabs/index.tsx +6 -6
  224. package/src/web/components/tabs/tabs.h5.tsx +17 -12
  225. package/src/web/components/tabs/tabs.pc.tsx +45 -34
  226. package/src/web/components/text/index.css +1 -1
  227. package/src/web/components/text/index.tsx +13 -14
  228. package/src/web/components/wedaVideo/index.css +42 -0
  229. package/src/web/components/wedaVideo/index.tsx +198 -0
  230. package/src/web/utils/constant.ts +2 -1
  231. package/src/web/utils/isObjectEqual.js +2 -1
  232. package/src/web/utils/loading-fallback.tsx +2 -2
  233. package/src/web/utils/lodash.ts +1 -1
  234. package/src/web/utils/useSetState.ts +6 -2
  235. package/src/web/weda-ui.css +17 -0
@@ -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 { useCustomCompareEffect, usePrevious, useSyncedRef } from '@react-hookz/web';
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
- eventRef.current.change(
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
- }, [currentIndex, tabs], isObjectEqual);
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 { useCustomCompareEffect, useMountEffect, useSyncedRef } from '@react-hookz/web';
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 Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
23
- return {
24
- id: index.toString(),
25
- label: item.title,
26
- value: item.value
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
- eventsRef.current && eventsRef.current.change({
34
- id: _tabs[activeIndex]?.id,
35
- label: _tabs[activeIndex]?.label,
36
- value: _tabs[activeIndex]?.value,
37
- });
38
- }, [activeIndex, _tabs], isObjectEqual);
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
- <TeaTabs style={style} tabs={_tabs} activeId={String(activeIndex)} onActive={onActive} className={classNames(
45
- "weda-tabs_pc",
46
- {
47
- [className]: className
48
- }
49
- )}>
50
- {_tabs?.map(
51
- (item, index) => (
52
- <TabPanel
53
- key={item.id}
54
- id={item.id}
55
- >
56
- {isMultipleSlot ? restProps[`panel${index + 1}`] : restProps['panel1']}
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
- </TeaTabs>
61
- </ConfigProvider>
70
+ ))}
71
+ </TeaTabs>
72
+ </ConfigProvider>
62
73
  );
63
74
  }
@@ -23,4 +23,4 @@
23
23
  }
24
24
  .weda-text.level_6 {
25
25
  font-size: 24px !important;
26
- }
26
+ }
@@ -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 = (level === '0' || !level) ? '' : `level_${level}`;
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,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 = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNMjUuMzIgMTYuMzU5N0MyNi4wNzY0IDE2LjM1OTcgMjYuODI1NCAxNi41MDg3IDI3LjUyNDMgMTYuNzk4MUMyOC4yMjMxIDE3LjA4NzYgMjguODU4MSAxNy41MTE5IDI5LjM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,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)) { // for Proxy created by mbox
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 "react";
2
- export const fallback = <div>组件加载中...</div>;
1
+ import * as React from 'react';
2
+ export const fallback = <div>组件加载中...</div>;
@@ -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 (null | undefined) => val == null;
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({}, prevState, patch instanceof Function ? patch(prevState) : patch)
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
+ };
@@ -69,3 +69,20 @@ body .weda-ui {
69
69
  .weda-ui .weui-cell {
70
70
  font-size: 16px; /* 修改默认weui的17为16 */
71
71
  }
72
+
73
+ .weui-picker a:link:hover {
74
+ text-decoration: none;
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
+ }