@cloudbase/weda-ui 0.2.15 → 1.0.21

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 (250) hide show
  1. package/README.md +41 -169
  2. package/package.json +28 -15
  3. package/src/configs/components/calendar.json +78 -0
  4. package/src/configs/components/carousel.json +273 -0
  5. package/src/configs/components/chart/bar.json +724 -0
  6. package/src/configs/components/chart/line.json +679 -0
  7. package/src/configs/components/chart/pie.json +497 -0
  8. package/src/configs/components/chart/statisticsCard.json +379 -0
  9. package/src/configs/components/container.json +7 -2
  10. package/src/configs/components/dataView.json +154 -0
  11. package/src/configs/components/form/checkbox.json +97 -5
  12. package/src/configs/components/form/location.json +152 -0
  13. package/src/configs/components/form/radio.json +96 -4
  14. package/src/configs/components/form/select.json +245 -11
  15. package/src/configs/components/form/uploaderFile.json +2 -1
  16. package/src/configs/components/graphicCard.json +410 -0
  17. package/src/configs/components/image.json +7 -2
  18. package/src/configs/components/link.json +20 -4
  19. package/src/configs/components/listView.json +277 -0
  20. package/src/configs/components/modal.json +37 -5
  21. package/src/configs/components/navLayout.json +362 -0
  22. package/src/configs/components/navigationBar.json +59 -0
  23. package/src/configs/components/richtextview.json +4 -1
  24. package/src/configs/components/scrollVeiw.json +74 -22
  25. package/src/configs/components/swiper.json +6 -3
  26. package/src/configs/components/tabs.json +51 -8
  27. package/src/configs/components/text.json +33 -25
  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 +34 -0
  33. package/src/mp/components/button/index.js +12 -13
  34. package/src/mp/components/button/index.wxml +1 -1
  35. package/src/mp/components/calendar/arrowright--line.svg +11 -0
  36. package/src/mp/components/calendar/index.js +238 -0
  37. package/src/mp/components/calendar/index.json +4 -0
  38. package/src/mp/components/calendar/index.wxml +37 -0
  39. package/src/mp/components/calendar/index.wxss +178 -0
  40. package/src/mp/components/carousel/index.js +88 -0
  41. package/src/mp/components/carousel/index.json +7 -0
  42. package/src/mp/components/carousel/index.wxml +6 -0
  43. package/src/mp/components/chart/bar/index.js +258 -0
  44. package/src/mp/components/chart/bar/index.json +6 -0
  45. package/src/mp/components/chart/bar/index.wxml +3 -0
  46. package/src/mp/components/chart/bar/index.wxss +9 -0
  47. package/src/mp/components/chart/common/config/bar.js +50 -0
  48. package/src/mp/components/chart/common/config/global.js +16 -0
  49. package/src/mp/components/chart/common/config/line.js +48 -0
  50. package/src/mp/components/chart/common/config/pie.js +36 -0
  51. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  52. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  53. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  54. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  55. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  56. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  57. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  58. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  59. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  60. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  61. package/src/mp/components/chart/line/index.js +247 -0
  62. package/src/mp/components/chart/line/index.json +6 -0
  63. package/src/mp/components/chart/line/index.wxml +3 -0
  64. package/src/mp/components/chart/line/index.wxss +9 -0
  65. package/src/mp/components/chart/pie/index.js +182 -0
  66. package/src/mp/components/chart/pie/index.json +6 -0
  67. package/src/mp/components/chart/pie/index.wxml +4 -0
  68. package/src/mp/components/chart/pie/index.wxss +9 -0
  69. package/src/mp/components/chart/statisticsCard/index.js +253 -0
  70. package/src/mp/components/chart/statisticsCard/index.json +4 -0
  71. package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
  72. package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
  73. package/src/mp/components/dataView/index.js +34 -0
  74. package/src/mp/components/dataView/index.json +7 -0
  75. package/src/mp/components/dataView/index.wxml +15 -0
  76. package/src/mp/components/dataView/index.wxss +0 -0
  77. package/src/mp/components/form/checkbox/index.js +41 -2
  78. package/src/mp/components/form/checkbox/index.wxml +1 -1
  79. package/src/mp/components/form/input/index.js +1 -1
  80. package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
  81. package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
  82. package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
  83. package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
  84. package/src/mp/components/form/location/index.js +382 -0
  85. package/src/mp/components/form/location/index.json +6 -0
  86. package/src/mp/components/form/location/index.wxml +25 -0
  87. package/src/mp/components/form/location/index.wxss +91 -0
  88. package/src/mp/components/form/radio/index.js +38 -0
  89. package/src/mp/components/form/select/index.js +360 -40
  90. package/src/mp/components/form/select/index.wxml +21 -6
  91. package/src/mp/components/form/select/region/index.js +98 -0
  92. package/src/mp/components/form/textarea/index.wxml +6 -5
  93. package/src/mp/components/form/uploader/index.js +84 -48
  94. package/src/mp/components/form/uploader/index.wxml +15 -3
  95. package/src/mp/components/form/uploaderFile/index.js +106 -27
  96. package/src/mp/components/graphicCard/chevron-right.svg +3 -0
  97. package/src/mp/components/graphicCard/index.js +203 -0
  98. package/src/mp/components/graphicCard/index.json +4 -0
  99. package/src/mp/components/graphicCard/index.wxml +29 -0
  100. package/src/mp/components/graphicCard/index.wxss +157 -0
  101. package/src/mp/components/image/index.js +0 -1
  102. package/src/mp/components/listView/arrow-right-line.svg +3 -0
  103. package/src/mp/components/listView/index.js +285 -0
  104. package/src/mp/components/listView/index.json +4 -0
  105. package/src/mp/components/listView/index.wxml +40 -0
  106. package/src/mp/components/listView/index.wxss +155 -0
  107. package/src/mp/components/listView/more-line.svg +3 -0
  108. package/src/mp/components/navLayout/index.js +123 -0
  109. package/src/mp/components/navLayout/index.json +7 -0
  110. package/src/mp/components/navLayout/index.wxml +25 -0
  111. package/src/mp/components/navLayout/index.wxss +1193 -0
  112. package/src/mp/components/navigationBar/index.js +193 -0
  113. package/src/mp/components/navigationBar/index.json +6 -0
  114. package/src/mp/components/navigationBar/index.wxml +88 -0
  115. package/src/mp/components/navigationBar/index.wxss +1257 -0
  116. package/src/mp/components/swiper/index.wxml +2 -0
  117. package/src/mp/components/tabs/index.js +7 -2
  118. package/src/mp/components/tabs/index.wxml +2 -1
  119. package/src/mp/components/text/index.js +0 -25
  120. package/src/mp/components/text/index.wxml +3 -3
  121. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  122. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  123. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  124. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  125. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  126. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  127. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  128. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  129. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  130. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  131. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  132. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  133. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  134. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  135. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  136. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  137. package/src/mp/index.json +18 -2
  138. package/src/mp/style/weda-ui.wxss +2 -0
  139. package/src/mp/utils/debounce.js +133 -0
  140. package/src/mp/utils/destr.js +48 -0
  141. package/src/mp/utils/dr_square_point.js +25 -0
  142. package/src/mp/utils/platform.js +25 -0
  143. package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
  144. package/src/mp/utils/spark-md5.js +776 -0
  145. package/src/mp/utils/tcb.js +62 -0
  146. package/src/setupTests.js +2 -1
  147. package/src/web/components/button/index.css +8 -1
  148. package/src/web/components/button/index.tsx +3 -2
  149. package/src/web/components/calendar/index.css +382 -0
  150. package/src/web/components/calendar/index.jsx +312 -0
  151. package/src/web/components/calendar/util.js +90 -0
  152. package/src/web/components/carousel/index.css +119 -0
  153. package/src/web/components/carousel/index.tsx +417 -0
  154. package/src/web/components/chart/bar/index.tsx +140 -0
  155. package/src/web/components/chart/common/config/bar.js +49 -0
  156. package/src/web/components/chart/common/config/global.js +16 -0
  157. package/src/web/components/chart/common/config/line.js +50 -0
  158. package/src/web/components/chart/common/config/pie.js +37 -0
  159. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  160. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  161. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  162. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  163. package/src/web/components/chart/common/core/type.ts +34 -0
  164. package/src/web/components/chart/common/echart.css +106 -0
  165. package/src/web/components/chart/common/echarts.ts +33 -0
  166. package/src/web/components/chart/common/useChart.tsx +69 -0
  167. package/src/web/components/chart/line/index.tsx +136 -0
  168. package/src/web/components/chart/pie/index.tsx +99 -0
  169. package/src/web/components/chart/statisticsCard/index.css +62 -0
  170. package/src/web/components/chart/statisticsCard/index.tsx +307 -0
  171. package/src/web/components/chart/statisticsCard/interface.ts +14 -0
  172. package/src/web/components/dataView/index.tsx +20 -0
  173. package/src/web/components/dataView/interface.ts +6 -0
  174. package/src/web/components/form/checkbox/index.tsx +55 -23
  175. package/src/web/components/form/location/common/mapChoose.css +178 -0
  176. package/src/web/components/form/location/common/mapChoose.jsx +343 -0
  177. package/src/web/components/form/location/common/mapView.jsx +190 -0
  178. package/src/web/components/form/location/common/propsConfig.js +54 -0
  179. package/src/web/components/form/location/common/selectModal.css +44 -0
  180. package/src/web/components/form/location/common/selectModal.jsx +82 -0
  181. package/src/web/components/form/location/common/useLocationInfo.js +100 -0
  182. package/src/web/components/form/location/components/LocationH5/index.css +243 -0
  183. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
  184. package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
  185. package/src/web/components/form/location/components/LocationPC/index.css +44 -0
  186. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
  187. package/src/web/components/form/location/constants.js +4 -0
  188. package/src/web/components/form/location/index.css +0 -0
  189. package/src/web/components/form/location/index.jsx +25 -0
  190. package/src/web/components/form/radio/index.tsx +84 -53
  191. package/src/web/components/form/select/h5.tsx +389 -71
  192. package/src/web/components/form/select/index.css +10 -0
  193. package/src/web/components/form/select/index.tsx +404 -144
  194. package/src/web/components/form/select/region/index.ts +122 -31
  195. package/src/web/components/form/select/time.jsx +90 -0
  196. package/src/web/components/form/select/year.tsx +170 -0
  197. package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
  198. package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
  199. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
  200. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
  201. package/src/web/components/graphicCard/index.css +159 -0
  202. package/src/web/components/graphicCard/index.tsx +310 -0
  203. package/src/web/components/image/image.tsx +1 -2
  204. package/src/web/components/image/index.tsx +1 -1
  205. package/src/web/components/index.js +24 -2
  206. package/src/web/components/link/index.tsx +6 -3
  207. package/src/web/components/listView/arrow-right-line.svg +3 -0
  208. package/src/web/components/listView/index.css +143 -0
  209. package/src/web/components/listView/index.tsx +359 -0
  210. package/src/web/components/listView/interface.ts +98 -0
  211. package/src/web/components/modal/index.tsx +3 -1
  212. package/src/web/components/navLayout/index.css +332 -0
  213. package/src/web/components/navLayout/index.tsx +247 -0
  214. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  215. package/src/web/components/navigationBar/common.tsx +198 -0
  216. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  217. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  218. package/src/web/components/navigationBar/index.css +762 -0
  219. package/src/web/components/navigationBar/index.tsx +231 -0
  220. package/src/web/components/navigationBar/type.d.ts +111 -0
  221. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  222. package/src/web/components/phone/index.css +0 -0
  223. package/src/web/components/phone/index.tsx +22 -0
  224. package/src/web/components/phoneCode/index.css +0 -0
  225. package/src/web/components/phoneCode/index.tsx +22 -0
  226. package/src/web/components/richTextView/index.tsx +3 -5
  227. package/src/web/components/share/index.css +0 -0
  228. package/src/web/components/share/index.tsx +38 -0
  229. package/src/web/components/tabs/index.tsx +4 -2
  230. package/src/web/components/tabs/tabs.h5.tsx +50 -37
  231. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  232. package/src/web/components/text/index.tsx +6 -14
  233. package/src/web/components/uploaderFileView/index.css +9 -9
  234. package/src/web/components/uploaderFileView/index.jsx +32 -23
  235. package/src/web/components/userInfo/index.css +0 -0
  236. package/src/web/components/userInfo/index.tsx +30 -0
  237. package/src/web/types.d.ts +15 -14
  238. package/src/web/utils/debounce.js +98 -0
  239. package/src/web/utils/platform.js +40 -0
  240. package/src/web/utils/tcb.js +49 -0
  241. package/src/web/utils/tmap.js +4 -0
  242. package/src/web/weda-ui.css +2 -0
  243. package/CHANGELOG.md +0 -240
  244. package/src/.DS_Store +0 -0
  245. package/src/configs/.DS_Store +0 -0
  246. package/src/mp/.gitignore +0 -10
  247. package/src/web/.DS_Store +0 -0
  248. package/src/web/components/form/select/region/cities.ts +0 -2410
  249. package/src/web/components/form/select/region/provinces.ts +0 -240
  250. package/src/web/components/form/select/region/regions.ts +0 -20645
