@cloudbase/weda-ui 3.6.5 → 3.7.2

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 (84) hide show
  1. package/dist/configs/components/form-location.d.ts +2 -2
  2. package/dist/configs/components/wd-card.d.ts +14 -14
  3. package/dist/configs/components/wd-card.js +38 -32
  4. package/dist/configs/components/wd-cascader.d.ts +276 -0
  5. package/dist/configs/components/wd-cascader.js +183 -0
  6. package/dist/configs/components/wd-code-editor.d.ts +245 -0
  7. package/dist/configs/components/wd-code-editor.js +92 -0
  8. package/dist/configs/components/wd-form-arr.d.ts +193 -0
  9. package/dist/configs/components/wd-form-arr.js +206 -0
  10. package/dist/configs/components/wd-form-obj.d.ts +181 -0
  11. package/dist/configs/components/wd-form-obj.js +107 -0
  12. package/dist/configs/components/wd-form.d.ts +2 -2
  13. package/dist/configs/components/wd-image.js +1 -1
  14. package/dist/configs/components/wd-table.d.ts +3 -3
  15. package/dist/configs/components/wd-upload-file.d.ts +1 -0
  16. package/dist/configs/components/wd-upload-file.js +4 -1
  17. package/dist/configs/components/wd-upload-image.d.ts +2 -0
  18. package/dist/configs/components/wd-upload-image.js +4 -1
  19. package/dist/configs/components/web-view.d.ts +20 -1
  20. package/dist/configs/components/web-view.js +22 -1
  21. package/dist/configs/index.d.ts +1604 -28
  22. package/dist/configs/index.js +8 -0
  23. package/dist/configs/type-utils/type-form.d.ts +22 -0
  24. package/dist/configs/type-utils/type-form.js +58 -1
  25. package/dist/configs/type-utils/x-runtime-default.d.ts +3 -0
  26. package/dist/configs/type-utils/x-runtime-default.js +3 -0
  27. package/dist/enum/index.d.ts +8 -0
  28. package/dist/enum/index.js +11 -0
  29. package/dist/style/index.scss +1 -1
  30. package/dist/web/components/container/index.js +49 -1
  31. package/dist/web/components/form/uploader/uploader.h5.js +3 -3
  32. package/dist/web/components/form/uploader/uploader.pc.js +3 -3
  33. package/dist/web/components/form-input-hooks/index.js +14 -7
  34. package/dist/web/components/form-location/index.d.ts +1 -1
  35. package/dist/web/components/index.d.ts +4 -0
  36. package/dist/web/components/index.js +6 -0
  37. package/dist/web/components/navigationBar/common.js +1 -1
  38. package/dist/web/components/wd-cascader/cascader.d.ts +6 -0
  39. package/dist/web/components/wd-cascader/cascader.h5.d.ts +2 -0
  40. package/dist/web/components/wd-cascader/cascader.h5.js +132 -0
  41. package/dist/web/components/wd-cascader/cascader.js +97 -0
  42. package/dist/web/components/wd-cascader/index.d.ts +4 -0
  43. package/dist/web/components/wd-cascader/index.js +3 -0
  44. package/dist/web/components/wd-cascader/interface.d.ts +26 -0
  45. package/dist/web/components/wd-cascader/interface.js +1 -0
  46. package/dist/web/components/wd-cascader/utils.d.ts +6 -0
  47. package/dist/web/components/wd-cascader/utils.js +63 -0
  48. package/dist/web/components/wd-code-editor/index.d.ts +3 -0
  49. package/dist/web/components/wd-code-editor/index.js +3 -0
  50. package/dist/web/components/wd-code-editor/lang/index.d.ts +17 -0
  51. package/dist/web/components/wd-code-editor/lang/index.js +21 -0
  52. package/dist/web/components/wd-code-editor/lang/mongodb/complete.d.ts +8 -0
  53. package/dist/web/components/wd-code-editor/lang/mongodb/complete.js +222 -0
  54. package/dist/web/components/wd-code-editor/lang/mongodb/index.d.ts +2 -0
  55. package/dist/web/components/wd-code-editor/lang/mongodb/index.js +60 -0
  56. package/dist/web/components/wd-code-editor/lang/mongodb/snippets.d.ts +6 -0
  57. package/dist/web/components/wd-code-editor/lang/mongodb/snippets.js +189 -0
  58. package/dist/web/components/wd-code-editor/theme.d.ts +4 -0
  59. package/dist/web/components/wd-code-editor/theme.js +5 -0
  60. package/dist/web/components/wd-code-editor/wd-code-editor.d.ts +9 -0
  61. package/dist/web/components/wd-code-editor/wd-code-editor.js +66 -0
  62. package/dist/web/components/wd-date/elements/Modal.h5.d.ts +2 -0
  63. package/dist/web/components/wd-date/elements/Modal.h5.js +4 -2
  64. package/dist/web/components/wd-form/form-utils.js +1 -1
  65. package/dist/web/components/wd-form/index.d.ts +4 -4
  66. package/dist/web/components/wd-form-arr/index.d.ts +4 -0
  67. package/dist/web/components/wd-form-arr/index.js +3 -0
  68. package/dist/web/components/wd-form-arr/wd-form-arr.d.ts +8 -0
  69. package/dist/web/components/wd-form-arr/wd-form-arr.js +6 -0
  70. package/dist/web/components/wd-form-item/wd-form-item.js +3 -3
  71. package/dist/web/components/wd-form-obj/base-form-obj.d.ts +13 -0
  72. package/dist/web/components/wd-form-obj/base-form-obj.js +351 -0
  73. package/dist/web/components/wd-form-obj/index.d.ts +4 -0
  74. package/dist/web/components/wd-form-obj/index.js +3 -0
  75. package/dist/web/components/wd-form-obj/wd-form-obj.d.ts +9 -0
  76. package/dist/web/components/wd-form-obj/wd-form-obj.js +7 -0
  77. package/dist/web/components/wd-tabs/tabs.d.ts +1 -1
  78. package/dist/web/components/wd-unified-link/index.js +2 -2
  79. package/dist/web/components/web-view/web-view.js +15 -4
  80. package/dist/web/utils/tool.d.ts +1 -0
  81. package/dist/web/utils/tool.js +4 -1
  82. package/dist/web/utils/widget-api/index.d.ts +20 -0
  83. package/dist/web/utils/widget-api/index.js +14 -0
  84. package/package.json +8 -1
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { BaseFormObj } from '../wd-form-obj/base-form-obj';
4
+ export const WdFormArr = forwardRef(function WdFormArr(props, ref) {
5
+ return _jsx(BaseFormObj, { objType: "arr", ...props, ref: ref });
6
+ });
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import classNames from '../../utils/classnames';
3
3
  import { useConfig } from '../../utils/config-context';
