@cloudbase/weda-ui 3.4.11 → 3.4.12

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 (150) 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-email.js +17 -2
  6. package/dist/configs/components/form-input.js +17 -2
  7. package/dist/configs/components/form-phone.js +17 -2
  8. package/dist/configs/components/form-radio.js +15 -2
  9. package/dist/configs/components/form-select-multiple.js +362 -0
  10. package/dist/configs/components/form-switch.js +15 -2
  11. package/dist/configs/components/form-text-area.js +15 -2
  12. package/dist/configs/components/form-url.js +17 -2
  13. package/dist/configs/components/form-user-tree-select.js +13 -0
  14. package/dist/configs/components/listView.js +32 -49
  15. package/dist/configs/components/table.json +1 -54
  16. package/dist/configs/components/wd-bubble.js +46 -8
  17. package/dist/configs/components/wd-button.js +3 -0
  18. package/dist/configs/components/wd-checkbox.js +464 -0
  19. package/dist/configs/components/wd-form.js +66 -10
  20. package/dist/configs/components/wd-input-email.js +37 -0
  21. package/dist/configs/components/wd-input-phone.js +43 -0
  22. package/dist/configs/components/wd-input-url.js +37 -0
  23. package/dist/configs/components/wd-input.js +94 -0
  24. package/dist/configs/components/wd-official-account.js +87 -0
  25. package/dist/configs/components/wd-radio.js +443 -0
  26. package/dist/configs/components/wd-switch.js +315 -0
  27. package/dist/configs/components/wd-table.js +8 -56
  28. package/dist/configs/components/wd-textarea.js +82 -0
  29. package/dist/configs/components/wd-tree.js +443 -0
  30. package/dist/configs/components/web-view.js +3 -0
  31. package/dist/configs/index.js +24 -1
  32. package/dist/configs/type-utils/type-form.js +681 -0
  33. package/dist/docs/common/components/json-schema-view.js +1 -1
  34. package/dist/docs/common/components/methods-view.js +1 -1
  35. package/dist/docs/common/components/properties-view.js +3 -1
  36. package/dist/docs/common/format.js +7 -7
  37. package/dist/docs/common/tableView.js +3 -1
  38. package/dist/enum/index.js +196 -0
  39. package/dist/style/index.scss +1 -1
  40. package/dist/web/actions/showMessage/index.js +4 -1
  41. package/dist/web/components/carousel/index.js +1 -1
  42. package/dist/web/components/customer-service/customer-service.js +19 -2
  43. package/dist/web/components/dataView/index.js +16 -3
  44. package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
  45. package/dist/web/components/flow/common/request.js +5 -5
  46. package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +90 -0
  47. package/dist/web/components/form/formcell/index.css +13 -1
  48. package/dist/web/components/form/formcell/index.js +1 -1
  49. package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
  50. package/dist/web/components/form/select/dropdown-select/index.js +7 -1
  51. package/dist/web/components/form/select/h5.js +18 -8
  52. package/dist/web/components/form/select/index.js +9 -9
  53. package/dist/web/components/form/select/region/index.js +1 -1
  54. package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
  55. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
  56. package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
  57. package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
  58. package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
  59. package/dist/web/components/form/selectMultiple/h5.js +40 -0
  60. package/dist/web/components/form/selectMultiple/index.js +94 -0
  61. package/dist/web/components/form/selectMultiple/request.js +76 -0
  62. package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
  63. package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
  64. package/dist/web/components/form/selectMultiple/status/index.css +63 -0
  65. package/dist/web/components/form/selectMultiple/status/index.js +7 -0
  66. package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
  67. package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
  68. package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
  69. package/dist/web/components/form/tips/index.css +9 -3
  70. package/dist/web/components/form/uploader/index.css +10 -0
  71. package/dist/web/components/form/uploader/uploader.h5.js +60 -62
  72. package/dist/web/components/form/uploader/uploader.pc.js +48 -41
  73. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
  74. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
  75. package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
  76. package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
  77. package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
  78. package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
  79. package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
  80. package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
  81. package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
  82. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +57 -10
  83. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
  84. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
  85. package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
  86. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
  87. package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +3 -3
  88. package/dist/web/components/form-input-hooks/index.js +39 -14
  89. package/dist/web/components/form-select-multiple/index.js +26 -0
  90. package/dist/web/components/form-user-tree-select/index.js +2 -2
  91. package/dist/web/components/formdetail/index.css +31 -1
  92. package/dist/web/components/formdetail/index.js +30 -0
  93. package/dist/web/components/index.js +17 -1
  94. package/dist/web/components/listView/index.js +20 -5
  95. package/dist/web/components/phone/index.js +26 -1
  96. package/dist/web/components/phoneCode/index.js +3 -1
  97. package/dist/web/components/richText/index.css +70 -67
  98. package/dist/web/components/richText/index.js +311 -251
  99. package/dist/web/components/richText/richtext.module.css +1 -0
  100. package/dist/web/components/richTextView/index.css +39 -0
  101. package/dist/web/components/richTextView/index.js +1 -1
  102. package/dist/web/components/share/index.js +26 -1
  103. package/dist/web/components/wd-checkbox/checkbox.js +34 -0
  104. package/dist/web/components/wd-checkbox/index.js +3 -0
  105. package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
  106. package/dist/web/components/wd-checkbox-list/index.js +3 -0
  107. package/dist/web/components/wd-form/index.js +25 -12
  108. package/dist/web/components/wd-form/wd-form.js +42 -0
  109. package/dist/web/components/wd-form-cell/index.js +3 -0
  110. package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
  111. package/dist/web/components/wd-form-item/index.js +4 -0
  112. package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
  113. package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
  114. package/dist/web/components/wd-input/index.js +3 -0
  115. package/dist/web/components/wd-input/wd-input.js +155 -0
  116. package/dist/web/components/wd-input-email/index.js +3 -0
  117. package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
  118. package/dist/web/components/wd-input-group/index.js +3 -0
  119. package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
  120. package/dist/web/components/wd-input-phone/index.js +3 -0
  121. package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
  122. package/dist/web/components/wd-input-url/index.js +3 -0
  123. package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
  124. package/dist/web/components/wd-input-wrap/index.js +3 -0
  125. package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
  126. package/dist/web/components/wd-official-account/index.css +29 -0
  127. package/dist/web/components/wd-official-account/index.js +36 -0
  128. package/dist/web/components/wd-radio/index.js +3 -0
  129. package/dist/web/components/wd-radio/wd-radio.js +30 -0
  130. package/dist/web/components/wd-radio-list/index.js +3 -0
  131. package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
  132. package/dist/web/components/wd-switch/index.js +3 -0
  133. package/dist/web/components/wd-switch/wd-switch.js +52 -0
  134. package/dist/web/components/wd-table/components/FieldRender/index.js +5 -4
  135. package/dist/web/components/wd-table/components/Table/index.js +12 -2
  136. package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
  137. package/dist/web/components/wd-table/utils/index.js +6 -2
  138. package/dist/web/components/wd-table/wd-table.js +70 -57
  139. package/dist/web/components/wd-textarea/index.js +3 -0
  140. package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
  141. package/dist/web/components/wd-tree/index.js +3 -0
  142. package/dist/web/components/wd-tree/utils.js +291 -0
  143. package/dist/web/components/wd-tree/wd-tree.js +193 -0
  144. package/dist/web/utils/constant.js +16 -0
  145. package/dist/web/utils/datasource.js +2 -2
  146. package/dist/web/utils/date.js +3 -3
  147. package/dist/web/utils/hooks/useFormLegacy.js +111 -0
  148. package/dist/web/utils/tool.js +12 -2
  149. package/dist/web/weda-ui.css +193 -3
  150. 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;
