@dckj-npm/dc-material 0.1.361 → 0.1.363

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 (47) hide show
  1. package/build/docs/colorful-button.html +3 -3
  2. package/build/docs/colorful-input.html +3 -3
  3. package/build/docs/index.html +3 -3
  4. package/build/docs/teletext-list.html +48 -0
  5. package/build/docs/umi.399a9633.js +1 -0
  6. package/build/docs/{umi.a2a18b22.css → umi.6743fcd4.css} +2 -2
  7. package/build/docs/~demos/colorful-button-demo.html +3 -3
  8. package/build/docs/~demos/colorful-input-demo.html +3 -3
  9. package/build/docs/~demos/teletext-list-demo-1.html +47 -0
  10. package/build/docs/~demos/teletext-list-demo.html +47 -0
  11. package/build/lowcode/assets-daily.json +13 -13
  12. package/build/lowcode/assets-dev.json +2 -2
  13. package/build/lowcode/assets-prod.json +13 -13
  14. package/build/lowcode/meta.design.js +1 -1
  15. package/build/lowcode/meta.js +1 -1
  16. package/build/lowcode/render/default/view.css +1 -1
  17. package/build/lowcode/render/default/view.js +1 -1
  18. package/build/lowcode/view.css +1 -1
  19. package/build/lowcode/view.js +1 -1
  20. package/dist/BizComps.css +1 -1
  21. package/dist/BizComps.js +1 -1
  22. package/dist/BizComps.js.map +1 -1
  23. package/es/components/teletext-list/index.scss +9 -0
  24. package/es/components/teletext-list/teletext-list-item.d.ts +5 -1
  25. package/es/components/teletext-list/teletext-list-item.js +32 -24
  26. package/es/components/teletext-list/teletext-list-item.scss +0 -16
  27. package/es/components/teletext-list/teletext-list.d.ts +4 -4
  28. package/es/components/teletext-list/teletext-list.js +11 -24
  29. package/es/types/assets.d.ts +4 -0
  30. package/es/utils/children-node-handle.js +12 -6
  31. package/lib/components/teletext-list/index.scss +9 -0
  32. package/lib/components/teletext-list/teletext-list-item.d.ts +5 -1
  33. package/lib/components/teletext-list/teletext-list-item.js +33 -24
  34. package/lib/components/teletext-list/teletext-list-item.scss +0 -16
  35. package/lib/components/teletext-list/teletext-list.d.ts +4 -4
  36. package/lib/components/teletext-list/teletext-list.js +11 -24
  37. package/lib/types/assets.d.ts +4 -0
  38. package/lib/utils/children-node-handle.js +12 -6
  39. package/lowcode/teletext-list/meta.ts +266 -38
  40. package/lowcode_es/meta.js +1 -1
  41. package/lowcode_es/teletext-list/meta.d.ts +2 -2
  42. package/lowcode_es/teletext-list/meta.js +272 -24
  43. package/lowcode_lib/meta.js +1 -1
  44. package/lowcode_lib/teletext-list/meta.d.ts +2 -2
  45. package/lowcode_lib/teletext-list/meta.js +274 -26
  46. package/package.json +3 -3
  47. package/build/docs/umi.e8fefa28.js +0 -1
@@ -5,6 +5,13 @@ exports.__esModule = true;
5
5
  exports.convertChildren = convertChildren;
6
6
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
7
  var _react = _interopRequireDefault(require("react"));
8
+ var normalizeNodeKey = function normalizeNodeKey(rawKey) {
9
+ if (rawKey === undefined || rawKey === null) {
10
+ return '';
11
+ }
12
+ return String(rawKey).replace(/^\.?\$?/, '');
13
+ };
14
+
8
15
  /**
9
16
  * 从children数组中获取指定组件
10
17
  * @author ZhuGangMin
@@ -15,17 +22,16 @@ var _react = _interopRequireDefault(require("react"));
15
22
  */
