@cloudbase/weda-ui 3.4.11 → 3.4.13

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 (168) hide show
  1. package/dist/configs/components/common/form-input-required.js +3 -3
  2. package/dist/configs/components/customer-service.js +3 -0
  3. package/dist/configs/components/dataView.js +20 -10
  4. package/dist/configs/components/form-checkbox.js +15 -2
  5. package/dist/configs/components/form-date.js +1 -1
  6. package/dist/configs/components/form-depart-tree-select.js +1 -1
  7. package/dist/configs/components/form-email.js +17 -2
  8. package/dist/configs/components/form-input.js +17 -2
  9. package/dist/configs/components/form-location.js +1 -1
  10. package/dist/configs/components/form-multi-region.js +1 -1
  11. package/dist/configs/components/form-phone.js +17 -2
  12. package/dist/configs/components/form-radio.js +15 -2
  13. package/dist/configs/components/form-rich-text.js +1 -1
  14. package/dist/configs/components/form-select-multiple.js +362 -0
  15. package/dist/configs/components/form-select.js +1 -1
  16. package/dist/configs/components/form-switch.js +16 -3
  17. package/dist/configs/components/form-text-area.js +15 -2
  18. package/dist/configs/components/form-time.js +1 -1
  19. package/dist/configs/components/form-url.js +17 -2
  20. package/dist/configs/components/form-user-tree-select.js +14 -1
  21. package/dist/configs/components/listView.js +32 -49
  22. package/dist/configs/components/table.json +1 -54
  23. package/dist/configs/components/wd-bubble.js +46 -8
  24. package/dist/configs/components/wd-button.js +3 -0
  25. package/dist/configs/components/wd-checkbox.js +464 -0
  26. package/dist/configs/components/wd-form.js +66 -10
  27. package/dist/configs/components/wd-input-email.js +37 -0
  28. package/dist/configs/components/wd-input-phone.js +43 -0
  29. package/dist/configs/components/wd-input-url.js +37 -0
  30. package/dist/configs/components/wd-input.js +94 -0
  31. package/dist/configs/components/wd-official-account.js +87 -0
  32. package/dist/configs/components/wd-radio.js +443 -0
  33. package/dist/configs/components/wd-switch.js +315 -0
  34. package/dist/configs/components/wd-table.js +11 -59
  35. package/dist/configs/components/wd-textarea.js +82 -0
  36. package/dist/configs/components/wd-tree.js +443 -0
  37. package/dist/configs/components/web-view.js +3 -0
  38. package/dist/configs/index.js +24 -1
  39. package/dist/configs/type-utils/type-form.js +681 -0
  40. package/dist/docs/common/components/json-schema-view.js +1 -1
  41. package/dist/docs/common/components/methods-view.js +1 -1
  42. package/dist/docs/common/components/properties-view.js +3 -1
  43. package/dist/docs/common/format.js +7 -7
  44. package/dist/docs/common/tableView.js +3 -1
  45. package/dist/enum/index.js +196 -0
  46. package/dist/style/index.scss +1 -1
  47. package/dist/web/actions/showMessage/index.js +4 -1
  48. package/dist/web/components/carousel/index.js +1 -1
  49. package/dist/web/components/customer-service/customer-service.js +19 -2
  50. package/dist/web/components/dataView/index.js +16 -3
  51. package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
  52. package/dist/web/components/flow/common/request.js +5 -5
  53. package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +90 -0
  54. package/dist/web/components/form/formcell/index.css +13 -1
  55. package/dist/web/components/form/formcell/index.js +1 -1
  56. package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
  57. package/dist/web/components/form/select/dropdown-select/index.js +9 -3
  58. package/dist/web/components/form/select/h5.js +18 -8
  59. package/dist/web/components/form/select/index.js +9 -10
  60. package/dist/web/components/form/select/region/index.js +1 -1
  61. package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
  62. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
  63. package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
  64. package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
  65. package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
  66. package/dist/web/components/form/selectMultiple/h5.js +40 -0
  67. package/dist/web/components/form/selectMultiple/index.js +94 -0
  68. package/dist/web/components/form/selectMultiple/request.js +76 -0
  69. package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
  70. package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
  71. package/dist/web/components/form/selectMultiple/status/index.css +63 -0
  72. package/dist/web/components/form/selectMultiple/status/index.js +7 -0
  73. package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
  74. package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
  75. package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
  76. package/dist/web/components/form/tips/index.css +9 -3
  77. package/dist/web/components/form/uploader/index.css +10 -0
  78. package/dist/web/components/form/uploader/uploader.h5.js +60 -62
  79. package/dist/web/components/form/uploader/uploader.pc.js +48 -41
  80. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
  81. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
  82. package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
  83. package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
  84. package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
  85. package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
  86. package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
  87. package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
  88. package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
  89. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +76 -15
  90. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
  91. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
  92. package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
  93. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
  94. package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +10 -6
  95. package/dist/web/components/form-input-hooks/index.js +41 -15
  96. package/dist/web/components/form-select-multiple/index.js +26 -0
  97. package/dist/web/components/form-upload-file/index.js +0 -1
  98. package/dist/web/components/form-user-tree-select/index.js +2 -2
  99. package/dist/web/components/formdetail/index.css +31 -1
  100. package/dist/web/components/formdetail/index.js +33 -1
  101. package/dist/web/components/index.js +27 -11
  102. package/dist/web/components/listView/index.js +20 -5
  103. package/dist/web/components/navigationBar/common.js +1 -1
  104. package/dist/web/components/navigationBar/horizontalMenu.js +1 -1
  105. package/dist/web/components/navigationBar/index.css +11 -0
  106. package/dist/web/components/navigationBar/index.js +8 -1
  107. package/dist/web/components/phone/index.js +26 -1
  108. package/dist/web/components/phoneCode/index.js +3 -1
  109. package/dist/web/components/richText/index.css +70 -67
  110. package/dist/web/components/richText/index.js +311 -251
  111. package/dist/web/components/richText/richtext.module.css +1 -0
  112. package/dist/web/components/richTextView/index.css +39 -0
  113. package/dist/web/components/richTextView/index.js +1 -1
  114. package/dist/web/components/share/index.js +26 -1
  115. package/dist/web/components/table/ImportFileModalByApi/uploadCSVFile.js +1 -1
  116. package/dist/web/components/wd-checkbox/checkbox.js +34 -0
  117. package/dist/web/components/wd-checkbox/index.js +3 -0
  118. package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
  119. package/dist/web/components/wd-checkbox-list/index.js +3 -0
  120. package/dist/web/components/wd-form/hooks/use-remote-value.js +9 -2
  121. package/dist/web/components/wd-form/index.js +69 -34
  122. package/dist/web/components/wd-form/wd-form.js +42 -0
  123. package/dist/web/components/wd-form-cell/index.js +3 -0
  124. package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
  125. package/dist/web/components/wd-form-item/index.js +4 -0
  126. package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
  127. package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
  128. package/dist/web/components/wd-icon/wd-icon.js +10 -2
  129. package/dist/web/components/wd-input/index.js +3 -0
  130. package/dist/web/components/wd-input/wd-input.js +155 -0
  131. package/dist/web/components/wd-input-email/index.js +3 -0
  132. package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
  133. package/dist/web/components/wd-input-group/index.js +3 -0
  134. package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
  135. package/dist/web/components/wd-input-phone/index.js +3 -0
  136. package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
  137. package/dist/web/components/wd-input-url/index.js +3 -0
  138. package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
  139. package/dist/web/components/wd-input-wrap/index.js +3 -0
  140. package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
  141. package/dist/web/components/wd-official-account/index.css +29 -0
  142. package/dist/web/components/wd-official-account/index.js +36 -0
  143. package/dist/web/components/wd-radio/index.js +3 -0
  144. package/dist/web/components/wd-radio/wd-radio.js +30 -0
  145. package/dist/web/components/wd-radio-list/index.js +3 -0
  146. package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
  147. package/dist/web/components/wd-switch/index.js +3 -0
  148. package/dist/web/components/wd-switch/wd-switch.js +52 -0
  149. package/dist/web/components/wd-table/components/FieldRender/index.js +5 -4
  150. package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -0
  151. package/dist/web/components/wd-table/components/Table/index.js +40 -9
  152. package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
  153. package/dist/web/components/wd-table/hooks/useTableData.js +6 -1
  154. package/dist/web/components/wd-table/hooks/useViewFields.js +1 -1
  155. package/dist/web/components/wd-table/utils/index.js +6 -2
  156. package/dist/web/components/wd-table/wd-table.js +125 -99
  157. package/dist/web/components/wd-textarea/index.js +3 -0
  158. package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
  159. package/dist/web/components/wd-tree/index.js +3 -0
  160. package/dist/web/components/wd-tree/utils.js +291 -0
  161. package/dist/web/components/wd-tree/wd-tree.js +193 -0
  162. package/dist/web/utils/constant.js +16 -0
  163. package/dist/web/utils/datasource.js +2 -2
  164. package/dist/web/utils/date.js +3 -3
  165. package/dist/web/utils/hooks/useFormLegacy.js +112 -0
  166. package/dist/web/utils/tool.js +12 -2
  167. package/dist/web/weda-ui.css +197 -3
  168. package/package.json +6 -5