@@ -0,0 +1,231 @@
1
+ /* eslint-disable react/jsx-key */
2
+ import React, { useState, useEffect } from 'react';
3
+ import { CommonPropsType } from '../../types';
4
+ import classNames from '../../utils/classnames';
5
+ import { ConfigProvider } from 'tea-component';
6
+ import { usePlatform, isInIde } from '../../utils/platform';
7
+ import { getAppCustomNav } from '../../utils/tcb';
8
+ import { IMenuItem, INavigationStyle } from './type';
9
+ import './index.css';
10
+ import VerticalMenu from './verticalMenu';
11
+ import HorizontalMenu from './horizontalMenu';
12
+ import H5Menu from './h5Menu';
13
+ import { expandMenu, findMenuItemByPath } from './common';
14
+ import destr from 'destr';
15
+ /**
16
+ * Web端
17
+ */
18
+ const CLASS_PREFIX = 'weda-menu';
19
+
20
+ // 默认导航数据
21
+ const defaultNavigationBar: {
22
+ navigationStyle: INavigationStyle;
23
+ menuData: IMenuItem[];
24
+ } = {
25
+ menuData: [],
26
+ navigationStyle: {
27
+ isHorizontal: false,
28
+ showMenuIcon: true,
29
+ menuFontSize: 16,
30
+ menuBackgroundColor: '#fff',
31
+ menuColor: '#000',
32
+ menuHoverColor: '#f3f3f3',
33
+ showTitle: true,
34
+ title: '菜单标题',
35
+ showLogo: true,
36
+ logoUrl:
37
+ 'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg',
38
+ titleFontSize: 18,
39
+ titleColor: '#000',
40
+ logoWidth: 32,
41
+ logoHeight: 32,
42
+ },
43
+ };
44
+ // 默认高亮当前路由对应的菜单
45
+ const defaultSelectedMenu = (menu: IMenuItem[]) => {
46
+ try {
47
+ const url = window.location.href;
48
+ let selectedKey = url.substring(url.lastIndexOf('/'));
49
+ const targetMenu = findMenuItemByPath(menu, selectedKey);
50
+ if (targetMenu) {
51
+ selectedKey = targetMenu.key;
52
+ }
53
+ return selectedKey;
54
+ } catch (error) {
55
+ return '';
56
+ }
57
+ };
58
+ /**
59
+ * 导航菜单
60
+ */
61
+ export default function NavigationBar({
62
+ navigationbar,
63
+ contentSlot,
64
+ className,
65
+ style,
66
+ callApi = { getAppCustomNav },
67
+ }: PropsType) {
68
+ const platform = usePlatform();
69
+ const [menuData, setMenuData] = useState<IMenuItem[]>([]);
70
+ const [mobileMenuData, setMobileMenuData] = useState<IMenuItem[]>([]);
71
+ // 是否启用多端
72
+ const [isMultiTerminal, setIsMultiTerminal] = useState(false);
73
+ const [navigationStyle, setNavigationStyle] = useState<INavigationStyle>(
74
+ defaultNavigationBar.navigationStyle
75
+ );
76
+ // 菜单选中
77
+ const [selected, setSelected] = useState<string>('');
78
+ // 导航样式
79
+ const { isHorizontal = false } = navigationStyle;
80
+ const cls = classNames({
81
+ [CLASS_PREFIX]: true,
82
+ [className]: className,
83
+ [`${CLASS_PREFIX}-mobile`]: platform === 'h5',
84
+ [`${CLASS_PREFIX}-horizontal`]: isHorizontal,
85
+ });
86
+ // 导航容器样式
87
+ const navigationWrapStyle: React.CSSProperties = {
88
+ display: 'flex',
89
+ height: '100vh',
90
+ flexDirection: isHorizontal || platform === 'h5' ? 'column' : 'row',
91
+ position: 'relative',
92
+ ...style,
93
+ };
94
+
95
+ // 更新导航菜单
96
+ const updateNavigationData = () => {
97
+ callApi
98
+ .getAppCustomNav()
99
+ .then((res) => {
100
+ const { Content } = res;
101
+ const navigationData = destr(Content);
102
+ if (navigationData?.navigationStyle) {
103
+ // 设置默认选中
104
+ let selectedKey = '';
105
+ if (navigationData?.menuData?.length) {
106
+ selectedKey = defaultSelectedMenu(navigationData?.menuData);
107
+ }
108
+ setSelected(selectedKey);
109
+
110
+ // 设置默认展开状态
111
+ let menus = navigationData?.menuData || [];
112
+ menus = expandMenu(menus, { key: selectedKey }, true);
113
+ setMenuData(menus);
114
+ setNavigationStyle({
115
+ ...defaultNavigationBar.navigationStyle,
116
+ ...navigationData?.navigationStyle,
117
+ });
118
+ // 如果启用多端独立菜单导航,则设置移动端数据
119
+ if (navigationData?.isMultiTerminal) {
120
+ let mobileMenus = navigationData?.mobileMenuData || [];
121
+ mobileMenus = expandMenu(mobileMenus, { key: selectedKey }, true);
122
+ setMobileMenuData(mobileMenus);
123
+ setIsMultiTerminal(true);
124
+ }
125
+ }
126
+ })
127
+ .catch((error) => {
128
+ console.log(error);
129
+ });
130
+ };
131
+ /**
132
+ * 每次渲染组件通过接口拉取数据
133
+ */
134
+ useEffect(() => {
135
+ updateNavigationData();
136
+ }, []);
137
+ useEffect(() => {
138
+ if (isInIde()) {
139
+ // setMenuData(navigationbar?.menuData);
140
+ // setNavigationStyle(navigationbar?.navigationStyle);
141
+ updateNavigationData();
142
+ }
143
+ }, [navigationbar]);
144
+
145
+ // 初始化css变量
146
+ useEffect(() => {
147
+ if (navigationStyle.menuHoverColor) {
148
+ const body = document.getElementsByTagName('body')[0];
149
+ if (body) {
150
+ body.style.setProperty(
151
+ '--weda-navigation-menu-hover-color',
152
+ navigationStyle.menuHoverColor
153
+ );
154
+ body.style.setProperty(
155
+ '--weda-navigation-menu-selected-color',
156
+ navigationStyle.menuHoverColor
157
+ );
158
+ body.style.setProperty(
159
+ '--weda-navigation-menu-background-color',
160
+ navigationStyle.menuBackgroundColor
161
+ );
162
+ }
163
+ }
164
+ }, [navigationStyle.menuHoverColor, navigationStyle.menuBackgroundColor]);
165
+
166
+ const renderMenu = () => {
167
+ return (
168
+ <>
169
+ <div
170
+ className={cls}
171
+ style={navigationWrapStyle}
172
+ data-testid="navigationBar"
173
+ >
174
+ <div
175
+ className={`${CLASS_PREFIX}__wrapper`}
176
+ style={{
177
+ background: navigationStyle?.menuBackgroundColor || '#fff',
178
+ }}
179
+ >
180
+ {platform !== 'h5' && !isHorizontal && (
181
+ <VerticalMenu
182
+ menuData={menuData}
183
+ navigationStyle={navigationStyle}
184
+ setMenuData={setMenuData}
185
+ selected={selected}
186
+ setSelected={setSelected}
187
+ />
188
+ )}
189
+ {platform !== 'h5' && isHorizontal && (
190
+ <HorizontalMenu
191
+ menuData={menuData}
192
+ navigationStyle={navigationStyle}
193
+ selected={selected}
194
+ setSelected={setSelected}
195
+ />
196
+ )}
197
+ {platform === 'h5' && (
198
+ <H5Menu
199
+ menuData={isMultiTerminal ? mobileMenuData : menuData}
200
+ navigationStyle={navigationStyle}
201
+ setMenuData={setMenuData}
202
+ className={className}
203
+ selected={selected}
204
+ setSelected={setSelected}
205
+ />
206
+ )}
207
+ </div>
208
+ <div className="menu-solt">{contentSlot}</div>
209
+ </div>
210
+ </>
211
+ );
212
+ };
213
+
214
+ return (
215
+ <ConfigProvider classPrefix="wedatea2td">
216
+ {!isInIde() &&
217
+ (menuData?.length > 0 || mobileMenuData?.length > 0) &&
218
+ renderMenu()}
219
+ {isInIde() && renderMenu()}
220
+ </ConfigProvider>
221
+ );
222
+ }
223
+
224
+ export interface PropsType extends CommonPropsType {
225
+ contentSlot?: string;
226
+ navigationbar: {
227
+ navigationStyle: INavigationStyle;
228
+ menuData: IMenuItem[];
229
+ };
230
+ callApi: any;
231
+ }
@@ -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;
@@ -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;
@@ -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
- selectedIndex: number
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
  }
