@cloudbase/weda-ui 3.18.8 → 3.20.0

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 (57) hide show
  1. package/dist/configs/components/lottery.d.ts +2 -0
  2. package/dist/configs/components/lottery.js +6 -1
  3. package/dist/configs/components/wd-checkbox.js +4 -0
  4. package/dist/configs/components/wd-form.d.ts +2 -2
  5. package/dist/configs/components/wd-form.js +2 -3
  6. package/dist/configs/components/wd-image.js +1 -0
  7. package/dist/configs/components/wd-radio.js +4 -0
  8. package/dist/configs/components/wd-table.d.ts +19 -3
  9. package/dist/configs/components/wd-table.js +16 -0
  10. package/dist/configs/components/wd-tree.d.ts +33 -0
  11. package/dist/configs/components/wd-tree.js +58 -0
  12. package/dist/configs/index.d.ts +66 -6
  13. package/dist/configs/type-utils/type-form.d.ts +2 -2
  14. package/dist/configs/type-utils/type-form.js +4 -0
  15. package/dist/style/index.css +2 -1
  16. package/dist/style/index.scss +1 -1
  17. package/dist/style/weda-ui.min.css +2 -2
  18. package/dist/web/components/customer-service/customer-service.js +4 -3
  19. package/dist/web/components/form-input-hooks/index.d.ts +3 -1
  20. package/dist/web/components/form-input-hooks/index.js +93 -54
  21. package/dist/web/components/form-rich-text/index.d.ts +1 -1
  22. package/dist/web/components/form-rich-text/index.js +6 -2
  23. package/dist/web/components/formdetail/index.d.ts +1 -1
  24. package/dist/web/components/formdetail/index.js +28 -42
  25. package/dist/web/components/lottery/index.d.ts +1 -0
  26. package/dist/web/components/lottery/index.js +19 -47
  27. package/dist/web/components/lottery/lotteryUtil.d.ts +1 -1
  28. package/dist/web/components/lottery/lotteryUtil.js +4 -5
  29. package/dist/web/components/richText/index.js +9 -3
  30. package/dist/web/components/wd-form/contexts/form-field-arr-context.d.ts +21 -0
  31. package/dist/web/components/wd-form/contexts/form-field-arr-context.js +10 -0
  32. package/dist/web/components/wd-form/contexts/form-field-context.d.ts +19 -0
  33. package/dist/web/components/wd-form/contexts/form-field-context.js +10 -0
  34. package/dist/web/components/wd-form/contexts/form-field-obj-context.d.ts +13 -0
  35. package/dist/web/components/wd-form/contexts/form-field-obj-context.js +10 -0
  36. package/dist/web/components/wd-form/form-utils.d.ts +1 -0
  37. package/dist/web/components/wd-form/form-utils.js +32 -0
  38. package/dist/web/components/wd-form/index.d.ts +4 -4
  39. package/dist/web/components/wd-form/index.js +137 -191
  40. package/dist/web/components/wd-form-item/wd-form-item.d.ts +2 -2
  41. package/dist/web/components/wd-form-item/wd-form-item.js +96 -14
  42. package/dist/web/components/wd-form-obj/base-form-obj.js +57 -197
  43. package/dist/web/components/wd-input/wd-input.js +1 -1
  44. package/dist/web/components/wd-input-number/wd-input-number.js +40 -2
  45. package/dist/web/components/wd-rich-text/wd-rich-text.d.ts +1 -1
  46. package/dist/web/components/wd-rich-text/wd-rich-text.js +7 -3
  47. package/dist/web/components/wd-table/components/Table/index.js +14 -9
  48. package/dist/web/components/wd-table/utils/index.d.ts +0 -1
  49. package/dist/web/components/wd-table/utils/index.js +1 -1
  50. package/dist/web/components/wd-table/wd-table.js +4 -0
  51. package/dist/web/components/wd-tree/utils.d.ts +29 -3
  52. package/dist/web/components/wd-tree/utils.js +26 -12
  53. package/dist/web/components/wd-tree/wd-tree.d.ts +1 -0
  54. package/dist/web/components/wd-tree/wd-tree.js +65 -40
  55. package/dist/web/utils/widget-api/index.d.ts +0 -14
  56. package/dist/web/utils/widget-api/index.js +0 -7
  57. package/package.json +5 -5
