publ-echo-test 0.0.65 → 0.0.68

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 { findAllChildrenButGroup, 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);
@@ -139,6 +139,7 @@ var ReactGridLayout = function (_a) {
139
139
  var _b;
140
140
  var e = _a.e, node = _a.node;
141
141
  var l = (_b = getLayoutItem(layout, i)) !== null && _b !== void 0 ? _b : { i: i, x: x, y: y, w: 1, h: 1 };
142
+ console.log(l);
142
143
  if (!l)
143
144
  return;
144
145
  setOldDragItem(cloneLayoutItem(l));
@@ -147,7 +148,7 @@ var ReactGridLayout = function (_a) {
147
148
  if (!blockStructure) {
148
149
  return;
149
150
  }
150
- var childrenIds = findAllChildrenButGroup(blockStructure, i);
151
+ var childrenIds = findAllChildrenComponentIds(blockStructure, i).map(function (i) { return i.toString(); });
151
152
  var children_1 = childrenIds.map(function (id) {
152
153
  var item = getLayoutItem(layout, id);
153
154
  return cloneLayoutItem(item);
@@ -174,7 +175,7 @@ var ReactGridLayout = function (_a) {
174
175
  if (!blockStructure) {
175
176
  return;
176
177
  }
177
- var children_2 = findChildrenIds(blockStructure, i).map(function (id) {
178
+ var children_2 = findChildrenComponentIds(blockStructure, i).map(function (id) {
178
179
  var item = getLayoutItem(layout, id);
179
180
  return cloneLayoutItem(item);
180
181
  });
@@ -40,14 +40,13 @@ 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[];
48
- export declare const findAllChildrenButGroup: (blockStructure: Block[], targetId: string) => string[];
49
48
  export declare const findGroupBlocks: (blockStructure: Block[], targetId: string) => GroupBlock[];
50
- export declare const findAllComponentBlockIds: (blockStructure: Block[]) => string[];
49
+ export declare const findAllComponentBlockIds: (blockStructure: Block[]) => number[];
51
50
  export declare const findParentGroupByGroupId: (blockStructure: Block[], targetId: string) => string | null;
52
51
  export declare const addBlockToRoot: (blockStructure: Block[], newBlock: Block) => Block[];
53
52
  export declare const addBulkToTarget: (blockStructure: Block[], targetId: string, bulkIds: string[]) => Block[];
@@ -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) {
@@ -107,25 +109,24 @@ export var findAllParentGroups = function (blockStructure, targetId) {
107
109
  };
108
110
  return findParentGroups(blockStructure, targetId) || [];
109
111
  };
110
- export var findAllChildrenButGroup = function (blockStructure, targetId) {
111
- var collectChildrenIds = function (block) {
112
- var ids = [];
113
- if ('children' in block && block.children) {
114
- for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
115
- var child = _a[_i];
116
- if (child.type !== 'GROUP_BLOCK') {
117
- ids.push(child.blockId);
118
- }
119
- ids = ids.concat(collectChildrenIds(child));
120
- }
121
- }
122
- return ids;
123
- };
124
- var targetBlock = findBlockById(blockStructure, targetId);
125
- return targetBlock ? collectChildrenIds(targetBlock) : [];
126
- };
112
+ // export const findAllChildrenButGroup = (blockStructure: Block[], targetId: string): string[] => {
113
+ // const collectChildrenIds = (block: Block): string[] => {
114
+ // let ids: string[] = [];
115
+ // if ('children' in block && block.children) {
116
+ // for (const child of block.children) {
117
+ // if (child.type !== 'GROUP_BLOCK') {
118
+ // ids.push(child.blockId);
119
+ // }
120
+ // ids = ids.concat(collectChildrenIds(child));
121
+ // }
122
+ // }
123
+ // return ids;
124
+ // };
125
+ // const targetBlock = findBlockById(blockStructure, targetId);
126
+ // return targetBlock ? collectChildrenIds(targetBlock) : [];
127
+ // };
127
128
  export var findGroupBlocks = function (blockStructure, targetId) {
128
- var targetBlock = findBlockById(blockStructure, targetId);
129
+ var targetBlock = findBlockByBlockId(blockStructure, targetId);
129
130
  var groupBlocks = [];
130
131
  if (targetBlock && targetBlock.blockId === 'ROOT') {
131
132
  if ('children' in targetBlock) {
@@ -147,7 +148,7 @@ export var findAllComponentBlockIds = function (blockStructure) {
147
148
  for (var _i = 0, blocks_3 = blocks; _i < blocks_3.length; _i++) {
148
149
  var block = blocks_3[_i];
149
150
  if (block.type === 'COMPONENT_BLOCK') {
150
- ids.push(block.blockId);
151
+ ids.push(block.componentBlockId);
151
152
  }
152
153
  if ('children' in block && block.children) {
153
154
  ids = ids.concat(collectComponentBlockIds(block.children));
@@ -186,7 +187,7 @@ export var addBlockToRoot = function (blockStructure, newBlock) {
186
187
  };
187
188
  export var addBulkToTarget = function (blockStructure, targetId, bulkIds) {
188
189
  var structure = deepClone(blockStructure);
189
- var targetBlock = findBlockById(structure, targetId);
190
+ var targetBlock = findBlockByBlockId(structure, targetId);
190
191
  if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK' || !targetBlock.children) {
191
192
  return blockStructure;
192
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.65",
3
+ "version": "0.0.68",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",