publ-echo-test 0.0.331 → 0.0.332

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.
Files changed (76) hide show
  1. package/css/gle-styles.css +0 -1
  2. package/package.json +1 -1
  3. package/dist/external-lib/classnames/index.d.ts +0 -5
  4. package/dist/external-lib/classnames/index.js +0 -60
  5. package/dist/external-lib/lodash.isEqual/index.d.ts +0 -30
  6. package/dist/external-lib/lodash.isEqual/index.js +0 -1661
  7. package/dist/lib/Draggable/Draggable.d.ts +0 -17
  8. package/dist/lib/Draggable/Draggable.js +0 -192
  9. package/dist/lib/Draggable/DraggableCore.d.ts +0 -5
  10. package/dist/lib/Draggable/DraggableCore.js +0 -267
  11. package/dist/lib/Draggable/constants.d.ts +0 -12
  12. package/dist/lib/Draggable/constants.js +0 -12
  13. package/dist/lib/Draggable/index.d.ts +0 -2
  14. package/dist/lib/Draggable/index.js +0 -2
  15. package/dist/lib/Draggable/types.d.ts +0 -55
  16. package/dist/lib/Draggable/types.js +0 -1
  17. package/dist/lib/Draggable/utils/domHelpers.d.ts +0 -22
  18. package/dist/lib/Draggable/utils/domHelpers.js +0 -222
  19. package/dist/lib/Draggable/utils/getPrefix.d.ts +0 -5
  20. package/dist/lib/Draggable/utils/getPrefix.js +0 -41
  21. package/dist/lib/Draggable/utils/positionHelpers.d.ts +0 -7
  22. package/dist/lib/Draggable/utils/positionHelpers.js +0 -32
  23. package/dist/lib/Draggable/utils/types.d.ts +0 -30
  24. package/dist/lib/Draggable/utils/types.js +0 -1
  25. package/dist/lib/Draggable/utils/validationHelpers.d.ts +0 -4
  26. package/dist/lib/Draggable/utils/validationHelpers.js +0 -16
  27. package/dist/lib/GridItem/GridItem.d.ts +0 -5
  28. package/dist/lib/GridItem/GridItem.js +0 -633
  29. package/dist/lib/GridItem/GridItemCopy.d.ts +0 -5
  30. package/dist/lib/GridItem/GridItemCopy.js +0 -613
  31. package/dist/lib/GridItem/GroupItem.d.ts +0 -10
  32. package/dist/lib/GridItem/GroupItem.js +0 -472
  33. package/dist/lib/GridItem/OutsideClickHandler.d.ts +0 -7
  34. package/dist/lib/GridItem/OutsideClickHandler.js +0 -112
  35. package/dist/lib/GridItem/index.d.ts +0 -1
  36. package/dist/lib/GridItem/index.js +0 -1
  37. package/dist/lib/GridItem/types.d.ts +0 -112
  38. package/dist/lib/GridItem/types.js +0 -1
  39. package/dist/lib/GridItem/utils/calculateUtils.d.ts +0 -30
  40. package/dist/lib/GridItem/utils/calculateUtils.js +0 -115
  41. package/dist/lib/GridLayoutEditor/ReactGridLayout.d.ts +0 -6
  42. package/dist/lib/GridLayoutEditor/ReactGridLayout.js +0 -748
  43. package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.d.ts +0 -4
  44. package/dist/lib/GridLayoutEditor/ResponsiveGridLayout.js +0 -117
  45. package/dist/lib/GridLayoutEditor/group.d.ts +0 -58
  46. package/dist/lib/GridLayoutEditor/group.js +0 -341
  47. package/dist/lib/GridLayoutEditor/index.d.ts +0 -3
  48. package/dist/lib/GridLayoutEditor/index.js +0 -2
  49. package/dist/lib/GridLayoutEditor/types.d.ts +0 -170
  50. package/dist/lib/GridLayoutEditor/types.js +0 -1
  51. package/dist/lib/GridLayoutEditor/utils/renderHelpers.d.ts +0 -173
  52. package/dist/lib/GridLayoutEditor/utils/renderHelpers.js +0 -607
  53. package/dist/lib/GridLayoutEditor/utils/responsiveUtils.d.ts +0 -26
  54. package/dist/lib/GridLayoutEditor/utils/responsiveUtils.js +0 -77
  55. package/dist/lib/Resizable/Resizable.d.ts +0 -6
  56. package/dist/lib/Resizable/Resizable.js +0 -386
  57. package/dist/lib/Resizable/ResizableBox.d.ts +0 -7
  58. package/dist/lib/Resizable/ResizableBox.js +0 -57
  59. package/dist/lib/Resizable/index.d.ts +0 -1
  60. package/dist/lib/Resizable/index.js +0 -1
  61. package/dist/lib/Resizable/types.d.ts +0 -69
  62. package/dist/lib/Resizable/types.js +0 -1
  63. package/dist/lib/Resizable/utils/cloneElement.d.ts +0 -2
  64. package/dist/lib/Resizable/utils/cloneElement.js +0 -21
  65. package/dist/lib/components/WidthProvider.d.ts +0 -9
  66. package/dist/lib/components/WidthProvider.js +0 -65
  67. package/dist/lib/components/index.d.ts +0 -1
  68. package/dist/lib/components/index.js +0 -1
  69. package/dist/lib/components/types.d.ts +0 -13
  70. package/dist/lib/components/types.js +0 -1
  71. package/dist/lib/index.d.ts +0 -5
  72. package/dist/lib/index.js +0 -5
  73. package/dist/lib/types.d.ts +0 -4
  74. package/dist/lib/types.js +0 -1
  75. package/dist/lib/utils/classNames.d.ts +0 -3
  76. package/dist/lib/utils/classNames.js +0 -10