16
23
  function convertChildren(children, key, props) {
17
24
  var node;
25
+ var targetKey = normalizeNodeKey(key);
18
26
  if (Array.isArray(children)) {
19
27
  for (var i = 0; i < children.length; i++) {
28
+ var _child$props;
20
29
  var child = children[i];
21
- if (child.key === key) {
22
- var _child$props;
30
+ var childKey = normalizeNodeKey(child === null || child === void 0 ? void 0 : child.key);
31
+ var childPropsKey = normalizeNodeKey(child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.key);
32
+ if (childKey === targetKey || childPropsKey === targetKey) {
23
33
  // 属性融合
24
34
  var propsContact = props ? (0, _extends2["default"])({}, child.props, props) : child.props;
25
- // 样式融合
26
- if (props !== null && props !== void 0 && props.style && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.style) {
27
- propsContact.style = (0, _extends2["default"])({}, child.props.style, props.style);
28
- }
29
35
  node = /*#__PURE__*/_react["default"].cloneElement(child, propsContact);
30
36
  break;
31
37
  }
@@ -1,9 +1,125 @@
1
1
  import {
2
2
  IPublicTypeComponentMetadata,
3
3
  IPublicTypeSnippet,
4
- IPublicTypeConfigure,
5
4
  } from '@alilc/lowcode-types'
6
5
 
6
+ const IMAGE_KEY = 'image'
7
+
8
+ const normalizeNodeKey = (rawKey: any): string => {
9
+ if (rawKey === undefined || rawKey === null) return ''
10
+ return String(rawKey).replace(/^\.?\$?/, '')
11
+ }
12
+
13
+ const parsePxNumber = (value: any): number | undefined => {
14
+ if (typeof value === 'number' && Number.isFinite(value)) {
15
+ return value
16
+ }
17
+ if (typeof value === 'string') {
18
+ const numberLike = Number(value.trim())
19
+ if (Number.isFinite(numberLike)) {
20
+ return numberLike
21
+ }
22
+ const matched = value.match(/^\s*(\d+(?:\.\d+)?)\s*px\s*$/i)
23
+ if (!matched) return undefined
24
+ const parsed = Number(matched[1])
25
+ return Number.isFinite(parsed) ? parsed : undefined
26
+ }
27
+ return undefined
28
+ }
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
+ const findImageChildNode = (target: any): any | undefined => {
50
+ const children = target?.node?.children
51
+ if (!children) return undefined
52
+ if (typeof children.find === 'function') {
53
+ return children.find((child: any) => {
54
+ return normalizeNodeKey(child?.getPropValue?.('key')) === IMAGE_KEY
55
+ })
56
+ }
57
+ return undefined
58
+ }
59
+
60
+ const getImageStyleNumber = (target: any, styleKey: 'width' | 'height'): number | undefined => {
61
+ // 优先通过引擎 API 读取,保证与 syncImageStyleValue 写入来源一致
62
+ const imageChildNode = findImageChildNode(target)
63
+ if (imageChildNode) {
64
+ return parsePxNumber(imageChildNode.getPropValue?.('style')?.[styleKey])
65
+ }
66
+ // 降级:从 schema 快照读取
67
+ const imageChildSchema = findImageChildSchema(target)
68
+ return parsePxNumber(imageChildSchema?.props?.style?.[styleKey])
69
+ }
70
+
71
+ const syncImageStyleValue = (target: any, styleKey: 'width' | 'height', value: number) => {
72
+ // 优先通过引擎节点 API 更新子节点 style,确保引擎感知变化(布局面板读取时可见)
73
+ const imageChildNode = findImageChildNode(target)
74
+ if (imageChildNode) {
75
+ const currentStyle = imageChildNode.getPropValue?.('style') || {}
76
+ imageChildNode.setPropValue?.('style', { ...currentStyle, [styleKey]: `${value}px` })
77
+ return
78
+ }
79
+ // 降级:直接写 schema(引擎无法感知,但保留作为兜底)
80
+ const imageChildSchema = findImageChildSchema(target)
81
+ if (!imageChildSchema) {
82
+ return
83
+ }
84
+ if (!imageChildSchema.props) {
85
+ imageChildSchema.props = {}
86
+ }
87
+ const currentStyle = imageChildSchema.props.style || {}
88
+ imageChildSchema.props.style = {
89
+ ...currentStyle,
90
+ [styleKey]: `${value}px`,
91
+ }
92
+ }
93
+
94
+ const syncImageDimensionPropsFromChild = (target: any) => {
95
+ const widthFromChild = getImageStyleNumber(target, 'width')
96
+ const heightFromChild = getImageStyleNumber(target, 'height')
97
+ const propsApi = target?.getProps?.()
98
+
99
+ if (propsApi && widthFromChild !== undefined) {
100
+ const currentWidth = parsePxNumber(propsApi.getPropValue?.('imgWidth'))
101
+ if (currentWidth !== widthFromChild) {
102
+ propsApi.setPropValue('imgWidth', widthFromChild)
103
+ }
104
+ }
105
+
106
+ if (propsApi && heightFromChild !== undefined) {
107
+ const currentHeight = parsePxNumber(propsApi.getPropValue?.('imgHeight'))
108
+ if (currentHeight !== heightFromChild) {
109
+ propsApi.setPropValue('imgHeight', heightFromChild)
110
+ }
111
+ }
112
+ }
113
+
114
+ const isDataListBoundExpression = (target: any): boolean => {
115
+ const dataListValue = target?.getProps?.()?.getPropValue?.('dataList')
116
+ return !!(
117
+ dataListValue &&
118
+ typeof dataListValue === 'object' &&
119
+ (dataListValue as any).type === 'JSExpression'
120
+ )
121
+ }
122
+
7
123
  const TeletextListMeta: IPublicTypeComponentMetadata = {
8
124
  group: '低代码组件',
9
125
  componentName: 'TeletextList',
@@ -129,7 +245,18 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
129
245
  },
130
246
  extraProps: {
131
247
  setValue: (target, value) => {
132
- target.getProps().setPropValue('imagePlacement', value)
248
+ const props = target.getProps()
249
+ // 显式快照需要保护的配置,防止引擎某些实现在写入时触发重初始化导致配置丢失
250
+ const prevDataList = props.getPropValue('dataList')
251
+ const prevDataListBind = props.getPropValue('dataListBind')
252
+ const prevTextImgGap = props.getPropValue('textImgGap')
253
+ props.setPropValue('imagePlacement', value)
254
+ // 写回被保护的配置(幂等操作,若引擎未重置则无副作用)
255
+ if (prevDataList !== undefined) props.setPropValue('dataList', prevDataList)
256
+ if (prevDataListBind !== undefined) props.setPropValue('dataListBind', prevDataListBind)
257
+ if (prevTextImgGap !== undefined) props.setPropValue('textImgGap', prevTextImgGap)
258
+ // 切换图片布局时同步一次子图片尺寸,避免面板回退到默认值
259
+ syncImageDimensionPropsFromChild(target)
133
260
  },
134
261
  },
135
262
  },
@@ -140,8 +267,62 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
140
267
  setter: {
141
268
  componentName: 'NumberSetter',
142
269
  isRequired: false,
143
- initialValue: 100,
144
- defaultValue: 100,
270
+ initialValue: (target) => {
271
+ const styleWidth = getImageStyleNumber(target, 'width')
272
+ if (styleWidth !== undefined) {
273
+ return styleWidth
274
+ }
275
+ const propValue = target?.getProps()?.getPropValue?.('imgWidth')
276
+ const parsedPropValue = parsePxNumber(propValue)
277
+ if (parsedPropValue !== undefined) return parsedPropValue
278
+ // 数据源已绑定时,避免回退为 100 触发误写回
279
+ if (isDataListBoundExpression(target)) {
280
+ return undefined
281
+ }
282
+ return 100
283
+ },
284
+ defaultValue: (target) => {
285
+ const styleWidth = getImageStyleNumber(target, 'width')
286
+ if (styleWidth !== undefined) {
287
+ return styleWidth
288
+ }
289
+ const propValue = target?.getProps()?.getPropValue?.('imgWidth')
290
+ const parsedPropValue = parsePxNumber(propValue)
291
+ if (parsedPropValue !== undefined) return parsedPropValue
292
+ if (isDataListBoundExpression(target)) {
293
+ return undefined
294
+ }
295
+ return 100
296
+ },
297
+ },
298
+ extraProps: {
299
+ getValue: (target) => {
300
+ const styleWidth = getImageStyleNumber(target, 'width')
301
+ if (styleWidth !== undefined) {
302
+ const currentWidth = parsePxNumber(target?.getProps()?.getPropValue?.('imgWidth'))
303
+ if (currentWidth !== styleWidth) {
304
+ target?.getProps()?.setPropValue?.('imgWidth', styleWidth)
305
+ }
306
+ return styleWidth
307
+ }
308
+ const propValue = target?.getProps()?.getPropValue?.('imgWidth')
309
+ const parsedPropValue = parsePxNumber(propValue)
310
+ if (parsedPropValue !== undefined) {
311
+ return parsedPropValue
312
+ }
313
+ if (isDataListBoundExpression(target)) {
314
+ return undefined
315
+ }
316
+ return 100
317
+ },
318
+ setValue: (target, value) => {
319
+ const parsedValue = parsePxNumber(value)
320
+ if (parsedValue === undefined) {
321
+ return
322
+ }
323
+ target.getProps().setPropValue('imgWidth', parsedValue)
324
+ syncImageStyleValue(target, 'width', parsedValue)
325
+ },
145
326
  },
146
327
  },
147
328
  {
@@ -151,8 +332,62 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
151
332
  setter: {
152
333
  componentName: 'NumberSetter',
153
334
  isRequired: false,
154
- initialValue: 100,
155
- defaultValue: 100,
335
+ initialValue: (target) => {
336
+ const styleHeight = getImageStyleNumber(target, 'height')
337
+ if (styleHeight !== undefined) {
338
+ return styleHeight
339
+ }
340
+ const propValue = target?.getProps()?.getPropValue?.('imgHeight')
341
+ const parsedPropValue = parsePxNumber(propValue)
342
+ if (parsedPropValue !== undefined) return parsedPropValue
343
+ // 数据源已绑定时,避免回退为 100 触发误写回
344
+ if (isDataListBoundExpression(target)) {
345
+ return undefined
346
+ }
347
+ return 100
348
+ },
349
+ defaultValue: (target) => {
350
+ const styleHeight = getImageStyleNumber(target, 'height')
351
+ if (styleHeight !== undefined) {
352
+ return styleHeight
353
+ }
354
+ const propValue = target?.getProps()?.getPropValue?.('imgHeight')
355
+ const parsedPropValue = parsePxNumber(propValue)
356
+ if (parsedPropValue !== undefined) return parsedPropValue
357
+ if (isDataListBoundExpression(target)) {
358
+ return undefined
359
+ }
360
+ return 100
361
+ },
362
+ },
363
+ extraProps: {
364
+ getValue: (target) => {
365
+ const styleHeight = getImageStyleNumber(target, 'height')
366
+ if (styleHeight !== undefined) {
367
+ const currentHeight = parsePxNumber(target?.getProps()?.getPropValue?.('imgHeight'))
368
+ if (currentHeight !== styleHeight) {
369
+ target?.getProps()?.setPropValue?.('imgHeight', styleHeight)
370
+ }
371
+ return styleHeight
372
+ }
373
+ const propValue = target?.getProps()?.getPropValue?.('imgHeight')
374
+ const parsedPropValue = parsePxNumber(propValue)
375
+ if (parsedPropValue !== undefined) {
376
+ return parsedPropValue
377
+ }
378
+ if (isDataListBoundExpression(target)) {
379
+ return undefined
380
+ }
381
+ return 100
382
+ },
383
+ setValue: (target, value) => {
384
+ const parsedValue = parsePxNumber(value)
385
+ if (parsedValue === undefined) {
386
+ return
387
+ }
388
+ target.getProps().setPropValue('imgHeight', parsedValue)
389
+ syncImageStyleValue(target, 'height', parsedValue)
390
+ },
156
391
  },
157
392
  },
158
393
  {
@@ -177,7 +412,7 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
177
412
  },
178
413
  extraProps: {
179
414
  setValue: (target, value) => {
180
- console.log('dataList setValue', target, value)
415
+ target.getProps().setPropValue('dataListBind', value)
181
416
  },
182
417
  },
183
418
  },
@@ -225,14 +460,15 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
225
460
  extraProps: {
226
461
  setValue(target, value) {
227
462
  target.getProps().setPropValue('textLines', value)
228
- const schema = target?.node?.schema
229
- const node = target?.node
463
+ const schema: any = target?.node?.schema
464
+ const node: any = target?.node
465
+ const schemaChildren: any[] = Array.isArray(schema?.children) ? schema.children : []
230
466
 
231
467
  // 获取当前文本组件数量
232
468
  const currentLength =
233
- schema?.children?.filter(
469
+ schemaChildren.filter(
234
470
  (child) =>
235
- child.componentName === 'NextText' && child.props.key?.startsWith('text-'),
471
+ child.componentName === 'NextText' && child?.props?.key?.startsWith('text-'),
236
472
  )?.length || 0
237
473
 
238
474
  if (value > currentLength) {
@@ -246,23 +482,30 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
246
482
  key: `text-${i}`,
247
483
  },
248
484
  }
249
- console.log('node', node, 'node-children', node?.children)
250
485
  node?.children?.push(newChild)
251
486
  }
252
487
  } else if (value < currentLength) {
253
- // 需要移除多余的文本组件
254
- node?.children?.filter(
255
- (child) =>
256
- !(
257
- child.componentName === 'NextText' &&
258
- child.props?.key?.startsWith('text-') &&
259
- parseInt(child?.props?.key.split('-')[1]) > value
260
- ),
261
- )
488
+ // 收集需要移除的节点,再调用 child.remove() 通过引擎 API 逐个删除
489
+ // 避免 node.children = [...] 直接赋值(IPublicModelNodeChildren 不支持重新赋值)
490
+ const nodesToRemove: any[] = []
491
+ node?.children?.forEach?.((child: any) => {
492
+ const key = child?.schema?.props?.key
493
+ if (
494
+ child?.componentName === 'NextText' &&
495
+ typeof key === 'string' &&
496
+ key.startsWith('text-')
497
+ ) {
498
+ const order = Number(key.split('-')[1])
499
+ if (!Number.isNaN(order) && order > value) {
500
+ nodesToRemove.push(child)
501
+ }
502
+ }
503
+ })
504
+ nodesToRemove.forEach((child) => child?.remove?.())
262
505
  }
263
506
 
264
507
  // 更新数据源绑定的配置
265
- const dataListBindProp = target.parent.items.find(
508
+ const dataListBindProp = (target?.parent as any)?.items?.find(
266
509
  (item) => item.name === 'dataListBind',
267
510
  )
268
511
  if (dataListBindProp && dataListBindProp.setter) {
@@ -288,17 +531,6 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
288
531
  ...textChildren,
289
532
  ]
290
533
  }
291
-
292
- console.log(
293
- '文字行数',
294
- target,
295
- value,
296
- schema,
297
- target.node,
298
- target.parent,
299
- target.parent.getPropValue('dataListBind'),
300
- target.parent.node?.getProp('dataListBind'),
301
- )
302
534
  },