@@ -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,9 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  /* eslint max-lines: [error, 500] */
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,11 @@ 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
19
  const logger = debug('wd-form');
20
20
  const WdForm = React.forwardRef(function WdForm(props, ref) {
21
21
  var _a;
22
- const { className, id, style, contentSlot: contentSlotEl, layout, formType, _id, datasourceType, dataSourceName, methodGetItem, paramGetItem, appCloud = tcbAppCloud,
22
+ const { className, id, style, contentSlot: contentSlotEl, layout, formType, _id, datasourceType, dataSourceName, methodGetItem, methodCreate, methodUpdate, paramGetItem, appCloud = tcbAppCloud,
23
23
  // 兼容流程setValue调用,其他地方别用
24
24
  $node, } = props;
25
25
  const formItemMap = useMap([]);
@@ -37,6 +37,7 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
37
37
  'weui-form': platform === 'h5',
38
38
  'weda-form-pc': platform === 'pc',
39
39
  'gsd-h5-react-form-pc': platform === 'pc',
40
+ 'wedatea2td-form': platform === 'pc',
40
41
  }, className);
41
42
  const [initialValues, setInitialValues] = useState((_a = props.initialValues) !== null && _a !== void 0 ? _a : emptyObject);
42
43
  const eventsRef = useSyncedRef(props.events);
@@ -286,6 +287,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
286
287
  dataSourceProfile,
287
288
  errors,
288
289
  clearValidate,
290
+ datasourceType,
291
+ methodCreate,
292
+ methodUpdate,
293
+ methodGetItem,
289
294
  };
