@cloudbase/weda-ui 0.2.17 → 2.0.8

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 (269) hide show
  1. package/README.md +3 -0
  2. package/package.json +10 -5
  3. package/src/configs/components/button.json +0 -2
  4. package/src/configs/components/calendar.json +9 -3
  5. package/src/configs/components/carousel.json +18 -9
  6. package/src/configs/components/chart/bar.json +31 -12
  7. package/src/configs/components/chart/line.json +27 -10
  8. package/src/configs/components/chart/pie.json +22 -8
  9. package/src/configs/components/chart/statisticsCard.json +61 -13
  10. package/src/configs/components/container.json +7 -2
  11. package/src/configs/components/dataView.json +31 -11
  12. package/src/configs/components/form/checkbox.json +97 -5
  13. package/src/configs/components/form/radio.json +123 -4
  14. package/src/configs/components/form/select.json +247 -13
  15. package/src/configs/components/graphicCard.json +90 -75
  16. package/src/configs/components/image.json +19 -8
  17. package/src/configs/components/link.json +25 -6
  18. package/src/configs/components/listView.json +83 -27
  19. package/src/configs/components/lottery.json +153 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +97 -79
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +6 -2
  24. package/src/configs/components/scrollVeiw.json +98 -34
  25. package/src/configs/components/swiper.json +22 -10
  26. package/src/configs/components/tabs.json +54 -9
  27. package/src/configs/components/text.json +43 -30
  28. package/src/configs/components/wxOpenApi/phone.json +141 -0
  29. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  30. package/src/configs/components/wxOpenApi/share.json +167 -0
  31. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  32. package/src/configs/index.js +13 -0
  33. package/src/docs/common/format.tsx +112 -0
  34. package/src/docs/common/tableView.css +164 -0
  35. package/src/docs/common/tableView.tsx +273 -0
  36. package/src/docs/compsdocs/chart/Bar.mdx +159 -0
  37. package/src/docs/compsdocs/chart/Line.mdx +100 -0
  38. package/src/docs/compsdocs/chart/Pie.mdx +83 -0
  39. package/src/docs/compsdocs/chart/_category_.json +1 -0
  40. package/src/docs/compsdocs/chart/statisticsCard.mdx +51 -0
  41. package/src/docs/compsdocs/database/DataView.mdx +33 -0
  42. package/src/docs/compsdocs/database/ListView.mdx +33 -0
  43. package/src/docs/compsdocs/database/_category_.json +1 -0
  44. package/src/docs/compsdocs/form/Form.mdx +35 -0
  45. package/src/docs/compsdocs/form/FormCheckbox.mdx +35 -0
  46. package/src/docs/compsdocs/form/FormDate.mdx +30 -0
  47. package/src/docs/compsdocs/form/FormEmail.mdx +30 -0
  48. package/src/docs/compsdocs/form/FormImageUploader.mdx +31 -0
  49. package/src/docs/compsdocs/form/FormInput.mdx +30 -0
  50. package/src/docs/compsdocs/form/FormLocation.mdx +64 -0
  51. package/src/docs/compsdocs/form/FormPhone.mdx +30 -0
  52. package/src/docs/compsdocs/form/FormRadio.mdx +35 -0
  53. package/src/docs/compsdocs/form/FormRegion.mdx +30 -0
  54. package/src/docs/compsdocs/form/FormSelect.mdx +36 -0
  55. package/src/docs/compsdocs/form/FormSwitch.mdx +30 -0
  56. package/src/docs/compsdocs/form/FormTextarea.mdx +30 -0
  57. package/src/docs/compsdocs/form/FormTime.mdx +30 -0
  58. package/src/docs/compsdocs/form/FormUploadFile.mdx +30 -0
  59. package/src/docs/compsdocs/form/FormUrl.mdx +30 -0
  60. package/src/docs/compsdocs/form/_category_.json +1 -0
  61. package/src/docs/compsdocs/grid/Card.mdx +32 -0
  62. package/src/docs/compsdocs/grid/Container.mdx +42 -0
  63. package/src/docs/compsdocs/grid/Footer.mdx +31 -0
  64. package/src/docs/compsdocs/grid/GridLayout.mdx +32 -0
  65. package/src/docs/compsdocs/grid/Header.mdx +31 -0
  66. package/src/docs/compsdocs/grid/Layout.mdx +25 -0
  67. package/src/docs/compsdocs/grid/List.mdx +31 -0
  68. package/src/docs/compsdocs/grid/ScrollView.mdx +37 -0
  69. package/src/docs/compsdocs/grid/Swiper.mdx +58 -0
  70. package/src/docs/compsdocs/grid/_category_.json +1 -0
  71. package/src/docs/compsdocs/media/Icon.mdx +31 -0
  72. package/src/docs/compsdocs/media/Image.mdx +55 -0
  73. package/src/docs/compsdocs/media/_category_.json +1 -0
  74. package/src/docs/compsdocs/model/ModelCreate.mdx +20 -0
  75. package/src/docs/compsdocs/model/ModelDetail.mdx +20 -0
  76. package/src/docs/compsdocs/model/ModelTable.mdx +24 -0
  77. package/src/docs/compsdocs/model/ModelUpdate.mdx +21 -0
  78. package/src/docs/compsdocs/model/PageLayout.mdx +21 -0
  79. package/src/docs/compsdocs/model/_category_.json +1 -0
  80. package/src/docs/compsdocs/navmenu/Classification.mdx +38 -0
  81. package/src/docs/compsdocs/navmenu/NavBar.mdx +43 -0
  82. package/src/docs/compsdocs/navmenu/NavLayout.mdx +30 -0
  83. package/src/docs/compsdocs/navmenu/TabBar.mdx +43 -0
  84. package/src/docs/compsdocs/navmenu/TabBarItem.mdx +29 -0
  85. package/src/docs/compsdocs/navmenu/_category_.json +1 -0
  86. package/src/docs/compsdocs/senior/Lottery.mdx +48 -0
  87. package/src/docs/compsdocs/senior/Modal.mdx +58 -0
  88. package/src/docs/compsdocs/senior/SlotMachine.mdx +52 -0
  89. package/src/docs/compsdocs/senior/_category_.json +1 -0
  90. package/src/docs/compsdocs/show/Calendar.mdx +29 -0
  91. package/src/docs/compsdocs/show/Divider.mdx +31 -0
  92. package/src/docs/compsdocs/show/GraphicCard.mdx +30 -0
  93. package/src/docs/compsdocs/show/Item.mdx +32 -0
  94. package/src/docs/compsdocs/show/ItemList.mdx +47 -0
  95. package/src/docs/compsdocs/show/Media.mdx +25 -0
  96. package/src/docs/compsdocs/show/StatusTip.mdx +25 -0
  97. package/src/docs/compsdocs/show/Swiper.mdx +33 -0
  98. package/src/docs/compsdocs/show/Tabs.mdx +38 -0
  99. package/src/docs/compsdocs/show/_category_.json +1 -0
  100. package/src/docs/compsdocs/show/button.mdx +25 -0
  101. package/src/docs/compsdocs/text/Link.mdx +43 -0
  102. package/src/docs/compsdocs/text/RichTextView.mdx +36 -0
  103. package/src/docs/compsdocs/text/Text.mdx +31 -0
  104. package/src/docs/compsdocs/text/Title.mdx +32 -0
  105. package/src/docs/compsdocs/text/_category_.json +1 -0
  106. package/src/docs/compsdocs/wxOpen/Phone.mdx +60 -0
  107. package/src/docs/compsdocs/wxOpen/Share.mdx +46 -0
  108. package/src/docs/compsdocs/wxOpen/UserInfo.mdx +60 -0
  109. package/src/docs/compsdocs/wxOpen/_category_.json +4 -0
  110. package/src/index.js +2 -0
  111. package/src/mp/components/button/index.js +18 -2
  112. package/src/mp/components/button/index.wxml +7 -4
  113. package/src/mp/components/chart/bar/index.js +6 -2
  114. package/src/mp/components/chart/common/core/eChartBar.js +9 -8
  115. package/src/mp/components/chart/common/core/eChartBase.js +20 -16
  116. package/src/mp/components/chart/common/core/eChartLine.js +6 -5
  117. package/src/mp/components/chart/line/index.js +10 -6
  118. package/src/mp/components/chart/pie/index.js +6 -2
  119. package/src/mp/components/chart/statisticsCard/index.js +33 -6
  120. package/src/mp/components/dataView/index.json +1 -1
  121. package/src/mp/components/form/checkbox/index.js +41 -2
  122. package/src/mp/components/form/checkbox/index.wxml +1 -1
  123. package/src/mp/components/form/form/index.wxml +1 -2
  124. package/src/mp/components/form/formcell/index.wxml +1 -1
  125. package/src/mp/components/form/formcell/index.wxss +17 -0
  126. package/src/mp/components/form/input/index.js +1 -1
  127. package/src/mp/components/form/input/index.wxss +15 -0
  128. package/src/mp/components/form/location/index.js +43 -2
  129. package/src/mp/components/form/location/index.wxss +4 -6
  130. package/src/mp/components/form/radio/index.js +34 -1
  131. package/src/mp/components/form/select/index.js +351 -41
  132. package/src/mp/components/form/select/index.wxml +17 -2
  133. package/src/mp/components/form/select/index.wxss +4 -0
  134. package/src/mp/components/form/select/region/index.js +101 -0
  135. package/src/mp/components/form/textarea/index.js +1 -1
  136. package/src/mp/components/form/textarea/index.wxss +4 -0
  137. package/src/mp/components/form/uploader/index.js +39 -27
  138. package/src/mp/components/form/uploader/index.json +3 -2
  139. package/src/mp/components/form/uploader/index.wxml +11 -7
  140. package/src/mp/components/form/uploader/index.wxss +20 -2
  141. package/src/mp/components/form/uploader/weui-uploader.js +209 -0
  142. package/src/mp/components/form/uploader/weui-uploader.json +7 -0
  143. package/src/mp/components/form/uploader/weui-uploader.wxml +45 -0
  144. package/src/mp/components/form/uploader/weui-uploader.wxss +1 -0
  145. package/src/mp/components/form/uploaderFile/index.js +10 -6
  146. package/src/mp/components/form/uploaderFile/index.wxss +4 -4
  147. package/src/mp/components/image/index.wxss +3 -2
  148. package/src/mp/components/listView/index.js +38 -43
  149. package/src/mp/components/listView/index.wxml +1 -1
  150. package/src/mp/components/listView/index.wxss +5 -0
  151. package/src/mp/components/lottery/index.js +270 -0
  152. package/src/mp/components/{internals/listView → lottery}/index.json +0 -0
  153. package/src/mp/components/lottery/index.wxml +43 -0
  154. package/src/mp/components/lottery/index.wxss +317 -0
  155. package/src/mp/components/navigationBar/index.js +193 -0
  156. package/src/mp/components/navigationBar/index.json +6 -0
  157. package/src/mp/components/navigationBar/index.wxml +88 -0
  158. package/src/mp/components/navigationBar/index.wxss +1257 -0
  159. package/src/mp/components/tabs/index.js +7 -2
  160. package/src/mp/components/tabs/index.wxml +2 -1
  161. package/src/mp/components/text/index.js +0 -25
  162. package/src/mp/components/text/index.wxml +3 -3
  163. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  164. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  165. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  166. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  167. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  168. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  169. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  170. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  171. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  172. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  173. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  174. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  175. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  176. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  177. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  178. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  179. package/src/mp/index.json +7 -1
  180. package/src/mp/style/weda-ui.wxss +16 -0
  181. package/src/mp/utils/constant.js +15 -0
  182. package/src/mp/utils/destr.js +48 -0
  183. package/src/mp/utils/lodash.js +2 -0
  184. package/src/mp/utils/platform.js +10 -0
  185. package/src/mp/utils/tcb.js +44 -0
  186. package/src/web/components/button/index.css +8 -1
  187. package/src/web/components/button/index.tsx +10 -9
  188. package/src/web/components/calendar/index.jsx +1 -1
  189. package/src/web/components/carousel/index.tsx +8 -8
  190. package/src/web/components/chart/bar/index.tsx +40 -39
  191. package/src/web/components/chart/common/config/line.js +1 -1
  192. package/src/web/components/chart/common/core/eChartBar.js +7 -6
  193. package/src/web/components/chart/common/core/eChartBase.ts +20 -16
  194. package/src/web/components/chart/common/core/eChartLine.js +8 -6
  195. package/src/web/components/chart/line/index.tsx +40 -39
  196. package/src/web/components/chart/statisticsCard/index.tsx +29 -8
  197. package/src/web/components/form/checkbox/index.tsx +61 -23
  198. package/src/web/components/form/form/index.css +5 -1
  199. package/src/web/components/form/form/index.tsx +3 -1
  200. package/src/web/components/form/formcell/index.css +22 -1
  201. package/src/web/components/form/formcell/index.tsx +11 -6
  202. package/src/web/components/form/input/index.css +7 -12
  203. package/src/web/components/form/location/components/LocationH5/index.css +4 -7
  204. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +1 -1
  205. package/src/web/components/form/radio/index.tsx +90 -53
  206. package/src/web/components/form/select/h5.tsx +370 -73
  207. package/src/web/components/form/select/index.css +15 -0
  208. package/src/web/components/form/select/index.tsx +392 -145
  209. package/src/web/components/form/select/region/index.ts +122 -31
  210. package/src/web/components/form/select/time.jsx +89 -0
  211. package/src/web/components/form/select/year.tsx +170 -0
  212. package/src/web/components/form/textarea/index.css +4 -0
  213. package/src/web/components/form/textarea/index.tsx +2 -2
  214. package/src/web/components/form/tips/index.css +4 -0
  215. package/src/web/components/form/tips/index.tsx +4 -3
  216. package/src/web/components/form/uploader/index.css +26 -2
  217. package/src/web/components/form/uploader/uploader.h5.tsx +89 -57
  218. package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
  219. package/src/web/components/form/uploaderFile/index.css +2 -4
  220. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
  221. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
  222. package/src/web/components/image/image.tsx +1 -1
  223. package/src/web/components/image/index.css +3 -3
  224. package/src/web/components/image/index.tsx +6 -7
  225. package/src/web/components/index.js +8 -0
  226. package/src/web/components/link/index.tsx +7 -4
  227. package/src/web/components/listView/index.css +4 -0
  228. package/src/web/components/listView/index.tsx +12 -20
  229. package/src/web/components/lottery/index.css +327 -0
  230. package/src/web/components/lottery/index.tsx +567 -0
  231. package/src/web/components/lottery/lotteryUtil.ts +130 -0
  232. package/src/web/components/modal/index.tsx +3 -1
  233. package/src/web/components/navLayout/index.tsx +2 -2
  234. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  235. package/src/web/components/navigationBar/common.tsx +198 -0
  236. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  237. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  238. package/src/web/components/navigationBar/index.css +762 -0
  239. package/src/web/components/navigationBar/index.tsx +230 -0
  240. package/src/web/components/navigationBar/type.d.ts +111 -0
  241. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  242. package/src/web/components/phone/index.css +0 -0
  243. package/src/web/components/phone/index.tsx +22 -0
  244. package/src/web/components/phoneCode/index.css +0 -0
  245. package/src/web/components/phoneCode/index.tsx +22 -0
  246. package/src/web/components/picker/timePicker.tsx +2 -2
  247. package/src/web/components/richTextView/index.tsx +3 -5
  248. package/src/web/components/share/index.css +0 -0
  249. package/src/web/components/share/index.tsx +38 -0
  250. package/src/web/components/slot/index.tsx +1 -1
  251. package/src/web/components/tabs/index.tsx +2 -0
  252. package/src/web/components/tabs/tabs.h5.tsx +43 -33
  253. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  254. package/src/web/components/text/index.tsx +12 -20
  255. package/src/web/components/userInfo/index.css +0 -0
  256. package/src/web/components/userInfo/index.tsx +30 -0
  257. package/src/web/utils/{constant.js → constant.ts} +17 -2
  258. package/src/web/utils/lodash.ts +2 -0
  259. package/src/web/utils/platform.js +9 -0
  260. package/src/web/utils/tcb.js +26 -0
  261. package/src/web/weda-ui.css +7 -1
  262. package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
  263. package/src/mp/components/internals/listView/index.js +0 -286
  264. package/src/mp/components/internals/listView/index.wxml +0 -40
  265. package/src/mp/components/internals/listView/index.wxss +0 -150
  266. package/src/mp/components/internals/listView/more-line.svg +0 -3
  267. package/src/web/components/form/select/region/cities.ts +0 -2410
  268. package/src/web/components/form/select/region/provinces.ts +0 -240
  269. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,230 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { CommonPropsType } from '../../types';
