@inditextech/weave-sdk 0.40.1 → 0.40.2

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/dist/sdk.cjs CHANGED
@@ -17482,9 +17482,13 @@ var WeaveStateSerializer = class {
17482
17482
  });
17483
17483
  const { key, type, props } = element;
17484
17484
  if (typeof type !== "string") throw new Error(`Deserialization error: element type must be string received [${type}]`);
17485
- const { children,...restProps } = props;
17485
+ let restProps = {};
17486
17486
  let childrenNodes = [];
17487
- if (children) childrenNodes = this.deserializeElement(children);
17487
+ if (props.children) {
17488
+ const { children,...actRestProps } = props;
17489
+ restProps = actRestProps;
17490
+ if (children) childrenNodes = this.deserializeElement(children);
17491
+ } else restProps = props;
17488
17492
  return react.default.createElement(type.toLowerCase(), {
17489
17493
  ...restProps,
17490
17494
  key
@@ -18305,13 +18309,17 @@ var WeaveZIndexManager = class {
18305
18309
  this.logger = this.instance.getChildLogger("zindex-manager");
18306
18310
  this.logger.debug("zIndex manager created");
18307
18311
  }
18312
+ getSelectionPlugin() {
18313
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
18314
+ return selectionPlugin;
18315
+ }
18308
18316
  moveUp(instance) {
18309
18317
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], up one step of z-index`);
18310
18318
  instance.moveUp();
18311
18319
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
18312
18320
  if (handler) {
18313
- const node = handler.serialize(instance);
18314
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.UP);
18321
+ const nodeState = handler.serialize(instance);
18322
+ this.instance.moveNode(nodeState, __inditextech_weave_types.WEAVE_NODE_POSITION.UP);
18315
18323
  }
18316
18324
  }
18317
18325
  moveDown(instance) {
@@ -18319,8 +18327,8 @@ var WeaveZIndexManager = class {
18319
18327
  instance.moveDown();
18320
18328
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
18321
18329
  if (handler) {
18322
- const node = handler.serialize(instance);
18323
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN);
18330
+ const nodeState = handler.serialize(instance);
18331
+ this.instance.moveNode(nodeState, __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN);
18324
18332
  }
18325
18333
  }
18326
18334
  sendToBack(instances) {
@@ -18331,7 +18339,6 @@ var WeaveZIndexManager = class {
18331
18339
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
18332
18340
  if (handler) {
18333
18341
  const nodeState = handler.serialize(node);
18334
- this.instance.updateNode(nodeState);
18335
18342
  this.instance.moveNode(nodeState, __inditextech_weave_types.WEAVE_NODE_POSITION.BACK);
18336
18343
  }
18337
18344
  }
@@ -18344,7 +18351,6 @@ var WeaveZIndexManager = class {
18344
18351
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
18345
18352
  if (handler) {
18346
18353
  const nodeState = handler.serialize(node);
18347
- this.instance.updateNode(nodeState);
18348
18354
  this.instance.moveNode(nodeState, __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT);
18349
18355
  }
18350
18356
  }
@@ -18448,35 +18454,26 @@ var WeaveStateManager = class {
18448
18454
  return;
18449
18455
  }
18450
18456
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before init");
18451
- let parentChildren = [];
18452
- if (parent.props.children) parentChildren = JSON.parse(JSON.stringify(parent.props.children));
18457
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18453
18458
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before add");
18454
- if (index && parentChildren) {
18455
- parentChildren.splice(index, 0, node);
18456
- parentChildren = parentChildren.map((actNode, index$1) => {
18457
- return {
18458
- ...actNode,
18459
- props: {
18460
- ...actNode.props,
18461
- zIndex: index$1
18462
- }
18463
- };
18464
- });
18465
- }
18466
- if (!index && parent.props.children) {
18467
- const childrenAmount = parent.props.children.length;
18468
- let finalNode = JSON.parse(JSON.stringify(node));
18469
- finalNode = {
18470
- ...finalNode,
18459
+ if (index) {
18460
+ newChildren?.splice(index, 0, node);
18461
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18462
+ }
18463
+ if (!index) {
18464
+ const childrenAmount = newChildren.length;
18465
+ node.props.zIndex = childrenAmount;
18466
+ const nodeToAdd = {
18467
+ ...node,
18471
18468
  props: {
18472
- ...finalNode.props,
18469
+ ...node.props,
18473
18470
  zIndex: childrenAmount
18474
18471
  }
18475
18472
  };
18476
- this.logger.info({ node: JSON.parse(JSON.stringify(finalNode)) }, "addNode: node to add");
18477
- parentChildren.push(finalNode);
18473
+ this.logger.info({ node: JSON.parse(JSON.stringify(nodeToAdd)) }, "addNode: node to add");
18474
+ newChildren.push(nodeToAdd);
18478
18475
  }
18479
- parent.props.children = parentChildren;
18476
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18480
18477
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent after add");
18481
18478
  this.instance.emitEvent("onNodeAdded", node);
18482
18479
  }
@@ -18495,11 +18492,12 @@ var WeaveStateManager = class {
18495
18492
  return;
18496
18493
  }
18497
18494
  this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: before update");
18498
- const nodeNew = JSON.parse(JSON.stringify({
18499
- ...nodeState.props,
18495
+ const newNode = JSON.parse(JSON.stringify(nodeState));
18496
+ newNode.props = {
18497
+ ...newNode.props,
18500
18498
  ...node.props
18501
- }));
18502
- nodeState.props = { ...nodeNew };
18499
+ };
18500
+ if (typeof newNode.props !== "undefined") nodeState.props = newNode.props;
18503
18501
  this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: after update");
18504
18502
  this.instance.emitEvent("onNodeUpdated", node);
18505
18503
  }
@@ -18511,20 +18509,27 @@ var WeaveStateManager = class {
18511
18509
  this.logger.warn({ node }, msg);
18512
18510
  return;
18513
18511
  }
18514
- const { node: nodeState, parent: parentState } = this.findNodeById(state.weave, node.key);
18512
+ const { node: nodeState, parent } = this.findNodeById(state.weave, node.key);
18515
18513
  if (!nodeState) {
18516
18514
  const msg = `Node with key [${node.key}] doesn't exists, cannot remove it`;
18517
18515
  this.logger.warn({ node }, msg);
18518
18516
  return;
18519
18517
  }
18520
- this.logger.info({ key: node.key }, "removeNode: node to remove");
18521
- this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent before remove");
18522
- if (parentState && parentState.props.children) {
18523
- const newChildren = JSON.parse(JSON.stringify(parentState.props.children));
18524
- const filteredChildren = newChildren.filter((actNode) => actNode.key !== node.key);
18525
- parentState.props.children = filteredChildren;
18526
- this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent after remove");
18518
+ if (!parent) {
18519
+ const msg = `Parent doesn't exists, cannot remove it`;
18520
+ this.logger.warn({ node }, msg);
18521
+ return;
18527
18522
  }
18523
+ this.logger.info({ key: node.key }, "removeNode: node to remove");
18524
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "removeNode: parent before remove");
18525
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18526
+ for (let i = newChildren.length - 1; i >= 0; i--) if (newChildren[i].key === node.key) {
18527
+ newChildren.splice(i, 1);
18528
+ break;
18529
+ }
18530
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18531
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18532
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "removeNode: parent after remove");
18528
18533
  this.instance.emitEvent("onNodeRemoved", node);
