publ-echo 0.0.56 → 0.0.58

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;
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;
46
46
  // const moveDroppingItem = (prevProps: GridItemProps) => {
47
47
  // const { droppingPosition } = props;
48
48
  // if (!droppingPosition) return;
@@ -275,16 +275,70 @@ var GridItem = function (_a) {
275
275
  * @param {ResizeEventType} e event data
276
276
  * @param {Object} callbackData an object with node and size information
277
277
  */
278
+ // const onResizeCallback = useCallback((
279
+ // e:ResizeEventType,
280
+ // callbackData:ResizeCallbackData
281
+ // ) => {
282
+ // setIsResizing(true);
283
+ // const { dirX, dirY } = getDirectionOfMouseEvent(e as MouseEvent);
284
+ // const shouldBlock = shouldBlockResize({
285
+ // handle: callbackData.handle,
286
+ // direction: dirY!,
287
+ // contentHeight: textContentHeight!,
288
+ // gridItemHeight: callbackData.size.height,
289
+ // shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
290
+ // initialHeight: shouldAutoShrink.current.initialHeight,
291
+ // colHeight: rowHeight as number
292
+ // })
293
+ // if (resizing?.top) {
294
+ // callbackData.size.top = resizing?.top
295
+ // }
296
+ // const shouldResize = shouldAutoResize({
297
+ // handle: callbackData.handle,
298
+ // dirX: dirX!,
299
+ // dirY: dirY!,
300
+ // contentHeight: textContentHeight!,
301
+ // gridItemHeight: callbackData.size.height,
302
+ // shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
303
+ // initialHeight: shouldAutoShrink.current.initialHeight
304
+ // })
305
+ // console.log(shouldResize)
306
+ // if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK') {
307
+ // callbackData.size.height = textContentHeight!;
308
+ // }
309
+ // if (shouldResize === 'EXPAND') {
310
+ // callbackData.size.height = textContentHeight!;
311
+ // shouldAutoShrink.current.shouldAutoShrink = true;
312
+ // // NOTE: 배포전에 무조건 변경
313
+ // if (callbackData.handle === 'nw') {
314
+ // callbackData.handle = 'w';
315
+ // }
316
+ // if (callbackData.handle === 'ne') {
317
+ // callbackData.handle = 'se';
318
+ // }
319
+ // }
320
+ // if (shouldResize === 'SHRINK') {
321
+ // callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, textContentHeight!);
322
+ // // NOTE: 배포전에 무조건 변경
323
+ // if (callbackData.handle === 'nw') {
324
+ // callbackData.handle = 'sw'
325
+ // }
326
+ // if (callbackData.handle === 'ne') {
327
+ // callbackData.handle = 'se'
328
+ // }
329
+ // }
330
+ // onResizeHandler(e, callbackData, "onResize");
331
+ // }, [textContentHeight])
278
332
  var onResize = function (e, callbackData) {
279
- var _a, _b;
333
+ var _a;
280
334
  setIsResizing(true);
281
- var _c = getDirectionOfMouseEvent(e), dirX = _c.dirX, dirY = _c.dirY;
282
- var contentHeight = (_b = (_a = callbackData.node.parentNode) === null || _a === void 0 ? void 0 : _a.children[0].children[0].children[0].clientHeight) !== null && _b !== void 0 ? _b : 0;
283
- console.log(contentHeight);
335
+ var _b = getDirectionOfMouseEvent(e), dirX = _b.dirX, dirY = _b.dirY;
336
+ var myh = (_a = myHeightRef.current) === null || _a === void 0 ? void 0 : _a.myHeight;
337
+ console.log('myh: ', myh);
284
338
  var shouldBlock = shouldBlockResize({
285
339
  handle: callbackData.handle,
286
340
  direction: dirY,
287
- contentHeight: contentHeight,
341
+ contentHeight: myh,
288
342
  gridItemHeight: callbackData.size.height,
289
343
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
290
344
  initialHeight: shouldAutoShrink.current.initialHeight,
@@ -297,17 +351,17 @@ var GridItem = function (_a) {
297
351
  handle: callbackData.handle,
298
352
  dirX: dirX,
299
353
  dirY: dirY,
300
- contentHeight: contentHeight,
354
+ contentHeight: myh,
301
355
  gridItemHeight: callbackData.size.height,
302
356
  shouldAutoShrink: shouldAutoShrink.current.shouldAutoShrink,
303
357
  initialHeight: shouldAutoShrink.current.initialHeight
304
358
  });
305
359
  console.log(shouldResize);
306
360
  if (shouldResize !== 'EXPAND' && shouldBlock === 'BLOCK') {
307
- callbackData.size.height = contentHeight;
361
+ callbackData.size.height = myh;
308
362
  }
309
363
  if (shouldResize === 'EXPAND') {
310
- callbackData.size.height = contentHeight;
364
+ callbackData.size.height = myh;
311
365
  shouldAutoShrink.current.shouldAutoShrink = true;
312
366
  // NOTE: 배포전에 무조건 변경
313
367
  if (callbackData.handle === 'nw') {
@@ -318,7 +372,7 @@ var GridItem = function (_a) {
318
372
  }
319
373
  }
320
374
  if (shouldResize === 'SHRINK') {
321
- callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, contentHeight);
375
+ callbackData.size.height = Math.max(shouldAutoShrink.current.initialHeight, myh);
322
376
  // NOTE: 배포전에 무조건 변경
323
377
  if (callbackData.handle === 'nw') {
324
378
  callbackData.handle = 'sw';
@@ -13,7 +13,11 @@ type UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {
13
13
  onResize?: ResizeHandler;
14
14
  box?: BoxOptions;
15
15
  };
16
- type UseResizeObserverResult = Size;
16
+ type UseResizeObserverResult = Size & {
17
+ myHeightRef: RefObject<{
18
+ myHeight: number;
19
+ }>;
20
+ };
17
21
  /**
18
22
  * Custom hook for observing the size of an element using the ResizeObserver API.
19
23
  *
@@ -18,7 +18,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
18
  }
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
- import { useEffect, useRef, useState } from 'react';
21
+ import { useLayoutEffect, useRef, useState } from 'react';
22
22
  import { useIsMounted } from './useIsMounted';
23
23
  var initialSize = {
24
24
  width: undefined,
@@ -50,11 +50,12 @@ var initialSize = {
50
50
  export function useResizeObserver(options, deps) {
51
51
  var ref = options.ref, _a = options.box, box = _a === void 0 ? 'content-box' : _a;
52
52
  var _b = useState(initialSize), size = _b[0], setSize = _b[1];
53
+ var refvalue = useRef({ myHeight: 0 });
53
54
  var isMounted = useIsMounted();
54
55
  var previousSize = useRef(__assign({}, initialSize));
55
56
  var onResize = useRef(undefined);
56
57
  onResize.current = options === null || options === void 0 ? void 0 : options.onResize;
57
- useEffect(function () {
58
+ useLayoutEffect(function () {
58
59
  if (!(ref === null || ref === void 0 ? void 0 : ref.current))
59
60
  return;
60
61
  var placeholder = document.querySelector('.placeholder');
@@ -77,6 +78,7 @@ export function useResizeObserver(options, deps) {
77
78
  var newScrollHeight = entry.target.scrollHeight;
78
79
  var newClientHeight = entry.target.clientHeight;
79
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
+ refvalue.current.myHeight = newTextContentHeight;
80
82
  var hasChanged = previousSize.current.width !== newWidth ||
81
83
  previousSize.current.height !== newHeight ||
82
84
  previousSize.current.scrollHeight !== newScrollHeight ||
@@ -101,7 +103,7 @@ export function useResizeObserver(options, deps) {
101
103
  observer.disconnect();
102
104
  };
103
105
  }, __spreadArray([box, ref, isMounted], deps, true));
104
- return size;
106
+ return __assign(__assign({}, size), { myHeightRef: refvalue });
105
107
  }
106
108
  function extractSize(entry, box, sizeType) {
107
109
  if (!entry[box]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",