publ-echo-test 0.0.331 → 0.0.333
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/css/gle-styles.css +0 -1
- package/dist/lib/GridItem/GridItem.d.ts +3 -3
- package/dist/lib/GridItem/GridItem.js +31 -247
- package/dist/lib/GridItem/GroupItem.d.ts +3 -3
- package/dist/lib/GridItem/GroupItem.js +38 -37
- package/dist/lib/GridLayoutEditor/ReactGridLayout.js +2 -3
- package/dist/lib/Resizable/Resizable.d.ts +3 -3
- package/dist/lib/Resizable/Resizable.js +35 -132
- package/package.json +1 -1
- package/dist/lib/GridItem/GridItemCopy.d.ts +0 -5
- package/dist/lib/GridItem/GridItemCopy.js +0 -613
@@ -21,22 +21,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
return t;
|
22
22
|
};
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
|
-
import React, { useEffect, useRef, useState } from
|
25
|
-
import { DraggableCore } from
|
26
|
-
import classNames from
|
27
|
-
import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, clamp, resolveRowHeight, } from
|
28
|
-
import { perc, setTopLeft, setTransform, } from
|
24
|
+
import React, { useEffect, useRef, useState } from 'react';
|
25
|
+
import { DraggableCore } from '../Draggable';
|
26
|
+
import classNames from '../../external-lib/classnames';
|
27
|
+
import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, clamp, resolveRowHeight, } from './utils/calculateUtils';
|
28
|
+
import { perc, setTopLeft, setTransform, } from '../GridLayoutEditor/utils/renderHelpers';
|
29
29
|
var GroupItem = function (_a) {
|
30
30
|
var _b;
|
31
31
|
var children = _a.children, props = __rest(_a, ["children"]);
|
32
|
-
var resizeHandle = props.resizeHandle, cols = props.cols, zOrder = props.zOrder, zOrderInternal = props.zOrderInternal, isDraggable = props.isDraggable, _c = props.transformScale, transformScale = _c === void 0 ? 1 : _c, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _d = props.cancel, cancel = _d === void 0 ?
|
32
|
+
var resizeHandle = props.resizeHandle, cols = props.cols, zOrder = props.zOrder, zOrderInternal = props.zOrderInternal, isDraggable = props.isDraggable, _c = props.transformScale, transformScale = _c === void 0 ? 1 : _c, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _d = props.cancel, cancel = _d === void 0 ? '' : _d, _e = props.handle, handle = _e === void 0 ? '' : _e, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _f = props.minH, minH = _f === void 0 ? 1 : _f, _g = props.minW, minW = _g === void 0 ? 1 : _g, _h = props.maxH, maxH = _h === void 0 ? Infinity : _h, _j = props.maxW, maxW = _j === void 0 ? Infinity : _j, i = props.i, _k = props.isHiddenVisibility, isHiddenVisibility = _k === void 0 ? false : _k, containerWidth = props.containerWidth, customColWidth = props.customColWidth, autoResize = props.autoResize, minZ = props.minZ, onContextGroup = props.onContextGroup;
|
33
33
|
var _l = useState(), resizing = _l[0], setResizing = _l[1];
|
34
34
|
var _m = useState(), dragging = _m[0], setDragging = _m[1];
|
35
35
|
var _o = useState(), dragStart = _o[0], setDragStart = _o[1];
|
36
36
|
var _p = useState(false), isDragging = _p[0], setIsDragging = _p[1];
|
37
37
|
var _q = useState(false), isResizing = _q[0], setIsResizing = _q[1];
|
38
38
|
var elementRef = useRef(null);
|
39
|
-
var isSelected = (_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.classList.contains(
|
39
|
+
var isSelected = (_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.classList.contains('react-grid-item-selected');
|
40
40
|
useEffect(function () {
|
41
41
|
var _a;
|
42
42
|
if (!isSelected || !autoResize) {
|
@@ -54,7 +54,7 @@ var GroupItem = function (_a) {
|
|
54
54
|
var callback = function (mutationsList) {
|
55
55
|
for (var _i = 0, mutationsList_1 = mutationsList; _i < mutationsList_1.length; _i++) {
|
56
56
|
var mutation = mutationsList_1[_i];
|
57
|
-
var isCharacterChanged = mutation.type ===
|
57
|
+
var isCharacterChanged = mutation.type === 'characterData';
|
58
58
|
var keepWidth = true;
|
59
59
|
var hasPaddingChanged = false;
|
60
60
|
var height = isCharacterChanged
|
@@ -85,14 +85,14 @@ var GroupItem = function (_a) {
|
|
85
85
|
var _a = calcWH(getPositionParams(), {
|
86
86
|
width: width,
|
87
87
|
height: height,
|
88
|
-
}, x, y,
|
88
|
+
}, x, y, 'e', props.w, props.h, false), w_1 = _a.w, h_1 = _a.h;
|
89
89
|
if (keepWidth) {
|
90
90
|
w_1 = prevW;
|
91
91
|
}
|
92
92
|
if (prevH > h_1) {
|
93
93
|
h_1 = prevH;
|
94
94
|
}
|
95
|
-
var _b = getResizableXYPosition(
|
95
|
+
var _b = getResizableXYPosition('e', w_1, h_1, prevW, prevH), newX = _b.newX, newY = _b.newY;
|
96
96
|
if (prevH === h_1 && prevW === w_1 && newX === x && newY === y) {
|
97
97
|
return;
|
98
98
|
}
|
@@ -162,7 +162,7 @@ var GroupItem = function (_a) {
|
|
162
162
|
style = setTopLeft(pos);
|
163
163
|
if (usePercentages) {
|
164
164
|
if (containerWidth == null) {
|
165
|
-
throw new Error(
|
165
|
+
throw new Error('Container width is missing!');
|
166
166
|
}
|
167
167
|
style.left = perc(pos.left / containerWidth);
|
168
168
|
style.width = perc(pos.width / containerWidth);
|
@@ -176,7 +176,7 @@ var GroupItem = function (_a) {
|
|
176
176
|
* @return {Element} Child wrapped in Draggable.
|
177
177
|
*/
|
178
178
|
var mixinDraggable = function (child, isDraggable) {
|
179
|
-
return (_jsx(DraggableCore, { disabled: !isDraggable, onStart: onDragStart, onDrag: onDrag, onStop: onDragStop, handle: handle, cancel:
|
179
|
+
return (_jsx(DraggableCore, { disabled: !isDraggable, onStart: onDragStart, onDrag: onDrag, onStop: onDragStop, handle: handle, cancel: '.react-resizable-handle' + (cancel ? ',' + cancel : ''), scale: transformScale, nodeRef: elementRef, children: child }));
|
180
180
|
};
|
181
181
|
// /**
|
182
182
|
// * Mix a Resizable instance into a child.
|
@@ -263,7 +263,7 @@ var GroupItem = function (_a) {
|
|
263
263
|
var onDrag = function (e, _a) {
|
264
264
|
var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
|
265
265
|
if (!dragging) {
|
266
|
-
throw new Error(
|
266
|
+
throw new Error('onDrag called before onDragStart.');
|
267
267
|
}
|
268
268
|
setIsDragging(true);
|
269
269
|
var top = dragging.top + deltaY;
|
@@ -278,6 +278,7 @@ var GroupItem = function (_a) {
|
|
278
278
|
var rowHeightNumber = resolveRowHeight(rowHeight, colWidth);
|
279
279
|
var bottomBoundary = offsetParent.clientHeight -
|
280
280
|
calcGridItemWHPx(h, rowHeightNumber, margin[1]);
|
281
|
+
console.log('bb', bottomBoundary);
|
281
282
|
top = clamp(top, 0, bottomBoundary);
|
282
283
|
var rightBoundary = containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
|
283
284
|
left = clamp(left, 0, rightBoundary);
|
@@ -296,7 +297,7 @@ var GroupItem = function (_a) {
|
|
296
297
|
var onDragStop = function (e, _a) {
|
297
298
|
var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
|
298
299
|
if (!dragging) {
|
299
|
-
throw new Error(
|
300
|
+
throw new Error('onDragEnd called before onDragStart.');
|
300
301
|
}
|
301
302
|
var w = props.w, h = props.h, i = props.i;
|
302
303
|
var left = dragging.left, top = dragging.top;
|
@@ -312,7 +313,7 @@ var GroupItem = function (_a) {
|
|
312
313
|
var getResizableXYPosition = function (handle, width, height, prevW, prevH) {
|
313
314
|
var newX = x;
|
314
315
|
var newY = y;
|
315
|
-
if (handle ===
|
316
|
+
if (handle === 'nw') {
|
316
317
|
// NOTE - nw left(X)와 top(Y) 둘다 변경
|
317
318
|
if (width > prevW) {
|
318
319
|
newX = x - (width - prevW);
|
@@ -327,7 +328,7 @@ var GroupItem = function (_a) {
|
|
327
328
|
newY = y + (prevH - height);
|
328
329
|
}
|
329
330
|
}
|
330
|
-
if (handle ===
|
331
|
+
if (handle === 'n' || handle === 'ne') {
|
331
332
|
// NOTE - n, ne left(X) 고정 & top(Y) 변경
|
332
333
|
if (height > prevH) {
|
333
334
|
newY = y - (height - prevH);
|
@@ -336,7 +337,7 @@ var GroupItem = function (_a) {
|
|
336
337
|
newY = y + (prevH - height);
|
337
338
|
}
|
338
339
|
}
|
339
|
-
if (handle ===
|
340
|
+
if (handle === 'w' || handle === 'sw') {
|
340
341
|
// NOTE - s, sw left(X) 변경 top(Y) 고정
|
341
342
|
if (width > prevW) {
|
342
343
|
newX = x - (width - prevW);
|
@@ -353,7 +354,7 @@ var GroupItem = function (_a) {
|
|
353
354
|
* @param {Object} callbackData an object with node and size information
|
354
355
|
*/
|
355
356
|
var onResizeStart = function (e, callbackData) {
|
356
|
-
onResizeHandler(e, callbackData,
|
357
|
+
onResizeHandler(e, callbackData, 'onResizeStart');
|
357
358
|
};
|
358
359
|
/**
|
359
360
|
* onResize event handler
|
@@ -362,7 +363,7 @@ var GroupItem = function (_a) {
|
|
362
363
|
*/
|
363
364
|
var onResize = function (e, callbackData) {
|
364
365
|
setIsResizing(true);
|
365
|
-
onResizeHandler(e, callbackData,
|
366
|
+
onResizeHandler(e, callbackData, 'onResize');
|
366
367
|
};
|
367
368
|
/**
|
368
369
|
* onResizeStop event handler
|
@@ -371,7 +372,7 @@ var GroupItem = function (_a) {
|
|
371
372
|
*/
|
372
373
|
var onResizeStop = function (e, callbackData) {
|
373
374
|
setIsResizing(false);
|
374
|
-
onResizeHandler(e, callbackData,
|
375
|
+
onResizeHandler(e, callbackData, 'onResizeStop');
|
375
376
|
};
|
376
377
|
/**
|
377
378
|
* Wrapper around drag events to provide more useful data.
|
@@ -405,7 +406,7 @@ var GroupItem = function (_a) {
|
|
405
406
|
// maxW = Math.min(maxW, cols - x);
|
406
407
|
w = clamp(w, minW, maxW);
|
407
408
|
h = clamp(h, tempMinH, maxH);
|
408
|
-
setResizing(handlerName ===
|
409
|
+
setResizing(handlerName === 'onResizeStop' ? undefined : size);
|
409
410
|
var _d = getResizableXYPosition(handle, w, h, prevW, prevH), newX = _d.newX, newY = _d.newY;
|
410
411
|
handler(i, w, h, { e: e, node: node, size: size }, newX, newY);
|
411
412
|
};
|
@@ -414,22 +415,22 @@ var GroupItem = function (_a) {
|
|
414
415
|
var newChild = React.cloneElement(child, {
|
415
416
|
key: i,
|
416
417
|
ref: elementRef,
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
className: classNames(
|
418
|
+
'data-group-block-id': i,
|
419
|
+
'data-z-index': z,
|
420
|
+
'data-z-order': zOrder,
|
421
|
+
'data-z-order-internal': zOrderInternal,
|
422
|
+
'data-min-z': minZ,
|
423
|
+
className: classNames('react-group-block', child.props.className, className, {
|
423
424
|
static: props.static,
|
424
425
|
isResizing: Boolean(resizing) &&
|
425
426
|
Boolean(isResizing) &&
|
426
427
|
Boolean(isHiddenVisibility),
|
427
428
|
resizing: Boolean(resizing),
|
428
|
-
|
429
|
+
'react-draggable': isDraggable,
|
429
430
|
isDragging: Boolean(isDragging) &&
|
430
431
|
Boolean(dragging) &&
|
431
432
|
Boolean(isHiddenVisibility),
|
432
|
-
|
433
|
+
'react-draggable-dragging': Boolean(dragging),
|
433
434
|
// dropping: Boolean(droppingPosition),
|
434
435
|
cssTransforms: useCSSTransforms,
|
435
436
|
}),
|
@@ -443,25 +444,25 @@ var GroupItem = function (_a) {
|
|
443
444
|
}
|
444
445
|
// 일시적으로 pointer-events 비활성화
|
445
446
|
if (elementRef.current) {
|
446
|
-
elementRef.current.style.pointerEvents =
|
447
|
+
elementRef.current.style.pointerEvents = 'none';
|
447
448
|
}
|
448
449
|
// 현재 마우스 위치에서 실제 요소 찾기
|
449
450
|
var underlyingElement = document.elementFromPoint(e.clientX, e.clientY);
|
450
451
|
// pointer-events 복구
|
451
452
|
if (elementRef.current) {
|
452
|
-
elementRef.current.style.pointerEvents =
|
453
|
+
elementRef.current.style.pointerEvents = 'auto';
|
453
454
|
}
|
454
|
-
document.querySelectorAll(
|
455
|
-
el.classList.remove(
|
455
|
+
document.querySelectorAll('.cb-layout-box.hovered').forEach(function (el) {
|
456
|
+
el.classList.remove('hovered');
|
456
457
|
});
|
457
458
|
if (underlyingElement &&
|
458
|
-
underlyingElement.classList.contains(
|
459
|
-
underlyingElement.classList.add(
|
459
|
+
underlyingElement.classList.contains('cb-layout-box')) {
|
460
|
+
underlyingElement.classList.add('hovered');
|
460
461
|
}
|
461
462
|
},
|
462
463
|
onMouseLeave: function () {
|
463
|
-
document.querySelectorAll(
|
464
|
-
el.classList.remove(
|
464
|
+
document.querySelectorAll('.cb-layout-box.hovered').forEach(function (el) {
|
465
|
+
el.classList.remove('hovered');
|
465
466
|
});
|
466
467
|
},
|
467
468
|
});
|
@@ -35,7 +35,6 @@ import { useState, useRef, useLayoutEffect } from "react";
|
|
35
35
|
import classNames from "../../external-lib/classnames";
|
36
36
|
import { bottom, cloneLayoutItem, compact, getAllCollisions, getBoundingArea, getLayoutItem, moveElement, noop, synchronizeLayoutWithChildren, withLayoutItem, } from "./utils/renderHelpers";
|
37
37
|
import { calcGridColWidth, calcXY, resolveRowHeight, } from "../GridItem/utils/calculateUtils";
|
38
|
-
// NOTE: 필수 변경하기
|
39
38
|
import GridItem from "../GridItem/GridItem";
|
40
39
|
import isEqual from "../../external-lib/lodash.isEqual";
|
41
40
|
import { findAllChildrenCbIds, findBlockByBlockId, findDirectChildrenBlockIds, findDirectChildrenCbIds, findGroupBlocks, findParentGroupBlock, formatCbIdToBlockId, getBlockSpecificType, zIndexMap, } from "./group";
|
@@ -529,7 +528,7 @@ var ReactGridLayout = function (_a) {
|
|
529
528
|
if (!item) {
|
530
529
|
return null;
|
531
530
|
}
|
532
|
-
return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z: zIndexMap.ISDRAGGING, i: activeDrag.i, className: "placeholder", containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, isDraggable: false, isResizable: false, isBounded: false, useCSSTransforms: useCSSTransforms, transformScale: transformScale, autoResize: !!l.autoResize,
|
531
|
+
return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z: zIndexMap.ISDRAGGING, i: activeDrag.i, className: "placeholder", containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, isDraggable: false, isResizable: false, isBounded: false, useCSSTransforms: useCSSTransforms, transformScale: transformScale, autoResize: !!l.autoResize, children: item && item }));
|
533
532
|
};
|
534
533
|
/**
|
535
534
|
* Given a grid item, set its style attributes & surround in a <Draggable>.
|
@@ -697,7 +696,7 @@ var ReactGridLayout = function (_a) {
|
|
697
696
|
return zIndexMap.EDITABLE_GROUP + internalZOrder;
|
698
697
|
}
|
699
698
|
if (type === "GROUP_BLOCK") {
|
700
|
-
return
|
699
|
+
return internalZOrder;
|
701
700
|
}
|
702
701
|
return -1; // NOTE: ERROR
|
703
702
|
})();
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import React from
|
2
|
-
import { PropsWithChildren } from
|
3
|
-
import { ResizableProps } from
|
1
|
+
import React from 'react';
|
2
|
+
import { PropsWithChildren } from '../Draggable/types';
|
3
|
+
import { ResizableProps } from './types';
|
4
4
|
type Props = ResizableProps;
|
5
5
|
declare const Resizable: ({ children, axis, handleSize, lockAspectRatio, minConstraints, maxConstraints, resizeHandles, transformScale, isResizing, autoResize, colWidth, margin, ...props }: PropsWithChildren<Props>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
6
6
|
export default Resizable;
|
@@ -31,12 +31,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
31
31
|
};
|
32
32
|
import { createElement as _createElement } from "react";
|
33
33
|
import { jsx as _jsx } from "react/jsx-runtime";
|
34
|
-
import React, { useEffect, useRef, } from
|
35
|
-
import { cloneElement } from
|
36
|
-
import { DraggableCore } from
|
37
|
-
import classNames from
|
34
|
+
import React, { useEffect, useRef, } from 'react';
|
35
|
+
import { cloneElement } from './utils/cloneElement';
|
36
|
+
import { DraggableCore } from '../Draggable';
|
37
|
+
import classNames from '../../external-lib/classnames';
|
38
38
|
var Resizable = function (_a) {
|
39
|
-
var children = _a.children, _b = _a.axis, axis = _b === void 0 ?
|
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"]);
|
40
40
|
var handleRefs = useRef({
|
41
41
|
s: useRef(null),
|
42
42
|
n: useRef(null),
|
@@ -66,22 +66,17 @@ var Resizable = function (_a) {
|
|
66
66
|
extendedHeightRef.current = null;
|
67
67
|
minWidth.current = 0;
|
68
68
|
shouldShrinkRef.current = false;
|
69
|
-
minHeight.current = 0;
|
70
69
|
return;
|
71
70
|
}
|
72
71
|
if (!elementRef.current) {
|
73
72
|
return;
|
74
73
|
}
|
75
|
-
var placeholder = document.querySelector(
|
74
|
+
var placeholder = document.querySelector('.placeholder');
|
76
75
|
if (!placeholder) {
|
77
76
|
return;
|
78
77
|
}
|
79
78
|
var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
|
80
|
-
|
81
|
-
if (isCCBLayoutbox) {
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
if (target.clientHeight && !isCCBLayoutbox) {
|
79
|
+
if (target.clientHeight) {
|
85
80
|
minHeight.current = target.clientHeight;
|
86
81
|
}
|
87
82
|
// target.clientHeight -> 실제 "노드"의 height. (gridItem아닌)
|
@@ -96,8 +91,8 @@ var Resizable = function (_a) {
|
|
96
91
|
target.clientHeight < elementRef.current.clientHeight) {
|
97
92
|
minHeight.current = target.clientHeight;
|
98
93
|
}
|
99
|
-
var minWidthStyle = target.computedStyleMap().get(
|
100
|
-
if (typeof minWidthStyle.value ===
|
94
|
+
var minWidthStyle = target.computedStyleMap().get('min-width');
|
95
|
+
if (typeof minWidthStyle.value === 'number' && margin && colWidth) {
|
101
96
|
var minWidthBase = minWidthStyle.value;
|
102
97
|
var minColWidth = (minWidthBase + margin[0]) / (colWidth + margin[0]);
|
103
98
|
var minW = Math.ceil(minColWidth);
|
@@ -105,96 +100,6 @@ var Resizable = function (_a) {
|
|
105
100
|
minWidth.current = Math.round(minWidthPx);
|
106
101
|
}
|
107
102
|
}, [isResizing, autoResize, children, elementRef]);
|
108
|
-
useEffect(function () {
|
109
|
-
if (!autoResize) {
|
110
|
-
return;
|
111
|
-
}
|
112
|
-
if (!isResizing) {
|
113
|
-
extendedHeightRef.current = null;
|
114
|
-
minWidth.current = 0;
|
115
|
-
shouldShrinkRef.current = false;
|
116
|
-
minHeight.current = 0;
|
117
|
-
return;
|
118
|
-
}
|
119
|
-
if (!elementRef.current) {
|
120
|
-
return;
|
121
|
-
}
|
122
|
-
setTimeout(function () {
|
123
|
-
var _a;
|
124
|
-
var placeholder = document.querySelector(".placeholder");
|
125
|
-
if (!placeholder) {
|
126
|
-
return;
|
127
|
-
}
|
128
|
-
var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
|
129
|
-
// const oneComposition = target.querySelector(".composition-container");
|
130
|
-
var isCCBLayoutbox = target.classList.contains("ccb-layout-box");
|
131
|
-
var layoutBox = target.children[0];
|
132
|
-
var contentsWrapper = layoutBox.children[0];
|
133
|
-
var oneComposition = contentsWrapper.querySelector(".composition-container");
|
134
|
-
// const oneComposition =
|
135
|
-
// contentsWrapper.children[0].children[0].children[0].children[2];
|
136
|
-
if (!isCCBLayoutbox || !oneComposition) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
if (isCCBLayoutbox && oneComposition) {
|
140
|
-
var minCellWidth = 10;
|
141
|
-
var numberOfItems = Number(target.getAttribute("data-number-of-items"));
|
142
|
-
var numberOfColumns = Number(target.getAttribute("data-number-of-columns"));
|
143
|
-
var rowGap = Number(target.getAttribute("data-row-gap"));
|
144
|
-
var columnGap = Number(target.getAttribute("data-column-gap"));
|
145
|
-
var insetTop = Number(target.getAttribute("data-inset-top"));
|
146
|
-
var insetBottom = Number(target.getAttribute("data-inset-bottom"));
|
147
|
-
var compositionCols = Number(oneComposition.getAttribute("data-cols"));
|
148
|
-
// const compositionRows = Number(
|
149
|
-
// oneComposition.getAttribute("data-rows")!
|
150
|
-
// );
|
151
|
-
var oneCompositionMinWidth = minCellWidth * compositionCols + 20; /* 20px padding */
|
152
|
-
// let oneCompositionMinHeight =
|
153
|
-
// minColHeight * compositionRows + 20; /* 20px padding */
|
154
|
-
// const contentsWrapper = placeholder.querySelector(
|
155
|
-
// ".cb-contentslist-wrapper"
|
156
|
-
// );
|
157
|
-
if (contentsWrapper) {
|
158
|
-
var gridWrapperInnerH = contentsWrapper.clientHeight;
|
159
|
-
var oneCompositionH = oneComposition.scrollHeight;
|
160
|
-
console.log("scrollHeight", oneCompositionH);
|
161
|
-
console.log("clientHeight", oneComposition.clientHeight);
|
162
|
-
console.log("gap", oneCompositionH - oneComposition.clientHeight);
|
163
|
-
var compositionBGwrapperPaddingT = Number(oneComposition.getAttribute("data-wrapper-paddingt"));
|
164
|
-
var compositionBGwrapperPaddingB = Number(oneComposition.getAttribute("data-wrapper-paddingb"));
|
165
|
-
var compositionBGwrapperPaddingL = Number(oneComposition.getAttribute("data-wrapper-paddingl"));
|
166
|
-
var compositionBGwrapperPaddingR = Number(oneComposition.getAttribute("data-wrapper-paddingr"));
|
167
|
-
var oneCompositionMinHeight = oneCompositionH +
|
168
|
-
compositionBGwrapperPaddingT +
|
169
|
-
compositionBGwrapperPaddingB;
|
170
|
-
var styles = getComputedStyle(target);
|
171
|
-
var paddingL = parseFloat(styles.paddingLeft);
|
172
|
-
var paddingR = parseFloat(styles.paddingRight);
|
173
|
-
var paddingT = parseFloat(styles.paddingTop);
|
174
|
-
var paddingB = parseFloat(styles.paddingBottom);
|
175
|
-
var paddingLR = paddingL + paddingR;
|
176
|
-
var paddingTB = paddingT + paddingB;
|
177
|
-
var compositionWrapperPaddingLR = (compositionBGwrapperPaddingL + compositionBGwrapperPaddingR) *
|
178
|
-
numberOfColumns;
|
179
|
-
var listMinWidth = oneCompositionMinWidth * numberOfColumns +
|
180
|
-
(numberOfColumns - 1) * columnGap +
|
181
|
-
paddingLR +
|
182
|
-
compositionWrapperPaddingLR;
|
183
|
-
var numberOfRows = Math.ceil(numberOfItems / numberOfColumns);
|
184
|
-
var gridWrapperTotalH = gridWrapperInnerH + insetTop + insetBottom;
|
185
|
-
var listMinHeight = oneCompositionMinHeight * numberOfRows +
|
186
|
-
(numberOfRows - 1) * rowGap +
|
187
|
-
paddingTB +
|
188
|
-
insetTop +
|
189
|
-
insetBottom;
|
190
|
-
if (listMinHeight > gridWrapperTotalH) {
|
191
|
-
minHeight.current = listMinHeight;
|
192
|
-
}
|
193
|
-
minWidth.current = listMinWidth;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
}, 0);
|
197
|
-
}, [isResizing, autoResize, children, elementRef]);
|
198
103
|
var resetData = function () {
|
199
104
|
lastHandleRectRef.current = null;
|
200
105
|
slack.current = null;
|
@@ -238,7 +143,6 @@ var Resizable = function (_a) {
|
|
238
143
|
height = Math.min(maxConstraints[1], height);
|
239
144
|
}
|
240
145
|
slack.current = [slackW + (oldW - width), slackH + (oldH - height)];
|
241
|
-
console.log("minH", minHeight.current);
|
242
146
|
return [width, height];
|
243
147
|
};
|
244
148
|
var checkTopLeft = function (deltaX, deltaY, top, left, width, height, handleAxis) {
|
@@ -253,28 +157,28 @@ var Resizable = function (_a) {
|
|
253
157
|
var resizableLeft = startPosition.current.left + (startSize.current.width - width);
|
254
158
|
var resizableTop = startPosition.current.top + (startSize.current.height - height);
|
255
159
|
if (deltaX < 0) {
|
256
|
-
if (handleAxis ===
|
160
|
+
if (handleAxis === 'nw' || handleAxis === 'w' || handleAxis === 'sw') {
|
257
161
|
if (currentSumOfLeftAndWidth > startSumOfLeftAndWidth) {
|
258
162
|
newLeft = Math.min(left, resizableLeft);
|
259
163
|
}
|
260
164
|
}
|
261
165
|
}
|
262
166
|
if (deltaY < 0) {
|
263
|
-
if (handleAxis ===
|
167
|
+
if (handleAxis === 'nw' || handleAxis === 'n' || handleAxis === 'ne') {
|
264
168
|
if (currentSumOfTopAndHeight > startSumOfTopAndHeight) {
|
265
169
|
newTop = Math.min(top, resizableTop);
|
266
170
|
}
|
267
171
|
}
|
268
172
|
}
|
269
173
|
if (deltaX > 0) {
|
270
|
-
if (handleAxis ===
|
174
|
+
if (handleAxis === 'nw' || handleAxis === 'w' || handleAxis === 'sw') {
|
271
175
|
if (width >= minConstraints[0]) {
|
272
176
|
newLeft = Math.max(left, resizableLeft);
|
273
177
|
}
|
274
178
|
}
|
275
179
|
}
|
276
180
|
if (deltaY > 0) {
|
277
|
-
if (handleAxis ===
|
181
|
+
if (handleAxis === 'nw' || handleAxis === 'n' || handleAxis === 'ne') {
|
278
182
|
if (height >= minConstraints[1]) {
|
279
183
|
newTop = Math.max(top, resizableTop);
|
280
184
|
}
|
@@ -287,7 +191,7 @@ var Resizable = function (_a) {
|
|
287
191
|
var _b, _c;
|
288
192
|
var _d, _e, _f, _g, _h, _j;
|
289
193
|
var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
|
290
|
-
if (handlerName ===
|
194
|
+
if (handlerName === 'onResizeStart') {
|
291
195
|
var position = { top: (_d = props.top) !== null && _d !== void 0 ? _d : 0, left: (_e = props.left) !== null && _e !== void 0 ? _e : 0 };
|
292
196
|
startPosition.current = position;
|
293
197
|
startSize.current = {
|
@@ -296,12 +200,12 @@ var Resizable = function (_a) {
|
|
296
200
|
};
|
297
201
|
resetData();
|
298
202
|
}
|
299
|
-
var canDragX = (axis ===
|
300
|
-
handleAxis !==
|
301
|
-
handleAxis !==
|
302
|
-
var canDragY = (axis ===
|
303
|
-
handleAxis !==
|
304
|
-
handleAxis !==
|
203
|
+
var canDragX = (axis === 'both' || axis === 'x') &&
|
204
|
+
handleAxis !== 'n' &&
|
205
|
+
handleAxis !== 's';
|
206
|
+
var canDragY = (axis === 'both' || axis === 'y') &&
|
207
|
+
handleAxis !== 'e' &&
|
208
|
+
handleAxis !== 'w';
|
305
209
|
if (!canDragX && !canDragY)
|
306
210
|
return;
|
307
211
|
var axisV = handleAxis[0];
|
@@ -319,35 +223,34 @@ var Resizable = function (_a) {
|
|
319
223
|
// }
|
320
224
|
// }
|
321
225
|
lastHandleRectRef.current = handleRect;
|
322
|
-
if (axisH ===
|
226
|
+
if (axisH === 'w') {
|
323
227
|
deltaX = -deltaX;
|
324
228
|
}
|
325
|
-
if (axisV ===
|
229
|
+
if (axisV === 'n') {
|
326
230
|
deltaY = -deltaY;
|
327
231
|
}
|
328
232
|
var width = props.width + (canDragX ? deltaX / transformScale : 0);
|
329
233
|
var height = props.height + (canDragY ? deltaY / transformScale : 0);
|
330
234
|
var left = (_h = props === null || props === void 0 ? void 0 : props.left) !== null && _h !== void 0 ? _h : 0;
|
331
235
|
var top = (_j = props === null || props === void 0 ? void 0 : props.top) !== null && _j !== void 0 ? _j : 0;
|
332
|
-
if (axisV ===
|
236
|
+
if (axisV === 'n') {
|
333
237
|
top = top - deltaY;
|
334
238
|
}
|
335
|
-
if (axisH ===
|
239
|
+
if (axisH === 'w') {
|
336
240
|
left = left - deltaX;
|
337
241
|
}
|
338
242
|
_b = checkConstraints(width, height), width = _b[0], height = _b[1];
|
339
243
|
if (autoResize && minHeight.current === height) {
|
340
244
|
handleAxis = removeNorthHandle(handleAxis);
|
341
245
|
}
|
342
|
-
console.log("deltax deltay", deltaX, deltaY);
|
343
246
|
_c = checkTopLeft(deltaX, deltaY, top, left, width, height, handleAxis), top = _c[0], left = _c[1];
|
344
247
|
var isDimensionsChanged = width !== props.width || height !== props.height;
|
345
|
-
var cb = typeof props[handlerName] ===
|
346
|
-
var isCbSkipped = handlerName ===
|
248
|
+
var cb = typeof props[handlerName] === 'function' ? props[handlerName] : null;
|
249
|
+
var isCbSkipped = handlerName === 'onResize' && !isDimensionsChanged;
|
347
250
|
if (cb && !isCbSkipped) {
|
348
251
|
cb(e, { node: node, size: { width: width, height: height, top: top, left: left }, handle: handleAxis });
|
349
252
|
}
|
350
|
-
if (handlerName ===
|
253
|
+
if (handlerName === 'onResizeStop') {
|
351
254
|
startPosition.current = null;
|
352
255
|
startSize.current = null;
|
353
256
|
resetData();
|
@@ -358,27 +261,27 @@ var Resizable = function (_a) {
|
|
358
261
|
if (!handle) {
|
359
262
|
return (_jsx("span", { className: "react-resizable-handle react-resizable-handle-".concat(handleAxis), ref: ref }));
|
360
263
|
}
|
361
|
-
if (typeof handle ===
|
264
|
+
if (typeof handle === 'function') {
|
362
265
|
return handle(handleAxis, ref);
|
363
266
|
}
|
364
|
-
var isDOMElement = typeof handle.type ===
|
267
|
+
var isDOMElement = typeof handle.type === 'string';
|
365
268
|
var props = __assign({ ref: ref }, (isDOMElement ? {} : { handleAxis: handleAxis }));
|
366
269
|
return React.cloneElement(handle, props);
|
367
270
|
};
|
368
|
-
return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className :
|
271
|
+
return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className : 'react-resizable'), children: __spreadArray([
|
369
272
|
// ...children.props.children,
|
370
273
|
React.Children.map(children.props.children, function (child) { return child; })
|
371
274
|
], resizeHandles.map(function (handleAxis) {
|
372
275
|
var ref = (handleRefs === null || handleRefs === void 0 ? void 0 : handleRefs.current) && handleRefs.current[handleAxis];
|
373
|
-
return (_createElement(DraggableCore, __assign({}, draggableOpts, { nodeRef: ref, key: "resizableHandle-".concat(handleAxis), onStop: resizeHandler(
|
276
|
+
return (_createElement(DraggableCore, __assign({}, draggableOpts, { nodeRef: ref, key: "resizableHandle-".concat(handleAxis), onStop: resizeHandler('onResizeStop', handleAxis), onStart: resizeHandler('onResizeStart', handleAxis), onDrag: resizeHandler('onResize', handleAxis) }), renderResizeHandle(handleAxis, ref)));
|
374
277
|
}), true) }));
|
375
278
|
};
|
376
279
|
function removeNorthHandle(axis) {
|
377
280
|
switch (axis) {
|
378
|
-
case
|
379
|
-
return
|
380
|
-
case
|
381
|
-
return
|
281
|
+
case 'ne':
|
282
|
+
return 'e';
|
283
|
+
case 'nw':
|
284
|
+
return 'w';
|
382
285
|
default:
|
383
286
|
return axis;
|
384
287
|
}
|
package/package.json
CHANGED
@@ -1,5 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { GridItemProps } from "./types";
|
3
|
-
import { PropsWithChildren } from "../types";
|
4
|
-
declare const GridItem: ({ children, ...props }: PropsWithChildren<GridItemProps>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
5
|
-
export default GridItem;
|