pds-dev-kit-web-test 2.5.61 → 2.5.64

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.
@@ -8,15 +8,21 @@ export type PayloadCBType = {
8
8
  type: ComponentBlock['type'];
9
9
  blockId: string;
10
10
  cbId: number;
11
+ workDir: string;
11
12
  };
12
13
  export type PayloadGBType = {
13
14
  type: GroupBlock['type'];
14
15
  blockId: string;
16
+ childrenBlockIds: string[];
17
+ childrenCBIds: number[];
18
+ workDir: string;
15
19
  };
16
20
  export type PayloadBulkType = {
17
21
  type: 'BULK';
18
22
  blockId: 'BULK';
19
23
  childrenBlockIds: string[];
24
+ childrenCBIds: number[];
25
+ workDir: string;
20
26
  };
21
27
  export type BlockPayloadType = PayloadCBType | PayloadGBType | PayloadBulkType;
22
28
  type ActionHandlerPayload = {
@@ -86,6 +92,11 @@ type ActionHandlerPayload = {
86
92
  sectionId: number;
87
93
  e: React.MouseEvent;
88
94
  };
95
+ '@CUSTOMSECTION/GROUP_RIGHT_CLICKED': {
96
+ e: React.MouseEvent;
97
+ blockId: string;
98
+ isEditingGroup: boolean;
99
+ };
89
100
  '@CUSTOMSECTION/BULK_CREATED': {
90
101
  message: string;
91
102
  data: LayoutItem;
@@ -61,10 +61,8 @@ var styled_components_1 = __importDefault(require("styled-components"));
61
61
  var components_1 = require("../../components");
62
62
  var ComponentBlockMatcher_1 = __importDefault(require("./components/ComponentBlock/ComponentBlockMatcher"));
63
63
  var S_HiddenCover_1 = require("./components/ComponentBlock/componentBlocks/components/S_HiddenCover");
64
- var useGroupDrag_1 = require("./hooks/useGroupDrag");
65
- var useGroupDrag_2 = require("./hooks/useGroupDrag/useGroupDrag");
66
- var utils_1 = require("./hooks/useGroupDrag/utils");
67
- var _clsx_1 = require("./newUtils/\bclsx");
64
+ var clsx_1 = require("./newUtils/clsx");
65
+ var group_2 = require("./newUtils/group");
68
66
  var util_1 = require("./util");
69
67
  var parseSectionPadding_1 = __importDefault(require("./util/layoutPropParsers/parseSectionPadding"));
70
68
  var Responsive = (0, publ_echo_test_1.WidthProvider)(publ_echo_test_1.ResponsiveGridEditor);
@@ -99,17 +97,11 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
99
97
  sm: sm
100
98
  };
101
99
  }), layouts = _l[0], setLayouts = _l[1];
102
- var _m = (0, useGroupDrag_1.useGroupDrag)({
103
- layouts: layouts,
104
- setLayouts: setLayouts,
105
- device: device,
106
- sectionActionHandler: sectionActionHandler
107
- }), setGroupCB = _m.setGroupCB,
108
- // breakGroupCB,
109
- // escapeFromGroup,
110
- // makeAllInOneGroup,
111
- // makeCollisionGroup,
112
- makeCollisionOfBulk = _m.makeCollisionOfBulk, getCollisionGroupIds = _m.getCollisionGroupIds;
100
+ var _m = (0, react_1.useState)('ROOT'), editingGroupBlock = _m[0], setEditingGroupBlock = _m[1];
101
+ var _o = (0, react_1.useState)([]), bulkBlockIds = _o[0], setBulkBlockIds = _o[1];
102
+ var newblock = bulkBlockIds.length > 0
103
+ ? (0, group_1.addBulkToTarget)(pedigreeState, editingGroupBlock, bulkBlockIds)
104
+ : pedigreeState;
113
105
  (0, react_1.useImperativeHandle)(ref, function () {
114
106
  return {
115
107
  selectCB: function (cbId) {
@@ -130,21 +122,21 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
130
122
  setLayouts(function (prev) {
131
123
  var _a;
132
124
  var _b;
133
- var group = (0, useGroupDrag_2.getGroupCB)(prev[layoutByDevice]);
125
+ var group = (0, group_2.getGroupCB)(prev[layoutByDevice]);
134
126
  var groupedCBIds = (_b = group === null || group === void 0 ? void 0 : group.childrenIds) !== null && _b !== void 0 ? _b : [];
135
- var filteredLayout = (0, useGroupDrag_2.filterItemsById)(parsedLayouts[layoutByDevice], groupedCBIds);
127
+ var filteredLayout = (0, group_2.filterItemsById)(parsedLayouts[layoutByDevice], groupedCBIds);
136
128
  if (group === null || group === void 0 ? void 0 : group.groupLayouts) {
137
129
  var groupCbs = parsedLayouts[layoutByDevice].filter(function (each) {
138
130
  return groupedCBIds.includes(each.i);
139
131
  });
140
132
  if (groupCbs.length > 0) {
141
- var newGroupLayout = (0, utils_1.getGroupForMultiple)(groupCbs);
133
+ var newGroupLayout = (0, group_2.getGroupForMultiple)(groupCbs);
142
134
  filteredLayout.push(newGroupLayout);
143
135
  }
144
136
  }
145
137
  return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = filteredLayout, _a));
146
138
  });
147
- }, [componentBlocks, useGroupDrag_2.getGroupCB, layoutByDevice]);
139
+ }, [componentBlocks, group_2.getGroupCB, layoutByDevice]);
148
140
  (0, react_1.useEffect)(function () {
149
141
  if (editingSectionId !== props.id) {
150
142
  setSelectedBlockId(null);
@@ -187,27 +179,29 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
187
179
  if (!selectedCBId) {
188
180
  return;
189
181
  }
190
- var bulks = getCollisionGroupIds(selectedCBId).map(function (cbid) { return blockIdMap.CB_ID[Number(cbid)]; });
191
- var bulkIds = (0, group_1.findAccessibleChildrenBlocks)(pedigreeState, editingGroupBlock, bulks);
192
- setBulkBlockIds(bulkIds);
193
- sectionActionHandler &&
194
- sectionActionHandler({
195
- type: '@CUSTOMSECTION/BLOCK_CLICKED',
196
- payload: {
197
- block: { type: 'BULK', blockId: 'BULK', childrenBlockIds: bulks }
198
- }
199
- });
182
+ // const bulks = getCollisionGroupIds(selectedCBId).map(
183
+ // (cbid) => blockIdMap.CB_ID[Number(cbid)]
184
+ // );
185
+ // const bulkIds = findAccessibleChildrenBlocks(pedigreeState, editingGroupBlock, bulks);
186
+ // setBulkBlockIds(bulkIds);
187
+ // sectionActionHandler &&
188
+ // sectionActionHandler({
189
+ // type: '@CUSTOMSECTION/BLOCK_CLICKED',
190
+ // payload: {
191
+ // block: { type: 'BULK', blockId: 'BULK', childrenBlockIds: bulks }
192
+ // }
193
+ // });
200
194
  setSelectedBlockId('BULK');
201
195
  }
202
- }, [selectedBlockId, shortcutKeyMode, getCollisionGroupIds, sectionActionHandler, setSelectedBlockId]);
196
+ }, [selectedBlockId, shortcutKeyMode, sectionActionHandler, setSelectedBlockId]);
203
197
  var makeAllInOneGroup = function () {
204
198
  var allRootChildIds = (0, group_1.findAllChildrenIds)(pedigreeState, editingGroupBlock, 'current');
205
199
  setBulkBlockIds(allRootChildIds);
206
200
  };