290
295
  }, [
291
296
  authValue,
@@ -303,6 +308,10 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
303
308
  clearValidate,
304
309
  updateFormContext,
305
310
  formData,
311
+ datasourceType,
312
+ methodCreate,
313
+ methodUpdate,
314
+ methodGetItem,
306
315
  ]);
307
316
  const setInitValue = useDebouncedCallback(() => {
308
317
  var _a;
@@ -343,13 +352,16 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
343
352
  }
344
353
  };
345
354
  });
346
- useEffect(() => {
355
+ useDebouncedEffect(() => {
347
356
  formItemMap.forEach((item) => {
348
357
  var _a;
349
358
  (_a = item === null || item === void 0 ? void 0 : item.forceUpdate) === null || _a === void 0 ? void 0 : _a.call(item);
350
359
  });
351
- // eslint-disable-next-line react-hooks/exhaustive-deps
352
- }, [layout]);
360
+ }, [formItemMap, layout, formItemMapKey],
361
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
362
+ 15,
363
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
364
+ 30);
353
365
  useLayoutEffect(() => {
354
366
  // 兼容流程
355
367
  if ($node) {
@@ -363,12 +375,13 @@ const WdForm = React.forwardRef(function WdForm(props, ref) {
363
375
  };
364
376
  }
365
377
  }, [$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
- }
378
+ const labelPosition = useMemo(() => {
379
+ if (layout === 'horizontal') {
380
+ return 'horizontal-left';
381
+ }
382
+ return 'vertical-left';
383
+ }, [layout]);
384
+ return (_jsx(FormUi, { layout: layout, className: cls, style: style, id: id, labelPosition: labelPosition, children: contentSlot }));
372
385
  });