@@ -1,633 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import { jsx as _jsx } from "react/jsx-runtime";
24
- import React, { useEffect, useRef, useState } from "react";
25
- import { DraggableCore } from "../Draggable";
26
- import classNames from "../../external-lib/classnames";
27
- import { calcGridColWidth, calcGridItemPosition, calcGridItemWHPx, calcWH, calcXY, clamp, resolveRowHeight, } from "./utils/calculateUtils";
28
- import { perc, setTopLeft, setTransform, } from "../GridLayoutEditor/utils/renderHelpers";
29
- import { Resizable } from "../Resizable";
30
- var GridItem = function (_a) {
31
- var _b;
32
- var children = _a.children, props = __rest(_a, ["children"]);
33
- var resizeHandle = props.resizeHandle, cols = props.cols, zOrder = props.zOrder, zOrderInternal = props.zOrderInternal, isDraggable = props.isDraggable, _c = props.transformScale, transformScale = _c === void 0 ? 1 : _c, isResizable = props.isResizable, useCSSTransforms = props.useCSSTransforms, className = props.className, _d = props.cancel, cancel = _d === void 0 ? "" : _d, _e = props.handle, handle = _e === void 0 ? "" : _e, x = props.x, y = props.y, z = props.z, w = props.w, h = props.h, _f = props.minH, minH = _f === void 0 ? 1 : _f, _g = props.minW, minW = _g === void 0 ? 1 : _g, _h = props.maxH, maxH = _h === void 0 ? Infinity : _h, _j = props.maxW, maxW = _j === void 0 ? Infinity : _j, i = props.i, _k = props.isHiddenVisibility, isHiddenVisibility = _k === void 0 ? false : _k, containerWidth = props.containerWidth, customColWidth = props.customColWidth, autoResize = props.autoResize;
34
- var _l = useState(), resizing = _l[0], setResizing = _l[1];
35
- var _m = useState(), dragging = _m[0], setDragging = _m[1];
36
- var _o = useState(), dragStart = _o[0], setDragStart = _o[1];
37
- var _p = useState(false), isDragging = _p[0], setIsDragging = _p[1];
38
- var _q = useState(false), isResizing = _q[0], setIsResizing = _q[1];
39
- var elementRef = useRef(null);
40
- var isSelected = (_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.classList.contains("react-grid-item-selected");
41
- useEffect(function () {
42
- var _a;
43
- if (!isSelected || !autoResize) {
44
- return;
45
- }
46
- var targetNode = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.children[0].children[0].children[0];
47
- if (!targetNode || isDragging || isResizing) {
48
- return;
49
- }
50
- console.log("contains?:", targetNode.classList.contains("ccb-layout-box"));
51
- if (targetNode.classList.contains("ccb-layout-box")) {
52
- return;
53
- }
54
- var prevPaddingL = parseFloat(getComputedStyle(targetNode).paddingLeft);
55
- var prevPaddingR = parseFloat(getComputedStyle(targetNode).paddingRight);
56
- var prevPaddingT = parseFloat(getComputedStyle(targetNode).paddingTop);
57
- var prevPaddingB = parseFloat(getComputedStyle(targetNode).paddingBottom);
58
- // MutationObserver 콜백 함수
59
- var callback = function (mutationsList) {
60
- for (var _i = 0, mutationsList_1 = mutationsList; _i < mutationsList_1.length; _i++) {
61
- var mutation = mutationsList_1[_i];
62
- var isCharacterChanged = mutation.type === "characterData";
63
- var keepWidth = true;
64
- var hasPaddingChanged = false;
65
- var height = isCharacterChanged
66
- ? mutation.target.parentNode.clientHeight
67
- : mutation.target.clientHeight;
68
- var width = targetNode.clientWidth;
69
- if (!isCharacterChanged && mutation.target instanceof Element) {
70
- var styles = getComputedStyle(mutation.target);
71
- var minWidth = parseFloat(styles.minWidth);
72
- if (minWidth > width) {
73
- keepWidth = false;
74
- }
75
- // NOTE: POC
76
- var paddingL = parseFloat(styles.paddingLeft);
77
- var paddingR = parseFloat(styles.paddingRight);
78
- var paddingT = parseFloat(styles.paddingTop);
79
- var paddingB = parseFloat(styles.paddingBottom);
80
- if (prevPaddingL !== paddingL ||
81
- prevPaddingR !== paddingR ||
82
- prevPaddingT !== paddingT ||
83
- prevPaddingB !== paddingB) {
84
- hasPaddingChanged = true;
85
- keepWidth = false;
86
- }
87
- }
88
- var prevW = props.w;
89
- var prevH = props.h;
90
- var _a = calcWH(getPositionParams(), {
91
- width: width,
92
- height: height,
93
- }, x, y, "e", props.w, props.h, false), w_1 = _a.w, h_1 = _a.h;
94
- if (keepWidth) {
95
- w_1 = prevW;
96
- }
97
- if (prevH > h_1) {
98
- h_1 = prevH;
99
- }
100
- var _b = getResizableXYPosition("e", w_1, h_1, prevW, prevH), newX = _b.newX, newY = _b.newY;
101
- if (prevH === h_1 && prevW === w_1 && newX === x && newY === y) {
102
- return;
103
- }
104
- props.onFitToContent &&
105
- props.onFitToContent(i, w_1, h_1, newX, newY, { hasPaddingChanged: hasPaddingChanged });
106
- }
107
- };
108
- // MutationObserver 인스턴스 생성
109
- var observer = new MutationObserver(callback);
110
- // 관찰할 DOM 변이 설정
111
- var config = { characterData: true, attributes: true, subtree: true };
112
- // 대상 노드와 설정으로 관찰 시작
113
- observer.observe(targetNode, config);
114
- // 정리 함수에서 MutationObserver 해제
115
- return function () {
116
- if (targetNode.classList.contains("ccb-layout-box")) {
117
- return;
118
- }
119
- observer.disconnect();
120
- };
121
- }, [autoResize, isSelected, isDragging, isResizing, props.w, props.h, x, y]);
122
- useEffect(function () {
123
- var _a;
124
- if (!isSelected || !autoResize) {
125
- return;
126
- }
127
- var targetNode = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.children[0].children[0].children[0];
128
- if (!targetNode || isDragging || isResizing) {
129
- return;
130
- }
131
- console.log("targetNode", targetNode);
132
- if (!targetNode.classList.contains("ccb-layout-box")) {
133
- return;
134
- }
135
- console.log("contains?:", targetNode.classList.contains("ccb-layout-box"));
136
- var prevPaddingL = parseFloat(getComputedStyle(targetNode).paddingLeft);
137
- var prevPaddingR = parseFloat(getComputedStyle(targetNode).paddingRight);
138
- var prevPaddingT = parseFloat(getComputedStyle(targetNode).paddingTop);
139
- var prevPaddingB = parseFloat(getComputedStyle(targetNode).paddingBottom);
140
- // MutationObserver 콜백 함수
141
- var callback = function (mutationsList) {
142
- for (var _i = 0, mutationsList_2 = mutationsList; _i < mutationsList_2.length; _i++) {
143
- var mutation = mutationsList_2[_i];
144
- console.log("mutation", mutation);
145
- // const isInitial = mutation.attributeName === "data-is-initialized";
146
- var isSizeChanged = mutation.attributeName === "data-min-width" ||
147
- mutation.attributeName === "data-min-height";
148
- var keepWidth = true;
149
- var hasPaddingChanged = true;
150
- var layoutBox = targetNode.children[0];
151
- var contentsWrapper = layoutBox.children[0];
152
- var oneComposition = contentsWrapper.querySelector(".composition-container");
153
- console.log("layoutbox", layoutBox);
154
- console.log("contentsWrapper", contentsWrapper);
155
- console.log("oneComposition", oneComposition);
156
- // const insetTop = Number(mutation.target.dataset.insetTop!);
157
- // const insetBottom = Number(mutation.target.dataset.insetBottom!);
158
- var minWidth = 0;
159
- // const minHeight =
160
- // Number(mutation.target.dataset.minHeight) + insetTop + insetBottom;
161
- // const contentsWrapper = mutation.target.querySelector(
162
- // ".cb-contentslist-wrapper"
163
- // );
164
- // const oneComposition = mutation.target.querySelector(
165
- // ".composition-container"
166
- // );
167
- var minHeight = 0;
168
- if (contentsWrapper && oneComposition) {
169
- var minCellWidth = 10;
170
- var numberOfItems = Number(mutation.target.getAttribute("data-number-of-items"));
171
- var numberOfColumns = Number(mutation.target.getAttribute("data-number-of-columns"));
172
- var rowGap = Number(mutation.target.getAttribute("data-row-gap"));
173
- var columnGap = Number(mutation.target.getAttribute("data-column-gap"));
174
- var insetTop = Number(mutation.target.getAttribute("data-inset-top"));
175
- var insetBottom = Number(mutation.target.getAttribute("data-inset-bottom"));
176
- var compositionCols = Number(oneComposition.getAttribute("data-cols"));
177
- // const compositionRows = Number(
178
- // oneComposition.getAttribute("data-rows")!
179
- // );
180
- var oneCompositionMinWidth = minCellWidth * compositionCols + 20; /* 20px padding */
181
- console.log("compositionCols", compositionCols);
182
- // let oneCompositionMinHeight =
183
- // minColHeight * compositionRows + 20; /* 20px padding */
184
- if (contentsWrapper) {
185
- var gridWrapperInnerH = contentsWrapper.clientHeight;
186
- var oneCompositionH = oneComposition.clientHeight;
187
- var compositionBGwrapperPaddingT = Number(oneComposition.getAttribute("data-wrapper-paddingt"));
188
- var compositionBGwrapperPaddingB = Number(oneComposition.getAttribute("data-wrapper-paddingb"));
189
- var compositionBGwrapperPaddingL = Number(oneComposition.getAttribute("data-wrapper-paddingl"));
190
- var compositionBGwrapperPaddingR = Number(oneComposition.getAttribute("data-wrapper-paddingr"));
191
- var oneCompositionMinHeight = oneCompositionH +
192
- compositionBGwrapperPaddingT +
193
- compositionBGwrapperPaddingB;
194
- var styles = getComputedStyle(mutation.target);
195
- var paddingL = parseFloat(styles.paddingLeft);
196
- var paddingR = parseFloat(styles.paddingRight);
197
- var paddingT = parseFloat(styles.paddingTop);
198
- var paddingB = parseFloat(styles.paddingBottom);
199
- var paddingLR = paddingL + paddingR;
200
- var paddingTB = paddingT + paddingB;
201
- var compositionWrapperPaddingLR = (compositionBGwrapperPaddingL + compositionBGwrapperPaddingR) *
202
- numberOfColumns;
203
- var numberOfRows = Math.ceil(numberOfItems / numberOfColumns);
204
- var listMinWidth = oneCompositionMinWidth * numberOfColumns +
205
- (numberOfColumns - 1) * columnGap +
206
- paddingLR +
207
- compositionWrapperPaddingLR;
208
- console.log("oneCompositionMinWidth", oneCompositionMinWidth);
209
- console.log("cols", numberOfColumns);
210
- var gridWrapperTotalH = gridWrapperInnerH + insetTop + insetBottom;
211
- var listMinHeight = oneCompositionMinHeight * numberOfRows +
212
- (numberOfRows - 1) * rowGap +
213
- paddingTB +
214
- insetTop +
215
- insetBottom;
216
- if (listMinHeight > gridWrapperTotalH) {
217
- minHeight = listMinHeight;
218
- }
219
- minWidth = listMinWidth;
220
- }
221
- }
222
- // 필요가 없을 수도.
223
- if (isNaN(minWidth) || isNaN(minHeight)) {
224
- return;
225
- }
226
- var width = targetNode.clientWidth;
227
- if (!isSizeChanged && mutation.target instanceof Element) {
228
- var styles = getComputedStyle(mutation.target);
229
- if (minWidth > width) {
230
- keepWidth = false;
231
- }
232
- // NOTE: POC
233
- var paddingL = parseFloat(styles.paddingLeft);
234
- var paddingR = parseFloat(styles.paddingRight);
235
- var paddingT = parseFloat(styles.paddingTop);
236
- var paddingB = parseFloat(styles.paddingBottom);
237
- if (prevPaddingL !== paddingL ||
238
- prevPaddingR !== paddingR ||
239
- prevPaddingT !== paddingT ||
240
- prevPaddingB !== paddingB) {
241
- hasPaddingChanged = true;
242
- keepWidth = false;
243
- }
244
- }
245
- var prevW = props.w;
246
- var prevH = props.h;
247
- var _a = calcWH(getPositionParams(), {
248
- width: minWidth,
249
- height: minHeight,
250
- }, x, y, "e", props.w, props.h, true), w_2 = _a.w, h_2 = _a.h;
251
- if (keepWidth) {
252
- w_2 = prevW;
253
- }
254
- if (prevH > h_2) {
255
- h_2 = prevH;
256
- }
257
- var _b = getResizableXYPosition("e", w_2, h_2, prevW, prevH), newX = _b.newX, newY = _b.newY;
258
- if (prevH === h_2 && prevW === w_2 && newX === x && newY === y) {
259
- return;
260
- }
261
- props.onFitToContent &&
262
- props.onFitToContent(i, w_2, h_2, newX, newY, { hasPaddingChanged: hasPaddingChanged });
263
- }
264
- };
265
- var callbackLater = function (mutationsList) {
266
- setTimeout(function () {
267
- callback(mutationsList);
268
- }, 200);
269
- };
270
- // MutationObserver 인스턴스 생성
271
- var observer = new MutationObserver(callbackLater);
272
- // 관찰할 DOM 변이 설정
273
- var config = { attributes: true, characterData: true };
274
- // 대상 노드와 설정으로 관찰 시작
275
- observer.observe(targetNode, config);
276
- // 정리 함수에서 MutationObserver 해제
277
- return function () {
278
- if (!targetNode.classList.contains("ccb-layout-box")) {
279
- return;
280
- }
281
- observer.disconnect();
282
- };
283
- }, [autoResize, isSelected, isDragging, isResizing, props.w, props.h, x, y]);
284
- // useEffect(() => {
285
- // if (!isSelected || !autoResize) {
286
- // return;
287
- // }
288
- // const targetNode = elementRef.current?.children[0].children[0].children[0];
289
- // if (!targetNode || isDragging || isResizing) {
290
- // return;
291
- // }
292
- // if (targetNode.id !== "contentslist-box") {
293
- // return;
294
- // }
295
- // const minWidth = Number((targetNode as HTMLElement).dataset?.minWidth ?? 0);
296
- // const minHeight = Number(
297
- // (targetNode as HTMLElement).dataset?.minHeight ?? 0
298
- // );
299
- // const insetTop = Number((targetNode as HTMLElement).dataset.insetTop!);
300
- // const insetBottom = Number(
301
- // (targetNode as HTMLElement).dataset.insetBottom!
302
- // );
303
- // let { w, h } = calcWH(
304
- // getPositionParams(),
305
- // {
306
- // width: minWidth,
307
- // height: minHeight + insetTop + insetBottom,
308
- // },
309
- // x,
310
- // y,
311
- // "e",
312
- // props.w,
313
- // props.h,
314
- // true
315
- // );
316
- // const prevW = props.w;
317
- // const prevH = props.h;
318
- // if (prevW > w) {
319
- // w = prevW;
320
- // }
321
- // if (prevH > h) {
322
- // h = prevH;
323
- // }
324
- // if (prevH === h && prevW === w) {
325
- // console.log("cancelled 3");
326
- // return;
327
- // }
328
- // props.onFitToContent &&
329
- // props.onFitToContent(i, w, h, x, y, { hasPaddingChanged: true });
330
- // }, [isSelected, isResizing]);
331
- // const moveDroppingItem = (prevProps: GridItemProps) => {
332
- // const { droppingPosition } = props;
333
- // if (!droppingPosition) return;
334
- // const node = elementRef.current;
335
- // // Can't find DOM node (are we unmounted?)
336
- // if (!node) return;
337
- // const prevDroppingPosition = prevProps.droppingPosition || {
338
- // left: 0,
339
- // top: 0,
340
- // };
341
- // const shouldDrag =
342
- // (dragging && droppingPosition.left !== prevDroppingPosition.left) ||
343
- // droppingPosition.top !== prevDroppingPosition.top;
344
- // if (!dragging) {
345
- // onDragStart(droppingPosition.e, {
346
- // node,
347
- // deltaX: droppingPosition.left,
348
- // deltaY: droppingPosition.top,
349
- // });
350
- // } else if (shouldDrag) {
351
- // const deltaX = droppingPosition.left - dragging.left;
352
- // const deltaY = droppingPosition.top - dragging.top;
353
- // onDrag(droppingPosition.e, {
354
- // node,
355
- // deltaX,
356
- // deltaY,
357
- // });
358
- // }
359
- // };
360
- var getPositionParams = function (prop) {
361
- if (prop === void 0) { prop = props; }
362
- return {
363
- cols: prop.cols,
364
- containerPadding: prop.containerPadding,
365
- containerWidth: prop.containerWidth,
366
- margin: prop.margin,
367
- maxRows: prop.maxRows,
368
- rowHeight: prop.rowHeight,
369
- };
370
- };
371
- var colWidth = customColWidth !== null && customColWidth !== void 0 ? customColWidth : calcGridColWidth(getPositionParams());
372
- var createStyle = function (pos) {
373
- var usePercentages = props.usePercentages, containerWidth = props.containerWidth, useCSSTransforms = props.useCSSTransforms;
374
- var style;
375
- if (useCSSTransforms) {
376
- style = setTransform(pos);
377
- }
378
- else {
379
- style = setTopLeft(pos);
380
- if (usePercentages) {
381
- if (containerWidth == null) {
382
- throw new Error("Container width is missing!");
383
- }
384
- style.left = perc(pos.left / containerWidth);
385
- style.width = perc(pos.width / containerWidth);
386
- }
387
- }
388
- return style;
389
- };
390
- /**
391
- * Mix a Draggable instance into a child.
392
- * @param {Element} child Child element.
393
- * @return {Element} Child wrapped in Draggable.
394
- */
395
- var mixinDraggable = function (child, isDraggable) {
396
- return (_jsx(DraggableCore, { disabled: !isDraggable, onStart: onDragStart, onDrag: onDrag, onStop: onDragStop, handle: handle, cancel: ".react-resizable-handle" + (cancel ? "," + cancel : ""), scale: transformScale, nodeRef: elementRef, children: child }));
397
- };
398
- /**
399
- * Mix a Resizable instance into a child.
400
- * @param {Element} child Child element.
401
- * @param {Object} position Position object (pixel values)
402
- * @return {Element} Child wrapped in Resizable.
403
- */
404
- var mixinResizable = function (child, position, isResizable) {
405
- var positionParams = getPositionParams();
406
- // const maxWidth = calcGridItemPosition(
407
- // positionParams,
408
- // x,
409
- // y,
410
- // z,
411
- // cols - x, // TODO - 수정 필요
412
- // h
413
- // ).width;
414
- var mins = calcGridItemPosition(positionParams, x, y, z, minW, minH);
415
- var maxes = calcGridItemPosition(positionParams, x, y, z, maxW, maxH);
416
- var minConstraints = [mins.width, mins.height];
417
- var maxConstraints = [
418
- Math.min(maxes.width, containerWidth),
419
- Math.min(maxes.height, Infinity),
420
- ];
421
- return (_jsx(Resizable, { draggableOpts: {
422
- disabled: !isResizable,
423
- }, className: isResizable ? undefined : "react-resizable-hide", width: position.width, height: position.height, top: position.top, left: position.left, resizeHandles: props.resizeHandles, onResizeStop: onResizeStop, onResizeStart: onResizeStart, onResize: onResize, minConstraints: minConstraints, maxConstraints: maxConstraints, transformScale: transformScale, handle: resizeHandle, isResizing: isResizing, autoResize: autoResize, colWidth: colWidth, margin: props.margin, children: child }));
424
- };
425
- /**
426
- * onDragStart event handler
427
- * @param {Event} e event data
428
- * @param {Object} callbackData an object with node, delta and position information
429
- */
430
- var onDragStart = function (e, _a) {
431
- var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
432
- var newPosition = { top: 0, left: 0 };
433
- var offsetParent = node.offsetParent;
434
- if (!offsetParent)
435
- return;
436
- var parentRect = offsetParent.getBoundingClientRect();
437
- var clientRect = node.getBoundingClientRect();
438
- var cLeft = clientRect.left / transformScale;
439
- var pLeft = parentRect.left / transformScale;
440
- var cTop = clientRect.top / transformScale;
441
- var pTop = parentRect.top / transformScale;
442
- newPosition.left = cLeft - pLeft + offsetParent.scrollLeft;
443
- newPosition.top = cTop - pTop + offsetParent.scrollTop;
444
- setDragging(newPosition);
445
- var _b = calcXY(getPositionParams(), newPosition.top, newPosition.left, props.w, props.h), x = _b.x, y = _b.y;
446
- setDragStart({ x: x, y: y });
447
- props.onDragStart &&
448
- props.onDragStart(props.i, x, y, { e: e, node: node, newPosition: newPosition });
449
- };
450
- /**
451
- * onDrag event handler
452
- * @param {Event} e event data
453
- * @param {Object} callbackData an object with node, delta and position information
454
- */
455
- var onDrag = function (e, _a) {
456
- var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
457
- if (!dragging) {
458
- throw new Error("onDrag called before onDragStart.");
459
- }
460
- setIsDragging(true);
461
- var top = dragging.top + deltaY;
462
- var left = dragging.left + deltaX;
463
- var isBounded = props.isBounded, i = props.i, w = props.w, h = props.h, containerWidth = props.containerWidth;
464
- var positionParams = getPositionParams();
465
- if (isBounded) {
466
- var offsetParent = node.offsetParent;
467
- if (offsetParent) {
468
- var margin = props.margin, rowHeight = props.rowHeight;
469
- // const colWidth = calcGridColWidth(positionParams);
470
- var rowHeightNumber = resolveRowHeight(rowHeight, colWidth);
471
- var bottomBoundary = offsetParent.clientHeight -
472
- calcGridItemWHPx(h, rowHeightNumber, margin[1]);
473
- top = clamp(top, 0, bottomBoundary);
474
- var rightBoundary = containerWidth - calcGridItemWHPx(w, colWidth, margin[0]);
475
- left = clamp(left, 0, rightBoundary);
476
- }
477
- }
478
- var newPosition = { top: top, left: left };
479
- setDragging(newPosition);
480
- var _b = calcXY(positionParams, top, left, w, h), x = _b.x, y = _b.y;
481
- props.onDrag && props.onDrag(i, x, y, { e: e, node: node, newPosition: newPosition });
482
- };
483
- /**
484
- * onDragStop event handler
485
- * @param {Event} e event data
486
- * @param {Object} callbackData an object with node, delta and position information
487
- */
488
- var onDragStop = function (e, _a) {
489
- var node = _a.node, deltaX = _a.deltaX, deltaY = _a.deltaY;
490
- if (!dragging) {
491
- throw new Error("onDragEnd called before onDragStart.");
492
- }
493
- var w = props.w, h = props.h, i = props.i;
494
- var left = dragging.left, top = dragging.top;
495
- var _b = calcXY(getPositionParams(), top, left, w, h), x = _b.x, y = _b.y;
496
- var newPosition = { top: top, left: left };
497
- var change = (dragStart === null || dragStart === void 0 ? void 0 : dragStart.x) !== x || (dragStart === null || dragStart === void 0 ? void 0 : dragStart.y) !== y;
498
- setDragging(undefined);
499
- setDragStart(undefined);
500
- setIsDragging(false);
501
- props.onDragStop &&
502
- props.onDragStop(i, x, y, { e: e, node: node, newPosition: newPosition, change: change });
503
- };
504
- var getResizableXYPosition = function (handle, width, height, prevW, prevH) {
505
- var newX = x;
506
- var newY = y;
507
- if (handle === "nw") {
508
- // NOTE - nw left(X)와 top(Y) 둘다 변경
509
- if (width > prevW) {
510
- newX = x - (width - prevW);
511
- }
512
- else {
513
- newX = x + (prevW - width);
514
- }
515
- if (height > prevH) {
516
- newY = y - (height - prevH);
517
- }
518
- else {
519
- newY = y + (prevH - height);
520
- }
521
- }
522
- if (handle === "n" || handle === "ne") {
523
- // NOTE - n, ne left(X) 고정 & top(Y) 변경
524
- if (height > prevH) {
525
- newY = y - (height - prevH);
526
- }
527
- else {
528
- newY = y + (prevH - height);
529
- }
530
- }
531
- if (handle === "w" || handle === "sw") {
532
- // NOTE - s, sw left(X) 변경 top(Y) 고정
533
- if (width > prevW) {
534
- newX = x - (width - prevW);
535
- }
536
- else {
537
- newX = x + (prevW - width);
538
- }
539
- }
540
- return { newX: newX, newY: newY };
541
- };
542
- /**
543
- * onResizeStart event handler
544
- * @param {ResizeEventType} e event data
545
- * @param {Object} callbackData an object with node and size information
546
- */
547
- var onResizeStart = function (e, callbackData) {
548
- onResizeHandler(e, callbackData, "onResizeStart");
549
- };
550
- /**
551
- * onResize event handler
552
- * @param {ResizeEventType} e event data
553
- * @param {Object} callbackData an object with node and size information
554
- */
555
- var onResize = function (e, callbackData) {
556
- setIsResizing(true);
557
- onResizeHandler(e, callbackData, "onResize");
558
- };
559
- /**
560
- * onResizeStop event handler
561
- * @param {ResizeEventType} e event data
562
- * @param {Object} callbackData an object with node and size information
563
- */
564
- var onResizeStop = function (e, callbackData) {
565
- setIsResizing(false);
566
- onResizeHandler(e, callbackData, "onResizeStop");
567
- };
568
- /**
569
- * Wrapper around drag events to provide more useful data.
570
- * All drag events call the function with the given handler name,
571
- * with the signature (index, x, y).
572
- *
573
- * @param {String} handlerName Handler name to wrap.
574
- * @return {Function} Handler function.
575
- */
576
- var onResizeHandler = function (e, _a, handlerName) {
577
- var node = _a.node, size = _a.size, handle = _a.handle, minWidth = _a.minWidth, minHeight = _a.minHeight;
578
- var handler = props[handlerName];
579
- if (!handler)
580
- return;
581
- var prevW = props.w, prevH = props.h;
582
- // Get new XY
583
- var _b = calcWH(getPositionParams(), size, x, y, handle, prevW, prevH, true), w = _b.w, h = _b.h;
584
- var tempMinH = minH;
585
- if (minWidth) {
586
- var _c = calcWH(getPositionParams(), __assign(__assign({}, size), { width: minWidth, height: minHeight !== null && minHeight !== void 0 ? minHeight : 0 }), x, y, handle, prevW, prevH, true), minW_1 = _c.w, newMinH = _c.h;
587
- if (minW_1 > w) {
588
- w = minW_1;
589
- }
590
- if (minH > 1) {
591
- tempMinH = Math.max(1, newMinH);
592
- }
593
- }
594
- // minW should be at least 1
595
- // minW = Math.max(minW, 1);
596
- // maxW should be at most (cols - x)
597
- // maxW = Math.min(maxW, cols - x);
598
- w = clamp(w, minW, maxW);
599
- h = clamp(h, tempMinH, maxH);
600
- setResizing(handlerName === "onResizeStop" ? undefined : size);
601
- var _d = getResizableXYPosition(handle, w, h, prevW, prevH), newX = _d.newX, newY = _d.newY;
602
- handler(i, w, h, { e: e, node: node, size: size }, newX, newY);
603
- };
604
- var pos = calcGridItemPosition(getPositionParams(), x, y, z, w, h, {
605
- dragging: dragging,
606
- resizing: resizing,
607
- }, colWidth);
608
- var child = React.Children.only(children);
609
- var newChild = React.cloneElement(child, {
610
- key: i,
611
- ref: elementRef,
612
- "data-grid-id": i,
613
- "data-z-index": z,
614
- "data-z-order": zOrder,
615
- "data-z-order-internal": zOrderInternal,
616
- className: classNames("react-grid-item", child.props.className, className, {
617
- static: props.static,
618
- isResizing: Boolean(resizing) && Boolean(isResizing) && Boolean(isHiddenVisibility),
619
- resizing: Boolean(resizing),
620
- "react-draggable": isDraggable,
621
- "editable-grid-item": isResizable && isDraggable,
622
- isDragging: Boolean(isDragging) && Boolean(dragging) && Boolean(isHiddenVisibility),
623
- "react-draggable-dragging": Boolean(dragging),
624
- // dropping: Boolean(droppingPosition),
625
- cssTransforms: useCSSTransforms,
626
- }),
627
- style: __assign(__assign(__assign({}, props.style), child.props.style), createStyle(pos)),
628
- });
629
- newChild = mixinResizable(newChild, pos, isResizable);
630
- newChild = mixinDraggable(newChild, isDraggable);
631
- return newChild;
632
- };
633
- export default GridItem;
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { GridItemProps } from "./types";
3
- import { PropsWithChildren } from "../types";
4
- declare const GridItem: ({ children, ...props }: PropsWithChildren<GridItemProps>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
5
- export default GridItem;