publ-echo 0.0.78 → 0.0.79
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.
|
@@ -31,7 +31,7 @@ import { useResizeObserver } from "../hooks/useResizeobserver";
|
|
|
31
31
|
import { shouldAutoResize, shouldBlockResize } from "./utils/autoResizeUtils";
|
|
32
32
|
var GridItem = function (_a) {
|
|
33
33
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
34
|
-
var resizeHandle = props.resizeHandle, cols = props.cols, isDraggable = props.isDraggable, _b = props.transformScale, transformScale = _b === void 0 ? 1 : _b, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _c = props.cancel, cancel = _c === void 0 ? "" : _c, _d = props.handle, handle = _d === void 0 ? "" : _d, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _e = props.minH, minH = _e === void 0 ? 1 : _e, _f = props.minW, minW = _f === void 0 ? 1 : _f, _g = props.maxH, maxH = _g === void 0 ? Infinity : _g, _h = props.maxW, maxW = _h === void 0 ? Infinity : _h, i = props.i, _j = props.isHiddenVisibility, isHiddenVisibility = _j === void 0 ? false : _j, containerWidth = props.containerWidth, customColWidth = props.customColWidth, rowHeight = props.rowHeight, activeResizeObserver = props.activeResizeObserver
|
|
34
|
+
var resizeHandle = props.resizeHandle, cols = props.cols, isDraggable = props.isDraggable, _b = props.transformScale, transformScale = _b === void 0 ? 1 : _b, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _c = props.cancel, cancel = _c === void 0 ? "" : _c, _d = props.handle, handle = _d === void 0 ? "" : _d, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _e = props.minH, minH = _e === void 0 ? 1 : _e, _f = props.minW, minW = _f === void 0 ? 1 : _f, _g = props.maxH, maxH = _g === void 0 ? Infinity : _g, _h = props.maxW, maxW = _h === void 0 ? Infinity : _h, i = props.i, _j = props.isHiddenVisibility, isHiddenVisibility = _j === void 0 ? false : _j, containerWidth = props.containerWidth, customColWidth = props.customColWidth, rowHeight = props.rowHeight, activeResizeObserver = props.activeResizeObserver;
|
|
35
35
|
var shouldAutoShrink = useRef({ shouldAutoShrink: false, initialHeight: 0 });
|
|
36
36
|
var _k = useState(), resizing = _k[0], setResizing = _k[1];
|
|
37
37
|
var _l = useState(), dragging = _l[0], setDragging = _l[1];
|
|
@@ -39,7 +39,7 @@ var GridItem = function (_a) {
|
|
|
39
39
|
var _o = useState(false), isDragging = _o[0], setIsDragging = _o[1];
|
|
40
40
|
var _p = useState(false), isResizing = _p[0], setIsResizing = _p[1];
|
|
41
41
|
var elementRef = useRef(null);
|
|
42
|
-
var
|
|
42
|
+
var gridItemHeight = useResizeObserver([isDragging, isResizing]).gridItemHeight;
|
|
43
43
|
var isHoveredRef = useRef(false);
|
|
44
44
|
useEffect(function () {
|
|
45
45
|
var node = elementRef.current;
|
|
@@ -70,7 +70,10 @@ var GridItem = function (_a) {
|
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (isHoveredRef.current) {
|
|
73
|
-
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
var target = elementRef.current.querySelector(".cb-text-content");
|
|
76
|
+
if (!target) {
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
76
79
|
var observer = new ResizeObserver(function (_a) {
|
|
@@ -83,16 +86,14 @@ var GridItem = function (_a) {
|
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
if (isHoveredRef.current) {
|
|
86
|
-
console.log('disconnect from observer');
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
91
|
;
|
|
90
92
|
var _d = calcWH(getPositionParams(), { width: newClientWidth, height: newClientHeight }, x, y, 'se', props.w, props.h), w = _d.w, h = _d.h;
|
|
91
93
|
props.onContentSizeChange(props.i, { x: x, y: y, w: w, h: h });
|
|
92
94
|
});
|
|
93
|
-
observer.observe(
|
|
95
|
+
observer.observe(target, { box: 'border-box' });
|
|
94
96
|
if (isHoveredRef.current) {
|
|
95
|
-
console.log('disconnect observer');
|
|
96
97
|
observer.disconnect();
|
|
97
98
|
}
|
|
98
99
|
;
|
|
@@ -317,20 +318,11 @@ var GridItem = function (_a) {
|
|
|
317
318
|
* @param {Object} callbackData an object with node and size information
|
|
318
319
|
*/
|
|
319
320
|
var onResizeStart = function (e, callbackData) {
|
|
320
|
-
// const isOverflowingVertically = scrollHeight > clientHeight;
|
|
321
|
-
// const isHandleVertical = callbackData.handle.includes('n') || callbackData.handle.includes('s')
|
|
322
|
-
// const isOverflowingHorizontally = scrollWidth > clientWidth;
|
|
323
|
-
// if (isOverflowingVertically && isHandleVertical) {
|
|
324
|
-
// elementRef.current?.classList.add(`resize-notallowed-${callbackData.handle}`)
|
|
325
|
-
// return;
|
|
326
|
-
// }
|
|
327
321
|
onResizeHandler(e, callbackData, "onResizeStart");
|
|
328
|
-
// NOTE: 확인필요
|
|
329
322
|
shouldAutoShrink.current.initialHeight = gridItemHeight;
|
|
330
323
|
};
|
|
331
324
|
var onResize = function (e, callbackData, contentSize) {
|
|
332
325
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
333
|
-
console.log(contentSize);
|
|
334
326
|
setIsResizing(true);
|
|
335
327
|
var _j = getDirectionOfMouseEvent(e), dirX = _j.dirX, dirY = _j.dirY;
|
|
336
328
|
var oneLetterSize = (_a = calculateCharacterWidthInDiv()) !== null && _a !== void 0 ? _a : 0;
|
|
@@ -458,7 +450,6 @@ var GridItem = function (_a) {
|
|
|
458
450
|
if (className === 'placeholder') {
|
|
459
451
|
return newChild;
|
|
460
452
|
}
|
|
461
|
-
console.log(activeResizeObserver);
|
|
462
453
|
newChild = mixinResizable(newChild, pos, isResizable);
|
|
463
454
|
newChild = mixinDraggable(newChild, isDraggable);
|
|
464
455
|
return newChild;
|
|
@@ -395,7 +395,7 @@ var ReactGridLayout = function (_a) {
|
|
|
395
395
|
: !l.static && isResizable;
|
|
396
396
|
var resizeHandlesOptions = l.resizeHandles || resizeHandles;
|
|
397
397
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
398
|
-
return (_jsx(GridItem, { className: "i-am-grid-item", containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop: onDragStopHandler, onDragStart: onDragStartHandler, onDrag: onDragHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeStop: onResizeStopHandler, onContentSizeChange: onContentSizeChange, isDraggable: draggable, isResizable: resizable, isBounded: bounded, useCSSTransforms: useCSSTransforms && isMounted, usePercentages: !isMounted, transformScale: transformScale, w: l.w, h: l.h, x: l.x, y: l.y, z: l.z || 0, i: l.i, minH: l.minH, minW: l.minW, maxH: l.maxH, maxW: l.maxW, static: l.static, droppingPosition: isDroppingItem ? droppingPosition : undefined, resizeHandles: resizeHandlesOptions, resizeHandle: resizeHandle, isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, activeResizeObserver: child.props.className === 'react-grid-item-selected', children: child }, l.i));
|
|
398
|
+
return (_jsx(GridItem, { className: "i-am-grid-item", containerWidth: width, cols: cols, margin: margin, containerPadding: containerPadding || margin, maxRows: maxRows, rowHeight: rowHeight, cancel: draggableCancel, handle: draggableHandle, onDragStop: onDragStopHandler, onDragStart: onDragStartHandler, onDrag: onDragHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeStop: onResizeStopHandler, onContentSizeChange: onContentSizeChange, isDraggable: draggable, isResizable: resizable, isBounded: bounded, useCSSTransforms: useCSSTransforms && isMounted, usePercentages: !isMounted, transformScale: transformScale, w: l.w, h: l.h, x: l.x, y: l.y, z: l.z || 0, i: l.i, minH: l.minH, minW: l.minW, maxH: l.maxH, maxW: l.maxW, static: l.static, droppingPosition: isDroppingItem ? droppingPosition : undefined, resizeHandles: resizeHandlesOptions, resizeHandle: resizeHandle, isHiddenVisibility: isHiddenVisibility, customColWidth: colWidth, activeResizeObserver: child.props.className === 'react-grid-item-selected' && l.activeAutoResize, children: child }, l.i));
|
|
399
399
|
};
|
|
400
400
|
var onDragOverHandler = function (e) {
|
|
401
401
|
var _a;
|
|
@@ -35,7 +35,8 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
35
35
|
import DraggableCore from "../Draggable/DraggableCore";
|
|
36
36
|
import { cloneElement } from "./utils/cloneElement";
|
|
37
37
|
var Resizable = function (_a) {
|
|
38
|
-
var
|
|
38
|
+
var _b;
|
|
39
|
+
var children = _a.children, _c = _a.axis, axis = _c === void 0 ? "both" : _c, _d = _a.handleSize, handleSize = _d === void 0 ? [20, 20] : _d, _e = _a.lockAspectRatio, lockAspectRatio = _e === void 0 ? false : _e, _f = _a.minConstraints, minConstraints = _f === void 0 ? [20, 20] : _f, _g = _a.maxConstraints, maxConstraints = _g === void 0 ? [Infinity, Infinity] : _g, _h = _a.resizeHandles, resizeHandles = _h === void 0 ? ["se"] : _h, _j = _a.transformScale, transformScale = _j === void 0 ? 1 : _j, props = __rest(_a, ["children", "axis", "handleSize", "lockAspectRatio", "minConstraints", "maxConstraints", "resizeHandles", "transformScale"]);
|
|
39
40
|
var placeholderObserver = props.placeholderObserver;
|
|
40
41
|
var handleRefs = useRef({
|
|
41
42
|
s: useRef(null),
|
|
@@ -51,18 +52,13 @@ var Resizable = function (_a) {
|
|
|
51
52
|
var startSize = useRef(null);
|
|
52
53
|
var lastHandleRect = null;
|
|
53
54
|
var slack = null;
|
|
54
|
-
var
|
|
55
|
-
var
|
|
55
|
+
var _k = useState({ width: 0, height: 0 }), content = _k[0], setContent = _k[1];
|
|
56
|
+
var target = (_b = document.querySelector('.placeholder')) === null || _b === void 0 ? void 0 : _b.querySelector('.cb-text-content');
|
|
56
57
|
useEffect(function () {
|
|
57
|
-
var _a;
|
|
58
58
|
if (!placeholderObserver) {
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
if (!
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
var content = (_a = placeholder.children[0].children[0]) === null || _a === void 0 ? void 0 : _a.children[0];
|
|
65
|
-
if (!content) {
|
|
61
|
+
if (!target) {
|
|
66
62
|
return;
|
|
67
63
|
}
|
|
68
64
|
var observer = new ResizeObserver(function (_a) {
|
|
@@ -71,11 +67,11 @@ var Resizable = function (_a) {
|
|
|
71
67
|
var contentWidth = entry.target.clientWidth;
|
|
72
68
|
setContent({ width: contentWidth, height: contentHeight });
|
|
73
69
|
});
|
|
74
|
-
observer.observe(
|
|
70
|
+
observer.observe(target, { box: 'border-box' });
|
|
75
71
|
return function () {
|
|
76
72
|
observer.disconnect();
|
|
77
73
|
};
|
|
78
|
-
}, [placeholderObserver,
|
|
74
|
+
}, [placeholderObserver, target]);
|
|
79
75
|
var className = props.className, draggableOpts = props.draggableOpts, width = props.width, height = props.height, handle = props.handle, onResize = props.onResize, onResizeStop = props.onResizeStop, onResizeStart = props.onResizeStart, restProps = __rest(props, ["className", "draggableOpts", "width", "height", "handle", "onResize", "onResizeStop", "onResizeStart"]);
|
|
80
76
|
var resetData = function () {
|
|
81
77
|
lastHandleRect = slack = null;
|
|
@@ -32,29 +32,27 @@ export function useResizeObserver(deps) {
|
|
|
32
32
|
var refvalue = useRef({ myHeight: 0 });
|
|
33
33
|
var isMounted = useIsMounted();
|
|
34
34
|
useLayoutEffect(function () {
|
|
35
|
-
var
|
|
36
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
var target = (_a = document.querySelector('.placeholder')) === null || _a === void 0 ? void 0 : _a.querySelector('.cb-text-box');
|
|
37
|
+
if (!target) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
if (typeof window === 'undefined' || !('ResizeObserver' in window)) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
43
|
var observer = new ResizeObserver(function (_a) {
|
|
43
|
-
var _b
|
|
44
|
+
var _b;
|
|
44
45
|
var entry = _a[0];
|
|
45
46
|
var newWidth = extractSize(entry, 'contentBoxSize', 'inlineSize');
|
|
46
47
|
var newHeight = extractSize(entry, 'borderBoxSize', 'blockSize');
|
|
47
48
|
var newScrollHeight = entry.target.scrollHeight;
|
|
48
|
-
var
|
|
49
|
-
var newContentHeight = (_c = (_b = entry.target.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) === null || _c === void 0 ? void 0 : _c.clientHeight;
|
|
50
|
-
var newContentWidth = (_e = (_d = entry.target.children[0]) === null || _d === void 0 ? void 0 : _d.children[0]) === null || _e === void 0 ? void 0 : _e.clientWidth;
|
|
49
|
+
var newContentHeight = (_b = entry.target.children[0]) === null || _b === void 0 ? void 0 : _b.clientHeight;
|
|
51
50
|
refvalue.current.myHeight = newContentHeight;
|
|
52
|
-
var newSize = { gridItemWidth: newWidth, gridItemHeight: newHeight, scrollHeight: newScrollHeight, clientHeight:
|
|
51
|
+
var newSize = { gridItemWidth: newWidth, gridItemHeight: newHeight, scrollHeight: newScrollHeight, clientHeight: newContentHeight };
|
|
53
52
|
previousSize.current = newSize;
|
|
54
53
|
setSize(newSize);
|
|
55
54
|
});
|
|
56
|
-
observer.observe(
|
|
57
|
-
console.log('target', placeholder.children[0]);
|
|
55
|
+
observer.observe(target, { box: 'border-box' });
|
|
58
56
|
return function () {
|
|
59
57
|
observer.disconnect();
|
|
60
58
|
};
|