3
+ import classNames from '../../utils/classnames';
4
+ import { ConfigProvider } from 'tea-component';
5
+ import { usePlatform, isInIde } from '../../utils/platform';
6
+ import { getAppCustomNav } from '../../utils/tcb';
7
+ import { IMenuItem, INavigationStyle } from './type';
8
+ import './index.css';
9
+ import VerticalMenu from './verticalMenu';
10
+ import HorizontalMenu from './horizontalMenu';
11
+ import H5Menu from './h5Menu';
12
+ import { expandMenu, findMenuItemByPath } from './common';
13
+ import destr from 'destr';
14
+ /**
15
+ * Web端
16
+ */
17
+ const CLASS_PREFIX = 'weda-menu';
18
+
19
+ // 默认导航数据
20
+ const defaultNavigationBar: {
21
+ navigationStyle: INavigationStyle;
22
+ menuData: IMenuItem[];
23
+ } = {
24
+ menuData: [],
25
+ navigationStyle: {
26
+ isHorizontal: false,
27
+ showMenuIcon: true,
28
+ menuFontSize: 16,
29
+ menuBackgroundColor: '#fff',
30
+ menuColor: '#000',
31
+ menuHoverColor: '#f3f3f3',
32
+ showTitle: true,
33
+ title: '菜单标题',
34
+ showLogo: true,
35
+ logoUrl:
36
+ 'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg',
37
+ titleFontSize: 18,
38
+ titleColor: '#000',
39
+ logoWidth: 32,
40
+ logoHeight: 32,
41
+ },
42
+ };
43
+ // 默认高亮当前路由对应的菜单
44
+ const defaultSelectedMenu = (menu: IMenuItem[]) => {
45
+ try {
46
+ const url = window.location.href;
47
+ let selectedKey = url.substring(url.lastIndexOf('/'));
48
+ const targetMenu = findMenuItemByPath(menu, selectedKey);
49
+ if (targetMenu) {
50
+ selectedKey = targetMenu.key;
51
+ }
52
+ return selectedKey;
53
+ } catch (error) {
54
+ return '';
55
+ }
56
+ };
57
+ /**
58
+ * 导航菜单
59
+ */
60
+ export default function NavigationBar({
61
+ navigationbar,
62
+ contentSlot,
63
+ className,
64
+ style,
65
+ callApi = { getAppCustomNav },
66
+ }: PropsType) {
67
+ const platform = usePlatform();
68
+ const [menuData, setMenuData] = useState<IMenuItem[]>([]);
69
+ const [mobileMenuData, setMobileMenuData] = useState<IMenuItem[]>([]);
70
+ // 是否启用多端
71
+ const [isMultiTerminal, setIsMultiTerminal] = useState(false);
72
+ const [navigationStyle, setNavigationStyle] = useState<INavigationStyle>(
73
+ defaultNavigationBar.navigationStyle
74
+ );
75
+ // 菜单选中
76
+ const [selected, setSelected] = useState<string>('');
77
+ // 导航样式
78
+ const { isHorizontal = false } = navigationStyle;
79
+ const cls = classNames({
80
+ [CLASS_PREFIX]: true,
81
+ [className]: className,
82
+ [`${CLASS_PREFIX}-mobile`]: platform === 'h5',
83
+ [`${CLASS_PREFIX}-horizontal`]: isHorizontal,
84
+ });
85
+ // 导航容器样式
86
+ const navigationWrapStyle: React.CSSProperties = {
87
+ display: 'flex',
88
+ height: '100vh',
89
+ flexDirection: isHorizontal || platform === 'h5' ? 'column' : 'row',
90
+ position: 'relative',
91
+ ...style,
92
+ };
93
+
94
+ // 更新导航菜单
95
+ const updateNavigationData = () => {
96
+ callApi
97
+ .getAppCustomNav()
98
+ .then((res) => {
99
+ const { Content } = res;
100
+ const navigationData = destr(Content);
101
+ if (navigationData?.navigationStyle) {
102
+ // 设置默认选中
103
+ let selectedKey = '';
104
+ if (navigationData?.menuData?.length) {
105
+ selectedKey = defaultSelectedMenu(navigationData?.menuData);
106
+ }
107
+ setSelected(selectedKey);
108
+
109
+ // 设置默认展开状态
110
+ let menus = navigationData?.menuData || [];
111
+ menus = expandMenu(menus, { key: selectedKey }, true);
112
+ setMenuData(menus);
113
+ setNavigationStyle({
114
+ ...defaultNavigationBar.navigationStyle,
115
+ ...navigationData?.navigationStyle,
116
+ });
117
+ // 如果启用多端独立菜单导航,则设置移动端数据
118
+ if (navigationData?.isMultiTerminal) {
119
+ let mobileMenus = navigationData?.mobileMenuData || [];
120
+ mobileMenus = expandMenu(mobileMenus, { key: selectedKey }, true);
121
+ setMobileMenuData(mobileMenus);
122
+ setIsMultiTerminal(true);
123
+ }
124
+ }
125
+ })
126
+ .catch((error) => {
127
+ console.log(error);
128
+ });
129
+ };
130
+ /**
131
+ * 每次渲染组件通过接口拉取数据
132
+ */
133
+ useEffect(() => {
134
+ updateNavigationData();
135
+ }, []);
136
+ useEffect(() => {
137
+ if (isInIde()) {
138
+ // setMenuData(navigationbar?.menuData);
139
+ // setNavigationStyle(navigationbar?.navigationStyle);
140
+ updateNavigationData();
141
+ }
142
+ }, [navigationbar]);
143
+
144
+ // 初始化css变量
145
+ useEffect(() => {
146
+ if (navigationStyle.menuHoverColor) {
147
+ const body = document.getElementsByTagName('body')[0];
148
+ if (body) {
149
+ body.style.setProperty(
150
+ '--weda-navigation-menu-hover-color',
151
+ navigationStyle.menuHoverColor
152
+ );
153
+ body.style.setProperty(
154
+ '--weda-navigation-menu-selected-color',
155
+ navigationStyle.menuHoverColor
156
+ );
157
+ body.style.setProperty(
158
+ '--weda-navigation-menu-background-color',
159
+ navigationStyle.menuBackgroundColor
160
+ );
161
+ }
162
+ }
163
+ }, [navigationStyle.menuHoverColor, navigationStyle.menuBackgroundColor]);
164
+
165
+ const renderMenu = () => {
166
+ return (
167
+ <>
168
+ <div
169
+ className={cls}
170
+ style={navigationWrapStyle}
171
+ data-testid="navigationBar"
172
+ >
173
+ <div
174
+ className={`${CLASS_PREFIX}__wrapper`}
175
+ style={{
176
+ background: navigationStyle?.menuBackgroundColor || '#fff',
177
+ }}
178
+ >
179
+ {platform !== 'h5' && !isHorizontal && (
180
+ <VerticalMenu
181
+ menuData={menuData}
182
+ navigationStyle={navigationStyle}
183
+ setMenuData={setMenuData}
184
+ selected={selected}
185
+ setSelected={setSelected}
186
+ />
187
+ )}
188
+ {platform !== 'h5' && isHorizontal && (
189
+ <HorizontalMenu
190
+ menuData={menuData}
191
+ navigationStyle={navigationStyle}
192
+ selected={selected}
193
+ setSelected={setSelected}
194
+ />
195
+ )}
196
+ {platform === 'h5' && (
197
+ <H5Menu
198
+ menuData={isMultiTerminal ? mobileMenuData : menuData}
199
+ navigationStyle={navigationStyle}
200
+ setMenuData={setMenuData}
201
+ className={className}
202
+ selected={selected}
203
+ setSelected={setSelected}
204
+ />
205
+ )}
206
+ </div>
207
+ <div className="menu-solt">{contentSlot}</div>
208
+ </div>
209
+ </>
210
+ );
211
+ };
212
+
213
+ return (
214
+ <ConfigProvider classPrefix="wedatea2td">
215
+ {!isInIde() &&
216
+ (menuData?.length > 0 || mobileMenuData?.length > 0) &&
217
+ renderMenu()}
218
+ {isInIde() && renderMenu()}
219
+ </ConfigProvider>
220
+ );
221
+ }
222
+
223
+ export interface PropsType extends CommonPropsType {
224
+ contentSlot?: string;
225
+ navigationbar: {
226
+ navigationStyle: INavigationStyle;
227
+ menuData: IMenuItem[];
228
+ };
229
+ callApi: any;
230
+ }
@@ -0,0 +1,111 @@
1
+ export interface IMenuItem {
2
+ /**
3
+ * 节点的 id
4
+ */
5
+ key: string;
6
+
7
+ /**
8
+ * 菜单标题
9
+ */
10
+ title?: string | any;
11
+
12
+ /**
13
+ * 菜单类型
14
+ * group 分组
15
+ * link 外链菜单
16
+ * basemenu 无链接菜单
17
+ * route 内链菜单
18
+ */
19
+ type?: string;
20
+
21
+ /**
22
+ * 是否外跳
23
+ */
24
+ linkTargetBlank?: boolean;
25
+ /**
26
+ * 路由路径
27
+ */
28
+ path?: string;
29
+ /**
30
+ * 外部链接
31
+ */
32
+ linkUrl?: string;
33
+ /**
34
+ * 图标链接
35
+ */
36
+ iconUrl?: string;
37
+
38
+ /**
39
+ * 子菜单
40
+ */
41
+ children?: IMenuItem[];
42
+
43
+ /**
44
+ * 层级
45
+ */
46
+ level: number;
47
+
48
+ /**
49
+ * 展开状态
50
+ */
51
+ opened?: boolean;
52
+ }
53
+
54
+ export interface INavigationStyle {
55
+ /**
56
+ * 是否横向菜单
57
+ */
58
+ isHorizontal: boolean;
59
+ /**
60
+ * 是否展示菜单图标
61
+ */
62
+ showMenuIcon: boolean;
63
+ /**
64
+ * 菜单字号
65
+ */
66
+ menuFontSize: number;
67
+ /**
68
+ * 菜单背景色
69
+ */
70
+ menuBackgroundColor: string;
71
+ /**
72
+ * 菜单字体颜色
73
+ */
74
+ menuColor: string;
75
+ /**
76
+ * 菜单选中颜色
77
+ */
78
+ menuHoverColor: string;
79
+ /**
80
+ * 标题
81
+ */
82
+ showTitle: boolean;
83
+ /**
84
+ * 名称
85
+ */
86
+ title: string;
87
+ /**
88
+ * 是否展示图标
89
+ */
90
+ showLogo: boolean;
91
+ /**
92
+ * 图标地址
93
+ */
94
+ logoUrl: string;
95
+ /**
96
+ * 标题字号
97
+ */
98
+ titleFontSize: number;
99
+ /**
100
+ * 标题颜色
101
+ */
102
+ titleColor: string;
103
+ /**
104
+ * 图标宽度
105
+ */
106
+ logoWidth: number;
107
+ /**
108
+ * 图标高度
109
+ */
110
+ logoHeight: number;
111
+ }
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import { Menu } from 'tea-component';
3
+ import { IMenuItem, INavigationStyle } from './type';
4
+ import {
5
+ renderMenuTitle,
6
+ renderLogo,
7
+ renderTitle,
8
+ navigateTo,
9
+ expandMenu,
10
+ } from './common';
11
+ const CLASS_PREFIX = 'weda-menu';
12
+
13
+ /**
14
+ * pc端纵向导航
15
+ */
16
+ const VerticalMenu: React.FC<{
17
+ menuData: IMenuItem[];
18
+ navigationStyle: INavigationStyle;
19
+ setMenuData: (menus: IMenuItem[]) => void;
20
+ selected: string;
21
+ setSelected: (selectedKey: string) => void;
22
+ }> = ({ menuData, navigationStyle, setMenuData, selected, setSelected }) => {
23
+ // 菜单背景色
24
+ const menuStyle: React.CSSProperties = {
25
+ background: navigationStyle.menuBackgroundColor || '#fff',
26
+ };
27
+ // 渲染subMenu
28
+ const renderSubMenu = (item: IMenuItem, hasThereNode = false) => {
29
+ const { key, children, opened } = item;
30
+ return children.length > 0 ? (
31
+ <Menu.SubMenu
32
+ className={hasThereNode ? `${CLASS_PREFIX}__submenu` : ''}
33
+ key={key}
34
+ title={renderMenuTitle(navigationStyle, item, true)}
35
+ opened={opened}
36
+ onOpenedChange={(opened) => {
37
+ const menus = expandMenu(menuData, { ...item, opened });
38
+ setMenuData(menus);
39
+ }}
40
+ >
41
+ {children?.map((el: any) => renderSubMenu(el, true))}
42
+ </Menu.SubMenu>
43
+ ) : (
44
+ renderMenuItem(item)
45
+ );
46
+ };
47
+ // 渲染MenuItem
48
+ const renderMenuItem = (item: IMenuItem) => {
49
+ const { key } = item;
50
+ return (
51
+ <Menu.Item
52
+ key={key}
53
+ title={renderMenuTitle(navigationStyle, item, true)}
54
+ selected={item.key === selected}
55
+ onClick={() => {
56
+ if (item.key !== selected) {
57
+ setSelected(item.key);
58
+ navigateTo(item);
59
+ }
60
+ }}
61
+ />
62
+ );
63
+ };
64
+
65
+ return (
66
+ <Menu
67
+ style={menuStyle}
68
+ className={`${CLASS_PREFIX}__menu-content`}
69
+ title={renderTitle(navigationStyle) || ' '}
70
+ icon={renderLogo(navigationStyle, `${CLASS_PREFIX}__main-icon`)}
71
+ >
72
+ {menuData?.map((item: any) => {
73
+ return item?.children?.length > 0
74
+ ? renderSubMenu(item)
75
+ : renderMenuItem(item);
76
+ })}
77
+ </Menu>
78
+ );
79
+ };
80
+
81
+ export default VerticalMenu;
File without changes
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import Button from '../../components/button';
3
+ import { CommonPropsType } from '../../types';
4
+
5
+ const Phone = (props: PropsType) => <Button {...props} />;
6
+
7
+ export interface PropsType extends CommonPropsType {
8
+ /**
9
+ * 按钮标题
10
+ */
11
+ text?: string;
12
+ /**
13
+ * 按钮风格
14
+ */
15
+ type?: 'primary' | 'warn' | 'wechat' | 'default';
16
+ /**
17
+ * 按钮大小
18
+ */
19
+ size?: 'default' | 'mini' | 'large';
20
+ }
21
+
22
+ export default Phone;
File without changes
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import Button from '../../components/button';
3
+ import { CommonPropsType } from '../../types';
4
+
5
+ const PhoneCode = (props: PropsType) => <Button {...props} />;
6
+
7
+ export interface PropsType extends CommonPropsType {
8
+ /**
9
+ * 按钮标题
10
+ */
11
+ text?: string;
12
+ /**
13
+ * 按钮风格
14
+ */
15
+ type?: 'primary' | 'warn' | 'wechat' | 'default';
16
+ /**
17
+ * 按钮大小
18
+ */
19
+ size?: 'default' | 'mini' | 'large';
20
+ }
21
+
22
+ export default PhoneCode;
@@ -9,7 +9,7 @@ export interface PropsType extends CommonPropsType {
9
9
  title?: string;
10
10
  }
