publ-echo 0.0.71 → 0.0.73

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,8 +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;
35
- console.log(i, 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, activeContentObserver = props.activeContentObserver;
36
35
  var shouldAutoShrink = useRef({ shouldAutoShrink: false, initialHeight: 0 });
37
36
  var _k = useState(), resizing = _k[0], setResizing = _k[1];
38
37
  var _l = useState(), dragging = _l[0], setDragging = _l[1];
@@ -40,10 +39,7 @@ var GridItem = function (_a) {
40
39
  var _o = useState(false), isDragging = _o[0], setIsDragging = _o[1];
41
40
  var _p = useState(false), isResizing = _p[0], setIsResizing = _p[1];
42
41
  var elementRef = useRef(null);
43
- var _q = useResizeObserver([isDragging, isResizing]), contentHeight = _q.contentHeight, contentWidth = _q.contentWidth, gridItemHeight = _q.gridItemHeight, gridItemWidth = _q.gridItemWidth;
44
- if (activeResizeObserver) {
45
- console.log('h,w: ', contentHeight, contentWidth);
46
- }
42
+ var _q = useResizeObserver([isDragging, isResizing]), gridItemHeight = _q.gridItemHeight, gridItemWidth = _q.gridItemWidth;
47
43
  useEffect(function () {
48
44
  if (isDragging || isResizing) {
49
45
  return;
@@ -163,7 +159,7 @@ var GridItem = function (_a) {
163
159
  ];
164
160
  return (_jsx(Resizable, { draggableOpts: {
165
161
  disabled: !isResizable,
166
- }, 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 }));
162
+ }, 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, placeholderObserver: activeResizeObserver, children: child }));
167
163
  };
