publ-echo-test 0.0.261 → 0.0.263

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.
@@ -57,11 +57,8 @@ var Resizable = function (_a) {
57
57
  var shouldShrinkRef = useRef(false);
58
58
  var minWidth = useRef(0);
59
59
  var minHeight = useRef(0);
60
- // #################################################################
61
- // ## 여기가 `useLayoutEffect`에서 `ResizeObserver`로 변경된 부분입니다. ##
62
- // #################################################################
63
60
  useEffect(function () {
64
- var _a, _b, _c, _d;
61
+ var _a;
65
62
  if (!autoResize) {
66
63
  return;
67
64
  }
@@ -78,21 +75,63 @@ var Resizable = function (_a) {
78
75
  if (!placeholder) {
79
76
  return;
80
77
  }
81
- var target = (_c = (_b = (_a = placeholder.children[0]) === null || _a === void 0 ? void 0 : _a.children[0]) === null || _b === void 0 ? void 0 : _b.children[0]) !== null && _c !== void 0 ? _c : (_d = placeholder.children[0]) === null || _d === void 0 ? void 0 : _d.children[0];
82
- if (!target) {
78
+ var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
79
+ var isContentsList = target.id === "contentslist-box";
80
+ if (isContentsList) {
81
+ return;
82
+ }
83
+ if (target.clientHeight && !isContentsList) {
84
+ minHeight.current = target.clientHeight;
85
+ }
86
+ // target.clientHeight -> 실제 "노드"의 height. (gridItem아닌)
87
+ if (target.clientHeight > elementRef.current.clientHeight) {
88
+ extendedHeightRef.current = target.clientHeight;
89
+ shouldShrinkRef.current = true;
90
+ }
91
+ else {
92
+ extendedHeightRef.current = null;
93
+ }
94
+ if (shouldShrinkRef.current &&
95
+ target.clientHeight < elementRef.current.clientHeight) {
96
+ minHeight.current = target.clientHeight;
97
+ }
98
+ var minWidthStyle = target.computedStyleMap().get("min-width");
99
+ if (typeof minWidthStyle.value === "number" && margin && colWidth) {
100
+ var minWidthBase = minWidthStyle.value;
101
+ var minColWidth = (minWidthBase + margin[0]) / (colWidth + margin[0]);
102
+ var minW = Math.ceil(minColWidth);
103
+ var minWidthPx = minW * colWidth + (minW - 1) * margin[0];
104
+ minWidth.current = Math.round(minWidthPx);
105
+ }
106
+ }, [isResizing, autoResize, children, elementRef]);
107
+ useEffect(function () {
108
+ if (!autoResize) {
83
109
  return;
84
110
  }
85
- // 크기를 측정하고 제약 조건을 설정하는 로직을 함수로 분리
86
- var measureAndSetConstraints = function () {
111
+ if (!isResizing) {
112
+ extendedHeightRef.current = null;
113
+ minWidth.current = 0;
114
+ shouldShrinkRef.current = false;
115
+ return;
116
+ }
117
+ if (!elementRef.current) {
118
+ return;
119
+ }
120
+ setTimeout(function () {
121
+ var _a, _b;
122
+ var placeholder = document.querySelector(".placeholder");
123
+ if (!placeholder) {
124
+ return;
125
+ }
126
+ var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
87
127
  var oneComposition = target.querySelector(".composition-container");
88
128
  var isContentsList = target.id === "contentslist-box";
89
- if (isContentsList && !oneComposition)
129
+ if (!isContentsList || !oneComposition) {
90
130
  return;
91
- if (target.clientHeight && !isContentsList) {
92
- minHeight.current = target.clientHeight;
93
131
  }
94
132
  if (isContentsList && oneComposition) {
95
133
  var minCellWidth = 10;
134
+ var minColHeight = 11;
96
135
  var numberOfItems = Number(target.getAttribute("data-number-of-items"));
97
136
  var numberOfColumns = Number(target.getAttribute("data-number-of-columns"));
98
137
  var rowGap = Number(target.getAttribute("data-row-gap"));
@@ -100,72 +139,59 @@ var Resizable = function (_a) {
100
139
  var insetTop = Number(target.getAttribute("data-inset-top"));
101
140
  var insetBottom = Number(target.getAttribute("data-inset-bottom"));
102
141
  var compositionCols = Number(oneComposition.getAttribute("data-cols"));
103
- var oneCompositionMinWidth = minCellWidth * compositionCols + 20;
142
+ var compositionRows = Number(oneComposition.getAttribute("data-rows"));
143
+ var oneCompositionMinWidth = minCellWidth * compositionCols + 20; /* 20px padding */
144
+ // let oneCompositionMinHeight =
145
+ // minColHeight * compositionRows + 20; /* 20px padding */
104
146
  var contentsWrapper = placeholder.querySelector(".cb-contentslist-wrapper");
105
147
  if (contentsWrapper) {
148
+ var wrapperH = contentsWrapper.clientHeight;
106
149
  var tempCompositionH = oneComposition.clientHeight;
150
+ console.log("tempCompositionH", tempCompositionH);
151
+ console.log("parentH", (_b = oneComposition.parentElement) === null || _b === void 0 ? void 0 : _b.clientHeight);
107
152
  var CompositionBGwrapperPaddingT = Number(oneComposition.getAttribute("data-wrapper-paddingT"));
108
153
  var CompositionBGwrapperPaddingB = Number(oneComposition.getAttribute("data-wrapper-paddingB"));
109
- var oneCompositionMinHeight = tempCompositionH +
110
- CompositionBGwrapperPaddingT +
111
- CompositionBGwrapperPaddingB;
112
- var styles = getComputedStyle(target);
113
- var paddingLR = parseFloat(styles.paddingLeft) + parseFloat(styles.paddingRight);
114
- var paddingTB = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom);
115
- minWidth.current =
116
- oneCompositionMinWidth * numberOfColumns +
154
+ if (tempCompositionH > wrapperH) {
155
+ var oneCompositionMinHeight = tempCompositionH +
156
+ CompositionBGwrapperPaddingT +
157
+ CompositionBGwrapperPaddingB;
158
+ var styles = getComputedStyle(target);
159
+ var paddingL = parseFloat(styles.paddingLeft);
160
+ var paddingR = parseFloat(styles.paddingRight);
161
+ var paddingT = parseFloat(styles.paddingTop);
162
+ var paddingB = parseFloat(styles.paddingBottom);
163
+ var paddingLR = paddingL + paddingR;
164
+ var paddingTB = paddingT + paddingB;
165
+ var listMinWidth = oneCompositionMinWidth * numberOfColumns +
117
166
  (numberOfColumns - 1) * columnGap +
118
167
  paddingLR;
119
- var numberOfRows = Math.ceil(numberOfItems / numberOfColumns);
120
- minHeight.current =
121
- oneCompositionMinHeight * numberOfRows +
168
+ var numberOfRows = Math.ceil(numberOfItems / numberOfColumns);
169
+ var listMinHeight = oneCompositionMinHeight * numberOfRows +
122
170
  (numberOfRows - 1) * rowGap +
123
171
  paddingTB +
124
172
  insetTop +
125
173
  insetBottom;
174
+ console.log("oneCompositionMinHeight", oneCompositionMinHeight);
175
+ console.log("listMinHeight", listMinHeight);
176
+ // minWidth.current = listMinWidth;
177
+ // minHeight.current = listMinHeight;
178
+ return;
179
+ }
126
180
  }
127
181
  return;
128
182
  }
129
- if (target.clientHeight > elementRef.current.clientHeight) {
130
- extendedHeightRef.current = target.clientHeight;
131
- shouldShrinkRef.current = true;
132
- }
133
- else {
134
- extendedHeightRef.current = null;
135
- }
136
- if (shouldShrinkRef.current &&
137
- target.clientHeight < elementRef.current.clientHeight) {
138
- minHeight.current = target.clientHeight;
139
- }
140
- var minWidthStyle = target
141
- .computedStyleMap()
142
- .get("min-width");
143
- if (typeof (minWidthStyle === null || minWidthStyle === void 0 ? void 0 : minWidthStyle.value) === "number" && margin && colWidth) {
144
- var minWidthBase = minWidthStyle.value;
145
- var minColWidth = (minWidthBase + margin[0]) / (colWidth + margin[0]);
146
- var minW = Math.ceil(minColWidth);
147
- minWidth.current = Math.round(minW * colWidth + (minW - 1) * margin[0]);
148
- }
149
- };
150
- // ResizeObserver를 생성하고, target 요소의 크기 변경을 감지
151
- var observer = new ResizeObserver(function () {
152
- measureAndSetConstraints();
153
- });
154
- observer.observe(target);
155
- // 초기 렌더링 시점에도 한번 실행하여 초기값을 설정
156
- measureAndSetConstraints();
157
- // 클린업 함수: 컴포넌트가 언마운트되거나 의존성이 변경될 때 observer 연결을 해제
158
- return function () {
159
- observer.disconnect();
160
- };
161
- }, [isResizing, autoResize, children, elementRef, colWidth, margin]);
183
+ }, 0);
184
+ }, [isResizing, autoResize, children, elementRef]);
162
185
  var resetData = function () {
163
186
  lastHandleRectRef.current = null;
164
187
  slack.current = null;
165
188
  };
189
+ // NOTE - 최소 또는 최대 제약 조건 width와 height 계산, 비율 고정 계산
166
190
  var checkConstraints = function (width, height) {
167
191
  var _a;
168
- // ... (이하 동일)
192
+ if (!minConstraints && !maxConstraints && !lockAspectRatio) {
193
+ return [width, height];
194
+ }
169
195
  if (lockAspectRatio) {
170
196
  var ratio = props.width / props.height;
171
197
  var deltaWidth = width - props.width;
@@ -266,7 +292,19 @@ var Resizable = function (_a) {
266
292
  return;
267
293
  var axisV = handleAxis[0];
268
294
  var axisH = handleAxis[handleAxis.length - 1];
269
- lastHandleRectRef.current = node.getBoundingClientRect();
295
+ var handleRect = node.getBoundingClientRect();
296
+ // if (lastHandleRectRef.current !== null) {
297
+ // if (axisH === "w") {
298
+ // const deltaLeftSinceLast = handleRect.left - lastHandleRectRef.current.left;
299
+ // console.log('delta, :', deltaLeftSinceLast);
300
+ // deltaX += deltaLeftSinceLast;
301
+ // }
302
+ // if (axisV === "n") {
303
+ // const deltaTopSinceLast = handleRect.top - lastHandleRectRef.current.top;
304
+ // deltaY += deltaTopSinceLast;
305
+ // }
306
+ // }
307
+ lastHandleRectRef.current = handleRect;
270
308
  if (axisH === "w") {
271
309
  deltaX = -deltaX;
272
310
  }
@@ -313,6 +351,7 @@ var Resizable = function (_a) {
313
351
  return React.cloneElement(handle, props);
314
352
  };
315
353
  return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className : "react-resizable"), children: __spreadArray([
354
+ // ...children.props.children,
316
355
  React.Children.map(children.props.children, function (child) { return child; })
317
356
  ], resizeHandles.map(function (handleAxis) {
318
357
  var ref = (handleRefs === null || handleRefs === void 0 ? void 0 : handleRefs.current) && handleRefs.current[handleAxis];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.261",
3
+ "version": "0.0.263",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",