11
11
  export default function TimePicker(props: PropsType) {
12
- const { title = '时间', defaultValue = '', children, className } = props;
12
+ const { title, defaultValue = '', children, className } = props;
13
13
 
14
14
  const click = function () {
15
15
  const hour = [];
@@ -53,4 +53,4 @@ export default function TimePicker(props: PropsType) {
53
53
  {children}
54
54
  </div>
55
55
  );
56
- }
56
+ }
@@ -4,6 +4,7 @@ import { getTempFileURL } from '../../utils/tcb';
4
4
  import './index.css';
5
5
  import { LOAD_ERR_IMG_BASE64 } from '../../utils/constant';
6
6
  import { CommonPropsType } from '../../types';
7
+ import destr from 'destr';
7
8
 
8
9
  export interface PropsType extends CommonPropsType {
9
10
  value: string
@@ -15,10 +16,7 @@ export default function RichTextView({
15
16
  style,
16
17
  id
17
18
  }: PropsType) {
18
- let parseValue = value;
19
- try {
20
- parseValue = JSON.parse(value);
21
- } catch (e) {}
19
+ let parseValue = destr(value);
22
20
  const cls = classNames({
23
21
  'weda-ui': true,
24
22
  'weda-RichTextView': true,
@@ -64,4 +62,4 @@ export default function RichTextView({
64
62
  </div>
65
63
  )
66
64
  );
67
- }
65
+ }
File without changes
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import Button from '../../components/button';
3
+ import { CommonPropsType } from '../../types';
4
+
5
+ const Share = (props: PropsType) => <Button {...props} />;
6
+
7
+ export interface PropsType extends CommonPropsType {
8
+ /**
9
+ * 按钮标题
10
+ */
11
+ text?: string;
12
+ /**
13
+ * 按钮风格
14
+ */
15
+ type?: 'primary' | 'warn' | 'wechat' | 'default';
16
+ /**
17
+ * 按钮大小
18
+ */
19
+ size?: 'default' | 'mini' | 'large';
20
+ /**
21
+ * 分享标题
22
+ */
23
+ title?: string;
24
+ /**
25
+ * 选择页面
26
+ */
27
+ path?: string;
28
+ /**
29
+ * 携带参数
30
+ */
31
+ withParams?: boolean;
32
+ /**
33
+ * 参数
34
+ */
35
+ params?: any;
36
+ }
37
+
38
+ export default Share;
@@ -17,4 +17,4 @@ export default function Slot({ compositeParent, name, className }: PropsType) {
17
17
  );
18
18
  }
19
19
  return compositeParent.props.data[name] || null;
20
- }
20
+ }
@@ -12,11 +12,13 @@ import TabsPc from './tabs.pc';
12
12
  export interface PropsType extends CommonPropsType {
13
13
  tabs: {
14
14
  title: string;
15
+ value: string;
15
16
 
16
17
  // @deprecated
17
18
  name?: string;
18
19
  }[];
19
20
  selectedIndex: number|string
21
+ isMultipleSlot: boolean
20
22
  [key: string]: React.ReactNode
21
23
  // [panel: `panel${number}`]: React.ReactNode; // require typescript@4.4
22
24
  }