@@ -63,3 +63,42 @@
63
63
  list-style: decimal !important;
64
64
  padding: revert !important;
65
65
  }
66
+
67
+ .weda-RichTextView .tableWrapper,
68
+ .weda-RichTextView div:has(> table) {
69
+ margin: 20px 0;
70
+ padding: 0;
71
+ overflow-x: auto;
72
+ display: flex;
73
+ justify-content: center;
74
+ }
75
+ .weda-RichTextView table {
76
+ min-width: fit-content;
77
+ border-collapse: collapse;
78
+ margin: 0;
79
+ overflow: hidden;
80
+ }
81
+ .weda-RichTextView table th,
82
+ .weda-RichTextView table td {
83
+ box-sizing: border-box;
84
+ position: relative;
85
+ min-width: 70px;
86
+ padding: 0px 5px;
87
+ border: 1px solid #e1e6f0;
88
+ vertical-align: top;
89
+ background-clip: padding-box;
90
+ }
91
+ .weda-RichTextView table th {
92
+ font-weight: bold;
93
+ background-color: #f5f7fa;
94
+ }
95
+ .weda-RichTextView table td {
96
+ background-color: white;
97
+ }
98
+ .weda-RichTextView table th > p,
99
+ .weda-RichTextView table td > p {
100
+ min-height: 1em;
101
+ }
102
+ .weda-RichTextView img {
103
+ vertical-align: unset;
104
+ }
@@ -15,7 +15,7 @@ export default function RichTextView({ value = '', className, style, id, }) {
15
15
  const [displayValue, setDisplayValue] = useState('');
16
16
  const regex = new RegExp(/<img [^>]*src=\\*"([^"]*?)\\*"/g);
17
17
  const iferror = `javascript:this.width='80';this.src='${LOAD_ERR_IMG_BASE64}';this.onerror=null`;
18
- let tempValue = parseValue
18
+ let tempValue = (parseValue || '')
19
19
  .toString()
20
20
  .replace(/<img /g, `<img onerror=${iferror} style="max-width:100%" `);
