publ-echo 0.0.59 → 0.0.61

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.
@@ -42,7 +42,7 @@ var GridItem = function (_a) {
42
42
  var _q = useResizeObserver({
43
43
  ref: elementRef,
44
44
  box: 'border-box',
45
- }, [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.textContentHeight, myHeightRef = _q.myHeightRef;
45
+ }, [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.textContentHeight;
46
46
  // const moveDroppingItem = (prevProps: GridItemProps) => {
47
47
  // const { droppingPosition } = props;
48
48
  // if (!droppingPosition) return;
@@ -133,7 +133,7 @@ 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: ', textContentHeight);
136
+ console.log("from mixin: ".concat(className), textContentHeight);
137
137
  console.log('prop value: ', placeholderHeight);
138
138
  return (_jsx(Resizable, { draggableOpts: {
139
139
  disabled: !isResizable,
@@ -331,16 +331,13 @@ var GridItem = function (_a) {
331
331
  // }
332
332
  // onResizeHandler(e, callbackData, "onResize");
333
333
  // }, [textContentHeight])
334
- var onResize = function (e, callbackData) {
335
- var _a;
334
+ var onResize = function (e, callbackData, gridItemHeight) {
336
335
  setIsResizing(true);
337
- var _b = getDirectionOfMouseEvent(e), dirX = _b.dirX, dirY = _b.dirY;
338
- var myh = (_a = myHeightRef.current) === null || _a === void 0 ? void 0 : _a.myHeight;
339
- console.log('myh: ', myh);
336
+ var _a = getDirectionOfMouseEvent(e), dirX = _a.dirX, dirY = _a.dirY;
340
337
  var shouldBlock = shouldBlockResize({
341
338
  handle: callbackData.handle,
342
339
  direction: dirY,
343
- contentHeight: myh,
340
+ contentHeight: gridItemHeight,
344
341
  gridItemHeight: callbackData.size.height,
345
342
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
346
343
  initialHeight: shouldAutoShrink.current.initialHeight,
@@ -353,17 +350,17 @@ var GridItem = function (_a) {
353
350
  handle: callbackData.handle,
354
351
  dirX: dirX,
355
352
  dirY: dirY,
356
- contentHeight: myh,
353
+ contentHeight: gridItemHeight,
357
354
  gridItemHeight: callbackData.size.height,
358
355
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
359
356
  initialHeight: shouldAutoShrink.current.initialHeight
360
357
  });
361
358
  console.log(shouldResize);
362
359
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK') {
363
- callbackData.size.height = myh;
360
+ callbackData.size.height = gridItemHeight;
364
361
  }
365
362
  if (shouldResize === 'EXPAND') {
366
- callbackData.size.height = myh;
363
+ callbackData.size.height = gridItemHeight;
367
364
  shouldAutoShrink.current.shouldAutoShrink = true;
368
365
  // NOTE: 배포전에 무조건 변경
369
366
  if (callbackData.handle === 'nw') {
@@ -374,7 +371,7 @@ var GridItem = function (_a) {
374
371
  }
375
372
  }
376
373
  if (shouldResize === 'SHRINK') {
377
- callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, myh);
374
+ callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, gridItemHeight);
378
375
  // NOTE: 배포전에 무조건 변경
379
376
  if (callbackData.handle === 'nw') {
380
377
  callbackData.handle = 'sw';
@@ -450,6 +447,9 @@ var GridItem = function (_a) {
450
447
  }),
451
448
  style: __assign(__assign(__assign({}, props.style), child.props.style), createStyle(pos)),
452
449
  });
450
+ if (className === 'placeholder') {
451
+ return newChild;
452
+ }
453
453
  newChild = mixinResizable(newChild, pos, isResizable, textContentHeight !== null && textContentHeight !== void 0 ? textContentHeight : 0);
454
454
  newChild = mixinDraggable(newChild, isDraggable);
455
455
  return newChild;
@@ -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,11 +47,12 @@ var Resizable = function (_a) {
46
47
  ne: useRef(null),
47
48
  nw: useRef(null),
48
49
  });
49
- // const elementRef = useRef<HTMLDivElement>(null);
50
- // const { textContentHeight, myHeightRef } = useResizeObserver({
51
- // ref: elementRef,
52
- // box: 'border-box',
53
- // } ,[])
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');
54
56
  var startPosition = useRef(null);
55
57
  var startSize = useRef(null);
56
58
  var lastHandleRect = null;
@@ -131,8 +133,8 @@ var Resizable = function (_a) {
131
133
  }
132
134
  return [newTop, newLeft];
133
135
  };
134
- var resizeHandler = function (handlerName, handleAxis) {
135
- return function (e, _a) {
136
+ var resizeHandler = function (handlerName, handleAxis, textContentHeight) {
137
+ return function (e, _a, textContent) {
136
138
  var _b, _c;
137
139
  var _d, _e, _f, _g, _h, _j;
138
140
  var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
@@ -189,7 +191,7 @@ var Resizable = function (_a) {
189
191
  var cb = typeof props[handlerName] === "function" ? props[handlerName] : null;
190
192
  var isCbSkipped = handlerName === "onResize" && !isDimensionsChanged;
191
193
  if (cb && !isCbSkipped) {
192
- 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);
193
195
  }
194
196
  if (handlerName === "onResizeStop") {
195
197
  startPosition.current = null;
@@ -214,7 +216,7 @@ var Resizable = function (_a) {
214
216
  React.Children.map(children.props.children, function (child) { return child; })
215
217
  ], resizeHandles.map(function (handleAxis) {
216
218
  var ref = (handleRefs === null || handleRefs === void 0 ? void 0 : handleRefs.current) && handleRefs.current[handleAxis];
217
- 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)));
218
220
  }), true) }));
219
221
  };
220
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,24 +79,27 @@ 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
- var hasChanged = previousSize.current.width !== newWidth ||
83
- previousSize.current.height !== newHeight ||
84
- previousSize.current.scrollHeight !== newScrollHeight ||
85
- previousSize.current.clientHeight !== newClientHeight ||
86
- previousSize.current.textContentHeight !== newTextContentHeight;
87
- if (hasChanged) {
88
- var newSize = { width: newWidth, height: newHeight, scrollHeight: newScrollHeight, clientHeight: newClientHeight, textContentHeight: newTextContentHeight };
89
- previousSize.current = newSize;
90
- if (onResize === null || onResize === void 0 ? void 0 : onResize.current) {
91
- onResize.current(newSize);
92
- }
93
- else {
94
- if (isMounted()) {
95
- console.log('set- new -size');
96
- setSize(newSize);
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 () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",