@byeolnaerim/flex-layout 0.0.4 → 0.0.6

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 (82) hide show
  1. package/README.en.md +314 -0
  2. package/README.ko.md +312 -0
  3. package/README.md +314 -0
  4. package/dist/components.cjs +651 -657
  5. package/dist/components.cjs.map +1 -1
  6. package/dist/components.js +3027 -5
  7. package/dist/components.js.map +1 -1
  8. package/dist/flex-layout/components/FlexLayout.d.ts +2 -0
  9. package/dist/flex-layout/components/FlexLayoutContainer.d.ts +2 -0
  10. package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +2 -0
  11. package/dist/flex-layout/components/FlexLayoutSplitScreen.d.ts +11 -0
  12. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +27 -0
  13. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.d.ts +5 -0
  14. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.d.ts +8 -0
  15. package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.d.ts +3 -0
  16. package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.d.ts +9 -0
  17. package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +29 -0
  18. package/dist/flex-layout/components/index.d.ts +7 -0
  19. package/dist/flex-layout/hooks/index.d.ts +2 -0
  20. package/dist/{useDrag-DR01Ob3s.d.ts → flex-layout/hooks/useDrag.d.ts} +19 -22
  21. package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.d.ts +28 -0
  22. package/dist/{hooks.d.ts → flex-layout/hooks/useListPaging.d.ts} +6 -12
  23. package/dist/flex-layout/hooks/useSizes.d.ts +8 -0
  24. package/dist/flex-layout/index.d.ts +5 -0
  25. package/dist/flex-layout/providers/FlexLayoutContext.d.ts +8 -0
  26. package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +51 -0
  27. package/dist/flex-layout/providers/index.d.ts +1 -0
  28. package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +62 -0
  29. package/dist/flex-layout/store/index.d.ts +1 -0
  30. package/dist/flex-layout/styles/FlexLayout.module.css +416 -0
  31. package/dist/flex-layout/styles/listScroll.module.css +85 -0
  32. package/dist/flex-layout/styles/shake.module.css +41 -0
  33. package/dist/flex-layout/types/FlexDirectionTypes.d.ts +6 -0
  34. package/dist/flex-layout/types/FlexLayoutTypes.d.ts +53 -0
  35. package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +26 -0
  36. package/dist/flex-layout/utils/index.d.ts +1 -0
  37. package/dist/hooks.cjs.map +1 -1
  38. package/dist/hooks.js +407 -3
  39. package/dist/hooks.js.map +1 -1
  40. package/dist/index.cjs +681 -687
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +1 -10
  43. package/dist/index.js +3396 -9
  44. package/dist/index.js.map +1 -1
  45. package/dist/providers.js +400 -4
  46. package/dist/providers.js.map +1 -1
  47. package/dist/store.js +180 -2
  48. package/dist/store.js.map +1 -1
  49. package/dist/utils.js +195 -2
  50. package/dist/utils.js.map +1 -1
  51. package/package.json +18 -45
  52. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.cts +0 -31
  53. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.ts +0 -31
  54. package/dist/chunk-3EDKZTM3.js +0 -3
  55. package/dist/chunk-3EDKZTM3.js.map +0 -1
  56. package/dist/chunk-5HWEFTNQ.js +0 -176
  57. package/dist/chunk-5HWEFTNQ.js.map +0 -1
  58. package/dist/chunk-7J5JUVZK.js +0 -3
  59. package/dist/chunk-7J5JUVZK.js.map +0 -1
  60. package/dist/chunk-CFQQ6ZDC.js +0 -182
  61. package/dist/chunk-CFQQ6ZDC.js.map +0 -1
  62. package/dist/chunk-JM3CZ5DU.js +0 -238
  63. package/dist/chunk-JM3CZ5DU.js.map +0 -1
  64. package/dist/chunk-PMTZFSP4.js +0 -219
  65. package/dist/chunk-PMTZFSP4.js.map +0 -1
  66. package/dist/chunk-UYI4Z27V.js +0 -2432
  67. package/dist/chunk-UYI4Z27V.js.map +0 -1
  68. package/dist/chunk-W4CNFJTK.js +0 -197
  69. package/dist/chunk-W4CNFJTK.js.map +0 -1
  70. package/dist/chunk-YIHCWXKY.js +0 -3
  71. package/dist/chunk-YIHCWXKY.js.map +0 -1
  72. package/dist/components.d.cts +0 -122
  73. package/dist/components.d.ts +0 -122
  74. package/dist/hooks.d.cts +0 -37
  75. package/dist/index.d.cts +0 -10
  76. package/dist/providers.d.cts +0 -54
  77. package/dist/providers.d.ts +0 -54
  78. package/dist/store.d.cts +0 -67
  79. package/dist/store.d.ts +0 -67
  80. package/dist/useDrag-CYQnhUFk.d.cts +0 -108
  81. package/dist/utils.d.cts +0 -28
  82. package/dist/utils.d.ts +0 -28