4
4
  import { WdIcon } from '../wd-icon';
@@ -11,7 +11,7 @@ import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default
11
11
  * 表单项包裹,包括标题、文本提示、校验
12
12
  */
13
13
  export function WdFormItem(props) {
14
- const { id, className, style, label, labelVisible = X_RUNTIME_DEFAULT.labelVisible, labelTips = X_RUNTIME_DEFAULT.labelTips, labelWidth: _labelWidth = X_RUNTIME_DEFAULT.labelWidth, labelWrap = X_RUNTIME_DEFAULT.labelWrap, extra = X_RUNTIME_DEFAULT.extra, required = X_RUNTIME_DEFAULT.required, readOnly, children, testId, requiredFlag = X_RUNTIME_DEFAULT.requiredFlag, validateState, validateErrorMsg, readValue, borderedH5 = X_RUNTIME_DEFAULT.borderedH5, borderedPc = X_RUNTIME_DEFAULT.borderedPc, classRoot, controlAlign, inputId, isWdFormDetail, before, after, readBeforeAfter = true, visible = true, } = props;
14
+ const { id, className, style, label, labelVisible = X_RUNTIME_DEFAULT.labelVisible, labelTips = X_RUNTIME_DEFAULT.labelTips, labelWidth: _labelWidth = X_RUNTIME_DEFAULT.labelWidth, labelWrap = X_RUNTIME_DEFAULT.labelWrap, extra = X_RUNTIME_DEFAULT.extra, required = X_RUNTIME_DEFAULT.required, readOnly, children, testId, requiredFlag = X_RUNTIME_DEFAULT.requiredFlag, validateState, validateErrorMsg, readValue, borderedH5 = X_RUNTIME_DEFAULT.borderedH5, borderedPc = X_RUNTIME_DEFAULT.borderedPc, classRoot, controlAlign, inputId, isWdFormDetail, before, after, readBeforeAfter = true, visible = true, LabelContainer = null, } = props;
15
15
  const { classPrefix } = useConfig();
16
16
  const platform = usePlatform();
17
17
  const labelAlign = useLabelAlign(props);
@@ -62,5 +62,5 @@ export function WdFormItem(props) {
62
62
  const Message = validateErrorMsg && (_jsx("p", { className: `${item}__help`, children: _jsx("span", { className: `${classPrefix}-g-text-${validateState} ${root}__error`, children: textToString(validateErrorMsg) }) }));
63
63
  if (!visible)
64
64
  return null;
65
- return (_jsxs("div", { className: cls, id: id, style: style, children: [_jsxs("div", { className: itemWrap, children: [Label, Item] }), Message, Help] }));
65
+ return (_jsxs("div", { className: cls, id: id, style: style, children: [_jsx("div", { className: itemWrap, children: LabelContainer ? (_jsx(LabelContainer, { Label: Label, Item: Item })) : (_jsxs(_Fragment, { children: [Label, Item] })) }), Message, Help] }));
66
66
  }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { CommonPropsType } from '../../types';
3
+ import type { DataType as ObjDataType } from '../../../configs/components/wd-form-obj';
4
+ import type { DataType as ArrDataType } from '../../../configs/components/wd-form-arr';
5
+ import '../style';
6
+ export declare const BaseFormObj: React.ForwardRefExoticComponent<BaseFormObjProps & React.RefAttributes<any>>;
7
+ type DataType = ObjDataType & ArrDataType;
8
+ export interface BaseFormObjProps extends CommonPropsType, DataType {
9
+ disabled: boolean;
10
+ readOnly: boolean;
11
+ objType: 'arr' | 'obj';
12
+ }
13
+ export {};
@@ -0,0 +1,351 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
3
+ import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
4
+ import { useConfig } from '../../utils/config-context';
5
+ import { WdFormItem } from '../wd-form-item';
6
+ import { usePlatform } from '../../utils/platform';
7
+ import classNames from '../../utils/classnames';
8
+ import { FormObjContext, FormObjWidgetContext, useFormObjWidget, } from '../../utils/widget-api';
9
+ import { noop } from '../../utils/constant';
10
+ import lodashSet from 'lodash.set';
11
+ import lodashGet from 'lodash.get';
12
+ import { useFormInputTrait, useParentForm } from '../form-input-hooks';
13
+ import { deepClone } from '../../utils/tool';
14
+ import isObjectEqual from '../../utils/isObjectEqual';
15
+ import { WdIcon } from '../wd-icon';
16
+ import { WdCard } from '../wd-card';
17
+ import '../style';
18
+ import useDebouncedCallback from '../../utils/hooks/use-debounced-callback';
19
+ import { useMap } from '@react-hookz/web';
20
+ import { isNil } from '../../utils/lodash';
21
+ const classRoot = 'form-obj';
22
+ /**
23
+ * 获取待操作的数据路径,嵌套表单中子组件的名称是按lodashSet形式拼接的,在更新嵌套表单值时,要去除掉当前嵌套表单的路径名称
24
+ * @param operateName 待操作的表单项名称
25
+ * @param currentName 当前表单项名称
26
+ * @returns
27
+ */
28
+ const getValueName = (operateName, currentName) => operateName.replace(new RegExp(`^${currentName}(\\.)?`), '');
29
+ const LabelContainer = (props) => {
30
+ const { Label, Item } = props || {};
31
+ const cardRef = React.createRef();
32
+ const [iconName, setIconName] = useState('chevronup');
33
+ const headerSlot = (_jsxs(_Fragment, { children: [_jsx(WdIcon, { name: iconName, events: {
34
+ tap: () => {
35
+ setIconName(iconName === 'chevrondown' ? 'chevronup' : 'chevrondown');
36
+ },
37
+ } }), Label] }));
38
+ return (_jsx(WdCard, { ref: cardRef, className: iconName === 'chevrondown' ? 'wd-card-content__hidden' : '', showContent: true, headerSlot: headerSlot, contentSlot: Item, events: { tap: () => { } } }));
39
+ };
40
+ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
41
+ const { classPrefix } = useConfig();
42
+ const platform = usePlatform();
43
+ const cls = classNames({
44
+ [`${classPrefix}-form-obj`]: true,
45
+ [`${classPrefix}-${platform}-form-obj`]: true,
46
+ [props.className]: true,
47
+ });
48
+ const formItemProps = {
49
+ ...props,
50
+ classRoot,
51
+ LabelContainer,
52
+ };
53
+ const initValue = { arr: [], obj: {} }[props.objType];
54
+ // 嵌套表单状态
55
+ const [status, updateStatus] = useState('edit');
56
+ const [innerHandle, setInnerHandle] = useState({});
57
+ const inputRef = useRef({});
58
+ // 嵌套表单的最终值
59
+ const [objValue, setObjValue] = useState(initValue);
60
+ // 父级普通表单对象
61
+ const parentForm = useParentForm(props.$widget);
62
+ // 父级嵌套表单对象
63
+ const parentFormObj = useFormObjWidget();
64
+ // 嵌套表单内的子组件实例对象集合,在form-input-hooks中会调用addFormItem添加关联上
65
+ const formsItemMap = useMap([]);
66
+ const { name, value, readOnly, disabled, visible,
67
+ // onChange: _onChange,
68
+ } = useFormInputTrait({
69
+ label: props.label,
70
+ value: props.value,
71
+ name: props.name,
72
+ inputRef,
73
+ readOnly: props.readOnly,
74
+ disabled: props.disabled,
75
+ status: props.status,
76
+ required: false,
77
+ requiredMsg: '',
78
+ $widget: props.$widget,
79
+ setInnerHandle,
80
+ onChange: noop,
81
+ $node: props.$node,
82
+ });
83
+ useEffect(() => {
84
+ setObjValue(value || {});
85
+ }, [value]);
86
+ useEffect(() => {
87
+ if (readOnly) {
88
+ updateStatus('readOnly');
89
+ }
90
+ else if (disabled) {
91
+ updateStatus('disabled');
92
+ }
93
+ else {
94
+ updateStatus('edit');
95
+ }
96
+ }, [disabled, readOnly]);
97
+ /**
98
+ * 对外触发嵌套表单的onDataChange事件
99
+ */
100
+ const triggerOnDataChange = useDebouncedCallback(useCallback((value) => {
101
+ var _a, _b;
102
+ (_b = (_a = props.events) === null || _a === void 0 ? void 0 : _a.onDataChange) === null || _b === void 0 ? void 0 : _b.call(_a, { data: value });
103
+ }, [props.events]), 500);
104
+ /**
105
+ * 不在表单容器中使用时,更新子组件值
106
+ */
107
+ const updateChildValue = useDebouncedCallback(useCallback((value) => {
108
+ formsItemMap.forEach((items, childName) => {
109
+ var _a;
110
+ const newValue = lodashGet(value, getValueName(childName, name));
111
+ if (!Array.isArray(items)) {
112
+ items = [items];
113
+ }
114
+ (_a = items === null || items === void 0 ? void 0 : items.forEach) === null || _a === void 0 ? void 0 : _a.call(items, (item) => {
115
+ if (item.setValue && !isObjectEqual(item.value, newValue)) {
116
+ item.setValue(newValue);
117
+ }
118
+ });
119
+ });
120
+ }, [formsItemMap, name]), 0);
121
+ const dealArrChange = (params, objValue) => {
122
+ let value;
123
+ // 顶层为数组类型
124
+ if (Array.isArray(objValue) && ['add', 'remove'].includes(params.type)) {
125
+ value = deepClone(objValue);
126
+ // 触发添加操作,则增加一个undefined值
127
+ if (params.type === 'add') {
128
+ value.push({});
129
+ }
130
+ // 触发删除操作,则删除对应索引的值
131
+ if (params.type === 'remove') {
132
+ value = [
133
+ ...value.slice(0, params.value),
134
+ ...value.slice(params.value + 1),
135
+ ];
136
+ }
137
+ }
138
+ return value;
139
+ };
140
+ const dealObjChange = (params, objValue) => {
141
+ var _a;
142
+ let value;
143
+ if ((_a = Object.keys(objValue || {})) === null || _a === void 0 ? void 0 : _a.length) {
144
+ value = deepClone({ ...objValue, ...params.value });
145
+ }
146
+ return value;
147
+ };
148
+ /**
149
+ * 更新值
150
+ * @param params
151
+ * @param param1.isUpdateParentForm 是否更新父级表单,因子组件值变化调用change时不去触发父表单的更新,因为子组件自己会触发;因为外部设置了值,则触发父表单更新
152
+ * @param param1.isUpdateChildValue 是否更新子组件值, 因子组件值变化调用change时不去触发updateChildValueWithoutForm;因为外部设置了值,则触发updateChildValueWithoutForm去更新子组件值
153
+ * @returns
154
+ */
155
+ const change = useCallback((params, { isUpdateParentForm = false, isUpdateChildValue = true } = {}) => {
156
+ var _a, _b, _c;
157
+ let value = deepClone(params.value);
158
+ if (props.objType === 'arr') {
159
+ value = dealArrChange(params, objValue) || value;
160
+ }
161
+ // 如果有更新标识,则按标识路径更新值
162
+ if (params.name) {
163
+ value = deepClone(objValue);
164
+ lodashSet(value, getValueName(params.name, name), params.value);
165
+ }
166
+ else if (props.objType === 'obj') {
167
+ value = dealObjChange(params, objValue) || value;
168
+ }
169
+ if (isObjectEqual(value, objValue)) {
170
+ return;
171
+ }
172
+ setObjValue(value || initValue);
173
+ if (isUpdateChildValue) {
174
+ // 外部设置数据,同时去更新子组件的值
175
+ updateChildValue(value);
176
+ }
177
+ if (isUpdateParentForm) {
178
+ // 触发父级普通表单值更新
179
+ (_a = parentForm === null || parentForm === void 0 ? void 0 : parentForm.__setValueImmediate__) === null || _a === void 0 ? void 0 : _a.call(parentForm, { [name]: value }, false, true);
180
+ }
181
+ if (params.name) {
182
+ // 触发父级嵌套表单值更新
183
+ (_b = parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.__setValueImmediate__) === null || _b === void 0 ? void 0 : _b.call(parentFormObj, {
184
+ name: params.name,
185
+ value: params.value,
186
+ });
187
+ }
188
+ else if (parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.formObjName) {
189
+ // 外部直接调用formObj.setValue的情况下,触发父级嵌套表单值更新
190
+ (_c = parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.__setValueImmediate__) === null || _c === void 0 ? void 0 : _c.call(parentFormObj, { name, value });
191
+ }
192
+ triggerOnDataChange(value);
193
+ },
194
+ // eslint-disable-next-line react-hooks/exhaustive-deps
195
+ [
196
+ objValue,
197
+ updateChildValue,
198
+ name,
199
+ parentFormObj,
200
+ triggerOnDataChange,
201
+ parentForm,
202
+ props.objType,
203
+ ]);
204
+ /**
205
+ * 子组件默认值变更,触发嵌套表单值更新
206
+ */
207
+ const changeByChildFormObj = useCallback((params) => {
208
+ var _a, _b;
209
+ const value = deepClone(objValue);
210
+ lodashSet(value, getValueName(params.name, name), params.value);
211
+ if (isObjectEqual(value, objValue)) {
212
+ return;
213
+ }
214
+ if (params.name) {
215
+ // 将值同步给父级嵌套表单
216
+ (_a = parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.__setValueImmediate__) === null || _a === void 0 ? void 0 : _a.call(parentFormObj, {
217
+ name: params.name,
218
+ value: params.value,
219
+ });
220
+ }
221
+ else if (parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.formObjName) {
222
+ // 外部直接调用formObj.setValue的情况下,触发父级嵌套表单值更新
223
+ (_b = parentFormObj === null || parentFormObj === void 0 ? void 0 : parentFormObj.__setValueImmediate__) === null || _b === void 0 ? void 0 : _b.call(parentFormObj, { name, value });
224
+ }
225
+ setObjValue(value || initValue);
226
+ },
227
+ // eslint-disable-next-line react-hooks/exhaustive-deps
228
+ [objValue, name, parentFormObj]);
229
+ useLayoutEffect(() => {
230
+ if (!ref)
231
+ return;
232
+ ref.current = {
233
+ ...innerHandle,
234
+ /**
235
+ * 外部直接set嵌入表单的值
236
+ * @param value
237
+ */
238
+ setValue: (value) => {
239
+ change({ name: '', value }, { isUpdateParentForm: true });
240
+ },
241
+ getValue() {
242
+ return objValue;
243
+ },
244
+ getConfig() {
245
+ return {
246
+ componentType: 'formObj',
247
+ };
248
+ },
249
+ methods: {
250
+ ...(props.objType === 'arr'
251
+ ? {
252
+ add: () => {
253
+ change({ type: 'add' }, { isUpdateParentForm: false });
254
+ },
255
+ remove: ({ index = -1 } = {}) => {
256
+ change({ type: 'remove', value: index }, { isUpdateParentForm: false });
257
+ },
258
+ }
259
+ : {}),
260
+ change: (params) => {
261
+ change(params, { isUpdateParentForm: true });
262
+ },
263
+ },
264
+ label: props.label,
265
+ name: name,
266
+ value: objValue,
267
+ visible,
268
+ disabled,
269
+ readOnly,
270
+ };
271
+ // eslint-disable-next-line react-hooks/exhaustive-deps
272
+ }, [
273
+ innerHandle,
274
+ props.label,
275
+ name,
276
+ objValue,
277
+ visible,
278
+ disabled,
279
+ readOnly,
280
+ change,
281
+ props.objType,
282
+ ]);
283
+ const formObjWidgetContextProvider = useMemo(() => {
284
+ return {
285
+ formObjName: name,
286
+ /**
287
+ * 用于同步子组件的默认值
288
+ * @param params
289
+ */
290
+ __setValueImmediate__(params) {
291
+ changeByChildFormObj(params);
292
+ },
293
+ };
294
+ }, [changeByChildFormObj, name]);
295
+ const formObjContextProvider = useMemo(() => {
296
+ return {
297
+ formObjName: name,
298
+ status,
299
+ /**
300
+ * 嵌套表单内部子组件值改变时,触发嵌套表单组件的值更新
301
+ * @param params.name 子组件名称
302
+ * @param params.value 子组件值
303
+ */
304
+ valueChangeFromChild: (params = {}) => {
305
+ if (!params.name)
306
+ return;
307
+ // 由于是子组件值变更触发,所以嵌套表单值更新后不再次触发子组件值变更
308
+ change(params, { isUpdateChildValue: false });
309
+ },
310
+ /**
311
+ * 收集嵌套表单内的子组件实例,以便嵌套表单值变化时,主动触发子组件值更新
312
+ * @param childName 子组件名称
313
+ * @param formItem 子组件$widget
314
+ * @returns
315
+ */
316
+ addFormItem(childName, formItem) {
317
+ if (isNil(childName) ||
318
+ !formItem ||
319
+ (typeof childName === 'string' && childName.length === 0)) {
320
+ // childName 没设置或为空串的时候不受表单容器控制
321
+ console.warn(`组件 #${formItem === null || formItem === void 0 ? void 0 : formItem.id} 表单key(表单输入类组件 childName 属性)没设置或为空串的时候不受表单容器控制`);
322
+ return noop;
323
+ }
324
+ if (formsItemMap.has(childName)) {
325
+ formsItemMap.get(childName).push(formItem);
326
+ }
327
+ else {
328
+ formsItemMap.set(childName, [formItem]);
329
+ }
330
+ return () => {
331
+ const items = formsItemMap.get(childName);
332
+ const removedArr = items.filter((item) => item !== formItem);
333
+ if (removedArr.length <= 0) {
334
+ formsItemMap.delete(childName);
335
+ }
336
+ else {
337
+ formsItemMap.set(childName, removedArr);
338
+ }
339
+ };
340
+ },
341
+ };
342
+ }, [change, formsItemMap, name, status]);
343
+ useEffect(() => {
344
+ // 如果是最顶层的嵌套表单,则去更新子组件的值,否则自己的值更新不去触发子组件值更新,因为父级普通表单会去更新
345
+ if (!parentFormObj) {
346
+ updateChildValue(objValue);
347
+ }
348
+ // eslint-disable-next-line react-hooks/exhaustive-deps
349
+ }, [objValue, parentFormObj]);
350
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsx(FormObjWidgetContext.Provider, { value: formObjWidgetContextProvider, children: _jsx(FormObjContext.Provider, { value: formObjContextProvider, children: _jsx("fieldset", { className: cls, id: props.id, style: props.style, role: "container", "data-testid": "formObj", children: props.children }) }) }) }));
351
+ });
@@ -0,0 +1,4 @@
1
+ import { WdFormObj } from './wd-form-obj';
2
+ export { WdFormObj } from './wd-form-obj';
3
+ export type { WdFormObjProps } from './wd-form-obj';
4
+ export default WdFormObj;
@@ -0,0 +1,3 @@
1
+ import { WdFormObj } from './wd-form-obj';
2
+ export { WdFormObj } from './wd-form-obj';
3
+ export default WdFormObj;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { CommonPropsType } from '../../types';
3
+ import type { DataType } from '../../../configs/components/wd-form-arr';
4
+ import '../style';
5
+ export declare const WdFormObj: React.ForwardRefExoticComponent<WdFormObjProps & React.RefAttributes<any>>;
6
+ export interface WdFormObjProps extends CommonPropsType, DataType {
7
+ disabled: boolean;
8
+ readOnly: boolean;
9
+ }
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import '../style';
4
+ import { BaseFormObj } from './base-form-obj';
5
+ export const WdFormObj = forwardRef(function WdFormObj(props, ref) {
6
+ return _jsx(BaseFormObj, { objType: "obj", ...props, ref: ref });
7
+ });
@@ -9,5 +9,5 @@ export interface WdTabsProps extends CommonPropsType {
9
9
  selected?: boolean;
10
10
  }[];