207
- var _o = (0, util_1.parseCustomSectionPlacement)({
201
+ var _p = (0, util_1.parseCustomSectionPlacement)({
208
202
  isMobile: isMobile,
209
203
  customSectionProps: CB_PLACEMENT_PROP_SECTION
210
- }), rows = _o.rows, width = _o.width, minHeight = _o.minHeight, isFullWidth = _o.isFullWidth;
204
+ }), rows = _p.rows, width = _p.width, minHeight = _p.minHeight, isFullWidth = _p.isFullWidth;
211
205
  var customSectionStyles = {
212
206
  minHeight: "".concat(minHeight, "vh"),
213
207
  width: '100%',
@@ -215,6 +209,7 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
215
209
  };
216
210
  var breakpoint = device === 'MOBILE' ? 'sm' : 'lg';
217
211
  var onClickCB = function (id) {
212
+ var _a, _b;
218
213
  var blockId = blockIdMap.CB_ID[id];
219
214
  if (!isEditMode) {
220
215
  return;
@@ -232,7 +227,10 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
232
227
  return Array.from(set);
233
228
  });
234
229
  setSelectedBlockId(null);
235
- var newBulkIds = Array.from(new Set(__spreadArray(__spreadArray([], bulkBlockIds, true), blockIds_1, true)));
230
+ var newBulkBlockIds = Array.from(new Set(__spreadArray(__spreadArray([], bulkBlockIds, true), blockIds_1, true)));
231
+ var newBulkCBIds = newBulkBlockIds
232
+ .map(function (id) { return blockIdMap.BLOCK_ID[id]; })
233
+ .filter(function (each) { return each !== undefined; });
236
234
  sectionActionHandler &&
237
235
  sectionActionHandler({
238
236
  type: '@CUSTOMSECTION/BLOCK_CLICKED',
@@ -240,7 +238,9 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
240
238
  block: {
241
239
  type: 'BULK',
242
240
  blockId: 'BULK',
243
- childrenBlockIds: newBulkIds
241
+ childrenBlockIds: newBulkBlockIds,
242
+ childrenCBIds: newBulkCBIds,
243
+ workDir: (_a = (0, group_1.getBlockWorkDirPath)(newblock, blockId)) !== null && _a !== void 0 ? _a : 'NOT-FOUND'
244
244
  }
245
245
  }
246
246
  });
@@ -248,21 +248,23 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
248
248
  }
249
249
  if (shortcutKeyMode === 'COLLISION_SELECT') {
250
250
  var selectedCBId = selectedBlockId ? blockIdMap.BLOCK_ID[selectedBlockId] : undefined;
251
- var bulks = getCollisionGroupIds(id, selectedCBId).map(function (cbid) { return blockIdMap.CB_ID[Number(cbid)]; });
252
- var bulkIds = (0, group_1.findAccessibleChildrenBlocks)(pedigreeState, editingGroupBlock, bulks);
253
- setBulkBlockIds(bulkIds);
254
- sectionActionHandler &&
255
- sectionActionHandler({
256
- type: '@CUSTOMSECTION/BLOCK_CLICKED',
257
- payload: {
258
- block: {
259
- type: 'BULK',
260
- blockId: 'BULK',
261
- childrenBlockIds: bulkIds
262
- }
263
- }
264
- });
265
- setSelectedBlockId('BULK');
251
+ // const bulks = getCollisionGroupIds(id, selectedCBId).map(
252
+ // (cbid) => blockIdMap.CB_ID[Number(cbid)]
253
+ // );
254
+ // const bulkIds = findAccessibleChildrenBlocks(pedigreeState, editingGroupBlock, bulks);
255
+ // setBulkBlockIds(bulkIds);
256
+ // sectionActionHandler &&
257
+ // sectionActionHandler({
258
+ // type: '@CUSTOMSECTION/BLOCK_CLICKED',
259
+ // payload: {
260
+ // block: {
261
+ // type: 'BULK',
262
+ // blockId: 'BULK',
263
+ // childrenBlockIds: bulkIds
264
+ // }
265
+ // }
266
+ // });
267
+ // setSelectedBlockId('BULK');
266
268
  return;
267
269
  }
268
270
  setSelectedBlockId(blockId);
