@openli1115/lowcode-edit-pro-table 1.0.64 → 1.0.65

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.
@@ -4,5 +4,9 @@ export declare function getFormContext(): any;
4
4
  export declare const FormProvider: React.FC<{
5
5
  initialValues?: Record<string, any>;
6
6
  onChange?: (values: Record<string, any>) => void;
7
+ /** 由 preview 传入:最后一次 onChange(newStructures) 的引用;若与 initialValues 全等则本次为 store 回灌,勿再 merge(根治 #185) */
8
+ lastOutboundStructuresRef?: {
9
+ current: any;
10
+ };
7
11
  children: React.ReactNode;
8
12
  }>;
@@ -33,6 +33,7 @@ export var FormProvider = function FormProvider(_ref) {
33
33
  var _ref$initialValues = _ref.initialValues,
34
34
  initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
35
35
  onChange = _ref.onChange,
36
+ lastOutboundStructuresRef = _ref.lastOutboundStructuresRef,
36
37
  children = _ref.children;
37
38
  var FormContext = getFormContext();
38
39
 
@@ -47,24 +48,12 @@ export var FormProvider = function FormProvider(_ref) {
47
48
  valuesRef.current = values;
48
49
 
49
50
  /**
50
- * setFieldValue onChange 写回 previewStore 后,父组件会把同一帧/下一帧的 screenStructures 再塞回 initialValues。
51
- * 旧数据 + 大表场景下 lodash isEqual 仍可能因类型/多余字段判成不等;Windows 上渲染更慢,Fusion Overlay 反复 setPosition,
52
- * 极易 #185。此处用「计数跳过」不依赖深度比较是否相等。
53
- */
54
- var pendingSkipStoreResyncRef = useRef(0);
55
-
56
- /**
57
- * store 每次 dispatch 都会给新的 screenStructures 引用;若内容与表单 state 实际一致仍 setValues,
58
- * 会整页重渲染(含 EditProTable、ss_xxx_tab 等大表),Fusion Overlay/Select 反复 setPosition,
59
- * 易触发 React #185(Maximum update depth exceeded)。
60
- *
61
- * 仅与 initialValuesRef 比较不够:用户改字段后 onChange 已把同一份数据写回 store,若此时再 merge,
62
- * 或与内表 mutate 的 window.screenStructures 产生细微差异,会反复 setValues 形成环。
63
- * 因此:initialValues 与当前表单 values 深度相等时,一律不再 setValues。
51
+ * store 每次 dispatch 都会给新的 screenStructures 引用;previewStore 直接把 onChange payload 设为 state(同引用)。
52
+ * initialValues === 上次 handleFormChange 推出去的对象,说明只是「表单 store props」回灌,禁止再 merge,否则大表 + Fusion #185。
53
+ * 逻辑流 / 接口改数会换对象引用,不会与 lastOutbound 全等。
64
54
  */
65
55
  useEffect(function () {
66
- if (pendingSkipStoreResyncRef.current > 0) {
67
- pendingSkipStoreResyncRef.current = 0;
56
+ if (lastOutboundStructuresRef && initialValues === lastOutboundStructuresRef.current) {
68
57
  initialValuesRef.current = initialValues;
69
58
  return;
70
59
  }
@@ -97,11 +86,8 @@ export var FormProvider = function FormProvider(_ref) {
97
86
  var newValues = cloneDeep(prev);
98
87
  set(newValues, path, value);
99
88
  console.log("[FormProvider] \uD83D\uDCDD Set field '" + path + "' to:", value);
100
-
101
- // 触发 onChange 回调,把新值通知到外部 store;计数放在微任务首行,避免早于「store 回灌」的 effect 误消费
102
89
  if (onChange) {
103
90
  Promise.resolve().then(function () {
104
- pendingSkipStoreResyncRef.current += 1;
105
91
  onChange(newValues);
106
92
  });
107
93
  }
@@ -4,5 +4,9 @@ export declare function getFormContext(): any;
4
4
  export declare const FormProvider: React.FC<{
5
5
  initialValues?: Record<string, any>;
6
6
  onChange?: (values: Record<string, any>) => void;
7
+ /** 由 preview 传入:最后一次 onChange(newStructures) 的引用;若与 initialValues 全等则本次为 store 回灌,勿再 merge(根治 #185) */
8
+ lastOutboundStructuresRef?: {
9
+ current: any;
10
+ };
7
11
  children: React.ReactNode;
8
12
  }>;
@@ -39,6 +39,7 @@ var FormProvider = exports.FormProvider = function FormProvider(_ref) {
39
39
  var _ref$initialValues = _ref.initialValues,
40
40
  initialValues = _ref$initialValues === void 0 ? {} : _ref$initialValues,
41
41
  onChange = _ref.onChange,
42
+ lastOutboundStructuresRef = _ref.lastOutboundStructuresRef,
42
43
  children = _ref.children;
43
44
  var FormContext = getFormContext();
44
45
 
@@ -53,24 +54,12 @@ var FormProvider = exports.FormProvider = function FormProvider(_ref) {
53
54
  valuesRef.current = values;
54
55
 
55
56
  /**
56
- * setFieldValue onChange 写回 previewStore 后,父组件会把同一帧/下一帧的 screenStructures 再塞回 initialValues。
57
- * 旧数据 + 大表场景下 lodash isEqual 仍可能因类型/多余字段判成不等;Windows 上渲染更慢,Fusion Overlay 反复 setPosition,
58
- * 极易 #185。此处用「计数跳过」不依赖深度比较是否相等。
59
- */
60
- var pendingSkipStoreResyncRef = useRef(0);
61
-
62
- /**
63
- * store 每次 dispatch 都会给新的 screenStructures 引用;若内容与表单 state 实际一致仍 setValues,
64
- * 会整页重渲染(含 EditProTable、ss_xxx_tab 等大表),Fusion Overlay/Select 反复 setPosition,
65
- * 易触发 React #185(Maximum update depth exceeded)。
66
- *
67
- * 仅与 initialValuesRef 比较不够:用户改字段后 onChange 已把同一份数据写回 store,若此时再 merge,
68
- * 或与内表 mutate 的 window.screenStructures 产生细微差异,会反复 setValues 形成环。
69
- * 因此:initialValues 与当前表单 values 深度相等时,一律不再 setValues。
57
+ * store 每次 dispatch 都会给新的 screenStructures 引用;previewStore 直接把 onChange payload 设为 state(同引用)。
58
+ * initialValues === 上次 handleFormChange 推出去的对象,说明只是「表单 store props」回灌,禁止再 merge,否则大表 + Fusion #185。
59
+ * 逻辑流 / 接口改数会换对象引用,不会与 lastOutbound 全等。
70
60
  */
71
61
  useEffect(function () {
72
- if (pendingSkipStoreResyncRef.current > 0) {
73
- pendingSkipStoreResyncRef.current = 0;
62
+ if (lastOutboundStructuresRef && initialValues === lastOutboundStructuresRef.current) {
74
63
  initialValuesRef.current = initialValues;
75
64
  return;
76
65
  }
@@ -103,11 +92,8 @@ var FormProvider = exports.FormProvider = function FormProvider(_ref) {
103
92
  var newValues = (0, _lodash.cloneDeep)(prev);
104
93
  (0, _lodash.set)(newValues, path, value);
105
94
  console.log("[FormProvider] \uD83D\uDCDD Set field '" + path + "' to:", value);
106
-
107
- // 触发 onChange 回调,把新值通知到外部 store;计数放在微任务首行,避免早于「store 回灌」的 effect 误消费
108
95
  if (onChange) {
109
96
  Promise.resolve().then(function () {
110
- pendingSkipStoreResyncRef.current += 1;
111
97
  onChange(newValues);
112
98
  });
113
99
  }
@@ -101,7 +101,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
101
101
  packageName = '@openli1115/lowcode-edit-pro-table';
102
102
  }
103
103
  if (version === void 0) {
104
- version = '1.0.64';
104
+ version = '1.0.65';
105
105
  }
106
106
  if (basicLibraryVersion === void 0) {
107
107
  basicLibraryVersion = {
@@ -106,7 +106,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
106
106
  packageName = '@openli1115/lowcode-edit-pro-table';
107
107
  }
108
108
  if (version === void 0) {
109
- version = '1.0.64';
109
+ version = '1.0.65';
110
110
  }
111
111
  if (basicLibraryVersion === void 0) {
112
112
  basicLibraryVersion = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openli1115/lowcode-edit-pro-table",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "description": "@openli1115/lowcode-edit-pro-table",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -101,10 +101,10 @@
101
101
  },
102
102
  "componentConfig": {
103
103
  "isComponentLibrary": true,
104
- "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.64/build/lowcode/assets-prod.json"
104
+ "materialSchema": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.65/build/lowcode/assets-prod.json"
105
105
  },
106
106
  "lcMeta": {
107
107
  "type": "component"
108
108
  },
109
- "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.64/build/index.html"
109
+ "homepage": "https://unpkg.com/@openli1115/lowcode-edit-pro-table@1.0.65/build/index.html"
110
110
  }