21
21
  const getSrc = async (img) => {
@@ -1,5 +1,30 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * @Date: 2023-04-12 16:43:55
4
+ * @LastEditTime: 2023-05-04 12:10:01
5
+ * @Description:
6
+ */
7
+ import * as React from 'react';
2
8
  import { Bubble, ConfigProvider } from 'tea-component';
3
9
  import Button from '../../components/button';
4
- const Share = (props) => (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(Bubble, { content: "\u8BE5\u7EC4\u4EF6\u5FC5\u987B\u5728\u5C0F\u7A0B\u5E8F\u771F\u5B9E\u73AF\u5883\u4F7F\u7528\u624D\u80FD\u591F\u770B\u5230\u5B9E\u9645\u6548\u679C\u3002", children: _jsx(Button, { ...props }) }) }));
10
+ // @ts-ignore忽略ts交验
11
+ // eslint-disable-next-line rulesdir/no-phantom-deps,import/no-unresolved
12
+ import { autorun } from 'mobx';
13
+ const Share = (props) => {
14
+ var _a, _b;
15
+ const [editorPlatforms, setEditorPlatforms] = React.useState([]);
16
+ const dispose = React.useMemo(() => {
17
+ return autorun(() => {
18
+ var _a, _b;
19
+ setEditorPlatforms((_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.editorPlatforms);
20
+ });
21
+ }, []);
22
+ React.useEffect(() => {
23
+ return () => {
24
+ dispose();
25
+ };
26
+ }, [dispose]);
27
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: ((_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.isEditorMode) ||
28
+ (editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP')) ? (_jsx(Bubble, { content: "\u8BE5\u7EC4\u4EF6\u5FC5\u987B\u5728\u5C0F\u7A0B\u5E8F\u771F\u5B9E\u73AF\u5883\u4F7F\u7528\u624D\u80FD\u591F\u770B\u5230\u5B9E\u9645\u6548\u679C\u3002", children: _jsx(Button, { ...props }) })) : null }));
29
+ };
5
30
  export default Share;
@@ -87,5 +87,5 @@ export function UploadCSVFile({ parseFile, fields, datasourceTitle, dbName, setD
87
87
  setDisableNext(true);
88
88
  }, children: "\u5220\u9664" })] }) }), children: isDragging ? ('释放鼠标') : (_jsx(Status, { className: "upload-file", icon: 'blank', size: 's', operation: _jsxs(_Fragment, { children: [_jsx("a", { onClick: open, children: "\u70B9\u51FB\u4E0A\u4F20" }), " /", ' ', _jsx(Text, { theme: "weak", children: "\u62D6\u62FD\u5230\u6B64\u533A\u57DF" })] }) })) })) }) }), _jsx("div", { className: "modal-upload-text-wrap", children: _jsxs("ul", { children: [_jsxs("li", { children: ["1\u3001\u8BF7\u4E0B\u8F7D\u4F7F\u7528", _jsx("span", { onClick: () => {
89
89
  getCSVTemplate(fields, datasourceTitle);
90
- }, children: "\u00A0 \u5BFC\u5165\u6A21\u7248" }), "\uFF0C\u5E76\u6309\u7167\u793A\u4F8B\u586B\u5199\u6570\u636E\uFF0C\u4EE5\u4FDD\u8BC1\u6570\u636E\u5BFC\u5165\u987A\u5229"] }), _jsx("li", { children: "2\u3001\u652F\u6301xlsx\u7C7B\u578B\u6587\u4EF6\uFF0C\u8981\u6C42\u6587\u4EF6\u5927\u5C0F2M\u4EE5\u5185\uFF0C\u4E0D\u80FD\u8D85\u8FC710000\u884C" }), _jsxs("li", { children: [_jsx("div", { children: "3\u3001\u5BFC\u5165\u66F4\u65B0\u8BF4\u660E" }), _jsx("div", { children: "\u00A01\uFF09\u652F\u6301\u9009\u62E9\u5F00\u542F\u552F\u4E00\u5C5E\u6027\u7684\u5B57\u6BB5\uFF0C\u7528\u4E8E\u5339\u914D\u5E76\u66F4\u65B0\u5DF2\u6709\u7684\u6570\u636E\u8BB0\u5F55" }), _jsx("div", { children: "\u00A02\uFF09\u5BFC\u5165\u6A21\u5F0F\u4E3A\u300C\u65B0\u589E\u6216\u66F4\u65B0\u300D\u65F6\uFF0C\u5982\u300C\u6570\u636E\u6807\u8BC6\u300D\u5217\u4E3A\u7A7A\uFF0C\u8BE5\u884C\u6570\u636E\u4F1A\u6267\u884C\u65B0\u589E\u64CD\u4F5C" })] }), _jsxs("li", { children: [_jsx("div", { children: "4\u3001\u6570\u636E\u683C\u5F0F\u8BF4\u660E" }), _jsx("div", { children: "\u00A0 1\uFF09\u679A\u4E3E\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u9009\u62E9\u9009\u9879\u6807\u8BC6\u6216\u9009\u9879\u503C\u8FDB\u884C\u5BFC\u5165\uFF1A\u9009\u9879\u6807\u8BC6\u4E3A\u8868\u683C\u4E2D\u5C55\u793A\u7684\u4E1A\u52A1\u540D\u79F0\uFF1B\u9009\u9879\u503C\u4E3A\u9009\u9879\u7684\u7CFB\u7EDF\u552F\u4E00\u6807\u8BC6" }), _jsx("div", { children: "\u00A02\uFF09\u5173\u8054\u5173\u7CFB\u3001\u4E3B\u5B50\u660E\u7EC6\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u9009\u62E9\u4E3B\u5217\u5B57\u6BB5\u6216\u6570\u636E\u6807\u8BC6\u8FDB\u884C\u5BFC\u5165\uFF1A\u4E3B\u5217\u5B57\u6BB5\u4E3A\u8868\u683C\u4E2D\u5C55\u793A\u7684\u5173\u8054\u6570\u636E\u4E1A\u52A1\u540D\u79F0\uFF1B\u6570\u636E\u6807\u8BC6\u4E3A\u5173\u8054\u6570\u636E\u7684\u7CFB\u7EDF\u552F\u4E00\u6807\u8BC6" }), _jsx("div", { children: "\u00A03\uFF09\u5E03\u5C14\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u5BFC\u5165\u300C\u662F/\u5426\u300D\u6216\u300Ctrue/false\u300D" }), _jsx("div", { children: "\u00A04\uFF09\u56FE\u7247\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u5BFC\u5165https\u6216cloud\u534F\u8BAE\u7684\u56FE\u7247\u5730\u5740" }), _jsx("div", { children: "\u00A05\uFF09\u6587\u4EF6\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301cloud\u534F\u8BAE\u7684\u6587\u4EF6\u5730\u5740" }), _jsx("div", { children: "\u00A06\uFF09\u5730\u7406\u4F4D\u7F6E\u7C7B\u578B\u6570\u636E\uFF1A\u6570\u636E\u683C\u5F0F\u8981\u6C42\u4E3A\u5730\u70B9\u540D\u79F0(\u5750\u6807\u7ECF\u5EA6\uFF0C\u5750\u6807\u7EF4\u5EA6)" })] })] }) })] }));
90
+ }, children: "\u00A0 \u5BFC\u5165\u6A21\u7248" }), "\uFF0C\u5E76\u6309\u7167\u793A\u4F8B\u586B\u5199\u6570\u636E\uFF0C\u4EE5\u4FDD\u8BC1\u6570\u636E\u5BFC\u5165\u987A\u5229"] }), _jsx("li", { children: "2\u3001\u652F\u6301xlsx\u7C7B\u578B\u6587\u4EF6\uFF0C\u8981\u6C42\u6587\u4EF6\u5927\u5C0F2M\u4EE5\u5185\uFF0C\u4E0D\u80FD\u8D85\u8FC710000\u884C" }), _jsxs("li", { children: [_jsx("div", { children: "3\u3001\u5BFC\u5165\u66F4\u65B0\u8BF4\u660E" }), _jsx("div", { children: "\u00A01\uFF09\u652F\u6301\u9009\u62E9\u5F00\u542F\u552F\u4E00\u5C5E\u6027\u7684\u5B57\u6BB5\uFF0C\u7528\u4E8E\u5339\u914D\u5E76\u66F4\u65B0\u5DF2\u6709\u7684\u6570\u636E\u8BB0\u5F55" }), _jsx("div", { children: "\u00A02\uFF09\u5BFC\u5165\u6A21\u5F0F\u4E3A\u300C\u65B0\u589E\u6216\u66F4\u65B0\u300D\u65F6\uFF0C\u5982\u300C\u6570\u636E\u6807\u8BC6\u300D\u5217\u4E3A\u7A7A\uFF0C\u8BE5\u884C\u6570\u636E\u4F1A\u6267\u884C\u65B0\u589E\u64CD\u4F5C" }), _jsx("div", { children: "\u00A03\uFF09\u5355\u5143\u683C\u5185\u5BB9\u4E3A\u7A7A\u65F6\uFF0C\u8BE5\u7A7A\u503C\u5C06\u8986\u76D6\u539F\u6709\u6570\u636E\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C" })] }), _jsxs("li", { children: [_jsx("div", { children: "4\u3001\u6570\u636E\u683C\u5F0F\u8BF4\u660E" }), _jsx("div", { children: "\u00A0 1\uFF09\u679A\u4E3E\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u9009\u62E9\u9009\u9879\u6807\u8BC6\u6216\u9009\u9879\u503C\u8FDB\u884C\u5BFC\u5165\uFF1A\u9009\u9879\u6807\u8BC6\u4E3A\u8868\u683C\u4E2D\u5C55\u793A\u7684\u4E1A\u52A1\u540D\u79F0\uFF1B\u9009\u9879\u503C\u4E3A\u9009\u9879\u7684\u7CFB\u7EDF\u552F\u4E00\u6807\u8BC6" }), _jsx("div", { children: "\u00A02\uFF09\u5173\u8054\u5173\u7CFB\u3001\u4E3B\u5B50\u660E\u7EC6\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u9009\u62E9\u4E3B\u5217\u5B57\u6BB5\u6216\u6570\u636E\u6807\u8BC6\u8FDB\u884C\u5BFC\u5165\uFF1A\u4E3B\u5217\u5B57\u6BB5\u4E3A\u8868\u683C\u4E2D\u5C55\u793A\u7684\u5173\u8054\u6570\u636E\u4E1A\u52A1\u540D\u79F0\uFF1B\u6570\u636E\u6807\u8BC6\u4E3A\u5173\u8054\u6570\u636E\u7684\u7CFB\u7EDF\u552F\u4E00\u6807\u8BC6" }), _jsx("div", { children: "\u00A03\uFF09\u5E03\u5C14\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u5BFC\u5165\u300C\u662F/\u5426\u300D\u6216\u300Ctrue/false\u300D" }), _jsx("div", { children: "\u00A04\uFF09\u56FE\u7247\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301\u5BFC\u5165https\u6216cloud\u534F\u8BAE\u7684\u56FE\u7247\u5730\u5740" }), _jsx("div", { children: "\u00A05\uFF09\u6587\u4EF6\u7C7B\u578B\u6570\u636E\uFF1A\u652F\u6301cloud\u534F\u8BAE\u7684\u6587\u4EF6\u5730\u5740" }), _jsx("div", { children: "\u00A06\uFF09\u5730\u7406\u4F4D\u7F6E\u7C7B\u578B\u6570\u636E\uFF1A\u6570\u636E\u683C\u5F0F\u8981\u6C42\u4E3A\u5730\u70B9\u540D\u79F0(\u5750\u6807\u7ECF\u5EA6\uFF0C\u5750\u6807\u7EF4\u5EA6)" })] })] }) })] }));
91
91
  }
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import classNames from '../../utils/classnames';
4
+ import { useConfig } from '../../utils/config-context';
5
+ import getLocalCounter from '../../utils/getLocalCounter';
6
+ export const WdCheckbox = ({ index, option, name, size, disabled, readOnly, checkedItemValue, getChangeHandler, isAll, }) => {
7
+ const { classPrefix } = useConfig();
8
+ const { label, value: optionValue } = option;
9
+ // 类名
10
+ const classList = [];
11
+ switch (size) {
12
+ case 'sm':
13
+ classList.push(`size-sm `);
14
+ break;
15
+ case 'md':
16
+ classList.push(`size-md `);
17
+ break;
18
+ case 'lg':
19
+ classList.push(`size-lg `);
20
+ break;
21
+ default:
22
+ classList.push();
23
+ }
24
+ // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
25
+ const hashcode = React.useMemo(() => getLocalCounter(), []);
26
+ const _id = `checkbox-${hashcode}-${index}`;
27
+ const _name = `checkbox-${hashcode}-${name}`;
28
+ const NUMBER_1 = 1;
29
+ return (_jsxs("div", { className: `${classPrefix}-checkbox-wrap ${classNames(classList)} ${checkedItemValue[optionValue] ? 'is-checked' : ''} ${isAll ? 'is-indeterminate' : ''} ${disabled || readOnly ? 'is-disabled' : ''} ${'checkbox' + (index + NUMBER_1)}`, "data-testid": "wd-checkbox-test", onClickCapture: (e) => {
30
+ e.stopPropagation();
31
+ e.preventDefault();
32
+ getChangeHandler(e, optionValue);
33
+ }, children: [_jsx("input", { className: `${classPrefix}-checkbox-input `, type: "checkbox", id: _id, name: _name, value: optionValue, disabled: disabled || readOnly, checked: !!checkedItemValue[optionValue], onChange: (e) => e.stopPropagation() }), _jsx("span", { className: `${classPrefix}-checkbox-inner ` }), label && (_jsx("span", { className: `${classPrefix}-checkbox-label`, children: label }))] }, _id));
34
+ };
@@ -0,0 +1,3 @@
1
+ import { WdCheckbox } from './checkbox';
2
+ export { WdCheckbox } from './checkbox';
3
+ export default WdCheckbox;
@@ -0,0 +1,140 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import * as React from 'react';
4
+ import classNames from '../../utils/classnames';
5
+ import { useConfig } from '../../utils/config-context';
6
+ import { WdCheckbox } from '../wd-checkbox';
7
+ import { WdFormItem } from '../wd-form-item';
8
+ import { emptyObject } from '../../utils/constant';
9
+ import { usePlatform } from '../../utils/platform';
10
+ import { useFormInputTrait } from '../form-input-hooks';
11
+ import fromEntries from 'object.fromentries';
12
+ import { callWedaApi } from '../../utils/tcb';
13
+ import destr from 'destr';
14
+ import { useSize } from '../../utils/hooks/useFormLegacy';
15
+ export const WdCheckboxList = React.forwardRef(function WdCheckboxList(props, inputRef) {
16
+ const { range: propRange, direction, events = emptyObject, format = '', enumName = '', label, } = props;
17
+ const [innerHandle, setInnerHandle] = React.useState({}); // hook里挂出的属性
18
+ const size = useSize(props);
19
+ const platform = usePlatform();
20
+ const { classPrefix } = useConfig();
21
+ const compClassName = `${classPrefix}-checkbox-group `;
22
+ // 类名
23
+ const classList = [compClassName];
24
+ ['inline'].includes(direction) &&
25
+ classList.push(`${classPrefix}-checkbox-group--inline `);
26
+ /** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
27
+ const traitProps = { ...props, inputRef, setInnerHandle };
28
+ const { value: defaultValue, onChange: outerOnChange, disabled, readOnly, validateErrorMsg, validateState, visible, name, value, required, layout, } = useFormInputTrait(traitProps);
29
+ const [options, setOptions] = React.useState(format === 'x-enum' ? [] : propRange);
30
+ const [enumOptions, setEnumOptions] = React.useState([]);
31
+ const [checkedItemValue, setCheckedItemValue] = React.useState(fromEntries(options.map(({ value, checked }) => [value, !!checked])));
32
+ /**
33
+ * 在ios h5端, label和input的绑定不生效
34
+ * 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
35
+ */
36
+ const getChangeHandler = function (e, value) {
37
+ const checked = !checkedItemValue[value];
38
+ const newMap = Object.assign({}, checkedItemValue, {
39
+ [value]: checked,
40
+ });
41
+ if (!disabled && !readOnly) {
42
+ setCheckedItemValue(newMap);
43
+ const value = Object.entries(newMap)
44
+ .filter(([, checked]) => checked)
45
+ .map(([value]) => value);
46
+ events === null || events === void 0 ? void 0 : events.change({ value }, { originEvent: e });
47
+ outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange(value);
48
+ }
49
+ };
50
+ React.useEffect(() => {
51
+ setCheckedItemValue(fromEntries(options.map(({ value, checked }) => [value, !!checked])));
52
+ }, [options]);
53
+ React.useEffect(() => {
54
+ if (format !== 'x-enum') {
55
+ const opts = propRange &&
56
+ propRange.map((item) => {
57
+ const checked = defaultValue &&
58
+ defaultValue.find((val) => `${val}` === `${item.value}`);
59
+ return {
60
+ value: item.value,
61
+ label: item.label,
62
+ checked: !!checked,
63
+ };
64
+ });
65
+ setOptions(opts);
66
+ }
67
+ }, [propRange, defaultValue, format]);
68
+ React.useEffect(() => {
69
+ // 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
70
+ if (format === 'x-enum' && enumName) {
71
+ fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
72
+ }
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, []);
75
+ React.useImperativeHandle(inputRef, () => ({
76
+ ...innerHandle,
77
+ name,
78
+ value,
79
+ label,
80
+ required,
81
+ visible,
82
+ disabled,
83
+ readOnly,
84
+ }), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
85
+ const fetchData = async (param) => {
86
+ var _a, _b, _c;
87
+ const data = await callWedaApi({
88
+ action: 'DescribeGeneralOptionsDetailList',
89
+ data: param,
90
+ });
91
+ /* istanbul ignore next */
92
+ const config = (_c = destr((_b = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Config)) !== null && _c !== void 0 ? _c : [];
93
+ const enumOption = config.map((item) => {
94
+ return {
95
+ label: item.value,
96
+ value: item.key,
97
+ checked: false,
98
+ };
99
+ });
100
+ setEnumOptions(enumOption);
101
+ const opt = enumOption &&
102
+ enumOption.map((item) => {
103
+ const checked = defaultValue &&
104
+ defaultValue.find((val) => `${val}` === `${item.value}`);
105
+ return {
106
+ value: item.value,
107
+ label: item.label,
108
+ checked: !!checked,
109
+ };
110
+ });
111
+ setOptions(opt);
112
+ };
113
+ React.useEffect(() => {
114
+ if (format === 'x-enum') {
115
+ const opt = enumOptions &&
116
+ enumOptions.map((item) => {
117
+ const checked = defaultValue &&
118
+ defaultValue.find((val) => `${val}` === `${item.value}`);
119
+ return {
120
+ value: item.value,
121
+ label: item.label,
122
+ checked: !!checked,
123
+ };
124
+ });
125
+ setOptions(opt);
126
+ }
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ }, [defaultValue, format]);
129
+ const labelSize = () => {
130
+ if (['h5'].includes(platform) ||
131
+ (['horizontal', ''].includes(layout) &&
132
+ ['vertical'].includes(direction))) {
133
+ return 'xs';
134
+ }
135
+ return size;
136
+ };
137
+ return (visible && (_jsx(WdFormItem, { ...props, testId: "form-checkbox-list", validateErrorMsg: validateErrorMsg, validateState: validateState, readValue: defaultValue, disabled: disabled, classRoot: 'checkbox', size: labelSize(), layout: layout, children: _jsx("div", { className: classNames(classList), children: options === null || options === void 0 ? void 0 : options.map((Item, index) => {
138
+ return (_createElement(WdCheckbox, { ...props, size: ['h5'].includes(platform) ? 'lg' : props === null || props === void 0 ? void 0 : props.size, key: index, index: index, option: Item, disabled: disabled, readOnly: readOnly, getChangeHandler: getChangeHandler, checkedItemValue: checkedItemValue }));
139
+ }) }) })));
140
+ });
@@ -0,0 +1,3 @@
1
+ import { WdCheckboxList } from './checkboxList';
2
+ export { WdCheckboxList } from './checkboxList';
3
+ export default WdCheckboxList;
@@ -1,4 +1,4 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, useEffect } from 'react';
2
2
  import { debug } from '../../../utils/console';
3
3
  import { usePlatform } from '../../../utils/platform';
4
4
  import { alertError } from '../../form/form';
@@ -19,7 +19,7 @@ methodGetItem, paramGetItem, appCloud, isDataModel, }) {
19
19
  console.error(err);
20
20
  alertError(platform, '表单容器数据查询失败');
21
21
  }, [platform]);
