@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
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { Checkbox as TeaCheckbox, ConfigProvider } from 'tea-component';
3
3
 
4
4
  import classNames from '../../../utils/classnames';
@@ -8,6 +8,8 @@ import fromEntries from 'object.fromentries';
8
8
  import { usePlatform } from '../../../utils/platform';
9
9
  import { renderDecorator } from '../renderDecorator';
10
10
  import { CommonFormPropsType } from '../types';
11
+ import { callWedaApi } from '../../../utils/tcb';
12
+ import destr from 'destr';
11
13
 
12
14
  export default function Checkbox({
13
15
  // 系统属性
@@ -19,6 +21,8 @@ export default function Checkbox({
19
21
  name = 'formCheckbox',
20
22
  label = '标题',
21
23
  labelVisible = true,
24
+ format = '',
25
+ enumName = '',
22
26
  range = [],
23
27
  layout = 'horizontal',
24
28
  disabled = false,
@@ -40,21 +44,53 @@ export default function Checkbox({
40
44
  'weui-cell_disabled': isH5 && disabled,
41
45
  });
42
46
 
47
+ const [option, setOption] = useState(range);
43
48
  const [checkedItems, setCheckedItems] = React.useState(
44
- platform === 'h5' ? fromEntries(range.map(({ value, checked }) => [value, !!checked]))
45
- : range.filter(({checked}) => checked).map(({value}) => value)
49
+ platform === 'h5' ? fromEntries(option.map(({ value, checked }) => [value, !!checked]))
50
+ : option.filter(({ checked }) => checked).map(({ value }) => value)
46
51
  );
47
52
  // 两次range不同时, 需要刷新checkedItems
48
53
  const prevRangeRef = React.useRef<object[]>();
49
54
  React.useEffect(() => {
50
- if (!isObjectEqual(prevRangeRef.current, range)) {
51
- prevRangeRef.current = range;
55
+ if (!isObjectEqual(prevRangeRef.current, option)) {
56
+ prevRangeRef.current = option;
52
57
  setCheckedItems(
53
- fromEntries(range.map(({ value, checked }) => [value, !!checked]))
58
+ fromEntries(option.map(({ value, checked }) => [value, !!checked]))
54
59
  );
55
60
  }
56
61
  });
57
62
 
63
+ useEffect(() => {
64
+ // 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
65
+ if (format === 'x-enum' && enumName) {
66
+ fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
67
+ }
68
+ }, []);
69
+
70
+ useEffect(() => {
71
+ if (format !== 'x-enum') {
72
+ setOption(range)
73
+ }
74
+ }, [range]);
75
+
76
+ const fetchData = async (param:
77
+ { OptNameList?: object, PageIndex?: number, PageSize?: number }
78
+ ) => {
79
+ let data = await callWedaApi({
80
+ action: 'DescribeGeneralOptionsDetailList',
81
+ data: param,
82
+ });
83
+ const config = destr(data?.Items?.[0]?.Config) ?? [];
84
+ const enumOption = config.map(item => {
85
+ return {
86
+ label: item.value,
87
+ value: item.key,
88
+ checked: false
89
+ };
90
+ });
91
+ setOption(enumOption);
92
+ };
93
+
58
94
  /**
59
95
  * 在ios h5端, label和input的绑定不生效
60
96
  * 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
@@ -82,8 +118,8 @@ export default function Checkbox({
82
118
  // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
83
119
  const hashcode = React.useMemo(() => getLocalCounter(), []);
84
120
  let checkboxElement;
85
- if(platform === 'h5') {
86
- checkboxElement = range.map(({ label, value }, index) => {
121
+ if (platform === 'h5') {
122
+ checkboxElement = option.map(({ label, value }, index) => {
87
123
  const _id = `checkbox-${hashcode}-${index}`;
88
124
  const _name = `checkbox-${hashcode}-${name}`;
89
125
  return (
@@ -120,17 +156,17 @@ export default function Checkbox({
120
156
  .map(([value]) => value)
121
157
  }
122
158
  onChange={value => {
123
- const newMap = range
124
- .map((opt) => opt.value)
125
- .reduce((acc, cur) => {
126
- const idx = value.indexOf(cur);
127
- if(idx < 0) {
128
- acc[cur] = false;
129
- } else {
130
- acc[cur] = true;
131
- }
132
- return acc;
133
- }, {});
159
+ const newMap = option
160
+ .map((opt) => opt.value)
161
+ .reduce((acc, cur) => {
162
+ const idx = value.indexOf(cur);
163
+ if (idx < 0) {
164
+ acc[cur] = false;
165
+ } else {
166
+ acc[cur] = true;
167
+ }
168
+ return acc;
169
+ }, {});
134
170
  setCheckedItems(newMap);
135
171
  events.change(
136
172
  {
@@ -141,7 +177,7 @@ export default function Checkbox({
141
177
  );
142
178
  }}
143
179
  >
144
- {range.map(({value, label}, index) => {
180
+ {option.map(({ value, label }, index) => {
145
181
  const _id = `checkbox-${hashcode}-${index}`;
146
182
  return (
147
183
  <TeaCheckbox key={_id} name={value} id={_id}>
@@ -149,7 +185,7 @@ export default function Checkbox({
149
185
  </TeaCheckbox>
150
186
  );
151
187
  })}
152
- </TeaCheckbox.Group>
188
+ </TeaCheckbox.Group>
153
189
  </ConfigProvider>
154
190
  );
155
191
  }
@@ -167,5 +203,7 @@ export default function Checkbox({
167
203
  }
168
204
 
169
205
  export interface PropsType extends CommonFormPropsType {
170
- range?: {label: string, value: any; [key: string]: any}[];
171
- }
206
+ range?: { label: string, value: any;[key: string]: any }[];
207
+ format?: string;
208
+ enumName?: string;
209
+ }
@@ -5,4 +5,8 @@
5
5
  .wedatea2td-form > .gsd-h5-react-formitem,
6
6
  .wedatea2td-form > div > .gsd-h5-react-formitem {
7
7
  padding-left: 32px;
8
- }
8
+ }
9
+
10
+ .weda-ui.weda-form-pc, .weda-ui.gsd-h5-react-form-pc {
11
+ padding-left: 24px;
12
+ }
@@ -22,6 +22,8 @@ export default function Form({
22
22
  'weda-ui': true,
23
23
  'weda-form': true,
24
24
  'weui-form': platform === 'h5',
25
+ 'weda-form-pc': platform === 'pc',
26
+ 'gsd-h5-react-form-pc': platform === 'pc',
25
27
  [className]: className,
26
28
  });
27
29
  if(platform === 'pc') {
@@ -45,4 +47,4 @@ export default function Form({
45
47
 
46
48
  export interface PropsType extends CommonFormPropsType {
47
49
  contentSlot?: any;
48
- }
50
+ }
@@ -4,7 +4,28 @@
4
4
  font-family: SimSun;
5
5
  font-size: 12px;
6
6
  color: #f60;
7
+ align-self: flex-start;
7
8
  }
9
+
10
+ .weda-ui .weui-cells__group_form .weui-cells {
11
+ margin: 0;
12
+ }
13
+ .weda-formcells.weui-flex .weda-formcells__label {
14
+ width: 130px;
15
+ }
16
+ .weui-cells__group_form .weui-cell {
17
+ padding: 16px 16px;
18
+ }
19
+
20
+ .weda-formcells__content.weui-flex__item .weui-cell_form {
21
+ padding: 0;
22
+ }
23
+
24
+ .weda-formcells__content.weui-flex__item .weui-cell_form {
25
+ padding-right: 16px;
26
+ }
27
+
28
+
8
29
  /* formcell 在 form container 外部兼容 and 独立 layout 适配 */
9
30
 
10
31
  .weda-formcells__pc.vertical .wedatea2td-form__controls,
@@ -68,4 +89,4 @@
68
89
  /*formcell end*/
69
90
 
70
91
 
71
- /* formcell 在 form container 外部兼容 */
92
+ /* formcell 在 form container 外部兼容 */
@@ -14,13 +14,13 @@ export default function FormCell({
14
14
  children,
15
15
  multiCell,
16
16
  requiredFlag,
17
- size
17
+ size,
18
18
  }: PropsType) {
19
19
  const platform = usePlatform();
20
20
  const isFlex = layout !== 'vertical';
21
21
 
22
- if(platform === 'pc') {
23
- return (
22
+ if (platform === 'pc') {
23
+ return (
24
24
  <ConfigProvider classPrefix="wedatea2td">
25
25
  <TeaForm.Item
26
26
  style={style}
@@ -31,9 +31,14 @@ export default function FormCell({
31
31
  'weda-formcells__pc': !!label,
32
32
  'weda-formcells__full-width': size === 'full',
33
33
  [layout]: layout,
34
- [className]: [className]
34
+ [className]: [className],
35
35
  })}
36
- label={label}
36
+ label={
37
+ <>
38
+ {label}
39
+ {requiredFlag && <span className="weda-formcells__flag">*</span>}
40
+ </>
41
+ }
37
42
  >
38
43
  {children}
39
44
  </TeaForm.Item>
@@ -59,10 +64,10 @@ export default function FormCell({
59
64
  'weui-cell': true,
60
65
  })}
61
66
  >
67
+ <label>{label}</label>
62
68
  {requiredFlag ? (
63
69
  <label className="weda-formcells__flag">*</label>
64
70
  ) : null}
65
- <label>{label}</label>
66
71
  </div>
67
72
  ) : null}
68
73
  <div
@@ -7,22 +7,17 @@
7
7
  /*
8
8
  把weui-cell 的padding还回到input
9
9
  */
10
- .weda-ui.weda-input input.weui-input {
11
- padding: 28px 16px;
10
+ .weda-ui input.weui-input {
11
+ padding: 28px 0;
12
12
  }
13
13
 
14
- .weda-ui.weda-input .weui-cell.weda-formcells__label {
15
- padding: 16px;
16
- }
17
- .weda-ui.weda-input .weda-formcells__label.weui-cell label {
18
- padding: 0;
19
- }
20
- .weda-ui.weda-input .weui-cell {
14
+ .weda-ui.weda-input .weui-flex__item .weui-cell_form {
21
15
  padding: 0;
16
+ padding-right: 16px;
22
17
  }
23
18
 
24
- .weda-ui.weda-input .weui-btn_input-clear {
25
- padding-right: 16px;
19
+ .weda-ui.weda-input .weui-cell_form {
20
+ padding: 0 16px;
26
21
  }
27
22
 
28
23
  /**
@@ -38,4 +33,4 @@
38
33
  }
39
34
  /**
40
35
  * END
41
- */
36
+ */
@@ -1,7 +1,3 @@
1
- .weda-ui_form-location {
2
- padding: 1.14286rem 0;
3
- }
4
-
5
1
  .form-location-warp {
6
2
  display: flex;
7
3
  white-space: nowrap;
@@ -10,7 +6,9 @@
10
6
  .form-location-label {
11
7
  display: flex;
12
8
  align-items: center;
13
- padding: 0 1.14286rem;
9
+ padding: 16px;
10
+ width: 130px;
11
+
14
12
  }
15
13
  .form-location-label > span {
16
14
  margin-right: 0.28571rem;
@@ -19,8 +17,7 @@
19
17
  color: #f60;
20
18
  }
21
19
 
22
- .form-location-con {
23
- padding-left: 1.14286rem;
20
+ .weda-ui .form-location-con {
24
21
  display: flex;
25
22
  align-items: center;
26
23
  }
@@ -329,8 +329,8 @@ export default function LocationH5(props) {
329
329
  <div className="form-location-warp">
330
330
  {labelVisible && (
331
331
  <div className="form-location-label">
332
- {requiredFlag && <span>*</span>}
333
332
  {label}
333
+ {requiredFlag && <span>*</span>}
334
334
  </div>
335
335
  )}
336
336
  <div className="form-location-con">
@@ -1,14 +1,16 @@
1
- import * as React from 'react';
2
- import {ConfigProvider, Radio as TeaRadio} from 'tea-component';
1
+ import React, { useEffect, useState } from 'react';
2
+ import { ConfigProvider, Radio as TeaRadio } from 'tea-component';
3
3
 
4
- import {usePlatform} from '../../../utils/platform';
4
+ import { usePlatform } from '../../../utils/platform';
5
5
  import classNames from '../../../utils/classnames';
6
6
  import getLocalCounter from '../../../utils/getLocalCounter';
7
7
  import isObjectEqual from '../../../utils/isObjectEqual';
8
+ import { callWedaApi } from '../../../utils/tcb';
8
9
 
9
10
  import './index.css';
10
11
  import { renderDecorator } from '../renderDecorator';
11
12
  import { CommonFormPropsType } from '../types';
13
+ import destr from 'destr';
12
14
 
13
15
  export default function Radio({
14
16
  // 系统属性
@@ -19,6 +21,8 @@ export default function Radio({
19
21
  // 组件属性
20
22
  label = '标题',
21
23
  labelVisible = true,
24
+ format = '',
25
+ enumName = '',
22
26
  name = 'formRadio',
23
27
  range = [],
24
28
  layout = 'horizontal',
@@ -39,19 +43,50 @@ export default function Radio({
39
43
  'weui-check__label': isH5,
40
44
  'weui-cell_disabled': isH5 && disabled,
41
45
  });
42
-
46
+ const [option, setOption] = useState(range);
43
47
  const [checkedItemValue, setCheckedItemValue] = React.useState(
44
- range.find((item) => item.checked)?.value
48
+ option.find((item) => item.checked)?.value
45
49
  );
46
50
  // 两次range不同时, 需要刷新checkedItemValue
47
51
  const prevRangeRef = React.useRef<PropsType['range']>();
48
52
  React.useEffect(() => {
49
- if (!isObjectEqual(prevRangeRef.current, range)) {
50
- prevRangeRef.current = range;
51
- setCheckedItemValue(range.find((item) => item.checked)?.value);
53
+ if (!isObjectEqual(prevRangeRef.current, option)) {
54
+ prevRangeRef.current = option;
55
+ setCheckedItemValue(option.find((item) => item.checked)?.value);
52
56
  }
53
57
  });
54
58
 
59
+ useEffect(() => {
60
+ // 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
61
+ if (format === 'x-enum' && enumName) {
62
+ fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
63
+ }
64
+ }, []);
65
+
66
+ useEffect(() => {
67
+ if (format !== 'x-enum') {
68
+ setOption(range)
69
+ }
70
+ }, [range]);
71
+
72
+ const fetchData = async (param:
73
+ { OptNameList?: object, PageIndex?: number, PageSize?: number }
74
+ ) => {
75
+ let data = await callWedaApi({
76
+ action: 'DescribeGeneralOptionsDetailList',
77
+ data: param,
78
+ });
79
+ const config = destr(data?.Items?.[0]?.Config) ?? [];
80
+ const enumOption = config.map(item => {
81
+ return {
82
+ label: item.value,
83
+ value: item.key,
84
+ checked: false
85
+ };
86
+ });
87
+ setOption(enumOption);
88
+ };
89
+
55
90
  /**
56
91
  * 在ios h5端, label和input的绑定不生效
57
92
  * 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
@@ -70,55 +105,55 @@ export default function Radio({
70
105
  // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
71
106
  const hashcode = React.useMemo(() => getLocalCounter(), []);
72
107
  let radioElement;
73
- if(isH5) {
108
+ if (isH5) {
74
109
 
75
- radioElement = range.map(({ label, value }, index) => {
110
+ radioElement = option.map(({ label, value }, index) => {
76
111
  const _id = `radio-${hashcode}-${index}`;
77
112
  const _name = `radio-${hashcode}-${name}`;
78
113
  return (
79
- <div
80
- className={subCls}
81
- key={_id}
82
- onClickCapture={getChangeHandler(value)}
83
- >
84
- <div className="weui-cell__hd">
85
- <input
86
- type="radio"
87
- className="weui-check"
88
- value={value}
89
- name={_name}
90
- id={_id}
91
- checked={checkedItemValue === value}
92
- disabled={disabled}
93
- onClick={(e) => e.stopPropagation()}
114
+ <div
115
+ className={subCls}
116
+ key={_id}
117
+ onClickCapture={getChangeHandler(value)}
118
+ >
119
+ <div className="weui-cell__hd">
120
+ <input
121
+ type="radio"
122
+ className="weui-check"
123
+ value={value}
124
+ name={_name}
125
+ id={_id}
126
+ checked={checkedItemValue === value}
127
+ disabled={disabled}
128
+ onClick={(e) => e.stopPropagation()}
94
129
  />
95
- <i className="weui-icon-checked"></i>
96
- </div>
97
- <div className="weui-cell__bd">
98
- <p>{label}</p>
130
+ <i className="weui-icon-checked"></i>
131
+ </div>
132
+ <div className="weui-cell__bd">
133
+ <p>{label}</p>
134
+ </div>
99
135
  </div>
100
- </div>
101
- );
102
- });
103
- } else {
104
- // pc
105
- radioElement = (<ConfigProvider classPrefix="wedatea2td">
106
- <TeaRadio.Group
107
- disabled={disabled}
108
- value={checkedItemValue}
109
- onChange={(value, {event}) => getChangeHandler(value)(event)}
110
- >
111
- {range.map(({value, label}, index) => {
112
- const _id = `radio-${hashcode}-${index}`;
113
- return (
114
- <TeaRadio key={_id} name={value} id={_id}>
115
- {label}
116
- </TeaRadio>
117
- );
118
- })}
119
- </TeaRadio.Group>
120
- </ConfigProvider>);
121
- }
136
+ );
137
+ });
138
+ } else {
139
+ // pc
140
+ radioElement = (<ConfigProvider classPrefix="wedatea2td">
141
+ <TeaRadio.Group
142
+ disabled={disabled}
143
+ value={checkedItemValue}
144
+ onChange={(value, { event }) => getChangeHandler(value)(event)}
145
+ >
146
+ {option.map(({ value, label }, index) => {
147
+ const _id = `radio-${hashcode}-${index}`;
148
+ return (
149
+ <TeaRadio key={_id} name={value} id={_id}>
150
+ {label}
151
+ </TeaRadio>
152
+ );
153
+ })}
154
+ </TeaRadio.Group>
155
+ </ConfigProvider>);
156
+ }
122
157
  return renderDecorator(radioElement, decorator)({
123
158
  id,
124
159
  className: cls,
@@ -132,5 +167,7 @@ export default function Radio({
132
167
 
133
168
  export interface PropsType extends CommonFormPropsType {
134
169
  // 组件属性
135
- range?: ({label: string} & Record<string, any>)[];
136
- }
170
+ range?: ({ label: string } & Record<string, any>)[];
171
+ format?: string;
172
+ enumName?: string;
173
+ }