@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
@@ -1,30 +1,43 @@
1
+ import { useCustomCompareEffect, useMountEffect, useSyncedRef } from '@react-hookz/web';
1
2
  import * as React from 'react';
2
3
  import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
3
4
  import classNames from '../../utils/classnames';
5
+ import isObjectEqual from '../../utils/isObjectEqual';
4
6
  import { useSyncValue } from '../../utils/useSyncValue';
5
7
  import { PropsType } from './index';
6
8
 
7
9
 
8
10
  export default function TabsPc({
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
 
17
20
  const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
18
- const _tabs = Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
19
- return {
20
- id: index.toString(),
21
- label: item.title
22
- };
23
- });
21
+ const _tabs = React.useMemo(() => {
22
+ return Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
23
+ return {
24
+ id: index.toString(),
25
+ label: item.title,
26
+ value: item.value
27
+ };
28
+ });
29
+ }, [tabs]);
24
30
 
31
+ const eventsRef = useSyncedRef(events);
32
+ useCustomCompareEffect(() => {
33
+ eventsRef.current && eventsRef.current.change({
34
+ id: _tabs[activeIndex]?.id,
35
+ label: _tabs[activeIndex]?.label,
36
+ value: _tabs[activeIndex]?.value,
37
+ });
38
+ }, [activeIndex, _tabs], isObjectEqual);
25
39
  const onActive = (e) => {
26
40
  setActiveIndex(e.id);
27
- events && events.change(e);
28
41
  };
29
42
  return (
30
43
  <ConfigProvider classPrefix="wedatea2td">
@@ -40,11 +53,11 @@ export default function TabsPc({
40
53
  key={item.id}
41
54
  id={item.id}
42
55
  >
43
- {restProps[`panel${index + 1}`]}
56
+ {isMultipleSlot ? restProps[`panel${index + 1}`] : restProps['panel1']}
44
57
  </TabPanel>
45
58
  )
46
59
  )}
47
60
  </TeaTabs>
48
61
  </ConfigProvider>
49
62
  );