@@ -1,9 +1,9 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, forwardRef, useImperativeHandle, useState, useCallback, useRef, } from 'react';
3
- import { useResizeObserver, useDebouncedEffect } from '@react-hookz/web';
2
+ import { useEffect, forwardRef, useImperativeHandle, useState, useCallback, useRef } from 'react';
3
+ import { useResizeObserver } from '@react-hookz/web';
4
4
  import { WdFormItem } from '../wd-form-item';
5
5
  import classNames from '../../utils/classnames';
6
- import { usePlatform, randomStr, isInIde } from '../../utils/platform';
6
+ import { usePlatform, randomStr } from '../../utils/platform';
7
7
  import isObjectEqual from '../../utils/isObjectEqual';
8
8
  import { useFormInputTrait, useParentForm } from '../form-input-hooks';
9
9
  import { FormDetailStatusContext } from '../../utils/widget-api';
@@ -45,9 +45,7 @@ export const reorderContext = (data, name, isPureArray) => data.map((i, index) =
45
45
  Object.keys(i).forEach((j) => {
46
46
  var _a;
47
47
  if ((_a = item[j]) === null || _a === void 0 ? void 0 : _a.name) {
48
- item[j].name = isPureArray
49
- ? `${name}[${index}]`
50
- : `${name}[${index}].${j}`;
48
+ item[j].name = isPureArray ? `${name}[${index}]` : `${name}[${index}].${j}`;
51
49
  }
52
50
  });
53
51
  item.index = index;
@@ -65,7 +63,7 @@ export const newContextItem = (childFormItem, name, isPureArray, parent) => {
65
63
  });
66
64
  return mock;
67
65
  };
68
- export const changeHandle = ({ type, name, data, childFormItem, isPureArray, params, parent, }) => {
66
+ export const changeHandle = ({ type, name, data, childFormItem, isPureArray, params, parent }) => {
69
67
  switch (type) {
70
68
  case 'add': {
71
69
  const mock = newContextItem(childFormItem, name, isPureArray, parent);
@@ -118,9 +116,8 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
118
116
  });
119
117
  const tableRef = useRef(null);
120
118
  const [isTableView, setIsTableView] = useState(false);
121
- const [detailValue, setDetailValue] = useState([]);
119
+ const [detailValue, setDetailValue] = useState(props.value || []);
122
120
  const [contextData, setContextData] = useState([]);
123
- const [isInit, setIsInit] = useState(false);
124
121
  const [childFormItem, setChildFormItem] = useState([]);
125
122
  const [hasScroll, setHasScroll] = useState(false);
126
123
  const platform = usePlatform();
@@ -163,6 +160,9 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
163
160
  }
164
161
  const mock = newContextItem(childFormItem, name, isPureArray, parent);
165
162
  let data = (initialValues === null || initialValues === void 0 ? void 0 : initialValues.length) ? initialValues : [mock];
163
+ if (!(childFormItem === null || childFormItem === void 0 ? void 0 : childFormItem.length)) {
164
+ data = [];
165
+ }
166
166
  // 新的明细组件,开放初始值,根据初始值设置上下文
167
167
  if (isWdFormDetail) {
168
168
  data = initialValues;
@@ -194,30 +194,29 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
194
194
  setChildFormItem(childFormItem);
195
195
  }
196
196
  }, [initDetailValue, isPureArray, name, (_a = parent === null || parent === void 0 ? void 0 : parent.dataSourceProfile) === null || _a === void 0 ? void 0 : _a.name]);
