@cloudbase/weda-ui 3.15.6 → 3.15.7
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
-
import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState
|
|
3
|
+
import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { useConfig } from '../../utils/config-context';
|
|
5
5
|
import { WdFormItem } from '../wd-form-item';
|
|
6
6
|
import { usePlatform } from '../../utils/platform';
|
|
7
7
|
import classNames from '../../utils/classnames';
|
|
8
|
-
import { FormObjContext, FormObjWidgetContext, useFormObjWidget
|
|
8
|
+
import { FormObjContext, FormObjWidgetContext, useFormObjWidget } from '../../utils/widget-api';
|
|
9
9
|
import { noop } from '../../utils/constant';
|
|
10
10
|
import lodashSet from 'lodash.set';
|
|
11
11
|
import lodashGet from 'lodash.get';
|
|
@@ -132,10 +132,7 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
132
132
|
}
|
|
133
133
|
// 触发删除操作,则删除对应索引的值
|
|
134
134
|
if (params.type === 'remove') {
|
|
135
|
-
value = [
|
|
136
|
-
...value.slice(0, params.value),
|
|
137
|
-
...value.slice(params.value + 1),
|
|
138
|
-
];
|
|
135
|
+
value = [...value.slice(0, params.value), ...value.slice(params.value + 1)];
|
|
139
136
|
}
|
|
140
137
|
}
|
|
141
138
|
return value;
|
|
@@ -161,6 +158,9 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
161
158
|
*/
|
|
162
159
|
const change = useCallback((params, { isUpdateParentForm = false, isUpdateChildValue = true } = {}) => {
|
|
163
160
|
var _a, _b, _c;
|
|
161
|
+
if (disabled || readOnly) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
164
|
let value = deepClone(params.value);
|
|
165
165
|
if (props.objType === 'arr') {
|
|
166
166
|
value = dealArrChange(params, objValue) || value;
|
|
@@ -173,8 +173,7 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
173
173
|
else if (props.objType === 'obj') {
|
|
174
174
|
value = dealObjChange(params, objValue) || value;
|
|
175
175
|
}
|
|
176
|
-
if (isObjectEqual(value, objValue) ||
|
|
177
|
-
(value === null && isObjectEqual(initValue, objValue))) {
|
|
176
|
+
if (isObjectEqual(value, objValue) || (value === null && isObjectEqual(initValue, objValue))) {
|
|
178
177
|
return;
|
|
179
178
|
}
|
|
180
179
|
setObjValue(value || initValue);
|
|
@@ -200,15 +199,7 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
200
199
|
triggerOnDataChange(value);
|
|
201
200
|
},
|
|
202
201
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
203
|
-
[
|
|
204
|
-
objValue,
|
|
205
|
-
updateChildValue,
|
|
206
|
-
name,
|
|
207
|
-
parentFormObj,
|
|
208
|
-
triggerOnDataChange,
|
|
209
|
-
parentForm,
|
|
210
|
-
props.objType,
|
|
211
|
-
]);
|
|
202
|
+
[objValue, updateChildValue, name, parentFormObj, triggerOnDataChange, parentForm, props.objType]);
|
|
212
203
|
const changeDebounce = useDebouncedCallback(useCallback((value, option) => {
|
|
213
204
|
change(value, option);
|
|
214
205
|
}, [change]), 300);
|
|
@@ -281,17 +272,7 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
281
272
|
readOnly,
|
|
282
273
|
};
|
|
283
274
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
284
|
-
}, [
|
|
285
|
-
innerHandle,
|
|
286
|
-
props.label,
|
|
287
|
-
name,
|
|
288
|
-
objValue,
|
|
289
|
-
visible,
|
|
290
|
-
disabled,
|
|
291
|
-
readOnly,
|
|
292
|
-
change,
|
|
293
|
-
props.objType,
|
|
294
|
-
]);
|
|
275
|
+
}, [innerHandle, props.label, name, objValue, visible, disabled, readOnly, change, props.objType]);
|
|
295
276
|
const formObjWidgetContextProvider = useMemo(() => {
|
|
296
277
|
return {
|
|
297
278
|
formObjName: name,
|
|
@@ -326,9 +307,7 @@ export const BaseFormObj = forwardRef(function BaseFormObj(props, ref) {
|
|
|
326
307
|
* @returns
|
|
327
308
|
*/
|
|
328
309
|
addFormItem(childName, formItem) {
|
|
329
|
-
if (isNil(childName) ||
|
|
330
|
-
!formItem ||
|
|
331
|
-
(typeof childName === 'string' && childName.length === 0)) {
|
|
310
|
+
if (isNil(childName) || !formItem || (typeof childName === 'string' && childName.length === 0)) {
|
|
332
311
|
// childName 没设置或为空串的时候不受表单容器控制
|
|
333
312
|
console.warn(`组件 #${formItem === null || formItem === void 0 ? void 0 : formItem.id} 表单key(表单输入类组件 childName 属性)没设置或为空串的时候不受表单容器控制`);
|
|
334
313
|
return noop;
|