22
- const { data: remoteValue, error, isLoading, } = useSWR(() => {
22
+ const { data: remoteValue, error, isLoading, mutate, } = useSWR(() => {
23
23
  if (!formTypeWithInitValue.includes(formType) || !dataSourceName) {
24
24
  logger.debug('formType没有初始值或者,没配数据源', {
25
25
  formType,
@@ -70,10 +70,17 @@ methodGetItem, paramGetItem, appCloud, isDataModel, }) {
70
70
  }, true);
71
71
  }, {
72
72
  onError: onInitialValuesError,
73
+ revalidateOnFocus: false,
73
74
  });
75
+ useEffect(() => {
76
+ return () => {
77
+ mutate();
78
+ };
79
+ }, [mutate]);
74
80
  return {
75
81
  remoteValue,
76
82
  error,
77
83
  isLoading,
84
+ mutate,
78
85
  };
79
86
  }
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- /* eslint max-lines: [error, 500] */
2
+ /* eslint max-lines: [error, 600] */
3
3
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
4
- import { useDebouncedCallback, useMap, useMountEffect, useSyncedRef, } from '@react-hookz/web';
4
+ import { useDebouncedCallback, useDebouncedEffect, useMap, useMountEffect, useSyncedRef, } from '@react-hookz/web';
5
5
  import { isInIde, usePlatform } from '../../utils/platform';
6
- import { ConfigProvider, Form as TeaForm } from 'tea-component';
7
6
  import classNames from '../../utils/classnames';
8
7
  import { debug } from '../../utils/console';
9
8
  import { useWedaAppContext } from '../../utils/widget-api';
@@ -16,10 +15,12 @@ import lodashSet from 'lodash.set';
16
15
  import lodashGet from 'lodash.get';
17
16
  import isObjectEqual from '../../utils/isObjectEqual';
18
17
  import { useDataSource } from '../../utils/hooks/useDataSource';
18
+ import { WdForm as FormUi } from './wd-form';
19
+ const SET_VALUE_DEBOUNCE_TIMEOUT = 200;
19
20
  const logger = debug('wd-form');
20
21
  const WdForm = React.forwardRef(function WdForm(props, ref) {
21
22
  var _a;
22
- const { className, id, style, contentSlot: contentSlotEl, layout, formType, _id, datasourceType, dataSourceName, methodGetItem, paramGetItem, appCloud = tcbAppCloud,
23
+ const { className, id, style, contentSlot: contentSlotEl, layout, formType, _id, datasourceType, dataSourceName, methodGetItem, methodCreate, methodUpdate, paramGetItem, appCloud = tcbAppCloud,
23
24
  // 兼容流程setValue调用,其他地方别用
24
25
  $node, } = props;
25
26
  const formItemMap = useMap([]);
@@ -37,7 +38,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
37
38
  'weui-form': platform === 'h5',
38
39
  'weda-form-pc': platform === 'pc',
39
40
  'gsd-h5-react-form-pc': platform === 'pc',
41
+ 'wedatea2td-form': platform === 'pc',
40
42
  }, className);
43
+ const isDataModel = !['connector', 'custom-connector'].includes(datasourceType); // 是否为数据模型,兼容历史 undefined
44
+ const hasSetInitValueRef = useRef(false);
41
45
  const [initialValues, setInitialValues] = useState((_a = props.initialValues) !== null && _a !== void 0 ? _a : emptyObject);
42
46
  const eventsRef = useSyncedRef(props.events);
43
47
  const validate = useCallback(async () => {
@@ -70,6 +74,17 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
70
74
  return errObj;
71
75
  }, [formItemMap]);
72
76
  const [errors, setErrors] = useState(undefined);
77
+ const { remoteValue: fetchedInitialValues, isLoading: isLoadingInitValues, error: initValueFetchError, } = useRemoteValue({
78
+ appCloud,
79
+ formType,
80
+ _id,
81
+ // methodCreate,
82
+ methodGetItem,
83
+ // methodUpdate,
84
+ paramGetItem,
85
+ dataSourceName,
86
+ isDataModel,
87
+ });
73
88
  const submit = useCallback(async () => {
74
89
  const { submit } = eventsRef.current;
75
90
  const errorObj = await validate();
@@ -95,7 +110,7 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
95
110
  }
96
111
  });
97
112
  }, [eventsRef, formItemMap]);