@@ -274,7 +276,8 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
274
276
  block: {
275
277
  blockId: blockId,
276
278
  type: 'COMPONENT_BLOCK',
277
- cbId: id
279
+ cbId: id,
280
+ workDir: (_b = (0, group_1.getBlockWorkDirPath)(newblock, blockId)) !== null && _b !== void 0 ? _b : 'NOT-FOUND'
278
281
  }
279
282
  }
280
283
  });
@@ -320,7 +323,7 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
320
323
  });
321
324
  };
322
325
  var onDragStop = function (props) {
323
- var _a;
326
+ var _a, _b;
324
327
  if (!isEditMode || !props.item) {
325
328
  return;
326
329
  }
@@ -346,7 +349,7 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
346
349
  var blockId = blockIdMap.CB_ID[numberId];
347
350
  var isIdNumber = !Number.isNaN(numberId);
348
351
  if (blockId) {
349
- if ((0, useGroupDrag_2.getGroupCB)(layouts[layoutByDevice])) {
352
+ if ((0, group_2.getGroupCB)(layouts[layoutByDevice])) {
350
353
  setTimeout(function () {
351
354
  setBulkBlockIds([]);
352
355
  }, 100);
@@ -362,7 +365,8 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
362
365
  block: {
363
366
  blockId: blockId,
364
367
  cbId: numberId,
365
- type: 'COMPONENT_BLOCK'
368
+ type: 'COMPONENT_BLOCK',
369
+ workDir: (_b = (0, group_1.getBlockWorkDirPath)(newblock, blockId)) !== null && _b !== void 0 ? _b : 'NOT-FOUND'
366
370
  }
367
371
  }
368
372
  });
@@ -431,11 +435,23 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
431
435
  }
432
436
  });
433
437
  };
438
+ var onContextGroup = function (e, blockId, isEditingGroup) {
439
+ setSelectedBlockId(blockId);
440
+ sectionActionHandler &&
441
+ sectionActionHandler({
442
+ type: '@CUSTOMSECTION/GROUP_RIGHT_CLICKED',
443
+ payload: {
444
+ blockId: blockId,
445
+ e: e,
446
+ isEditingGroup: isEditingGroup
447
+ }
448
+ });
449
+ };
434
450
  var onContextSection = function (e) {
435
451
  if (!isEditMode) {
436
452
  return;
437
453
  }
438
- if ((0, useGroupDrag_2.getGroupCB)(layouts[layoutByDevice])) {
454
+ if ((0, group_2.getGroupCB)(layouts[layoutByDevice])) {
439
455
  setBulkBlockIds([]);
440
456
  }
441
457
  setSelectedBlockId(null);
@@ -467,9 +483,10 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
467
483
  var breakpoints = device === 'DESKTOP' ? { lg: 100, sm: 0 } : { lg: 1200, sm: 480 };
468
484
  var innerRef = (0, react_1.useRef)(null);
469
485
  var clickOneCBInBulk = function (id) {
486
+ var _a;
470
487
  var blockId = blockIdMap.CB_ID[id];
471
488
  if (shortcutKeyMode === 'COLLISION_SELECT') {
472
- makeCollisionOfBulk();
489
+ // makeCollisionOfBulk();
473
490
  return;
474
491
  }
475
492
  if (shortcutKeyMode === 'BULK_SELECT') {
@@ -488,7 +505,8 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
488
505
  block: {
489
506
  blockId: oneLastBlockId,
490
507
  cbId: cbId,
491
- type: 'COMPONENT_BLOCK'
508
+ type: 'COMPONENT_BLOCK',
509
+ workDir: (_a = (0, group_1.getBlockWorkDirPath)(newblock, blockId)) !== null && _a !== void 0 ? _a : 'NOT-FOUND'
492
510
  }
493
511
  }
494
512
  });
@@ -501,7 +519,7 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
501
519
  if (shortcutKeyMode !== 'COLLISION_SELECT') {
502
520
  return;
503
521
  }
504
- makeCollisionOfBulk();
522
+ // makeCollisionOfBulk();
505
523
  };
506
524
  var showSectionHiddenCover = (function () {
507
525
  if (mode === 'EDIT') {
@@ -515,11 +533,6 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
515
533
  }
516
534
  return false;
517
535
  })();
518
- var _p = (0, react_1.useState)('ROOT'), editingGroupBlock = _p[0], setEditingGroupBlock = _p[1];
519
- var _q = (0, react_1.useState)([]), bulkBlockIds = _q[0], setBulkBlockIds = _q[1];
520
- var newblock = bulkBlockIds.length > 0
521
- ? (0, group_1.addBulkToTarget)(pedigreeState, editingGroupBlock, bulkBlockIds)
522
- : pedigreeState;
523
536
  var onDoubleClickGroup = function (e, id, type) {
524
537
  e.stopPropagation();
525
538
  if (id === 'BULK') {
@@ -531,6 +544,7 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
531
544
  setEditingGroupBlock('ROOT');
532
545
  };
533
546
  var onClickGroup = function (e, id, type) {
547
+ var _a, _b, _c, _d;
534
548
  e.stopPropagation();
535
549
  if (id === 'BULK') {
536
550
  return;
@@ -547,14 +561,18 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
547
561
  block: {
548
562
  blockId: oneLastBlockId,
549
563
  type: 'COMPONENT_BLOCK',
550
- cbId: blockIdMap.BLOCK_ID[oneLastBlockId]
564
+ cbId: blockIdMap.BLOCK_ID[oneLastBlockId],
565
+ workDir: (_a = (0, group_1.getBlockWorkDirPath)(newblock, oneLastBlockId)) !== null && _a !== void 0 ? _a : 'NOT-FOUND'
551
566
  }
552
567
  }
553
568
  });
554
569
  return;
555
570
  }
