publ-echo 0.0.58 → 0.0.60
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.
|
@@ -116,7 +116,7 @@ var GridItem = function (_a) {
|
|
|
116
116
|
* @param {Object} position Position object (pixel values)
|
|
117
117
|
* @return {Element} Child wrapped in Resizable.
|
|
118
118
|
*/
|
|
119
|
-
var mixinResizable = function (child, position, isResizable) {
|
|
119
|
+
var mixinResizable = function (child, position, isResizable, placeholderHeight) {
|
|
120
120
|
var positionParams = getPositionParams();
|
|
121
121
|
// const maxWidth = calcGridItemPosition(
|
|
122
122
|
// positionParams,
|
|
@@ -133,6 +133,8 @@ var GridItem = function (_a) {
|
|
|
133
133
|
Math.min(maxes.width, containerWidth),
|
|
134
134
|
Math.min(maxes.height, Infinity),
|
|
135
135
|
];
|
|
136
|
+
console.log("from mixin: ".concat(className), textContentHeight);
|
|
137
|
+
console.log('prop value: ', placeholderHeight);
|
|
136
138
|
return (_jsx(Resizable, { draggableOpts: {
|
|
137
139
|
disabled: !isResizable,
|
|
138
140
|
}, 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 }));
|
|
@@ -329,10 +331,11 @@ var GridItem = function (_a) {
|
|
|
329
331
|
// }
|
|
330
332
|
// onResizeHandler(e, callbackData, "onResize");
|
|
331
333
|
// }, [textContentHeight])
|
|
332
|
-
var onResize = function (e, callbackData) {
|
|
334
|
+
var onResize = function (e, callbackData, gridItemHeight) {
|
|
333
335
|
var _a;
|
|
334
336
|
setIsResizing(true);
|
|
335
337
|
var _b = getDirectionOfMouseEvent(e), dirX = _b.dirX, dirY = _b.dirY;
|
|
338
|
+
console.log("%c ".concat(gridItemHeight), 'background: #222; color: #bada55');
|
|
336
339
|
var myh = (_a = myHeightRef.current) === null || _a === void 0 ? void 0 : _a.myHeight;
|
|
337
340
|
console.log('myh: ', myh);
|
|
338
341
|
var shouldBlock = shouldBlockResize({
|
|
@@ -448,7 +451,10 @@ var GridItem = function (_a) {
|
|
|
448
451
|
}),
|
|
449
452
|
style: __assign(__assign(__assign({}, props.style), child.props.style), createStyle(pos)),
|
|
450
453
|
});
|
|
451
|
-
|
|
454
|
+
if (className === 'placeholder') {
|
|
455
|
+
return newChild;
|
|
456
|
+
}
|
|
457
|
+
newChild = mixinResizable(newChild, pos, isResizable, textContentHeight !== null && textContentHeight !== void 0 ? textContentHeight : 0);
|
|
452
458
|
newChild = mixinDraggable(newChild, isDraggable);
|
|
453
459
|
return newChild;
|
|
454
460
|
};
|
|
@@ -357,26 +357,6 @@ var ReactGridLayout = function (_a) {
|
|
|
357
357
|
}
|
|
358
358
|
return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z: activeDrag.z || 0, 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, children: item && item }));
|
|
359
359
|
};
|
|
360
|
-
var placeholder2 = function () {
|
|
361
|
-
if (!activeDrag)
|
|
362
|
-
return;
|
|
363
|
-
// {...activeDrag} is pretty slow, actually
|
|
364
|
-
var l = getLayoutItem(props.layout, String(activeDrag.i));
|
|
365
|
-
if (!l) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
// NOTE: toChildren changes key
|
|
369
|
-
// LINK: https://legacy.reactjs.org/docs/react-api.html
|
|
370
|
-
var items = React.Children.toArray(children);
|
|
371
|
-
var item = items.find(function (child) {
|
|
372
|
-
var originalKey = String(child.key).split(".$");
|
|
373
|
-
return originalKey[1] === l.i;
|
|
374
|
-
});
|
|
375
|
-
if (!item) {
|
|
376
|
-
return null;
|
|
377
|
-
}
|
|
378
|
-
return (_jsx(GridItem, { w: activeDrag.w, h: activeDrag.h, x: activeDrag.x, y: activeDrag.y, z: activeDrag.z || 0, 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, children: item && item }));
|
|
379
|
-
};
|
|
380
360
|
/**
|
|
381
361
|
* Given a grid item, set its style attributes & surround in a <Draggable>.
|
|
382
362
|
* @param {Element} child React element.
|
|
@@ -398,7 +378,7 @@ var ReactGridLayout = function (_a) {
|
|
|
398
378
|
: !l.static && isResizable;
|
|
399
379
|
var resizeHandlesOptions = l.resizeHandles || resizeHandles;
|
|
400
380
|
var bounded = draggable && isBounded && l.isBounded !== false;
|
|
401
|
-
return (_jsx(GridItem, { 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));
|
|
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));
|
|
402
382
|
};
|
|
403
383
|
var onDragOverHandler = function (e) {
|
|
404
384
|
var _a;
|
|
@@ -34,6 +34,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
34
34
|
import React, { useRef } from "react";
|
|
35
35
|
import DraggableCore from "../Draggable/DraggableCore";
|
|
36
36
|
import { cloneElement } from "./utils/cloneElement";
|
|
37
|
+
import { useResizeObserver } from "../hooks/useResizeobserver";
|
|
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, props = __rest(_a, ["children", "axis", "handleSize", "lockAspectRatio", "minConstraints", "maxConstraints", "resizeHandles", "transformScale"]);
|
|
39
40
|
var handleRefs = useRef({
|
|
@@ -46,6 +47,12 @@ var Resizable = function (_a) {
|
|
|
46
47
|
ne: useRef(null),
|
|
47
48
|
nw: useRef(null),
|
|
48
49
|
});
|
|
50
|
+
var elementRef = useRef({ isOkay: true });
|
|
51
|
+
var _j = useResizeObserver({
|
|
52
|
+
ref: elementRef,
|
|
53
|
+
box: 'border-box',
|
|
54
|
+
}, [props.onResize]), textContentHeight = _j.textContentHeight, myHeightRef = _j.myHeightRef;
|
|
55
|
+
console.log("%c ".concat(textContentHeight), 'background: #ff0000; color: #ffffff');
|
|
49
56
|
var startPosition = useRef(null);
|
|
50
57
|
var startSize = useRef(null);
|
|
51
58
|
var lastHandleRect = null;
|
|
@@ -126,8 +133,8 @@ var Resizable = function (_a) {
|
|
|
126
133
|
}
|
|
127
134
|
return [newTop, newLeft];
|
|
128
135
|
};
|
|
129
|
-
var resizeHandler = function (handlerName, handleAxis) {
|
|
130
|
-
return function (e, _a) {
|
|
136
|
+
var resizeHandler = function (handlerName, handleAxis, textContentHeight) {
|
|
137
|
+
return function (e, _a, textContent) {
|
|
131
138
|
var _b, _c;
|
|
132
139
|
var _d, _e, _f, _g, _h, _j;
|
|
133
140
|
var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
@@ -184,7 +191,7 @@ var Resizable = function (_a) {
|
|
|
184
191
|
var cb = typeof props[handlerName] === "function" ? props[handlerName] : null;
|
|
185
192
|
var isCbSkipped = handlerName === "onResize" && !isDimensionsChanged;
|
|
186
193
|
if (cb && !isCbSkipped) {
|
|
187
|
-
cb(e, { node: node, size: { width: width, height: height, top: top, left: left }, handle: handleAxis });
|
|
194
|
+
cb(e, { node: node, size: { width: width, height: height, top: top, left: left }, handle: handleAxis }, textContentHeight !== null && textContentHeight !== void 0 ? textContentHeight : -1);
|
|
188
195
|
}
|
|
189
196
|
if (handlerName === "onResizeStop") {
|
|
190
197
|
startPosition.current = null;
|
|
@@ -209,7 +216,7 @@ var Resizable = function (_a) {
|
|
|
209
216
|
React.Children.map(children.props.children, function (child) { return child; })
|
|
210
217
|
], resizeHandles.map(function (handleAxis) {
|
|
211
218
|
var ref = (handleRefs === null || handleRefs === void 0 ? void 0 : handleRefs.current) && handleRefs.current[handleAxis];
|
|
212
|
-
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)));
|
|
219
|
+
return (_createElement(DraggableCore, __assign({}, draggableOpts, { nodeRef: ref, key: "resizableHandle-".concat(handleAxis), onStop: resizeHandler("onResizeStop", handleAxis), onStart: resizeHandler("onResizeStart", handleAxis), onDrag: resizeHandler("onResize", handleAxis, textContentHeight) }), renderResizeHandle(handleAxis, ref)));
|
|
213
220
|
}), true) }));
|
|
214
221
|
};
|
|
215
222
|
export default Resizable;
|
|
@@ -49,7 +49,7 @@ export type ResizableProps = {
|
|
|
49
49
|
handle?: ResizeHandleType;
|
|
50
50
|
onResizeStop?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
51
51
|
onResizeStart?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
52
|
-
onResize?: (e: SyntheticEvent<any>, data: ResizeCallbackData) => any;
|
|
52
|
+
onResize?: (e: SyntheticEvent<any>, data: ResizeCallbackData, gridItemHeight?: number) => any;
|
|
53
53
|
handleSize?: [number, number];
|
|
54
54
|
lockAspectRatio?: boolean;
|
|
55
55
|
minConstraints?: [number, number];
|
|
@@ -79,30 +79,34 @@ export function useResizeObserver(options, deps) {
|
|
|
79
79
|
var newClientHeight = entry.target.clientHeight;
|
|
80
80
|
var newTextContentHeight = (_d = (_c = (_b = entry.target.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) === null || _c === void 0 ? void 0 : _c.clientHeight) !== null && _d !== void 0 ? _d : 0;
|
|
81
81
|
refvalue.current.myHeight = newTextContentHeight;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
// const hasChanged =
|
|
83
|
+
// previousSize.current.width !== newWidth ||
|
|
84
|
+
// previousSize.current.height !== newHeight ||
|
|
85
|
+
// previousSize.current.scrollHeight !== newScrollHeight ||
|
|
86
|
+
// previousSize.current.clientHeight !== newClientHeight ||
|
|
87
|
+
// previousSize.current.textContentHeight !== newTextContentHeight
|
|
88
|
+
var newSize = { width: newWidth, height: newHeight, scrollHeight: newScrollHeight, clientHeight: newClientHeight, textContentHeight: newTextContentHeight };
|
|
89
|
+
previousSize.current = newSize;
|
|
90
|
+
setSize(newSize);
|
|
91
|
+
// if (hasChanged) {
|
|
92
|
+
// const newSize: Size = { width: newWidth, height: newHeight, scrollHeight: newScrollHeight, clientHeight: newClientHeight, textContentHeight: newTextContentHeight }
|
|
93
|
+
// previousSize.current = newSize;
|
|
94
|
+
// if (onResize?.current) {
|
|
95
|
+
// onResize.current(newSize)
|
|
96
|
+
// } else {
|
|
97
|
+
// if (isMounted()) {
|
|
98
|
+
// console.log('set- new -size')
|
|
99
|
+
// setSize(newSize)
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
100
103
|
});
|
|
101
104
|
observer.observe(placeholder.children[0], { box: box });
|
|
102
105
|
return function () {
|
|
103
106
|
observer.disconnect();
|
|
104
107
|
};
|
|
105
108
|
}, __spreadArray([box, ref, isMounted], deps, true));
|
|
109
|
+
console.log('--SIZE FROM OBSERVER--', size.textContentHeight);
|
|
106
110
|
return __assign(__assign({}, size), { myHeightRef: refvalue });
|
|
107
111
|
}
|
|
108
112
|
function extractSize(entry, box, sizeType) {
|