publ-echo 0.0.103 → 0.0.105
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/lib/Draggable/DraggableCore.js +3 -2
- package/dist/lib/GridItem/GridItem.d.ts +3 -3
- package/dist/lib/GridItem/GridItem.js +36 -25
- package/dist/lib/GridItem/GroupItem.d.ts +10 -0
- package/dist/lib/GridItem/GroupItem.js +473 -0
- package/dist/lib/GridItem/OutsideClickHandler.d.ts +7 -0
- package/dist/lib/GridItem/OutsideClickHandler.js +112 -0
- package/dist/lib/GridItem/types.d.ts +7 -5
- package/dist/lib/GridLayoutEditor/ReactGridLayout.d.ts +4 -4
- package/dist/lib/GridLayoutEditor/ReactGridLayout.js +312 -61
- package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.js +2 -2
- package/dist/lib/GridLayoutEditor/group.d.ts +57 -0
- package/dist/lib/GridLayoutEditor/group.js +340 -0
- package/dist/lib/GridLayoutEditor/types.d.ts +32 -6
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.d.ts +8 -0
- package/dist/lib/GridLayoutEditor/utils/renderHelpers.js +41 -0
- package/dist/lib/Resizable/Resizable.js +2 -3
- package/dist/lib/utils/classNames.d.ts +3 -0
- package/dist/lib/utils/classNames.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
export var zIndexMap = {
|
|
11
|
+
ISDRAGGING: 999999,
|
|
12
|
+
BULK: 20000,
|
|
13
|
+
EDITING_GROUP_CHILD: 10000,
|
|
14
|
+
EDITING_GROUP: 9000,
|
|
15
|
+
GROUP: 5000,
|
|
16
|
+
CB: 0,
|
|
17
|
+
ROOT: 0, //?
|
|
18
|
+
};
|
|
19
|
+
export function getBlockSpecificType(block) {
|
|
20
|
+
if (block.blockId === 'ROOT') {
|
|
21
|
+
return 'ROOT';
|
|
22
|
+
}
|
|
23
|
+
if (block.blockId === 'BULK') {
|
|
24
|
+
return 'BULK';
|
|
25
|
+
}
|
|
26
|
+
return block.type;
|
|
27
|
+
}
|
|
28
|
+
var deepClone = function (blocks) { return JSON.parse(JSON.stringify(blocks)); };
|
|
29
|
+
var collectChildrenCbIds = function (block, depth) {
|
|
30
|
+
var ids = [];
|
|
31
|
+
if ('children' in block && block.children) {
|
|
32
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
|
33
|
+
var child = _a[_i];
|
|
34
|
+
if (child.type === 'COMPONENT_BLOCK') {
|
|
35
|
+
ids.push(child.componentBlockId);
|
|
36
|
+
}
|
|
37
|
+
if (depth === 'deep' && child.type === 'GROUP_BLOCK') {
|
|
38
|
+
ids = ids.concat(collectChildrenCbIds(child, depth));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return ids;
|
|
43
|
+
};
|
|
44
|
+
var collectChildrenBlockIds = function (block, depth) {
|
|
45
|
+
var ids = [];
|
|
46
|
+
if ('children' in block && block.children) {
|
|
47
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
|
48
|
+
var child = _a[_i];
|
|
49
|
+
ids.push(child.blockId);
|
|
50
|
+
if (depth === 'deep') {
|
|
51
|
+
ids = ids.concat(collectChildrenBlockIds(child, depth));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return ids;
|
|
56
|
+
};
|
|
57
|
+
export var findBlockByBlockId = function (block, blockId) {
|
|
58
|
+
if (block.type !== 'GROUP_BLOCK' || block.children.length === 0) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (block.blockId === 'ROOT' && blockId === 'ROOT') {
|
|
62
|
+
return block;
|
|
63
|
+
}
|
|
64
|
+
for (var _i = 0, _a = block.children; _i < _a.length; _i++) {
|
|
65
|
+
var child = _a[_i];
|
|
66
|
+
if (child.blockId === blockId) {
|
|
67
|
+
return child;
|
|
68
|
+
}
|
|
69
|
+
if (child.type === 'GROUP_BLOCK' && child.children) {
|
|
70
|
+
var found = findBlockByBlockId(child, blockId);
|
|
71
|
+
if (found) {
|
|
72
|
+
return found;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
};
|
|
78
|
+
export var findDirectChildrenCbIds = function (block, targetId) {
|
|
79
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
|
80
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
return collectChildrenCbIds(targetBlock, 'current');
|
|
84
|
+
};
|
|
85
|
+
export var findAllChildrenCbIds = function (block, targetId) {
|
|
86
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
|
87
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
return collectChildrenCbIds(targetBlock, 'deep');
|
|
91
|
+
};
|
|
92
|
+
export var findAllChildrenBlockIds = function (block, targetId) {
|
|
93
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
|
94
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
return collectChildrenBlockIds(targetBlock, 'deep');
|
|
98
|
+
};
|
|
99
|
+
export var findDirectChildrenBlockIds = function (block, targetId) {
|
|
100
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
|
101
|
+
if (!targetBlock || targetBlock.type !== 'GROUP_BLOCK') {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
return collectChildrenBlockIds(targetBlock, 'current');
|
|
105
|
+
};
|
|
106
|
+
// NOTE: 타겟과 하위 모두.
|
|
107
|
+
export var findGroupBlocks = function (block, targetId) {
|
|
108
|
+
var targetBlock = findBlockByBlockId(block, targetId);
|
|
109
|
+
if (!targetBlock) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
if (targetBlock.type !== 'GROUP_BLOCK') {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
var groupBlocks = targetBlock.children.filter(function (child) { return child.type === 'GROUP_BLOCK'; });
|
|
116
|
+
var bulkInTarget = targetBlock.children.find(function (block) { return block.blockId === 'BULK'; });
|
|
117
|
+
if (bulkInTarget && bulkInTarget.type === 'GROUP_BLOCK') {
|
|
118
|
+
var groupInBulk = bulkInTarget.children.filter(function (child) { return child.type === 'GROUP_BLOCK'; });
|
|
119
|
+
if (targetBlock.blockId === 'ROOT') {
|
|
120
|
+
return groupBlocks.concat(groupInBulk);
|
|
121
|
+
}
|
|
122
|
+
if (groupInBulk && groupInBulk.length > 0) {
|
|
123
|
+
return [targetBlock].concat(groupBlocks).concat(groupInBulk);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (targetBlock.blockId === 'ROOT') {
|
|
127
|
+
return groupBlocks;
|
|
128
|
+
}
|
|
129
|
+
return [targetBlock].concat(groupBlocks);
|
|
130
|
+
};
|
|
131
|
+
// export const findAllComponentBlockIds = (blockStructure: Block[]): number[] => {
|
|
132
|
+
// const collectComponentBlockIds = (blocks: Block[]): number[] => {
|
|
133
|
+
// let ids: number[] = [];
|
|
134
|
+
// for (const block of blocks) {
|
|
135
|
+
// if (block.type === 'COMPONENT_BLOCK') {
|
|
136
|
+
// ids.push(block.componentBlockId);
|
|
137
|
+
// }
|
|
138
|
+
// if ('children' in block && block.children) {
|
|
139
|
+
// ids = ids.concat(collectComponentBlockIds(block.children));
|
|
140
|
+
// }
|
|
141
|
+
// }
|
|
142
|
+
// return ids;
|
|
143
|
+
// };
|
|
144
|
+
// return collectComponentBlockIds(blockStructure);
|
|
145
|
+
// };
|
|
146
|
+
// export const findParentGroupByGroupId = (blockStructure: Block[], targetId: string): string | null => {
|
|
147
|
+
// const findParentGroup = (
|
|
148
|
+
// blocks: Block[],
|
|
149
|
+
// id: string,
|
|
150
|
+
// parent: GroupBlock | null = null
|
|
151
|
+
// ): string | null => {
|
|
152
|
+
// for (const block of blocks) {
|
|
153
|
+
// if (block.blockId === id && block.type === 'GROUP_BLOCK') {
|
|
154
|
+
// return parent ? parent.blockId : null;
|
|
155
|
+
// }
|
|
156
|
+
// if ('children' in block && block.children) {
|
|
157
|
+
// const result = findParentGroup(block.children, id, block.type === 'GROUP_BLOCK' ? block : parent);
|
|
158
|
+
// if (result) {
|
|
159
|
+
// return result;
|
|
160
|
+
// }
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
163
|
+
// return null;
|
|
164
|
+
// };
|
|
165
|
+
// return findParentGroup(blockStructure, targetId);
|
|
166
|
+
// };
|
|
167
|
+
// export const addBlockToRoot = (block: RootBlock, newBlock: Block): Block[] => {
|
|
168
|
+
// return block.map(block => {
|
|
169
|
+
// if (block.blockId === 'ROOT' && block.type === 'GROUP_BLOCK') {
|
|
170
|
+
// return {
|
|
171
|
+
// ...block,
|
|
172
|
+
// children: block.children ? [...block.children, newBlock] : [newBlock]
|
|
173
|
+
// };
|
|
174
|
+
// }
|
|
175
|
+
// return block;
|
|
176
|
+
// });
|
|
177
|
+
// };
|
|
178
|
+
export var addBulkToTarget = function (block, targetId, bulkBlockIds) {
|
|
179
|
+
var blockCopy = deepClone(block);
|
|
180
|
+
var targetBlock = findBlockByBlockId(blockCopy, targetId);
|
|
181
|
+
if (!targetBlock ||
|
|
182
|
+
targetBlock.type !== 'GROUP_BLOCK' ||
|
|
183
|
+
!targetBlock.children) {
|
|
184
|
+
return block;
|
|
185
|
+
}
|
|
186
|
+
var bulkBlocks = targetBlock.children.filter(function (child) {
|
|
187
|
+
if (child.type === 'COMPONENT_BLOCK' &&
|
|
188
|
+
bulkBlockIds.includes(child.blockId.toString())) {
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
if (child.type === 'GROUP_BLOCK' && bulkBlockIds.includes(child.blockId)) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
});
|
|
196
|
+
if (bulkBlocks.length !== bulkBlockIds.length) {
|
|
197
|
+
return block;
|
|
198
|
+
}
|
|
199
|
+
if (bulkBlocks.length === 0) {
|
|
200
|
+
return block;
|
|
201
|
+
}
|
|
202
|
+
// Remove bulk blocks from target's children
|
|
203
|
+
targetBlock.children = targetBlock.children.filter(function (child) { return !bulkBlockIds.includes(child.blockId); });
|
|
204
|
+
var zOrdersDesktop = bulkBlocks
|
|
205
|
+
.map(function (block) { return block.zOrderDesktopInternal; })
|
|
206
|
+
.filter(function (each) { return each !== null; });
|
|
207
|
+
var zOrdersMobile = bulkBlocks
|
|
208
|
+
.map(function (block) { return block.zOrderMobileInternal; })
|
|
209
|
+
.filter(function (each) { return each !== null; });
|
|
210
|
+
var zOrderDesktopInternal = Math.max.apply(Math, zOrdersDesktop);
|
|
211
|
+
var zOrderMobileInternal = Math.max.apply(Math, zOrdersMobile);
|
|
212
|
+
// Create the new bulkBlock
|
|
213
|
+
var bulkBlock = {
|
|
214
|
+
blockId: 'BULK',
|
|
215
|
+
type: 'GROUP_BLOCK',
|
|
216
|
+
zOrderDesktopInternal: zOrderDesktopInternal,
|
|
217
|
+
zOrderMobileInternal: zOrderMobileInternal,
|
|
218
|
+
children: bulkBlocks,
|
|
219
|
+
};
|
|
220
|
+
// Add the bulkBlock to the target's children
|
|
221
|
+
targetBlock.children.push(bulkBlock);
|
|
222
|
+
return blockCopy;
|
|
223
|
+
};
|
|
224
|
+
function findPathHelper(current, targetBlockId) {
|
|
225
|
+
if (current.blockId === targetBlockId) {
|
|
226
|
+
return [current.blockId];
|
|
227
|
+
}
|
|
228
|
+
if ('children' in current && Array.isArray(current.children)) {
|
|
229
|
+
for (var _i = 0, _a = current.children; _i < _a.length; _i++) {
|
|
230
|
+
var child = _a[_i];
|
|
231
|
+
var result = findPathHelper(child, targetBlockId);
|
|
232
|
+
if (result !== null) {
|
|
233
|
+
return __spreadArray([current.blockId], result, true);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
export function getBlockWorkDirPath(blockStructure, targetBlockId) {
|
|
240
|
+
var path = findPathHelper(blockStructure, targetBlockId);
|
|
241
|
+
return path ? '/' + path.join('/') : '';
|
|
242
|
+
}
|
|
243
|
+
export function formatBlockIdToCbId(blockId) {
|
|
244
|
+
var match = blockId.match(/^CB_(\d+)$/);
|
|
245
|
+
return match ? parseInt(match[1], 10) : null;
|
|
246
|
+
}
|
|
247
|
+
export function formatCbIdToBlockId(cbId) {
|
|
248
|
+
return "CB_".concat(cbId);
|
|
249
|
+
}
|
|
250
|
+
// export const findAccessibleChildrenBlocks = (
|
|
251
|
+
// block: Block,
|
|
252
|
+
// targetGroupId: string,
|
|
253
|
+
// blockIds: string[]
|
|
254
|
+
// ): string[] => {
|
|
255
|
+
// const targetBlock = findBlockByBlockId(block, targetGroupId);
|
|
256
|
+
// if (!targetBlock || !('children' in targetBlock) || !targetBlock.children) {
|
|
257
|
+
// return [];
|
|
258
|
+
// }
|
|
259
|
+
// const result = new Set<string>();
|
|
260
|
+
// const traverse = (block: Block, rootId: string): boolean => {
|
|
261
|
+
// if ('children' in block && block.children) {
|
|
262
|
+
// for (const child of block.children) {
|
|
263
|
+
// if (blockIds.includes(child.blockId)) {
|
|
264
|
+
// result.add(rootId);
|
|
265
|
+
// return true; // Stop traversal for this branch
|
|
266
|
+
// }
|
|
267
|
+
// if (traverse(child, rootId)) {
|
|
268
|
+
// result.add(rootId);
|
|
269
|
+
// return true; // Stop traversal for this branch
|
|
270
|
+
// }
|
|
271
|
+
// }
|
|
272
|
+
// }
|
|
273
|
+
// return false;
|
|
274
|
+
// };
|
|
275
|
+
// for (const child of targetBlock.children) {
|
|
276
|
+
// if (blockIds.includes(child.blockId)) {
|
|
277
|
+
// result.add(child.blockId);
|
|
278
|
+
// } else {
|
|
279
|
+
// traverse(child, child.blockId);
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
282
|
+
// return Array.from(result);
|
|
283
|
+
// };
|
|
284
|
+
export function findParentGroupBlock(current, targetBlockId) {
|
|
285
|
+
// 현재 블록이 그룹(또는 루트) 블록이고, 자식이 있다면 탐색합니다.
|
|
286
|
+
if ('children' in current && Array.isArray(current.children)) {
|
|
287
|
+
for (var _i = 0, _a = current.children; _i < _a.length; _i++) {
|
|
288
|
+
var child = _a[_i];
|
|
289
|
+
// 자식 중에 targetBlockId를 가진 블록이 있다면,
|
|
290
|
+
if (child.blockId === targetBlockId) {
|
|
291
|
+
// 현재 블록이 ROOT라면 부모가 ROOT이므로 null 반환
|
|
292
|
+
if (current.blockId === 'ROOT') {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
// 그렇지 않다면 현재 블록이 부모 그룹 블록이므로 반환
|
|
296
|
+
if (current.type === 'GROUP_BLOCK') {
|
|
297
|
+
return current;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// 만약 자식이 그룹 블록이라면 재귀적으로 탐색
|
|
301
|
+
if (child.type === 'GROUP_BLOCK') {
|
|
302
|
+
var found = findParentGroupBlock(child, targetBlockId);
|
|
303
|
+
if (found !== null) {
|
|
304
|
+
return found;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// 찾지 못하면 null 반환
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
export function findOneComponentBlock(current, targetBlockId) {
|
|
313
|
+
var targetBlock = findBlockByBlockId(current, targetBlockId);
|
|
314
|
+
if (!targetBlock) {
|
|
315
|
+
console.error('Target block not found');
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
if (targetBlock.type !== 'GROUP_BLOCK') {
|
|
319
|
+
console.error('Target block is not a group block');
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
// 직속 하위에서 먼저 찾기
|
|
323
|
+
for (var _i = 0, _a = targetBlock.children; _i < _a.length; _i++) {
|
|
324
|
+
var child = _a[_i];
|
|
325
|
+
if (child.type === 'COMPONENT_BLOCK') {
|
|
326
|
+
return child.componentBlockId;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// 직속 하위에 없다면 재귀적으로 찾기
|
|
330
|
+
for (var _b = 0, _c = targetBlock.children; _b < _c.length; _b++) {
|
|
331
|
+
var child = _c[_b];
|
|
332
|
+
if (child.type === 'GROUP_BLOCK') {
|
|
333
|
+
var found = findOneComponentBlock(child, child.blockId);
|
|
334
|
+
if (found !== null) {
|
|
335
|
+
return found;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DragEvent, ReactElement, RefObject } from
|
|
2
|
-
import { ResizeHandleAxis, ResizeHandleType } from
|
|
3
|
-
import { ResizeEventType } from
|
|
4
|
-
|
|
1
|
+
import { DragEvent, ReactElement, RefObject } from 'react';
|
|
2
|
+
import { ResizeHandleAxis, ResizeHandleType } from '../Resizable/types';
|
|
3
|
+
import { ResizeEventType } from '../GridItem/types';
|
|
4
|
+
import { Block } from './group';
|
|
5
|
+
export type CompactType = 'vertical' | 'horizontal';
|
|
5
6
|
export type LayoutItem = {
|
|
6
7
|
w: number;
|
|
7
8
|
h: number;
|
|
@@ -28,7 +29,13 @@ export type DroppedEvent = {
|
|
|
28
29
|
item?: LayoutItem;
|
|
29
30
|
event?: DragEvent<HTMLDivElement>;
|
|
30
31
|
};
|
|
32
|
+
export type UpdatedItem = {
|
|
33
|
+
id: string;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
31
37
|
export type ReactGridLayoutProps = {
|
|
38
|
+
sectionId: string;
|
|
32
39
|
children: ReactElement<any> | ReactElement[];
|
|
33
40
|
className?: string;
|
|
34
41
|
style?: Object;
|
|
@@ -59,6 +66,7 @@ export type ReactGridLayoutProps = {
|
|
|
59
66
|
onDrag?: EventCallback;
|
|
60
67
|
onDragStart?: EventCallback;
|
|
61
68
|
onDragStop?: EventCallback;
|
|
69
|
+
onDragStopForGroup?: EventCallbackForGroup;
|
|
62
70
|
onResize?: EventCallback;
|
|
63
71
|
onResizeStart?: EventCallback;
|
|
64
72
|
onResizeStop?: EventCallback;
|
|
@@ -72,6 +80,14 @@ export type ReactGridLayoutProps = {
|
|
|
72
80
|
minNbRow?: number;
|
|
73
81
|
customColWidth?: number;
|
|
74
82
|
onFitToContent?: OnFitContentCallBack;
|
|
83
|
+
blockStructure?: Block;
|
|
84
|
+
onDoubleClickGroup?: (e: React.MouseEvent, id: string, type: string) => void;
|
|
85
|
+
selectedGroupBlock?: 'ROOT' | string;
|
|
86
|
+
editingGroupBlock?: 'ROOT' | string;
|
|
87
|
+
onClickGroup?: (e: React.MouseEvent, id: string, type: string) => void;
|
|
88
|
+
bulkIds?: string[];
|
|
89
|
+
onDoubleClickOutsideGroup: () => void;
|
|
90
|
+
onContextGroup?: (e: React.MouseEvent, blockId: string, isEditingGroup: boolean) => void;
|
|
75
91
|
};
|
|
76
92
|
export type DragOverEvent = MouseEvent & {
|
|
77
93
|
nativeEvent: {
|
|
@@ -96,6 +112,15 @@ export type EventCallback = (properties: {
|
|
|
96
112
|
e?: ResizeEventType;
|
|
97
113
|
node?: HTMLElement;
|
|
98
114
|
}) => void;
|
|
115
|
+
export type EventCallbackForGroup = (properties: {
|
|
116
|
+
layout: Layout;
|
|
117
|
+
prev?: LayoutItem;
|
|
118
|
+
item?: LayoutItem;
|
|
119
|
+
placeholder?: LayoutItem;
|
|
120
|
+
e?: ResizeEventType;
|
|
121
|
+
node?: HTMLElement;
|
|
122
|
+
updatedItems: UpdatedItem[];
|
|
123
|
+
}) => void;
|
|
99
124
|
export type RowHeight = number | ((width: number) => number);
|
|
100
125
|
export type Position = {
|
|
101
126
|
left: number;
|
|
@@ -118,7 +143,7 @@ export type ResponsiveGridLayoutStateType = {
|
|
|
118
143
|
layout: Layout;
|
|
119
144
|
layouts?: ResponsiveLayout<string>;
|
|
120
145
|
};
|
|
121
|
-
type CoreType = Omit<ReactGridLayoutProps,
|
|
146
|
+
type CoreType = Omit<ReactGridLayoutProps, 'cols' | 'layout' | 'margin' | 'containerPadding' | 'transformScale' | 'onLayoutChange' | 'isHiddenVisibility'>;
|
|
122
147
|
export type ResponsiveGridLayoutProps = {
|
|
123
148
|
breakpoint?: Breakpoint;
|
|
124
149
|
breakpoints?: Breakpoints<Breakpoint>;
|
|
@@ -129,9 +154,10 @@ export type ResponsiveGridLayoutProps = {
|
|
|
129
154
|
onBreakpointChange?: OnBreakpointChangeCallback;
|
|
130
155
|
onLayoutChange?: OnLayoutChangeCallback;
|
|
131
156
|
onWidthChange?: OnWidthChangeCallback;
|
|
157
|
+
zoom?: number;
|
|
132
158
|
} & CoreType;
|
|
133
159
|
export type Breakpoint = string;
|
|
134
|
-
export type DefaultBreakpoints =
|
|
160
|
+
export type DefaultBreakpoints = 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
|
|
135
161
|
export type ResponsiveLayout<T extends Breakpoint> = Record<T, Layout>;
|
|
136
162
|
export type Breakpoints<T extends Breakpoint> = Record<T, number>;
|
|
137
163
|
export type OnLayoutChangeCallback = (properties: {
|
|
@@ -163,3 +163,11 @@ export declare function synchronizeLayoutWithChildren(initialLayout: Layout, chi
|
|
|
163
163
|
*/
|
|
164
164
|
export declare function validateLayout(layout: Layout, contextName?: string): void;
|
|
165
165
|
export declare const noop: (args: any) => any;
|
|
166
|
+
export declare function getBoundingArea(layout: Layout, ids: string[]): {
|
|
167
|
+
x: number;
|
|
168
|
+
y: number;
|
|
169
|
+
w: number;
|
|
170
|
+
h: number;
|
|
171
|
+
z: number;
|
|
172
|
+
minZ: number;
|
|
173
|
+
} | null;
|
|
@@ -564,3 +564,44 @@ function log() {
|
|
|
564
564
|
console.log.apply(console, args);
|
|
565
565
|
}
|
|
566
566
|
export var noop = function (_args) { return undefined; };
|
|
567
|
+
export function getBoundingArea(layout, ids) {
|
|
568
|
+
var layoutItems = ids.map(function (id) { return getLayoutItem(layout, id); }).filter(function (item) { return item !== undefined; });
|
|
569
|
+
if (layoutItems.length === 0) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
if (layoutItems.length === 1) {
|
|
573
|
+
return {
|
|
574
|
+
x: layoutItems[0].x,
|
|
575
|
+
y: layoutItems[0].y,
|
|
576
|
+
w: layoutItems[0].w,
|
|
577
|
+
h: layoutItems[0].h,
|
|
578
|
+
z: layoutItems[0].z,
|
|
579
|
+
minZ: layoutItems[0].z,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
var _a = layoutItems.reduce(function (acc, elem, idx, arr) {
|
|
583
|
+
var _a, _b, _c, _d;
|
|
584
|
+
if (idx === arr.length - 1) {
|
|
585
|
+
return acc;
|
|
586
|
+
}
|
|
587
|
+
var elem1 = idx === 0 ? elem : acc;
|
|
588
|
+
var elem2 = arr[idx + 1];
|
|
589
|
+
var minX = Math.min(elem1.x, elem2.x);
|
|
590
|
+
var minY = Math.min(elem1.y, elem2.y);
|
|
591
|
+
var elem1W = elem1.x - minX + elem1.w;
|
|
592
|
+
var elem2W = elem2.x - minX + elem2.w;
|
|
593
|
+
var elem1H = elem1.y - minY + elem1.h;
|
|
594
|
+
var elem2H = elem2.y - minY + elem2.h;
|
|
595
|
+
var maxZ = Math.max((_a = elem1 === null || elem1 === void 0 ? void 0 : elem1.z) !== null && _a !== void 0 ? _a : 0, (_b = elem2 === null || elem2 === void 0 ? void 0 : elem2.z) !== null && _b !== void 0 ? _b : 0);
|
|
596
|
+
var minZ = Math.min((_c = elem1 === null || elem1 === void 0 ? void 0 : elem1.z) !== null && _c !== void 0 ? _c : 0, (_d = elem2 === null || elem2 === void 0 ? void 0 : elem2.z) !== null && _d !== void 0 ? _d : 0);
|
|
597
|
+
return {
|
|
598
|
+
x: Math.min(elem1.x, elem2.x),
|
|
599
|
+
y: Math.min(elem1.y, elem2.y),
|
|
600
|
+
w: Math.max(elem1W, elem2W),
|
|
601
|
+
h: Math.max(elem1H, elem2H),
|
|
602
|
+
z: maxZ,
|
|
603
|
+
minZ: minZ,
|
|
604
|
+
};
|
|
605
|
+
}, { x: 0, y: 0, w: 0, h: 0, z: 0, minZ: 0 }), minX = _a.x, minY = _a.y, maxW = _a.w, maxH = _a.h, maxZ = _a.z, minZ = _a.minZ;
|
|
606
|
+
return { x: minX, y: minY, w: maxW, h: maxH, z: maxZ, minZ: minZ };
|
|
607
|
+
}
|
|
@@ -34,6 +34,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
34
34
|
import React, { useEffect, useRef } from "react";
|
|
35
35
|
import { cloneElement } from "./utils/cloneElement";
|
|
36
36
|
import { DraggableCore } from "../Draggable";
|
|
37
|
+
import classNames from "../../external-lib/classnames";
|
|
37
38
|
var Resizable = function (_a) {
|
|
38
39
|
var children = _a.children, _b = _a.axis, axis = _b === void 0 ? "both" : _b, _c = _a.handleSize, handleSize = _c === void 0 ? [20, 20] : _c, _d = _a.lockAspectRatio, lockAspectRatio = _d === void 0 ? false : _d, _e = _a.minConstraints, minConstraints = _e === void 0 ? [20, 20] : _e, _f = _a.maxConstraints, maxConstraints = _f === void 0 ? [Infinity, Infinity] : _f, _g = _a.resizeHandles, resizeHandles = _g === void 0 ? ["se"] : _g, _h = _a.transformScale, transformScale = _h === void 0 ? 1 : _h, isResizing = _a.isResizing, autoResize = _a.autoResize, colWidth = _a.colWidth, margin = _a.margin, props = __rest(_a, ["children", "axis", "handleSize", "lockAspectRatio", "minConstraints", "maxConstraints", "resizeHandles", "transformScale", "isResizing", "autoResize", "colWidth", "margin"]);
|
|
39
40
|
var handleRefs = useRef({
|
|
@@ -119,8 +120,6 @@ var Resizable = function (_a) {
|
|
|
119
120
|
width = height * ratio;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
|
-
console.log('w: ', width);
|
|
123
|
-
console.log('minW: ', minWidth.current);
|
|
124
123
|
var _b = [width, height], oldW = _b[0], oldH = _b[1];
|
|
125
124
|
var _c = (_a = slack.current) !== null && _a !== void 0 ? _a : [0, 0], slackW = _c[0], slackH = _c[1];
|
|
126
125
|
width += slackW;
|
|
@@ -269,7 +268,7 @@ var Resizable = function (_a) {
|
|
|
269
268
|
var props = __assign({ ref: ref }, (isDOMElement ? {} : { handleAxis: handleAxis }));
|
|
270
269
|
return React.cloneElement(handle, props);
|
|
271
270
|
};
|
|
272
|
-
return cloneElement(children, __assign(__assign({}, restProps), { className:
|
|
271
|
+
return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className : 'react-resizable'), children: __spreadArray([
|
|
273
272
|
// ...children.props.children,
|
|
274
273
|
React.Children.map(children.props.children, function (child) { return child; })
|
|
275
274
|
], resizeHandles.map(function (handleAxis) {
|