556
- var newBulkBlockIds = bulkBlockIds.filter(function (each) { return each !== id; });
557
- setBulkBlockIds(newBulkBlockIds);
571
+ var newBulkBlockIds_1 = bulkBlockIds.filter(function (each) { return each !== id; });
572
+ var newBulkCBIds_1 = newBulkBlockIds_1
573
+ .map(function (id) { return blockIdMap.BLOCK_ID[id]; })
574
+ .filter(function (each) { return each !== undefined; });
575
+ setBulkBlockIds(newBulkBlockIds_1);
558
576
  sectionActionHandler &&
559
577
  sectionActionHandler({
560
578
  type: '@CUSTOMSECTION/BLOCK_CLICKED',
@@ -562,7 +580,9 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
562
580
  block: {
563
581
  blockId: 'BULK',
564
582
  type: 'BULK',
565
- childrenBlockIds: newBulkBlockIds
583
+ childrenBlockIds: newBulkBlockIds_1,
584
+ childrenCBIds: newBulkCBIds_1,
585
+ workDir: (_b = (0, group_1.getBlockWorkDirPath)(newblock, 'BULK')) !== null && _b !== void 0 ? _b : 'NOT-FOUND'
566
586
  }
567
587
  }
568
588
  });
@@ -570,8 +590,11 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
570
590
  }
571
591
  if (shortcutKeyMode === 'BULK_SELECT') {
572
592
  var added = selectedBlockId ? [selectedBlockId.toString(), id] : [id];
573
- var newBulkBlocks = Array.from(new Set(__spreadArray(__spreadArray([], bulkBlockIds, true), added, true)));
574
- setBulkBlockIds(newBulkBlocks);
593
+ var newBulkBlockIds_2 = Array.from(new Set(__spreadArray(__spreadArray([], bulkBlockIds, true), added, true)));
594
+ var newBulkCBIds_2 = newBulkBlockIds_2
595
+ .map(function (id) { return blockIdMap.BLOCK_ID[id]; })
596
+ .filter(function (each) { return each !== undefined; });
597
+ setBulkBlockIds(newBulkBlockIds_2);
575
598
  setSelectedBlockId(null);
576
599
  sectionActionHandler &&
577
600
  sectionActionHandler({
@@ -580,7 +603,9 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
580
603
  block: {
581
604
  blockId: 'BULK',
582
605
  type: 'BULK',
583
- childrenBlockIds: newBulkBlocks
606
+ childrenBlockIds: newBulkBlockIds_2,
607
+ childrenCBIds: newBulkCBIds_2,
608
+ workDir: (_c = (0, group_1.getBlockWorkDirPath)(newblock, 'BULK')) !== null && _c !== void 0 ? _c : 'NOT-FOUND'
584
609
  }
585
610
  }
586
611
  });
@@ -588,13 +613,20 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
588
613
  }
589
614
  setBulkBlockIds([]);
590
615
  setSelectedBlockId(id);
616
+ var newBulkBlockIds = (0, group_1.findAllChildrenIds)(newblock, id, 'current');
617
+ var newBulkCBIds = newBulkBlockIds
618
+ .map(function (id) { return blockIdMap.BLOCK_ID[id]; })
619
+ .filter(function (each) { return each !== undefined; });
591
620
  sectionActionHandler &&
592
621
  sectionActionHandler({
593
622
  type: '@CUSTOMSECTION/BLOCK_CLICKED',
594
623
  payload: {
595
624
  block: {
596
625
  blockId: id,
597
- type: 'GROUP_BLOCK'
626
+ type: 'GROUP_BLOCK',
627
+ workDir: (_d = (0, group_1.getBlockWorkDirPath)(newblock, id)) !== null && _d !== void 0 ? _d : 'NOT-FOUND',
628
+ childrenBlockIds: newBulkBlockIds,
629
+ childrenCBIds: newBulkCBIds
598
630
  }
599
631
  }
600
632
  });
@@ -631,13 +663,13 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
631
663
  fontSize: "".concat(baseFontSize, "px")
632
664
  }, onLayoutChange: onLayoutChange, onDragStart: onDragStart, onDragStop: onDragStop, onResizeStop: onResizeStop, onDragStopForGroup: onGroupDragStop, onFitToContent: onAutoFitContent, onWidthChange: onWidthChange, minNbRow: rows, isDraggable: isEditMode, isResizable: isEditMode,
633
665
  // GROUP