@@ -1,2432 +0,0 @@
1
- import { useDragEvents, dragState, dropMovementEventSubject, useDragCapture, allSplitScreenCount } from './chunk-PMTZFSP4.js';
2
- import { ContainerOpenCloseProvider } from './chunk-JM3CZ5DU.js';
3
- import { getGrow, mathGrow, mathWeight, isDocumentOut, findNotCloseFlexContent, isOverMove } from './chunk-W4CNFJTK.js';
4
- import { setScrollPosition, getScrollPosition, removeScrollPosition, setResizePanelRef, setContainerRef, resetRootSplitScreen, getSplitScreen, setSplitScreen, getCurrentSplitScreenComponents, removeSplitScreenChild } from './chunk-CFQQ6ZDC.js';
5
- import { createContext, memo, useRef, useState, useEffect, Children, isValidElement, Fragment as Fragment$1, useCallback, useContext, useLayoutEffect, cloneElement } from 'react';
6
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { Subject, fromEvent, distinctUntilChanged, take as take$1 } from 'rxjs';
8
- import equal from 'fast-deep-equal';
9
- import { throttleTime, take } from 'rxjs/operators';
10
-
11
- // src/flex-layout/styles/FlexLayout.module.css
12
- var FlexLayout_default = {};
13
- var FlexLayoutContext = createContext(null);
14
- function useFlexLayoutContext() {
15
- const context = useContext(FlexLayoutContext);
16
- if (!context) {
17
- throw new Error(
18
- "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
19
- );
20
- }
21
- return context;
22
- }
23
- function FlexLayoutProvider({
24
- value,
25
- children
26
- }) {
27
- return /* @__PURE__ */ jsx(FlexLayoutContext.Provider, { value, children });
28
- }
29
- var FlexLayout = ({
30
- layoutName,
31
- direction,
32
- children,
33
- ref,
34
- className,
35
- panelClassName,
36
- panelMovementMode = "divorce",
37
- ...props
38
- }) => {
39
- const containerCount = Children.count(children);
40
- const fitContent = direction === "row" ? "width" : "height";
41
- const isFragmentElement = (node) => isValidElement(node) && node.type === Fragment$1;
42
- const nodes = Children.toArray(children).flatMap(
43
- (node) => isFragmentElement(node) ? Children.toArray(node.props.children) : [node]
44
- );
45
- const flattenedChildren = nodes.filter(
46
- isValidElement
47
- );
48
- if (flattenedChildren.length === 0) {
49
- return null;
50
- }
51
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
52
- FlexLayoutProvider,
53
- {
54
- value: {
55
- layoutName,
56
- direction,
57
- panelMovementMode,
58
- panelClassName,
59
- containerCount,
60
- fitContent
61
- },
62
- children: /* @__PURE__ */ jsx(
63
- "div",
64
- {
65
- className: `${FlexLayout_default["flex-layout"]} ${className && className !== "" ? className : ""}`,
66
- ...ref ? { ref } : {},
67
- ...props,
68
- "data-layout_name": layoutName,
69
- "data-direction": direction,
70
- children: flattenedChildren.map((child, index) => {
71
- if (!child || !isValidElement(child)) return null;
72
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
73
- child,
74
- /* @__PURE__ */ jsx(
75
- ContainerOpenCloseProvider,
76
- {
77
- layoutName,
78
- containerName: child.props.containerName,
79
- sizeName: fitContent
80
- }
81
- )
82
- ] }, index);
83
- })
84
- }
85
- )
86
- }
87
- ) });
88
- };
89
- var FlexLayout_default2 = FlexLayout;
90
- var useSize = (sizeName) => {
91
- const ref = useRef(null);
92
- const [size, setSize] = useState(void 0);
93
- useLayoutEffect(() => {
94
- if (!ref.current) return;
95
- const handleResize = () => {
96
- if (ref.current) {
97
- const newSize = ref.current.getBoundingClientRect()[sizeName];
98
- setSize(newSize);
99
- }
100
- };
101
- handleResize();
102
- const resizeObserver = new ResizeObserver(() => {
103
- handleResize();
104
- });
105
- resizeObserver.observe(ref.current);
106
- window.addEventListener("resize", handleResize);
107
- return () => {
108
- resizeObserver.disconnect();
109
- window.removeEventListener("resize", handleResize);
110
- };
111
- }, [sizeName]);
112
- return { ref, size };
113
- };
114
- var flexDirectionModel = {
115
- row: {
116
- xy: "x",
117
- targetDirection: "left",
118
- nextDirection: "right",
119
- sizeName: "width",
120
- resizeCursor: "ew-resize"
121
- },
122
- column: {
123
- xy: "y",
124
- targetDirection: "top",
125
- nextDirection: "bottom",
126
- sizeName: "height",
127
- resizeCursor: "ns-resize"
128
- }
129
- };
130
- var FlexLayoutResizePanel = ({
131
- direction,
132
- containerCount,
133
- panelMode = "default",
134
- containerName,
135
- layoutName,
136
- panelClassName,
137
- panelMovementMode
138
- }) => {
139
- let isResizePanelClickRef = useRef(false);
140
- let prevTouchEvent = null;
141
- let parentSizeRef = useRef(0);
142
- let totalMovementRef = useRef(0);
143
- const containerCountRef = useRef(containerCount);
144
- useEffect(() => {
145
- return () => {
146
- document.body.style.cursor = "";
147
- };
148
- }, []);
149
- useEffect(() => {
150
- containerCountRef.current = containerCount;
151
- }, [containerCount]);
152
- const panelRef = useRef(null);
153
- const panelMouseDownEvent = (event) => {
154
- if (!panelRef.current || !panelRef.current.parentElement) return;
155
- isResizePanelClickRef.current = true;
156
- containerCountRef.current = [
157
- ...panelRef.current.parentElement.children
158
- ].filter((e) => e.hasAttribute("data-container_name")).length;
159
- const sizeName = flexDirectionModel[direction].sizeName;
160
- parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
161
- prevTouchEvent = null;
162
- totalMovementRef.current = 0;
163
- if (!parentSizeRef.current) return;
164
- document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
165
- };
166
- const panelMouseUpEvent = () => {
167
- isResizePanelClickRef.current = false;
168
- parentSizeRef.current = 0;
169
- prevTouchEvent = null;
170
- totalMovementRef.current = 0;
171
- document.body.style.cursor = "";
172
- };
173
- function moveMouseFlex(originTarget, resizePanel, moveEvent) {
174
- const model = flexDirectionModel[direction];
175
- const movement = moveEvent["movement" + model.xy.toUpperCase()];
176
- totalMovementRef.current += movement;
177
- const minSizeName = "min-" + model.sizeName;
178
- const maxSizeName = "max-" + model.sizeName;
179
- let targetElement = findNotCloseFlexContent(
180
- originTarget,
181
- "previousElementSibling"
182
- );
183
- if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
184
- targetElement = originTarget;
185
- let nextElement = findNotCloseFlexContent(
186
- resizePanel.nextElementSibling,
187
- "nextElementSibling"
188
- );
189
- if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
190
- nextElement = resizePanel.nextElementSibling;
191
- if (!targetElement || !nextElement) return;
192
- const targetRect = targetElement.getBoundingClientRect();
193
- const targetStyle = window.getComputedStyle(targetElement);
194
- const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
195
- const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
196
- const nextRect = nextElement.getBoundingClientRect();
197
- const nextStyle = window.getComputedStyle(nextElement);
198
- const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
199
- const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
200
- let targetSize = targetRect[model.sizeName] + movement;
201
- let nextElementSize = nextRect[model.sizeName] - movement;
202
- if (targetMaxSize > 0 && targetSize > targetMaxSize) {
203
- return;
204
- }
205
- if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
206
- return;
207
- }
208
- if (isOverMove(targetSize, targetMinSize)) {
209
- targetSize = 0;
210
- nextElementSize = nextRect[model.sizeName];
211
- } else if (isOverMove(nextElementSize, nextMinSize)) {
212
- nextElementSize = 0;
213
- targetSize = targetRect[model.sizeName];
214
- }
215
- const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
216
- const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
217
- targetElement.style.flex = `${targetFlexGrow} 1 0%`;
218
- nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
219
- }
220
- useEffect(() => {
221
- const addGlobalMoveEvent = (event) => {
222
- if (!isResizePanelClickRef.current || !panelRef.current) {
223
- return;
224
- }
225
- event.preventDefault();
226
- const targetElement = panelRef.current.previousElementSibling;
227
- const targetPanel = panelRef.current;
228
- if (!targetElement || !targetPanel) return;
229
- let move = { movementX: 0, movementY: 0 };
230
- if (window.TouchEvent && event instanceof window.TouchEvent) {
231
- if (!prevTouchEvent) {
232
- prevTouchEvent = event;
233
- return;
234
- }
235
- move.movementX = (prevTouchEvent.touches[0].pageX - event.touches[0].pageX) * -2;
236
- move.movementY = (prevTouchEvent.touches[0].pageY - event.touches[0].pageY) * -2;
237
- prevTouchEvent = event;
238
- } else {
239
- move.movementX = event.movementX;
240
- move.movementY = event.movementY;
241
- }
242
- moveMouseFlex(targetElement, targetPanel, move);
243
- };
244
- ["mousemove", "touchmove"].forEach((eventName) => {
245
- window.addEventListener(eventName, addGlobalMoveEvent, {
246
- passive: false
247
- });
248
- });
249
- ["mouseup", "touchend"].forEach((eventName) => {
250
- window.addEventListener(eventName, panelMouseUpEvent);
251
- });
252
- return () => {
253
- ["mousemove", "touchmove"].forEach((eventName) => {
254
- window.removeEventListener(eventName, addGlobalMoveEvent);
255
- });
256
- ["mouseup", "touchend"].forEach((eventName) => {
257
- window.removeEventListener(eventName, panelMouseUpEvent);
258
- });
259
- };
260
- }, []);
261
- useEffect(() => {
262
- if (!panelRef.current) return;
263
- setResizePanelRef(layoutName, containerName, panelRef);
264
- }, [containerName, layoutName]);
265
- return /* @__PURE__ */ jsx(
266
- "div",
267
- {
268
- id: containerName + "_resize_panel",
269
- className: `${FlexLayout_default["flex-resize-panel"]} ${FlexLayout_default[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
270
- ref: panelRef,
271
- onMouseDown: panelMouseDownEvent,
272
- onTouchStart: panelMouseDownEvent,
273
- children: /* @__PURE__ */ jsx("div", { className: FlexLayout_default.hover })
274
- }
275
- );
276
- };
277
- var FlexLayoutResizePanel_default = FlexLayoutResizePanel;
278
- var FlexLayoutContainer = ({
279
- isFitContent,
280
- isFitResize,
281
- // fitContent,
282
- // containerCount,
283
- // layoutName,
284
- containerName,
285
- grow: initialGrow,
286
- prevGrow: initialPrevGrow,
287
- isInitialResizable,
288
- isResizePanel,
289
- children,
290
- className,
291
- panelMode
292
- }) => {
293
- const {
294
- direction,
295
- panelMovementMode,
296
- panelClassName,
297
- layoutName,
298
- fitContent,
299
- containerCount
300
- } = useFlexLayoutContext();
301
- const { ref, size } = (
302
- // isFitContent && fitContent
303
- //?
304
- useSize(fitContent)
305
- );
306
- const flexContainerNodeRef = useRef(null);
307
- const flexContainerRef = useCallback(
308
- (node) => {
309
- flexContainerNodeRef.current = node;
310
- if (node !== null) {
311
- setContainerRef(layoutName, containerName, { current: node });
312
- }
313
- },
314
- [layoutName, containerName]
315
- );
316
- const [growState, setGrowState] = useState(initialGrow);
317
- useEffect(() => {
318
- setGrowState(initialGrow);
319
- }, [initialGrow]);
320
- const [prevGrowState, setPrevGrowState] = useState(
321
- initialPrevGrow
322
- );
323
- const [isFirstLoad, setIsFirstLoad] = useState(true);
324
- useEffect(() => {
325
- if (!flexContainerNodeRef.current) return;
326
- setContainerRef(layoutName, containerName, flexContainerNodeRef);
327
- return () => {
328
- setContainerRef(layoutName, containerName, {
329
- current: null
330
- });
331
- };
332
- }, [containerName, layoutName]);
333
- useEffect(() => {
334
- if (typeof window == "undefined" || flexContainerNodeRef.current === null)
335
- return;
336
- const storedGrow = sessionStorage.getItem(containerName);
337
- if (storedGrow !== null) {
338
- const parsed = parseFloat(storedGrow);
339
- if (!isNaN(parsed)) {
340
- flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
341
- setGrowState(parsed);
342
- }
343
- }
344
- }, [containerName]);
345
- useEffect(() => {
346
- if (!flexContainerNodeRef.current) return;
347
- const targetNode = flexContainerNodeRef.current;
348
- const observer = new MutationObserver((mutations) => {
349
- for (const mutation of mutations) {
350
- if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
351
- const flexValue = targetNode.style.flex;
352
- const parsedGrow = parseFloat(flexValue.split(" ")[0]);
353
- if (!isNaN(parsedGrow)) {
354
- setGrowState(parsedGrow);
355
- }
356
- }
357
- }
358
- });
359
- observer.observe(targetNode, {
360
- attributes: true,
361
- attributeFilter: ["style"],
362
- attributeOldValue: true
363
- });
364
- return () => {
365
- observer.disconnect();
366
- };
367
- }, [containerName]);
368
- useEffect(() => {
369
- if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent)
370
- return;
371
- requestAnimationFrame(() => {
372
- if (!flexContainerNodeRef.current) return;
373
- const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
374
- const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
375
- if (isFitContent) {
376
- flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
377
- }
378
- if (!isFitResize && isFirstLoad) {
379
- setIsFirstLoad(false);
380
- return;
381
- }
382
- if (getGrow(flexContainerNodeRef.current) != 0 && isFitResize) {
383
- const newGrow = mathGrow(size, parentSize, containerCount);
384
- setPrevGrowState(growState);
385
- setGrowState(newGrow);
386
- }
387
- });
388
- }, [size, containerCount, isFitResize, children]);
389
- useEffect(() => {
390
- if (!flexContainerNodeRef.current) return;
391
- let notGrowList = [];
392
- let containerList = [
393
- ...flexContainerNodeRef.current.parentElement?.children || []
394
- ].filter((e) => e.hasAttribute("data-container_name"));
395
- let remainingGrow = containerList.reduce((t, e, i) => {
396
- let item = e;
397
- if (item.classList.contains(FlexLayout_default["flex-resize-panel"])) return t;
398
- if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
399
- notGrowList.push(item);
400
- return t;
401
- }
402
- let grow = parseFloat(item.dataset.grow || "");
403
- item.style.flex = `${grow} 1 0%`;
404
- t -= grow;
405
- return t;
406
- }, containerList.length);
407
- if (notGrowList.length != 0) {
408
- let resizeWeight = mathWeight(notGrowList.length, remainingGrow);
409
- notGrowList.forEach((e) => {
410
- e.dataset.grow = resizeWeight.toString();
411
- e.style.flex = `${resizeWeight} 1 0%`;
412
- });
413
- }
414
- }, []);
415
- return /* @__PURE__ */ jsxs(Fragment, { children: [
416
- /* @__PURE__ */ jsx(
417
- "div",
418
- {
419
- id: containerName,
420
- "data-container_name": containerName,
421
- ref: flexContainerRef,
422
- className: `${FlexLayout_default["flex-container"]} ${className && className !== "" ? className : ""}`,
423
- ...growState !== void 0 ? { ["data-grow"]: growState } : {},
424
- ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
425
- "data-is_resize": isInitialResizable,
426
- "data-is_resize_panel": isResizePanel,
427
- style: growState !== void 0 && {
428
- flex: `${growState} 1 0%`
429
- } || {},
430
- children: isFitContent && /* @__PURE__ */ jsx(
431
- "div",
432
- {
433
- className: `${FlexLayout_default["flex-content-fit-wrapper"]}`,
434
- ref,
435
- children
436
- }
437
- ) || children
438
- }
439
- ),
440
- isResizePanel && /* @__PURE__ */ jsx(
441
- FlexLayoutResizePanel_default,
442
- {
443
- containerName,
444
- layoutName,
445
- direction,
446
- containerCount,
447
- panelMode,
448
- panelClassName,
449
- panelMovementMode
450
- }
451
- )
452
- ] });
453
- };
454
- var FlexLayoutContainer_default = FlexLayoutContainer;
455
- function useFlexLayoutSplitScreen({
456
- isSplitInitial = false,
457
- parentDirection,
458
- directionInitial = "row",
459
- selfContainerName,
460
- parentLayoutName,
461
- layoutName
462
- }) {
463
- const [direction, setDirection] = useState(
464
- directionInitial
465
- );
466
- const [isSplit, setIsSplit] = useState(isSplitInitial);
467
- const [boundaryContainerSize, setBoundaryContainerSize] = useState(null);
468
- const [centerDropTargetComponent, setCenterDropTargetComponent] = useState([]);
469
- const [afterDropTargetComponent, setAfterDropTargetComponent] = useState([]);
470
- const [beforeDropTargetComponent, setBeforeDropTargetComponent] = useState([]);
471
- const layoutRef = useRef(null);
472
- const dragState2 = useDragCapture(layoutRef);
473
- useEffect(() => {
474
- if (!dragState2) {
475
- setBoundaryContainerSize(null);
476
- return;
477
- }
478
- const {
479
- isDrop,
480
- isDragging,
481
- positionName,
482
- containerName,
483
- children: dropComponent,
484
- isOver,
485
- navigationTitle,
486
- dropEndCallback,
487
- x,
488
- y,
489
- screenKey
490
- } = dragState2;
491
- const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
492
- if ((isOver || isDrop) && boundaryContainerSize) {
493
- setBoundaryContainerSize(null);
494
- }
495
- if (selfContainerName.startsWith(containerName)) {
496
- return;
497
- }
498
- if (isDrop && screenKey) {
499
- const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
500
- if (!isSplit && !isOver) {
501
- if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
502
- setIsSplit(true);
503
- setDirection(dropDirection);
504
- }
505
- dropMovementEventSubject.next({
506
- state: "append",
507
- targetContainerName: containerName,
508
- targetParentLayoutName: parentLayoutName,
509
- targetLayoutName: layoutName,
510
- targetComponent: dropComponent,
511
- orderName,
512
- x,
513
- y,
514
- dropEndCallback,
515
- dropTargetComponentEvent: {
516
- navigationTitle,
517
- dropDocumentOutsideOption: dragState2?.dropDocumentOutsideOption,
518
- direction: dropDirection,
519
- screenKey
520
- }
521
- });
522
- }
523
- }
524
- if (isDragging && !isSplit && !isOver) {
525
- const newSize = {
526
- left: positionName === "rightBoundary" ? "50%" : "0",
527
- top: positionName === "bottomBoundary" ? "50%" : "0",
528
- width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
529
- height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
530
- };
531
- if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
532
- setBoundaryContainerSize(newSize);
533
- }
534
- }
535
- }, [
536
- dragState2,
537
- isSplit,
538
- boundaryContainerSize,
539
- parentLayoutName,
540
- layoutName,
541
- selfContainerName,
542
- direction
543
- ]);
544
- return {
545
- direction,
546
- setDirection,
547
- isSplit,
548
- setIsSplit,
549
- boundaryContainerSize,
550
- //setBoundaryContainerSize,
551
- centerDropTargetComponent,
552
- afterDropTargetComponent,
553
- beforeDropTargetComponent,
554
- setAfterDropTargetComponent,
555
- setBeforeDropTargetComponent,
556
- setCenterDropTargetComponent,
557
- //dropTargetComponent,
558
- //setDropTargetComponent,
559
- //setDropPosition,
560
- isOver: dragState2?.isOver,
561
- layoutRef
562
- };
563
- }
564
- var MAX_STEP = 18;
565
- function edgeVelocity(x, y) {
566
- const w = window.innerWidth, h = window.innerHeight;
567
- const mx = w * 0.15, my = h * 0.15;
568
- let vx = 0;
569
- if (x < mx)
570
- vx = -((mx - x) / mx) * MAX_STEP;
571
- else if (x > w - mx)
572
- vx = (x - (w - mx)) / mx * MAX_STEP;
573
- let vy = 0;
574
- if (y < my)
575
- vy = -((my - y) / my) * MAX_STEP;
576
- else if (y > h - my)
577
- vy = (y - (h - my)) / my * MAX_STEP;
578
- return { vx, vy };
579
- }
580
- function FlexLayoutSplitScreenDragBox({
581
- onMouseDown,
582
- onTouchStart,
583
- dropEndCallback,
584
- style,
585
- navigationTitle,
586
- targetComponent,
587
- containerName,
588
- children,
589
- className,
590
- dropDocumentOutsideOption,
591
- screenKey = Array.from(
592
- window.crypto.getRandomValues(new Uint32Array(16)),
593
- (e) => e.toString(32).padStart(2, "0")
594
- ).join(""),
595
- isBlockingActiveInput = false,
596
- customData = {},
597
- scrollTargetRef,
598
- ...props
599
- }) {
600
- const scrollRAF = useRef(null);
601
- const velocity = useRef({ vx: 0, vy: 0 });
602
- const ref = useRef(null);
603
- const clonedNodeRef = useRef(null);
604
- const clonedWidth = useRef(null);
605
- const clonedHeight = useRef(null);
606
- const hrefUrlRef = useRef("");
607
- const { handleStart, handleMove, handleEnd } = useDragEvents({
608
- isBlockingActiveInput
609
- });
610
- const handleMoveWrapper = (event) => {
611
- let x = 0;
612
- let y = 0;
613
- if (event.type === "touchmove") {
614
- const t = event.touches[0];
615
- x = t.clientX;
616
- y = t.clientY;
617
- } else {
618
- const m = event;
619
- x = m.clientX;
620
- y = m.clientY;
621
- }
622
- const { vx, vy } = edgeVelocity(x, y);
623
- const inEdge = vx !== 0 || vy !== 0;
624
- if (clonedNodeRef.current?.isConnected && !inEdge) {
625
- event.preventDefault();
626
- if (scrollRAF.current) {
627
- cancelAnimationFrame(scrollRAF.current);
628
- scrollRAF.current = null;
629
- }
630
- }
631
- if (clonedNodeRef.current?.isConnected && inEdge) {
632
- event.preventDefault();
633
- velocity.current = { vx, vy };
634
- if (!scrollRAF.current) {
635
- const step = () => {
636
- scrollTargetRef?.current?.scrollBy(
637
- velocity.current.vx,
638
- velocity.current.vy
639
- );
640
- if (velocity.current.vx === 0 && velocity.current.vy === 0) {
641
- scrollRAF.current = null;
642
- return;
643
- }
644
- scrollRAF.current = requestAnimationFrame(step);
645
- };
646
- scrollRAF.current = requestAnimationFrame(step);
647
- }
648
- }
649
- if (event.type !== "touchmove") {
650
- event.preventDefault();
651
- }
652
- handleMove({
653
- event,
654
- notDragCallback: ({ x: x2, y: y2 }) => {
655
- if (clonedNodeRef.current) clonedNodeRef.current.remove();
656
- },
657
- dragStartCallback: ({ x: x2, y: y2 }) => {
658
- if (!clonedNodeRef.current) return;
659
- navigator.vibrate(100);
660
- clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
661
- clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
662
- },
663
- moveingCallback: ({ x: x2, y: y2 }) => {
664
- if (clonedNodeRef.current?.isConnected) {
665
- clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
666
- clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
667
- }
668
- dragState.next({
669
- isDragging: true,
670
- isDrop: false,
671
- navigationTitle,
672
- children: targetComponent,
673
- x: x2,
674
- y: y2,
675
- containerName,
676
- dropDocumentOutsideOption,
677
- customData
678
- });
679
- }
680
- });
681
- };
682
- const handleEndWrapper = (event) => {
683
- if (scrollRAF.current !== null) {
684
- cancelAnimationFrame(scrollRAF.current);
685
- scrollRAF.current = null;
686
- }
687
- velocity.current = { vx: 0, vy: 0 };
688
- handleEnd({
689
- event,
690
- dragEndCallback: ({ x, y }) => {
691
- const href = hrefUrlRef.current;
692
- if (clonedNodeRef.current) clonedNodeRef.current.remove();
693
- if (dropDocumentOutsideOption && isDocumentOut({ x, y })) {
694
- if (dropDocumentOutsideOption.isNewTap || !dropDocumentOutsideOption.widthRatio && !dropDocumentOutsideOption.heightRatio) {
695
- window.open(href, "_blank");
696
- } else {
697
- const width = window.innerWidth * (dropDocumentOutsideOption.widthRatio || 1);
698
- const height = window.innerHeight * (dropDocumentOutsideOption.heightRatio || 1);
699
- window.open(
700
- href,
701
- "_blank",
702
- `width=${width},height=${height},left=${window.screenLeft - x * -1 - width},top=${window.screenTop + y}`
703
- );
704
- }
705
- }
706
- dragState.next({
707
- isDragging: false,
708
- isDrop: true,
709
- navigationTitle,
710
- children: targetComponent,
711
- x,
712
- y,
713
- containerName,
714
- dropDocumentOutsideOption,
715
- dropEndCallback,
716
- screenKey,
717
- customData
718
- });
719
- }
720
- });
721
- };
722
- useEffect(() => {
723
- if (ref.current) {
724
- const clone = ref.current.cloneNode(true);
725
- const originRect = ref.current.getBoundingClientRect();
726
- clone.style.width = originRect.width + "px";
727
- clone.style.height = originRect.height + "px";
728
- clone.style.opacity = "0.3";
729
- clone.style.backdropFilter = "blur(6px)";
730
- clonedWidth.current = originRect.width;
731
- clonedHeight.current = originRect.height;
732
- if (dropDocumentOutsideOption?.openUrl) {
733
- hrefUrlRef.current = dropDocumentOutsideOption.openUrl;
734
- const href = document.createElement("span");
735
- href.textContent = hrefUrlRef.current;
736
- clone.prepend(href);
737
- }
738
- if (navigationTitle) {
739
- const title = document.createElement("span");
740
- title.textContent = navigationTitle;
741
- clone.prepend(title);
742
- }
743
- clone.style.position = "fixed";
744
- clonedNodeRef.current = clone;
745
- clonedNodeRef.current.classList.add(
746
- FlexLayout_default["flex-split-screen-drag-box-clone"]
747
- );
748
- }
749
- }, []);
750
- useEffect(() => {
751
- const moveEvents = [
752
- "mousemove",
753
- "touchmove"
754
- ];
755
- const endEvents = ["mouseup", "touchend"];
756
- moveEvents.forEach((eventName) => {
757
- window.addEventListener(eventName, handleMoveWrapper, {
758
- passive: false
759
- });
760
- });
761
- endEvents.forEach((eventName) => {
762
- window.addEventListener(eventName, handleEndWrapper);
763
- });
764
- return () => {
765
- moveEvents.forEach((eventName) => {
766
- window.removeEventListener(eventName, handleMoveWrapper);
767
- });
768
- endEvents.forEach((eventName) => {
769
- window.removeEventListener(eventName, handleEndWrapper);
770
- });
771
- };
772
- }, [
773
- customData,
774
- targetComponent,
775
- dropDocumentOutsideOption,
776
- screenKey,
777
- isBlockingActiveInput,
778
- containerName,
779
- navigationTitle,
780
- dropEndCallback
781
- ]);
782
- useEffect(() => {
783
- const el = ref.current;
784
- if (!el) return;
785
- const onCtx = (e) => e.preventDefault();
786
- el.addEventListener("contextmenu", onCtx);
787
- return () => {
788
- el.removeEventListener("contextmenu", onCtx);
789
- };
790
- }, []);
791
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
792
- "div",
793
- {
794
- className: `${className || ""} ${FlexLayout_default["flex-split-screen-drag-box"]}`,
795
- ref,
796
- onContextMenu: (e) => e.preventDefault(),
797
- onMouseDown: (ev) => {
798
- if (onMouseDown) {
799
- Promise.resolve().then(() => onMouseDown(ev));
800
- }
801
- handleStart({
802
- event: ev,
803
- dragStartCallback: ({ x, y }) => {
804
- if (clonedNodeRef.current) {
805
- document.body.appendChild(
806
- clonedNodeRef.current
807
- );
808
- if (ref.current) {
809
- const originRect = ref.current.getBoundingClientRect();
810
- clonedNodeRef.current.style.width = originRect.width + "px";
811
- clonedNodeRef.current.style.height = originRect.height + "px";
812
- clonedWidth.current = originRect.width;
813
- clonedHeight.current = originRect.height;
814
- }
815
- }
816
- if (clonedNodeRef.current?.isConnected) {
817
- navigator.vibrate(100);
818
- clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
819
- clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
820
- }
821
- dragState.next({
822
- isDragging: true,
823
- isDrop: false,
824
- navigationTitle,
825
- children: targetComponent,
826
- x,
827
- y,
828
- containerName,
829
- dropDocumentOutsideOption,
830
- customData
831
- });
832
- }
833
- });
834
- },
835
- onTouchStart: (ev) => {
836
- if (onTouchStart) {
837
- Promise.resolve().then(() => onTouchStart(ev));
838
- }
839
- handleStart({
840
- event: ev,
841
- dragStartCallback: ({ x, y }) => {
842
- if (clonedNodeRef.current) {
843
- document.body.appendChild(
844
- clonedNodeRef.current
845
- );
846
- if (ref.current) {
847
- const originRect = ref.current.getBoundingClientRect();
848
- clonedNodeRef.current.style.width = originRect.width + "px";
849
- clonedNodeRef.current.style.height = originRect.height + "px";
850
- clonedWidth.current = originRect.width;
851
- clonedHeight.current = originRect.height;
852
- }
853
- }
854
- if (clonedNodeRef.current?.isConnected) {
855
- navigator.vibrate(100);
856
- clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
857
- clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
858
- }
859
- dragState.next({
860
- isDragging: true,
861
- isDrop: false,
862
- navigationTitle,
863
- children: targetComponent,
864
- x,
865
- y,
866
- containerName,
867
- dropDocumentOutsideOption,
868
- customData
869
- });
870
- }
871
- });
872
- },
873
- style: { ...style },
874
- ...props,
875
- children
876
- }
877
- ) });
878
- }
879
-
880
- // src/flex-layout/styles/listScroll.module.css
881
- var listScroll_default = {};
882
- var FlexLayoutSplitScreenScrollBox = ({
883
- className,
884
- children,
885
- keyName,
886
- direction,
887
- isDefaultScrollStyle = false,
888
- ...props
889
- }) => {
890
- const scrollRef = useRef(null);
891
- const [isMouseDown, setIsMouseDown] = useState(false);
892
- const scrollEventSubject = useRef(new Subject());
893
- useEffect(() => {
894
- const mouseUpSubscribe = fromEvent(
895
- window,
896
- "mouseup"
897
- ).subscribe(() => {
898
- setIsMouseDown(false);
899
- });
900
- const scrollEventSubscribe = scrollEventSubject.current.pipe(throttleTime(70)).subscribe((position) => {
901
- setScrollPosition(keyName, position);
902
- });
903
- const scrollSubscribe = getScrollPosition(keyName).pipe(take(1)).subscribe((position) => {
904
- if (scrollRef.current && position) {
905
- scrollRef.current.scrollLeft = position.x;
906
- scrollRef.current.scrollTop = position.y;
907
- }
908
- });
909
- return () => {
910
- removeScrollPosition(keyName);
911
- mouseUpSubscribe.unsubscribe();
912
- scrollSubscribe.unsubscribe();
913
- scrollEventSubscribe.unsubscribe();
914
- };
915
- }, [keyName]);
916
- useEffect(() => {
917
- if (!scrollRef.current) return;
918
- let animationFrameId = null;
919
- const handleWheel = (event) => {
920
- if (!scrollRef.current || direction !== "x") return;
921
- if (scrollRef.current.matches(":hover")) {
922
- event.preventDefault();
923
- const { deltaY } = event;
924
- const newScrollLeft = scrollRef.current.scrollLeft + deltaY;
925
- if (animationFrameId) {
926
- cancelAnimationFrame(animationFrameId);
927
- }
928
- animationFrameId = requestAnimationFrame(() => {
929
- scrollRef.current.scrollLeft = newScrollLeft;
930
- scrollEventSubject.current.next({
931
- x: newScrollLeft,
932
- y: scrollRef.current.scrollTop
933
- });
934
- animationFrameId = null;
935
- });
936
- }
937
- };
938
- scrollRef.current.addEventListener("wheel", handleWheel, {
939
- passive: false
940
- });
941
- return () => {
942
- scrollRef.current?.removeEventListener("wheel", handleWheel);
943
- };
944
- }, []);
945
- return /* @__PURE__ */ jsx(
946
- "div",
947
- {
948
- ref: scrollRef,
949
- onMouseUp: () => setIsMouseDown(false),
950
- onMouseDown: () => setIsMouseDown(true),
951
- onMouseMove: (event) => {
952
- if (!scrollRef.current || !isMouseDown || direction !== "x")
953
- return;
954
- scrollRef.current.scrollLeft += event.movementX * -1;
955
- scrollEventSubject.current.next({
956
- x: scrollRef.current.scrollLeft,
957
- y: scrollRef.current.scrollTop
958
- });
959
- },
960
- onScroll: () => {
961
- if (!scrollRef.current) return;
962
- scrollEventSubject.current.next({
963
- x: scrollRef.current.scrollLeft,
964
- y: scrollRef.current.scrollTop
965
- });
966
- },
967
- className: `${className || ""} ${isDefaultScrollStyle ? listScroll_default["default-scroll"] : listScroll_default["list-scroll"]} ${direction ? listScroll_default[direction] : ""}`,
968
- ...props,
969
- children
970
- }
971
- );
972
- };
973
- var FlexLayoutSplitScreenScrollBox_default = memo(FlexLayoutSplitScreenScrollBox);
974
- function FlexLayoutSplitScreenDragBoxContainer({
975
- className,
976
- children,
977
- layoutName,
978
- ...props
979
- }) {
980
- return /* @__PURE__ */ jsx(
981
- FlexLayoutSplitScreenScrollBox_default,
982
- {
983
- keyName: layoutName,
984
- className: `${FlexLayout_default["flex-split-screen-drag-box-title-container"]} ${className && className !== "" && className || ""}`,
985
- direction: "x",
986
- ...props,
987
- children
988
- }
989
- );
990
- }
991
- function FlexLayoutSplitScreenDragBoxItem({
992
- children,
993
- onClose,
994
- isActive,
995
- ...props
996
- }) {
997
- useEffect(() => {
998
- allSplitScreenCount.next(allSplitScreenCount.value + 1);
999
- return () => {
1000
- if (allSplitScreenCount.value <= 1) return;
1001
- allSplitScreenCount.next(allSplitScreenCount.value - 1);
1002
- };
1003
- }, []);
1004
- return /* @__PURE__ */ jsxs(
1005
- "div",
1006
- {
1007
- className: `${FlexLayout_default["flex-split-screen-drag-box-title-item"]} ${isActive ? FlexLayout_default["active"] : ""}`,
1008
- ...props,
1009
- children: [
1010
- children,
1011
- /* @__PURE__ */ jsx("button", { type: "button", onClick: (ev) => onClose(ev), children: "X" })
1012
- ]
1013
- }
1014
- );
1015
- }
1016
- function FlexLayoutSplitScreenDragBoxTitleMore({
1017
- className,
1018
- ...props
1019
- }) {
1020
- return /* @__PURE__ */ jsxs(
1021
- "button",
1022
- {
1023
- ...props,
1024
- className: `${FlexLayout_default["flex-split-screen-drag-box-title-more"]} ${className || ""}`,
1025
- children: [
1026
- /* @__PURE__ */ jsx("span", { children: "." }),
1027
- /* @__PURE__ */ jsx("span", { children: "." }),
1028
- /* @__PURE__ */ jsx("span", { children: "." })
1029
- ]
1030
- }
1031
- );
1032
- }
1033
- function isOverDrop({
1034
- x,
1035
- y,
1036
- element
1037
- }) {
1038
- const {
1039
- x: elementX,
1040
- y: elementY,
1041
- right: elementRight,
1042
- bottom: elementBottom
1043
- } = element.getBoundingClientRect();
1044
- const isElementOver = x < elementX || x > elementRight || y < elementY || y > elementBottom;
1045
- return isElementOver;
1046
- }
1047
- function isInnerDrop({
1048
- x,
1049
- y,
1050
- element
1051
- }) {
1052
- const {
1053
- x: elementX,
1054
- y: elementY,
1055
- right: elementRight,
1056
- bottom: elementBottom
1057
- } = element.getBoundingClientRect();
1058
- const isElementInner = x >= elementX && x <= elementRight && y >= elementY && y <= elementBottom;
1059
- return isElementInner;
1060
- }
1061
- var handleUpdateDropTargetComponents = ({
1062
- orderName,
1063
- parentOrderName,
1064
- containerName,
1065
- parentLayoutName,
1066
- layoutName,
1067
- dropComponent,
1068
- navigationTitle,
1069
- nextContainerName,
1070
- isUsePrefix = true,
1071
- beforeDropTargetComponent,
1072
- afterDropTargetComponent,
1073
- centerDropTargetComponent,
1074
- dropDocumentOutsideOption,
1075
- screenKey = Array.from(
1076
- window.crypto.getRandomValues(new Uint32Array(16)),
1077
- (e) => e.toString(32).padStart(2, "0")
1078
- ).join("")
1079
- }) => {
1080
- const nextContainerNameOrderName = parentOrderName ? parentOrderName : orderName;
1081
- let listMap;
1082
- let list;
1083
- let key;
1084
- if (nextContainerNameOrderName === orderName || nextContainerNameOrderName === "center") {
1085
- listMap = orderName === "before" ? { beforeDropTargetComponent } : orderName === "after" ? { afterDropTargetComponent } : {
1086
- centerDropTargetComponent: centerDropTargetComponent.filter(
1087
- (e) => !e.containerName.split("_").at(0).startsWith(
1088
- containerName.split("_").at(0)
1089
- )
1090
- )
1091
- };
1092
- } else {
1093
- listMap = nextContainerNameOrderName === "before" ? { beforeDropTargetComponent } : { afterDropTargetComponent };
1094
- }
1095
- const entries = Object.entries(listMap)[0];
1096
- key = entries[0];
1097
- list = entries[1];
1098
- const newComponent = {
1099
- containerName: `${containerName + "_" + layoutName}${isUsePrefix ? "_" + orderName + "-" + list.length : ""}`,
1100
- component: cloneElement(
1101
- dropComponent,
1102
- { key: screenKey, screenKey }
1103
- ),
1104
- navigationTitle,
1105
- dropDocumentOutsideOption,
1106
- screenKey: screenKey || Array.from(
1107
- window.crypto.getRandomValues(new Uint32Array(16)),
1108
- (e) => e.toString(32).padStart(2, "0")
1109
- ).join("")
1110
- };
1111
- let allComponents;
1112
- if (nextContainerName) {
1113
- const index = list.findIndex(
1114
- (item) => item.containerName === nextContainerName
1115
- );
1116
- if (index !== -1) {
1117
- if (nextContainerNameOrderName === orderName) {
1118
- if (orderName === "before") {
1119
- allComponents = [
1120
- ...list.slice(0, index),
1121
- newComponent,
1122
- ...list.slice(index)
1123
- ];
1124
- } else {
1125
- allComponents = [
1126
- ...list.slice(0, index + 1),
1127
- newComponent,
1128
- ...list.slice(index + 1)
1129
- ];
1130
- }
1131
- } else {
1132
- if (nextContainerNameOrderName === "after" && orderName === "before") {
1133
- allComponents = [
1134
- ...list.slice(0, index),
1135
- newComponent,
1136
- ...list.slice(index)
1137
- ];
1138
- } else if (nextContainerNameOrderName === "before" && orderName === "after") {
1139
- allComponents = [
1140
- ...list.slice(0, index + 1),
1141
- newComponent,
1142
- ...list.slice(index + 1)
1143
- ];
1144
- } else {
1145
- if (orderName === "before") {
1146
- allComponents = [
1147
- ...list.slice(0, index),
1148
- newComponent,
1149
- ...list.slice(index)
1150
- ];
1151
- } else {
1152
- allComponents = [
1153
- ...list.slice(0, index + 1),
1154
- newComponent,
1155
- ...list.slice(index + 1)
1156
- ];
1157
- }
1158
- }
1159
- }
1160
- } else {
1161
- if (nextContainerNameOrderName === "center" && orderName === "after") {
1162
- allComponents = [newComponent, ...list];
1163
- } else if (nextContainerNameOrderName === "center" && orderName === "before") {
1164
- allComponents = [...list, newComponent];
1165
- } else {
1166
- allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1167
- }
1168
- }
1169
- } else {
1170
- allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1171
- }
1172
- const seen = /* @__PURE__ */ new Set();
1173
- const result = allComponents.filter((item) => {
1174
- if (seen.has(item.containerName)) {
1175
- return false;
1176
- }
1177
- seen.add(item.containerName);
1178
- return true;
1179
- });
1180
- dropMovementEventSubject.next({
1181
- state: "append",
1182
- targetParentLayoutName: parentLayoutName,
1183
- targetLayoutName: layoutName,
1184
- targetContainerName: containerName,
1185
- orderName
1186
- });
1187
- return { [key]: result };
1188
- };
1189
- var handleRemove = (list, targetContainerName, orderNameSetter) => {
1190
- const result = list.filter((e) => e.containerName !== targetContainerName);
1191
- if (result.length != list.length)
1192
- orderNameSetter(list.length - result.length);
1193
- return result;
1194
- };
1195
- function getAdjacentItem(items, currentIndex) {
1196
- if (currentIndex + 1 < items.length) {
1197
- return {
1198
- adjacentItem: items[currentIndex + 1],
1199
- adjacentIndex: currentIndex + 1
1200
- };
1201
- } else if (currentIndex - 1 >= 0) {
1202
- return {
1203
- adjacentItem: items[currentIndex - 1],
1204
- adjacentIndex: currentIndex - 1
1205
- };
1206
- }
1207
- return { adjacentItem: null, adjacentIndex: currentIndex };
1208
- }
1209
- var getSelfOrderName = (containerName) => {
1210
- const result = containerName.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);
1211
- if (["before", "center", "after"].some((e) => e === result)) {
1212
- return result;
1213
- } else {
1214
- return;
1215
- }
1216
- };
1217
- function FlexLayoutSplitScreen({
1218
- children,
1219
- containerName,
1220
- layoutName,
1221
- navigationTitle,
1222
- dropDocumentOutsideOption,
1223
- screenKey
1224
- }) {
1225
- const {
1226
- direction,
1227
- isSplit,
1228
- boundaryContainerSize,
1229
- afterDropTargetComponent,
1230
- beforeDropTargetComponent,
1231
- centerDropTargetComponent,
1232
- setAfterDropTargetComponent,
1233
- setBeforeDropTargetComponent,
1234
- setCenterDropTargetComponent,
1235
- layoutRef,
1236
- setIsSplit,
1237
- setDirection
1238
- } = useFlexLayoutSplitScreen({
1239
- isSplitInitial: false,
1240
- directionInitial: "row",
1241
- selfContainerName: containerName,
1242
- parentLayoutName: "",
1243
- layoutName
1244
- });
1245
- useEffect(() => {
1246
- resetRootSplitScreen(layoutName);
1247
- const subscribe = getSplitScreen(layoutName, layoutName).subscribe((layoutInfo) => {
1248
- if (layoutInfo) {
1249
- setBeforeDropTargetComponent([
1250
- ...layoutInfo.beforeDropTargetComponent
1251
- ]);
1252
- setAfterDropTargetComponent([
1253
- ...layoutInfo.afterDropTargetComponent
1254
- ]);
1255
- setCenterDropTargetComponent([
1256
- ...layoutInfo.centerDropTargetComponent
1257
- ]);
1258
- setDirection(layoutInfo.direction);
1259
- if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
1260
- setIsSplit(true);
1261
- }
1262
- } else {
1263
- setSplitScreen(layoutName, layoutName, {
1264
- afterDropTargetComponent: [],
1265
- beforeDropTargetComponent: [],
1266
- centerDropTargetComponent: [
1267
- {
1268
- containerName,
1269
- component: children,
1270
- navigationTitle,
1271
- dropDocumentOutsideOption,
1272
- screenKey: screenKey ? screenKey : Array.from(
1273
- window.crypto.getRandomValues(
1274
- new Uint32Array(16)
1275
- ),
1276
- (e) => e.toString(32).padStart(2, "0")
1277
- ).join("")
1278
- }
1279
- ],
1280
- direction
1281
- });
1282
- }
1283
- });
1284
- return () => {
1285
- subscribe.unsubscribe();
1286
- resetRootSplitScreen(layoutName);
1287
- };
1288
- }, [layoutName]);
1289
- useEffect(() => {
1290
- const subscribe = dropMovementEventSubject.pipe(
1291
- distinctUntilChanged((prev, curr) => {
1292
- const filterChildren = (obj) => {
1293
- const {
1294
- children: children2,
1295
- component,
1296
- targetComponent,
1297
- x,
1298
- y,
1299
- ...rest
1300
- } = obj || {};
1301
- return rest;
1302
- };
1303
- return equal(filterChildren(prev), filterChildren(curr));
1304
- })
1305
- ).subscribe((event) => {
1306
- if (event.state === "remove") {
1307
- if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
1308
- requestAnimationFrame(() => {
1309
- let removeCallback = (removeOrderName) => {
1310
- if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
1311
- const targetComponentsMap = handleUpdateDropTargetComponents({
1312
- orderName: removeOrderName,
1313
- containerName: event.nextContainerName,
1314
- parentLayoutName: "",
1315
- layoutName,
1316
- dropComponent: event.targetComponent,
1317
- navigationTitle: event.dropTargetComponentEvent.navigationTitle,
1318
- isUsePrefix: true,
1319
- afterDropTargetComponent,
1320
- beforeDropTargetComponent,
1321
- centerDropTargetComponent,
1322
- dropDocumentOutsideOption,
1323
- screenKey: event.dropTargetComponentEvent.screenKey
1324
- });
1325
- setSplitScreen(layoutName, layoutName, {
1326
- ...getCurrentSplitScreenComponents(
1327
- layoutName,
1328
- layoutName
1329
- ) || {
1330
- afterDropTargetComponent,
1331
- beforeDropTargetComponent,
1332
- centerDropTargetComponent,
1333
- direction
1334
- },
1335
- ...targetComponentsMap
1336
- });
1337
- Promise.resolve().then(
1338
- () => event.dropEndCallback && event.dropEndCallback({
1339
- x: event.x,
1340
- y: event.y,
1341
- containerName
1342
- })
1343
- );
1344
- }
1345
- };
1346
- const currentComponents = getCurrentSplitScreenComponents(
1347
- layoutName,
1348
- layoutName
1349
- );
1350
- const afterList = handleRemove(
1351
- currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
1352
- event.targetContainerName,
1353
- () => removeCallback("after")
1354
- );
1355
- const beforList = handleRemove(
1356
- currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
1357
- event.targetContainerName,
1358
- () => removeCallback("before")
1359
- );
1360
- const centerList = handleRemove(
1361
- currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
1362
- event.targetContainerName,
1363
- () => removeCallback("center")
1364
- );
1365
- setSplitScreen(layoutName, layoutName, {
1366
- afterDropTargetComponent: afterList,
1367
- beforeDropTargetComponent: beforList,
1368
- centerDropTargetComponent: centerList,
1369
- direction
1370
- });
1371
- });
1372
- }
1373
- } else if (event.state === "append") {
1374
- const {
1375
- x,
1376
- y,
1377
- dropEndCallback,
1378
- dropTargetComponentEvent,
1379
- orderName,
1380
- parentOrderName,
1381
- targetLayoutName,
1382
- targetParentLayoutName,
1383
- targetContainerName,
1384
- targetComponent,
1385
- nextContainerName
1386
- } = event;
1387
- if (layoutRef.current && orderName && x && y && targetComponent && dropTargetComponentEvent && targetLayoutName === layoutName && isInnerDrop({ x, y, element: layoutRef.current })) {
1388
- const {
1389
- direction: dropDirection,
1390
- navigationTitle: navigationTitle2,
1391
- dropDocumentOutsideOption: dropDocumentOutsideOption2
1392
- } = dropTargetComponentEvent;
1393
- const isOrderNameNotCenter = orderName !== "center";
1394
- const isOrderNameCenterAndFirstScreen = orderName === "center" && centerDropTargetComponent.length <= 1;
1395
- if (isOrderNameNotCenter || isOrderNameCenterAndFirstScreen) {
1396
- setIsSplit(true);
1397
- if (isOrderNameNotCenter) {
1398
- setDirection(dropDirection);
1399
- const targetComponentsMap = handleUpdateDropTargetComponents({
1400
- orderName,
1401
- parentOrderName,
1402
- containerName: targetContainerName,
1403
- nextContainerName,
1404
- dropComponent: targetComponent,
1405
- parentLayoutName: "",
1406
- layoutName,
1407
- navigationTitle: navigationTitle2,
1408
- isUsePrefix: true,
1409
- afterDropTargetComponent,
1410
- beforeDropTargetComponent,
1411
- centerDropTargetComponent,
1412
- dropDocumentOutsideOption: dropDocumentOutsideOption2
1413
- });
1414
- setSplitScreen(layoutName, layoutName, {
1415
- ...{
1416
- afterDropTargetComponent,
1417
- beforeDropTargetComponent,
1418
- centerDropTargetComponent,
1419
- direction: dropDirection
1420
- },
1421
- ...targetComponentsMap,
1422
- ...{ direction: dropDirection }
1423
- });
1424
- Promise.resolve().then(
1425
- () => dropEndCallback && dropEndCallback({
1426
- x: event.x,
1427
- y: event.y,
1428
- containerName
1429
- })
1430
- );
1431
- } else {
1432
- const childScreenInfo = getCurrentSplitScreenComponents(
1433
- layoutName,
1434
- `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`
1435
- ) || {
1436
- afterDropTargetComponent: [],
1437
- beforeDropTargetComponent: [],
1438
- centerDropTargetComponent: [],
1439
- direction
1440
- };
1441
- setSplitScreen(
1442
- layoutName,
1443
- `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`,
1444
- {
1445
- ...childScreenInfo,
1446
- ...{
1447
- centerDropTargetComponent: [
1448
- centerDropTargetComponent[0],
1449
- {
1450
- containerName: `${targetContainerName}_${layoutName}_${orderName}`,
1451
- component: targetComponent,
1452
- dropDocumentOutsideOption: dropDocumentOutsideOption2,
1453
- screenKey: centerDropTargetComponent[0].screenKey,
1454
- navigationTitle: navigationTitle2
1455
- }
1456
- ]
1457
- }
1458
- }
1459
- );
1460
- }
1461
- }
1462
- }
1463
- }
1464
- });
1465
- return () => {
1466
- subscribe.unsubscribe();
1467
- };
1468
- }, [
1469
- direction,
1470
- layoutName,
1471
- isSplit,
1472
- beforeDropTargetComponent,
1473
- afterDropTargetComponent,
1474
- centerDropTargetComponent
1475
- ]);
1476
- return /* @__PURE__ */ jsxs("div", { className: `${FlexLayout_default["flex-split-screen"]}`, ref: layoutRef, children: [
1477
- /* @__PURE__ */ jsxs(
1478
- FlexLayout_default2,
1479
- {
1480
- direction,
1481
- layoutName,
1482
- "data-is_split": isSplit,
1483
- panelMovementMode: "bulldozer",
1484
- children: [
1485
- beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
1486
- ({
1487
- containerName: cName,
1488
- component,
1489
- navigationTitle: navigationTitle2,
1490
- dropDocumentOutsideOption: dropDocumentOutsideOption2,
1491
- screenKey: screenKey2
1492
- }, i) => /* @__PURE__ */ jsx(
1493
- FlexLayoutContainer_default,
1494
- {
1495
- containerName: cName,
1496
- isInitialResizable: true,
1497
- isResizePanel: true,
1498
- children: /* @__PURE__ */ jsx(
1499
- FlexLayoutSplitScreenChild,
1500
- {
1501
- parentDirection: direction,
1502
- layoutName: `${layoutName}_before`,
1503
- parentLayoutName: layoutName,
1504
- containerName: cName,
1505
- depth: 1,
1506
- rootRef: layoutRef,
1507
- screenKey: screenKey2,
1508
- initialCenterComponents: [
1509
- {
1510
- navigationTitle: navigationTitle2,
1511
- component,
1512
- containerName: cName,
1513
- dropDocumentOutsideOption: dropDocumentOutsideOption2,
1514
- screenKey: screenKey2
1515
- }
1516
- ],
1517
- rootName: layoutName
1518
- }
1519
- )
1520
- },
1521
- cName
1522
- )
1523
- ) }) : /* @__PURE__ */ jsx("div", {}),
1524
- centerDropTargetComponent.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx(
1525
- FlexLayoutContainer_default,
1526
- {
1527
- containerName: `${centerDropTargetComponent[0].containerName}`,
1528
- isInitialResizable: true,
1529
- isResizePanel: isSplit,
1530
- children: isSplit ? /* @__PURE__ */ jsx(
1531
- FlexLayoutSplitScreenChild,
1532
- {
1533
- parentDirection: direction,
1534
- layoutName: `${layoutName}_center`,
1535
- parentLayoutName: layoutName,
1536
- containerName: `${centerDropTargetComponent[0].containerName}`,
1537
- depth: 0,
1538
- rootRef: layoutRef,
1539
- screenKey: centerDropTargetComponent[0].screenKey,
1540
- initialCenterComponents: [
1541
- {
1542
- navigationTitle: centerDropTargetComponent[0].navigationTitle,
1543
- component: centerDropTargetComponent[0].component,
1544
- containerName: centerDropTargetComponent[0].containerName,
1545
- dropDocumentOutsideOption: centerDropTargetComponent[0].dropDocumentOutsideOption,
1546
- screenKey: centerDropTargetComponent[0].screenKey
1547
- }
1548
- ],
1549
- rootName: layoutName
1550
- }
1551
- ) : /* @__PURE__ */ jsx(
1552
- FlexLayoutSplitScreenScrollBox_default,
1553
- {
1554
- keyName: centerDropTargetComponent[0].containerName,
1555
- isDefaultScrollStyle: true,
1556
- children: centerDropTargetComponent[0].component
1557
- }
1558
- )
1559
- }
1560
- ),
1561
- afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
1562
- ({
1563
- containerName: cName,
1564
- component,
1565
- navigationTitle: navigationTitle2,
1566
- dropDocumentOutsideOption: dropDocumentOutsideOption2,
1567
- screenKey: screenKey2
1568
- }, i) => /* @__PURE__ */ jsx(
1569
- FlexLayoutContainer_default,
1570
- {
1571
- containerName: cName,
1572
- isInitialResizable: true,
1573
- isResizePanel: afterDropTargetComponent.length - 1 !== i,
1574
- children: /* @__PURE__ */ jsx(
1575
- FlexLayoutSplitScreenChild,
1576
- {
1577
- parentDirection: direction,
1578
- layoutName: `${layoutName}_after`,
1579
- parentLayoutName: layoutName,
1580
- containerName: cName,
1581
- depth: 1,
1582
- rootRef: layoutRef,
1583
- screenKey: screenKey2,
1584
- initialCenterComponents: [
1585
- {
1586
- navigationTitle: navigationTitle2,
1587
- component,
1588
- containerName: cName,
1589
- dropDocumentOutsideOption: dropDocumentOutsideOption2,
1590
- screenKey: screenKey2
1591
- }
1592
- ],
1593
- rootName: layoutName
1594
- }
1595
- )
1596
- },
1597
- cName
1598
- )
1599
- ) }) : /* @__PURE__ */ jsx("div", {})
1600
- ]
1601
- }
1602
- ),
1603
- boundaryContainerSize && /* @__PURE__ */ jsx(
1604
- "div",
1605
- {
1606
- className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
1607
- style: { ...boundaryContainerSize },
1608
- children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
1609
- }
1610
- )
1611
- ] });
1612
- }
1613
- function FlexLayoutSplitScreenChild({
1614
- containerName,
1615
- layoutName,
1616
- parentLayoutName,
1617
- parentDirection,
1618
- depth,
1619
- //isSplit: isSplitInitial,
1620
- rootRef,
1621
- rootName,
1622
- initialCenterComponents,
1623
- screenKey
1624
- }) {
1625
- const {
1626
- direction,
1627
- isSplit,
1628
- boundaryContainerSize,
1629
- afterDropTargetComponent,
1630
- beforeDropTargetComponent,
1631
- centerDropTargetComponent,
1632
- setAfterDropTargetComponent,
1633
- setBeforeDropTargetComponent,
1634
- setCenterDropTargetComponent,
1635
- layoutRef,
1636
- setIsSplit,
1637
- setDirection
1638
- } = useFlexLayoutSplitScreen({
1639
- isSplitInitial: false,
1640
- directionInitial: "row",
1641
- parentDirection,
1642
- selfContainerName: containerName,
1643
- parentLayoutName,
1644
- layoutName
1645
- });
1646
- const [isEmptyContent, setIsEmptyContent] = useState(false);
1647
- const [activeIndex, setActiveIndex] = useState(0);
1648
- const centerDropTargetComponentRef = useRef(centerDropTargetComponent);
1649
- const activeIndexRef = useRef(activeIndex);
1650
- useEffect(() => {
1651
- const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).pipe(take$1(1)).subscribe((layoutInfo) => {
1652
- setSplitScreen(rootName, `${layoutName}=${screenKey}`, {
1653
- afterDropTargetComponent: layoutInfo?.afterDropTargetComponent || [],
1654
- beforeDropTargetComponent: layoutInfo?.beforeDropTargetComponent || [],
1655
- centerDropTargetComponent: layoutInfo?.centerDropTargetComponent || initialCenterComponents || [],
1656
- direction: layoutInfo?.direction || direction
1657
- });
1658
- });
1659
- return () => {
1660
- removeSplitScreenChild(rootName, layoutName);
1661
- subscribe.unsubscribe();
1662
- };
1663
- }, [rootName, layoutName, initialCenterComponents]);
1664
- useEffect(() => {
1665
- const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).subscribe((layoutInfo) => {
1666
- if (layoutInfo) {
1667
- setBeforeDropTargetComponent([
1668
- ...layoutInfo.beforeDropTargetComponent
1669
- ]);
1670
- setAfterDropTargetComponent([
1671
- ...layoutInfo.afterDropTargetComponent
1672
- ]);
1673
- setCenterDropTargetComponent([
1674
- ...layoutInfo.centerDropTargetComponent
1675
- ]);
1676
- setDirection(layoutInfo.direction);
1677
- if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
1678
- setIsSplit(true);
1679
- } else if (layoutInfo.beforeDropTargetComponent.length === 0 && layoutInfo.centerDropTargetComponent.length === 0 && layoutInfo.afterDropTargetComponent.length === 0) {
1680
- dropMovementEventSubject.next({
1681
- state: "remove",
1682
- targetContainerName: containerName,
1683
- targetParentLayoutName: "",
1684
- targetLayoutName: parentLayoutName
1685
- });
1686
- setIsEmptyContent(true);
1687
- }
1688
- }
1689
- });
1690
- return () => {
1691
- subscribe.unsubscribe();
1692
- };
1693
- }, [rootName, layoutName]);
1694
- useEffect(() => {
1695
- const subscribe = dropMovementEventSubject.pipe(
1696
- distinctUntilChanged((prev, curr) => {
1697
- const filterChildren = (obj) => {
1698
- const {
1699
- children,
1700
- component,
1701
- targetComponent,
1702
- x,
1703
- y,
1704
- ...rest
1705
- } = obj || {};
1706
- return rest;
1707
- };
1708
- return equal(filterChildren(prev), filterChildren(curr));
1709
- })
1710
- ).subscribe((event) => {
1711
- if (event.state === "remove") {
1712
- if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
1713
- requestAnimationFrame(() => {
1714
- let removeCallback = (removeOrderName) => {
1715
- if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
1716
- const targetComponentsMap = handleUpdateDropTargetComponents({
1717
- orderName: removeOrderName,
1718
- containerName: event.nextContainerName,
1719
- parentLayoutName,
1720
- layoutName,
1721
- dropComponent: event.targetComponent,
1722
- navigationTitle: event.dropTargetComponentEvent.navigationTitle,
1723
- isUsePrefix: true,
1724
- afterDropTargetComponent,
1725
- beforeDropTargetComponent,
1726
- centerDropTargetComponent,
1727
- dropDocumentOutsideOption: event.dropTargetComponentEvent?.dropDocumentOutsideOption,
1728
- screenKey: event.dropTargetComponentEvent.screenKey
1729
- });
1730
- setSplitScreen(
1731
- rootName,
1732
- `${layoutName}=${screenKey}`,
1733
- {
1734
- ...getCurrentSplitScreenComponents(
1735
- rootName,
1736
- `${layoutName}=${screenKey}`
1737
- ) || {
1738
- afterDropTargetComponent,
1739
- beforeDropTargetComponent,
1740
- centerDropTargetComponent,
1741
- direction
1742
- },
1743
- ...targetComponentsMap
1744
- }
1745
- );
1746
- Promise.resolve().then(
1747
- () => event.dropEndCallback && event.dropEndCallback({
1748
- x: event.x,
1749
- y: event.y,
1750
- containerName
1751
- })
1752
- );
1753
- }
1754
- };
1755
- const currentComponents = getCurrentSplitScreenComponents(
1756
- rootName,
1757
- `${layoutName}=${screenKey}`
1758
- );
1759
- const afterList = handleRemove(
1760
- currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
1761
- event.targetContainerName,
1762
- () => removeCallback("after")
1763
- );
1764
- const beforList = handleRemove(
1765
- currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
1766
- event.targetContainerName,
1767
- () => removeCallback("before")
1768
- );
1769
- const centerList = handleRemove(
1770
- currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
1771
- event.targetContainerName,
1772
- () => removeCallback("center")
1773
- );
1774
- setSplitScreen(
1775
- rootName,
1776
- `${layoutName}=${screenKey}`,
1777
- {
1778
- afterDropTargetComponent: afterList,
1779
- beforeDropTargetComponent: beforList,
1780
- centerDropTargetComponent: centerList,
1781
- direction
1782
- }
1783
- );
1784
- });
1785
- }
1786
- } else if (event.state === "append") {
1787
- const {
1788
- x,
1789
- y,
1790
- dropEndCallback,
1791
- dropTargetComponentEvent,
1792
- orderName,
1793
- targetLayoutName,
1794
- targetParentLayoutName,
1795
- targetContainerName,
1796
- targetComponent,
1797
- nextContainerName,
1798
- parentOrderName
1799
- } = event;
1800
- if (layoutRef.current && orderName && x && y && dropTargetComponentEvent && isInnerDrop({ x, y, element: layoutRef.current })) {
1801
- const {
1802
- direction: dropDirection,
1803
- navigationTitle,
1804
- dropDocumentOutsideOption,
1805
- screenKey: containerScreenKey
1806
- } = dropTargetComponentEvent;
1807
- if (
1808
- //orderName !== 'center' &&
1809
- targetLayoutName === layoutName && targetComponent
1810
- ) {
1811
- if (dropDirection === parentDirection && orderName !== "center") {
1812
- dropMovementEventSubject.next({
1813
- state: "append",
1814
- targetContainerName,
1815
- targetParentLayoutName: "",
1816
- targetLayoutName: parentLayoutName,
1817
- targetComponent,
1818
- nextContainerName: containerName,
1819
- parentOrderName: getSelfOrderName(layoutName) || orderName,
1820
- orderName,
1821
- x,
1822
- y,
1823
- dropEndCallback,
1824
- dropTargetComponentEvent: {
1825
- navigationTitle,
1826
- dropDocumentOutsideOption,
1827
- direction: parentDirection,
1828
- screenKey
1829
- }
1830
- });
1831
- } else {
1832
- if (orderName !== "center") {
1833
- setDirection(dropDirection);
1834
- setIsSplit(true);
1835
- }
1836
- const targetComponentsMap = handleUpdateDropTargetComponents({
1837
- orderName,
1838
- parentOrderName,
1839
- containerName: targetContainerName,
1840
- nextContainerName,
1841
- parentLayoutName,
1842
- layoutName,
1843
- dropComponent: targetComponent,
1844
- navigationTitle,
1845
- isUsePrefix: orderName !== "center",
1846
- afterDropTargetComponent,
1847
- beforeDropTargetComponent,
1848
- centerDropTargetComponent,
1849
- dropDocumentOutsideOption
1850
- });
1851
- setSplitScreen(
1852
- rootName,
1853
- `${layoutName}=${screenKey}`,
1854
- {
1855
- ...getCurrentSplitScreenComponents(
1856
- rootName,
1857
- `${layoutName}=${screenKey}`
1858
- ) || {
1859
- afterDropTargetComponent,
1860
- beforeDropTargetComponent,
1861
- centerDropTargetComponent,
1862
- direction
1863
- },
1864
- ...targetComponentsMap,
1865
- ...{ direction: dropDirection }
1866
- }
1867
- );
1868
- Promise.resolve().then(
1869
- () => event.dropEndCallback && event.dropEndCallback({
1870
- x: event.x,
1871
- y: event.y,
1872
- containerName
1873
- })
1874
- );
1875
- }
1876
- }
1877
- }
1878
- }
1879
- });
1880
- return () => {
1881
- subscribe.unsubscribe();
1882
- };
1883
- }, [
1884
- direction,
1885
- parentDirection,
1886
- parentLayoutName,
1887
- layoutName,
1888
- beforeDropTargetComponent,
1889
- afterDropTargetComponent,
1890
- centerDropTargetComponent
1891
- ]);
1892
- useEffect(() => {
1893
- centerDropTargetComponentRef.current = centerDropTargetComponent;
1894
- }, [centerDropTargetComponent]);
1895
- useEffect(() => {
1896
- activeIndexRef.current = activeIndex;
1897
- }, [activeIndex]);
1898
- const [isOnlyOneScreen, setIsOnlyOneScreen] = useState(false);
1899
- return /* @__PURE__ */ jsx(Fragment, { children: !isEmptyContent && /* @__PURE__ */ jsxs(
1900
- "div",
1901
- {
1902
- className: `${FlexLayout_default["flex-split-screen"]}`,
1903
- ref: layoutRef,
1904
- children: [
1905
- /* @__PURE__ */ jsxs(
1906
- FlexLayout_default2,
1907
- {
1908
- direction,
1909
- layoutName: `${layoutName}`,
1910
- panelMovementMode: "bulldozer",
1911
- children: [
1912
- beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
1913
- ({
1914
- containerName: cName,
1915
- component,
1916
- navigationTitle,
1917
- dropDocumentOutsideOption,
1918
- screenKey: screenKey2
1919
- }, i) => /* @__PURE__ */ jsx(
1920
- FlexLayoutContainer_default,
1921
- {
1922
- containerName: cName,
1923
- isInitialResizable: true,
1924
- isResizePanel: true,
1925
- children: /* @__PURE__ */ jsx(
1926
- FlexLayoutSplitScreenChild,
1927
- {
1928
- parentDirection: direction,
1929
- layoutName: `${layoutName}_before-${depth}`,
1930
- parentLayoutName: layoutName,
1931
- containerName: cName,
1932
- depth: depth + 1,
1933
- rootRef,
1934
- screenKey: screenKey2,
1935
- initialCenterComponents: [
1936
- {
1937
- navigationTitle,
1938
- component,
1939
- containerName: cName,
1940
- dropDocumentOutsideOption,
1941
- screenKey: screenKey2
1942
- }
1943
- ],
1944
- rootName
1945
- }
1946
- )
1947
- },
1948
- cName
1949
- )
1950
- ) }) : /* @__PURE__ */ jsx("div", {}),
1951
- centerDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1952
- FlexLayoutContainer_default,
1953
- {
1954
- containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
1955
- isInitialResizable: true,
1956
- isResizePanel: isSplit,
1957
- children: isSplit ? /* @__PURE__ */ jsx("div", { "data-key": screenKey, children: /* @__PURE__ */ jsx(
1958
- FlexLayoutSplitScreenChild,
1959
- {
1960
- parentDirection: direction,
1961
- layoutName: `${layoutName}_center-${depth}`,
1962
- parentLayoutName: layoutName,
1963
- containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
1964
- depth: depth + 1,
1965
- rootRef,
1966
- initialCenterComponents: centerDropTargetComponent.map(
1967
- ({
1968
- navigationTitle,
1969
- component,
1970
- containerName: cName,
1971
- dropDocumentOutsideOption,
1972
- screenKey: centerScreenKey
1973
- }) => ({
1974
- navigationTitle,
1975
- component,
1976
- containerName: cName,
1977
- dropDocumentOutsideOption,
1978
- screenKey: centerScreenKey
1979
- })
1980
- ),
1981
- screenKey,
1982
- rootName
1983
- }
1984
- ) }) : /* @__PURE__ */ jsxs(
1985
- FlexLayoutSplitScreenScrollBox_default,
1986
- {
1987
- keyName: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName,
1988
- isDefaultScrollStyle: true,
1989
- children: [
1990
- !isOnlyOneScreen && /* @__PURE__ */ jsx(
1991
- "div",
1992
- {
1993
- className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper-sticky"]}`,
1994
- children: /* @__PURE__ */ jsxs(
1995
- "div",
1996
- {
1997
- "data-is_split": isSplit,
1998
- "data-layout_name": layoutName,
1999
- "data-parent_layout_name": parentLayoutName,
2000
- "data-container_name": `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2001
- className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper"]}`,
2002
- children: [
2003
- /* @__PURE__ */ jsx(
2004
- FlexLayoutSplitScreenDragBoxContainer,
2005
- {
2006
- "data-layout_name": layoutName,
2007
- layoutName,
2008
- children: centerDropTargetComponent.map(
2009
- (item, index) => /* @__PURE__ */ jsx(
2010
- FlexLayoutSplitScreenDragBoxItem,
2011
- {
2012
- onClose: (ev) => {
2013
- if (activeIndexRef.current === index && centerDropTargetComponent.length === 1) {
2014
- dropMovementEventSubject.next(
2015
- {
2016
- state: "remove",
2017
- targetContainerName: containerName,
2018
- targetParentLayoutName: parentLayoutName,
2019
- targetLayoutName: layoutName
2020
- }
2021
- );
2022
- } else {
2023
- if (centerDropTargetComponent.length === activeIndexRef.current + 1) {
2024
- setActiveIndex(
2025
- activeIndexRef.current - 1
2026
- );
2027
- }
2028
- setCenterDropTargetComponent(
2029
- (prev) => {
2030
- const result = handleRemove(
2031
- prev,
2032
- item.containerName,
2033
- () => {
2034
- }
2035
- );
2036
- return result;
2037
- }
2038
- );
2039
- }
2040
- },
2041
- isActive: activeIndex === index,
2042
- children: /* @__PURE__ */ jsx(
2043
- FlexLayoutSplitScreenDragBox,
2044
- {
2045
- onClick: () => {
2046
- setActiveIndex(
2047
- index
2048
- );
2049
- },
2050
- containerName: item.containerName,
2051
- dropDocumentOutsideOption: item.dropDocumentOutsideOption,
2052
- targetComponent: item.component,
2053
- navigationTitle: item.navigationTitle,
2054
- "data-container-name": item.containerName,
2055
- "data-layout-name": layoutName,
2056
- "data-parent-layout-name": parentLayoutName,
2057
- dropEndCallback: ({
2058
- x,
2059
- y,
2060
- containerName: appendContainerName
2061
- }) => {
2062
- if (!rootRef.current || !layoutRef.current)
2063
- return;
2064
- const isRootOver = isOverDrop(
2065
- {
2066
- x,
2067
- y,
2068
- element: rootRef.current
2069
- }
2070
- );
2071
- const isLayoutInner = isInnerDrop(
2072
- {
2073
- x,
2074
- y,
2075
- element: layoutRef.current
2076
- }
2077
- );
2078
- if (!isRootOver && !isLayoutInner || !isRootOver && isLayoutInner && centerDropTargetComponentRef.current.length > 1) {
2079
- const option = {};
2080
- if (centerDropTargetComponentRef.current.length > 1) {
2081
- const {
2082
- adjacentItem,
2083
- adjacentIndex
2084
- } = getAdjacentItem(
2085
- centerDropTargetComponentRef.current,
2086
- activeIndexRef.current
2087
- );
2088
- if (adjacentItem && activeIndexRef.current === index) {
2089
- Object.assign(
2090
- option,
2091
- {
2092
- x,
2093
- y,
2094
- targetComponent: adjacentItem.component,
2095
- nextContainerName: adjacentItem.containerName,
2096
- orderName: "center",
2097
- dropTargetComponentEvent: {
2098
- navigationTitle: adjacentItem.navigationTitle,
2099
- dropDocumentOutsideOption: adjacentItem.dropDocumentOutsideOption,
2100
- direction,
2101
- screenKey
2102
- }
2103
- }
2104
- );
2105
- }
2106
- }
2107
- if (index === 0) {
2108
- dropMovementEventSubject.next(
2109
- {
2110
- state: "remove",
2111
- targetContainerName: item.containerName,
2112
- targetParentLayoutName: parentLayoutName,
2113
- targetLayoutName: layoutName,
2114
- ...option
2115
- }
2116
- );
2117
- } else {
2118
- dropMovementEventSubject.next(
2119
- {
2120
- state: "remove",
2121
- targetContainerName: item.containerName,
2122
- targetParentLayoutName: "",
2123
- targetLayoutName: layoutName,
2124
- ...option
2125
- }
2126
- );
2127
- }
2128
- }
2129
- },
2130
- children: item.navigationTitle
2131
- }
2132
- )
2133
- },
2134
- item.navigationTitle + layoutName + item.containerName
2135
- )
2136
- )
2137
- },
2138
- layoutName
2139
- ),
2140
- /* @__PURE__ */ jsx(FlexLayoutSplitScreenDragBoxTitleMore, {})
2141
- ]
2142
- }
2143
- )
2144
- }
2145
- ),
2146
- (() => {
2147
- const target = centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0];
2148
- return target.component;
2149
- })()
2150
- ]
2151
- }
2152
- )
2153
- },
2154
- (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName
2155
- ) }) : /* @__PURE__ */ jsx("div", {}),
2156
- afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
2157
- ({
2158
- containerName: cName,
2159
- component,
2160
- navigationTitle,
2161
- dropDocumentOutsideOption,
2162
- screenKey: screenKey2
2163
- }, i) => /* @__PURE__ */ jsx(
2164
- FlexLayoutContainer_default,
2165
- {
2166
- containerName: cName,
2167
- isInitialResizable: true,
2168
- isResizePanel: i !== afterDropTargetComponent.length - 1,
2169
- children: /* @__PURE__ */ jsx(
2170
- FlexLayoutSplitScreenChild,
2171
- {
2172
- parentDirection: direction,
2173
- layoutName: `${layoutName}_after-${depth}`,
2174
- parentLayoutName: layoutName,
2175
- containerName: cName,
2176
- depth: depth + 1,
2177
- rootRef,
2178
- screenKey: screenKey2,
2179
- initialCenterComponents: [
2180
- {
2181
- navigationTitle,
2182
- component,
2183
- containerName: cName,
2184
- dropDocumentOutsideOption,
2185
- screenKey: screenKey2
2186
- }
2187
- ],
2188
- rootName
2189
- }
2190
- )
2191
- },
2192
- cName
2193
- )
2194
- ) }) : /* @__PURE__ */ jsx("div", {})
2195
- ]
2196
- }
2197
- ),
2198
- boundaryContainerSize && /* @__PURE__ */ jsx(
2199
- "div",
2200
- {
2201
- className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
2202
- style: { ...boundaryContainerSize },
2203
- children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
2204
- }
2205
- )
2206
- ]
2207
- }
2208
- ) });
2209
- }
2210
- FlexLayoutSplitScreen.displayName = "FlexLayoutSplitScreen";
2211
- var FlexLayoutSplitScreen_default = FlexLayoutSplitScreen;
2212
- function clamp(n, min, max) {
2213
- return Math.max(min, Math.min(max, n));
2214
- }
2215
- function pickDefaultScrollRoot() {
2216
- if (typeof document === "undefined") return null;
2217
- let el = document.body;
2218
- while (el && el !== document.documentElement && el !== document.body) {
2219
- const style = getComputedStyle(el);
2220
- const oy = style.overflowY;
2221
- const ox = style.overflowX;
2222
- const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
2223
- if (scrollable) return el;
2224
- el = el.parentElement;
2225
- }
2226
- return null;
2227
- }
2228
- function isVerticalScroll(root) {
2229
- if (typeof window == "undefined") return true;
2230
- if (!root) {
2231
- return document.documentElement.scrollHeight > window.innerHeight + 1;
2232
- }
2233
- const el = root;
2234
- return el.scrollHeight > el.clientHeight + 1;
2235
- }
2236
- var dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
2237
- function quantizeToDevicePixel(n) {
2238
- return Math.round(n * dpr) / dpr;
2239
- }
2240
- var FlexLayoutStickyBox = ({
2241
- edge = "auto",
2242
- offset = 16,
2243
- scrollRoot = null,
2244
- debug = false,
2245
- children,
2246
- style,
2247
- className,
2248
- onTranslateChange = () => {
2249
- },
2250
- ...rest
2251
- }) => {
2252
- const offsetRef = useRef(offset);
2253
- const rootRef = useRef(null);
2254
- const contentRef = useRef(null);
2255
- const mutatingRef = useRef(false);
2256
- const lastOffsetRef = useRef(0);
2257
- const [resolvedEdge, setResolvedEdge] = useState("top");
2258
- const rafId = useRef(null);
2259
- const [contentDynamicStyle, setContentDynamicStyle] = useState({});
2260
- useEffect(() => {
2261
- setContentDynamicStyle({
2262
- willChange: "transform",
2263
- transition: "transform 50ms linear"
2264
- });
2265
- }, []);
2266
- useEffect(() => {
2267
- offsetRef.current = offset;
2268
- scheduleUpdate();
2269
- }, [offset]);
2270
- const [ioRoot, setIoRoot] = useState(null);
2271
- useEffect(() => {
2272
- const root = scrollRoot ?? pickDefaultScrollRoot();
2273
- setResolvedEdge(
2274
- edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
2275
- );
2276
- setIoRoot(root);
2277
- }, [edge, scrollRoot]);
2278
- useEffect(() => {
2279
- if (edge !== "auto") {
2280
- setResolvedEdge(edge);
2281
- return;
2282
- }
2283
- const vertical = isVerticalScroll(ioRoot);
2284
- setResolvedEdge(vertical ? "top" : "left");
2285
- }, [edge, ioRoot]);
2286
- useEffect(() => {
2287
- }, []);
2288
- const scheduleUpdate = () => {
2289
- if (rafId.current != null) return;
2290
- rafId.current = requestAnimationFrame(() => {
2291
- rafId.current = null;
2292
- doUpdate();
2293
- });
2294
- };
2295
- const doUpdate = () => {
2296
- if (mutatingRef.current) return;
2297
- mutatingRef.current = true;
2298
- const rootEl = rootRef.current;
2299
- const contentEl = contentRef.current;
2300
- if (!rootEl || !contentEl) {
2301
- mutatingRef.current = false;
2302
- return;
2303
- }
2304
- const parentEl = rootEl.parentElement;
2305
- if (!parentEl) {
2306
- mutatingRef.current = false;
2307
- return;
2308
- }
2309
- const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
2310
- const parentRect = parentEl.getBoundingClientRect();
2311
- const contentRect = contentEl.getBoundingClientRect();
2312
- let newOffset = 0;
2313
- if (resolvedEdge === "top" || resolvedEdge === "bottom") {
2314
- const maxTranslate = Math.max(
2315
- 0,
2316
- parentRect.height - contentRect.height
2317
- );
2318
- let desiredTop = 0;
2319
- if (resolvedEdge === "top") {
2320
- desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
2321
- } else {
2322
- const targetBottomFromParentTop = Math.min(
2323
- parentRect.bottom,
2324
- rootBounds.bottom - offsetRef.current
2325
- ) - parentRect.top;
2326
- desiredTop = targetBottomFromParentTop - contentRect.height;
2327
- }
2328
- newOffset = clamp(desiredTop, 0, maxTranslate);
2329
- } else {
2330
- const maxTranslate = Math.max(
2331
- 0,
2332
- parentRect.width - contentRect.width
2333
- );
2334
- let desiredLeft = 0;
2335
- if (resolvedEdge === "left") {
2336
- desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
2337
- } else {
2338
- const targetRightFromParentLeft = Math.min(
2339
- parentRect.right,
2340
- rootBounds.right - offsetRef.current
2341
- ) - parentRect.left;
2342
- desiredLeft = targetRightFromParentLeft - contentRect.width;
2343
- }
2344
- newOffset = clamp(desiredLeft, 0, maxTranslate);
2345
- }
2346
- const nextOffset = quantizeToDevicePixel(newOffset);
2347
- if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
2348
- if (resolvedEdge === "top" || resolvedEdge === "bottom") {
2349
- contentEl.style.transform = `translateY(${nextOffset}px)`;
2350
- } else {
2351
- contentEl.style.transform = `translateX(${nextOffset}px)`;
2352
- }
2353
- lastOffsetRef.current = nextOffset;
2354
- onTranslateChange(nextOffset, rootRef, contentRef);
2355
- }
2356
- if (debug) {
2357
- rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
2358
- contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
2359
- }
2360
- queueMicrotask(() => {
2361
- mutatingRef.current = false;
2362
- });
2363
- };
2364
- useEffect(() => {
2365
- if (typeof window == "undefined") return;
2366
- const rootEl = rootRef.current;
2367
- if (!rootEl) return;
2368
- const parentEl = rootEl.parentElement;
2369
- console.log(parentEl);
2370
- if (!parentEl) return;
2371
- const targets = [parentEl];
2372
- const observerCallback = () => {
2373
- if (!mutatingRef.current) scheduleUpdate();
2374
- };
2375
- const io = new IntersectionObserver(observerCallback, {
2376
- root: ioRoot instanceof Element ? ioRoot : null,
2377
- threshold: 0,
2378
- rootMargin: "1px"
2379
- });
2380
- const ro = new ResizeObserver(observerCallback);
2381
- targets.forEach((t) => io.observe(t));
2382
- ro.observe(parentEl);
2383
- if (contentRef.current) {
2384
- ro.observe(contentRef.current);
2385
- }
2386
- const scrollTarget = ioRoot || window;
2387
- scrollTarget.addEventListener("scroll", scheduleUpdate, {
2388
- passive: true
2389
- });
2390
- window.addEventListener("resize", scheduleUpdate);
2391
- scheduleUpdate();
2392
- return () => {
2393
- io.disconnect();
2394
- ro.disconnect();
2395
- scrollTarget.removeEventListener("scroll", scheduleUpdate);
2396
- window.removeEventListener("resize", scheduleUpdate);
2397
- if (rafId.current != null) {
2398
- cancelAnimationFrame(rafId.current);
2399
- rafId.current = null;
2400
- }
2401
- };
2402
- }, [ioRoot, resolvedEdge, offset, debug]);
2403
- return /* @__PURE__ */ jsx(
2404
- "div",
2405
- {
2406
- ref: rootRef,
2407
- className,
2408
- style: {
2409
- display: "block",
2410
- minWidth: 0,
2411
- minHeight: 0,
2412
- height: "100%",
2413
- // 부모 높이를 채우도록 설정
2414
- ...style
2415
- },
2416
- ...rest,
2417
- children: /* @__PURE__ */ jsx(
2418
- "div",
2419
- {
2420
- ref: contentRef,
2421
- style: contentDynamicStyle,
2422
- children
2423
- }
2424
- )
2425
- }
2426
- );
2427
- };
2428
- var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
2429
-
2430
- export { FlexLayoutContainer_default, FlexLayoutResizePanel_default, FlexLayoutSplitScreenDragBox, FlexLayoutSplitScreenScrollBox_default, FlexLayoutSplitScreen_default, FlexLayoutStickyBox_default, FlexLayout_default2 as FlexLayout_default };
2431
- //# sourceMappingURL=chunk-UYI4Z27V.js.map
2432
- //# sourceMappingURL=chunk-UYI4Z27V.js.map