publ-echo-test 0.0.67 → 0.0.69

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.
@@ -37,7 +37,7 @@ import { bottom, cloneLayoutItem, compact, getAllCollisions, getBoundingArea, ge
37
37
  import { calcGridColWidth, calcXY, resolveRowHeight, } from "../GridItem/utils/calculateUtils";
38
38
  import GridItem from "../GridItem/GridItem";
39
39
  import isEqual from "../../external-lib/lodash.isEqual";
40
- import { findAllChildrenComponentIds, findChildrenIds, findGroupBlocks, getBlockSpecificType, zIndexMap } from "./group";
40
+ import { findAllChildrenComponentIds, findChildrenComponentIds, findGroupBlocks, getBlockSpecificType, zIndexMap } from "./group";
41
41
  import GroupItem from "../GridItem/GroupItem";
42
42
  import OutsideClickHandler from "../GridItem/OutsideClickHandler";
43
43
  var layoutClassName = "react-grid-layout";
@@ -58,7 +58,7 @@ var ReactGridLayout = function (_a) {
58
58
  var _7 = useState(), droppingPosition = _7[0], setDroppingPosition = _7[1];
59
59
  var _8 = useState(false), isMounted = _8[0], setIsMounted = _8[1];
60
60
  // const [selectedGroup, setSelectedGroup] = useState<string>('1');
61
- var editableItems = blockStructure ? findChildrenIds(blockStructure, editingGroupBlock) : [];
61
+ var editableItems = blockStructure ? findChildrenComponentIds(blockStructure, editingGroupBlock) : [];
62
62
  var _9 = useState([]), oldGroupChildren = _9[0], setOldGroupChildren = _9[1];
63
63
  var _10 = useState(function () {
64
64
  return synchronizeLayoutWithChildren(props.layout || [], children, cols, compactType, allowOverlap);
@@ -175,7 +175,7 @@ var ReactGridLayout = function (_a) {
175
175
  if (!blockStructure) {
176
176
  return;
177
177
  }
178
- var children_2 = findChildrenIds(blockStructure, i).map(function (id) {
178
+ var children_2 = findChildrenComponentIds(blockStructure, i).map(function (id) {
179
179
  var item = getLayoutItem(layout, id);
180
180
  return cloneLayoutItem(item);
181
181
  });
@@ -40,8 +40,8 @@ export type BulkBlockInternal = {
40
40
  zOrderMobileInternal: number;
41
41
  children: (ComponentBlock | GroupBlock)[];
42
42
  };
43
- export declare const findBlockById: (blocks: Block[], blockId: string) => Block | null;
44
- export declare const findChildrenIds: (blockStructure: Block[], targetId: string) => string[];
43
+ export declare const findBlockByBlockId: (blocks: Block[], blockId: string) => Block | null;
44
+ export declare const findChildrenComponentIds: (blockStructure: Block[], targetId: string) => string[];
45
45
  export declare const findAllChildrenIds: (blockStructure: Block[], targetId: string) => string[];
46
46
  export declare const findAllChildrenComponentIds: (blockStructure: Block[], targetId: string) => number[];
47
47
  export declare const findAllParentGroups: (blockStructure: Block[], targetId: string) => GroupBlock[];
@@ -35,14 +35,14 @@ export function getBlockSpecificType(block) {
35
35
  return block.type;
36
36
  }
37
37
  var deepClone = function (blocks) { return JSON.parse(JSON.stringify(blocks)); };
38
- export var findBlockById = function (blocks, blockId) {
38
+ export var findBlockByBlockId = function (blocks, blockId) {
39
39
  for (var _i = 0, blocks_1 = blocks; _i < blocks_1.length; _i++) {
40
40
  var block = blocks_1[_i];
41
41
  if (block.blockId === blockId) {
42
42
  return block;
43
43
  }
44
44
  if (block.type === 'GROUP_BLOCK' && block.children) {
45
- var found = findBlockById(block.children, blockId);
45
+ var found = findBlockByBlockId(block.children, blockId);
46
46
  if (found) {
47
47
  return found;
48
48
  }
@@ -50,11 +50,13 @@ export var findBlockById = function (blocks, blockId) {
50
50
  }
51
51
  return null;
52
52
  };
53
- export var findChildrenIds = function (blockStructure, targetId) {
54
- var targetBlock = findBlockById(blockStructure, targetId);
55
- return targetBlock && 'children' in targetBlock && targetBlock.children
56
- ? targetBlock.children.map(function (child) { return child.blockId; })
57
- : [];
53
+ export var findChildrenComponentIds = function (blockStructure, targetId) {
54
+ var targetBlock = findBlockByBlockId(blockStructure, targetId);
55
+ if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
56
+ return [];
57
+ }
58
+ var blockCBChildren = targetBlock.children.filter(function (child) { return child.type === 'COMPONENT_BLOCK'; });
59
+ return blockCBChildren.map(function (cb) { return cb.componentBlockId.toString(); });
58
60
  };
59
61
  export var findAllChildrenIds = function (blockStructure, targetId) {
60
62
  var collectChildrenIds = function (block) {
@@ -68,7 +70,7 @@ export var findAllChildrenIds = function (blockStructure, targetId) {
68
70
  }
69
71
  return ids;
70
72
  };
71
- var targetBlock = findBlockById(blockStructure, targetId);
73
+ var targetBlock = findBlockByBlockId(blockStructure, targetId);
72
74
  return targetBlock ? collectChildrenIds(targetBlock) : [];
73
75
  };
74
76
  export var findAllChildrenComponentIds = function (blockStructure, targetId) {
@@ -85,7 +87,7 @@ export var findAllChildrenComponentIds = function (blockStructure, targetId) {
85
87
  }
86
88
  return ids;
87
89
  };
88
- var targetBlock = findBlockById(blockStructure, targetId);
90
+ var targetBlock = findBlockByBlockId(blockStructure, targetId);
89
91
  return targetBlock ? collectComponentIds(targetBlock) : [];
90
92
  };
91
93
  export var findAllParentGroups = function (blockStructure, targetId) {
@@ -124,7 +126,7 @@ export var findAllParentGroups = function (blockStructure, targetId) {
124
126
  // return targetBlock ? collectChildrenIds(targetBlock) : [];
125
127
  // };
126
128
  export var findGroupBlocks = function (blockStructure, targetId) {
127
- var targetBlock = findBlockById(blockStructure, targetId);
129
+ var targetBlock = findBlockByBlockId(blockStructure, targetId);
128
130
  var groupBlocks = [];
129
131
  if (targetBlock && targetBlock.blockId === 'ROOT') {
130
132
  if ('children' in targetBlock) {
@@ -183,13 +185,22 @@ export var addBlockToRoot = function (blockStructure, newBlock) {
183
185
  return block;
184
186
  });
185
187
  };
186
- export var addBulkToTarget = function (blockStructure, targetId, bulkIds) {
188
+ export var addBulkToTarget = function (blockStructure, targetId, bulkIds // componentBlockId
189
+ ) {
187
190
  var structure = deepClone(blockStructure);
188
- var targetBlock = findBlockById(structure, targetId);
191
+ var targetBlock = findBlockByBlockId(structure, targetId);
189
192
  if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
190
193
  return blockStructure;
191
194
  }
192
- var bulkBlocks = targetBlock.children.filter(function (child) { return bulkIds.includes(child.blockId); });
195
+ var bulkBlocks = targetBlock.children.filter(function (child) {
196
+ if (child.type === 'COMPONENT_BLOCK' && bulkIds.includes(child.componentBlockId.toString())) {
197
+ return true;
198
+ }
199
+ if (child.type === 'GROUP_BLOCK' && bulkIds.includes(child.blockId)) {
200
+ return true;
201
+ }
202
+ return false;
203
+ });
193
204
  if (bulkBlocks.length !== bulkIds.length) {
194
205
  throw new Error("Some bulkIds do not exist as children of the target block.");
195
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",