373
386
  function getFormDataFromItemMap(formItemMap) {
374
387
  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;
@@ -0,0 +1,55 @@
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 { WdIcon } from '../wd-icon';
5
+ import { WdBubble } from '../wd-bubble';
6
+ import { usePlatform } from '../../utils/platform';
7
+ import { useLabelAlign, useLayout, useSize, convertPx, } from '../../utils/hooks/useFormLegacy';
8
+ /**
9
+ * 表单项包裹,包括标题、文本提示、校验
10
+ */
11
+ export function WdFormItem(props) {
12
+ const { id, className, style, label, labelVisible, labelTips, labelWidth: _labelWidth, labelWrap, extra, required, readOnly, children, testId, requiredFlag, validateState, validateErrorMsg, readValue, borderedH5, borderedPc, classRoot, controlAlign, inputId, } = props;
13
+ const { classPrefix } = useConfig();
14
+ const platform = usePlatform();
15
+ const labelAlign = useLabelAlign(props);
16
+ const layout = useLayout(props);
17
+ const labelWidth = convertPx(_labelWidth);
18
+ const labelStyle = labelWidth ? { width: labelWidth } : {};
19
+ const _size = useSize(props);
20
+ const size = _size === 'xs' ? 'xs' : platform === 'h5' ? 'lg' : _size;
21
+ // 样式前缀定义
22
+ const root = `${classPrefix}-${classRoot}`;
23
+ const item = `${classPrefix}-form-item`;
24
+ const itemWrap = `${classPrefix}-form-item-wrap`;
25
+ const labelRoot = `${root}__label`;
26
+ // 表单项样式
27
+ const cls = classNames(item, className, `${classPrefix}-${platform}-form-item`, `${root}-root`, `${classPrefix}-${platform}-${classRoot}-root`, `item-size-height-${size}`, {
28
+ 'is-required': requiredFlag && required,
29
+ 'is-borderless': platform === 'h5' ? !borderedH5 : !borderedPc,
30
+ [`${item}--weui`]: platform === 'h5',
31
+ [`${item}--horizontal-left`]: layout === 'horizontal' && labelAlign === 'left',
32
+ [`${item}--horizontal-right`]: layout === 'horizontal' && labelAlign === 'right',
33
+ [`${item}--vertical-left`]: layout === 'vertical' && labelAlign === 'left',
34
+ [`${item}--vertical-right`]: layout === 'vertical' && labelAlign === 'right',
35
+ });
36
+ const labelCls = classNames(`${itemWrap}__label`, labelRoot, {
37
+ 'is-nowrap': !labelWrap,
38
+ });
39
+ const controlWrapCls = classNames(`${itemWrap}__control-wrap`, {
40
+ [`${itemWrap}__control-wrap--right`]: controlAlign === 'right',
41
+ });
42
+ // 输入部分
43
+ const Item = (_jsx("div", { className: `${itemWrap}__control`, "data-testid": testId, children: _jsx("div", { className: controlWrapCls, children: readOnly ? (_jsx("div", { className: `${item}__readonly`, children: readValue })) : (children) }) }));
44
+ // 标题部分,含必填、提示
45
+ const Label = labelVisible && (_jsx("div", { className: labelCls, style: labelStyle, children: _jsxs("label", { htmlFor: inputId, children: [_jsx("span", { className: `${itemWrap}__label-text ${labelRoot}-text`, title: label, children: label }), labelTips && (_jsx("span", { className: `${itemWrap}__label-explain`, children: _jsx(WdBubble, { style: { display: 'inline' }, bubbleChildren: _jsx(WdIcon, { name: "td:help-circle" }), bubbleContent: labelTips, promptTheme: "dark" }) }))] }) }));
46
+ // 下方空白替代(改为距左对齐)
47
+ // const LabelSpace = labelVisible && layout === 'horizontal' && (
48
+ // <div className={labelCls} style={labelStyle}></div>
49
+ // );
50
+ // 下方提示部分
51
+ const Help = extra && (_jsx("p", { className: `${item}__help`, children: _jsx("span", { className: `${item}__help-text ${root}__help`, children: extra }) }));
52
+ // 校验提示文字部分
53
+ const Message = validateErrorMsg && (_jsx("p", { className: `${item}__help`, children: _jsx("span", { className: `${classPrefix}-g-text-${validateState} ${root}__error`, children: validateErrorMsg }) }));
54
+ return (_jsxs("div", { className: cls, id: id, style: style, children: [_jsxs("div", { className: itemWrap, children: [Label, Item] }), Message, Help] }));
55
+ }
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useConfig } from '../../utils/config-context';
3
+ import classNames from '../../utils/classnames';
4
+ import { useSize } from '../../utils/hooks/useFormLegacy';
5
+ /**
6
+ * 输入类组件包裹,添加前后文字
7
+ */
8
+ export const WdInputGroup = (props) => {
9
+ const { before, after, block, children, classRoot = '' } = props;
10
+ const { classPrefix } = useConfig();
11
+ const size = useSize(props);
12
+ const root = `${classPrefix}-${classRoot}`;
13
+ const inputGroup = `${classPrefix}-form-input-group`;
14
+ const inputGroupCls = classNames(inputGroup, `size-height-${size}`, {
15
+ 'size-width-hundred': block,
16
+ });
17
+ const beforeCls = `${inputGroup}__addon ${inputGroup}__addon-left ${root}__text-before`;
18
+ const afterCls = `${inputGroup}__addon ${inputGroup}__addon-right ${root}__text-after`;
19
+ const contentCls = `${inputGroup}__content`;
20
+ if (before || after) {
21
+ return (_jsxs("div", { className: inputGroupCls, children: [before && _jsx("div", { className: beforeCls, children: before }), _jsx("div", { className: contentCls, children: children }), after && _jsx("div", { className: afterCls, children: after })] }));
22
+ }
23
+ return _jsx(_Fragment, { children: children });
24
+ };
@@ -0,0 +1,3 @@
1
+ import { WdInput } from './wd-input';
2
+ export { WdInput };
3
+ export default WdInput;