@dckj-npm/dc-material 0.1.360 → 0.1.362

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 (46) hide show
  1. package/build/docs/colorful-button.html +48 -0
  2. package/build/docs/colorful-input.html +48 -0
  3. package/build/docs/index.html +48 -0
  4. package/build/docs/teletext-list.html +48 -0
  5. package/build/docs/umi.6743fcd4.css +8 -0
  6. package/build/docs/umi.b6edaa19.js +1 -0
  7. package/build/docs/~demos/colorful-button-demo.html +47 -0
  8. package/build/docs/~demos/colorful-input-demo.html +47 -0
  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/schema.json +1278 -0
  25. package/es/components/teletext-list/teletext-list-item.d.ts +5 -1
  26. package/es/components/teletext-list/teletext-list-item.js +33 -21
  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/schema.json +1278 -0
  33. package/lib/components/teletext-list/teletext-list-item.d.ts +5 -1
  34. package/lib/components/teletext-list/teletext-list-item.js +34 -21
  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 +176 -35
  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 +185 -22
  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 +187 -24
  46. package/package.json +3 -3
@@ -1,5 +1,77 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- var _props, _props$find, _props$find$setter, _props$find$setter$ge;
2
+ var IMAGE_KEY = 'image';
3
+ var normalizeNodeKey = function normalizeNodeKey(rawKey) {
4
+ if (rawKey === undefined || rawKey === null) return '';
5
+ return String(rawKey).replace(/^\.?\$?/, '');
6
+ };
7
+ var parsePxNumber = function parsePxNumber(value) {
8
+ if (typeof value === 'number' && Number.isFinite(value)) {
9
+ return value;
10
+ }
11
+ if (typeof value === 'string') {
12
+ var numberLike = Number(value.trim());
13
+ if (Number.isFinite(numberLike)) {
14
+ return numberLike;
15
+ }
16
+ var matched = value.match(/^\s*(\d+(?:\.\d+)?)\s*px\s*$/i);
17
+ if (!matched) return undefined;
18
+ var parsed = Number(matched[1]);
19
+ return Number.isFinite(parsed) ? parsed : undefined;
20
+ }
21
+ return undefined;
22
+ };
23
+ var getSchemaChildren = function getSchemaChildren(target) {
24
+ var _target$node;
25
+ var nodeSchema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
26
+ return Array.isArray(nodeSchema === null || nodeSchema === void 0 ? void 0 : nodeSchema.children) ? nodeSchema.children : [];
27
+ };
28
+ var findImageChildSchema = function findImageChildSchema(target) {
29
+ var schemaChildren = getSchemaChildren(target);
30
+ return schemaChildren.find(function (child) {
31
+ var _child$props;
32
+ var keyFromProps = normalizeNodeKey(child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.key);
33
+ var keyFromNode = normalizeNodeKey(child === null || child === void 0 ? void 0 : child.key);
34
+ return keyFromProps === IMAGE_KEY || keyFromNode === IMAGE_KEY;
35
+ });
36
+ };
37
+ var getImageStyleNumber = function getImageStyleNumber(target, styleKey) {
38
+ var _imageChildSchema$pro, _imageChildSchema$pro2;
39
+ var imageChildSchema = findImageChildSchema(target);
40
+ var childStyleValue = imageChildSchema === null || imageChildSchema === void 0 ? void 0 : (_imageChildSchema$pro = imageChildSchema.props) === null || _imageChildSchema$pro === void 0 ? void 0 : (_imageChildSchema$pro2 = _imageChildSchema$pro.style) === null || _imageChildSchema$pro2 === void 0 ? void 0 : _imageChildSchema$pro2[styleKey];
41
+ return parsePxNumber(childStyleValue);
42
+ };
43
+ var syncImageStyleValue = function syncImageStyleValue(target, styleKey, value) {
44
+ var _extends2;
45
+ var imageChildSchema = findImageChildSchema(target);
46
+ if (!imageChildSchema) {
47
+ return;
48
+ }
49
+ if (!imageChildSchema.props) {
50
+ imageChildSchema.props = {};
51
+ }
52
+ var currentStyle = imageChildSchema.props.style || {};
53
+ imageChildSchema.props.style = _extends({}, currentStyle, (_extends2 = {}, _extends2[styleKey] = value + "px", _extends2));
54
+ };
55
+ var syncImageDimensionPropsFromChild = function syncImageDimensionPropsFromChild(target) {
56
+ var _target$getProps;
57
+ var widthFromChild = getImageStyleNumber(target, 'width');
58
+ var heightFromChild = getImageStyleNumber(target, 'height');
59
+ var propsApi = target === null || target === void 0 ? void 0 : (_target$getProps = target.getProps) === null || _target$getProps === void 0 ? void 0 : _target$getProps.call(target);
60
+ if (propsApi && widthFromChild !== undefined) {
61
+ var _propsApi$getPropValu;
62
+ var currentWidth = parsePxNumber((_propsApi$getPropValu = propsApi.getPropValue) === null || _propsApi$getPropValu === void 0 ? void 0 : _propsApi$getPropValu.call(propsApi, 'imgWidth'));
63
+ if (currentWidth !== widthFromChild) {
64
+ propsApi.setPropValue('imgWidth', widthFromChild);
65
+ }
66
+ }
67
+ if (propsApi && heightFromChild !== undefined) {
68
+ var _propsApi$getPropValu2;
69
+ var currentHeight = parsePxNumber((_propsApi$getPropValu2 = propsApi.getPropValue) === null || _propsApi$getPropValu2 === void 0 ? void 0 : _propsApi$getPropValu2.call(propsApi, 'imgHeight'));
70
+ if (currentHeight !== heightFromChild) {
71
+ propsApi.setPropValue('imgHeight', heightFromChild);
72
+ }
73
+ }
74
+ };
3
75
  var TeletextListMeta = {
4
76
  group: '低代码组件',
5
77
  componentName: 'TeletextList',
@@ -104,6 +176,8 @@ var TeletextListMeta = {
104
176
  extraProps: {
105
177
  setValue: function setValue(target, value) {
106
178
  target.getProps().setPropValue('imagePlacement', value);
179
+ // 切换图片布局时同步一次子图片尺寸,避免面板回退到默认值
180
+ syncImageDimensionPropsFromChild(target);
107
181
  }
108
182
  }
109
183
  }, {
@@ -113,8 +187,50 @@ var TeletextListMeta = {
113
187
  setter: {
114
188
  componentName: 'NumberSetter',
115
189
  isRequired: false,
116
- initialValue: 100,
117
- defaultValue: 100
190
+ initialValue: function initialValue(target) {
191
+ var _target$getProps2, _target$getProps2$get, _getImageStyleNumber;
192
+ var styleWidth = getImageStyleNumber(target, 'width');
193
+ if (styleWidth !== undefined) {
194
+ return styleWidth;
195
+ }
196
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps2 = target.getProps()) === null || _target$getProps2 === void 0 ? void 0 : (_target$getProps2$get = _target$getProps2.getPropValue) === null || _target$getProps2$get === void 0 ? void 0 : _target$getProps2$get.call(_target$getProps2, 'imgWidth');
197
+ var parsedPropValue = parsePxNumber(propValue);
198
+ if (parsedPropValue !== undefined) return parsedPropValue;
199
+ return (_getImageStyleNumber = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber !== void 0 ? _getImageStyleNumber : 100;
200
+ },
201
+ defaultValue: function defaultValue(target) {
202
+ var _getImageStyleNumber2;
203
+ return (_getImageStyleNumber2 = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber2 !== void 0 ? _getImageStyleNumber2 : 100;
204
+ }
205
+ },
206
+ extraProps: {
207
+ getValue: function getValue(target) {
208
+ var _target$getProps5, _target$getProps5$get, _getImageStyleNumber3;
209
+ var styleWidth = getImageStyleNumber(target, 'width');
210
+ if (styleWidth !== undefined) {
211
+ var _target$getProps3, _target$getProps3$get;
212
+ var currentWidth = parsePxNumber(target === null || target === void 0 ? void 0 : (_target$getProps3 = target.getProps()) === null || _target$getProps3 === void 0 ? void 0 : (_target$getProps3$get = _target$getProps3.getPropValue) === null || _target$getProps3$get === void 0 ? void 0 : _target$getProps3$get.call(_target$getProps3, 'imgWidth'));
213
+ if (currentWidth !== styleWidth) {
214
+ var _target$getProps4, _target$getProps4$set;
215
+ target === null || target === void 0 ? void 0 : (_target$getProps4 = target.getProps()) === null || _target$getProps4 === void 0 ? void 0 : (_target$getProps4$set = _target$getProps4.setPropValue) === null || _target$getProps4$set === void 0 ? void 0 : _target$getProps4$set.call(_target$getProps4, 'imgWidth', styleWidth);
216
+ }
217
+ return styleWidth;
218
+ }
219
+ 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');
220
+ var parsedPropValue = parsePxNumber(propValue);
221
+ if (parsedPropValue !== undefined) {
222
+ return parsedPropValue;
223
+ }
224
+ return (_getImageStyleNumber3 = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber3 !== void 0 ? _getImageStyleNumber3 : 100;
225
+ },
226
+ setValue: function setValue(target, value) {
227
+ var parsedValue = parsePxNumber(value);
228
+ if (parsedValue === undefined) {
229
+ return;
230
+ }
231
+ target.getProps().setPropValue('imgWidth', parsedValue);
232
+ syncImageStyleValue(target, 'width', parsedValue);
233
+ }
118
234
  }
119
235
  }, {
120
236
  title: '图片高度',
@@ -123,8 +239,50 @@ var TeletextListMeta = {
123
239
  setter: {
124
240
  componentName: 'NumberSetter',
125
241
  isRequired: false,
126
- initialValue: 100,
127
- defaultValue: 100
242
+ initialValue: function initialValue(target) {
243
+ var _target$getProps6, _target$getProps6$get, _getImageStyleNumber4;
244
+ var styleHeight = getImageStyleNumber(target, 'height');
245
+ if (styleHeight !== undefined) {
246
+ return styleHeight;
247
+ }
248
+ 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, 'imgHeight');
249
+ var parsedPropValue = parsePxNumber(propValue);
250
+ if (parsedPropValue !== undefined) return parsedPropValue;
251
+ return (_getImageStyleNumber4 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber4 !== void 0 ? _getImageStyleNumber4 : 100;
252
+ },
253
+ defaultValue: function defaultValue(target) {
254
+ var _getImageStyleNumber5;
255
+ return (_getImageStyleNumber5 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber5 !== void 0 ? _getImageStyleNumber5 : 100;
256
+ }
257
+ },
258
+ extraProps: {
259
+ getValue: function getValue(target) {
260
+ var _target$getProps9, _target$getProps9$get, _getImageStyleNumber6;
261
+ var styleHeight = getImageStyleNumber(target, 'height');
262
+ if (styleHeight !== undefined) {
263
+ var _target$getProps7, _target$getProps7$get;
264
+ var currentHeight = parsePxNumber(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'));
265
+ if (currentHeight !== styleHeight) {
266
+ var _target$getProps8, _target$getProps8$set;
267
+ target === null || target === void 0 ? void 0 : (_target$getProps8 = target.getProps()) === null || _target$getProps8 === void 0 ? void 0 : (_target$getProps8$set = _target$getProps8.setPropValue) === null || _target$getProps8$set === void 0 ? void 0 : _target$getProps8$set.call(_target$getProps8, 'imgHeight', styleHeight);
268
+ }
269
+ return styleHeight;
270
+ }
271
+ 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');
272
+ var parsedPropValue = parsePxNumber(propValue);
273
+ if (parsedPropValue !== undefined) {
274
+ return parsedPropValue;
275
+ }
276
+ return (_getImageStyleNumber6 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber6 !== void 0 ? _getImageStyleNumber6 : 100;
277
+ },
278
+ setValue: function setValue(target, value) {
279
+ var parsedValue = parsePxNumber(value);
280
+ if (parsedValue === undefined) {
281
+ return;
282
+ }
283
+ target.getProps().setPropValue('imgHeight', parsedValue);
284
+ syncImageStyleValue(target, 'height', parsedValue);
285
+ }
128
286
  }
129
287
  }, {
130
288
  title: '数据源绑定',
@@ -153,7 +311,7 @@ var TeletextListMeta = {
153
311
  },
154
312
  extraProps: {
155
313
  setValue: function setValue(target, value) {
156
- console.log('dataList setValue', target, value);
314
+ target.getProps().setPropValue('dataListBind', value);
157
315
  }
158
316
  }
159
317
  }, {
@@ -197,16 +355,17 @@ var TeletextListMeta = {
197
355
  },
198
356
  extraProps: {
199
357
  setValue: function setValue(target, value) {
200
- var _target$node, _schema$children, _schema$children$filt, _target$parent$node;
358
+ var _target$node2, _schemaChildren$filte, _target$parent, _target$parent$items;
201
359
  target.getProps().setPropValue('textLines', value);
202
- var schema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
360
+ var schema = target === null || target === void 0 ? void 0 : (_target$node2 = target.node) === null || _target$node2 === void 0 ? void 0 : _target$node2.schema;
203
361
  var node = target === null || target === void 0 ? void 0 : target.node;
362
+ var schemaChildren = Array.isArray(schema === null || schema === void 0 ? void 0 : schema.children) ? schema.children : [];
204
363
 
205
364
  // 获取当前文本组件数量
206
- var currentLength = (schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : (_schema$children$filt = _schema$children.filter(function (child) {
207
- var _child$props$key;
208
- return child.componentName === 'NextText' && ((_child$props$key = child.props.key) === null || _child$props$key === void 0 ? void 0 : _child$props$key.startsWith('text-'));
209
- })) === null || _schema$children$filt === void 0 ? void 0 : _schema$children$filt.length) || 0;
365
+ var currentLength = ((_schemaChildren$filte = schemaChildren.filter(function (child) {
366
+ var _child$props2, _child$props2$key;
367
+ return child.componentName === 'NextText' && (child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : (_child$props2$key = _child$props2.key) === null || _child$props2$key === void 0 ? void 0 : _child$props2$key.startsWith('text-'));
368
+ })) === null || _schemaChildren$filte === void 0 ? void 0 : _schemaChildren$filte.length) || 0;
210
369
  if (value > currentLength) {
211
370
  // 需要添加新的文本组件
212
371
  for (var i = currentLength + 1; i <= value; i++) {
@@ -219,20 +378,27 @@ var TeletextListMeta = {
219
378
  key: "text-" + i
220
379
  }
221
380
  };
222
- console.log('node', node, 'node-children', node === null || node === void 0 ? void 0 : node.children);
223
381
  node === null || node === void 0 ? void 0 : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.push(newChild);
224
382
  }
225
383
  } else if (value < currentLength) {
226
- var _node$children2;
227
384
  // 需要移除多余的文本组件
228
- node === null || node === void 0 ? void 0 : (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.filter(function (child) {
229
- var _child$props, _child$props$key2, _child$props2;
230
- return !(child.componentName === 'NextText' && (_child$props = child.props) !== null && _child$props !== void 0 && (_child$props$key2 = _child$props.key) !== null && _child$props$key2 !== void 0 && _child$props$key2.startsWith('text-') && parseInt(child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.key.split('-')[1]) > value);
385
+ var filteredChildren = (Array.isArray(node === null || node === void 0 ? void 0 : node.children) ? node.children : []).filter(function (child) {
386
+ var _child$props3;
387
+ if (child.componentName !== 'NextText') {
388
+ return true;
389
+ }
390
+ var key = child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.key;
391
+ if (!(key !== null && key !== void 0 && key.startsWith('text-'))) {
392
+ return true;
393
+ }
394
+ var order = Number(key.split('-')[1]);
395
+ return Number.isNaN(order) || order <= value;
231
396
  });
397
+ node.children = filteredChildren;
232
398
  }
233
399
 
234
400
  // 更新数据源绑定的配置
235
- var dataListBindProp = target.parent.items.find(function (item) {
401
+ var dataListBindProp = target === null || target === void 0 ? void 0 : (_target$parent = target.parent) === null || _target$parent === void 0 ? void 0 : (_target$parent$items = _target$parent.items) === null || _target$parent$items === void 0 ? void 0 : _target$parent$items.find(function (item) {
236
402
  return item.name === 'dataListBind';
237
403
  });
238
404
  if (dataListBindProp && dataListBindProp.setter) {
@@ -263,7 +429,6 @@ var TeletextListMeta = {
263
429
  // 更新setter的attributes
264
430
  dataListBindProp.setter.props.attributes[0].children = [].concat(baseChildren, textChildren);
265
431
  }
266
- console.log('文字行数', target, value, schema, target.node, target.parent, target.parent.getPropValue('dataListBind'), (_target$parent$node = target.parent.node) === null || _target$parent$node === void 0 ? void 0 : _target$parent$node.getProp('dataListBind'));
267
432
  }
268
433
  }
269
434
  }, {
@@ -726,7 +891,5 @@ var getSnippets = function getSnippets(textLines) {
726
891
  }];
727
892
  };
728
893
  export default _extends({}, TeletextListMeta, {
729
- snippets: getSnippets(((_props = TeletextListMeta.configure.props) === null || _props === void 0 ? void 0 : (_props$find = _props.find(function (prop) {
730
- return prop.name === 'textLines';
731
- })) === null || _props$find === void 0 ? void 0 : (_props$find$setter = _props$find.setter) === null || _props$find$setter === void 0 ? void 0 : (_props$find$setter$ge = _props$find$setter.getValue) === null || _props$find$setter$ge === void 0 ? void 0 : _props$find$setter$ge.call(_props$find$setter)) || 2)
894
+ snippets: getSnippets(2)
732
895
  });
@@ -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.360';
125
+ version = '0.1.362';
126
126
  }
127
127
  if (basicLibraryVersion === void 0) {
128
128
  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;
@@ -3,8 +3,80 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
5
  exports["default"] = void 0;
6
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
- var _props, _props$find, _props$find$setter, _props$find$setter$ge;
6
+ var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
+ var IMAGE_KEY = 'image';
8
+ var normalizeNodeKey = function normalizeNodeKey(rawKey) {
9
+ if (rawKey === undefined || rawKey === null) return '';
10
+ return String(rawKey).replace(/^\.?\$?/, '');
11
+ };
12
+ var parsePxNumber = function parsePxNumber(value) {
13
+ if (typeof value === 'number' && Number.isFinite(value)) {
14
+ return value;
15
+ }
16
+ if (typeof value === 'string') {
17
+ var numberLike = Number(value.trim());
18
+ if (Number.isFinite(numberLike)) {
19
+ return numberLike;
20
+ }
21
+ var matched = value.match(/^\s*(\d+(?:\.\d+)?)\s*px\s*$/i);
22
+ if (!matched) return undefined;
23
+ var parsed = Number(matched[1]);
24
+ return Number.isFinite(parsed) ? parsed : undefined;
25
+ }
26
+ return undefined;
27
+ };
28
+ var getSchemaChildren = function getSchemaChildren(target) {
29
+ var _target$node;
30
+ var nodeSchema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
31
+ return Array.isArray(nodeSchema === null || nodeSchema === void 0 ? void 0 : nodeSchema.children) ? nodeSchema.children : [];
32
+ };
33
+ var findImageChildSchema = function findImageChildSchema(target) {
34
+ var schemaChildren = getSchemaChildren(target);
35
+ return schemaChildren.find(function (child) {
36
+ var _child$props;
37
+ var keyFromProps = normalizeNodeKey(child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.key);
38
+ var keyFromNode = normalizeNodeKey(child === null || child === void 0 ? void 0 : child.key);
39
+ return keyFromProps === IMAGE_KEY || keyFromNode === IMAGE_KEY;
40
+ });
41
+ };
42
+ var getImageStyleNumber = function getImageStyleNumber(target, styleKey) {
43
+ var _imageChildSchema$pro, _imageChildSchema$pro2;
44
+ var imageChildSchema = findImageChildSchema(target);
45
+ var childStyleValue = imageChildSchema === null || imageChildSchema === void 0 ? void 0 : (_imageChildSchema$pro = imageChildSchema.props) === null || _imageChildSchema$pro === void 0 ? void 0 : (_imageChildSchema$pro2 = _imageChildSchema$pro.style) === null || _imageChildSchema$pro2 === void 0 ? void 0 : _imageChildSchema$pro2[styleKey];
46
+ return parsePxNumber(childStyleValue);
47
+ };
48
+ var syncImageStyleValue = function syncImageStyleValue(target, styleKey, value) {
49
+ var _extends2;
50
+ var imageChildSchema = findImageChildSchema(target);
51
+ if (!imageChildSchema) {
52
+ return;
53
+ }
54
+ if (!imageChildSchema.props) {
55
+ imageChildSchema.props = {};
56
+ }
57
+ var currentStyle = imageChildSchema.props.style || {};
58
+ imageChildSchema.props.style = (0, _extends3["default"])({}, currentStyle, (_extends2 = {}, _extends2[styleKey] = value + "px", _extends2));
59
+ };
60
+ var syncImageDimensionPropsFromChild = function syncImageDimensionPropsFromChild(target) {
61
+ var _target$getProps;
62
+ var widthFromChild = getImageStyleNumber(target, 'width');
63
+ var heightFromChild = getImageStyleNumber(target, 'height');
64
+ var propsApi = target === null || target === void 0 ? void 0 : (_target$getProps = target.getProps) === null || _target$getProps === void 0 ? void 0 : _target$getProps.call(target);
65
+ if (propsApi && widthFromChild !== undefined) {
66
+ var _propsApi$getPropValu;
67
+ var currentWidth = parsePxNumber((_propsApi$getPropValu = propsApi.getPropValue) === null || _propsApi$getPropValu === void 0 ? void 0 : _propsApi$getPropValu.call(propsApi, 'imgWidth'));
68
+ if (currentWidth !== widthFromChild) {
69
+ propsApi.setPropValue('imgWidth', widthFromChild);
70
+ }
71
+ }
72
+ if (propsApi && heightFromChild !== undefined) {
73
+ var _propsApi$getPropValu2;
74
+ var currentHeight = parsePxNumber((_propsApi$getPropValu2 = propsApi.getPropValue) === null || _propsApi$getPropValu2 === void 0 ? void 0 : _propsApi$getPropValu2.call(propsApi, 'imgHeight'));
75
+ if (currentHeight !== heightFromChild) {
76
+ propsApi.setPropValue('imgHeight', heightFromChild);
77
+ }
78
+ }
79
+ };
8
80
  var TeletextListMeta = {
9
81
  group: '低代码组件',
10
82
  componentName: 'TeletextList',
@@ -109,6 +181,8 @@ var TeletextListMeta = {
109
181
  extraProps: {
110
182
  setValue: function setValue(target, value) {
111
183
  target.getProps().setPropValue('imagePlacement', value);
184
+ // 切换图片布局时同步一次子图片尺寸,避免面板回退到默认值
185
+ syncImageDimensionPropsFromChild(target);
112
186
  }
113
187
  }
114
188
  }, {
@@ -118,8 +192,50 @@ var TeletextListMeta = {
118
192
  setter: {
119
193
  componentName: 'NumberSetter',
120
194
  isRequired: false,
121
- initialValue: 100,
122
- defaultValue: 100
195
+ initialValue: function initialValue(target) {
196
+ var _target$getProps2, _target$getProps2$get, _getImageStyleNumber;
197
+ var styleWidth = getImageStyleNumber(target, 'width');
198
+ if (styleWidth !== undefined) {
199
+ return styleWidth;
200
+ }
201
+ var propValue = target === null || target === void 0 ? void 0 : (_target$getProps2 = target.getProps()) === null || _target$getProps2 === void 0 ? void 0 : (_target$getProps2$get = _target$getProps2.getPropValue) === null || _target$getProps2$get === void 0 ? void 0 : _target$getProps2$get.call(_target$getProps2, 'imgWidth');
202
+ var parsedPropValue = parsePxNumber(propValue);
203
+ if (parsedPropValue !== undefined) return parsedPropValue;
204
+ return (_getImageStyleNumber = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber !== void 0 ? _getImageStyleNumber : 100;
205
+ },
206
+ defaultValue: function defaultValue(target) {
207
+ var _getImageStyleNumber2;
208
+ return (_getImageStyleNumber2 = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber2 !== void 0 ? _getImageStyleNumber2 : 100;
209
+ }
210
+ },
211
+ extraProps: {
212
+ getValue: function getValue(target) {
213
+ var _target$getProps5, _target$getProps5$get, _getImageStyleNumber3;
214
+ var styleWidth = getImageStyleNumber(target, 'width');
215
+ if (styleWidth !== undefined) {
216
+ var _target$getProps3, _target$getProps3$get;
217
+ var currentWidth = parsePxNumber(target === null || target === void 0 ? void 0 : (_target$getProps3 = target.getProps()) === null || _target$getProps3 === void 0 ? void 0 : (_target$getProps3$get = _target$getProps3.getPropValue) === null || _target$getProps3$get === void 0 ? void 0 : _target$getProps3$get.call(_target$getProps3, 'imgWidth'));
218
+ if (currentWidth !== styleWidth) {
219
+ var _target$getProps4, _target$getProps4$set;
220
+ target === null || target === void 0 ? void 0 : (_target$getProps4 = target.getProps()) === null || _target$getProps4 === void 0 ? void 0 : (_target$getProps4$set = _target$getProps4.setPropValue) === null || _target$getProps4$set === void 0 ? void 0 : _target$getProps4$set.call(_target$getProps4, 'imgWidth', styleWidth);
221
+ }
222
+ return styleWidth;
223
+ }
224
+ 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');
225
+ var parsedPropValue = parsePxNumber(propValue);
226
+ if (parsedPropValue !== undefined) {
227
+ return parsedPropValue;
228
+ }
229
+ return (_getImageStyleNumber3 = getImageStyleNumber(target, 'width')) !== null && _getImageStyleNumber3 !== void 0 ? _getImageStyleNumber3 : 100;
230
+ },
231
+ setValue: function setValue(target, value) {
232
+ var parsedValue = parsePxNumber(value);
233
+ if (parsedValue === undefined) {
234
+ return;
235
+ }
236
+ target.getProps().setPropValue('imgWidth', parsedValue);
237
+ syncImageStyleValue(target, 'width', parsedValue);
238
+ }
123
239
  }
124
240
  }, {
125
241
  title: '图片高度',
@@ -128,8 +244,50 @@ var TeletextListMeta = {
128
244
  setter: {
129
245
  componentName: 'NumberSetter',
130
246
  isRequired: false,
131
- initialValue: 100,
132
- defaultValue: 100
247
+ initialValue: function initialValue(target) {
248
+ var _target$getProps6, _target$getProps6$get, _getImageStyleNumber4;
249
+ var styleHeight = getImageStyleNumber(target, 'height');
250
+ if (styleHeight !== undefined) {
251
+ return styleHeight;
252
+ }
253
+ 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, 'imgHeight');
254
+ var parsedPropValue = parsePxNumber(propValue);
255
+ if (parsedPropValue !== undefined) return parsedPropValue;
256
+ return (_getImageStyleNumber4 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber4 !== void 0 ? _getImageStyleNumber4 : 100;
257
+ },
258
+ defaultValue: function defaultValue(target) {
259
+ var _getImageStyleNumber5;
260
+ return (_getImageStyleNumber5 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber5 !== void 0 ? _getImageStyleNumber5 : 100;
261
+ }
262
+ },
263
+ extraProps: {
264
+ getValue: function getValue(target) {
265
+ var _target$getProps9, _target$getProps9$get, _getImageStyleNumber6;
266
+ var styleHeight = getImageStyleNumber(target, 'height');
267
+ if (styleHeight !== undefined) {
268
+ var _target$getProps7, _target$getProps7$get;
269
+ var currentHeight = parsePxNumber(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'));
270
+ if (currentHeight !== styleHeight) {
271
+ var _target$getProps8, _target$getProps8$set;
272
+ target === null || target === void 0 ? void 0 : (_target$getProps8 = target.getProps()) === null || _target$getProps8 === void 0 ? void 0 : (_target$getProps8$set = _target$getProps8.setPropValue) === null || _target$getProps8$set === void 0 ? void 0 : _target$getProps8$set.call(_target$getProps8, 'imgHeight', styleHeight);
273
+ }
274
+ return styleHeight;
275
+ }
276
+ 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');
277
+ var parsedPropValue = parsePxNumber(propValue);
278
+ if (parsedPropValue !== undefined) {
279
+ return parsedPropValue;
280
+ }
281
+ return (_getImageStyleNumber6 = getImageStyleNumber(target, 'height')) !== null && _getImageStyleNumber6 !== void 0 ? _getImageStyleNumber6 : 100;
282
+ },
283
+ setValue: function setValue(target, value) {
284
+ var parsedValue = parsePxNumber(value);
285
+ if (parsedValue === undefined) {
286
+ return;
287
+ }
288
+ target.getProps().setPropValue('imgHeight', parsedValue);
289
+ syncImageStyleValue(target, 'height', parsedValue);
290
+ }
133
291
  }
134
292
  }, {
135
293
  title: '数据源绑定',
@@ -158,7 +316,7 @@ var TeletextListMeta = {
158
316
  },
159
317
  extraProps: {
160
318
  setValue: function setValue(target, value) {
161
- console.log('dataList setValue', target, value);
319
+ target.getProps().setPropValue('dataListBind', value);
162
320
  }
163
321
  }
164
322
  }, {
@@ -202,16 +360,17 @@ var TeletextListMeta = {
202
360
  },
203
361
  extraProps: {
204
362
  setValue: function setValue(target, value) {
205
- var _target$node, _schema$children, _schema$children$filt, _target$parent$node;
363
+ var _target$node2, _schemaChildren$filte, _target$parent, _target$parent$items;
206
364
  target.getProps().setPropValue('textLines', value);
207
- var schema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
365
+ var schema = target === null || target === void 0 ? void 0 : (_target$node2 = target.node) === null || _target$node2 === void 0 ? void 0 : _target$node2.schema;
208
366
  var node = target === null || target === void 0 ? void 0 : target.node;
367
+ var schemaChildren = Array.isArray(schema === null || schema === void 0 ? void 0 : schema.children) ? schema.children : [];
209
368
 
210
369
  // 获取当前文本组件数量
211
- var currentLength = (schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : (_schema$children$filt = _schema$children.filter(function (child) {
212
- var _child$props$key;
213
- return child.componentName === 'NextText' && ((_child$props$key = child.props.key) === null || _child$props$key === void 0 ? void 0 : _child$props$key.startsWith('text-'));
214
- })) === null || _schema$children$filt === void 0 ? void 0 : _schema$children$filt.length) || 0;
370
+ var currentLength = ((_schemaChildren$filte = schemaChildren.filter(function (child) {
371
+ var _child$props2, _child$props2$key;
372
+ return child.componentName === 'NextText' && (child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : (_child$props2$key = _child$props2.key) === null || _child$props2$key === void 0 ? void 0 : _child$props2$key.startsWith('text-'));
373
+ })) === null || _schemaChildren$filte === void 0 ? void 0 : _schemaChildren$filte.length) || 0;
215
374
  if (value > currentLength) {
216
375
  // 需要添加新的文本组件
217
376
  for (var i = currentLength + 1; i <= value; i++) {
@@ -224,20 +383,27 @@ var TeletextListMeta = {
224
383
  key: "text-" + i
225
384
  }
226
385
  };
227
- console.log('node', node, 'node-children', node === null || node === void 0 ? void 0 : node.children);
228
386
  node === null || node === void 0 ? void 0 : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.push(newChild);
229
387
  }
230
388
  } else if (value < currentLength) {
231
- var _node$children2;
232
389
  // 需要移除多余的文本组件
233
- node === null || node === void 0 ? void 0 : (_node$children2 = node.children) === null || _node$children2 === void 0 ? void 0 : _node$children2.filter(function (child) {
234
- var _child$props, _child$props$key2, _child$props2;
235
- return !(child.componentName === 'NextText' && (_child$props = child.props) !== null && _child$props !== void 0 && (_child$props$key2 = _child$props.key) !== null && _child$props$key2 !== void 0 && _child$props$key2.startsWith('text-') && parseInt(child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.key.split('-')[1]) > value);
390
+ var filteredChildren = (Array.isArray(node === null || node === void 0 ? void 0 : node.children) ? node.children : []).filter(function (child) {
391
+ var _child$props3;
392
+ if (child.componentName !== 'NextText') {
393
+ return true;
394
+ }
395
+ var key = child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.key;
396
+ if (!(key !== null && key !== void 0 && key.startsWith('text-'))) {
397
+ return true;
398
+ }
399
+ var order = Number(key.split('-')[1]);
400
+ return Number.isNaN(order) || order <= value;
236
401
  });
402
+ node.children = filteredChildren;
237
403
  }
238
404
 
239
405
  // 更新数据源绑定的配置
240
- var dataListBindProp = target.parent.items.find(function (item) {
406
+ var dataListBindProp = target === null || target === void 0 ? void 0 : (_target$parent = target.parent) === null || _target$parent === void 0 ? void 0 : (_target$parent$items = _target$parent.items) === null || _target$parent$items === void 0 ? void 0 : _target$parent$items.find(function (item) {
241
407
  return item.name === 'dataListBind';
242
408
  });
243
409
  if (dataListBindProp && dataListBindProp.setter) {
@@ -268,7 +434,6 @@ var TeletextListMeta = {
268
434
  // 更新setter的attributes
269
435
  dataListBindProp.setter.props.attributes[0].children = [].concat(baseChildren, textChildren);
270
436
  }
271
- console.log('文字行数', target, value, schema, target.node, target.parent, target.parent.getPropValue('dataListBind'), (_target$parent$node = target.parent.node) === null || _target$parent$node === void 0 ? void 0 : _target$parent$node.getProp('dataListBind'));
272
437
  }
273
438
  }
274
439
  }, {
@@ -730,8 +895,6 @@ var getSnippets = function getSnippets(textLines) {
730
895
  }
731
896
  }];
732
897
  };
733
- var _default = exports["default"] = (0, _extends2["default"])({}, TeletextListMeta, {
734
- snippets: getSnippets(((_props = TeletextListMeta.configure.props) === null || _props === void 0 ? void 0 : (_props$find = _props.find(function (prop) {
735
- return prop.name === 'textLines';
736
- })) === null || _props$find === void 0 ? void 0 : (_props$find$setter = _props$find.setter) === null || _props$find$setter === void 0 ? void 0 : (_props$find$setter$ge = _props$find$setter.getValue) === null || _props$find$setter$ge === void 0 ? void 0 : _props$find$setter$ge.call(_props$find$setter)) || 2)
898
+ var _default = exports["default"] = (0, _extends3["default"])({}, TeletextListMeta, {
899
+ snippets: getSnippets(2)
737
900
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dckj-npm/dc-material",
3
- "version": "0.1.360",
3
+ "version": "0.1.362",
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.360/build/lowcode/assets-prod.json"
117
+ "materialSchema": "https://unpkg.com/@dckj-npm/dc-material@0.1.362/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.360/build/index.html"
122
+ "homepage": "https://unpkg.com/@dckj-npm/dc-material@0.1.362/build/index.html"
123
123
  }