11
11
  direction: string;
12
- getIndex: (val: number) => void;
12
+ getIndex?: (val: number) => void;
13
13
  }
@@ -63,7 +63,7 @@ export const WdUnifiedLink = forwardRef(function WdUnifiedLink(props, ref) {
63
63
  (_c = window === null || window === void 0 ? void 0 : window.app) === null || _c === void 0 ? void 0 : _c.navigateTo({
64
64
  pageId,
65
65
  packageName: packageName === 'main' ? '' : packageName,
66
- mode: options.target === '_blank' ? 'web' : 'weDa',
66
+ mode: (options === null || options === void 0 ? void 0 : options.target) === '_blank' ? 'web' : 'weDa',
67
67
  params,
68
68
  });
69
69
  break;
@@ -86,6 +86,6 @@ export const WdUnifiedLink = forwardRef(function WdUnifiedLink(props, ref) {
86
86
  }
87
87
  }
88
88
  };
89
- return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("a", { href: /https?:\/\//.test(url) ? url : 'javascript:void(0);', rel: "noopener noreferrer", className: classNames(classes, className), id: id, style: style, onClick: onClick, ...options, children: children }) }));
89
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: _jsx("a", { href: /https?:\/\//.test(url) ? url : 'javascript:void(0);', rel: "noopener noreferrer", className: classNames(classes, className), id: id, style: style, onClick: onClick, "data-testid": "wd-unified-link", ...options, children: children }) }));
90
90
  });
91
91
  export default WdUnifiedLink;
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { forwardRef, useImperativeHandle, useRef, useEffect, } from 'react';
2
+ import { forwardRef, useRef, useEffect } from 'react';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { useConfig } from '../../utils/config-context';
5
5
  import { isInIde, usePlatform } from '../../utils/platform';
6
+ import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
6
7
  import { Bubble } from 'tea-component';
7
8
  import EmptyContent from '../statusContent';
8
9
  import './style';
@@ -46,9 +47,19 @@ export const WebView = forwardRef(function WebView({ link = '', events, classNam
46
47
  (events === null || events === void 0 ? void 0 : events.load) && (events === null || events === void 0 ? void 0 : events.load({ src: link }));
47
48
  }
48
49
  // Widget API,挂载组件只读属性和组件方法
49
- useImperativeHandle(ref, () => {
50
- return { link };
51
- }, [link]);
50
+ useSetWidgetApi(() => {
51
+ return {
52
+ link,
53
+ postMessage: (params) => {
54
+ if (params === null || params === void 0 ? void 0 : params.transfer) {
55
+ window === null || window === void 0 ? void 0 : window.postMessage(params === null || params === void 0 ? void 0 : params.message, params === null || params === void 0 ? void 0 : params.targetOrigin, params === null || params === void 0 ? void 0 : params.transfer);
56
+ }
57
+ else {
58
+ window === null || window === void 0 ? void 0 : window.postMessage(params === null || params === void 0 ? void 0 : params.message, params === null || params === void 0 ? void 0 : params.targetOrigin);
59
+ }
60
+ },
61
+ };
62
+ }, [link], ref);
52
63
  useEffect(() => {
53
64
  // 监听message事件
54
65
  window.addEventListener('message', (e) => {
@@ -47,3 +47,4 @@ export declare const safeObj: (v: any) => any;
47
47
  export declare const setRefProp: (ref: any, name: any, value: any) => void;
48
48
  export declare const convertSingleValue: (value: any, single: any) => any;
49
49
  export declare function getUrlPath(p: any, f: any): string;
50
+ export declare function isIOS(): boolean;
@@ -222,7 +222,7 @@ export const setRefProp = (ref, name, value) => {
222
222
  ref.current[name] = value;
223
223
  }
224
224
  };
225
- // 兼容单选多选值类型,上传图片/上传文件
225
+ // 兼容单选多选值类型,上传图片/上传文件/级联选择
226
226
  export const convertSingleValue = (value, single) => {
227
227
  let v = value;
228
228
  if (value !== null) {
@@ -241,3 +241,6 @@ export function getUrlPath(p, f) {
241
241
  const file = f.startsWith('/') ? f.slice(1) : f;
242
242
  return `${path}${file}`;
243
243
  }
244
+ export function isIOS() {
245
+ return /phone|pad|pod|iPhone|iPod|ios|iPad/.test(navigator.userAgent);
246
+ }
@@ -6,3 +6,23 @@ export declare function useWedaAppContext(): {
6
6
  };
7
7
  export declare const FormDetailStatusContext: import("react").Context<string>;
8
8
  export declare const useFormDetailContext: () => string;
9
+ export declare const FormObjContext: import("react").Context<{
10
+ formObjName: string;
11
+ status: 'edit' | 'disabled' | 'readOnly';
12
+ valueChangeFromChild: (params: {
13
+ name: string;
14
+ value: any;
15
+ }) => void;
16
+ addFormItem: (name: string, $widget: IWidget) => () => void;
17
+ }>;
18
+ export declare const useFormObjContext: () => {
19
+ formObjName: string;
20
+ status: 'edit' | 'disabled' | 'readOnly';
21
+ valueChangeFromChild: (params: {
22
+ name: string;
23
+ value: any;
24
+ }) => void;
25
+ addFormItem: (name: string, $widget: IWidget) => () => void;
26
+ };
27
+ export declare const FormObjWidgetContext: import("react").Context<IWidget>;
28
+ export declare const useFormObjWidget: () => IWidget;
@@ -55,3 +55,17 @@ export const useFormDetailContext = () => {
55
55
  const status = useContext(FormDetailStatusContext);
56
56
  return status;
57
57
  };
58
+ // 共享嵌套表单状态
59
+ export const FormObjContext = createContext({
60
+ formObjName: '',
61
+ status: 'edit',
62
+ valueChangeFromChild: () => { },
63
+ addFormItem: () => () => { },
64
+ }, 'FormObj');
65
+ export const useFormObjContext = () => {
66
+ return useContext(FormObjContext);
67
+ };
68
+ export const FormObjWidgetContext = createContext(null, 'FormObjWidget');
69
+ export const useFormObjWidget = () => {
70
+ return useContext(FormObjWidgetContext);
71
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.6.5",
3
+ "version": "3.7.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",
@@ -81,20 +81,27 @@
81
81
  "description": "腾讯云微搭低代码组件库模板",
82
82
  "dependencies": {
83
83
  "@antv/g6": "^4.8.5",
84
+ "@codemirror/autocomplete": "^6.16.0",
85
+ "@codemirror/lang-javascript": "^6.2.2",
86
+ "@codemirror/lang-sql": "^6.6.4",
84
87
  "@loadable/component": "^5.15.3",
85
88
  "@react-hookz/web": "^23.0.0",
86
89
  "@sinclair/typebox": "^0.29.6",
87
90
  "@storybook/addons": "^6.5.16",
88
91
  "@tcwd/style-wedatheme": "^1.0.4",
92
+ "@uiw/codemirror-theme-github": "^4.22.0",
93
+ "@uiw/react-codemirror": "^4.22.0",
89
94
  "@use-gesture/react": "^10.2.27",
90
95
  "await-to-js": "3.0.0",
91
96
  "bootstrap": "^5.2.3",
97
+ "codemirror": "^6.0.1",
92
98
  "compressorjs": "^1.2.1",
93
99
  "dayjs": "^1.10.7",
94
100
  "destr": "^2.0.1",
95
101
  "echarts": "^5.3.0",
96
102
  "echarts-for-react": "^3.0.2",
97
103
  "eslint-plugin-compat": "^4.1.4",
104
+ "js-beautify": "^1.15.1",
98
105
  "jsonexport": "3.2.0",
99
106
  "lodash.get": "^4.4.2",
100
107
  "lodash.isequal": "^4.5.0",