18529
18534
  }
18530
18535
  removeNodes(nodes) {
@@ -18532,39 +18537,32 @@ var WeaveStateManager = class {
18532
18537
  }
18533
18538
  moveNode(node, position) {
18534
18539
  const state = this.instance.getStore().getState();
18540
+ this.logger.info({ stage: JSON.parse(JSON.stringify(state)) }, "State before moveNode");
18535
18541
  if ((0, import_lodash.isEmpty)(state.weave)) {
18536
18542
  const msg = `State is empty, cannot update the node`;
18537
18543
  this.logger.warn({ node }, msg);
18538
18544
  return;
18539
18545
  }
18540
- const { node: nodeState, parent: nodeParent } = this.findNodeById(state.weave, node.key);
18546
+ const { node: nodeState, parent } = this.findNodeById(state.weave, node.key);
18541
18547
  if (!nodeState) {
18542
18548
  const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
18543
18549
  this.logger.warn({ node }, msg);
18544
18550
  return;
18545
18551
  }
18546
- if (nodeParent && nodeParent.props.children) {
18547
- let nodeParentNewChildren = JSON.parse(JSON.stringify([...nodeParent.props.children ?? []]));
18548
- const nodeNew = JSON.parse(JSON.stringify({ ...node }));
18549
- const childrenAmount = nodeParentNewChildren.length;
18550
- const nodeIndex = nodeParentNewChildren.findIndex((n) => n.key === nodeNew.key);
18551
- nodeParentNewChildren.splice(nodeIndex, 1);
18552
- if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.UP) nodeParentNewChildren.splice(nodeIndex + 1, 0, nodeNew);
18553
- if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN) nodeParentNewChildren.splice(nodeIndex - 1, 0, nodeNew);
18554
- if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT) nodeParentNewChildren.splice(childrenAmount - 1, 0, nodeNew);
18555
- if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.BACK) nodeParentNewChildren.splice(0, 0, nodeNew);
18556
- nodeParentNewChildren = nodeParentNewChildren.map((actNode, index) => {
18557
- return {
18558
- ...actNode,
18559
- props: {
18560
- ...actNode.props,
18561
- zIndex: index
18562
- }
18563
- };
18564
- });
18565
- if (!nodeParent.props.children) nodeParent.props.children = [];
18566
- nodeParent.props.children = nodeParentNewChildren;
18567
- }
18552
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "moveNode: parent before move");
18553
+ if (parent && parent.props.children) {
18554
+ const childrenAmount = parent.props.children.length;
18555
+ const nodeIndex = parent.props.children.findIndex((child) => child.key === node.key);
18556
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18557
+ newChildren.splice(nodeIndex, 1);
18558
+ if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.UP) newChildren.splice(nodeIndex + 1, 0, { ...node });
18559
+ if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN) newChildren.splice(nodeIndex - 1, 0, { ...node });
18560
+ if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT) newChildren.splice(childrenAmount - 1, 0, { ...node });
18561
+ if (position === __inditextech_weave_types.WEAVE_NODE_POSITION.BACK) newChildren.splice(0, 0, { ...node });
18562
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18563
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18564
+ }
18565
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "moveNode: parent after move");
18568
18566
  }