197
- const setFormDetailValue = useCallback((value) => {
198
- if (!isObjectEqual(value, detailValue) && childFormItem.length > 0) {
197
+ const setFormDetailValue = useCallback((value, _childFormItem = childFormItem) => {
198
+ if (!isObjectEqual(value, detailValue) && _childFormItem.length > 0) {
199
199
  setDetailValue(value || []);
200
200
  init(value || [], isWdFormDetail);
201
- setIsInit(true);
201
+ // setIsInit(true);
202
202
  }
203
203
  }, [childFormItem, detailValue, init, isWdFormDetail]);
204
204
  // 初始化context的值
205
205
  useEffect(() => {
206
206
  logger.debug('initDetailValue', initDetailValue);
207
- setFormDetailValue(initDetailValue);
207
+ let _childFormItem = childFormItem;
208
+ if ((_childFormItem === null || _childFormItem === void 0 ? void 0 : _childFormItem.length) === 0) {
209
+ _childFormItem = getChildFormItem({
210
+ isPureArray,
211
+ name,
212
+ parent,
213
+ defaultValue: initDetailValue,
214
+ });
215
+ }
216
+ setFormDetailValue(initDetailValue, _childFormItem);
208
217
  // 只有initDetailValue的值改变的时候才执行
209
218
  // eslint-disable-next-line react-hooks/exhaustive-deps
210
219
  }, [initDetailValue]);
211
- useDebouncedEffect(() => {
212
- var _a;
213
- // 子表单默认值变化时,若form值不同步,则主动同步(默认值为变量的情况)
214
- if (isInit &&
215
- detailValue &&
216
- !isObjectEqual((_a = parent === null || parent === void 0 ? void 0 : parent.value) === null || _a === void 0 ? void 0 : _a[name], detailValue)) {
217
- parent.__setValueImmediate__({ [name]: detailValue }, false);
218
- setIsInit(false);
219
- }
220
- }, [detailValue, isInit, name], 15);
221
220
  useEffect(() => {
222
221
  var _a;
223
222
  const childFormItem = getChildFormItem({
@@ -228,11 +227,12 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
228
227
  });
229
228
  setChildFormItem(childFormItem);
230
229
  // 只有在编辑器里,或存在初始值的时候,或新明细组件(wdFormDetail),才初始化明细单项
231
- if (isInIde() || hasInitValue || isWdFormDetail) {
230
+ if (hasInitValue || isWdFormDetail) {
232
231
  setDetailValue(initDetailValue || []);
233
232
  init(initDetailValue, isWdFormDetail);
234
233
  }
235
234
  else {
235
+ setDetailValue([]);
236
236
  (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data: [] });
237
237
  }
238
238
  // 组件卸载时触发
@@ -261,10 +261,7 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
261
261
  }, [_onChange, childFormItem, isPureArray]);
262
262
  const onChange = useCallback((type, params) => {
263
263
  var _a;
264
- if (disabled ||
265
- readOnly ||
266
- !(fieldAuth === null || fieldAuth === void 0 ? void 0 : fieldAuth.includes('w')) ||
267
- (parent === null || parent === void 0 ? void 0 : parent.formType) === 'read') {
264
+ if (disabled || readOnly || !(fieldAuth === null || fieldAuth === void 0 ? void 0 : fieldAuth.includes('w')) || (parent === null || parent === void 0 ? void 0 : parent.formType) === 'read') {
268
265
  return;
269
266
  }
270
267
  let data;
@@ -291,9 +288,9 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
291
288
  parent,
292
289
  });
293
290
  if (!isObjectEqual(data, contextData)) {
294
- updateFormDetailValue(data);
295
291
  setContextData(data);
296
292
  (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data });
293
+ updateFormDetailValue(data);
297
294
  }
298
295
  }, [
299
296
  disabled,
@@ -353,18 +350,7 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
353
350
  disabled,
354
351
  readOnly,
355
352
  };
356
- }, [
357
- innerHandle,
358
- onChange,
359
- isTableView,
360
- name,
361
- detailValue,
362
- label,
363
- visible,
364
- disabled,
365
- readOnly,
366
- setFormDetailValue,
367
- ]);
353
+ }, [innerHandle, onChange, isTableView, name, detailValue, label, visible, disabled, readOnly, setFormDetailValue]);
368
354
  // useEffect(() => {