168
164
  /**
169
165
  * onDragStart event handler
@@ -299,23 +295,24 @@ var GridItem = function (_a) {
299
295
  // NOTE: 확인필요
300
296
  shouldAutoShrink.current.initialHeight = gridItemHeight;
301
297
  };
302
- var onResize = function (e, callbackData) {
303
- var _a;
298
+ var onResize = function (e, callbackData, contentSize) {
299
+ var _a, _b, _c, _d, _e, _f, _g, _h;
300
+ console.log(contentSize);
304
301
  setIsResizing(true);
305
- var _b = getDirectionOfMouseEvent(e), dirX = _b.dirX, dirY = _b.dirY;
302
+ var _j = getDirectionOfMouseEvent(e), dirX = _j.dirX, dirY = _j.dirY;
306
303
  var oneLetterSize = (_a = calculateCharacterWidthInDiv()) !== null && _a !== void 0 ? _a : 0;
307
304
  var shouldBlock = shouldBlockResize({
308
305
  handle: callbackData.handle,
309
306
  dirY: dirY,
310
307
  dirX: dirX,
311
- contentHeight: contentHeight,
308
+ contentHeight: (_b = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _b !== void 0 ? _b : 0,
312
309
  gridItemHeight: callbackData.size.height,
313
310
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
314
311
  initialHeight: shouldAutoShrink.current.initialHeight,
315
312
  colHeight: rowHeight,
316
313
  gridItemWidth: callbackData.size.width,
317
314
  colWidth: colWidth,
318
- contentWidth: contentWidth,
315
+ contentWidth: (_c = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width) !== null && _c !== void 0 ? _c : 0,
319
316
  oneLetterSize: oneLetterSize
320
317
  });
321
318
  if (resizing === null || resizing === void 0 ? void 0 : resizing.top) {
@@ -325,19 +322,19 @@ var GridItem = function (_a) {
325
322
  handle: callbackData.handle,
326
323
  dirX: dirX,
327
324
  dirY: dirY,
328
- contentHeight: contentHeight,
325
+ contentHeight: (_d = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _d !== void 0 ? _d : 0,
329
326
  gridItemHeight: callbackData.size.height,
330
327
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
331
328
  initialHeight: shouldAutoShrink.current.initialHeight
332
329
  });
333
330
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-HEIGHT') {
334
- callbackData.size.height = contentHeight;
331
+ callbackData.size.height = (_e = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _e !== void 0 ? _e : 0;
335
332
  }
336
333
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK-WIDTH') {
337
- callbackData.size.width = contentWidth;
334
+ callbackData.size.width = (_f = contentSize === null || contentSize === void 0 ? void 0 : contentSize.width) !== null && _f !== void 0 ? _f : 0;
338
335
  }
339
336
  if (shouldResize === 'EXPAND') {
340
- callbackData.size.height = contentHeight;
337
+ callbackData.size.height = (_g = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _g !== void 0 ? _g : 0;
341
338
  shouldAutoShrink.current.shouldAutoShrink = true;
342
339
  // NOTE: 배포전에 무조건 변경
343
340
  if (callbackData.handle === 'nw') {
@@ -348,7 +345,7 @@ var GridItem = function (_a) {
348
345
  }
349
346
  }
350
347
  if (shouldResize === 'SHRINK') {
351
- callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, contentHeight);
348
+ callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, (_h = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _h !== void 0 ? _h : 0);
352
349
  // NOTE: 배포전에 무조건 변경
353
350
  if (callbackData.handle === 'nw') {
354
351
  callbackData.handle = 'sw';
@@ -357,10 +354,6 @@ var GridItem = function (_a) {
357
354
  callbackData.handle = 'se';
358
355
  }
359
356
  }
360
- if (activeResizeObserver) {
361
- console.log('shouldResize', shouldResize);
362
- console.log('shouldBlock', shouldBlock);
363
- }
364
357
  onResizeHandler(e, callbackData, "onResize");
365
358
  };
366
359
  /**
@@ -432,6 +425,7 @@ var GridItem = function (_a) {
432
425
  if (className === 'placeholder') {
433
426
  return newChild;
434
427
  }
428
+ console.log(activeResizeObserver);
435
429
  newChild = mixinResizable(newChild, pos, isResizable);
436
430
  newChild = mixinDraggable(newChild, isDraggable);
437
431
  return newChild;
@@ -79,6 +79,7 @@ export type GridItemProps = {
79
79
  isHiddenVisibility?: boolean;
80
80
  customColWidth?: number;
81
81
  activeResizeObserver?: boolean;
82
+ activeContentObserver?: boolean;
82
83
  };
83
84
  export type GridItemDefaultProps = {
84
85
  className: string;
@@ -370,7 +370,9 @@ var ReactGridLayout = function (_a) {
370
370
  if (!item) {
371
371
  return null;
372
372
  }
373
- 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 }));
373
+ 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,
374
+ // NOTE: text CB만
375
+ activeContentObserver: true, children: item && item }));
374
376
  };
375
377
  /**
376
378
  * Given a grid item, set its style attributes & surround in a <Draggable>.
@@ -393,10 +395,6 @@ var ReactGridLayout = function (_a) {
393
395
  : !l.static && isResizable;
394
396
  var resizeHandlesOptions = l.resizeHandles || resizeHandles;
395
397
  var bounded = draggable && isBounded && l.isBounded !== false;
396
- console.log('------');
397
- console.log('i', l.i);
398
- console.log('child.props.className', child.props.className);
399
- console.log('------');
400
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));
401
399
  };
402
400
  var onDragOverHandler = function (e) {
@@ -31,11 +31,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
31
  };
32
32
  import { createElement as _createElement } from "react";
33
33
  import { jsx as _jsx } from "react/jsx-runtime";
34
- import React, { useRef } from "react";
34
+ 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
38
  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
+ var placeholderObserver = props.placeholderObserver;
39
40
  var handleRefs = useRef({
40
41
  s: useRef(null),
41
42
  n: useRef(null),
@@ -50,6 +51,31 @@ var Resizable = function (_a) {
50
51
  var startSize = useRef(null);
51
52
  var lastHandleRect = null;
52
53
  var slack = null;
54
+ var _j = useState({ width: 0, height: 0 }), content = _j[0], setContent = _j[1];
55
+ var placeholder = document.querySelector('.placeholder');
56
+ useEffect(function () {
57
+ var _a;
58
+ if (!placeholderObserver) {
59
+ return;
60
+ }
61
+ if (!placeholder) {
62
+ return;
63
+ }
64
+ var content = (_a = placeholder.children[0].children[0]) === null || _a === void 0 ? void 0 : _a.children[0];
65
+ if (!content) {
66
+ return;
67
+ }
68
+ var observer = new ResizeObserver(function (_a) {
69
+ var entry = _a[0];
70
+ var contentHeight = entry.target.clientHeight;
71
+ var contentWidth = entry.target.clientWidth;
72
+ setContent({ width: contentWidth, height: contentHeight });
73
+ });
74
+ observer.observe(content, { box: 'border-box' });
75
+ return function () {
76
+ observer.disconnect();
77
+ };
78
+ }, [placeholderObserver, placeholder]);
53
79
  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"]);
54
80
  var resetData = function () {
55
81
  lastHandleRect = slack = null;
@@ -209,7 +235,7 @@ var Resizable = function (_a) {
209
235
  React.Children.map(children.props.children, function (child) { return child; })
210
236
  ], resizeHandles.map(function (handleAxis) {
211
237
  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)));
238
+ return (_createElement(DraggableCore, __assign({}, draggableOpts, { nodeRef: ref, key: "resizableHandle-".concat(handleAxis), onStop: resizeHandler("onResizeStop", handleAxis), onStart: resizeHandler("onResizeStart", handleAxis), onDrag: resizeHandler("onResize", handleAxis, content) }), renderResizeHandle(handleAxis, ref)));
213
239
  }), true) }));
214
240
  };
215
241
  export default Resizable;
@@ -62,5 +62,6 @@ export type ResizableProps = {
62
62
  style?: CSSProperties;
63
63
  width: number;
64
64
  height: number;
65
+ placeholderObserver?: boolean;
65
66
  };
66
67
  export type ResizeHandleType = ReactElement<any> | ((resizeHandleAxis: ResizeHandleAxis, ref: Ref<HTMLElement>) => ReactElement<any>);
@@ -4,8 +4,6 @@ type Size = {
4
4
  gridItemHeight: number;
5
5
  scrollHeight: number;
6
6
  clientHeight: number;
7
- contentHeight: number;
8
- contentWidth: number;
9
7
  };
10
8
  type UseResizeObserverResult = Size & {
11
9
  myHeightRef: RefObject<{
@@ -25,8 +25,6 @@ var initialSize = {
25
25
  gridItemHeight: 0,
26
26
  scrollHeight: 0,
27
27
  clientHeight: 0,
28
- contentHeight: 0,
29
- contentWidth: 0,
30
28
  };
31
29
  export function useResizeObserver(deps) {
32
30
  var previousSize = useRef(initialSize);
@@ -51,11 +49,12 @@ export function useResizeObserver(deps) {
51
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;
52
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;
53
51
  refvalue.current.myHeight = newContentHeight;
54
- var newSize = { gridItemWidth: newWidth, gridItemHeight: newHeight, scrollHeight: newScrollHeight, clientHeight: newClientHeight, contentHeight: newContentHeight, contentWidth: newContentWidth };
52
+ var newSize = { gridItemWidth: newWidth, gridItemHeight: newHeight, scrollHeight: newScrollHeight, clientHeight: newClientHeight };
55
53
  previousSize.current = newSize;
56
54
  setSize(newSize);
57
55
  });
58
56
  observer.observe(placeholder.children[0], { box: 'border-box' });
57
+ console.log('target', placeholder.children[0]);
59
58
  return function () {
60
59
  observer.disconnect();
61
60
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",