18569
18567
  getElementsTree() {
18570
18568
  const state = this.instance.getStore().getState().weave;
@@ -18649,7 +18647,7 @@ var WeaveRegisterManager = class {
18649
18647
 
18650
18648
  //#endregion
18651
18649
  //#region package.json
18652
- var version = "0.40.1";
18650
+ var version = "0.40.2";
18653
18651
 
18654
18652
  //#endregion
18655
18653
  //#region src/managers/setup.ts
package/dist/sdk.js CHANGED
@@ -17482,9 +17482,13 @@ var WeaveStateSerializer = class {
17482
17482
  });
17483
17483
  const { key, type, props } = element;
17484
17484
  if (typeof type !== "string") throw new Error(`Deserialization error: element type must be string received [${type}]`);
17485
- const { children,...restProps } = props;
17485
+ let restProps = {};
17486
17486
  let childrenNodes = [];
17487
- if (children) childrenNodes = this.deserializeElement(children);
17487
+ if (props.children) {
17488
+ const { children,...actRestProps } = props;
17489
+ restProps = actRestProps;
17490
+ if (children) childrenNodes = this.deserializeElement(children);
17491
+ } else restProps = props;
17488
17492
  return React.createElement(type.toLowerCase(), {
17489
17493
  ...restProps,
17490
17494
  key
@@ -18305,13 +18309,17 @@ var WeaveZIndexManager = class {
18305
18309
  this.logger = this.instance.getChildLogger("zindex-manager");
18306
18310
  this.logger.debug("zIndex manager created");
18307
18311
  }
18312
+ getSelectionPlugin() {
18313
+ const selectionPlugin = this.instance.getPlugin("nodesSelection");
18314
+ return selectionPlugin;
18315
+ }
18308
18316
  moveUp(instance) {
18309
18317
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], up one step of z-index`);
18310
18318
  instance.moveUp();
18311
18319
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
18312
18320
  if (handler) {
18313
- const node = handler.serialize(instance);
18314
- this.instance.moveNode(node, WEAVE_NODE_POSITION.UP);
18321
+ const nodeState = handler.serialize(instance);
18322
+ this.instance.moveNode(nodeState, WEAVE_NODE_POSITION.UP);
18315
18323
  }
18316
18324
  }
18317
18325
  moveDown(instance) {
@@ -18319,8 +18327,8 @@ var WeaveZIndexManager = class {
18319
18327
  instance.moveDown();
18320
18328
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
18321
18329
  if (handler) {
18322
- const node = handler.serialize(instance);
18323
- this.instance.moveNode(node, WEAVE_NODE_POSITION.DOWN);
18330
+ const nodeState = handler.serialize(instance);
18331
+ this.instance.moveNode(nodeState, WEAVE_NODE_POSITION.DOWN);
18324
18332
  }
18325
18333
  }
18326
18334
  sendToBack(instances) {
@@ -18331,7 +18339,6 @@ var WeaveZIndexManager = class {
18331
18339
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
18332
18340
  if (handler) {
18333
18341
  const nodeState = handler.serialize(node);
18334
- this.instance.updateNode(nodeState);
18335
18342
  this.instance.moveNode(nodeState, WEAVE_NODE_POSITION.BACK);
18336
18343
  }
18337
18344
  }
@@ -18344,7 +18351,6 @@ var WeaveZIndexManager = class {
18344
18351
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
18345
18352
  if (handler) {
18346
18353
  const nodeState = handler.serialize(node);
18347
- this.instance.updateNode(nodeState);
18348
18354
  this.instance.moveNode(nodeState, WEAVE_NODE_POSITION.FRONT);
18349
18355
  }
18350
18356
  }
@@ -18448,35 +18454,26 @@ var WeaveStateManager = class {
18448
18454
  return;
18449
18455
  }
18450
18456
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before init");
18451
- let parentChildren = [];
18452
- if (parent.props.children) parentChildren = JSON.parse(JSON.stringify(parent.props.children));
18457
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18453
18458
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent before add");
18454
- if (index && parentChildren) {
18455
- parentChildren.splice(index, 0, node);
18456
- parentChildren = parentChildren.map((actNode, index$1) => {
18457
- return {
18458
- ...actNode,
18459
- props: {
18460
- ...actNode.props,
18461
- zIndex: index$1
18462
- }
18463
- };
18464
- });
18465
- }
18466
- if (!index && parent.props.children) {
18467
- const childrenAmount = parent.props.children.length;
18468
- let finalNode = JSON.parse(JSON.stringify(node));
18469
- finalNode = {
18470
- ...finalNode,
18459
+ if (index) {
18460
+ newChildren?.splice(index, 0, node);
18461
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18462
+ }
18463
+ if (!index) {
18464
+ const childrenAmount = newChildren.length;
18465
+ node.props.zIndex = childrenAmount;
18466
+ const nodeToAdd = {
18467
+ ...node,
18471
18468
  props: {
18472
- ...finalNode.props,
18469
+ ...node.props,
18473
18470
  zIndex: childrenAmount
18474
18471
  }
18475
18472
  };
18476
- this.logger.info({ node: JSON.parse(JSON.stringify(finalNode)) }, "addNode: node to add");
18477
- parentChildren.push(finalNode);
18473
+ this.logger.info({ node: JSON.parse(JSON.stringify(nodeToAdd)) }, "addNode: node to add");
18474
+ newChildren.push(nodeToAdd);
18478
18475
  }
18479
- parent.props.children = parentChildren;
18476
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18480
18477
  this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "addNode: parent after add");
18481
18478
  this.instance.emitEvent("onNodeAdded", node);
18482
18479
  }
@@ -18495,11 +18492,12 @@ var WeaveStateManager = class {
18495
18492
  return;
18496
18493
  }
18497
18494
  this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: before update");
18498
- const nodeNew = JSON.parse(JSON.stringify({
18499
- ...nodeState.props,
18495
+ const newNode = JSON.parse(JSON.stringify(nodeState));
18496
+ newNode.props = {
18497
+ ...newNode.props,
18500
18498
  ...node.props
18501
- }));
18502
- nodeState.props = { ...nodeNew };
18499
+ };
18500
+ if (typeof newNode.props !== "undefined") nodeState.props = newNode.props;
18503
18501
  this.logger.info({ node: JSON.parse(JSON.stringify(nodeState)) }, "updateNode: after update");
18504
18502
  this.instance.emitEvent("onNodeUpdated", node);
18505
18503
  }
@@ -18511,20 +18509,27 @@ var WeaveStateManager = class {
18511
18509
  this.logger.warn({ node }, msg);
18512
18510
  return;
18513
18511
  }
18514
- const { node: nodeState, parent: parentState } = this.findNodeById(state.weave, node.key);
18512
+ const { node: nodeState, parent } = this.findNodeById(state.weave, node.key);
18515
18513
  if (!nodeState) {
18516
18514
  const msg = `Node with key [${node.key}] doesn't exists, cannot remove it`;
18517
18515
  this.logger.warn({ node }, msg);
18518
18516
  return;
18519
18517
  }
18520
- this.logger.info({ key: node.key }, "removeNode: node to remove");
18521
- this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent before remove");
18522
- if (parentState && parentState.props.children) {
18523
- const newChildren = JSON.parse(JSON.stringify(parentState.props.children));
18524
- const filteredChildren = newChildren.filter((actNode) => actNode.key !== node.key);
18525
- parentState.props.children = filteredChildren;
18526
- this.logger.info({ parent: JSON.parse(JSON.stringify(parentState)) }, "removeNode: parent after remove");
18518
+ if (!parent) {
18519
+ const msg = `Parent doesn't exists, cannot remove it`;
18520
+ this.logger.warn({ node }, msg);
18521
+ return;
18527
18522
  }
18523
+ this.logger.info({ key: node.key }, "removeNode: node to remove");
18524
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "removeNode: parent before remove");
18525
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18526
+ for (let i = newChildren.length - 1; i >= 0; i--) if (newChildren[i].key === node.key) {
18527
+ newChildren.splice(i, 1);
18528
+ break;
18529
+ }
18530
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18531
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18532
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "removeNode: parent after remove");
18528
18533
  this.instance.emitEvent("onNodeRemoved", node);
18529
18534
  }