369
355
  // const initArr = lodashGet(parent, 'initialValues.name', null);
370
356
  // logger.debug('initialValue', initArr, name);
@@ -413,6 +399,6 @@ const FormDetailCom = forwardRef(function FormDetail(props, ref) {
413
399
  const layout = platform === 'h5' ? 'vertical' : _currentLayout;
414
400
  const formItemProps = { ...props, classRoot, layout, isWdFormDetail };
415
401
  // 组件规范化后再考虑是否改动
416
- return isWdFormDetail ? (_jsx(WdFormItem, { ...formItemProps, children: formDetailRender() })) : (formDetailRender());
402
+ return isWdFormDetail ? _jsx(WdFormItem, { ...formItemProps, children: formDetailRender() }) : formDetailRender();
417
403
  });
418
404
  export default FormDetailCom;
@@ -6,6 +6,7 @@ type TCompRef = ICompRef<{
6
6
  start: () => void;
7
7
  }>;
8
8
  declare const _default: React.ForwardRefExoticComponent<CommonPropsType & {
9
+ duration: number;
9
10
  prizeList: {
10
11
  title: string;
11
12
  image: string;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useState, useEffect, useCallback, useImperativeHandle, useMemo, } from 'react';
2
+ import React, { useState, useEffect, useCallback, useImperativeHandle, useMemo } from 'react';
3
3
  import { usePlatform } from '../../utils/platform';
4
4
  import classNames from '../../utils/classnames';
5
5
  import { ConfigProvider } from 'tea-component';
@@ -8,7 +8,7 @@ import { getTempFileURL } from '../../utils/tcb';
8
8
  import './style';
9
9
  const CLASS_PREFIX = 'weda-lottery';
10
10
  export default React.forwardRef(function Lottery(props, ref) {
11
- const { className, id, style, prizeList, enablePrize, prizeResult, events } = props;
11
+ const { className, id, style, prizeList, enablePrize, prizeResult, events, duration = 2000 } = props;
12
12
  const platform = usePlatform();
13
13
  const [activedId, setActivedId] = useState(-1);
14
14
  const [isStartLottery, setIsStartLottery] = useState(false);
@@ -32,8 +32,8 @@ export default React.forwardRef(function Lottery(props, ref) {
32
32
  convertPrizeList(prizeList);
33
33
  }, [prizeList]);
34
34
  const lotteryAction = useMemo(() => {
35
- return new LotteryAction();
36
- }, []);
35
+ return new LotteryAction({ duration });
36
+ }, [duration]);
37
37
  //获取初始化默认数据,数据不足8条设置默认,超过8条获取前8条
38
38
  const lotteryListDefault = useCallback(() => {
39
39
  const list = [];
@@ -68,13 +68,7 @@ export default React.forwardRef(function Lottery(props, ref) {
68
68
  if (lotteryAction.isStart)
69
69
  return;
70
70
  setIsStartLottery(true);
71
- }, [
72
- lotteryAction.isStart,
73
- setIsStartLottery,
74
- setBtnActived,
75
- lotteryListDefault,
76
- setLotteryList,
77
- ]);
71
+ }, [lotteryAction.isStart, setIsStartLottery, setBtnActived, lotteryListDefault, setLotteryList]);
78
72
  const start = useCallback(() => {
79
73
  lotteryAction.start(prizeResult, () => {
80
74
  window.app.showToast({
@@ -226,12 +220,8 @@ export default React.forwardRef(function Lottery(props, ref) {
226
220
  return (_jsx("div", { className: `${CLASS_PREFIX}__dot-item`, style: {
227
221
  width: `${(9 * widthRatio) / 14}rem`,
228
222
  height: `${(9 * heightRatio) / 14}rem`,
229
- marginBottom: `${direction}` === 'vertical'
230
- ? `${(43 * heightRatio) / 14}rem`
231
- : '0',
232
- marginRight: `${direction}` === 'horizontal'
233
- ? `${(43 * widthRatio) / 14}rem`
234
- : '0',
223
+ marginBottom: `${direction}` === 'vertical' ? `${(43 * heightRatio) / 14}rem` : '0',
224
+ marginRight: `${direction}` === 'horizontal' ? `${(43 * widthRatio) / 14}rem` : '0',
235
225
  } }, index));
236
226
  }) }) }));
237
227
  };
@@ -289,41 +279,31 @@ export default React.forwardRef(function Lottery(props, ref) {
289
279
  return (_jsxs("div", { children: [dot.single && (_jsx("div", { className: classNames(`${CLASS_PREFIX}__dot-single`, `${CLASS_PREFIX}__dot-${dot.position}`), style: {
290
280
  width: `${(9 * widthRatio) / 14}rem`,
291
281
  height: `${(9 * heightRatio) / 14}rem`,
292
- top: `${dot.position}` === 'left-top' ||
293
- `${dot.position}` === 'right-top'
282
+ top: `${dot.position}` === 'left-top' || `${dot.position}` === 'right-top'
294
283
  ? `${(9 * heightRatio) / 14}rem`
295
284
  : '',
296
- bottom: `${dot.position}` === 'left-bottom' ||
297
- `${dot.position}` === 'right-bottom'
285
+ bottom: `${dot.position}` === 'left-bottom' || `${dot.position}` === 'right-bottom'
298
286
  ? `${(9 * heightRatio) / 14}rem`
299
287
  : '',
300
- left: `${dot.position}` === 'left-top' ||
301
- `${dot.position}` === 'left-bottom'
288
+ left: `${dot.position}` === 'left-top' || `${dot.position}` === 'left-bottom'
302
289
  ? `${(6 * widthRatio) / 14}rem`
303
290
  : '',
304
- right: `${dot.position}` === 'right-top' ||
305
- `${dot.position}` === 'right-bottom'
291
+ right: `${dot.position}` === 'right-top' || `${dot.position}` === 'right-bottom'
306
292
  ? `${(6 * widthRatio) / 14}rem`
307
293
  : '',
308
294
  } }, `${dot.direction}-${index}`)), !dot.single && (_jsx("div", { className: `${CLASS_PREFIX}__dot-${dot.position}`, style: {
309
- left: `${dot.position}` === 'top' ||
310
- `${dot.position}` === 'bottom'
295
+ left: `${dot.position}` === 'top' || `${dot.position}` === 'bottom'
311
296
  ? `calc((${'100%'} - ${dotWidth}rem) / 2)`
312
297
  : `${dot.position}` === 'left'
313
298
  ? `${(widthRatio * 18 - widthRatio * 9) / 2 / 14}rem`
314
299
  : '',
315
- top: `${dot.position}` === 'left' ||
316
- `${dot.position}` === 'right'
300
+ top: `${dot.position}` === 'left' || `${dot.position}` === 'right'
317
301
  ? `calc((100% - ${dotHeight}rem) / 2)`
318
302
  : `${dot.position}` === 'top'
319
303
  ? `${(heightRatio * 18 - heightRatio * 9) / 2 / 14}rem`
320
304
  : '',
321
- bottom: `${dot.position}` === 'bottom'
322
- ? `${(heightRatio * 18 - heightRatio * 9) / 2 / 14}rem`
323
- : '',
324
- right: `${dot.position}` === 'right'
325
- ? `${(widthRatio * 18 - widthRatio * 9) / 2 / 14}rem`
326
- : '',
305
+ bottom: `${dot.position}` === 'bottom' ? `${(heightRatio * 18 - heightRatio * 9) / 2 / 14}rem` : '',
306
+ right: `${dot.position}` === 'right' ? `${(widthRatio * 18 - widthRatio * 9) / 2 / 14}rem` : '',
327
307
  }, children: true && renderDot(dot.direction, dot.list) }, `${dot.direction}-${index}`))] }, index));
328
308
  }), _jsx("div", { className: `${CLASS_PREFIX}__inner`, style: {
329
309
  paddingTop: `${(18 * heightRatio) / 14}rem`,
@@ -334,28 +314,20 @@ export default React.forwardRef(function Lottery(props, ref) {
334
314
  return (_jsx("li", { "data-testid": "lottery-item", className: classNames(`${CLASS_PREFIX}__turntable-item`, item.idx === activedId ? 'is-actived' : '', item.selected ? 'is-selected' : ''), style: {
335
315
  width: `calc((${'100%'} - ${(widthRatio * 8 * 4) / 14}rem) / 3)`,
336
316
  height: `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3)`,
337
- top: `${index}` == '0' ||
338
- `${index}` == '1' ||
339
- `${index}` == '2'
317
+ top: `${index}` == '0' || `${index}` == '1' || `${index}` == '2'
340
318
  ? `${(heightRatio * 8) / 14}rem`
341
319
  : `${index}` == '3'
342
320
  ? `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`
343
321
  : '',
344
- bottom: `${index}` == '4' ||
345
- `${index}` == '5' ||
346
- `${index}` == '6'
322
+ bottom: `${index}` == '4' || `${index}` == '5' || `${index}` == '6'
347
323
  ? `${(heightRatio * 8) / 14}rem`
348
324
  : `${index}` == '7'
349
325
  ? `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`
350
326
  : '',
351
- right: `${index}` == '2' ||
352
- `${index}` == '3' ||
353
- `${index}` == '4'
327
+ right: `${index}` == '2' || `${index}` == '3' || `${index}` == '4'
354
328
  ? `${(widthRatio * 8) / 14}rem`
355
329
  : '',
356
- left: `${index}` == '0' ||
357
- `${index}` == '6' ||
358
- `${index}` == '7'
330
+ left: `${index}` == '0' || `${index}` == '6' || `${index}` == '7'
359
331
  ? `${(widthRatio * 8) / 14}rem`
360
332
  : `${index}` == '1' || `${index}` == '5'
361
333
  ? `calc((${'100%'} - ${(widthRatio * 8 * 4) / 14}rem) / 3 + ${(widthRatio * 8 * 2) / 14}rem)`
@@ -13,7 +13,7 @@ export default class LotteryAction {
13
13
  isSpeedUp: boolean;
14
14
  timeout: number;
15
15
  timer: any;
16
- constructor();
16
+ constructor(option: any);
17
17
  start(prizeResult: any, errorCallback: any): void;
18
18
  end(prizeResult: any): void;
19
19
  error(): void;
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable rulesdir/no-timer */
2
2
  export default class LotteryAction {
3
- constructor() {
3
+ constructor(option) {
4
+ var _a;
4
5
  Object.defineProperty(this, "idx", {
5
6
  enumerable: true,
6
7
  configurable: true,
@@ -84,7 +85,7 @@ export default class LotteryAction {
84
85
  // 抽奖速度
85
86
  this.speed = 0;
86
87
  // 持续时长
87
- this.duration = 2000;
88
+ this.duration = (_a = option === null || option === void 0 ? void 0 : option.duration) !== null && _a !== void 0 ? _a : 2000;
88
89
  // 长度
89
90
  this.maxIdx = 8;
90
91
  // 回调动作
@@ -134,9 +135,7 @@ export default class LotteryAction {
134
135
  clearTimeout(this.timer);
135
136
  }
136
137
  pointOnCubicBezier(cp, t) {
137
- const x = Math.pow(1 - t, 2) * cp[0] +
138
- 2 * t * (1 - t) * cp[1] +
139
- Math.pow(t, 2) * cp[2];
138
+ const x = Math.pow(1 - t, 2) * cp[0] + 2 * t * (1 - t) * cp[1] + Math.pow(t, 2) * cp[2];
140
139
  return x;
141
140
  }
142
141
  loop() {
@@ -83,7 +83,7 @@ initialContent, placeholder, iconPack, maxSize, cloudPath, visible, }) {
83
83
  cloudToHttpsMap: {},
84
84
  });
85
85
  const previousValueRef = React.useRef();
86
- const onDataChange = function (value) {
86
+ const onDataChange = React.useCallback((value) => {
87
87
  var _a;
88
88
  if (previousValueRef.current !== value) {
89
89
  previousValueRef.current = value;
@@ -97,7 +97,7 @@ initialContent, placeholder, iconPack, maxSize, cloudPath, visible, }) {
97
97
  }
98
98
  }
99
99
  }
100
- };
100
+ }, [events, onChange]);
101
101
  const isSizeAccept = (file) => {
102
102
  if (file.size > maxSize * 1024 * 1024) {
103
103
  alertErrorMessage({
@@ -313,8 +313,14 @@ initialContent, placeholder, iconPack, maxSize, cloudPath, visible, }) {
313
313
  ref.current.editor.setHTML(tempValue);
314
314
  }
315
315
  window.setTimeout(() => {
316
+ var _a, _b;
316
317
  if (currentCursor) {
317
- ref.current.editor.selection(currentCursor, currentCursor);
318
+ try {
319
+ (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.editor) === null || _b === void 0 ? void 0 : _b.selection(currentCursor, currentCursor);
320
+ }
321
+ catch {
322
+ // 避免组件销毁,执行报错
323
+ }
318
324
  }
319
325
  }, 0);
320
326
  }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ interface FormFieldArrContext {
3
+ isInformArrContainer?: boolean;
4
+ namePath?: string[];
5
+ status?: 'edit' | 'disabled' | 'readOnly';
6
+ getFieldValue?: (arg: {
7
+ namePath: string[];
8
+ initialValue?: any;
9
+ }) => any;
10
+ setFieldValue?: (arg: {
11
+ namePath: string[];
12
+ value?: any;
13
+ }) => void;
14
+ }
15
+ interface FormFieldArrContextProviderProps extends FormFieldArrContext {
16
+ children?: React.ReactNode;
17
+ }
18
+ declare const FormFieldArrContext: React.Context<FormFieldArrContext>;
19
+ export declare function FormFieldArrProvider({ children, isInformArrContainer, namePath, status, setFieldValue, getFieldValue, }: FormFieldArrContextProviderProps): JSX.Element;
20
+ export declare function useFormFieldArr(): FormFieldArrContext | null;
21
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useMemo } from 'react';
3
+ import { createContext } from '../../../utils/global-context';
4
+ const FormFieldArrContext = createContext(null, 'FormFieldArrContext');
5
+ export function FormFieldArrProvider({ children, isInformArrContainer, namePath, status, setFieldValue, getFieldValue, }) {
6
+ return (_jsx(FormFieldArrContext.Provider, { value: useMemo(() => ({ status, isInformArrContainer, namePath, setFieldValue, getFieldValue }), [status, isInformArrContainer, namePath, setFieldValue, getFieldValue]), children: children }));
7
+ }
8
+ export function useFormFieldArr() {
9
+ return useContext(FormFieldArrContext);
10
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface FormFieldContext {
3
+ setFieldValue: (arg: {
4
+ namePath: string[];
5
+ value?: any;
6
+ }) => void;
7
+ getFieldValue: (arg: {
8
+ namePath: string[];
9
+ initialValue?: any;
10
+ }) => any;
11
+ isInformContainer?: boolean;
12
+ }
13
+ interface FormFieldContextProviderProps extends FormFieldContext {
14
+ children?: React.ReactNode;
15
+ }
16
+ export declare const FormFieldContext: React.Context<FormFieldContext>;
17
+ export declare function FormFieldProvider({ children, isInformContainer, setFieldValue, getFieldValue, }: FormFieldContextProviderProps): JSX.Element;
18
+ export declare function useFormField(): FormFieldContext | null;
19
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useMemo } from 'react';
3
+ import { createContext } from '../../../utils/global-context';
4
+ export const FormFieldContext = createContext(null, 'FormFieldContext');
5
+ export function FormFieldProvider({ children, isInformContainer, setFieldValue, getFieldValue, }) {
6
+ return (_jsx(FormFieldContext.Provider, { value: useMemo(() => ({ setFieldValue, isInformContainer, getFieldValue }), [setFieldValue, isInformContainer, getFieldValue]), children: children }));
7
+ }
8
+ export function useFormField() {
9
+ return useContext(FormFieldContext);
10
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface FormFieldObjContext {
3
+ namePath?: string[];
4
+ status?: 'edit' | 'disabled' | 'readOnly';
5
+ objType?: string;
6
+ }
7
+ interface FormFieldObjContextProviderProps extends FormFieldObjContext {
8
+ children?: React.ReactNode;
9
+ }
10
+ declare const FormFieldObjContext: React.Context<FormFieldObjContext>;
11
+ export declare function FormFieldObjProvider({ children, namePath, status, objType }: FormFieldObjContextProviderProps): JSX.Element;
12
+ export declare function useFormFieldObj(): FormFieldObjContext | null;
13
+ export {};
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useMemo } from 'react';
3
+ import { createContext } from '../../../utils/global-context';
4
+ const FormFieldObjContext = createContext(null, 'FormFieldObjContext');
5
+ export function FormFieldObjProvider({ children, namePath, status, objType }) {
6
+ return (_jsx(FormFieldObjContext.Provider, { value: useMemo(() => ({ objType, status, namePath }), [objType, status, namePath]), children: children }));
7
+ }
8
+ export function useFormFieldObj() {
9
+ return useContext(FormFieldObjContext);
10
+ }
@@ -5,3 +5,4 @@ export declare function getErrorObjectFromValidateResult(errObj: Record<string,
5
5
  format?: string;
6
6
  label?: string;
7
7
  }>>): Record<string, string>;
8
+ export declare function removeUnusedPaths(data: any, formItemMapList: any): any;
@@ -40,3 +40,35 @@ export function getErrorObjectFromValidateResult(errObj) {
40
40
  return acc;
41
41
  }, {});
42
42
  }
43
+ export function removeUnusedPaths(data, formItemMapList) {
44
+ // 1. 将路径列表转为Set提高查询效率
45
+ const validPaths = new Set(formItemMapList);
46
+ // 2. 递归清理函数
47
+ function clean(obj, currentPath = '') {
48
+ var _a;
49
+ // 处理数组空项(可选)
50
+ if (Array.isArray(obj) && obj.length) {
51
+ obj.forEach((item, index) => {
52
+ if (typeof item === 'object' && item !== null) {
53
+ const path = `${currentPath}[${index}]`;
54
+ clean(item, path); // 递归处理嵌套对象
55
+ }
56
+ });
57
+ }
58
+ else if (typeof obj === 'object' && obj !== null) {
59
+ (_a = Object.keys(obj)) === null || _a === void 0 ? void 0 : _a.forEach((key) => {
60
+ const path = currentPath ? `${currentPath}.${key}` : key;
61
+ if (!validPaths.has(path)) {
62
+ delete obj[key]; // 删除无效属性
63
+ }
64
+ else if (typeof obj[key] === 'object' && obj[key] !== null) {
65
+ clean(obj[key], path); // 递归处理嵌套对象
66
+ }
67
+ });
68
+ }
69
+ return obj;
70
+ }
71
+ // 3. 执行清理并返回新对象(不修改原data)
72
+ const a = clean(JSON.parse(JSON.stringify(data)));
73
+ return a;
74
+ }
@@ -14,17 +14,17 @@ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponen
14
14
  layout: "vertical" | "horizontal";
15
15
  dataSourceName: string;
16
16
  labelAlign: "left" | "right";
17
- isDisabledSubmit: boolean;
17
+ datasourceType: "connector" | "custom-connector" | "model" | "expression";
18
+ methodGetItem: string;
19
+ paramGetItem: Record<string, unknown>;
18
20
  methodCreate: string;
19
21
  methodUpdate: string;
22
+ isDisabledSubmit: boolean;
20
23
  formType_bind: boolean;
21
- datasourceType: "connector" | "model" | "expression" | "custom-connector";
22
24
  fields: {
23
25
  name: string;
24
26
  componentType: string;
25
27
  }[];
26
- methodGetItem: string;
27
- paramGetItem: Record<string, unknown>;
28
28
  colNum: never;
29
29
  lgWidth: "lg" | "sm" | "md" | "hundred";
30
30
  initialValues: Record<string, unknown>;