98
- const setValue = useCallback((data, setNull) => {
113
+ const setValue = useDebouncedCallback((data, setNull) => {
99
114
  if (typeof data !== 'object' || typeof data === null) {
100
115
  console.warn('setValue data need expect a object but got', data);
101
116
  return;
@@ -114,7 +129,7 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
114
129
  }
115
130
  });
116
131
  updateFormContext();
117
- }, [formItemMap, updateFormContext]);
132
+ }, [formItemMap, updateFormContext], SET_VALUE_DEBOUNCE_TIMEOUT);
118
133
  const clearValidate = useCallback(() => {
119
134
  formItemMap.forEach((item) => {
120
135
  if (!item.clearValidate || typeof item.clearValidate !== 'function') {
@@ -127,6 +142,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
127
142
  // useWhatChanged([formItemMap, initialValues, submit, validate]);
128
143
  useLoopRenderDetect();
129
144
  const { ready } = useWedaAppContext();
145
+ const [visible, setVisible] = React.useState(false);
146
+ React.useEffect(() => {
147
+ setVisible(true);
148
+ }, []);
130
149
  const previousFormType = useRef(null);
131
150
  useEffect(() => {
132
151
  if (!ready) {
@@ -143,8 +162,16 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
143
162
  }
144
163
  else {
145
164
  formItemMap.forEach((item) => {
146
- var _a;
147
- item.setReadOnly((_a = item.initialDisabled) !== null && _a !== void 0 ? _a : false);
165
+ const { initialReadOnly, initialDisabled } = item || {};
166
+ if (initialReadOnly) {
167
+ item.setReadOnly(true);
168
+ }
169
+ else if (initialDisabled) {
170
+ item.setDisabled(true);
171
+ }
172
+ else {
173
+ item.setReadOnly(false);
174
+ }
148
175
  });
149
176
  }
150
177
  });
@@ -152,18 +179,6 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
152
179
  useMountEffect(() => {
153
180
  logger.debug('formItemMap', formItemMap);
154
181
  });
155
- const isDataModel = !['connector', 'custom-connector'].includes(datasourceType); // 是否为数据模型,兼容历史 undefined
156
- const { remoteValue: fetchedInitialValues, isLoading: isLoadingInitValues, error: initValueFetchError, } = useRemoteValue({
157
- appCloud,
158
- formType,
159
- _id,
160
- // methodCreate,
161
- methodGetItem,
162
- // methodUpdate,
163
- paramGetItem,
164
- dataSourceName,
165
- isDataModel,
166
- });
167
182
  useEffect(() => {
168
183
  if (isLoadingInitValues)
169
184
  return;
@@ -172,8 +187,13 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
172
187
  错误处理放在了 @link {onInitialValuesError}
173
188
  下面是可以拿到data了
174
189
  */
175
- // TODO: 有哪些key可以暴露
176
- setInitialValues(fetchedInitialValues);
190
+ setInitialValues((original) => {
191
+ if (hasSetInitValueRef.current) {
192
+ return original;
193
+ }
194
+ hasSetInitValueRef.current = true;
195
+ return fetchedInitialValues;
196
+ });
177
197
  setValue(fetchedInitialValues, true);
178
198
  }
179
199
  }, [fetchedInitialValues, initValueFetchError, isLoadingInitValues, setValue]);
@@ -286,6 +306,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
286
306
  dataSourceProfile,
287
307
  errors,
288
308
  clearValidate,
309
+ datasourceType,
310
+ methodCreate,
311
+ methodUpdate,
312
+ methodGetItem,
289
313
  };
290
314
  }, [
291
315
  authValue,
@@ -303,6 +327,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
303
327
  clearValidate,
304
328
  updateFormContext,
305
329
  formData,
330
+ datasourceType,
331
+ methodCreate,
332
+ methodUpdate,
333
+ methodGetItem,
306
334
  ]);
307
335
  const setInitValue = useDebouncedCallback(() => {
308
336
  var _a;
@@ -314,10 +342,12 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
314
342
  }
315
343
  }
316
344
  updateFormContext();
317
- }, [formItemMap, initialValues, updateFormContext],
318
- // eslint-disable-next-line @typescript-eslint/no-magic-numbers
319
- 200);
345
+ }, [formItemMap, initialValues, updateFormContext], SET_VALUE_DEBOUNCE_TIMEOUT);
346
+ const lastInitValueRef = useRef(null);
320
347
  React.useEffect(() => {
348
+ if (isObjectEqual(lastInitValueRef.current, initialValues)) {
349
+ return;
350
+ }
321
351
  // 单向 Form向下设置值
322
352
  let setValueReady = false;
323
353
  const timeout = 30;
@@ -337,19 +367,23 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
337
367
  setInitValue();
338
368
  };
339
369
  setValueUntilReady();
370
+ lastInitValueRef.current = initialValues;
340
371
  return () => {
341
372
  if (id) {
342
373
  clearTimeout(id);
343
374
  }
344
375
  };
345
376
  });
