@dckj-npm/dc-material 0.1.369 → 0.1.370

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.
@@ -1005,6 +1005,47 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
1005
1005
  ]
1006
1006
  },
1007
1007
  },
1008
+ extraProps: {
1009
+ /**
1010
+ * 自定义 getValue:保证引擎重评估期间 field.getValue() 始终返回有效值(非 undefined),
1011
+ * 从而阻止 initDefaultValue 在不应该的时机调用 initialValue 并覆盖为默认图数组。
1012
+ *
1013
+ * 触发场景:修改 imgWidth/imgHeight 或通过布局面板修改图片 margin 时,
1014
+ * imageChildNode.setPropValue('style', ...) 会触发引擎对父节点 settings 的重评估;
1015
+ * 若此时 dataList Prop 处于 "unset" 中间态,parent.getPropValue 会返回 undefined,
1016
+ * 导致不带 getValue 时 field.getValue() = undefined → initDefaultValue 触发 → 默认图。
1017
+ * 有了此 getValue 后,即使 schema 层暂时返回 undefined,从缓存取值仍可返回用户数据,
1018
+ * field.getValue() 非 undefined → initDefaultValue 永远跳过 → 默认图问题彻底消失。
1019
+ */
1020
+ getValue: (target: any, currentValue: any) => {
1021
+ const node = target?.node
1022
+ if (currentValue !== undefined) {
1023
+ // schema 层有值:同步更新缓存,确保用户最新编辑的数据被记录
1024
+ if (node) _nodeDataListCache.set(node, currentValue)
1025
+ return currentValue
1026
+ }
1027
+ // schema 层暂时无值(引擎重评估中间态):从缓存恢复,避免 initDefaultValue 触发
1028
+ const cached = node ? _nodeDataListCache.get(node) : undefined
1029
+ return cached // undefined 仅在缓存为空(全新组件首次初始化)时出现,属正常情况
1030
+ },
1031
+ /**
1032
+ * 自定义 setValue:用户每次编辑 dataList 条目时即时更新 WeakMap 缓存。
1033
+ * 这是保证缓存与用户实际数据保持同步的关键——之前缓存只在
1034
+ * imgWidth/imgHeight/imagePlacement.setValue 中写入,用户直接编辑 dataList
1035
+ * 时缓存一直停留在初始默认值,导致 margin 修改时从缓存取出默认图数组。
1036
+ */
1037
+ setValue: (target: any, value: any) => {
1038
+ const node = target?.node
1039
+ if (!node) return
1040
+ if (value !== undefined) {
1041
+ _nodeDataListCache.set(node, value)
1042
+ } else {
1043
+ // clearValue 场景(value = undefined):清空缓存,使下次 initDefaultValue
1044
+ // 可正常返回默认数组(仅用于组件被显式清除数据的情况)
1045
+ _nodeDataListCache.delete(node)
1046
+ }
1047
+ },
1048
+ },
1008
1049
  },
1009
1050
  ],
1010
1051
  supports: {
@@ -117,7 +117,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
117
117
  packageName = '@dckj-npm/dc-material';
118
118
  }
119
119
  if (version === void 0) {
120
- version = '0.1.369';
120
+ version = '0.1.370';
121
121
  }
122
122
  if (basicLibraryVersion === void 0) {
123
123
  basicLibraryVersion = {
@@ -928,6 +928,47 @@ var TeletextListMeta = {
928
928
  }]
929
929
  }];
930
930
  }
931
+ },
932
+ extraProps: {
933
+ /**
934
+ * 自定义 getValue:保证引擎重评估期间 field.getValue() 始终返回有效值(非 undefined),
935
+ * 从而阻止 initDefaultValue 在不应该的时机调用 initialValue 并覆盖为默认图数组。
936
+ *
937
+ * 触发场景:修改 imgWidth/imgHeight 或通过布局面板修改图片 margin 时,
938
+ * imageChildNode.setPropValue('style', ...) 会触发引擎对父节点 settings 的重评估;
939
+ * 若此时 dataList Prop 处于 "unset" 中间态,parent.getPropValue 会返回 undefined,
940
+ * 导致不带 getValue 时 field.getValue() = undefined → initDefaultValue 触发 → 默认图。
941
+ * 有了此 getValue 后,即使 schema 层暂时返回 undefined,从缓存取值仍可返回用户数据,
942
+ * field.getValue() 非 undefined → initDefaultValue 永远跳过 → 默认图问题彻底消失。
943
+ */
944
+ getValue: function getValue(target, currentValue) {
945
+ var node = target === null || target === void 0 ? void 0 : target.node;
946
+ if (currentValue !== undefined) {
947
+ // schema 层有值:同步更新缓存,确保用户最新编辑的数据被记录
948
+ if (node) _nodeDataListCache.set(node, currentValue);
949
+ return currentValue;
950
+ }
951
+ // schema 层暂时无值(引擎重评估中间态):从缓存恢复,避免 initDefaultValue 触发
952
+ var cached = node ? _nodeDataListCache.get(node) : undefined;
953
+ return cached; // undefined 仅在缓存为空(全新组件首次初始化)时出现,属正常情况
954
+ },
955
+ /**
956
+ * 自定义 setValue:用户每次编辑 dataList 条目时即时更新 WeakMap 缓存。
957
+ * 这是保证缓存与用户实际数据保持同步的关键——之前缓存只在
958
+ * imgWidth/imgHeight/imagePlacement.setValue 中写入,用户直接编辑 dataList
959
+ * 时缓存一直停留在初始默认值,导致 margin 修改时从缓存取出默认图数组。
960
+ */
961
+ setValue: function setValue(target, value) {
962
+ var node = target === null || target === void 0 ? void 0 : target.node;
963
+ if (!node) return;
964
+ if (value !== undefined) {
965
+ _nodeDataListCache.set(node, value);
966
+ } else {
967
+ // clearValue 场景(value = undefined):清空缓存,使下次 initDefaultValue
968
+ // 可正常返回默认数组(仅用于组件被显式清除数据的情况)
969
+ _nodeDataListCache["delete"](node);
970
+ }
971
+ }
931
972
  }