50
- }
63
+ }
@@ -21,8 +21,6 @@ export default function Text({
21
21
  maxLines = 2,
22
22
  space = false,
23
23
  userSelect = true,
24
- textAlign = '',
25
- textColor = '',
26
24
  style = {},
27
25
  className,
28
26
  events,
@@ -42,23 +40,17 @@ export default function Text({
42
40
  }
43
41
  const levelName = level === '0' ? '' : `level_${level}`;
44
42
 
45
- // 添加文本颜色属性
46
- let style2 = {};
47
- if (textColor !== "") {
48
- style2 = {color: textColor};
49
- }
50
-
51
- // 添加对齐属性
52
- if (textAlign !== "") {
53
- style2 = {...style2, textAlign};
54
- }
43
+ const inlineStyle = React.useMemo(
44
+ () => ({ ...textStyle, ...style }),
45
+ [textStyle, style]
46
+ );
55
47
  return (
56
48
  <p
57
49
  //@ts-expect-error contentEditable type def sucks
58
50
  contentEditable={contenteditable}
59
51
  onInput={onInput}
60
52
  onBlur={onBlur}
61
- style={{ ...style, ...textStyle, ...style2 }}
53
+ style={inlineStyle}
62
54
  className={classNames('weda-text', 'weda-ui', className, levelName)}
63
55
  id={id}
64
56
  onClick={(e) => events.tap({}, { originEvent: e })}
@@ -66,4 +58,4 @@ export default function Text({
66
58
  {text}
67
59
  </p>
68
60
  );
69
- }
61
+ }
@@ -1,11 +1,11 @@
1
- a.weda-file-view-pc__single{
2
- display: inline-block;
3
- vertical-align: middle;
4
- white-space: nowrap;
5
- overflow: hidden;
6
- text-overflow: ellipsis;
7
- max-width: 100%;
1
+ a.weda-uploader-file-view__single {
2
+ display: inline-block;
3
+ vertical-align: middle;
4
+ white-space: nowrap;
5
+ overflow: hidden;
6
+ text-overflow: ellipsis;
7
+ max-width: 100%;
8
8
  }
9
- a.weda-file-view-pc__single:hover{
10
- text-decoration: underline;
9
+ a.weda-uploader-file-view__single:hover {
10
+ text-decoration: underline;
11
11
  }
@@ -1,43 +1,52 @@
1
1
  import * as React from 'react';
2
2
  import { UploadFilePc } from '../form/uploaderFile/uploadFile.pc';
3
+ import { UploadFileH5 } from '../form/uploaderFile/uploadFile.h5';
3
4
  import {
4
5
  filterStrList,
5
6
  isCloudFileID,
6
7
  downloadFile,
8
+ usePlatform,
9
+ transFileCloudidToName,
7
10
  } from '../../utils/platform';
8
11
  import { getTempFileURL } from '../../utils/tcb';
9
12
  import './index.css';
10
13
 
11
- const CLASS_PREFIX = 'weda-file-view-pc';
14
+ const CLASS_PREFIX = 'weda-uploader-file-view';
12
15
 
13
16
  /**
14
- * 上传文件回显
15
- * single 表示单个文件回显
17
+ * 上传文件回显,传showType强制展示某端样式,否则根据平台自动判断
16
18
  */
17
19
  export default function UploaderFileView({
18
20
  value,
19
21
  className,
20
- single = true,
22
+ single = true, // 展示为单行 a 标签
23
+ showType, // 展示端为 pc 还是 h5 样式
21
24
  ...rest
22
25
  }) {
23
26
  const fileIDList = filterStrList(value);
24
- if(single){
25
- return <FileView fileID={fileIDList[0]}/>;
26
- }else{
27
- return (
28
- <UploadFilePc
29
- className={`${CLASS_PREFIX} ${className}`}
30
- decorator={null}
31
- {...rest}
32
- value={fileIDList}
33
- isEdit={false}
34
- />
27
+ if (single) {
28
+ return <FileView fileID={fileIDList[0]} />;
29
+ } else {
30
+ const platform = usePlatform();
31
+ const showTypeMix = showType ? (showType === 'h5' ? 'h5' : 'pc') : platform;
32
+ const uploadFileProps = {
33
+ ...rest,
34
+ className: `${CLASS_PREFIX} ${className}`,
35
+ decorator: null,
36
+ labelVisible: false,
37
+ value: fileIDList,
38
+ isEdit: false,
39
+ };
40
+ return showTypeMix === 'pc' ? (
41
+ <UploadFilePc {...uploadFileProps} />
42
+ ) : (
43
+ <UploadFileH5 {...uploadFileProps} />
35
44
  );
36
45
  }
37
46
  }
38
47
 
39
48
  /**
40
- * 单个文件回显
49
+ * 单个文件回显,用在表格里面
41
50
  */
42
51
  const FileView = ({ fileID }) => {
43
52
  const [src, setSrc] = React.useState('');
@@ -58,18 +67,18 @@ const FileView = ({ fileID }) => {
58
67
 
59
68
  const title = React.useMemo(() => {
60
69
  if (isCloudFileID(fileID)) {
61
- const uuidReg = /file-[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}-/;
62
- const lastIndex = `${fileID}`.lastIndexOf('/');
63
- const name = `${fileID}`.slice(lastIndex + 1);
64
- const title = name.replace(uuidReg, '');
65
- return title;
70
+ return transFileCloudidToName(fileID);
66
71
  } else {
67
72
  return fileID;
68
73
  }
69
74
  }, [fileID]);
70
75
  return (
71
- <a title={title} onClick={() => downloadFile(src)} className={`${CLASS_PREFIX}__single`}>
76
+ <a
77
+ title={title}
78
+ onClick={() => downloadFile(src)}
79
+ className={`${CLASS_PREFIX}__single`}
80
+ >
72
81
  {title}
73
- </a>
82
+ </a>
74
83
  );
75
84
  };
File without changes
@@ -0,0 +1,30 @@
1
+ import * as React from 'react';
2
+ import Button from '../../components/button';
3
+ import { CommonPropsType } from '../../types';
4
+
5
+ const UserInfo = (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
+ usage?: string;
24
+ /**
25
+ * 语言
26
+ */
27
+ language?: string;
28
+ }
29
+
30
+ export default UserInfo;
@@ -1,20 +1,21 @@
1
1
  /// <reference types="resize-observer-browser" />
2
2
 
3
- import * as React from "react";
4
- export type unknownFunction = (...args: unknown[]) => unknown
3
+ import { any } from 'prop-types';
4
+ import * as React from 'react';
5
+ export type unknownFunction = (...args: unknown[]) => unknown;
5
6
  export interface CommonPropsType {
6
- style?: React.CSSProperties,
7
- id?: string,
8
- events?: Record<string, unknownFunction>;
9
- className?: string,
10
- children?: React.ReactNode | undefined
7
+ style?: React.CSSProperties;
8
+ id?: string;
9
+ events?: Record<string, unknownFunction>;
10
+ className?: string;
11
+ children?: React.ReactNode | undefined;
11
12
  }
12
13
 
13
-
14
14
  declare global {
15
- var app: any
16
- interface Window {
17
- app: any;
18
- }
19
-
20
- }
15
+ var app: any;
16
+ interface Window {
17
+ app: any;
18
+ qq: any;
19
+ TMap: any;
20
+ }
21
+ }
@@ -0,0 +1,98 @@
1
+ function isObject(value) {
2
+ const type = typeof value;
3
+ return value != null && (type === 'object' || type === 'function');
4
+ }
5
+ function debounce(func, wait, options) {
6
+ let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
7
+ let lastInvokeTime = 0;
8
+ let leading = false;
9
+ let maxing = false;
10
+ let trailing = true;
11
+ if (typeof func !== 'function') {
12
+ throw new TypeError('Expected a function');
13
+ }
14
+ wait = +wait || 0;
15
+ if (isObject(options)) {
16
+ leading = !!options.leading;
17
+ maxing = 'maxWait' in options;
18
+ maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
19
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
20
+ }
21
+ function invokeFunc(time) {
22
+ const args = lastArgs;
23
+ const thisArg = lastThis;
24
+
25
+ lastArgs = lastThis = undefined;
26
+ lastInvokeTime = time;
27
+ result = func.apply(thisArg, args);
28
+ return result;
29
+ }
30
+ function startTimer(pendingFunc, wait) {
31
+ return setTimeout(pendingFunc, wait);
32
+ }
33
+ function leadingEdge(time) {
34
+ lastInvokeTime = time;
35
+ timerId = startTimer(timerExpired, wait);
36
+ return leading ? invokeFunc(time) : result;
37
+ }
38
+ function remainingWait(time) {
39
+ const timeSinceLastCall = time - lastCallTime;
40
+ const timeSinceLastInvoke = time - lastInvokeTime;
41
+ const timeWaiting = wait - timeSinceLastCall;
42
+
43
+ return maxing
44
+ ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
45
+ : timeWaiting;
46
+ }
47
+ function shouldInvoke(time) {
48
+ const timeSinceLastCall = time - lastCallTime;
49
+ const timeSinceLastInvoke = time - lastInvokeTime;
50
+ return (
51
+ lastCallTime === undefined ||
52
+ timeSinceLastCall >= wait ||
53
+ timeSinceLastCall < 0 ||
54
+ (maxing && timeSinceLastInvoke >= maxWait)
55
+ );
56
+ }
57
+ function timerExpired() {
58
+ const time = Date.now();
59
+ if (shouldInvoke(time)) {
60
+ return trailingEdge(time);
61
+ }
62
+ timerId = startTimer(timerExpired, remainingWait(time));
63
+ }
64
+ function trailingEdge(time) {
65
+ timerId = undefined;
66
+ if (trailing && lastArgs) {
67
+ return invokeFunc(time);
68
+ }
69
+ lastArgs = lastThis = undefined;
70
+ return result;
71
+ }
72
+
73
+ //debouncedFunc
74
+ function debounced(...args) {
75
+ const time = Date.now();
76
+ const isInvoking = shouldInvoke(time);
77
+
78
+ lastArgs = args;
79
+ lastThis = this;
80
+ lastCallTime = time;
81
+
82
+ if (isInvoking) {
83
+ if (timerId === undefined) {
84
+ return leadingEdge(lastCallTime);
85
+ }
86
+ if (maxing) {
87
+ timerId = startTimer(timerExpired, wait);
88
+ return invokeFunc(lastCallTime);
89
+ }
90
+ }
91
+ if (timerId === undefined) {
92
+ timerId = startTimer(timerExpired, wait);
93
+ }
94
+ return result;
95
+ }
96
+ return debounced;
97
+ }
98
+ export default debounce;
@@ -38,6 +38,21 @@ export function usePlatform() {
38
38
  return touchDevice || smallScreen ? 'h5' : 'pc';
39
39
  }
40
40
 
41
+ /**
42
+ * 在h5下,判断当前是否是移动浏览器
43
+ */
44
+ export function inH5IsMobile() {
45
+ try {
46
+ // 区分h5是在编辑器还是移动浏览器
47
+ let is_mobile_ua = false;
48
+ const ua = navigator && navigator.userAgent;
49
+ is_mobile_ua = /Android|webOS|BlackBerry|iPhone|iPad|iPod|iOS/i.test(ua);
50
+ return is_mobile_ua;
51
+ } catch (e) {
52
+ console.log('isMobile err', e);
53
+ }
54
+ }
55
+
41
56
  /**
42
57
  * 过滤非字符串,返回字符串数组
43
58
  * 用于兼容单个组件和组件数组
@@ -101,3 +116,28 @@ export const cutFileTitle = (str = '', count = 10) => {
101
116
  }
102
117
  return title;
103
118
  };
119
+
120
+ /**
121
+ * 判断是否在 ide 中
122
+ */
123
+ export const isInIde = () => !!window?.app?.cloud?.IS_WEDA_IDE;
124
+
125
+ /**
126
+ * cloudid和文件名转换
127
+ */
128
+ export const transFileCloudidToName = (fileID) => {
129
+ const uuidReg = /(file-)?[0-9a-f]{8}((-)?[0-9a-f]{4}){3}(-)?[0-9a-f]{12}-/;
130
+ const lastIndex = `${fileID}`.lastIndexOf('/');
131
+ const name = `${fileID}`.slice(lastIndex + 1);
132
+ const title = name.replace(uuidReg, '');
133
+ return title;
134
+ };
135
+
136
+ /**
137
+ * 判断是否是url
138
+ */
139
+ const reg =
140
+ // eslint-disable-next-line no-useless-escape
141
+ /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
142
+
143
+ export const isUrl = (path) => reg.test(path);
@@ -1,3 +1,4 @@
1
+ import { isInIde } from './platform';
1
2
  /**
2
3
  * 云存储/云函数相关
3
4
  */
@@ -35,3 +36,51 @@ export async function getTempFileURL(data) {
35
36
  return await window?.app?.cloud?.getTempFileURL(data);
36
37
  }
37
38
  }
39
+
40
+ /**
41
+ * 云函数获取数据
42
+ */
43
+ export async function callDataSource(param) {
44
+ const { params, dataSourceName, methodName } = param;
45
+ try {
46
+ const res = await window?.app?.cloud?.callDataSource?.({
47
+ params,
48
+ dataSourceName,
49
+ methodName,
50
+ });
51
+ return res;
52
+ } catch (error) {
53
+ console.error('错误', error);
54
+ return {};
55
+ }
56
+ }
57
+
58
+ /**
59
+ * 云API:获取用户自定义导航内容
60
+ * param
61
+ * WeAppId: string,
62
+ * EnvId: string,
63
+ * PublishType?: string,
64
+ */
65
+ export async function getAppCustomNav() {
66
+ try {
67
+ const PublishType = isInIde() ? 'preview' : '';
68
+ const WeAppId = window?.app?.id;
69
+ const res = await callWedaApi({
70
+ action: 'DescribeAppCustomNav',
71
+ serviceType: 'lowcode',
72
+ data: {
73
+ WeAppId,
74
+ PublishType,
75
+ },
76
+ });
77
+ return res;
78
+ } catch (error) {
79
+ console.error('错误', error);
80
+ return {};
81
+ }
82
+ }
83
+
84
+ export function callWedaApi(...args) {
85
+ return window.app.cloud.callWedaApi(...args);
86
+ }
@@ -0,0 +1,4 @@
1
+ export function getTMap() {
2
+ const TMap = window?.TMap;
3
+ return TMap;
4
+ }
@@ -6,6 +6,8 @@ body .weda-ui {
6
6
  --weui-BRAND: #006eff;
7
7
  --weui-TAG-TEXT-BLUE: #0067eb;
8
8
  --weui-BTN-DEFAULT-COLOR: #576b95;
9
+ --weui-WECHAT: #07c160;
10
+ --weui-TAG-TEXT-GREEN: #06ae56;
9
11
  --weui-BG-2: rgba(255, 255, 255, 0);
10
12
  }
11
13