346
- useEffect(() => {
377
+ useDebouncedEffect(() => {
347
378
  formItemMap.forEach((item) => {
348
379
  var _a;
349
380
  (_a = item === null || item === void 0 ? void 0 : item.forceUpdate) === null || _a === void 0 ? void 0 : _a.call(item);
350
381
  });
351
- // eslint-disable-next-line react-hooks/exhaustive-deps
352
- }, [layout]);
382
+ }, [formItemMap, layout, formItemMapKey],
383
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
384
+ 15,
385
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
386
+ 30);
353
387
  useLayoutEffect(() => {
354
388
  // 兼容流程
355
389
  if ($node) {
@@ -363,12 +397,13 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
363
397
  };
364
398
  }
365
399
  }, [$node, setValue, submit]);
366
- if (platform === 'h5') {
367
- return (_jsx("div", { className: cls, style: style, id: id, children: _jsx("div", { className: "weui-cells__group weui-cells__group_form", children: contentSlot }) }));
368
- }
369
- else {
370
- return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx(TeaForm, { layout: layout, className: cls, style: style, id: id, children: contentSlot }) }));
371
- }
400
+ const labelPosition = useMemo(() => {
401
+ if (layout === 'horizontal') {
402
+ return 'horizontal-left';
403
+ }
404
+ return 'vertical-left';
405
+ }, [layout]);
406
+ return (_jsx(FormUi, { layout: layout, className: cls, style: style, id: id, labelPosition: labelPosition, children: visible && contentSlot }));
372
407
  });