932
973
  }],
933
974
  supports: {
@@ -122,7 +122,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
122
122
  packageName = '@dckj-npm/dc-material';
123
123
  }
124
124
  if (version === void 0) {
125
- version = '0.1.369';
125
+ version = '0.1.370';
126
126
  }
127
127
  if (basicLibraryVersion === void 0) {
128
128
  basicLibraryVersion = {
@@ -933,6 +933,47 @@ var TeletextListMeta = {
933
933
  }]
934
934
  }];
935
935
  }
936
+ },
937
+ extraProps: {
938
+ /**
939
+ * 自定义 getValue:保证引擎重评估期间 field.getValue() 始终返回有效值(非 undefined),
940
+ * 从而阻止 initDefaultValue 在不应该的时机调用 initialValue 并覆盖为默认图数组。
941
+ *
942
+ * 触发场景:修改 imgWidth/imgHeight 或通过布局面板修改图片 margin 时,
943
+ * imageChildNode.setPropValue('style', ...) 会触发引擎对父节点 settings 的重评估;
944
+ * 若此时 dataList Prop 处于 "unset" 中间态,parent.getPropValue 会返回 undefined,
945
+ * 导致不带 getValue 时 field.getValue() = undefined → initDefaultValue 触发 → 默认图。
946
+ * 有了此 getValue 后,即使 schema 层暂时返回 undefined,从缓存取值仍可返回用户数据,
947
+ * field.getValue() 非 undefined → initDefaultValue 永远跳过 → 默认图问题彻底消失。
948
+ */
949
+ getValue: function getValue(target, currentValue) {
950
+ var node = target === null || target === void 0 ? void 0 : target.node;
951
+ if (currentValue !== undefined) {
952
+ // schema 层有值:同步更新缓存,确保用户最新编辑的数据被记录
953
+ if (node) _nodeDataListCache.set(node, currentValue);
954
+ return currentValue;
955
+ }
956
+ // schema 层暂时无值(引擎重评估中间态):从缓存恢复,避免 initDefaultValue 触发
957
+ var cached = node ? _nodeDataListCache.get(node) : undefined;
958
+ return cached; // undefined 仅在缓存为空(全新组件首次初始化)时出现,属正常情况
959
+ },
960
+ /**
961
+ * 自定义 setValue:用户每次编辑 dataList 条目时即时更新 WeakMap 缓存。
962
+ * 这是保证缓存与用户实际数据保持同步的关键——之前缓存只在
963
+ * imgWidth/imgHeight/imagePlacement.setValue 中写入,用户直接编辑 dataList
964
+ * 时缓存一直停留在初始默认值,导致 margin 修改时从缓存取出默认图数组。
965
+ */
966
+ setValue: function setValue(target, value) {
967
+ var node = target === null || target === void 0 ? void 0 : target.node;
968
+ if (!node) return;
969
+ if (value !== undefined) {
970
+ _nodeDataListCache.set(node, value);
971
+ } else {
972
+ // clearValue 场景(value = undefined):清空缓存,使下次 initDefaultValue
973
+ // 可正常返回默认数组(仅用于组件被显式清除数据的情况)
974
+ _nodeDataListCache["delete"](node);
975
+ }
976
+ }
936
977
  }
937
978
  }],
938
979
  supports: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dckj-npm/dc-material",
3
- "version": "0.1.369",
3
+ "version": "0.1.370",
4
4
  "description": "dc低代码物料",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -114,10 +114,10 @@
114
114
  },
115
115
  "componentConfig": {
116
116
  "isComponentLibrary": true,
117
- "materialSchema": "https://unpkg.com/@dckj-npm/dc-material@0.1.369/build/lowcode/assets-prod.json"
117
+ "materialSchema": "https://unpkg.com/@dckj-npm/dc-material@0.1.370/build/lowcode/assets-prod.json"
118
118
  },
119
119
  "lcMeta": {
120
120
  "type": "component"
121
121
  },
122
- "homepage": "https://unpkg.com/@dckj-npm/dc-material@0.1.369/build/index.html"
122
+ "homepage": "https://unpkg.com/@dckj-npm/dc-material@0.1.370/build/index.html"
123
123
  }