@dckj-npm/dc-material 0.1.217 → 0.1.219

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.
@@ -314,7 +314,18 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
314
314
  extraProps: {
315
315
  setValue(target, value) {
316
316
  target.getProps().setPropValue('textLines', value)
317
+ const map = {}
318
+
319
+ if (!Array.isArray(value)) {
320
+ value = []
321
+ }
322
+ value.forEach((item) => {
323
+ const tabItem = Object.assign({}, item)
324
+ map[item.key] = tabItem
325
+ })
326
+
317
327
  // 获取组件schema
328
+ const node = target?.node
318
329
  const schema = target?.node?.schema
319
330
  const currentLength =
320
331
  schema?.children?.filter(
@@ -325,18 +336,48 @@ const TeletextListMeta: IPublicTypeComponentMetadata = {
325
336
  if (value > currentLength) {
326
337
  // 需要添加新的文本组件
327
338
  for (let i = currentLength + 1; i <= value; i++) {
328
- schema?.children?.push({
339
+ const newChild = {
329
340
  componentName: 'NextText',
330
341
  props: {
331
342
  type: 'inherit',
332
343
  children: '基于 Ali-Lowcode-Engine 快速打造高生产力的低代码研发平台',
333
344
  key: `text-${i}`,
334
345
  },
335
- })
346
+ }
347
+ // 使用 node.children.push 添加子节点
348
+ // node.children.push(newChild)
349
+ node?.children?.mergeChildren(
350
+ (child) => {
351
+ const primaryKey = String(child.getPropValue('key'))
352
+ return Object.hasOwnProperty.call(map, primaryKey)
353
+ },
354
+ () => {
355
+ const items = []
356
+ for (const key in map) {
357
+ if (Object.hasOwnProperty.call(map, key)) {
358
+ items.push({
359
+ componentName: 'NextText',
360
+ props: map[key],
361
+ })
362
+ }
363
+ }
364
+ items.push(newChild)
365
+ return items
366
+ },
367
+ (child1, child2) => {
368
+ const a = children.findIndex(
369
+ (item) => String(item.props.key) === String(child1.getPropValue('key')),
370
+ )
371
+ const b = children.findIndex(
372
+ (item) => String(item.props.key) === String(child2.getPropValue('key')),
373
+ )
374
+ return a - b
375
+ },
376
+ )
336
377
  }
337
378
  } else if (value < currentLength) {
338
379
  // 需要移除多余的文本组件
339
- schema.children = schema.children.filter(
380
+ node.children = node.children.filter(
340
381
  (child) =>
341
382
  !(
342
383
  child.componentName === 'NextText' &&
@@ -99,7 +99,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
99
99
  packageName = '@dckj-npm/dc-material';
100
100
  }
101
101
  if (version === void 0) {
102
- version = '0.1.217';
102
+ version = '0.1.219';
103
103
  }
104
104
  if (basicLibraryVersion === void 0) {
105
105
  basicLibraryVersion = {
@@ -272,28 +272,67 @@ var TeletextListMeta = {
272
272
  setValue: function setValue(target, value) {
273
273
  var _target$node, _schema$children, _schema$children$filt, _target$parent$node;
274
274
  target.getProps().setPropValue('textLines', value);
275
+ var map = {};
276
+ if (!Array.isArray(value)) {
277
+ value = [];
278
+ }
279
+ value.forEach(function (item) {
280
+ var tabItem = Object.assign({}, item);
281
+ map[item.key] = tabItem;
282
+ });
283
+
275
284
  // 获取组件schema
285
+ var node = target === null || target === void 0 ? void 0 : target.node;
276
286
  var schema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
277
287
  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) {
278
288
  var _child$props$key;
279
289
  return child.componentName === 'NextText' && ((_child$props$key = child.props.key) === null || _child$props$key === void 0 ? void 0 : _child$props$key.startsWith('text-'));
280
290
  })) === null || _schema$children$filt === void 0 ? void 0 : _schema$children$filt.length) || 0;
281
291
  if (value > currentLength) {
282
- // 需要添加新的文本组件
283
- for (var i = currentLength + 1; i <= value; i++) {
284
- var _schema$children2;
285
- schema === null || schema === void 0 ? void 0 : (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.push({
292
+ var _loop = function _loop() {
293
+ var _node$children;
294
+ var newChild = {
286
295
  componentName: 'NextText',
287
296
  props: {
288
297
  type: 'inherit',
289
298
  children: '基于 Ali-Lowcode-Engine 快速打造高生产力的低代码研发平台',
290
299
  key: "text-" + i
291
300
  }
301
+ };
302
+ // 使用 node.children.push 添加子节点
303
+ // node.children.push(newChild)
304
+ node === null || node === void 0 ? void 0 : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.mergeChildren(function (child) {
305
+ var primaryKey = String(child.getPropValue('key'));
306
+ return Object.hasOwnProperty.call(map, primaryKey);
307
+ }, function () {
308
+ var items = [];
309
+ for (var key in map) {
310
+ if (Object.hasOwnProperty.call(map, key)) {
311
+ items.push({
312
+ componentName: 'NextText',
313
+ props: map[key]
314
+ });
315
+ }
316
+ }
317
+ items.push(newChild);
318
+ return items;
319
+ }, function (child1, child2) {
320
+ var a = children.findIndex(function (item) {
321
+ return String(item.props.key) === String(child1.getPropValue('key'));
322
+ });
323
+ var b = children.findIndex(function (item) {
324
+ return String(item.props.key) === String(child2.getPropValue('key'));
325
+ });
326
+ return a - b;
292
327
  });
328
+ };
329
+ // 需要添加新的文本组件
330
+ for (var i = currentLength + 1; i <= value; i++) {
331
+ _loop();
293
332
  }
294
333
  } else if (value < currentLength) {
295
334
  // 需要移除多余的文本组件
296
- schema.children = schema.children.filter(function (child) {
335
+ node.children = node.children.filter(function (child) {
297
336
  var _child$props$key2;
298
337
  return !(child.componentName === 'NextText' && (_child$props$key2 = child.props.key) !== null && _child$props$key2 !== void 0 && _child$props$key2.startsWith('text-') && parseInt(child.props.key.split('-')[1]) > value);
299
338
  });
@@ -104,7 +104,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
104
104
  packageName = '@dckj-npm/dc-material';
105
105
  }
106
106
  if (version === void 0) {
107
- version = '0.1.217';
107
+ version = '0.1.219';
108
108
  }
109
109
  if (basicLibraryVersion === void 0) {
110
110
  basicLibraryVersion = {
@@ -277,28 +277,67 @@ var TeletextListMeta = {
277
277
  setValue: function setValue(target, value) {
278
278
  var _target$node, _schema$children, _schema$children$filt, _target$parent$node;
279
279
  target.getProps().setPropValue('textLines', value);
280
+ var map = {};
281
+ if (!Array.isArray(value)) {
282
+ value = [];
283
+ }
284
+ value.forEach(function (item) {
285
+ var tabItem = Object.assign({}, item);
286
+ map[item.key] = tabItem;
287
+ });
288
+
280
289
  // 获取组件schema
290
+ var node = target === null || target === void 0 ? void 0 : target.node;
281
291
  var schema = target === null || target === void 0 ? void 0 : (_target$node = target.node) === null || _target$node === void 0 ? void 0 : _target$node.schema;
282
292
  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) {
283
293
  var _child$props$key;
284
294
  return child.componentName === 'NextText' && ((_child$props$key = child.props.key) === null || _child$props$key === void 0 ? void 0 : _child$props$key.startsWith('text-'));
285
295
  })) === null || _schema$children$filt === void 0 ? void 0 : _schema$children$filt.length) || 0;
286
296
  if (value > currentLength) {
287
- // 需要添加新的文本组件
288
- for (var i = currentLength + 1; i <= value; i++) {
289
- var _schema$children2;
290
- schema === null || schema === void 0 ? void 0 : (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.push({
297
+ var _loop = function _loop() {
298
+ var _node$children;
299
+ var newChild = {
291
300
  componentName: 'NextText',
292
301
  props: {
293
302
  type: 'inherit',
294
303
  children: '基于 Ali-Lowcode-Engine 快速打造高生产力的低代码研发平台',
295
304
  key: "text-" + i
296
305
  }
306
+ };
307
+ // 使用 node.children.push 添加子节点
308
+ // node.children.push(newChild)
309
+ node === null || node === void 0 ? void 0 : (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.mergeChildren(function (child) {
310
+ var primaryKey = String(child.getPropValue('key'));
311
+ return Object.hasOwnProperty.call(map, primaryKey);
312
+ }, function () {
313
+ var items = [];
314
+ for (var key in map) {
315
+ if (Object.hasOwnProperty.call(map, key)) {
316
+ items.push({
317
+ componentName: 'NextText',
318
+ props: map[key]
319
+ });
320
+ }
321
+ }
322
+ items.push(newChild);
323
+ return items;
324
+ }, function (child1, child2) {
325
+ var a = children.findIndex(function (item) {
326
+ return String(item.props.key) === String(child1.getPropValue('key'));
327
+ });
328
+ var b = children.findIndex(function (item) {
329
+ return String(item.props.key) === String(child2.getPropValue('key'));
330
+ });
331
+ return a - b;
297
332
  });
333
+ };
334
+ // 需要添加新的文本组件
335
+ for (var i = currentLength + 1; i <= value; i++) {
336
+ _loop();
298
337
  }
299
338
  } else if (value < currentLength) {
300
339
  // 需要移除多余的文本组件
301
- schema.children = schema.children.filter(function (child) {
340
+ node.children = node.children.filter(function (child) {
302
341
  var _child$props$key2;
303
342
  return !(child.componentName === 'NextText' && (_child$props$key2 = child.props.key) !== null && _child$props$key2 !== void 0 && _child$props$key2.startsWith('text-') && parseInt(child.props.key.split('-')[1]) > value);
304
343
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dckj-npm/dc-material",
3
- "version": "0.1.217",
3
+ "version": "0.1.219",
4
4
  "description": "dc低代码物料",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -106,7 +106,7 @@
106
106
  },
107
107
  "componentConfig": {
108
108
  "isComponentLibrary": true,
109
- "materialSchema": "https://unpkg.com/@dckj-npm/dc-material@0.1.217/build/lowcode/assets-prod.json"
109
+ "materialSchema": "https://unpkg.com/@dckj-npm/dc-material@0.1.219/build/lowcode/assets-prod.json"
110
110
  },
111
111
  "lcMeta": {
112
112
  "type": "component"