@cloudbase/weda-ui 0.2.16 → 1.0.24

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 (194) hide show
  1. package/README.md +41 -169
  2. package/package.json +23 -11
  3. package/src/configs/components/calendar.json +4 -1
  4. package/src/configs/components/chart/bar.json +724 -0
  5. package/src/configs/components/chart/line.json +679 -0
  6. package/src/configs/components/chart/pie.json +497 -0
  7. package/src/configs/components/chart/statisticsCard.json +61 -13
  8. package/src/configs/components/container.json +7 -2
  9. package/src/configs/components/dataView.json +21 -6
  10. package/src/configs/components/form/checkbox.json +97 -5
  11. package/src/configs/components/form/radio.json +96 -4
  12. package/src/configs/components/form/select.json +245 -11
  13. package/src/configs/components/graphicCard.json +84 -73
  14. package/src/configs/components/image.json +7 -2
  15. package/src/configs/components/link.json +19 -3
  16. package/src/configs/components/listView.json +65 -18
  17. package/src/configs/components/lottery.json +151 -0
  18. package/src/configs/components/modal.json +37 -5
  19. package/src/configs/components/navLayout.json +87 -75
  20. package/src/configs/components/navigationBar.json +59 -0
  21. package/src/configs/components/richtextview.json +4 -1
  22. package/src/configs/components/scrollVeiw.json +74 -22
  23. package/src/configs/components/swiper.json +4 -1
  24. package/src/configs/components/tabs.json +51 -8
  25. package/src/configs/components/text.json +33 -25
  26. package/src/configs/components/wxOpenApi/phone.json +141 -0
  27. package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
  28. package/src/configs/components/wxOpenApi/share.json +167 -0
  29. package/src/configs/components/wxOpenApi/userInfo.json +174 -0
  30. package/src/configs/index.js +20 -0
  31. package/src/index.js +2 -0
  32. package/src/mp/components/button/index.wxml +1 -2
  33. package/src/mp/components/chart/bar/index.js +258 -0
  34. package/src/mp/components/chart/bar/index.json +6 -0
  35. package/src/mp/components/chart/bar/index.wxml +3 -0
  36. package/src/mp/components/chart/bar/index.wxss +9 -0
  37. package/src/mp/components/chart/common/config/bar.js +50 -0
  38. package/src/mp/components/chart/common/config/global.js +16 -0
  39. package/src/mp/components/chart/common/config/line.js +48 -0
  40. package/src/mp/components/chart/common/config/pie.js +36 -0
  41. package/src/mp/components/chart/common/core/eChartBar.js +263 -0
  42. package/src/mp/components/chart/common/core/eChartBase.js +375 -0
  43. package/src/mp/components/chart/common/core/eChartLine.js +229 -0
  44. package/src/mp/components/chart/common/core/eChartPie.js +166 -0
  45. package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
  46. package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
  47. package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
  48. package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
  49. package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
  50. package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
  51. package/src/mp/components/chart/line/index.js +247 -0
  52. package/src/mp/components/chart/line/index.json +6 -0
  53. package/src/mp/components/chart/line/index.wxml +3 -0
  54. package/src/mp/components/chart/line/index.wxss +9 -0
  55. package/src/mp/components/chart/pie/index.js +182 -0
  56. package/src/mp/components/chart/pie/index.json +6 -0
  57. package/src/mp/components/chart/pie/index.wxml +4 -0
  58. package/src/mp/components/chart/pie/index.wxss +9 -0
  59. package/src/mp/components/chart/statisticsCard/index.js +33 -6
  60. package/src/mp/components/form/checkbox/index.js +41 -2
  61. package/src/mp/components/form/checkbox/index.wxml +1 -1
  62. package/src/mp/components/form/form/index.wxml +1 -2
  63. package/src/mp/components/form/input/index.js +1 -1
  64. package/src/mp/components/form/location/index.js +43 -2
  65. package/src/mp/components/form/radio/index.js +38 -0
  66. package/src/mp/components/form/select/index.js +348 -40
  67. package/src/mp/components/form/select/index.wxml +21 -6
  68. package/src/mp/components/form/select/region/index.js +101 -0
  69. package/src/mp/components/form/textarea/index.wxml +6 -5
  70. package/src/mp/components/form/uploader/index.js +76 -44
  71. package/src/mp/components/form/uploader/index.wxml +15 -3
  72. package/src/mp/components/form/uploaderFile/index.js +61 -29
  73. package/src/mp/components/graphicCard/index.js +26 -28
  74. package/src/mp/components/listView/index.js +52 -64
  75. package/src/mp/components/listView/index.wxml +2 -2
  76. package/src/mp/components/listView/index.wxss +5 -0
  77. package/src/mp/components/lottery/index.js +270 -0
  78. package/src/mp/components/lottery/index.json +4 -0
  79. package/src/mp/components/lottery/index.wxml +43 -0
  80. package/src/mp/components/lottery/index.wxss +317 -0
  81. package/src/mp/components/navLayout/index.js +3 -3
  82. package/src/mp/components/navigationBar/index.js +193 -0
  83. package/src/mp/components/navigationBar/index.json +6 -0
  84. package/src/mp/components/navigationBar/index.wxml +88 -0
  85. package/src/mp/components/navigationBar/index.wxss +1257 -0
  86. package/src/mp/components/tabs/index.js +7 -2
  87. package/src/mp/components/tabs/index.wxml +2 -1
  88. package/src/mp/components/text/index.js +0 -25
  89. package/src/mp/components/text/index.wxml +3 -3
  90. package/src/mp/components/wxOpenApi/phone/index.js +117 -0
  91. package/src/mp/components/wxOpenApi/phone/index.json +4 -0
  92. package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
  93. package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
  94. package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
  95. package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
  96. package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
  97. package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
  98. package/src/mp/components/wxOpenApi/share/index.js +117 -0
  99. package/src/mp/components/wxOpenApi/share/index.json +4 -0
  100. package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
  101. package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
  102. package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
  103. package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
  104. package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
  105. package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
  106. package/src/mp/index.json +10 -1
  107. package/src/mp/style/weda-ui.wxss +2 -0
  108. package/src/mp/utils/constant.js +15 -0
  109. package/src/mp/utils/destr.js +48 -0
  110. package/src/mp/utils/lodash.js +2 -0
  111. package/src/mp/utils/platform.js +25 -0
  112. package/src/mp/utils/tcb.js +44 -0
  113. package/src/setupTests.js +2 -1
  114. package/src/web/components/button/index.css +8 -1
  115. package/src/web/components/button/index.tsx +3 -2
  116. package/src/web/components/chart/bar/index.tsx +140 -0
  117. package/src/web/components/chart/common/config/bar.js +49 -0
  118. package/src/web/components/chart/common/config/global.js +16 -0
  119. package/src/web/components/chart/common/config/line.js +50 -0
  120. package/src/web/components/chart/common/config/pie.js +37 -0
  121. package/src/web/components/chart/common/core/eChartBar.js +265 -0
  122. package/src/web/components/chart/common/core/eChartBase.ts +383 -0
  123. package/src/web/components/chart/common/core/eChartLine.js +231 -0
  124. package/src/web/components/chart/common/core/eChartPie.js +170 -0
  125. package/src/web/components/chart/common/core/type.ts +34 -0
  126. package/src/web/components/chart/common/echart.css +106 -0
  127. package/src/web/components/chart/common/echarts.ts +33 -0
  128. package/src/web/components/chart/common/useChart.tsx +69 -0
  129. package/src/web/components/chart/line/index.tsx +136 -0
  130. package/src/web/components/chart/pie/index.tsx +99 -0
  131. package/src/web/components/chart/statisticsCard/index.tsx +29 -8
  132. package/src/web/components/form/checkbox/index.tsx +61 -23
  133. package/src/web/components/form/formcell/index.tsx +10 -5
  134. package/src/web/components/form/location/components/LocationH5/location.h5.jsx +3 -3
  135. package/src/web/components/form/location/components/LocationPC/location.PC.jsx +2 -2
  136. package/src/web/components/form/radio/index.tsx +90 -53
  137. package/src/web/components/form/select/h5.tsx +371 -72
  138. package/src/web/components/form/select/index.css +10 -0
  139. package/src/web/components/form/select/index.tsx +392 -145
  140. package/src/web/components/form/select/region/index.ts +122 -31
  141. package/src/web/components/form/select/time.jsx +90 -0
  142. package/src/web/components/form/select/year.tsx +170 -0
  143. package/src/web/components/form/tips/index.css +4 -0
  144. package/src/web/components/form/tips/index.tsx +4 -3
  145. package/src/web/components/form/uploader/uploader.h5.tsx +28 -19
  146. package/src/web/components/form/uploader/uploader.pc.tsx +17 -20
  147. package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +48 -44
  148. package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +28 -26
  149. package/src/web/components/graphicCard/index.css +1 -5
  150. package/src/web/components/graphicCard/index.tsx +4 -3
  151. package/src/web/components/image/image.tsx +1 -1
  152. package/src/web/components/image/index.tsx +1 -1
  153. package/src/web/components/index.js +13 -2
  154. package/src/web/components/link/index.tsx +6 -3
  155. package/src/web/components/listView/index.css +4 -0
  156. package/src/web/components/listView/index.tsx +10 -18
  157. package/src/web/components/lottery/index.css +327 -0
  158. package/src/web/components/lottery/index.tsx +567 -0
  159. package/src/web/components/lottery/lotteryUtil.ts +130 -0
  160. package/src/web/components/modal/index.tsx +3 -1
  161. package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
  162. package/src/web/components/navigationBar/common.tsx +198 -0
  163. package/src/web/components/navigationBar/h5Menu.tsx +179 -0
  164. package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
  165. package/src/web/components/navigationBar/index.css +762 -0
  166. package/src/web/components/navigationBar/index.tsx +231 -0
  167. package/src/web/components/navigationBar/type.d.ts +111 -0
  168. package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
  169. package/src/web/components/phone/index.css +0 -0
  170. package/src/web/components/phone/index.tsx +22 -0
  171. package/src/web/components/phoneCode/index.css +0 -0
  172. package/src/web/components/phoneCode/index.tsx +22 -0
  173. package/src/web/components/richTextView/index.tsx +3 -5
  174. package/src/web/components/share/index.css +0 -0
  175. package/src/web/components/share/index.tsx +38 -0
  176. package/src/web/components/tabs/index.tsx +2 -0
  177. package/src/web/components/tabs/tabs.h5.tsx +43 -33
  178. package/src/web/components/tabs/tabs.pc.tsx +23 -10
  179. package/src/web/components/text/index.tsx +6 -14
  180. package/src/web/components/userInfo/index.css +0 -0
  181. package/src/web/components/userInfo/index.tsx +30 -0
  182. package/src/web/utils/{constant.js → constant.ts} +17 -2
  183. package/src/web/utils/lodash.ts +2 -0
  184. package/src/web/utils/platform.js +10 -1
  185. package/src/web/utils/tcb.js +20 -6
  186. package/src/web/weda-ui.css +2 -0
  187. package/CHANGELOG.md +0 -240
  188. package/src/.DS_Store +0 -0
  189. package/src/configs/.DS_Store +0 -0
  190. package/src/mp/.gitignore +0 -10
  191. package/src/web/.DS_Store +0 -0
  192. package/src/web/components/form/select/region/cities.ts +0 -2410
  193. package/src/web/components/form/select/region/provinces.ts +0 -240
  194. 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
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
  );