@@ -4,13 +4,16 @@ import './index.css';
4
4
  import classNames from '../../utils/classnames';
5
5
  import { useSyncValue } from '../../utils/useSyncValue';
6
6
  import {PropsType} from './index';
7
+ import { useCustomCompareEffect, usePrevious, useSyncedRef } from '@react-hookz/web';
8
+ import isObjectEqual from '../../utils/isObjectEqual';
7
9
 
8
10
  export default function TabsH5({
9
- tabs,
11
+ tabs = [],
10
12
  selectedIndex,
11
13
  events,
12
14
  className,
13
15
  style,
16
+ isMultipleSlot = true,
14
17
  ...restProps
15
18
  }: PropsType) {
16
19
  const [currentIndex, setCurrentIndex] = useSyncValue(
@@ -25,44 +28,51 @@ export default function TabsH5({
25
28
  };
26
29
  }, [tabs, currentIndex]);
27
30
 
31
+ const eventRef = useSyncedRef(events);
32
+ useCustomCompareEffect(() => {
33
+ eventRef.current.change(
34
+ {
35
+ id: currentIndex,
36
+ label: tabs[currentIndex]?.title,
37
+ value: tabs[currentIndex]?.value,
38
+ },
39
+ );
40
+ }, [currentIndex, tabs], isObjectEqual);
28
41
  return (
29
- <div data-testid="tabs" className={classNames("weda-tabs weda-ui", {
30
- [className]: className
31
- })} style={style}>
42
+ <div
43
+ data-testid="tabs"
44
+ className={classNames('weda-tabs weda-ui', {
45
+ [className]: className,
46
+ })}
47
+ style={style}
48
+ >
32
49
  <div className="weda-tabs__nav">
33
- {
34
- tabs?.map(({ name, title }, index) => (
35
- <div
36
- className={
37
- classNames(
38
- 'weda-tabs__nav-cell',
39
- {
40
- 'active': currentIndex === index,
41
- 'scroll': currentIndex > 5
42
- }
43
- )
44
- }
45
- key={name || index}
46
- onClick={(event) => {
47
- setCurrentIndex(index);
48
- events && events.change({id: index, label: title}, { event });
49
- }}
50
- >
50
+ {tabs?.map(({ name, title }, index) => (
51
+ <div
52
+ className={classNames('weda-tabs__nav-cell', {
53
+ active: currentIndex === index,
54
+ scroll: currentIndex > 5,
55
+ })}
56
+ key={name || index}
57
+ onClick={() => {
58
+ setCurrentIndex(index);
59
+ }}
60
+ >
51
61
  {title}
52
- </div>
53
- ))
54
- }
62
+ </div>
63
+ ))}
55
64
 
56
- <div
57
- className="weda-tabs__nav-sticky"
58
- style={stickyStyle}
59
- ></div>
65
+ <div className="weda-tabs__nav-sticky" style={stickyStyle}></div>
60
66
  </div>
61
67
 
62
- <div className={classNames({
63
- 'weda-tabs__panel': true,
64
- })}>
65
- {restProps[`panel${currentIndex + 1}`]}
68
+ <div
69
+ className={classNames({
70
+ 'weda-tabs__panel': true,
71
+ })}
72
+ >
73
+ {isMultipleSlot
74
+ ? restProps[`panel${currentIndex + 1}`]
75
+ : restProps['panel1']}
66
76
  </div>
67
77
  </div>
68
78
  );