18530
18535
  removeNodes(nodes) {
@@ -18532,39 +18537,32 @@ var WeaveStateManager = class {
18532
18537
  }
18533
18538
  moveNode(node, position) {
18534
18539
  const state = this.instance.getStore().getState();
18540
+ this.logger.info({ stage: JSON.parse(JSON.stringify(state)) }, "State before moveNode");
18535
18541
  if ((0, import_lodash.isEmpty)(state.weave)) {
18536
18542
  const msg = `State is empty, cannot update the node`;
18537
18543
  this.logger.warn({ node }, msg);
18538
18544
  return;
18539
18545
  }
18540
- const { node: nodeState, parent: nodeParent } = this.findNodeById(state.weave, node.key);
18546
+ const { node: nodeState, parent } = this.findNodeById(state.weave, node.key);
18541
18547
  if (!nodeState) {
18542
18548
  const msg = `Node with key [${node.key}] doesn't exists, cannot update it`;
18543
18549
  this.logger.warn({ node }, msg);
18544
18550
  return;
18545
18551
  }
18546
- if (nodeParent && nodeParent.props.children) {
18547
- let nodeParentNewChildren = JSON.parse(JSON.stringify([...nodeParent.props.children ?? []]));
18548
- const nodeNew = JSON.parse(JSON.stringify({ ...node }));
18549
- const childrenAmount = nodeParentNewChildren.length;
18550
- const nodeIndex = nodeParentNewChildren.findIndex((n) => n.key === nodeNew.key);
18551
- nodeParentNewChildren.splice(nodeIndex, 1);
18552
- if (position === WEAVE_NODE_POSITION.UP) nodeParentNewChildren.splice(nodeIndex + 1, 0, nodeNew);
18553
- if (position === WEAVE_NODE_POSITION.DOWN) nodeParentNewChildren.splice(nodeIndex - 1, 0, nodeNew);
18554
- if (position === WEAVE_NODE_POSITION.FRONT) nodeParentNewChildren.splice(childrenAmount - 1, 0, nodeNew);
18555
- if (position === WEAVE_NODE_POSITION.BACK) nodeParentNewChildren.splice(0, 0, nodeNew);
18556
- nodeParentNewChildren = nodeParentNewChildren.map((actNode, index) => {
18557
- return {
18558
- ...actNode,
18559
- props: {
18560
- ...actNode.props,
18561
- zIndex: index
18562
- }
18563
- };
18564
- });
18565
- if (!nodeParent.props.children) nodeParent.props.children = [];
18566
- nodeParent.props.children = nodeParentNewChildren;
18567
- }
18552
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "moveNode: parent before move");
18553
+ if (parent && parent.props.children) {
18554
+ const childrenAmount = parent.props.children.length;
18555
+ const nodeIndex = parent.props.children.findIndex((child) => child.key === node.key);
18556
+ const newChildren = JSON.parse(JSON.stringify(parent.props.children ?? []));
18557
+ newChildren.splice(nodeIndex, 1);
18558
+ if (position === WEAVE_NODE_POSITION.UP) newChildren.splice(nodeIndex + 1, 0, { ...node });
18559
+ if (position === WEAVE_NODE_POSITION.DOWN) newChildren.splice(nodeIndex - 1, 0, { ...node });
18560
+ if (position === WEAVE_NODE_POSITION.FRONT) newChildren.splice(childrenAmount - 1, 0, { ...node });
18561
+ if (position === WEAVE_NODE_POSITION.BACK) newChildren.splice(0, 0, { ...node });
18562
+ for (let i = 0; i < newChildren.length; i++) newChildren[i].props.zIndex = i;
18563
+ if (typeof newChildren !== "undefined") parent.props.children = newChildren;
18564
+ }
18565
+ this.logger.info({ parent: JSON.parse(JSON.stringify(parent)) }, "moveNode: parent after move");
18568
18566
  }
18569
18567
  getElementsTree() {
18570
18568
  const state = this.instance.getStore().getState().weave;
@@ -18649,7 +18647,7 @@ var WeaveRegisterManager = class {
18649
18647
 
18650
18648
  //#endregion
18651
18649
  //#region package.json
18652
- var version = "0.40.1";
18650
+ var version = "0.40.2";
18653
18651
 
18654
18652
  //#endregion
18655
18653
  //#region src/managers/setup.ts