373
408
  function getFormDataFromItemMap(formItemMap) {
374
409
  const formData = {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import classNames from '../../utils/classnames';
3
+ import { useConfig } from '../../utils/config-context';
4
+ // import type { DataType } from '../../../configs/components/wd-form';
5
+ import { usePlatform } from '../../utils/platform';
6
+ // import { Input, ConfigProvider } from 'tea-component';
7
+ export const WdForm = ({ className, layout, labelPosition, children, ...rest }) => {
8
+ const platform = usePlatform();
9
+ // 兼容旧版组件的属性值
10
+ const { classPrefix } = useConfig();
11
+ // const InputWrap = React.useRef(null);
12
+ const formType = '';
13
+ const compClassName = `${classPrefix}-form`;
14
+ // 类名
15
+ const classList = [compClassName];
16
+ // weui添加className
17
+ ['weui'].includes(formType) && classList.push(`${classPrefix}-form--weui `);
18
+ platform === 'h5' && classList.push(`${classPrefix}-form--weui `);
19
+ layout === 'inline' && classList.push(`${classPrefix}-form--inline `);
20
+ switch (labelPosition) {
21
+ case 'horizontal-right':
22
+ classList.push(`${classPrefix}-form--horizontal-right`);
23
+ break;
24
+ case 'vertical-left':
25
+ classList.push(`${classPrefix}-form--vertical-left`);
26
+ break;
27
+ case 'vertical-right':
28
+ classList.push(`${classPrefix}-form--vertical-right`);
29
+ break;
30
+ default:
31
+ classList.push();
32
+ }
33
+ // 用户定义的className
34
+ classList.push(className);
35
+ if (platform === 'h5') {
36
+ classList.push('wd-h5-form');
37
+ }
38
+ else {
39
+ classList.push('wd-pc-form');
40
+ }
41
+ return (_jsx("div", { ...rest, className: classNames(...classList), children: children }));
42
+ };
@@ -0,0 +1,3 @@
1
+ import { WdFormCell } from './wd-form-cell';
2
+ export { WdFormCell } from './wd-form-cell';
3
+ export default WdFormCell;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classNames from '../../utils/classnames';
3
+ import { useConfig } from '../../utils/config-context';
4
+ import { usePlatform } from '../../utils/platform';
5
+ import { WdIcon } from '../wd-icon';
6
+ export const WdFormCell = ({ className, layout, labelPosition, label, children, }) => {
7
+ const platform = usePlatform();
8
+ // 兼容旧版组件的属性值
9
+ const { classPrefix } = useConfig();
10
+ // const InputWrap = React.useRef(null);
11
+ const formType = '';
12
+ const compClassName = `${classPrefix}-form-item `;
13
+ // 类名
14
+ const classList = [compClassName];
15
+ // weui添加className
16
+ ['weui'].includes(formType) &&
17
+ classList.push(`${classPrefix}-form-item--weui `);
18
+ // @ts-expect-error 兼容入参
19
+ layout === 'inline' && classList.push(`${classPrefix}-form-item--inline `);
20
+ switch (labelPosition) {
21
+ case 'horizontal-right':
22
+ classList.push(`${classPrefix}-form-item--horizontal-right `);
23
+ break;
24
+ case 'vertical-left':
25
+ classList.push(`${classPrefix}-form-item--vertical-left `);
26
+ break;
27
+ case 'vertical-right':
28
+ classList.push(`${classPrefix}-form-item--vertical-right `);
29
+ break;
30
+ default:
31
+ classList.push();
32
+ }
33
+ // 用户定义的className
34
+ classList.push(className);
35
+ if (platform === 'h5') {
36
+ classList.push('wd-h5-form-item');
37
+ }
38
+ else {
39
+ classList.push('wd-pc-for-item');
40
+ }
41
+ return (_jsx("div", { className: `${classNames(...classList)} is-required`, children: _jsxs("div", { className: `${classPrefix}-form-item-wrap`, children: [_jsx("div", { className: `${classPrefix}-form-item-wrap__label is-nowrap`, children: _jsxs("label", { children: [_jsx("span", { className: `${classPrefix}-form-item-wrap__label-text`, children: label || '' }), _jsx("span", { className: `${classPrefix}-form-item-wrap__label-explain`, children: _jsx(WdIcon, { name: "td:help-circle" }) })] }) }), _jsx("div", { className: `${classPrefix}-form-item-wrap__control`, children: _jsx("div", { className: `${classPrefix}-form-item-wrap__control-wrap`, children: children }) })] }) }));
42
+ };
@@ -0,0 +1,4 @@
1
+ import { WdFormItem } from './wd-form-item';
2
+ import { WdInputGroup } from './wd-input-group';
3
+ export { WdFormItem, WdInputGroup };
4
+ export default WdFormItem;