634
- selectedGroupBlock: (_c = selectedBlockId === null || selectedBlockId === void 0 ? void 0 : selectedBlockId.toString()) !== null && _c !== void 0 ? _c : 'ROOT', editingGroupBlock: editingGroupBlock, blockStructure: newblock, bulkIds: bulkBlockIds, onDoubleClickGroup: onDoubleClickGroup, onClickGroup: onClickGroup, onDoubleClickOutsideGroup: onDoubleClickOutsideGroup }, { children: layouts[layoutByDevice].map(function (each, index) {
666
+ selectedGroupBlock: (_c = selectedBlockId === null || selectedBlockId === void 0 ? void 0 : selectedBlockId.toString()) !== null && _c !== void 0 ? _c : 'ROOT', editingGroupBlock: editingGroupBlock, blockStructure: newblock, bulkIds: bulkBlockIds, onDoubleClickGroup: onDoubleClickGroup, onClickGroup: onClickGroup, onDoubleClickOutsideGroup: onDoubleClickOutsideGroup, onContextGroup: onContextGroup }, { children: layouts[layoutByDevice].map(function (each, index) {
635
667
  var matchedCB = componentBlocks === null || componentBlocks === void 0 ? void 0 : componentBlocks.find(function (cb) { return cb.id.toString() === each.i; });
636
668
  var isInBulk = bulkBlockIds.includes((0, group_1.getBlockIdByComponentId)(pedigreeState, Number(each.i)));
637
669
  if (!matchedCB) {
638
670
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
639
671
  }
640
- return ((0, jsx_runtime_1.jsx)("div", __assign({ className: (0, _clsx_1.clsx)({
672
+ return ((0, jsx_runtime_1.jsx)("div", __assign({ className: (0, clsx_1.clsx)({
641
673
  'react-grid-item-selected': selectedBlockId === blockIdMap.CB_ID[matchedCB.id]
642
674
  }) }, { children: (0, jsx_runtime_1.jsx)("div", __assign({ className: "grid-item-child", style: {
643
675
  width: '100%',
@@ -42,6 +42,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
42
42
  };
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
44
  var jsx_runtime_1 = require("react/jsx-runtime");
45
+ /* eslint-disable @typescript-eslint/no-unused-vars */
45
46
  var react_1 = __importStar(require("react"));
46
47
  var ErrorBoundary_1 = require("../../../DynamicLayout/components/Section/ErrorBoundary");
47
48
  var dynamicLayoutContext_1 = require("../../../DynamicLayout/dynamicLayoutContext");
@@ -49,8 +50,6 @@ var styled_components_1 = __importDefault(require("styled-components"));
49
50
  var components_1 = require("../../components");
50
51
  var CustomSection_1 = require("./CustomSection");
51
52
  var FlexGridItem_1 = __importDefault(require("./FlexGridItem"));
52
- var useGroupDrag_1 = require("./hooks/useGroupDrag/useGroupDrag");
53
- var utils_1 = require("./hooks/useGroupDrag/utils");
54
53
  var useResizableObserver_1 = require("./hooks/useResizableObserver");
55
54
  var util_1 = require("./util");
56
55
  var parseSectionPadding_1 = __importDefault(require("./util/layoutPropParsers/parseSectionPadding"));
@@ -70,51 +69,14 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
70
69
  var gleRef = (0, react_1.useRef)(null);
71
70
  var isMobile = device === 'MOBILE';
72
71
  var isEditMode = mode === 'EDIT';
73
- var layoutByDevice = device === 'DESKTOP' ? 'lg' : 'sm';
74
- var _e = (0, react_1.useState)(function () {
75
- var _a = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : []), lg = _a.lg, sm = _a.sm;
76
- return {
77
- lg: lg,
78
- sm: sm
79
- };
80
- }), layouts = _e[0], setLayouts = _e[1];
81
- (0, react_1.useImperativeHandle)(ref, function () {
82
- return {
83
- selectCB: function (cbId) {
84
- setSelectedCB(cbId);
85
- },
86
- selectCBInBulk: function (cbIds) {
87
- var parsedLayouts = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : []);
88
- setLayouts(function (prev) {
89
- var _a;
90
- var filteredLayout = (0, useGroupDrag_1.filterItemsById)(parsedLayouts[layoutByDevice], cbIds);
91
- var newGroupLayout = (0, utils_1.getGroupForMultiple)(parsedLayouts[layoutByDevice].filter(function (each) { return cbIds.includes(each.i); }));
92
- filteredLayout.push(newGroupLayout);
93
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = filteredLayout, _a));
94
- });
95
- }
96
- };
97
- }, [componentBlocks]);
98
- (0, react_1.useLayoutEffect)(function () {
99
- var parsedLayouts = (0, util_1.parsePlacement)(componentBlocks !== null && componentBlocks !== void 0 ? componentBlocks : []);
100
- setLayouts(function (prev) {
101
- var _a;
102
- var _b;
103
- var group = (0, useGroupDrag_1.getGroupCB)(prev[layoutByDevice]);
104
- var groupedCBIds = (_b = group === null || group === void 0 ? void 0 : group.childrenIds) !== null && _b !== void 0 ? _b : [];
105
- var filteredLayout = (0, useGroupDrag_1.filterItemsById)(parsedLayouts[layoutByDevice], groupedCBIds);
106
- if (group === null || group === void 0 ? void 0 : group.groupLayouts) {
107
- var groupCbs = parsedLayouts[layoutByDevice].filter(function (each) {
108
- return groupedCBIds.includes(each.i);
109
- });
110
- if (groupCbs.length > 0) {
111
- var newGroupLayout = (0, utils_1.getGroupForMultiple)(groupCbs);
112
- filteredLayout.push(newGroupLayout);
113
- }
114
- }
115
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = filteredLayout, _a));
116
- });
117
- }, [componentBlocks, useGroupDrag_1.getGroupCB, layoutByDevice]);
72
+ // const layoutByDevice = device === 'DESKTOP' ? 'lg' : 'sm';
73
+ // const [layouts] = useState<LayoutsType>(() => {
74
+ // const { lg, sm } = parsePlacement(componentBlocks ?? []);
75
+ // return {
76
+ // lg,
77
+ // sm
78
+ // };
79
+ // });
118
80
  (0, react_1.useEffect)(function () {
119
81
  if (editingSectionId !== props.id) {
120
82
  setSelectedCB(null);
@@ -162,10 +124,10 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
162
124
  setSelectedCB('BULK');
163
125
  }
164
126
  }, [selectedCB, shortcutKeyMode, sectionActionHandler, setSelectedCB]);
165
- var _f = (0, util_1.parseCustomSectionPlacement)({
127
+ var _e = (0, util_1.parseCustomSectionPlacement)({
166
128
  isMobile: isMobile,
167
129
  customSectionProps: CB_PLACEMENT_PROP_SECTION
168
- }), width = _f.width, minHeight = _f.minHeight, isFullWidth = _f.isFullWidth;
130
+ }), width = _e.width, minHeight = _e.minHeight, isFullWidth = _e.isFullWidth;
169
131
  var customSectionStyles = {
170
132
  minHeight: "".concat(minHeight, "vh"),
171
133
  width: '100%',
@@ -175,9 +137,6 @@ var CustomSection = (0, react_1.forwardRef)(function CustomSection(props, ref) {
175
137
  if (!isEditMode) {
176
138
  return;
177
139
  }
178
- if ((0, useGroupDrag_1.getGroupCB)(layouts[layoutByDevice])) {
179
- // breakGroupCB();
180
- }
181
140
  setSelectedCB(null);
182
141
  sectionActionHandler &&
183
142
  sectionActionHandler({
@@ -1,4 +1,5 @@
1
- import type { ComponentBlock } from '../../types';
1
+ import type { ComponentBlock } from '../types';
2
+ import type { Layout } from 'publ-echo-test/dist/lib';
2
3
  import type { LayoutItem } from 'publ-echo/dist/lib';
3
4
  export interface LayoutItemWithGroupType extends LayoutItem {
4
5
  childrenIds: string[];
@@ -11,3 +12,5 @@ export declare function splitComponentBlocksByGroup(componentBlocks: ComponentBl
11
12
  inGroup: ComponentBlock[];
12
13
  notInGroup: ComponentBlock[];
13
14
  };
15
+ export declare function getGroupCB(layout: Layout): LayoutItemWithGroupType | null;
16
+ export declare const filterItemsById: (layout: Layout, idsToRemove: Array<string>) => import("publ-echo-test/dist/lib").LayoutItem[];
@@ -20,7 +20,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
20
  return to.concat(ar || Array.prototype.slice.call(from));
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.splitComponentBlocksByGroup = exports.getGroupForMultiple = exports.recalculatedGroup = exports.getGroupData = void 0;
23
+ exports.filterItemsById = exports.getGroupCB = exports.splitComponentBlocksByGroup = exports.getGroupForMultiple = exports.recalculatedGroup = exports.getGroupData = void 0;
24
24
  function getGroupData(elem1, elem2) {
25
25
  var _a, _b;
26
26
  var minX = Math.min(elem1.x, elem2.x);
@@ -125,3 +125,16 @@ function splitComponentBlocksByGroup(componentBlocks, groupIds) {
125
125
  };
126
126
  }
127
127
  exports.splitComponentBlocksByGroup = splitComponentBlocksByGroup;
128
+ function getGroupCB(layout) {
129
+ var groupIdx = layout.findIndex(function (item) { return item.i === 'group'; });
130
+ if (groupIdx < 0) {
131
+ return null;
132
+ }
133
+ var groupItem = layout[groupIdx];
134
+ return groupItem;
135
+ }
136
+ exports.getGroupCB = getGroupCB;
137
+ var filterItemsById = function (layout, idsToRemove) {
138
+ return layout.filter(function (item) { return !idsToRemove.includes(item.i); });
139
+ };
140
+ exports.filterItemsById = filterItemsById;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.5.61",
3
+ "version": "2.5.64",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "lottie-react": "^2.3.1",
24
24
  "nuka-carousel": "^4.8.4",
25
25
  "publ-echo": "^0.0.99",
26
- "publ-echo-test": "^0.0.106",
26
+ "publ-echo-test": "^0.0.108",
27
27
  "react-hook-form": "^7.28.1",
28
28
  "react-i18next": "^11.12.0",
29
29
  "react-router-dom": "^5.2.0",
@@ -1 +0,0 @@
1
- export { default as useGroupDrag } from './useGroupDrag';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useGroupDrag = void 0;
7
- var useGroupDrag_1 = require("./useGroupDrag");
8
- Object.defineProperty(exports, "useGroupDrag", { enumerable: true, get: function () { return __importDefault(useGroupDrag_1).default; } });
@@ -1,24 +0,0 @@
1
- /// <reference types="react" />
2
- import { LayoutItemWithGroupType } from './utils';
3
- import type { LayoutsType } from '../../CustomSection';
4
- import type { Device } from '../../util/types';
5
- import type { DynamicLayoutProps } from '../../../../../DynamicLayout/types';
6
- import type { Layout, LayoutItem } from 'publ-echo/dist/lib';
7
- type Props = {
8
- device: Device;
9
- layouts: LayoutsType;
10
- setLayouts: React.Dispatch<React.SetStateAction<LayoutsType>>;
11
- sectionActionHandler: DynamicLayoutProps['sectionActionHandler'];
12
- };
13
- declare function useGroupDrag({ device, setLayouts, sectionActionHandler, layouts }: Props): {
14
- setGroupCB: (selectedId: number | 'group', newId: number) => void;
15
- breakGroupCB: () => void;
16
- makeAllInOneGroup: () => void;
17
- escapeFromGroup: (id: string) => void;
18
- makeCollisionGroup: (id: number, selectedCBId?: number) => void;
19
- makeCollisionOfBulk: () => void;
20
- getCollisionGroupIds: (id: number, selectedCBId?: number) => string[];
21
- };
22
- export declare function getGroupCB(layout: Layout): LayoutItemWithGroupType | null;
23
- export declare const filterItemsById: (layout: Layout, idsToRemove: Array<string>) => LayoutItem[];
24
- export default useGroupDrag;
@@ -1,297 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.filterItemsById = exports.getGroupCB = void 0;
27
- // eslint-disable-next-line import/no-extraneous-dependencies
28
- var renderHelpers_1 = require("publ-echo/dist/lib/GridLayoutEditor/utils/renderHelpers");
29
- var react_1 = require("react");
30
- var deepCopy_1 = __importDefault(require("../../../../../DynamicLayout/utils/deepCopy"));
31
- var utils_1 = require("./utils");
32
- function useGroupDrag(_a) {
33
- var device = _a.device, setLayouts = _a.setLayouts, sectionActionHandler = _a.sectionActionHandler, layouts = _a.layouts;
34
- var layoutByDevice = device === 'DESKTOP' ? 'lg' : 'sm';
35
- function makeAllInOneGroup() {
36
- setLayouts(function (prev) {
37
- var _a, _b;
38
- var _c;
39
- // TODO: 임시용 카피
40
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
41
- if (currentLayoutCopy.length === 0) {
42
- return prev;
43
- }
44
- var groupIdx = currentLayoutCopy.findIndex(function (item) { return item.i === 'group'; });
45
- // NOTE: 그룹이 없는 경우
46
- if (groupIdx < 0) {
47
- var group_1 = (0, utils_1.getGroupForMultiple)(currentLayoutCopy);
48
- sectionActionHandler &&
49
- sectionActionHandler({
50
- type: '@CUSTOMSECTION/BULK_CREATED',
51
- payload: {
52
- message: 'group generated',
53
- data: group_1
54
- }
55
- });
56
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = [group_1], _a));
57
- }
58
- // NOTE: 그룹이 이미 있는경우
59
- var groupItem = currentLayoutCopy.splice(groupIdx, 1)[0];
60
- if (!groupItem.groupLayouts) {
61
- return prev;
62
- }
63
- var groupItems = (_c = groupItem.groupLayouts.map(function (each) { return (__assign(__assign({}, each), { x: groupItem.x + each.x, y: groupItem.y + each.y })); })) !== null && _c !== void 0 ? _c : [];
64
- currentLayoutCopy.push.apply(currentLayoutCopy, groupItems);
65
- var group = (0, utils_1.getGroupForMultiple)(currentLayoutCopy);
66
- sectionActionHandler &&
67
- sectionActionHandler({
68
- type: '@CUSTOMSECTION/BULK_CREATED',
69
- payload: {
70
- message: 'group generated',
71
- data: group
72
- }
73
- });
74
- return __assign(__assign({}, prev), (_b = {}, _b[layoutByDevice] = [group], _b));
75
- });
76
- }
77
- function escapeFromGroup(id) {
78
- setLayouts(function (prev) {
79
- var _a;
80
- // TODO: 임시용 카피
81
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
82
- var groupIdx = currentLayoutCopy.findIndex(function (item) { return item.i === 'group'; });
83
- var group = currentLayoutCopy[groupIdx];
84
- if (!group || !group.groupLayouts) {
85
- return prev;
86
- }
87
- var escapeIndex = group.groupLayouts.findIndex(function (each) { return each.i === id; });
88
- if (escapeIndex < 0) {
89
- return prev;
90
- }
91
- var escapedItem = group.groupLayouts.splice(escapeIndex, 1)[0];
92
- escapedItem.x += group.x;
93
- escapedItem.y += group.y;
94
- currentLayoutCopy.push(escapedItem);
95
- var newGroup = (0, utils_1.recalculatedGroup)(group);
96
- currentLayoutCopy.splice(groupIdx, 1, newGroup);
97
- sectionActionHandler &&
98
- sectionActionHandler({
99
- type: '@CUSTOMSECTION/ESCAPE_ONE_FROM_BULK',
100
- payload: {
101
- id: id
102
- }
103
- });
104
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = currentLayoutCopy, _a));
105
- });
106
- }
107
- function setGroupCB(selectedId, newId) {
108
- setLayouts(function (prev) {
109
- var _a;
110
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
111
- var firstIdx = currentLayoutCopy.findIndex(function (item) {
112
- if (selectedId === 'group') {
113
- return item.i === 'group';
114
- }
115
- if (Number(item.i) === selectedId) {
116
- return true;
117
- }
118
- return false;
119
- });
120
- var firstElem = currentLayoutCopy.splice(firstIdx, 1)[0];
121
- var secondIdx = currentLayoutCopy.findIndex(function (item) { return Number(item.i) === newId; });
122
- var secondElem = currentLayoutCopy.splice(secondIdx, 1)[0];
123
- var group = (0, utils_1.getGroupData)(firstElem, secondElem);
124
- currentLayoutCopy.unshift(group);
125
- sectionActionHandler &&
126
- sectionActionHandler({
127
- type: '@CUSTOMSECTION/BULK_CREATED',
128
- payload: {
129
- message: 'group generated',
130
- data: group
131
- }
132
- });
133
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = currentLayoutCopy, _a));
134
- });
135
- }
136
- var breakGroupCB = (0, react_1.useCallback)(function () {
137
- setLayouts(function (prev) {
138
- var _a;
139
- var _b;
140
- // TODO: 임시용 카피
141
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
142
- var groupIdx = currentLayoutCopy.findIndex(function (item) { return item.i === 'group'; });
143
- if (groupIdx < 0) {
144
- return prev;
145
- }
146
- var groupItem = currentLayoutCopy.splice(groupIdx, 1)[0];
147
- if (!groupItem.groupLayouts) {
148
- return prev;
149
- }
150
- var groupItems = (_b = groupItem.groupLayouts.map(function (each) { return (__assign(__assign({}, each), { x: groupItem.x + each.x, y: groupItem.y + each.y })); })) !== null && _b !== void 0 ? _b : [];
151
- currentLayoutCopy.push.apply(currentLayoutCopy, groupItems);
152
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = currentLayoutCopy, _a));
153
- });
154
- sectionActionHandler &&
155
- sectionActionHandler({
156
- type: '@CUSTOMSECTION/BULK_DISMISSED',
157
- payload: {
158
- message: 'group dismissed'
159
- }
160
- });
161
- }, []);
162
- function getCollisionGroupIds(id, selectedCBId) {
163
- var currentLayoutCopy = (0, deepCopy_1.default)(layouts[layoutByDevice]); // 현재 레이아웃 복사
164
- var additionalSelectedCBLayout = (function () {
165
- if (selectedCBId === undefined || id === selectedCBId) {
166
- return null;
167
- }
168
- return (0, renderHelpers_1.getLayoutItem)(currentLayoutCopy, selectedCBId.toString());
169
- })();
170
- var layout = (0, renderHelpers_1.getLayoutItem)(currentLayoutCopy, id.toString());
171
- if (!layout) {
172
- return []; // 해당 id에 대한 layout이 없으면 빈 배열 반환
173
- }
174
- var collisions = (0, renderHelpers_1.getAllCollisions)(currentLayoutCopy, layout);
175
- var groupLayouts = __spreadArray([layout], collisions, true);
176
- if (additionalSelectedCBLayout) {
177
- var alreadyHas = collisions.some(function (each) { return each.i === additionalSelectedCBLayout.i; });
178
- if (!alreadyHas) {
179
- groupLayouts.push(additionalSelectedCBLayout);
180
- }
181
- }
182
- // 충돌 그룹 내의 layout 아이템의 id만 반환
183
- return groupLayouts.map(function (item) { return item.i; });
184
- }
185
- function makeCollisionGroup(id, selectedCBId) {
186
- setLayouts(function (prev) {
187
- var _a, _b;
188
- var _c, _d;
189
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
190
- var additionalSelectedCBLayout = (function () {
191
- if (selectedCBId === undefined) {
192
- return null;
193
- }
194
- if (id === selectedCBId) {
195
- return null;
196
- }
197
- return (0, renderHelpers_1.getLayoutItem)(currentLayoutCopy, selectedCBId.toString());
198
- })();
199
- var layout = (0, renderHelpers_1.getLayoutItem)(currentLayoutCopy, id.toString());
200
- if (!layout) {
201
- return prev;
202
- }
203
- var prevGroupIdx = currentLayoutCopy.findIndex(function (item) { return item.i === 'group'; });
204
- if (prevGroupIdx < 0) {
205
- var collisions = (0, renderHelpers_1.getAllCollisions)(currentLayoutCopy, layout);
206
- var groupLayouts = __spreadArray([layout], collisions, true);
207
- if (collisions.length === 0 && !additionalSelectedCBLayout) {
208
- sectionActionHandler &&
209
- sectionActionHandler({
210
- type: '@CUSTOMSECTION/COLLISION_NOT_FOUND',
211
- payload: {
212
- message: '겹치는 부분이 없어, 아무련 변화가 없습니다.'
213
- }
214
- });
215
- return prev;
216
- }
217
- if (additionalSelectedCBLayout) {
218
- var alreadyHas = collisions.some(function (each) { return each.i === additionalSelectedCBLayout.i; });
219
- !alreadyHas && groupLayouts.push(additionalSelectedCBLayout);
220
- }
221
- var group_2 = (0, utils_1.getGroupForMultiple)(groupLayouts);
222
- var filtered = currentLayoutCopy.filter(function (layout) { return !group_2.childrenIds.includes(layout.i); });
223
- sectionActionHandler &&
224
- sectionActionHandler({
225
- type: '@CUSTOMSECTION/BULK_CREATED',
226
- payload: {
227
- message: 'group generated with collision detect',
228
- data: group_2
229
- }
230
- });
231
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = __spreadArray([group_2], filtered, true), _a));
232
- }
233
- var groupItem = currentLayoutCopy.splice(prevGroupIdx, 1)[0];
234
- if (groupItem) {
235
- var collisions = (0, renderHelpers_1.getAllCollisions)(currentLayoutCopy, layout);
236
- var groupItems = (_d = (_c = groupItem.groupLayouts) === null || _c === void 0 ? void 0 : _c.map(function (each) { return (__assign(__assign({}, each), { x: groupItem.x + each.x, y: groupItem.y + each.y })); })) !== null && _d !== void 0 ? _d : [];
237
- var newGroup_1 = (0, utils_1.getGroupForMultiple)([layout].concat(collisions).concat(groupItems));
238
- var filtered = currentLayoutCopy.filter(function (layout) { return !newGroup_1.childrenIds.includes(layout.i); });
239
- sectionActionHandler &&
240
- sectionActionHandler({
241
- type: '@CUSTOMSECTION/BULK_CREATED',
242
- payload: {
243
- message: 'group generated with collision detect',
244
- data: newGroup_1
245
- }
246
- });
247
- return __assign(__assign({}, prev), (_b = {}, _b[layoutByDevice] = __spreadArray([newGroup_1], filtered, true), _b));
248
- }
249
- return prev;
250
- });
251
- }
252
- function makeCollisionOfBulk() {
253
- setLayouts(function (prev) {
254
- var _a;
255
- var _b, _c;
256
- var currentLayoutCopy = (0, deepCopy_1.default)(prev[layoutByDevice]);
257
- var prevGroupIdx = currentLayoutCopy.findIndex(function (item) { return item.i === 'group'; });
258
- var groupItem = currentLayoutCopy.splice(prevGroupIdx, 1)[0];
259
- var collisions = (0, renderHelpers_1.getAllCollisions)(currentLayoutCopy, groupItem);
260
- var groupItems = (_c = (_b = groupItem.groupLayouts) === null || _b === void 0 ? void 0 : _b.map(function (each) { return (__assign(__assign({}, each), { x: groupItem.x + each.x, y: groupItem.y + each.y })); })) !== null && _c !== void 0 ? _c : [];
261
- var newGroup = (0, utils_1.getGroupForMultiple)(groupItems.concat(collisions));
262
- var filtered = currentLayoutCopy.filter(function (layout) { return !newGroup.childrenIds.includes(layout.i); });
263
- sectionActionHandler &&
264
- sectionActionHandler({
265
- type: '@CUSTOMSECTION/BULK_CREATED',
266
- payload: {
267
- message: 'group generated with collision detect',
268
- data: newGroup
269
- }
270
- });
271
- return __assign(__assign({}, prev), (_a = {}, _a[layoutByDevice] = __spreadArray([newGroup], filtered, true), _a));
272
- });
273
- }
274
- return {
275
- setGroupCB: setGroupCB,
276
- breakGroupCB: breakGroupCB,
277
- makeAllInOneGroup: makeAllInOneGroup,
278
- escapeFromGroup: escapeFromGroup,
279
- makeCollisionGroup: makeCollisionGroup,
280
- makeCollisionOfBulk: makeCollisionOfBulk,
281
- getCollisionGroupIds: getCollisionGroupIds
282
- };
283
- }
284
- function getGroupCB(layout) {
285
- var groupIdx = layout.findIndex(function (item) { return item.i === 'group'; });
286
- if (groupIdx < 0) {
287
- return null;
288
- }
289
- var groupItem = layout[groupIdx];
290
- return groupItem;
291
- }
292
- exports.getGroupCB = getGroupCB;
293
- var filterItemsById = function (layout, idsToRemove) {
294
- return layout.filter(function (item) { return !idsToRemove.includes(item.i); });
295
- };
296
- exports.filterItemsById = filterItemsById;
297
- exports.default = useGroupDrag;