@@ -30,4 +32,4 @@ export default function Tabs(props: PropsType) {
30
32
  return <TabsH5 {...props} />;
31
33
  }
32
34
  return platform === 'h5' ? <TabsH5 {...props} /> : <TabsPc {...props} />;
33
- }
35
+ }
@@ -1,19 +1,25 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo } from 'react';
2
2
 
3
3
  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
- const [currentIndex, setCurrentIndex] = useSyncValue(selectedIndex);
19
+ const [currentIndex, setCurrentIndex] = useSyncValue(
20
+ typeof selectedIndex === 'string' ?
21
+ parseInt(selectedIndex) : selectedIndex
22
+ );
17
23
  const stickyStyle = useMemo(() => {
18
24
  const length = tabs.length;
19
25
  return {
@@ -21,46 +27,53 @@ export default function TabsH5({
21
27
  transform: `translate3d( ${currentIndex * 100}%, 0, 0)`
22
28
  };
23
29
  }, [tabs, currentIndex]);
24
-
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);
25
41
  return (
26
- <div data-testid="tabs" className={classNames("weda-tabs weda-ui", {
27
- [className]: className
28
- })} style={style}>
42
+ <div
43
+ data-testid="tabs"
44
+ className={classNames('weda-tabs weda-ui', {
45
+ [className]: className,
46
+ })}
47
+ style={style}
48
+ >
29
49
  <div className="weda-tabs__nav">
30
- {
31
- tabs?.map(({ name, title }, index) => (
32
- <div
33
- className={
34
- classNames(
35
- 'weda-tabs__nav-cell',
36
- {
37
- 'active': currentIndex === index,
38
- 'scroll': currentIndex > 5
39
- }
40
- )
41
- }
42
- key={name || index}
43
- onClick={(event) => {
44
- setCurrentIndex(index);
45
- events && events.change({id: index, label: title}, { event });
46
- }}
47
- >
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
+ >
48
61
  {title}
49
- </div>
50
- ))
51
- }
62
+ </div>
63
+ ))}
52
64
 
53
- <div
54
- className="weda-tabs__nav-sticky"
55
- style={stickyStyle}
56
- ></div>
65
+ <div className="weda-tabs__nav-sticky" style={stickyStyle}></div>
57
66
  </div>
58
67
 
59
- <div className={classNames({
60
- 'weda-tabs__panel': true,
61
- })}>
62
- {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']}
63
76
  </div>
64
77
  </div>
65
78
  );
66
- }
79
+ }