@dckj-npm/dc-material 0.1.368 → 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.
@@ -130,6 +130,34 @@ var isDataListBoundExpression = function isDataListBoundExpression(target) {
130
130
  var dataListValue = target === null || target === void 0 ? void 0 : (_target$getProps3 = target.getProps) === null || _target$getProps3 === void 0 ? void 0 : (_target$getProps3$cal = _target$getProps3.call(target)) === null || _target$getProps3$cal === void 0 ? void 0 : (_target$getProps3$cal2 = _target$getProps3$cal.getPropValue) === null || _target$getProps3$cal2 === void 0 ? void 0 : _target$getProps3$cal2.call(_target$getProps3$cal, 'dataList');
131
131
  return !!(dataListValue && typeof dataListValue === 'object' && dataListValue.type === 'JSExpression');
132
132
  };
133
+
134
+ /**
135
+ * 模块级 WeakMap 缓存:以 IPublicModelNode 对象引用为 key,存储每个 TeletextList 节点
136
+ * 最后一次已知的「非默认」dataList 值。
137
+ *
138
+ * 作用:在 setPropValue 触发的 settings 重评估中,引擎可能先将 node prop 清空再调用
139
+ * dataList.initialValue;此时 node.getPropValue 与 getProps().getPropValue 均返回
140
+ * undefined,导致 initialValue 回退默认数组、覆盖已绑定的 JSExpression 或用户数据。
141
+ * 通过在每次 imgWidth/imgHeight/imagePlacement.setValue 执行任何 setPropValue 之前
142
+ * 将当前 dataList 写入此缓存,initialValue 可从缓存安全恢复,彻底切断引擎中间态影响。
143
+ */
144
+ var _nodeDataListCache = new WeakMap();
145
+ var _cacheDataList = function _cacheDataList(target) {
146
+ var _node$getPropValue, _target$getProps4, _target$getProps4$cal, _target$getProps4$cal2;
147
+ var node = target === null || target === void 0 ? void 0 : target.node;
148
+ if (!node) return;
149
+ // 优先从 node 级 API 读取(schema 层,不受 settings 重评估中间态影响)
150
+ var fromNode = node === null || node === void 0 ? void 0 : (_node$getPropValue = node.getPropValue) === null || _node$getPropValue === void 0 ? void 0 : _node$getPropValue.call(node, 'dataList');
151
+ if (fromNode !== undefined) {
152
+ _nodeDataListCache.set(node, fromNode);
153
+ return;
154
+ }
155
+ // 降级:从 settings API 读取
156
+ var fromProps = target === null || target === void 0 ? void 0 : (_target$getProps4 = target.getProps) === null || _target$getProps4 === void 0 ? void 0 : (_target$getProps4$cal = _target$getProps4.call(target)) === null || _target$getProps4$cal === void 0 ? void 0 : (_target$getProps4$cal2 = _target$getProps4$cal.getPropValue) === null || _target$getProps4$cal2 === void 0 ? void 0 : _target$getProps4$cal2.call(_target$getProps4$cal, 'dataList');
157
+ if (fromProps !== undefined) {
158
+ _nodeDataListCache.set(node, fromProps);
159
+ }
160
+ };
133
161
  var TeletextListMeta = {
134
162
  group: '低代码组件',
135
163
  componentName: 'TeletextList',
@@ -234,6 +262,9 @@ var TeletextListMeta = {
234
262
  extraProps: {
235
263
  setValue: function setValue(target, value) {
236
264
  var props = target.getProps();
265
+ // 在任何 setPropValue 之前先写入模块级缓存,确保 dataList.initialValue
266
+ // 重评估时即使 engine 已清空 node prop 也能从缓存恢复正确值
267
+ _cacheDataList(target);
237
268
  // 显式快照需要保护的配置,防止引擎某些实现在写入时触发重初始化导致配置丢失
238
269
  var prevDataList = props.getPropValue('dataList');
239
270
  var prevDataListBind = props.getPropValue('dataListBind');
@@ -259,12 +290,12 @@ var TeletextListMeta = {
259
290
  componentName: 'NumberSetter',
260
291
  isRequired: false,
261
292
  initialValue: function initialValue(target) {
262
- var _target$getProps4, _target$getProps4$get;
293
+ var _target$getProps5, _target$getProps5$get;
263
294
  var styleWidth = getImageStyleNumber(target, 'width');
264
295
  if (styleWidth !== undefined) {
265
296
  return styleWidth;
266
297
  }
267
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps4 = target.getProps()) === null || _target$getProps4 === void 0 ? void 0 : (_target$getProps4$get = _target$getProps4.getPropValue) === null || _target$getProps4$get === void 0 ? void 0 : _target$getProps4$get.call(_target$getProps4, 'imgWidth');
298
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps5 = target.getProps()) === null || _target$getProps5 === void 0 ? void 0 : (_target$getProps5$get = _target$getProps5.getPropValue) === null || _target$getProps5$get === void 0 ? void 0 : _target$getProps5$get.call(_target$getProps5, 'imgWidth');
268
299
  var parsedPropValue = parsePxNumber(propValue);
269
300
  if (parsedPropValue !== undefined) return parsedPropValue;
270
301
  // 数据源已绑定时,避免回退为 100 触发误写回
@@ -274,12 +305,12 @@ var TeletextListMeta = {
274
305
  return 100;
275
306
  },
276
307
  defaultValue: function defaultValue(target) {
277
- var _target$getProps5, _target$getProps5$get;
308
+ var _target$getProps6, _target$getProps6$get;
278
309
  var styleWidth = getImageStyleNumber(target, 'width');
279
310
  if (styleWidth !== undefined) {
280
311
  return styleWidth;
281
312
  }
282
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps5 = target.getProps()) === null || _target$getProps5 === void 0 ? void 0 : (_target$getProps5$get = _target$getProps5.getPropValue) === null || _target$getProps5$get === void 0 ? void 0 : _target$getProps5$get.call(_target$getProps5, 'imgWidth');
313
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps6 = target.getProps()) === null || _target$getProps6 === void 0 ? void 0 : (_target$getProps6$get = _target$getProps6.getPropValue) === null || _target$getProps6$get === void 0 ? void 0 : _target$getProps6$get.call(_target$getProps6, 'imgWidth');
283
314
  var parsedPropValue = parsePxNumber(propValue);
284
315
  if (parsedPropValue !== undefined) return parsedPropValue;
285
316
  if (isDataListBoundExpression(target)) {
@@ -290,14 +321,14 @@ var TeletextListMeta = {
290
321
  },
291
322
  extraProps: {
292
323
  getValue: function getValue(target) {
293
- var _target$getProps6, _target$getProps6$get;
324
+ var _target$getProps7, _target$getProps7$get;
294
325
  // getValue 纯读操作,不做任何写入,避免触发引擎重评估其他 setter 的 initialValue
295
326
  // (写操作会导致引擎重初始化 dataList 等 prop,画布图片回退到默认图)
296
327
  var styleWidth = getImageStyleNumber(target, 'width');
297
328
  if (styleWidth !== undefined) {
298
329
  return styleWidth;
299
330
  }
300
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps6 = target.getProps()) === null || _target$getProps6 === void 0 ? void 0 : (_target$getProps6$get = _target$getProps6.getPropValue) === null || _target$getProps6$get === void 0 ? void 0 : _target$getProps6$get.call(_target$getProps6, 'imgWidth');
331
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps7 = target.getProps()) === null || _target$getProps7 === void 0 ? void 0 : (_target$getProps7$get = _target$getProps7.getPropValue) === null || _target$getProps7$get === void 0 ? void 0 : _target$getProps7$get.call(_target$getProps7, 'imgWidth');
301
332
  var parsedPropValue = parsePxNumber(propValue);
302
333
  if (parsedPropValue !== undefined) {
303
334
  return parsedPropValue;
@@ -310,8 +341,10 @@ var TeletextListMeta = {
310
341
  return;
311
342
  }
312
343
  var props = target.getProps();
344
+ // 在任何 setPropValue 之前先写入模块级缓存(与 imagePlacement.setValue 同策略)
345
+ _cacheDataList(target);
313
346
  // 快照需要保护的数据,防止 syncImageStyleValue → imageChildNode.setPropValue
314
- // 触发引擎重评估 dataList.initialValue,导致 dataList 被重置为默认图(与 imagePlacement.setValue 同策略)
347
+ // 触发引擎重评估 dataList.initialValue,导致 dataList 被重置为默认图
315
348
  var prevDataList = props.getPropValue('dataList');
316
349
  var prevDataListBind = props.getPropValue('dataListBind');
317
350
  props.setPropValue('imgWidth', parsedValue);
@@ -329,12 +362,12 @@ var TeletextListMeta = {
329
362
  componentName: 'NumberSetter',
330
363
  isRequired: false,
331
364
  initialValue: function initialValue(target) {
332
- var _target$getProps7, _target$getProps7$get;
365
+ var _target$getProps8, _target$getProps8$get;
333
366
  var styleHeight = getImageStyleNumber(target, 'height');
334
367
  if (styleHeight !== undefined) {
335
368
  return styleHeight;
336
369
  }
337
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps7 = target.getProps()) === null || _target$getProps7 === void 0 ? void 0 : (_target$getProps7$get = _target$getProps7.getPropValue) === null || _target$getProps7$get === void 0 ? void 0 : _target$getProps7$get.call(_target$getProps7, 'imgHeight');
370
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps8 = target.getProps()) === null || _target$getProps8 === void 0 ? void 0 : (_target$getProps8$get = _target$getProps8.getPropValue) === null || _target$getProps8$get === void 0 ? void 0 : _target$getProps8$get.call(_target$getProps8, 'imgHeight');
338
371
  var parsedPropValue = parsePxNumber(propValue);
339
372
  if (parsedPropValue !== undefined) return parsedPropValue;
340
373
  // 数据源已绑定时,避免回退为 100 触发误写回
@@ -344,12 +377,12 @@ var TeletextListMeta = {
344
377
  return 100;
345
378
  },
346
379
  defaultValue: function defaultValue(target) {
347
- var _target$getProps8, _target$getProps8$get;
380
+ var _target$getProps9, _target$getProps9$get;
348
381
  var styleHeight = getImageStyleNumber(target, 'height');
349
382
  if (styleHeight !== undefined) {
350
383
  return styleHeight;
351
384
  }
352
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps8 = target.getProps()) === null || _target$getProps8 === void 0 ? void 0 : (_target$getProps8$get = _target$getProps8.getPropValue) === null || _target$getProps8$get === void 0 ? void 0 : _target$getProps8$get.call(_target$getProps8, 'imgHeight');
385
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps9 = target.getProps()) === null || _target$getProps9 === void 0 ? void 0 : (_target$getProps9$get = _target$getProps9.getPropValue) === null || _target$getProps9$get === void 0 ? void 0 : _target$getProps9$get.call(_target$getProps9, 'imgHeight');
353
386
  var parsedPropValue = parsePxNumber(propValue);
354
387
  if (parsedPropValue !== undefined) return parsedPropValue;
355
388
  if (isDataListBoundExpression(target)) {
@@ -360,13 +393,13 @@ var TeletextListMeta = {
360
393
  },
361
394
  extraProps: {
362
395
  getValue: function getValue(target) {
363
- var _target$getProps9, _target$getProps9$get;
396
+ var _target$getProps0, _target$getProps0$get;
364
397
  // getValue 纯读操作,不做任何写入,避免触发引擎重评估其他 setter 的 initialValue
365
398
  var styleHeight = getImageStyleNumber(target, 'height');
366
399
  if (styleHeight !== undefined) {
367
400
  return styleHeight;
368
401
  }
369
- var propValue = target === null || target === void 0 ? void 0 : (_target$getProps9 = target.getProps()) === null || _target$getProps9 === void 0 ? void 0 : (_target$getProps9$get = _target$getProps9.getPropValue) === null || _target$getProps9$get === void 0 ? void 0 : _target$getProps9$get.call(_target$getProps9, 'imgHeight');
402
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps0 = target.getProps()) === null || _target$getProps0 === void 0 ? void 0 : (_target$getProps0$get = _target$getProps0.getPropValue) === null || _target$getProps0$get === void 0 ? void 0 : _target$getProps0$get.call(_target$getProps0, 'imgHeight');
370
403
  var parsedPropValue = parsePxNumber(propValue);
371
404
  if (parsedPropValue !== undefined) {
372
405
  return parsedPropValue;
@@ -379,6 +412,8 @@ var TeletextListMeta = {
379
412
  return;
380
413
  }
381
414
  var props = target.getProps();
415
+ // 在任何 setPropValue 之前先写入模块级缓存(与 imagePlacement.setValue 同策略)
416
+ _cacheDataList(target);
382
417
  // 快照需要保护的数据,防止 syncImageStyleValue → imageChildNode.setPropValue
383
418
  // 触发引擎重评估 dataList.initialValue,导致 dataList 被重置为默认图
384
419
  var prevDataList = props.getPropValue('dataList');
@@ -857,20 +892,28 @@ var TeletextListMeta = {
857
892
  }
858
893
  },
859
894
  initialValue: function initialValue(target) {
860
- var _target$node4, _target$node4$getProp, _target$getProps0, _target$getProps0$cal, _target$getProps0$cal2;
861
- // 若 dataList prop 已有值(用户自定义数组、JSExpression 数据源绑定等),
862
- // 直接返回当前值,防止引擎在任意 setPropValue 触发重评估时用静态默认数组
863
- // 覆盖已设置的 dataList,导致画布图片回退为默认图(问题 12.4 残留路径)。
864
- // 优先使用 node API(读取 schema 层数据,不受引擎 settings 重评估中间态影响);
865
- // settings API (getProps) 在引擎重评估时可能处于已清空的中间状态,
866
- // node.getPropValue 始终反映最后一次持久化写入的值。
867
- // 仅当两者均为 undefined(首次创建组件)时才注入默认占位数据。
868
- var fromNode = target === null || target === void 0 ? void 0 : (_target$node4 = target.node) === null || _target$node4 === void 0 ? void 0 : (_target$node4$getProp = _target$node4.getPropValue) === null || _target$node4$getProp === void 0 ? void 0 : _target$node4$getProp.call(_target$node4, 'dataList');
895
+ var _node$getPropValue2, _target$getProps1, _target$getProps1$cal, _target$getProps1$cal2;
896
+ // 读取顺序(由最可靠到最不可靠):
897
+ // 1. node 级 API(schema 层,引擎重评估前通常仍有值)
898
+ // 2. 模块级 WeakMap 缓存(在任何 setPropValue 之前写入,完全不受引擎清空影响)
899
+ // 3. settings API(重评估中间态下可能已清空,作为最后手段)
900
+ // 4. 默认占位数据(仅首次创建组件时触达)
901
+ var node = target === null || target === void 0 ? void 0 : target.node;
902
+ var fromNode = node === null || node === void 0 ? void 0 : (_node$getPropValue2 = node.getPropValue) === null || _node$getPropValue2 === void 0 ? void 0 : _node$getPropValue2.call(node, 'dataList');
869
903
  if (fromNode !== undefined) {
904
+ // 同步更新缓存,为后续可能的重评估提供后备
905
+ if (node) _nodeDataListCache.set(node, fromNode);
870
906
  return fromNode;
871
907
  }
872
- var current = target === null || target === void 0 ? void 0 : (_target$getProps0 = target.getProps) === null || _target$getProps0 === void 0 ? void 0 : (_target$getProps0$cal = _target$getProps0.call(target)) === null || _target$getProps0$cal === void 0 ? void 0 : (_target$getProps0$cal2 = _target$getProps0$cal.getPropValue) === null || _target$getProps0$cal2 === void 0 ? void 0 : _target$getProps0$cal2.call(_target$getProps0$cal, 'dataList');
908
+ // node.getPropValue 返回 undefined:引擎已在调用 initialValue 前清空 node prop
909
+ // → 读取模块级缓存(在 setValue 中任何 setPropValue 之前写入,最可靠的后备)
910
+ var cached = node ? _nodeDataListCache.get(node) : undefined;
911
+ if (cached !== undefined) {
912
+ return cached;
913
+ }
914
+ var current = target === null || target === void 0 ? void 0 : (_target$getProps1 = target.getProps) === null || _target$getProps1 === void 0 ? void 0 : (_target$getProps1$cal = _target$getProps1.call(target)) === null || _target$getProps1$cal === void 0 ? void 0 : (_target$getProps1$cal2 = _target$getProps1$cal.getPropValue) === null || _target$getProps1$cal2 === void 0 ? void 0 : _target$getProps1$cal2.call(_target$getProps1$cal, 'dataList');
873
915
  if (current !== undefined) {
916
+ if (node) _nodeDataListCache.set(node, current);
874
917
  return current;
875
918
  }
876
919
  return [{
@@ -890,6 +933,47 @@ var TeletextListMeta = {
890
933
  }]
891
934
  }];
892
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
+ }
893
977
  }
894
978
  }],
895
979
  supports: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dckj-npm/dc-material",
3
- "version": "0.1.368",
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.368/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.368/build/index.html"
122
+ "homepage": "https://unpkg.com/@dckj-npm/dc-material@0.1.370/build/index.html"
123
123
  }