@dckj-npm/dc-material 0.1.372 → 0.1.374
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.
- package/build/docs/colorful-button.html +3 -3
- package/build/docs/colorful-input.html +3 -3
- package/build/docs/index.html +3 -3
- package/build/docs/teletext-list.html +3 -3
- package/build/docs/{umi.78ba47eb.js → umi.f5910099.js} +1 -1
- package/build/docs/~demos/colorful-button-demo.html +3 -3
- package/build/docs/~demos/colorful-input-demo.html +3 -3
- package/build/docs/~demos/teletext-list-demo-1.html +3 -3
- package/build/docs/~demos/teletext-list-demo.html +3 -3
- package/build/lowcode/assets-daily.json +13 -13
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +13 -13
- package/build/lowcode/meta.design.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/lowcode/teletext-list/meta.ts +72 -328
- package/lowcode_es/meta.js +1 -1
- package/lowcode_es/teletext-list/meta.js +79 -333
- package/lowcode_lib/meta.js +1 -1
- package/lowcode_lib/teletext-list/meta.js +81 -335
- package/package.json +3 -3
|
@@ -27,25 +27,6 @@ const parsePxNumber = (value: any): number | undefined => {
|
|
|
27
27
|
return undefined
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const getSchemaChildren = (target: any): any[] => {
|
|
31
|
-
const nodeSchema = target?.node?.schema
|
|
32
|
-
return Array.isArray(nodeSchema?.children) ? nodeSchema.children : []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const findImageChildSchema = (target: any): any | undefined => {
|
|
36
|
-
const schemaChildren = getSchemaChildren(target)
|
|
37
|
-
return schemaChildren.find((child: any) => {
|
|
38
|
-
const keyFromProps = normalizeNodeKey(child?.props?.key)
|
|
39
|
-
const keyFromNode = normalizeNodeKey(child?.key)
|
|
40
|
-
return keyFromProps === IMAGE_KEY || keyFromNode === IMAGE_KEY
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 通过引擎的 IPublicModelNode API 查找 key='image' 的子节点。
|
|
46
|
-
* 相比直接读 node.schema.children,这里使用的是引擎可感知的公共 API,
|
|
47
|
-
* 保证后续 setPropValue/getPropValue 操作能被引擎正确追踪(触发响应式更新)。
|
|
48
|
-
*/
|
|
49
30
|
const findImageChildNode = (target: any): any | undefined => {
|
|
50
31
|
const children = target?.node?.children
|
|
51
32
|
if (!children) return undefined
|
|
@@ -58,118 +39,34 @@ const findImageChildNode = (target: any): any | undefined => {
|
|
|
58
39
|
}
|
|
59
40
|
|
|
60
41
|
const getImageStyleNumber = (target: any, styleKey: 'width' | 'height'): number | undefined => {
|
|
61
|
-
// 优先通过引擎 API 读取,保证与 syncImageStyleValue 写入来源一致
|
|
62
42
|
const imageChildNode = findImageChildNode(target)
|
|
63
43
|
if (imageChildNode) {
|
|
64
44
|
return parsePxNumber(imageChildNode.getPropValue?.('style')?.[styleKey])
|
|
65
45
|
}
|
|
66
|
-
|
|
67
|
-
const imageChildSchema = findImageChildSchema(target)
|
|
68
|
-
return parsePxNumber(imageChildSchema?.props?.style?.[styleKey])
|
|
46
|
+
return undefined
|
|
69
47
|
}
|
|
70
48
|
|
|
71
49
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* 此时 dataList 已稳定为正确的 JSExpression,重评估无副作用。
|
|
50
|
+
* 同步 Image 子节点的 style.width / style.height。
|
|
51
|
+
* 使用 Promise.resolve().then() 异步执行,避免在父节点 setPropValue
|
|
52
|
+
* 的 MobX 同步响应链中触发子节点变更(可能导致 SettingField 重建)。
|
|
76
53
|
*/
|
|
77
54
|
const syncImageStyleValue = (target: any, styleKey: 'width' | 'height', value: number): void => {
|
|
78
55
|
Promise.resolve().then(() => {
|
|
79
|
-
// 优先通过引擎节点 API 更新子节点 style,确保引擎感知变化(布局面板读取时可见)
|
|
80
56
|
const imageChildNode = findImageChildNode(target)
|
|
81
|
-
if (imageChildNode)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const otherPropValue = parsePxNumber(target?.getProps?.()?.getPropValue?.(otherPropKey))
|
|
90
|
-
if (otherPropValue !== undefined) {
|
|
91
|
-
updatedStyle[otherKey] = `${otherPropValue}px`
|
|
92
|
-
} else {
|
|
93
|
-
// 子节点 style 也没有,使用默认值 100
|
|
94
|
-
updatedStyle[otherKey] = '100px'
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
imageChildNode.setPropValue?.('style', updatedStyle)
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
// 降级:直接写 schema(引擎无法感知,但保留作为兜底)
|
|
101
|
-
const imageChildSchema = findImageChildSchema(target)
|
|
102
|
-
if (!imageChildSchema) {
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
if (!imageChildSchema.props) {
|
|
106
|
-
imageChildSchema.props = {}
|
|
107
|
-
}
|
|
108
|
-
const currentStyle = imageChildSchema.props.style || {}
|
|
109
|
-
imageChildSchema.props.style = {
|
|
110
|
-
...currentStyle,
|
|
111
|
-
[styleKey]: `${value}px`,
|
|
57
|
+
if (!imageChildNode) return
|
|
58
|
+
const currentStyle = imageChildNode.getPropValue?.('style') || {}
|
|
59
|
+
const updatedStyle: Record<string, any> = { ...currentStyle, [styleKey]: `${value}px` }
|
|
60
|
+
const otherKey = styleKey === 'width' ? 'height' : 'width'
|
|
61
|
+
if (!updatedStyle[otherKey]) {
|
|
62
|
+
const otherPropKey = otherKey === 'width' ? 'imgWidth' : 'imgHeight'
|
|
63
|
+
const otherPropValue = parsePxNumber(target?.getProps?.()?.getPropValue?.(otherPropKey))
|
|
64
|
+
updatedStyle[otherKey] = `${otherPropValue ?? 100}px`
|
|
112
65
|
}
|
|
66
|
+
imageChildNode.setPropValue?.('style', updatedStyle)
|
|
113
67
|
})
|
|
114
68
|
}
|
|
115
69
|
|
|
116
|
-
const syncImageDimensionPropsFromChild = (target: any) => {
|
|
117
|
-
const widthFromChild = getImageStyleNumber(target, 'width')
|
|
118
|
-
const heightFromChild = getImageStyleNumber(target, 'height')
|
|
119
|
-
const propsApi = target?.getProps?.()
|
|
120
|
-
|
|
121
|
-
if (propsApi && widthFromChild !== undefined) {
|
|
122
|
-
const currentWidth = parsePxNumber(propsApi.getPropValue?.('imgWidth'))
|
|
123
|
-
if (currentWidth !== widthFromChild) {
|
|
124
|
-
propsApi.setPropValue('imgWidth', widthFromChild)
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (propsApi && heightFromChild !== undefined) {
|
|
129
|
-
const currentHeight = parsePxNumber(propsApi.getPropValue?.('imgHeight'))
|
|
130
|
-
if (currentHeight !== heightFromChild) {
|
|
131
|
-
propsApi.setPropValue('imgHeight', heightFromChild)
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const isDataListBoundExpression = (target: any): boolean => {
|
|
137
|
-
const dataListValue = target?.getProps?.()?.getPropValue?.('dataList')
|
|
138
|
-
return !!(
|
|
139
|
-
dataListValue &&
|
|
140
|
-
typeof dataListValue === 'object' &&
|
|
141
|
-
(dataListValue as any).type === 'JSExpression'
|
|
142
|
-
)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* 模块级 WeakMap 缓存:以 IPublicModelNode 对象引用为 key,存储每个 TeletextList 节点
|
|
147
|
-
* 最后一次已知的「非默认」dataList 值。
|
|
148
|
-
*
|
|
149
|
-
* 作用:在 setPropValue 触发的 settings 重评估中,引擎可能先将 node prop 清空再调用
|
|
150
|
-
* dataList.initialValue;此时 node.getPropValue 与 getProps().getPropValue 均返回
|
|
151
|
-
* undefined,导致 initialValue 回退默认数组、覆盖已绑定的 JSExpression 或用户数据。
|
|
152
|
-
* 通过在每次 imgWidth/imgHeight/imagePlacement.setValue 执行任何 setPropValue 之前
|
|
153
|
-
* 将当前 dataList 写入此缓存,initialValue 可从缓存安全恢复,彻底切断引擎中间态影响。
|
|
154
|
-
*/
|
|
155
|
-
const _nodeDataListCache = new WeakMap<object, any>()
|
|
156
|
-
|
|
157
|
-
const _cacheDataList = (target: any): void => {
|
|
158
|
-
const node = target?.node
|
|
159
|
-
if (!node) return
|
|
160
|
-
// 优先从 node 级 API 读取(schema 层,不受 settings 重评估中间态影响)
|
|
161
|
-
const fromNode = node?.getPropValue?.('dataList')
|
|
162
|
-
if (fromNode !== undefined) {
|
|
163
|
-
_nodeDataListCache.set(node, fromNode)
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
// 降级:从 settings API 读取
|
|
167
|
-
const fromProps = target?.getProps?.()?.getPropValue?.('dataList')
|
|
168
|
-
if (fromProps !== undefined) {
|
|
169
|
-
_nodeDataListCache.set(node, fromProps)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
70
|
const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
174
71
|
group: '低代码组件',
|
|
175
72
|
componentName: 'TeletextList',
|
|
@@ -294,27 +191,8 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
|
294
191
|
initialValue: 'left',
|
|
295
192
|
},
|
|
296
193
|
extraProps: {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
// 在任何 setPropValue 之前先写入模块级缓存,确保 dataList.initialValue
|
|
300
|
-
// 重评估时即使 engine 已清空 node prop 也能从缓存恢复正确值
|
|
301
|
-
_cacheDataList(target)
|
|
302
|
-
// 显式快照需要保护的配置,防止引擎某些实现在写入时触发重初始化导致配置丢失
|
|
303
|
-
const prevDataList = props.getPropValue('dataList')
|
|
304
|
-
const prevDataListBind = props.getPropValue('dataListBind')
|
|
305
|
-
const prevTextImgGap = props.getPropValue('textImgGap')
|
|
306
|
-
const prevImgWidth = props.getPropValue('imgWidth')
|
|
307
|
-
const prevImgHeight = props.getPropValue('imgHeight')
|
|
308
|
-
props.setPropValue('imagePlacement', value)
|
|
309
|
-
// 写回被保护的配置(幂等操作,若引擎未重置则无副作用)
|
|
310
|
-
if (prevDataList !== undefined) props.setPropValue('dataList', prevDataList)
|
|
311
|
-
if (prevDataListBind !== undefined) props.setPropValue('dataListBind', prevDataListBind)
|
|
312
|
-
if (prevTextImgGap !== undefined) props.setPropValue('textImgGap', prevTextImgGap)
|
|
313
|
-
if (prevImgWidth !== undefined) props.setPropValue('imgWidth', prevImgWidth)
|
|
314
|
-
if (prevImgHeight !== undefined) props.setPropValue('imgHeight', prevImgHeight)
|
|
315
|
-
// 切换图片布局时同步一次子图片尺寸,避免面板回退到默认值
|
|
316
|
-
syncImageDimensionPropsFromChild(target)
|
|
317
|
-
},
|
|
194
|
+
// 引擎已自动 setPropValue('imagePlacement', value),无需再做任何额外写入
|
|
195
|
+
// 之前的快照-还原逻辑反而触发多余的 MobX 响应链,导致 dataList 被覆盖
|
|
318
196
|
},
|
|
319
197
|
},
|
|
320
198
|
{
|
|
@@ -324,60 +202,22 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
|
324
202
|
setter: {
|
|
325
203
|
componentName: 'NumberSetter',
|
|
326
204
|
isRequired: false,
|
|
327
|
-
initialValue:
|
|
328
|
-
const styleWidth = getImageStyleNumber(target, 'width')
|
|
329
|
-
if (styleWidth !== undefined) {
|
|
330
|
-
return styleWidth
|
|
331
|
-
}
|
|
332
|
-
const propValue = target?.getProps()?.getPropValue?.('imgWidth')
|
|
333
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
334
|
-
if (parsedPropValue !== undefined) return parsedPropValue
|
|
335
|
-
// 数据源已绑定时,避免回退为 100 触发误写回
|
|
336
|
-
if (isDataListBoundExpression(target)) {
|
|
337
|
-
return undefined
|
|
338
|
-
}
|
|
339
|
-
return 100
|
|
340
|
-
},
|
|
341
|
-
defaultValue: (target) => {
|
|
342
|
-
const styleWidth = getImageStyleNumber(target, 'width')
|
|
343
|
-
if (styleWidth !== undefined) {
|
|
344
|
-
return styleWidth
|
|
345
|
-
}
|
|
346
|
-
const propValue = target?.getProps()?.getPropValue?.('imgWidth')
|
|
347
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
348
|
-
if (parsedPropValue !== undefined) return parsedPropValue
|
|
349
|
-
if (isDataListBoundExpression(target)) {
|
|
350
|
-
return undefined
|
|
351
|
-
}
|
|
352
|
-
return 100
|
|
353
|
-
},
|
|
205
|
+
initialValue: 100,
|
|
354
206
|
},
|
|
355
207
|
extraProps: {
|
|
356
|
-
getValue: (target) => {
|
|
357
|
-
|
|
358
|
-
// (写操作会导致引擎重初始化 dataList 等 prop,画布图片回退到默认图)
|
|
208
|
+
getValue: (target, value) => {
|
|
209
|
+
if (value !== undefined) return parsePxNumber(value) ?? 100
|
|
359
210
|
const styleWidth = getImageStyleNumber(target, 'width')
|
|
360
|
-
if (styleWidth !== undefined)
|
|
361
|
-
return styleWidth
|
|
362
|
-
}
|
|
363
|
-
const propValue = target?.getProps()?.getPropValue?.('imgWidth')
|
|
364
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
365
|
-
if (parsedPropValue !== undefined) {
|
|
366
|
-
return parsedPropValue
|
|
367
|
-
}
|
|
211
|
+
if (styleWidth !== undefined) return styleWidth
|
|
368
212
|
return 100
|
|
369
213
|
},
|
|
370
214
|
setValue: (target, value) => {
|
|
215
|
+
// 引擎已自动 setPropValue('imgWidth', value)
|
|
216
|
+
// 只需同步到 Image 子节点的 style
|
|
371
217
|
const parsedValue = parsePxNumber(value)
|
|
372
|
-
if (parsedValue
|
|
373
|
-
|
|
218
|
+
if (parsedValue !== undefined) {
|
|
219
|
+
syncImageStyleValue(target, 'width', parsedValue)
|
|
374
220
|
}
|
|
375
|
-
const props = target.getProps()
|
|
376
|
-
// 在写入前先更新模块级缓存,确保async syncImageStyleValue触发的重评估时缓存有效
|
|
377
|
-
_cacheDataList(target)
|
|
378
|
-
props.setPropValue('imgWidth', parsedValue)
|
|
379
|
-
// syncImageStyleValue 异步执行,不在当前同步栈内触发 dataList.initialValue 重评估
|
|
380
|
-
syncImageStyleValue(target, 'width', parsedValue)
|
|
381
221
|
},
|
|
382
222
|
},
|
|
383
223
|
},
|
|
@@ -388,59 +228,22 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
|
388
228
|
setter: {
|
|
389
229
|
componentName: 'NumberSetter',
|
|
390
230
|
isRequired: false,
|
|
391
|
-
initialValue:
|
|
392
|
-
const styleHeight = getImageStyleNumber(target, 'height')
|
|
393
|
-
if (styleHeight !== undefined) {
|
|
394
|
-
return styleHeight
|
|
395
|
-
}
|
|
396
|
-
const propValue = target?.getProps()?.getPropValue?.('imgHeight')
|
|
397
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
398
|
-
if (parsedPropValue !== undefined) return parsedPropValue
|
|
399
|
-
// 数据源已绑定时,避免回退为 100 触发误写回
|
|
400
|
-
if (isDataListBoundExpression(target)) {
|
|
401
|
-
return undefined
|
|
402
|
-
}
|
|
403
|
-
return 100
|
|
404
|
-
},
|
|
405
|
-
defaultValue: (target) => {
|
|
406
|
-
const styleHeight = getImageStyleNumber(target, 'height')
|
|
407
|
-
if (styleHeight !== undefined) {
|
|
408
|
-
return styleHeight
|
|
409
|
-
}
|
|
410
|
-
const propValue = target?.getProps()?.getPropValue?.('imgHeight')
|
|
411
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
412
|
-
if (parsedPropValue !== undefined) return parsedPropValue
|
|
413
|
-
if (isDataListBoundExpression(target)) {
|
|
414
|
-
return undefined
|
|
415
|
-
}
|
|
416
|
-
return 100
|
|
417
|
-
},
|
|
231
|
+
initialValue: 100,
|
|
418
232
|
},
|
|
419
233
|
extraProps: {
|
|
420
|
-
getValue: (target) => {
|
|
421
|
-
|
|
234
|
+
getValue: (target, value) => {
|
|
235
|
+
if (value !== undefined) return parsePxNumber(value) ?? 100
|
|
422
236
|
const styleHeight = getImageStyleNumber(target, 'height')
|
|
423
|
-
if (styleHeight !== undefined)
|
|
424
|
-
return styleHeight
|
|
425
|
-
}
|
|
426
|
-
const propValue = target?.getProps()?.getPropValue?.('imgHeight')
|
|
427
|
-
const parsedPropValue = parsePxNumber(propValue)
|
|
428
|
-
if (parsedPropValue !== undefined) {
|
|
429
|
-
return parsedPropValue
|
|
430
|
-
}
|
|
237
|
+
if (styleHeight !== undefined) return styleHeight
|
|
431
238
|
return 100
|
|
432
239
|
},
|
|
433
240
|
setValue: (target, value) => {
|
|
241
|
+
// 引擎已自动 setPropValue('imgHeight', value)
|
|
242
|
+
// 只需同步到 Image 子节点的 style
|
|
434
243
|
const parsedValue = parsePxNumber(value)
|
|
435
|
-
if (parsedValue
|
|
436
|
-
|
|
244
|
+
if (parsedValue !== undefined) {
|
|
245
|
+
syncImageStyleValue(target, 'height', parsedValue)
|
|
437
246
|
}
|
|
438
|
-
const props = target.getProps()
|
|
439
|
-
// 在写入前先更新模块级缓存,确保async syncImageStyleValue触发的重评估时缓存有效
|
|
440
|
-
_cacheDataList(target)
|
|
441
|
-
props.setPropValue('imgHeight', parsedValue)
|
|
442
|
-
// syncImageStyleValue 异步执行,不在当前同步栈内触发 dataList.initialValue 重评估
|
|
443
|
-
syncImageStyleValue(target, 'height', parsedValue)
|
|
444
247
|
},
|
|
445
248
|
},
|
|
446
249
|
},
|
|
@@ -952,112 +755,32 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
|
952
755
|
},
|
|
953
756
|
},
|
|
954
757
|
initialValue: (target) => {
|
|
955
|
-
//
|
|
956
|
-
//
|
|
957
|
-
//
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
// 无论是哪种场景的 initialValue 调用,都必须返回已有值而不是默认数组。
|
|
963
|
-
// syncImageStyleValue 改为异步后,通常 node.getPropValue 已能拿到正确值;
|
|
964
|
-
// 缓存作为最后一道防线,彻底切断默认数组覆盖绑定表达式的可能。
|
|
965
|
-
const node = target?.node
|
|
966
|
-
// 优先读缓存:即使 node.getPropValue 暂时处于中间态,缓存也能提供可靠值
|
|
967
|
-
const cached = node ? _nodeDataListCache.get(node) : undefined
|
|
968
|
-
const fromNode = node?.getPropValue?.('dataList')
|
|
969
|
-
if (fromNode !== undefined) {
|
|
970
|
-
// 同步更新缓存,为后续可能的重评估提供后备
|
|
971
|
-
if (node) _nodeDataListCache.set(node, fromNode)
|
|
972
|
-
return fromNode
|
|
973
|
-
}
|
|
974
|
-
// node.getPropValue 返回 undefined:引擎可能已在调用 initialValue 前清空 node prop
|
|
975
|
-
// → 读取模块级缓存(在 setValue 中任何 setPropValue 之前写入,最可靠的后备)
|
|
976
|
-
if (cached !== undefined) {
|
|
977
|
-
return cached
|
|
978
|
-
}
|
|
979
|
-
const current = target?.getProps?.()?.getPropValue?.('dataList')
|
|
980
|
-
if (current !== undefined) {
|
|
981
|
-
if (node) _nodeDataListCache.set(node, current)
|
|
982
|
-
return current
|
|
983
|
-
}
|
|
984
|
-
return [
|
|
985
|
-
{
|
|
986
|
-
image: 'https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg',
|
|
987
|
-
title: '标题名称',
|
|
988
|
-
description:
|
|
989
|
-
'说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字',
|
|
990
|
-
},
|
|
991
|
-
{
|
|
992
|
-
image: 'https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg',
|
|
993
|
-
title: '标题名称',
|
|
994
|
-
description:
|
|
995
|
-
'说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字',
|
|
996
|
-
tags: [
|
|
997
|
-
{
|
|
998
|
-
name: '报名火热',
|
|
999
|
-
color: 'orange',
|
|
1000
|
-
},
|
|
1001
|
-
{
|
|
1002
|
-
name: '人数众多',
|
|
1003
|
-
color: 'blue',
|
|
1004
|
-
},
|
|
1005
|
-
],
|
|
1006
|
-
},
|
|
1007
|
-
]
|
|
758
|
+
// ignoreDefaultValue: () => true 保证此函数在 SettingFieldView remount 时
|
|
759
|
+
// 永远不会被 initDefaultValue 调用,仅作为安全兜底保留。
|
|
760
|
+
// 正常的首次创建数据由 snippet.props.dataList 提供。
|
|
761
|
+
const existing = target?.node?.schema?.props?.dataList
|
|
762
|
+
?? target?.getProps?.()?.getPropValue?.('dataList')
|
|
763
|
+
if (existing !== undefined) return existing
|
|
764
|
+
return DEFAULT_DATA_LIST
|
|
1008
765
|
},
|
|
1009
766
|
},
|
|
1010
767
|
extraProps: {
|
|
1011
768
|
/**
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
769
|
+
* ignoreDefaultValue: 彻底阻止引擎在 SettingFieldView remount 时
|
|
770
|
+
* 调用 initDefaultValue → 把 initialValue(默认数据数组)通过 field.setValue
|
|
771
|
+
* 写入 dataList prop,覆盖已绑定的 JSExpression。
|
|
1014
772
|
*
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
* 若此时 dataList Prop 处于 "unset" 中间态,parent.getPropValue 会返回 undefined,
|
|
1018
|
-
* 导致不带 getValue 时 field.getValue() = undefined → initDefaultValue 触发 → 默认图。
|
|
1019
|
-
* 有了此 getValue 后,即使 schema 层暂时返回 undefined,从缓存取值仍可返回用户数据,
|
|
1020
|
-
* field.getValue() 非 undefined → initDefaultValue 永远跳过 → 默认图问题彻底消失。
|
|
773
|
+
* 这是根本性解决方案:在引擎层面阻断 initDefaultValue 的执行,
|
|
774
|
+
* 而不是试图在 initialValue/getValue/setValue 中做缓存和还原来补救。
|
|
1021
775
|
*/
|
|
776
|
+
ignoreDefaultValue: () => true,
|
|
1022
777
|
getValue: (target: any, currentValue: any) => {
|
|
1023
|
-
|
|
1024
|
-
if (currentValue !== undefined)
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
// schema 层暂时无值(引擎重评估中间态):从缓存恢复,避免 initDefaultValue 触发
|
|
1030
|
-
const cached = node ? _nodeDataListCache.get(node) : undefined
|
|
1031
|
-
return cached // undefined 仅在缓存为空(全新组件首次初始化)时出现,属正常情况
|
|
1032
|
-
},
|
|
1033
|
-
/**
|
|
1034
|
-
* 自定义 setValue:用户每次编辑 dataList 条目时,先更新 WeakMap 缓存,
|
|
1035
|
-
* 再通过 node.setPropValue 将值持久化到 schema。
|
|
1036
|
-
*
|
|
1037
|
-
* ⚠️ 此引擎中 extraProps.setValue 完全接管写入逻辑,引擎不会自动持久化:
|
|
1038
|
-
* 若不在此处显式调用 setPropValue,用户编辑的数据将只存于内存缓存,
|
|
1039
|
-
* 页面刷新后丢失,同时 imgWidth/imgHeight.setValue 的快照–还原机制也因
|
|
1040
|
-
* props.getPropValue('dataList') 返回 undefined 而失效,导致还原跳过,
|
|
1041
|
-
* 进而触发引擎 initDefaultValue,画布回退默认图。
|
|
1042
|
-
*
|
|
1043
|
-
* 写入顺序:先缓存(供 initialValue/getValue 兜底),再写 schema(持久化)。
|
|
1044
|
-
* 写入 schema 会触发引擎对 settings 的重评估,但此时 schema 已有值,
|
|
1045
|
-
* initialValue 不会被调用,不会产生循环。
|
|
1046
|
-
*/
|
|
1047
|
-
setValue: (target: any, value: any) => {
|
|
1048
|
-
const node = target?.node
|
|
1049
|
-
if (!node) return
|
|
1050
|
-
if (value !== undefined) {
|
|
1051
|
-
// 先写缓存,确保重评估期间 getValue 可从缓存返回有效值
|
|
1052
|
-
_nodeDataListCache.set(node, value)
|
|
1053
|
-
// 再持久化到 schema(引擎不会自动写入,必须显式调用)
|
|
1054
|
-
target.getProps?.()?.setPropValue?.('dataList', value)
|
|
1055
|
-
} else {
|
|
1056
|
-
// clearValue 场景(value = undefined):清空缓存,使下次 initDefaultValue
|
|
1057
|
-
// 可正常返回默认数组(仅用于组件被显式清除数据的情况)
|
|
1058
|
-
_nodeDataListCache.delete(node)
|
|
1059
|
-
target.getProps?.()?.setPropValue?.('dataList', undefined)
|
|
1060
|
-
}
|
|
778
|
+
// currentValue 已有值时直接返回
|
|
779
|
+
if (currentValue !== undefined) return currentValue
|
|
780
|
+
// 从 schema 快照兜底读取(最可靠的源头数据,始终反映持久化状态)
|
|
781
|
+
const fromSchema = target?.node?.schema?.props?.dataList
|
|
782
|
+
if (fromSchema !== undefined) return fromSchema
|
|
783
|
+
return undefined
|
|
1061
784
|
},
|
|
1062
785
|
},
|
|
1063
786
|
},
|
|
@@ -1081,13 +804,34 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
|
|
|
1081
804
|
},
|
|
1082
805
|
}
|
|
1083
806
|
|
|
807
|
+
const DEFAULT_DATA_LIST = [
|
|
808
|
+
{
|
|
809
|
+
image: 'https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg',
|
|
810
|
+
title: '标题名称',
|
|
811
|
+
description:
|
|
812
|
+
'说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字',
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
image: 'https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg',
|
|
816
|
+
title: '标题名称',
|
|
817
|
+
description:
|
|
818
|
+
'说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字说明文字',
|
|
819
|
+
},
|
|
820
|
+
]
|
|
821
|
+
|
|
1084
822
|
const getSnippets = (textLines = 2): IPublicTypeSnippet[] => [
|
|
1085
823
|
{
|
|
1086
824
|
title: '图文列表',
|
|
1087
825
|
screenshot: '',
|
|
1088
826
|
schema: {
|
|
1089
827
|
componentName: 'TeletextList',
|
|
1090
|
-
props: {
|
|
828
|
+
props: {
|
|
829
|
+
// 将默认数据放到 snippet props 中,而非依赖 setter.initialValue。
|
|
830
|
+
// 因为 dataList 使用了 ignoreDefaultValue:()=>true 来阻止引擎在
|
|
831
|
+
// SettingFieldView remount 时覆盖已绑定的 JSExpression,
|
|
832
|
+
// 所以 initDefaultValue 永远不会运行,首次拖入的初始数据必须由 snippet 提供。
|
|
833
|
+
dataList: DEFAULT_DATA_LIST,
|
|
834
|
+
},
|
|
1091
835
|
children: [
|
|
1092
836
|
{
|
|
1093
837
|
componentName: 'NextText',
|
package/lowcode_es/meta.js
CHANGED
|
@@ -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.
|
|
120
|
+
version = '0.1.374';
|
|
121
121
|
}
|
|
122
122
|
if (basicLibraryVersion === void 0) {
|
|
123
123
|
basicLibraryVersion = {
|