303
535
  },
304
536
  },
@@ -838,9 +1070,5 @@ const getSnippets = (textLines = 2): IPublicTypeSnippet[] => [
838
1070
 
839
1071
  export default {
840
1072
  ...TeletextListMeta,
841
- snippets: getSnippets(
842
- (TeletextListMeta.configure as IPublicTypeConfigure).props
843
- ?.find((prop) => prop.name === 'textLines')
844
- ?.setter?.getValue?.() || 2,
845
- ),
1073
+ snippets: getSnippets(2),
846
1074
  }
@@ -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.361';
120
+ version = '0.1.362';
121
121
  }
122
122
  if (basicLibraryVersion === void 0) {
123
123
  basicLibraryVersion = {
@@ -1,4 +1,4 @@
1
- import { IPublicTypeSnippet, IPublicTypeConfigure } from '@alilc/lowcode-types';
1
+ import { IPublicTypeSnippet } from '@alilc/lowcode-types';
2
2
  declare const _default: {
3
3
  snippets: IPublicTypeSnippet[];
4
4
  componentName: string;
@@ -12,7 +12,7 @@ declare const _default: {
12
12
  devMode?: "proCode" | "lowCode";
13
13
  npm?: import("@alilc/lowcode-types").IPublicTypeNpmInfo;
14
14
  props?: import("@alilc/lowcode-types").IPublicTypePropConfig[];
15
- configure?: import("@alilc/lowcode-types").IPublicTypeFieldConfig[] | IPublicTypeConfigure;
15
+ configure?: import("@alilc/lowcode-types").IPublicTypeFieldConfig[] | import("@alilc/lowcode-types").IPublicTypeConfigure;
16
16
  experimental?: import("@alilc/lowcode-types").IPublicTypeAdvanced;
17
17
  schema?: import("@alilc/lowcode-types").IPublicTypeComponentSchema;
18
18
  group?: string | import("@alilc/lowcode-types").IPublicTypeI18nData;