publ-echo 0.0.63 → 0.0.64

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";
@@ -43,6 +43,30 @@ var GridItem = function (_a) {
43
43
  ref: elementRef,
44
44
  box: 'border-box',
45
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.contentHeight;
46
+ useEffect(function () {
47
+ if (!elementRef.current || !props.onContentSizeChange) {
48
+ return;
49
+ }
50
+ var observer = new ResizeObserver(function (_a) {
51
+ var _b, _c, _d, _e;
52
+ var entry = _a[0];
53
+ var newClientHeight = entry.target.clientHeight;
54
+ var newClientWidth = entry.target.clientWidth;
55
+ var _f = entry.target, clientTop = _f.clientTop, clientLeft = _f.clientLeft;
56
+ var containerHeight = (_c = (_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight) !== null && _c !== void 0 ? _c : 0;
57
+ var containerWidth = (_e = (_d = elementRef.current) === null || _d === void 0 ? void 0 : _d.clientWidth) !== null && _e !== void 0 ? _e : 0;
58
+ if (newClientHeight < containerHeight && newClientWidth < containerWidth) {
59
+ return;
60
+ }
61
+ var _g = calcWH(getPositionParams(), { width: newClientWidth, height: newClientHeight }, x, y, 'se', props.w, props.h), w = _g.w, h = _g.h;
62
+ props.onContentSizeChange(props.i, { x: x, y: y, w: w, h: h });
63
+ });
64
+ observer.observe(elementRef.current.children[0].children[0].children[0], { box: 'border-box' });
65
+ return function () {
66
+ observer.disconnect();
67
+ };
68
+ }, [scrollHeight, props]);
69
+ console.log(textContentHeight);
46
70
  // const moveDroppingItem = (prevProps: GridItemProps) => {
47
71
  // const { droppingPosition } = props;
48
72
  // if (!droppingPosition) return;
@@ -365,7 +389,6 @@ var GridItem = function (_a) {
365
389
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-HEIGHT') {
366
390
  callbackData.size.height = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height;
367
391
  }
368
- console.log(shouldBlock);
369
392
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-WIDTH') {
370
393
  callbackData.size.width = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width;
371
394
  }
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",