publ-echo-test 0.0.338 → 0.0.340

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,12 +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, { useEffect, useRef, } from 'react';
35
- import { cloneElement } from './utils/cloneElement';
36
- import { DraggableCore } from '../Draggable';
37
- import classNames from '../../external-lib/classnames';
34
+ import React, { useEffect, useRef, } from "react";
35
+ import { cloneElement } from "./utils/cloneElement";
36
+ import { DraggableCore } from "../Draggable";
37
+ import classNames from "../../external-lib/classnames";
38
38
  var Resizable = function (_a) {
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, isResizing = _a.isResizing, autoResize = _a.autoResize, colWidth = _a.colWidth, margin = _a.margin, props = __rest(_a, ["children", "axis", "handleSize", "lockAspectRatio", "minConstraints", "maxConstraints", "resizeHandles", "transformScale", "isResizing", "autoResize", "colWidth", "margin"]);
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, isResizing = _a.isResizing, autoResize = _a.autoResize, colWidth = _a.colWidth, margin = _a.margin, props = __rest(_a, ["children", "axis", "handleSize", "lockAspectRatio", "minConstraints", "maxConstraints", "resizeHandles", "transformScale", "isResizing", "autoResize", "colWidth", "margin"]);
40
40
  var handleRefs = useRef({
41
41
  s: useRef(null),
42
42
  n: useRef(null),
@@ -66,17 +66,22 @@ var Resizable = function (_a) {
66
66
  extendedHeightRef.current = null;
67
67
  minWidth.current = 0;
68
68
  shouldShrinkRef.current = false;
69
+ minHeight.current = 0;
69
70
  return;
70
71
  }
71
72
  if (!elementRef.current) {
72
73
  return;
73
74
  }
74
- var placeholder = document.querySelector('.placeholder');
75
+ var placeholder = document.querySelector(".placeholder");
75
76
  if (!placeholder) {
76
77
  return;
77
78
  }
78
79
  var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
79
- if (target.clientHeight) {
80
+ var isCCBLayoutbox = target.classList.contains("ccb-layout-box");
81
+ if (isCCBLayoutbox) {
82
+ return;
83
+ }
84
+ if (target.clientHeight && !isCCBLayoutbox) {
80
85
  minHeight.current = target.clientHeight;
81
86
  }
82
87
  // target.clientHeight -> 실제 "노드"의 height. (gridItem아닌)
@@ -91,8 +96,8 @@ var Resizable = function (_a) {
91
96
  target.clientHeight < elementRef.current.clientHeight) {
92
97
  minHeight.current = target.clientHeight;
93
98
  }
94
- var minWidthStyle = target.computedStyleMap().get('min-width');
95
- if (typeof minWidthStyle.value === 'number' && margin && colWidth) {
99
+ var minWidthStyle = target.computedStyleMap().get("min-width");
100
+ if (typeof minWidthStyle.value === "number" && margin && colWidth) {
96
101
  var minWidthBase = minWidthStyle.value;
97
102
  var minColWidth = (minWidthBase + margin[0]) / (colWidth + margin[0]);
98
103
  var minW = Math.ceil(minColWidth);
@@ -100,6 +105,96 @@ var Resizable = function (_a) {
100
105
  minWidth.current = Math.round(minWidthPx);
101
106
  }
102
107
  }, [isResizing, autoResize, children, elementRef]);
108
+ useEffect(function () {
109
+ if (!autoResize) {
110
+ return;
111
+ }
112
+ if (!isResizing) {
113
+ extendedHeightRef.current = null;
114
+ minWidth.current = 0;
115
+ shouldShrinkRef.current = false;
116
+ minHeight.current = 0;
117
+ return;
118
+ }
119
+ if (!elementRef.current) {
120
+ return;
121
+ }
122
+ setTimeout(function () {
123
+ var _a;
124
+ var placeholder = document.querySelector(".placeholder");
125
+ if (!placeholder) {
126
+ return;
127
+ }
128
+ var target = (_a = placeholder.children[0].children[0].children[0]) !== null && _a !== void 0 ? _a : placeholder.children[0].children[0];
129
+ // const oneComposition = target.querySelector(".composition-container");
130
+ var isCCBLayoutbox = target.classList.contains("ccb-layout-box");
131
+ var layoutBox = target.children[0];
132
+ var contentsWrapper = layoutBox.children[0];
133
+ var oneComposition = contentsWrapper.querySelector(".composition-container");
134
+ // const oneComposition =
135
+ // contentsWrapper.children[0].children[0].children[0].children[2];
136
+ if (!isCCBLayoutbox || !oneComposition) {
137
+ return;
138
+ }
139
+ if (isCCBLayoutbox && oneComposition) {
140
+ var minCellWidth = 10;
141
+ var numberOfItems = Number(target.getAttribute("data-number-of-items"));
142
+ var numberOfColumns = Number(target.getAttribute("data-number-of-columns"));
143
+ var rowGap = Number(target.getAttribute("data-row-gap"));
144
+ var columnGap = Number(target.getAttribute("data-column-gap"));
145
+ var insetTop = Number(target.getAttribute("data-inset-top"));
146
+ var insetBottom = Number(target.getAttribute("data-inset-bottom"));
147
+ var compositionCols = Number(oneComposition.getAttribute("data-cols"));
148
+ // const compositionRows = Number(
149
+ // oneComposition.getAttribute("data-rows")!
150
+ // );
151
+ var oneCompositionMinWidth = minCellWidth * compositionCols + 20; /* 20px padding */
152
+ // let oneCompositionMinHeight =
153
+ // minColHeight * compositionRows + 20; /* 20px padding */
154
+ // const contentsWrapper = placeholder.querySelector(
155
+ // ".cb-contentslist-wrapper"
156
+ // );
157
+ if (contentsWrapper) {
158
+ var gridWrapperInnerH = contentsWrapper.clientHeight;
159
+ var oneCompositionH = oneComposition.scrollHeight;
160
+ console.log("scrollHeight", oneCompositionH);
161
+ console.log("clientHeight", oneComposition.clientHeight);
162
+ console.log("gap", oneCompositionH - oneComposition.clientHeight);
163
+ var compositionBGwrapperPaddingT = Number(oneComposition.getAttribute("data-wrapper-paddingt"));
164
+ var compositionBGwrapperPaddingB = Number(oneComposition.getAttribute("data-wrapper-paddingb"));
165
+ var compositionBGwrapperPaddingL = Number(oneComposition.getAttribute("data-wrapper-paddingl"));
166
+ var compositionBGwrapperPaddingR = Number(oneComposition.getAttribute("data-wrapper-paddingr"));
167
+ var oneCompositionMinHeight = oneCompositionH +
168
+ compositionBGwrapperPaddingT +
169
+ compositionBGwrapperPaddingB;
170
+ var styles = getComputedStyle(target);
171
+ var paddingL = parseFloat(styles.paddingLeft);
172
+ var paddingR = parseFloat(styles.paddingRight);
173
+ var paddingT = parseFloat(styles.paddingTop);
174
+ var paddingB = parseFloat(styles.paddingBottom);
175
+ var paddingLR = paddingL + paddingR;
176
+ var paddingTB = paddingT + paddingB;
177
+ var compositionWrapperPaddingLR = (compositionBGwrapperPaddingL + compositionBGwrapperPaddingR) *
178
+ numberOfColumns;
179
+ var listMinWidth = oneCompositionMinWidth * numberOfColumns +
180
+ (numberOfColumns - 1) * columnGap +
181
+ paddingLR +
182
+ compositionWrapperPaddingLR;
183
+ var numberOfRows = Math.ceil(numberOfItems / numberOfColumns);
184
+ var gridWrapperTotalH = gridWrapperInnerH + insetTop + insetBottom;
185
+ var listMinHeight = oneCompositionMinHeight * numberOfRows +
186
+ (numberOfRows - 1) * rowGap +
187
+ paddingTB +
188
+ insetTop +
189
+ insetBottom;
190
+ if (listMinHeight > gridWrapperTotalH) {
191
+ minHeight.current = listMinHeight;
192
+ }
193
+ minWidth.current = listMinWidth;
194
+ }
195
+ }
196
+ }, 0);
197
+ }, [isResizing, autoResize, children, elementRef]);
103
198
  var resetData = function () {
104
199
  lastHandleRectRef.current = null;
105
200
  slack.current = null;
@@ -143,6 +238,7 @@ var Resizable = function (_a) {
143
238
  height = Math.min(maxConstraints[1], height);
144
239
  }
145
240
  slack.current = [slackW + (oldW - width), slackH + (oldH - height)];
241
+ console.log("minH", minHeight.current);
146
242
  return [width, height];
147
243
  };
148
244
  var checkTopLeft = function (deltaX, deltaY, top, left, width, height, handleAxis) {
@@ -157,28 +253,28 @@ var Resizable = function (_a) {
157
253
  var resizableLeft = startPosition.current.left + (startSize.current.width - width);
158
254
  var resizableTop = startPosition.current.top + (startSize.current.height - height);
159
255
  if (deltaX < 0) {
160
- if (handleAxis === 'nw' || handleAxis === 'w' || handleAxis === 'sw') {
256
+ if (handleAxis === "nw" || handleAxis === "w" || handleAxis === "sw") {
161
257
  if (currentSumOfLeftAndWidth > startSumOfLeftAndWidth) {
162
258
  newLeft = Math.min(left, resizableLeft);
163
259
  }
164
260
  }
165
261
  }
166
262
  if (deltaY < 0) {
167
- if (handleAxis === 'nw' || handleAxis === 'n' || handleAxis === 'ne') {
263
+ if (handleAxis === "nw" || handleAxis === "n" || handleAxis === "ne") {
168
264
  if (currentSumOfTopAndHeight > startSumOfTopAndHeight) {
169
265
  newTop = Math.min(top, resizableTop);
170
266
  }
171
267
  }
172
268
  }
173
269
  if (deltaX > 0) {
174
- if (handleAxis === 'nw' || handleAxis === 'w' || handleAxis === 'sw') {
270
+ if (handleAxis === "nw" || handleAxis === "w" || handleAxis === "sw") {
175
271
  if (width >= minConstraints[0]) {
176
272
  newLeft = Math.max(left, resizableLeft);
177
273
  }
178
274
  }
179
275
  }
180
276
  if (deltaY > 0) {
181
- if (handleAxis === 'nw' || handleAxis === 'n' || handleAxis === 'ne') {
277
+ if (handleAxis === "nw" || handleAxis === "n" || handleAxis === "ne") {
182
278
  if (height >= minConstraints[1]) {
183
279
  newTop = Math.max(top, resizableTop);
184
280
  }
@@ -191,7 +287,7 @@ var Resizable = function (_a) {
191
287
  var _b, _c;
192
288
  var _d, _e, _f, _g, _h, _j;
193
289
  var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
194
- if (handlerName === 'onResizeStart') {
290
+ if (handlerName === "onResizeStart") {
195
291
  var position = { top: (_d = props.top) !== null && _d !== void 0 ? _d : 0, left: (_e = props.left) !== null && _e !== void 0 ? _e : 0 };
196
292
  startPosition.current = position;
197
293
  startSize.current = {
@@ -200,12 +296,12 @@ var Resizable = function (_a) {
200
296
  };
201
297
  resetData();
202
298
  }
203
- var canDragX = (axis === 'both' || axis === 'x') &&
204
- handleAxis !== 'n' &&
205
- handleAxis !== 's';
206
- var canDragY = (axis === 'both' || axis === 'y') &&
207
- handleAxis !== 'e' &&
208
- handleAxis !== 'w';
299
+ var canDragX = (axis === "both" || axis === "x") &&
300
+ handleAxis !== "n" &&
301
+ handleAxis !== "s";
302
+ var canDragY = (axis === "both" || axis === "y") &&
303
+ handleAxis !== "e" &&
304
+ handleAxis !== "w";
209
305
  if (!canDragX && !canDragY)
210
306
  return;
211
307
  var axisV = handleAxis[0];
@@ -223,34 +319,35 @@ var Resizable = function (_a) {
223
319
  // }
224
320
  // }
225
321
  lastHandleRectRef.current = handleRect;
226
- if (axisH === 'w') {
322
+ if (axisH === "w") {
227
323
  deltaX = -deltaX;
228
324
  }
229
- if (axisV === 'n') {
325
+ if (axisV === "n") {
230
326
  deltaY = -deltaY;
231
327
  }
232
328
  var width = props.width + (canDragX ? deltaX / transformScale : 0);
233
329
  var height = props.height + (canDragY ? deltaY / transformScale : 0);
234
330
  var left = (_h = props === null || props === void 0 ? void 0 : props.left) !== null && _h !== void 0 ? _h : 0;
235
331
  var top = (_j = props === null || props === void 0 ? void 0 : props.top) !== null && _j !== void 0 ? _j : 0;
236
- if (axisV === 'n') {
332
+ if (axisV === "n") {
237
333
  top = top - deltaY;
238
334
  }
239
- if (axisH === 'w') {
335
+ if (axisH === "w") {
240
336
  left = left - deltaX;
241
337
  }
242
338
  _b = checkConstraints(width, height), width = _b[0], height = _b[1];
243
339
  if (autoResize && minHeight.current === height) {
244
340
  handleAxis = removeNorthHandle(handleAxis);
245
341
  }
342
+ console.log("deltax deltay", deltaX, deltaY);
246
343
  _c = checkTopLeft(deltaX, deltaY, top, left, width, height, handleAxis), top = _c[0], left = _c[1];
247
344
  var isDimensionsChanged = width !== props.width || height !== props.height;
248
- var cb = typeof props[handlerName] === 'function' ? props[handlerName] : null;
249
- var isCbSkipped = handlerName === 'onResize' && !isDimensionsChanged;
345
+ var cb = typeof props[handlerName] === "function" ? props[handlerName] : null;
346
+ var isCbSkipped = handlerName === "onResize" && !isDimensionsChanged;
250
347
  if (cb && !isCbSkipped) {
251
348
  cb(e, { node: node, size: { width: width, height: height, top: top, left: left }, handle: handleAxis });
252
349
  }
253
- if (handlerName === 'onResizeStop') {
350
+ if (handlerName === "onResizeStop") {
254
351
  startPosition.current = null;
255
352
  startSize.current = null;
256
353
  resetData();
@@ -261,27 +358,27 @@ var Resizable = function (_a) {
261
358
  if (!handle) {
262
359
  return (_jsx("span", { className: "react-resizable-handle react-resizable-handle-".concat(handleAxis), ref: ref }));
263
360
  }
264
- if (typeof handle === 'function') {
361
+ if (typeof handle === "function") {
265
362
  return handle(handleAxis, ref);
266
363
  }
267
- var isDOMElement = typeof handle.type === 'string';
364
+ var isDOMElement = typeof handle.type === "string";
268
365
  var props = __assign({ ref: ref }, (isDOMElement ? {} : { handleAxis: handleAxis }));
269
366
  return React.cloneElement(handle, props);
270
367
  };
271
- return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className : 'react-resizable'), children: __spreadArray([
368
+ return cloneElement(children, __assign(__assign({}, restProps), { className: classNames(className !== null && className !== void 0 ? className : "react-resizable"), children: __spreadArray([
272
369
  // ...children.props.children,
273
370
  React.Children.map(children.props.children, function (child) { return child; })
274
371
  ], resizeHandles.map(function (handleAxis) {
275
372
  var ref = (handleRefs === null || handleRefs === void 0 ? void 0 : handleRefs.current) && handleRefs.current[handleAxis];
276
- 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)));
373
+ 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)));
277
374
  }), true) }));
278
375
  };
279
376
  function removeNorthHandle(axis) {
280
377
  switch (axis) {
281
- case 'ne':
282
- return 'e';
283
- case 'nw':
284
- return 'w';
378
+ case "ne":
379
+ return "e";
380
+ case "nw":
381
+ return "w";
285
382
  default:
286
383
  return axis;
287
384
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publ-echo-test",
3
- "version": "0.0.338",
3
+ "version": "0.0.340",
4
4
  "private": false,
5
5
  "main": "dist/lib/index.js",
6
6
  "types": "dist/lib/index.d.js",