publ-echo 0.0.63 → 0.0.65
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.
|
@@ -21,7 +21,7 @@ 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, { useRef, useState } from "react";
|
|
24
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
25
25
|
import { DraggableCore } from "../Draggable";
|
|
26
26
|
import classNames from "../../external-lib/classnames";
|
|
27
27
|
import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, calculateCharacterWidthInDiv, clamp, resolveRowHeight, } from "./utils/calculateUtils";
|
|
@@ -32,6 +32,7 @@ import { shouldAutoResize, shouldBlockResize } from "./utils/autoResizeUtils";
|
|
|
32
32
|
var GridItem = function (_a) {
|
|
33
33
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
34
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;
|
|
35
|
+
var child = React.Children.only(children);
|
|
35
36
|
var shouldAutoShrink = useRef({ shouldAutoShrink: false, initialHeight: 0 });
|
|
36
37
|
var _k = useState(), resizing = _k[0], setResizing = _k[1];
|
|
37
38
|
var _l = useState(), dragging = _l[0], setDragging = _l[1];
|
|
@@ -43,6 +44,34 @@ var GridItem = function (_a) {
|
|
|
43
44
|
ref: elementRef,
|
|
44
45
|
box: 'border-box',
|
|
45
46
|
}, [isDragging, isResizing]), _r = _q.width, width = _r === void 0 ? 0 : _r, _s = _q.height, height = _s === void 0 ? 0 : _s, _t = _q.clientHeight, clientHeight = _t === void 0 ? 0 : _t, _u = _q.scrollHeight, scrollHeight = _u === void 0 ? 0 : _u, textContentHeight = _q.contentHeight;
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
var _a;
|
|
49
|
+
if (!((_a = child.props.className) === null || _a === void 0 ? void 0 : _a.includes('react-grid-item-selected'))) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (!elementRef.current || !props.onContentSizeChange) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
console.log(elementRef.current);
|
|
56
|
+
var observer = new ResizeObserver(function (_a) {
|
|
57
|
+
var _b, _c, _d, _e;
|
|
58
|
+
var entry = _a[0];
|
|
59
|
+
var newClientHeight = entry.target.clientHeight;
|
|
60
|
+
var newClientWidth = entry.target.clientWidth;
|
|
61
|
+
var _f = entry.target, clientTop = _f.clientTop, clientLeft = _f.clientLeft;
|
|
62
|
+
var containerHeight = (_c = (_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight) !== null && _c !== void 0 ? _c : 0;
|
|
63
|
+
var containerWidth = (_e = (_d = elementRef.current) === null || _d === void 0 ? void 0 : _d.clientWidth) !== null && _e !== void 0 ? _e : 0;
|
|
64
|
+
if (newClientHeight < containerHeight && newClientWidth < containerWidth) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var _g = calcWH(getPositionParams(), { width: newClientWidth, height: newClientHeight }, x, y, 'se', props.w, props.h), w = _g.w, h = _g.h;
|
|
68
|
+
props.onContentSizeChange(props.i, { x: x, y: y, w: w, h: h });
|
|
69
|
+
});
|
|
70
|
+
observer.observe(elementRef.current.children[0].children[0].children[0], { box: 'border-box' });
|
|
71
|
+
return function () {
|
|
72
|
+
observer.disconnect();
|
|
73
|
+
};
|
|
74
|
+
}, [scrollHeight, props.i, props.w, props.h, x, y, child.props.className]);
|
|
46
75
|
// const moveDroppingItem = (prevProps: GridItemProps) => {
|
|
47
76
|
// const { droppingPosition } = props;
|
|
48
77
|
// if (!droppingPosition) return;
|
|
@@ -133,8 +162,6 @@ var GridItem = function (_a) {
|
|
|
133
162
|
Math.min(maxes.width, containerWidth),
|
|
134
163
|
Math.min(maxes.height, Infinity),
|
|
135
164
|
];
|
|
136
|
-
console.log("from mixin: ".concat(className), textContentHeight);
|
|
137
|
-
console.log('prop value: ', placeholderHeight);
|
|
138
165
|
return (_jsx(Resizable, { draggableOpts: {
|
|
139
166
|
disabled: !isResizable,
|
|
140
167
|
}, className: isResizable ? undefined : "react-resizable-hide", width: position.width, height: position.height, top: position.top, left: position.left, minConstraints: minConstraints, maxConstraints: maxConstraints, onResizeStop: onResizeStop, onResizeStart: onResizeStart, onResize: onResize, transformScale: transformScale, resizeHandles: props.resizeHandles, handle: resizeHandle, children: child }));
|
|
@@ -365,7 +392,6 @@ var GridItem = function (_a) {
|
|
|
365
392
|
if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-HEIGHT') {
|
|
366
393
|
callbackData.size.height = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height;
|
|
367
394
|
}
|
|
368
|
-
console.log(shouldBlock);
|
|
369
395
|
if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-WIDTH') {
|
|
370
396
|
callbackData.size.width = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width;
|
|
371
397
|
}
|
|
@@ -440,7 +466,6 @@ var GridItem = function (_a) {
|
|
|
440
466
|
dragging: dragging,
|
|
441
467
|
resizing: resizing,
|
|
442
468
|
}, colWidth);
|
|
443
|
-
var child = React.Children.only(children);
|
|
444
469
|
var newChild = React.cloneElement(child, {
|
|
445
470
|
key: i,
|
|
446
471
|
ref: elementRef,
|
|
@@ -75,6 +75,7 @@ export type GridItemProps = {
|
|
|
75
75
|
onResize?: ResizeGridItemCallback<GridResizeEvent>;
|
|
76
76
|
onResizeStart?: ResizeGridItemCallback<GridResizeEvent>;
|
|
77
77
|
onResizeStop?: ResizeGridItemCallback<GridResizeEvent>;
|
|
78
|
+
onContentSizeChange?: any;
|
|
78
79
|
isHiddenVisibility?: boolean;
|
|
79
80
|
customColWidth?: number;
|
|
80
81
|
};
|
|
@@ -266,6 +266,20 @@ var ReactGridLayout = function (_a) {
|
|
|
266
266
|
node: node,
|
|
267
267
|
});
|
|
268
268
|
};
|
|
269
|
+
// NOTE: 임시
|
|
270
|
+
var onContentSizeChange = function (i, pos) {
|
|
271
|
+
var _a = withLayoutItem(layout, i, function (l) {
|
|
272
|
+
l.w = pos.w;
|
|
273
|
+
l.h = pos.h;
|
|
274
|
+
l.x = pos.x;
|
|
275
|
+
l.y = pos.y;
|
|
276
|
+
return l;
|
|
277
|
+
}), newLayout = _a[0], l = _a[1];
|
|
278
|
+
if (!l) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
setLayout(newLayout);
|
|
282
|
+
};
|
|
269
283
|
var onResizeHandler = function (i, w, h, _a, x, y) {
|
|
270
284
|
var e = _a.e, node = _a.node;
|
|
271
285
|
var _b = withLayoutItem(layout, i, function (l) {
|
|
@@ -378,7 +392,7 @@ var ReactGridLayout = function (_a) {
|
|
|
378
392
|
: !l.static && isResizable;
|
|
379
393
|
var resizeHandlesOptions = l.resizeHandles || resizeHandles;
|
|
380
394
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
381
|
-
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, 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, children: child }, l.i));
|
|
395
|
+
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, children: child }, l.i));
|
|
382
396
|
};
|
|
383
397
|
var onDragOverHandler = function (e) {
|
|
384
398
|
var _a;
|