@byeolnaerim/flex-layout 0.0.5 → 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 (59) 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 +546 -553
  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.map +1 -1
  39. package/dist/index.cjs +3454 -0
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.css +471 -0
  42. package/dist/index.css.map +1 -0
  43. package/dist/index.d.ts +1 -2
  44. package/dist/index.js +3395 -0
  45. package/dist/index.js.map +1 -1
  46. package/package.json +18 -64
  47. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.cts +0 -31
  48. package/dist/FlexLayoutSplitScreenDragBox-eCtq4kLd.d.ts +0 -31
  49. package/dist/components.d.cts +0 -122
  50. package/dist/components.d.ts +0 -122
  51. package/dist/hooks.d.cts +0 -37
  52. package/dist/index.d.cts +0 -2
  53. package/dist/providers.d.cts +0 -54
  54. package/dist/providers.d.ts +0 -54
  55. package/dist/store.d.cts +0 -67
  56. package/dist/store.d.ts +0 -67
  57. package/dist/useDrag-CYQnhUFk.d.cts +0 -108
  58. package/dist/utils.d.cts +0 -28
  59. package/dist/utils.d.ts +0 -28
package/dist/index.cjs CHANGED
@@ -1,4 +1,3458 @@
1
1
  'use strict';
2
2
 
3
+ var React2 = require('react');
4
+ var equal = require('fast-deep-equal');
5
+ var rxjs = require('rxjs');
6
+ var operators = require('rxjs/operators');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
11
+ var equal__default = /*#__PURE__*/_interopDefault(equal);
12
+
13
+ // src/flex-layout/components/FlexLayout.tsx
14
+ function updateScrollStore(subject, newValue) {
15
+ const currentValue = subject.getValue();
16
+ if (!equal__default.default(currentValue, newValue)) {
17
+ subject.next(newValue);
18
+ }
19
+ }
20
+ function updateRefStore(store, newState) {
21
+ const prevState = store.getValue();
22
+ if (!equal__default.default(prevState, newState)) {
23
+ store.next(newState);
24
+ }
25
+ }
26
+ function updateSplitScreenStore(newValue) {
27
+ const prevValue = layoutSplitScreenStore.getValue();
28
+ if (!equal__default.default(prevValue, newValue)) {
29
+ layoutSplitScreenStore.next(newValue);
30
+ }
31
+ }
32
+ var scrollPositions = {};
33
+ var scrollPositionsSubject = new rxjs.BehaviorSubject(scrollPositions);
34
+ var setScrollPosition = (layoutName, position) => {
35
+ const current = scrollPositionsSubject.getValue();
36
+ const prevPos = current[layoutName];
37
+ if (prevPos && prevPos.x === position.x && prevPos.y === position.y) {
38
+ return;
39
+ }
40
+ const newPositions = {
41
+ ...current,
42
+ [layoutName]: position
43
+ };
44
+ updateScrollStore(scrollPositionsSubject, newPositions);
45
+ };
46
+ var getScrollPosition = (layoutName) => {
47
+ return scrollPositionsSubject.pipe(
48
+ // 해당 layoutName이 정의되지 않았을 때는 제외
49
+ operators.filter((e) => e[layoutName] !== void 0),
50
+ operators.map((positions) => positions[layoutName]),
51
+ operators.distinctUntilChanged(
52
+ (prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y
53
+ )
54
+ );
55
+ };
56
+ var removeScrollPosition = (layoutName) => {
57
+ const current = scrollPositionsSubject.getValue();
58
+ delete current[layoutName];
59
+ const newPositions = { ...current };
60
+ updateScrollStore(scrollPositionsSubject, newPositions);
61
+ };
62
+ var layoutSplitScreenStore = new rxjs.BehaviorSubject({});
63
+ var setSplitScreen = (rootName, layoutName, newComponents) => {
64
+ const current = layoutSplitScreenStore.getValue();
65
+ const updatedLayout = { ...current[rootName] || {} };
66
+ updatedLayout[layoutName] = newComponents;
67
+ const newStoreValue = {
68
+ ...current,
69
+ [rootName]: updatedLayout
70
+ };
71
+ updateSplitScreenStore(newStoreValue);
72
+ };
73
+ var resetRootSplitScreen = (rootName) => {
74
+ const current = layoutSplitScreenStore.getValue();
75
+ const newStoreValue = {
76
+ ...current,
77
+ [rootName]: {}
78
+ };
79
+ updateSplitScreenStore(newStoreValue);
80
+ };
81
+ var removeSplitScreenChild = (rootName, layoutName) => {
82
+ const current = layoutSplitScreenStore.getValue();
83
+ if (!current[rootName]) return;
84
+ const updatedLayout = { ...current[rootName] };
85
+ delete updatedLayout[layoutName];
86
+ const newStoreValue = {
87
+ ...current,
88
+ [rootName]: updatedLayout
89
+ };
90
+ updateSplitScreenStore(newStoreValue);
91
+ };
92
+ var getCurrentSplitScreenComponents = (rootName, layoutName) => {
93
+ const current = layoutSplitScreenStore.getValue();
94
+ if (!current[rootName]) return;
95
+ return current[rootName][layoutName];
96
+ };
97
+ var getSplitScreen = (rootName, layoutName) => {
98
+ return layoutSplitScreenStore.pipe(
99
+ operators.map((splitScreen) => splitScreen[rootName][layoutName]),
100
+ operators.distinctUntilChanged((prev, curr) => {
101
+ const filterChildren2 = (obj) => {
102
+ const { children, component, targetComponent, x, y, ...rest } = obj || {};
103
+ return rest;
104
+ };
105
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
106
+ })
107
+ );
108
+ };
109
+ var flexContainerStore = new rxjs.BehaviorSubject({});
110
+ var flexResizePanelStore = new rxjs.BehaviorSubject({});
111
+ var setContainerRef = (layoutName, containerName, ref) => {
112
+ const currentRefs = flexContainerStore.getValue();
113
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
114
+ if (ref === null) {
115
+ delete updatedLayoutRefs[containerName];
116
+ } else {
117
+ updatedLayoutRefs[containerName] = ref;
118
+ }
119
+ const newRefs = {
120
+ ...currentRefs,
121
+ [layoutName]: updatedLayoutRefs
122
+ };
123
+ updateRefStore(flexContainerStore, newRefs);
124
+ };
125
+ var setResizePanelRef = (layoutName, containerName, ref) => {
126
+ const currentRefs = flexResizePanelStore.getValue();
127
+ const updatedLayoutRefs = { ...currentRefs[layoutName] || {} };
128
+ if (ref === null) {
129
+ delete updatedLayoutRefs[containerName];
130
+ } else {
131
+ updatedLayoutRefs[containerName] = ref;
132
+ }
133
+ const newRefs = {
134
+ ...currentRefs,
135
+ [layoutName]: updatedLayoutRefs
136
+ };
137
+ updateRefStore(flexResizePanelStore, newRefs);
138
+ };
139
+ var getLayoutInfos = (layoutName) => {
140
+ return rxjs.combineLatest([flexContainerStore, flexResizePanelStore]).pipe(
141
+ operators.map(([containerRefs, resizePanelRefs]) => {
142
+ const containerData = containerRefs[layoutName] || {};
143
+ const resizePanelData = resizePanelRefs[layoutName] || {};
144
+ return {
145
+ container: containerData,
146
+ resizePanel: resizePanelData
147
+ };
148
+ }),
149
+ operators.filter((result) => result.container !== null)
150
+ // 빈 객체 제외
151
+ );
152
+ };
153
+ var getContainerRef = ({
154
+ containerName,
155
+ layoutName
156
+ }) => {
157
+ return flexContainerStore.pipe(
158
+ operators.map((refs) => {
159
+ if (layoutName) {
160
+ return refs[layoutName]?.[containerName] || null;
161
+ } else {
162
+ return Object.entries(refs).find(
163
+ ([key, value]) => refs[key][containerName]
164
+ )?.[1][containerName];
165
+ }
166
+ }),
167
+ operators.filter((ref) => ref !== null)
168
+ );
169
+ };
170
+ var getResizePanelRef = ({
171
+ containerName,
172
+ layoutName
173
+ }) => {
174
+ return flexResizePanelStore.pipe(
175
+ operators.map((refs) => {
176
+ if (layoutName) {
177
+ return refs[layoutName]?.[containerName] || null;
178
+ } else {
179
+ return Object.entries(refs).find(
180
+ ([key, value]) => refs[key][containerName]
181
+ )?.[1][containerName];
182
+ }
183
+ }),
184
+ operators.filter((ref) => ref !== null)
185
+ );
186
+ };
187
+
188
+ // src/flex-layout/utils/FlexLayoutUtils.ts
189
+ function isDocumentOut({ x, y }) {
190
+ if (typeof window == "undefined") return;
191
+ const { innerWidth, innerHeight, scrollX, scrollY } = window;
192
+ return x < 0 || y < 0 || x > innerWidth + scrollX || y > innerHeight + scrollY;
193
+ }
194
+ var lastTouchEvent;
195
+ function getClientXy(event) {
196
+ let clientX;
197
+ let clientY;
198
+ if (window.MouseEvent && event instanceof window.MouseEvent) {
199
+ clientX = event.clientX;
200
+ clientY = event.clientY;
201
+ } else if (window.TouchEvent && event instanceof window.TouchEvent) {
202
+ const _event = event.touches.length == 0 ? lastTouchEvent : event;
203
+ clientX = _event.touches[0].clientX;
204
+ clientY = _event.touches[0].clientY;
205
+ lastTouchEvent = event;
206
+ } else {
207
+ return;
208
+ }
209
+ return { clientX, clientY };
210
+ }
211
+ function isOverMove(elementSize, elementMinSize) {
212
+ return Math.floor(elementSize) <= 0 || (isNaN(elementMinSize) ? false : elementMinSize >= Math.floor(elementSize));
213
+ }
214
+ function findNotCloseFlexContent(target, direction) {
215
+ if (!target) return target;
216
+ let _target = target;
217
+ const isCloseCheck = () => {
218
+ let grow = parseFloat(window.getComputedStyle(_target).flex.split(" ")[0]) || 0;
219
+ if (grow == 0) {
220
+ return true;
221
+ } else {
222
+ return false;
223
+ }
224
+ };
225
+ while (isCloseCheck()) {
226
+ let nextTarget = _target[direction]?.[direction];
227
+ _target = nextTarget;
228
+ if (!_target) {
229
+ break;
230
+ }
231
+ }
232
+ return _target;
233
+ }
234
+ function remain(flexContainerList) {
235
+ return new Promise((resolve) => {
236
+ let notGrowList = [];
237
+ let totalGrow = flexContainerList.reduce((t, e, i) => {
238
+ if (e.hasAttribute("data-grow") == false) {
239
+ notGrowList.push(e);
240
+ return t;
241
+ }
242
+ let grow = parseFloat(e.dataset.grow || "");
243
+ e.style.flex = `${grow} 1 0%`;
244
+ t -= grow;
245
+ return t;
246
+ }, flexContainerList.length);
247
+ if (notGrowList.length != 0) {
248
+ resize(notGrowList, totalGrow);
249
+ }
250
+ resolve(flexContainerList);
251
+ });
252
+ }
253
+ function resize(list, totalGrow) {
254
+ return new Promise((resolve) => {
255
+ let resizeWeight = totalGrow / list.length;
256
+ list.forEach((e) => {
257
+ e.dataset.grow = resizeWeight.toString();
258
+ e.style.flex = `${resizeWeight} 1 0%`;
259
+ });
260
+ resolve(resizeWeight);
261
+ });
262
+ }
263
+ function mathWeight(totalCount, totalGrow) {
264
+ return 1 + (totalGrow - totalCount) / totalCount;
265
+ }
266
+ function mathGrow(childSize, parentSize, containerCount) {
267
+ return containerCount * (childSize / parentSize);
268
+ }
269
+ function getGrow(growTarget) {
270
+ const target = growTarget instanceof Element ? growTarget : growTarget;
271
+ return parseFloat(target.style.flex.split(" ")[0]) || parseFloat(target.dataset.grow || "");
272
+ }
273
+ function closeFlex(resizeTarget, containers, {
274
+ isResize = false,
275
+ isDsiabledResizePanel = false,
276
+ sizeName
277
+ }) {
278
+ return new Promise((resolve) => {
279
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (isDsiabledResizePanel) {
280
+ resizeTarget.dataset.is_resize_panel = "false";
281
+ }
282
+ resizeTarget.dataset.prev_grow = getGrow(resizeTarget).toString();
283
+ let notCloseList = containers.filter(
284
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
285
+ );
286
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
287
+ notCloseAndOpenTargetList.forEach((e) => {
288
+ e.style.transition = "flex 0.5s";
289
+ e.ontransitionend = (event) => {
290
+ if (event.propertyName != "flex-grow") {
291
+ return;
292
+ }
293
+ notCloseAndOpenTargetList.forEach(
294
+ (e2) => e2.style.transition = ""
295
+ );
296
+ e.ontransitionend = () => {
297
+ };
298
+ };
299
+ if (e == resizeTarget) {
300
+ e.dataset.grow = "0";
301
+ e.style.flex = `0 1 0%`;
302
+ return;
303
+ }
304
+ if (isResize) {
305
+ return;
306
+ }
307
+ let percent = getGrow(e) / containers.length;
308
+ if (notCloseList.length == 1) {
309
+ e.dataset.grow = containers.length.toString();
310
+ e.style.flex = `${containers.length} 1 0%`;
311
+ return;
312
+ }
313
+ e.dataset.grow = (containers.length * percent).toString();
314
+ e.style.flex = `${containers.length * percent} 1 0%`;
315
+ });
316
+ if (isResize) {
317
+ resize(notCloseList, containers.length);
318
+ }
319
+ resolve(resizeTarget);
320
+ });
321
+ }
322
+ function openFlex(resizeTarget, containers, {
323
+ isPrevSizeOpen = false,
324
+ isResize = false,
325
+ openGrowImportant = 0,
326
+ sizeName
327
+ }) {
328
+ return new Promise((resolve) => {
329
+ if (!resizeTarget.hasAttribute("data-is_resize_panel")) ; else if (resizeTarget.hasAttribute("data-is_resize_panel") && resizeTarget.dataset.is_resize_panel == "false") {
330
+ resizeTarget.dataset.is_resize_panel = "true";
331
+ }
332
+ let notCloseList = containers.filter(
333
+ (e) => e.style.flex != "0 1 0%" && e != resizeTarget
334
+ );
335
+ let notCloseAndOpenTargetList = [...notCloseList, resizeTarget];
336
+ let openTargetGrow = 1;
337
+ const sizeStyleName = "client" + sizeName.charAt(0).toUpperCase() + sizeName.substring(1);
338
+ const parentSize = sizeName && resizeTarget.parentElement && resizeTarget.parentElement[sizeStyleName] || 0;
339
+ if (isPrevSizeOpen && resizeTarget.hasAttribute("data-prev_grow")) {
340
+ openTargetGrow = parseFloat(resizeTarget.dataset.prev_grow || "1") || 1;
341
+ } else if (parentSize && parentSize !== 0) {
342
+ openTargetGrow = parentSize / notCloseList.length / (parentSize - 1) * containers.length;
343
+ } else {
344
+ openTargetGrow = 1;
345
+ }
346
+ if (openGrowImportant) {
347
+ openTargetGrow = openGrowImportant;
348
+ }
349
+ openTargetGrow = openTargetGrow === Infinity ? 1 : openTargetGrow;
350
+ notCloseAndOpenTargetList.forEach((e) => {
351
+ e.style.transition = "flex 0.5s";
352
+ e.ontransitionend = (event) => {
353
+ if (event.propertyName != "flex-grow") {
354
+ return;
355
+ }
356
+ notCloseAndOpenTargetList.forEach(
357
+ (e2) => e2.style.transition = ""
358
+ );
359
+ e.ontransitionend = () => {
360
+ };
361
+ };
362
+ if (e == resizeTarget) {
363
+ resizeTarget.dataset.grow = openTargetGrow.toString();
364
+ resizeTarget.style.flex = `${openTargetGrow} 1 0%`;
365
+ return;
366
+ }
367
+ if (isResize) {
368
+ return;
369
+ }
370
+ let grow = parentSize / notCloseList.length / (parentSize - 1) * (containers.length - openTargetGrow);
371
+ grow = grow === Infinity ? 1 : grow;
372
+ e.dataset.grow = grow.toString();
373
+ e.style.flex = `${grow} 1 0%`;
374
+ });
375
+ if (isResize) {
376
+ resize(notCloseAndOpenTargetList, containers.length);
377
+ }
378
+ resolve(openTargetGrow);
379
+ });
380
+ }
381
+ var g = globalThis;
382
+ g.__FLEX_SUBJECTS__ ?? (g.__FLEX_SUBJECTS__ = { openClose: {}, spread: {} });
383
+ var containerOpenCloseSubjectMap = g.__FLEX_SUBJECTS__.openClose;
384
+ var containerSpreadSubjectMap = g.__FLEX_SUBJECTS__.spread;
385
+ var ContainerOpenCloseProvider = ({
386
+ layoutName,
387
+ containerName,
388
+ sizeName
389
+ }) => {
390
+ if (!containerOpenCloseSubjectMap[containerName]) {
391
+ containerOpenCloseSubjectMap[containerName] = new rxjs.Subject();
392
+ }
393
+ if (!containerSpreadSubjectMap[containerName]) {
394
+ containerSpreadSubjectMap[containerName] = new rxjs.Subject();
395
+ }
396
+ const [containers, setContainers] = React2.useState([]);
397
+ const [container, setContainer] = React2.useState();
398
+ React2.useEffect(() => {
399
+ const subscription = getLayoutInfos(layoutName).subscribe(
400
+ (layout) => {
401
+ if (!layout || !layout.container[containerName] || !layout.container[containerName].current)
402
+ return;
403
+ setContainers(
404
+ Object.values(layout.container).filter(
405
+ (e) => e.current !== null
406
+ ).map((e) => e.current)
407
+ );
408
+ setContainer(layout.container[containerName].current);
409
+ }
410
+ );
411
+ return () => subscription.unsubscribe();
412
+ }, [containerName, layoutName]);
413
+ React2.useEffect(() => {
414
+ const styleName = `${sizeName.charAt(0).toUpperCase() + sizeName.substring(1)}`;
415
+ const clientSize = "client" + styleName;
416
+ const outerSize = "outer" + styleName;
417
+ const maxSize = "max" + styleName;
418
+ const subscribe = containerOpenCloseSubjectMap[containerName].subscribe(
419
+ ({
420
+ mode,
421
+ initOpenState: isOpenState,
422
+ onClose,
423
+ onOpen,
424
+ openOption = {},
425
+ closeOption = {}
426
+ }) => {
427
+ if (!container || containers.length === 0) return;
428
+ const currentGrow = getGrow(container);
429
+ const styleMap = window.getComputedStyle(container);
430
+ const maxSizeGrow = mathGrow(
431
+ parseInt(styleMap[maxSize]),
432
+ container.parentElement && container.parentElement[clientSize] || window[outerSize],
433
+ containers.length
434
+ );
435
+ const open = () => openFlex(container, containers, {
436
+ sizeName,
437
+ ...isNaN(maxSizeGrow) ? {} : {
438
+ openGrowImportant: maxSizeGrow
439
+ },
440
+ ...openOption
441
+ }).then((openTargetGrow) => {
442
+ if (onOpen) onOpen();
443
+ containerSpreadSubjectMap[containerName].next({
444
+ isOpen: true,
445
+ grow: openTargetGrow,
446
+ targetContainer: container
447
+ });
448
+ });
449
+ const close = () => closeFlex(container, containers, {
450
+ sizeName,
451
+ ...closeOption
452
+ }).then(() => {
453
+ if (onClose) onClose();
454
+ containerSpreadSubjectMap[containerName].next({
455
+ isOpen: false,
456
+ grow: 0,
457
+ targetContainer: container
458
+ });
459
+ });
460
+ if (mode === "toggle") {
461
+ if (currentGrow === 0) {
462
+ open();
463
+ } else {
464
+ close();
465
+ }
466
+ } else if (mode === "open") {
467
+ if (currentGrow === 0) {
468
+ open();
469
+ }
470
+ } else if (mode === "close") {
471
+ if (currentGrow !== 0) {
472
+ close();
473
+ }
474
+ }
475
+ }
476
+ );
477
+ return () => {
478
+ subscribe.unsubscribe();
479
+ };
480
+ }, [containerName, container, containers, sizeName]);
481
+ return null;
482
+ };
483
+ var useContainers = (layoutName) => {
484
+ const [containers, setContainers] = React2.useState([]);
485
+ React2.useEffect(() => {
486
+ const subscription = getLayoutInfos(layoutName).subscribe(
487
+ (layout) => {
488
+ setContainers(
489
+ Object.values(layout.container).filter(
490
+ (e) => e.current !== null
491
+ ).map((e) => e.current)
492
+ );
493
+ }
494
+ );
495
+ return () => subscription.unsubscribe();
496
+ }, [layoutName]);
497
+ return containers;
498
+ };
499
+ var useLayoutName = (containerName) => {
500
+ const [layoutName, setLayoutName] = React2.useState();
501
+ React2.useEffect(() => {
502
+ const subscribe = flexContainerStore.pipe(
503
+ rxjs.map(
504
+ (layouts) => Object.entries(layouts).filter(([_, v]) => v[containerName]).map(([k]) => k)[0]
505
+ // 첫 번째 결과 가져오기
506
+ )
507
+ ).subscribe(setLayoutName);
508
+ return () => subscribe.unsubscribe();
509
+ }, [containerName]);
510
+ return layoutName;
511
+ };
512
+ var useDecompositionLayout = ({
513
+ layoutName: initialLayoutName,
514
+ containerName
515
+ }) => {
516
+ const derivedLayoutName = useLayoutName(containerName);
517
+ const finalLayoutName = initialLayoutName || derivedLayoutName;
518
+ const [containers, setContainers] = React2.useState([]);
519
+ const [container, setContainer] = React2.useState();
520
+ const [resizePanel, setResizePanel] = React2.useState();
521
+ React2.useEffect(() => {
522
+ if (!finalLayoutName) return;
523
+ const subscription = getLayoutInfos(finalLayoutName).subscribe(
524
+ (layout) => {
525
+ if (!layout) return;
526
+ setContainers(
527
+ Object.values(layout.container).filter(
528
+ (e) => e.current !== null
529
+ ).map((e) => e.current)
530
+ );
531
+ if (containerName && layout.container[containerName] && layout.container[containerName].current) {
532
+ setContainer(layout.container[containerName].current);
533
+ if (layout.resizePanel[containerName] && layout.resizePanel[containerName].current) {
534
+ setResizePanel(
535
+ layout.resizePanel[containerName].current
536
+ );
537
+ }
538
+ }
539
+ }
540
+ );
541
+ return () => subscription.unsubscribe();
542
+ }, [containerName, finalLayoutName]);
543
+ return { layout: containers, container, resizePanel };
544
+ };
545
+ var useContainerSize = (containerName) => {
546
+ const { layout, container, resizePanel } = useDecompositionLayout({
547
+ containerName
548
+ });
549
+ const [size, setSize] = React2.useState();
550
+ React2.useEffect(() => {
551
+ if (!container) return;
552
+ const observer = new ResizeObserver((entries) => {
553
+ for (const entry of entries) {
554
+ setSize({
555
+ width: entry.contentRect.width,
556
+ height: entry.contentRect.height
557
+ });
558
+ }
559
+ });
560
+ observer.observe(container);
561
+ return () => observer.disconnect();
562
+ }, [container]);
563
+ return { size };
564
+ };
565
+ var useDoubleClick = (containerName, opt) => {
566
+ const [isOpen, setIsOpen] = React2.useState();
567
+ const [isDoubleClick, setIsDoubleClick] = React2.useState();
568
+ React2.useEffect(() => {
569
+ const resizePanelClickEvent = getResizePanelRef({
570
+ containerName
571
+ }).pipe(
572
+ rxjs.filter(
573
+ (resizePanelref) => resizePanelref != void 0 && resizePanelref.current != void 0
574
+ ),
575
+ //take(1),
576
+ rxjs.switchMap((resizePanelref) => {
577
+ if (!resizePanelref || !resizePanelref.current) return rxjs.EMPTY;
578
+ return rxjs.fromEvent(resizePanelref.current, "click");
579
+ })
580
+ );
581
+ const subscribe = resizePanelClickEvent.pipe(
582
+ rxjs.buffer(resizePanelClickEvent.pipe(rxjs.debounceTime(500))),
583
+ rxjs.filter((clickEventArray) => clickEventArray.length >= 2),
584
+ rxjs.map((events) => {
585
+ containerOpenCloseSubjectMap[containerName].next({
586
+ ...opt,
587
+ openOption: {
588
+ ...opt.openOption,
589
+ isPrevSizeOpen: false
590
+ },
591
+ onClose: () => {
592
+ if (opt.onClose) opt.onClose();
593
+ setIsOpen(false);
594
+ setIsDoubleClick(true);
595
+ },
596
+ onOpen: () => {
597
+ if (opt.onOpen) opt.onOpen();
598
+ setIsOpen(true);
599
+ setIsDoubleClick(true);
600
+ }
601
+ });
602
+ })
603
+ ).subscribe();
604
+ return () => {
605
+ subscribe.unsubscribe();
606
+ };
607
+ }, [containerName]);
608
+ return { isOpen, isDoubleClick, setIsDoubleClick };
609
+ };
610
+
611
+ // src/flex-layout/styles/FlexLayout.module.css
612
+ var FlexLayout_default = {};
613
+ var FlexLayoutContext = React2.createContext(null);
614
+ function useFlexLayoutContext() {
615
+ const context = React2.useContext(FlexLayoutContext);
616
+ if (!context) {
617
+ throw new Error(
618
+ "useFlexLayoutContext must be used within FlexLayoutContext.Provider"
619
+ );
620
+ }
621
+ return context;
622
+ }
623
+ function FlexLayoutProvider({
624
+ value,
625
+ children
626
+ }) {
627
+ return /* @__PURE__ */ React.createElement(FlexLayoutContext.Provider, { value }, children);
628
+ }
629
+
630
+ // src/flex-layout/components/FlexLayout.tsx
631
+ function FlexLayout({
632
+ layoutName,
633
+ direction,
634
+ children,
635
+ ref,
636
+ className,
637
+ panelClassName,
638
+ panelMovementMode = "divorce",
639
+ ...props
640
+ }) {
641
+ const containerCount = React2.Children.count(children);
642
+ const fitContent = direction === "row" ? "width" : "height";
643
+ const isFragmentElement = (node) => React2.isValidElement(node) && node.type === React2.Fragment;
644
+ const nodes = React2.Children.toArray(children).flatMap(
645
+ (node) => isFragmentElement(node) ? React2.Children.toArray(node.props.children) : [node]
646
+ );
647
+ const flattenedChildren = nodes.filter(
648
+ React2.isValidElement
649
+ );
650
+ if (flattenedChildren.length === 0) {
651
+ return null;
652
+ }
653
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
654
+ FlexLayoutProvider,
655
+ {
656
+ value: {
657
+ layoutName,
658
+ direction,
659
+ panelMovementMode,
660
+ panelClassName,
661
+ containerCount,
662
+ fitContent
663
+ }
664
+ },
665
+ /* @__PURE__ */ React.createElement(
666
+ "div",
667
+ {
668
+ className: `${FlexLayout_default["flex-layout"]} ${className && className !== "" ? className : ""}`,
669
+ ...ref ? { ref } : {},
670
+ ...props,
671
+ "data-layout_name": layoutName,
672
+ "data-direction": direction
673
+ },
674
+ flattenedChildren.map((child, index) => {
675
+ if (!child || !React2.isValidElement(child)) return null;
676
+ return /* @__PURE__ */ React.createElement(React2.Fragment, { key: index }, child, /* @__PURE__ */ React.createElement(
677
+ ContainerOpenCloseProvider,
678
+ {
679
+ layoutName,
680
+ containerName: child.props.containerName,
681
+ sizeName: fitContent
682
+ }
683
+ ));
684
+ })
685
+ )
686
+ ));
687
+ }
688
+ var useSize = (sizeName) => {
689
+ const ref = React2.useRef(null);
690
+ const [size, setSize] = React2.useState(void 0);
691
+ React2.useLayoutEffect(() => {
692
+ if (!ref.current) return;
693
+ const handleResize = () => {
694
+ if (ref.current) {
695
+ const newSize = ref.current.getBoundingClientRect()[sizeName];
696
+ setSize(newSize);
697
+ }
698
+ };
699
+ handleResize();
700
+ const resizeObserver = new ResizeObserver(() => {
701
+ handleResize();
702
+ });
703
+ resizeObserver.observe(ref.current);
704
+ window.addEventListener("resize", handleResize);
705
+ return () => {
706
+ resizeObserver.disconnect();
707
+ window.removeEventListener("resize", handleResize);
708
+ };
709
+ }, [sizeName]);
710
+ return { ref, size };
711
+ };
712
+ var flexDirectionModel = {
713
+ row: {
714
+ xy: "x",
715
+ targetDirection: "left",
716
+ nextDirection: "right",
717
+ sizeName: "width",
718
+ resizeCursor: "ew-resize"
719
+ },
720
+ column: {
721
+ xy: "y",
722
+ targetDirection: "top",
723
+ nextDirection: "bottom",
724
+ sizeName: "height",
725
+ resizeCursor: "ns-resize"
726
+ }
727
+ };
728
+ function FlexLayoutResizePanel({
729
+ direction,
730
+ containerCount,
731
+ panelMode = "default",
732
+ containerName,
733
+ layoutName,
734
+ panelClassName,
735
+ panelMovementMode
736
+ }) {
737
+ let isResizePanelClickRef = React2.useRef(false);
738
+ let prevTouchEvent = null;
739
+ let parentSizeRef = React2.useRef(0);
740
+ let totalMovementRef = React2.useRef(0);
741
+ const containerCountRef = React2.useRef(containerCount);
742
+ React2.useEffect(() => {
743
+ return () => {
744
+ document.body.style.cursor = "";
745
+ };
746
+ }, []);
747
+ React2.useEffect(() => {
748
+ containerCountRef.current = containerCount;
749
+ }, [containerCount]);
750
+ const panelRef = React2.useRef(null);
751
+ const panelMouseDownEvent = (event) => {
752
+ if (!panelRef.current || !panelRef.current.parentElement) return;
753
+ isResizePanelClickRef.current = true;
754
+ containerCountRef.current = [
755
+ ...panelRef.current.parentElement.children
756
+ ].filter((e) => e.hasAttribute("data-container_name")).length;
757
+ const sizeName = flexDirectionModel[direction].sizeName;
758
+ parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
759
+ prevTouchEvent = null;
760
+ totalMovementRef.current = 0;
761
+ if (!parentSizeRef.current) return;
762
+ document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
763
+ };
764
+ const panelMouseUpEvent = () => {
765
+ isResizePanelClickRef.current = false;
766
+ parentSizeRef.current = 0;
767
+ prevTouchEvent = null;
768
+ totalMovementRef.current = 0;
769
+ document.body.style.cursor = "";
770
+ };
771
+ function moveMouseFlex(originTarget, resizePanel, moveEvent) {
772
+ const model = flexDirectionModel[direction];
773
+ const movement = moveEvent["movement" + model.xy.toUpperCase()];
774
+ totalMovementRef.current += movement;
775
+ const minSizeName = "min-" + model.sizeName;
776
+ const maxSizeName = "max-" + model.sizeName;
777
+ let targetElement = findNotCloseFlexContent(
778
+ originTarget,
779
+ "previousElementSibling"
780
+ );
781
+ if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
782
+ targetElement = originTarget;
783
+ let nextElement = findNotCloseFlexContent(
784
+ resizePanel.nextElementSibling,
785
+ "nextElementSibling"
786
+ );
787
+ if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
788
+ nextElement = resizePanel.nextElementSibling;
789
+ if (!targetElement || !nextElement) return;
790
+ const targetRect = targetElement.getBoundingClientRect();
791
+ const targetStyle = window.getComputedStyle(targetElement);
792
+ const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
793
+ const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
794
+ const nextRect = nextElement.getBoundingClientRect();
795
+ const nextStyle = window.getComputedStyle(nextElement);
796
+ const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
797
+ const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
798
+ let targetSize = targetRect[model.sizeName] + movement;
799
+ let nextElementSize = nextRect[model.sizeName] - movement;
800
+ if (targetMaxSize > 0 && targetSize > targetMaxSize) {
801
+ return;
802
+ }
803
+ if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
804
+ return;
805
+ }
806
+ if (isOverMove(targetSize, targetMinSize)) {
807
+ targetSize = 0;
808
+ nextElementSize = nextRect[model.sizeName];
809
+ } else if (isOverMove(nextElementSize, nextMinSize)) {
810
+ nextElementSize = 0;
811
+ targetSize = targetRect[model.sizeName];
812
+ }
813
+ const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
814
+ const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
815
+ if (!(targetElement instanceof HTMLElement)) return;
816
+ if (!(nextElement instanceof HTMLElement)) return;
817
+ targetElement.style.flex = `${targetFlexGrow} 1 0%`;
818
+ nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
819
+ }
820
+ React2.useEffect(() => {
821
+ const addGlobalMoveEvent = (event) => {
822
+ if (!isResizePanelClickRef.current || !panelRef.current) {
823
+ return;
824
+ }
825
+ event.preventDefault();
826
+ const targetElement = panelRef.current.previousElementSibling;
827
+ const targetPanel = panelRef.current;
828
+ if (!targetElement || !targetPanel) return;
829
+ let move = { movementX: 0, movementY: 0 };
830
+ if (window.TouchEvent && event instanceof window.TouchEvent) {
831
+ if (!prevTouchEvent) {
832
+ prevTouchEvent = event;
833
+ return;
834
+ }
835
+ move.movementX = (prevTouchEvent.touches[0].pageX - event.touches[0].pageX) * -2;
836
+ move.movementY = (prevTouchEvent.touches[0].pageY - event.touches[0].pageY) * -2;
837
+ prevTouchEvent = event;
838
+ } else {
839
+ move.movementX = event.movementX;
840
+ move.movementY = event.movementY;
841
+ }
842
+ moveMouseFlex(targetElement, targetPanel, move);
843
+ };
844
+ ["mousemove", "touchmove"].forEach((eventName) => {
845
+ window.addEventListener(eventName, addGlobalMoveEvent, {
846
+ passive: false
847
+ });
848
+ });
849
+ ["mouseup", "touchend"].forEach((eventName) => {
850
+ window.addEventListener(eventName, panelMouseUpEvent);
851
+ });
852
+ return () => {
853
+ ["mousemove", "touchmove"].forEach((eventName) => {
854
+ window.removeEventListener(eventName, addGlobalMoveEvent);
855
+ });
856
+ ["mouseup", "touchend"].forEach((eventName) => {
857
+ window.removeEventListener(eventName, panelMouseUpEvent);
858
+ });
859
+ };
860
+ }, []);
861
+ React2.useEffect(() => {
862
+ if (!panelRef.current) return;
863
+ setResizePanelRef(layoutName, containerName, panelRef);
864
+ }, [containerName, layoutName]);
865
+ return /* @__PURE__ */ React.createElement(
866
+ "div",
867
+ {
868
+ id: containerName + "_resize_panel",
869
+ className: `${FlexLayout_default["flex-resize-panel"]} ${FlexLayout_default[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
870
+ ref: panelRef,
871
+ onMouseDown: panelMouseDownEvent,
872
+ onTouchStart: panelMouseDownEvent
873
+ },
874
+ /* @__PURE__ */ React.createElement("div", { className: FlexLayout_default.hover })
875
+ );
876
+ }
877
+
878
+ // src/flex-layout/components/FlexLayoutContainer.tsx
879
+ function FlexLayoutContainer({
880
+ isFitContent,
881
+ isFitResize,
882
+ // fitContent,
883
+ // containerCount,
884
+ // layoutName,
885
+ containerName,
886
+ grow: initialGrow,
887
+ prevGrow: initialPrevGrow,
888
+ isInitialResizable,
889
+ isResizePanel,
890
+ children,
891
+ className,
892
+ panelMode
893
+ }) {
894
+ const {
895
+ direction,
896
+ panelMovementMode,
897
+ panelClassName,
898
+ layoutName,
899
+ fitContent,
900
+ containerCount
901
+ } = useFlexLayoutContext();
902
+ const { ref, size } = (
903
+ // isFitContent && fitContent
904
+ //?
905
+ useSize(fitContent)
906
+ );
907
+ const flexContainerNodeRef = React2.useRef(null);
908
+ const flexContainerRef = React2.useCallback(
909
+ (node) => {
910
+ flexContainerNodeRef.current = node;
911
+ if (node !== null) {
912
+ setContainerRef(layoutName, containerName, { current: node });
913
+ }
914
+ },
915
+ [layoutName, containerName]
916
+ );
917
+ const [growState, setGrowState] = React2.useState(initialGrow);
918
+ React2.useEffect(() => {
919
+ setGrowState(initialGrow);
920
+ }, [initialGrow]);
921
+ const [prevGrowState, setPrevGrowState] = React2.useState(
922
+ initialPrevGrow
923
+ );
924
+ const [isFirstLoad, setIsFirstLoad] = React2.useState(true);
925
+ React2.useEffect(() => {
926
+ if (!flexContainerNodeRef.current) return;
927
+ setContainerRef(layoutName, containerName, flexContainerNodeRef);
928
+ return () => {
929
+ setContainerRef(layoutName, containerName, {
930
+ current: null
931
+ });
932
+ };
933
+ }, [containerName, layoutName]);
934
+ React2.useEffect(() => {
935
+ if (typeof window == "undefined" || flexContainerNodeRef.current === null)
936
+ return;
937
+ const storedGrow = sessionStorage.getItem(containerName);
938
+ if (storedGrow !== null) {
939
+ const parsed = parseFloat(storedGrow);
940
+ if (!isNaN(parsed)) {
941
+ flexContainerNodeRef.current.style.flex = `${parsed} 1 0%`;
942
+ setGrowState(parsed);
943
+ }
944
+ }
945
+ }, [containerName]);
946
+ React2.useEffect(() => {
947
+ if (!flexContainerNodeRef.current) return;
948
+ const targetNode = flexContainerNodeRef.current;
949
+ const observer = new MutationObserver((mutations) => {
950
+ for (const mutation of mutations) {
951
+ if (mutation.type === "attributes" && mutation.attributeName === "style" && targetNode.style.flex) {
952
+ const flexValue = targetNode.style.flex;
953
+ const parsedGrow = parseFloat(flexValue.split(" ")[0]);
954
+ if (!isNaN(parsedGrow)) {
955
+ setGrowState(parsedGrow);
956
+ }
957
+ }
958
+ }
959
+ });
960
+ observer.observe(targetNode, {
961
+ attributes: true,
962
+ attributeFilter: ["style"],
963
+ attributeOldValue: true
964
+ });
965
+ return () => {
966
+ observer.disconnect();
967
+ };
968
+ }, [containerName]);
969
+ React2.useEffect(() => {
970
+ if (!flexContainerNodeRef.current || !ref || !ref.current || !size || !fitContent)
971
+ return;
972
+ requestAnimationFrame(() => {
973
+ if (!flexContainerNodeRef.current) return;
974
+ const sizeName = `${fitContent.charAt(0).toUpperCase() + fitContent.substring(1)}`;
975
+ const parentSize = flexContainerNodeRef.current.parentElement && flexContainerNodeRef.current.parentElement["client" + sizeName] || 0;
976
+ if (isFitContent) {
977
+ flexContainerNodeRef.current.style["max" + sizeName] = size + "px";
978
+ }
979
+ if (!isFitResize && isFirstLoad) {
980
+ setIsFirstLoad(false);
981
+ return;
982
+ }
983
+ if (getGrow(flexContainerNodeRef.current) != 0 && isFitResize) {
984
+ const newGrow = mathGrow(size, parentSize, containerCount);
985
+ setPrevGrowState(growState);
986
+ setGrowState(newGrow);
987
+ }
988
+ });
989
+ }, [size, containerCount, isFitResize, children]);
990
+ React2.useEffect(() => {
991
+ if (!flexContainerNodeRef.current) return;
992
+ let notGrowList = [];
993
+ let containerList = [
994
+ ...flexContainerNodeRef.current.parentElement?.children || []
995
+ ].filter((e) => e.hasAttribute("data-container_name"));
996
+ let remainingGrow = containerList.reduce((t, e, i) => {
997
+ let item = e;
998
+ if (item.classList.contains(FlexLayout_default["flex-resize-panel"])) return t;
999
+ if (e.hasAttribute("data-grow") == false || e.getAttribute("data-is_resize") === "true") {
1000
+ notGrowList.push(item);
1001
+ return t;
1002
+ }
1003
+ let grow = parseFloat(item.dataset.grow || "");
1004
+ item.style.flex = `${grow} 1 0%`;
1005
+ t -= grow;
1006
+ return t;
1007
+ }, containerList.length);
1008
+ if (notGrowList.length != 0) {
1009
+ let resizeWeight = mathWeight(notGrowList.length, remainingGrow);
1010
+ notGrowList.forEach((e) => {
1011
+ e.dataset.grow = resizeWeight.toString();
1012
+ e.style.flex = `${resizeWeight} 1 0%`;
1013
+ });
1014
+ }
1015
+ }, []);
1016
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1017
+ "div",
1018
+ {
1019
+ id: containerName,
1020
+ "data-container_name": containerName,
1021
+ ref: flexContainerRef,
1022
+ className: `${FlexLayout_default["flex-container"]} ${className && className !== "" ? className : ""}`,
1023
+ ...growState !== void 0 ? { ["data-grow"]: growState } : {},
1024
+ ...prevGrowState != void 0 ? { ["data-prev_grow"]: prevGrowState } : {},
1025
+ "data-is_resize": isInitialResizable,
1026
+ "data-is_resize_panel": isResizePanel,
1027
+ style: growState !== void 0 && {
1028
+ flex: `${growState} 1 0%`
1029
+ } || {}
1030
+ },
1031
+ isFitContent && /* @__PURE__ */ React.createElement(
1032
+ "div",
1033
+ {
1034
+ className: `${FlexLayout_default["flex-content-fit-wrapper"]}`,
1035
+ ref
1036
+ },
1037
+ children
1038
+ ) || children
1039
+ ), isResizePanel && /* @__PURE__ */ React.createElement(
1040
+ FlexLayoutResizePanel,
1041
+ {
1042
+ containerName,
1043
+ layoutName,
1044
+ direction,
1045
+ containerCount,
1046
+ panelMode,
1047
+ panelClassName,
1048
+ panelMovementMode
1049
+ }
1050
+ ));
1051
+ }
1052
+ var dragState = new rxjs.Subject();
1053
+ var filterChildren = (obj) => {
1054
+ const { children, ...rest } = obj || {};
1055
+ return rest;
1056
+ };
1057
+ var useDragCapture = (targetRef) => {
1058
+ const stateRef = React2.useRef(null);
1059
+ const forceUpdate = React2.useRef(0);
1060
+ React2.useEffect(() => {
1061
+ const subscription = dragState.pipe(
1062
+ rxjs.map((value) => {
1063
+ if (!targetRef || !targetRef.current) return null;
1064
+ const { x, y } = value;
1065
+ const rect = targetRef.current.getBoundingClientRect();
1066
+ const {
1067
+ width,
1068
+ height,
1069
+ x: rectX,
1070
+ y: rectY,
1071
+ right,
1072
+ bottom
1073
+ } = rect;
1074
+ let isOver = false;
1075
+ if (x < rectX || x > right || y < rectY || y > bottom) {
1076
+ isOver = true;
1077
+ }
1078
+ const leftBoundary = rectX + width * 0.2;
1079
+ const rightBoundary = right - width * 0.2;
1080
+ const topBoundary = rectY + height * 0.2;
1081
+ const bottomBoundary = bottom - height * 0.2;
1082
+ let position = "centerBoundary";
1083
+ if (x < leftBoundary) {
1084
+ position = "leftBoundary";
1085
+ } else if (x > rightBoundary) {
1086
+ position = "rightBoundary";
1087
+ } else if (y < topBoundary) {
1088
+ position = "topBoundary";
1089
+ } else if (y > bottomBoundary) {
1090
+ position = "bottomBoundary";
1091
+ }
1092
+ return {
1093
+ positionName: position,
1094
+ isOver,
1095
+ ...value
1096
+ };
1097
+ }),
1098
+ rxjs.distinctUntilChanged(
1099
+ (prev, curr) => equal__default.default(filterChildren(prev), filterChildren(curr))
1100
+ )
1101
+ ).subscribe({
1102
+ next: (value) => {
1103
+ if (value && !equal__default.default(
1104
+ filterChildren(stateRef.current),
1105
+ filterChildren(value)
1106
+ )) {
1107
+ stateRef.current = value;
1108
+ forceUpdate.current++;
1109
+ }
1110
+ },
1111
+ error: (err) => console.error(err)
1112
+ });
1113
+ return () => subscription.unsubscribe();
1114
+ }, [targetRef]);
1115
+ const [, rerender] = React2.useState({});
1116
+ React2.useEffect(() => {
1117
+ const interval = setInterval(() => {
1118
+ rerender({});
1119
+ }, 50);
1120
+ return () => clearInterval(interval);
1121
+ }, []);
1122
+ return stateRef.current;
1123
+ };
1124
+ var dropMovementEventSubject = new rxjs.Subject();
1125
+ var allSplitScreenCount = new rxjs.BehaviorSubject(0);
1126
+ var useDragEvents = ({
1127
+ isBlockingActiveInput = false
1128
+ }) => {
1129
+ const dragResumeTimer = React2.useRef(null);
1130
+ const scrollThreshold = 10;
1131
+ const isScrolling = React2.useRef(false);
1132
+ const isPending = React2.useRef(false);
1133
+ const isMouseDown = React2.useRef(false);
1134
+ const isDragging = React2.useRef(false);
1135
+ const touchStartX = React2.useRef(0);
1136
+ const touchStartY = React2.useRef(0);
1137
+ const handleStart = React2.useCallback(
1138
+ ({
1139
+ event: _event,
1140
+ dragStartCallback
1141
+ }) => {
1142
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
1143
+ if (dragResumeTimer.current) {
1144
+ clearTimeout(dragResumeTimer.current);
1145
+ dragResumeTimer.current = null;
1146
+ }
1147
+ if (event.target.contentEditable === "true" || isBlockingActiveInput && document.activeElement === event.target) {
1148
+ return;
1149
+ }
1150
+ if (event.cancelable) {
1151
+ event.preventDefault();
1152
+ }
1153
+ isPending.current = true;
1154
+ isMouseDown.current = true;
1155
+ if (event instanceof globalThis.TouchEvent) {
1156
+ const touch = event.touches[0];
1157
+ touchStartX.current = touch.clientX;
1158
+ touchStartY.current = touch.clientY;
1159
+ } else if (event instanceof globalThis.MouseEvent) {
1160
+ touchStartX.current = event.clientX;
1161
+ touchStartY.current = event.clientY;
1162
+ }
1163
+ setTimeout(() => {
1164
+ if (!isPending.current || isScrolling.current) return;
1165
+ isPending.current = false;
1166
+ isDragging.current = true;
1167
+ const xy = getClientXy(event);
1168
+ if (!xy) return;
1169
+ const { clientX, clientY } = xy;
1170
+ dragStartCallback({ x: clientX, y: clientY });
1171
+ }, 300);
1172
+ },
1173
+ [isBlockingActiveInput]
1174
+ );
1175
+ const handleMove = React2.useCallback(
1176
+ ({
1177
+ event: _event,
1178
+ notDragCallback,
1179
+ dragStartCallback,
1180
+ moveingCallback
1181
+ }) => {
1182
+ if (!isMouseDown.current) return;
1183
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
1184
+ const xy = getClientXy(event);
1185
+ if (!xy) return;
1186
+ const { clientX, clientY } = xy;
1187
+ const deltaX = Math.abs(clientX - touchStartX.current);
1188
+ const deltaY = Math.abs(clientY - touchStartY.current);
1189
+ if (isPending.current && (deltaX > scrollThreshold || deltaY > scrollThreshold)) {
1190
+ isScrolling.current = true;
1191
+ isPending.current = false;
1192
+ isDragging.current = false;
1193
+ if (notDragCallback)
1194
+ notDragCallback({ x: clientX, y: clientY });
1195
+ if (dragResumeTimer.current) {
1196
+ clearTimeout(dragResumeTimer.current);
1197
+ dragResumeTimer.current = null;
1198
+ }
1199
+ dragResumeTimer.current = setTimeout(() => {
1200
+ if (!isMouseDown.current) return;
1201
+ if (dragStartCallback)
1202
+ dragStartCallback({ x: clientX, y: clientY });
1203
+ isPending.current = true;
1204
+ isScrolling.current = false;
1205
+ handleStart({ event: _event, dragStartCallback });
1206
+ }, 400);
1207
+ return;
1208
+ }
1209
+ if (!isDragging.current || isPending.current) return;
1210
+ moveingCallback({ x: clientX, y: clientY });
1211
+ },
1212
+ [isBlockingActiveInput]
1213
+ );
1214
+ const handleEnd = React2.useCallback(
1215
+ ({
1216
+ event: _event,
1217
+ dragEndCallback
1218
+ }) => {
1219
+ isScrolling.current = false;
1220
+ isMouseDown.current = false;
1221
+ if (isPending.current) {
1222
+ isPending.current = false;
1223
+ return;
1224
+ }
1225
+ const event = _event instanceof Event ? _event : _event.nativeEvent;
1226
+ if (!isDragging.current) return;
1227
+ isDragging.current = false;
1228
+ const xy = getClientXy(event);
1229
+ if (!xy) return;
1230
+ const { clientX, clientY } = xy;
1231
+ dragEndCallback({ x: clientX, y: clientY });
1232
+ },
1233
+ [isBlockingActiveInput]
1234
+ );
1235
+ return {
1236
+ handleStart,
1237
+ handleMove,
1238
+ handleEnd
1239
+ };
1240
+ };
1241
+ var folderEventSubject = new rxjs.Subject();
1242
+ var setFolderEvent = (newValue) => {
1243
+ folderEventSubject.next(newValue);
1244
+ };
1245
+ var useFolderEvent = () => {
1246
+ const [folderEvent, setFolderEvent2] = React2.useState(
1247
+ null
1248
+ );
1249
+ React2.useEffect(() => {
1250
+ const subscription = folderEventSubject.subscribe((e) => {
1251
+ if (!e) return;
1252
+ setFolderEvent2(e);
1253
+ });
1254
+ return () => {
1255
+ if (subscription) {
1256
+ subscription.unsubscribe();
1257
+ }
1258
+ };
1259
+ }, []);
1260
+ return { folderEvent };
1261
+ };
1262
+ function useFlexLayoutSplitScreen({
1263
+ isSplitInitial = false,
1264
+ parentDirection,
1265
+ directionInitial = "row",
1266
+ selfContainerName,
1267
+ parentLayoutName,
1268
+ layoutName
1269
+ }) {
1270
+ const [direction, setDirection] = React2.useState(
1271
+ directionInitial
1272
+ );
1273
+ const [isSplit, setIsSplit] = React2.useState(isSplitInitial);
1274
+ const [boundaryContainerSize, setBoundaryContainerSize] = React2.useState(null);
1275
+ const [centerDropTargetComponent, setCenterDropTargetComponent] = React2.useState([]);
1276
+ const [afterDropTargetComponent, setAfterDropTargetComponent] = React2.useState([]);
1277
+ const [beforeDropTargetComponent, setBeforeDropTargetComponent] = React2.useState([]);
1278
+ const layoutRef = React2.useRef(null);
1279
+ const dragState2 = useDragCapture(layoutRef);
1280
+ React2.useEffect(() => {
1281
+ if (!dragState2) {
1282
+ setBoundaryContainerSize(null);
1283
+ return;
1284
+ }
1285
+ const {
1286
+ isDrop,
1287
+ isDragging,
1288
+ positionName,
1289
+ containerName,
1290
+ children: dropComponent,
1291
+ isOver,
1292
+ navigationTitle,
1293
+ dropEndCallback,
1294
+ x,
1295
+ y,
1296
+ screenKey
1297
+ } = dragState2;
1298
+ const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
1299
+ if ((isOver || isDrop) && boundaryContainerSize) {
1300
+ setBoundaryContainerSize(null);
1301
+ }
1302
+ if (selfContainerName.startsWith(containerName)) {
1303
+ return;
1304
+ }
1305
+ if (isDrop && screenKey) {
1306
+ const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
1307
+ if (!isSplit && !isOver) {
1308
+ if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
1309
+ setIsSplit(true);
1310
+ setDirection(dropDirection);
1311
+ }
1312
+ dropMovementEventSubject.next({
1313
+ state: "append",
1314
+ targetContainerName: containerName,
1315
+ targetParentLayoutName: parentLayoutName,
1316
+ targetLayoutName: layoutName,
1317
+ targetComponent: dropComponent,
1318
+ orderName,
1319
+ x,
1320
+ y,
1321
+ dropEndCallback,
1322
+ dropTargetComponentEvent: {
1323
+ navigationTitle,
1324
+ dropDocumentOutsideOption: dragState2?.dropDocumentOutsideOption,
1325
+ direction: dropDirection,
1326
+ screenKey
1327
+ }
1328
+ });
1329
+ }
1330
+ }
1331
+ if (isDragging && !isSplit && !isOver) {
1332
+ const newSize = {
1333
+ left: positionName === "rightBoundary" ? "50%" : "0",
1334
+ top: positionName === "bottomBoundary" ? "50%" : "0",
1335
+ width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
1336
+ height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
1337
+ };
1338
+ if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
1339
+ setBoundaryContainerSize(newSize);
1340
+ }
1341
+ }
1342
+ }, [
1343
+ dragState2,
1344
+ isSplit,
1345
+ boundaryContainerSize,
1346
+ parentLayoutName,
1347
+ layoutName,
1348
+ selfContainerName,
1349
+ direction
1350
+ ]);
1351
+ return {
1352
+ direction,
1353
+ setDirection,
1354
+ isSplit,
1355
+ setIsSplit,
1356
+ boundaryContainerSize,
1357
+ //setBoundaryContainerSize,
1358
+ centerDropTargetComponent,
1359
+ afterDropTargetComponent,
1360
+ beforeDropTargetComponent,
1361
+ setAfterDropTargetComponent,
1362
+ setBeforeDropTargetComponent,
1363
+ setCenterDropTargetComponent,
1364
+ //dropTargetComponent,
1365
+ //setDropTargetComponent,
1366
+ //setDropPosition,
1367
+ isOver: dragState2?.isOver,
1368
+ layoutRef
1369
+ };
1370
+ }
1371
+ var MAX_STEP = 18;
1372
+ function edgeVelocity(x, y) {
1373
+ const w = window.innerWidth, h = window.innerHeight;
1374
+ const mx = w * 0.15, my = h * 0.15;
1375
+ let vx = 0;
1376
+ if (x < mx)
1377
+ vx = -((mx - x) / mx) * MAX_STEP;
1378
+ else if (x > w - mx)
1379
+ vx = (x - (w - mx)) / mx * MAX_STEP;
1380
+ let vy = 0;
1381
+ if (y < my)
1382
+ vy = -((my - y) / my) * MAX_STEP;
1383
+ else if (y > h - my)
1384
+ vy = (y - (h - my)) / my * MAX_STEP;
1385
+ return { vx, vy };
1386
+ }
1387
+ function FlexLayoutSplitScreenDragBox({
1388
+ onMouseDown,
1389
+ onTouchStart,
1390
+ dropEndCallback,
1391
+ style,
1392
+ navigationTitle,
1393
+ targetComponent,
1394
+ containerName,
1395
+ children,
1396
+ className,
1397
+ dropDocumentOutsideOption,
1398
+ screenKey = Array.from(
1399
+ window.crypto.getRandomValues(new Uint32Array(16)),
1400
+ (e) => e.toString(32).padStart(2, "0")
1401
+ ).join(""),
1402
+ isBlockingActiveInput = false,
1403
+ customData = {},
1404
+ scrollTargetRef,
1405
+ ...props
1406
+ }) {
1407
+ const scrollRAF = React2.useRef(null);
1408
+ const velocity = React2.useRef({ vx: 0, vy: 0 });
1409
+ const ref = React2.useRef(null);
1410
+ const clonedNodeRef = React2.useRef(null);
1411
+ const clonedWidth = React2.useRef(null);
1412
+ const clonedHeight = React2.useRef(null);
1413
+ const hrefUrlRef = React2.useRef("");
1414
+ const { handleStart, handleMove, handleEnd } = useDragEvents({
1415
+ isBlockingActiveInput
1416
+ });
1417
+ const handleMoveWrapper = (event) => {
1418
+ let x = 0;
1419
+ let y = 0;
1420
+ if (event.type === "touchmove") {
1421
+ const t = event.touches[0];
1422
+ x = t.clientX;
1423
+ y = t.clientY;
1424
+ } else {
1425
+ const m = event;
1426
+ x = m.clientX;
1427
+ y = m.clientY;
1428
+ }
1429
+ const { vx, vy } = edgeVelocity(x, y);
1430
+ const inEdge = vx !== 0 || vy !== 0;
1431
+ if (clonedNodeRef.current?.isConnected && !inEdge) {
1432
+ event.preventDefault();
1433
+ if (scrollRAF.current) {
1434
+ cancelAnimationFrame(scrollRAF.current);
1435
+ scrollRAF.current = null;
1436
+ }
1437
+ }
1438
+ if (clonedNodeRef.current?.isConnected && inEdge) {
1439
+ event.preventDefault();
1440
+ velocity.current = { vx, vy };
1441
+ if (!scrollRAF.current) {
1442
+ const step = () => {
1443
+ const target = scrollTargetRef?.current ?? document.scrollingElement;
1444
+ if (target?.scrollBy) {
1445
+ target.scrollBy(
1446
+ velocity.current.vx,
1447
+ velocity.current.vy
1448
+ );
1449
+ } else {
1450
+ window.scrollBy(
1451
+ velocity.current.vx,
1452
+ velocity.current.vy
1453
+ );
1454
+ }
1455
+ if (velocity.current.vx === 0 && velocity.current.vy === 0) {
1456
+ scrollRAF.current = null;
1457
+ return;
1458
+ }
1459
+ scrollRAF.current = requestAnimationFrame(step);
1460
+ };
1461
+ scrollRAF.current = requestAnimationFrame(step);
1462
+ }
1463
+ }
1464
+ if (event.type !== "touchmove") {
1465
+ event.preventDefault();
1466
+ }
1467
+ handleMove({
1468
+ event,
1469
+ notDragCallback: ({ x: x2, y: y2 }) => {
1470
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1471
+ },
1472
+ dragStartCallback: ({ x: x2, y: y2 }) => {
1473
+ if (!clonedNodeRef.current) return;
1474
+ navigator.vibrate(100);
1475
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1476
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1477
+ },
1478
+ moveingCallback: ({ x: x2, y: y2 }) => {
1479
+ if (clonedNodeRef.current?.isConnected) {
1480
+ clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
1481
+ clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
1482
+ }
1483
+ dragState.next({
1484
+ isDragging: true,
1485
+ isDrop: false,
1486
+ navigationTitle,
1487
+ children: targetComponent,
1488
+ x: x2,
1489
+ y: y2,
1490
+ containerName,
1491
+ dropDocumentOutsideOption,
1492
+ customData
1493
+ });
1494
+ }
1495
+ });
1496
+ };
1497
+ const handleEndWrapper = (event) => {
1498
+ if (scrollRAF.current !== null) {
1499
+ cancelAnimationFrame(scrollRAF.current);
1500
+ scrollRAF.current = null;
1501
+ }
1502
+ velocity.current = { vx: 0, vy: 0 };
1503
+ handleEnd({
1504
+ event,
1505
+ dragEndCallback: ({ x, y }) => {
1506
+ const href = hrefUrlRef.current;
1507
+ if (clonedNodeRef.current) clonedNodeRef.current.remove();
1508
+ if (dropDocumentOutsideOption && isDocumentOut({ x, y })) {
1509
+ if (dropDocumentOutsideOption.isNewTap || !dropDocumentOutsideOption.widthRatio && !dropDocumentOutsideOption.heightRatio) {
1510
+ window.open(href, "_blank");
1511
+ } else {
1512
+ const width = window.innerWidth * (dropDocumentOutsideOption.widthRatio || 1);
1513
+ const height = window.innerHeight * (dropDocumentOutsideOption.heightRatio || 1);
1514
+ window.open(
1515
+ href,
1516
+ "_blank",
1517
+ `width=${width},height=${height},left=${window.screenLeft - x * -1 - width},top=${window.screenTop + y}`
1518
+ );
1519
+ }
1520
+ }
1521
+ dragState.next({
1522
+ isDragging: false,
1523
+ isDrop: true,
1524
+ navigationTitle,
1525
+ children: targetComponent,
1526
+ x,
1527
+ y,
1528
+ containerName,
1529
+ dropDocumentOutsideOption,
1530
+ dropEndCallback,
1531
+ screenKey,
1532
+ customData
1533
+ });
1534
+ }
1535
+ });
1536
+ };
1537
+ React2.useEffect(() => {
1538
+ if (ref.current) {
1539
+ const clone = ref.current.cloneNode(true);
1540
+ const originRect = ref.current.getBoundingClientRect();
1541
+ clone.style.width = originRect.width + "px";
1542
+ clone.style.height = originRect.height + "px";
1543
+ clone.style.opacity = "0.3";
1544
+ clone.style.backdropFilter = "blur(6px)";
1545
+ clonedWidth.current = originRect.width;
1546
+ clonedHeight.current = originRect.height;
1547
+ if (dropDocumentOutsideOption?.openUrl) {
1548
+ hrefUrlRef.current = dropDocumentOutsideOption.openUrl;
1549
+ const href = document.createElement("span");
1550
+ href.textContent = hrefUrlRef.current;
1551
+ clone.prepend(href);
1552
+ }
1553
+ if (navigationTitle) {
1554
+ const title = document.createElement("span");
1555
+ title.textContent = navigationTitle;
1556
+ clone.prepend(title);
1557
+ }
1558
+ clone.style.position = "fixed";
1559
+ clonedNodeRef.current = clone;
1560
+ clonedNodeRef.current.classList.add(
1561
+ FlexLayout_default["flex-split-screen-drag-box-clone"]
1562
+ );
1563
+ }
1564
+ }, []);
1565
+ React2.useEffect(() => {
1566
+ const moveEvents = [
1567
+ "mousemove",
1568
+ "touchmove"
1569
+ ];
1570
+ const endEvents = ["mouseup", "touchend"];
1571
+ moveEvents.forEach((eventName) => {
1572
+ window.addEventListener(eventName, handleMoveWrapper, {
1573
+ passive: false
1574
+ });
1575
+ });
1576
+ endEvents.forEach((eventName) => {
1577
+ window.addEventListener(eventName, handleEndWrapper);
1578
+ });
1579
+ return () => {
1580
+ moveEvents.forEach((eventName) => {
1581
+ window.removeEventListener(eventName, handleMoveWrapper);
1582
+ });
1583
+ endEvents.forEach((eventName) => {
1584
+ window.removeEventListener(eventName, handleEndWrapper);
1585
+ });
1586
+ };
1587
+ }, [
1588
+ customData,
1589
+ targetComponent,
1590
+ dropDocumentOutsideOption,
1591
+ screenKey,
1592
+ isBlockingActiveInput,
1593
+ containerName,
1594
+ navigationTitle,
1595
+ dropEndCallback
1596
+ ]);
1597
+ React2.useEffect(() => {
1598
+ const el = ref.current;
1599
+ if (!el) return;
1600
+ const onCtx = (e) => e.preventDefault();
1601
+ el.addEventListener("contextmenu", onCtx);
1602
+ return () => {
1603
+ el.removeEventListener("contextmenu", onCtx);
1604
+ };
1605
+ }, []);
1606
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1607
+ "div",
1608
+ {
1609
+ className: `${className || ""} ${FlexLayout_default["flex-split-screen-drag-box"]}`,
1610
+ ref,
1611
+ onContextMenu: (e) => e.preventDefault(),
1612
+ onMouseDown: (ev) => {
1613
+ if (onMouseDown) {
1614
+ Promise.resolve().then(() => onMouseDown(ev));
1615
+ }
1616
+ handleStart({
1617
+ event: ev,
1618
+ dragStartCallback: ({ x, y }) => {
1619
+ if (clonedNodeRef.current) {
1620
+ document.body.appendChild(
1621
+ clonedNodeRef.current
1622
+ );
1623
+ if (ref.current) {
1624
+ const originRect = ref.current.getBoundingClientRect();
1625
+ clonedNodeRef.current.style.width = originRect.width + "px";
1626
+ clonedNodeRef.current.style.height = originRect.height + "px";
1627
+ clonedWidth.current = originRect.width;
1628
+ clonedHeight.current = originRect.height;
1629
+ }
1630
+ }
1631
+ if (clonedNodeRef.current?.isConnected) {
1632
+ navigator.vibrate(100);
1633
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1634
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1635
+ }
1636
+ dragState.next({
1637
+ isDragging: true,
1638
+ isDrop: false,
1639
+ navigationTitle,
1640
+ children: targetComponent,
1641
+ x,
1642
+ y,
1643
+ containerName,
1644
+ dropDocumentOutsideOption,
1645
+ customData
1646
+ });
1647
+ }
1648
+ });
1649
+ },
1650
+ onTouchStart: (ev) => {
1651
+ if (onTouchStart) {
1652
+ Promise.resolve().then(() => onTouchStart(ev));
1653
+ }
1654
+ handleStart({
1655
+ event: ev,
1656
+ dragStartCallback: ({ x, y }) => {
1657
+ if (clonedNodeRef.current) {
1658
+ document.body.appendChild(
1659
+ clonedNodeRef.current
1660
+ );
1661
+ if (ref.current) {
1662
+ const originRect = ref.current.getBoundingClientRect();
1663
+ clonedNodeRef.current.style.width = originRect.width + "px";
1664
+ clonedNodeRef.current.style.height = originRect.height + "px";
1665
+ clonedWidth.current = originRect.width;
1666
+ clonedHeight.current = originRect.height;
1667
+ }
1668
+ }
1669
+ if (clonedNodeRef.current?.isConnected) {
1670
+ navigator.vibrate(100);
1671
+ clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
1672
+ clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
1673
+ }
1674
+ dragState.next({
1675
+ isDragging: true,
1676
+ isDrop: false,
1677
+ navigationTitle,
1678
+ children: targetComponent,
1679
+ x,
1680
+ y,
1681
+ containerName,
1682
+ dropDocumentOutsideOption,
1683
+ customData
1684
+ });
1685
+ }
1686
+ });
1687
+ },
1688
+ style: { ...style },
1689
+ ...props
1690
+ },
1691
+ children
1692
+ ));
1693
+ }
1694
+
1695
+ // src/flex-layout/styles/listScroll.module.css
1696
+ var listScroll_default = {};
1697
+
1698
+ // src/flex-layout/components/FlexLayoutSplitScreenScrollBox.tsx
1699
+ var FlexLayoutSplitScreenScrollBox = ({
1700
+ className,
1701
+ children,
1702
+ keyName,
1703
+ direction,
1704
+ isDefaultScrollStyle = false,
1705
+ ...props
1706
+ }) => {
1707
+ const scrollRef = React2.useRef(null);
1708
+ const [isMouseDown, setIsMouseDown] = React2.useState(false);
1709
+ const scrollEventSubject = React2.useRef(new rxjs.Subject());
1710
+ React2.useEffect(() => {
1711
+ const mouseUpSubscribe = rxjs.fromEvent(
1712
+ window,
1713
+ "mouseup"
1714
+ ).subscribe(() => {
1715
+ setIsMouseDown(false);
1716
+ });
1717
+ const scrollEventSubscribe = scrollEventSubject.current.pipe(operators.throttleTime(70)).subscribe((position) => {
1718
+ setScrollPosition(keyName, position);
1719
+ });
1720
+ const scrollSubscribe = getScrollPosition(keyName).pipe(operators.take(1)).subscribe((position) => {
1721
+ if (scrollRef.current && position) {
1722
+ scrollRef.current.scrollLeft = position.x;
1723
+ scrollRef.current.scrollTop = position.y;
1724
+ }
1725
+ });
1726
+ return () => {
1727
+ removeScrollPosition(keyName);
1728
+ mouseUpSubscribe.unsubscribe();
1729
+ scrollSubscribe.unsubscribe();
1730
+ scrollEventSubscribe.unsubscribe();
1731
+ };
1732
+ }, [keyName]);
1733
+ React2.useEffect(() => {
1734
+ if (!scrollRef.current) return;
1735
+ let animationFrameId = null;
1736
+ const handleWheel = (event) => {
1737
+ if (!scrollRef.current || direction !== "x") return;
1738
+ if (scrollRef.current.matches(":hover")) {
1739
+ event.preventDefault();
1740
+ const { deltaY } = event;
1741
+ const newScrollLeft = scrollRef.current.scrollLeft + deltaY;
1742
+ if (animationFrameId) {
1743
+ cancelAnimationFrame(animationFrameId);
1744
+ }
1745
+ animationFrameId = requestAnimationFrame(() => {
1746
+ scrollRef.current.scrollLeft = newScrollLeft;
1747
+ scrollEventSubject.current.next({
1748
+ x: newScrollLeft,
1749
+ y: scrollRef.current.scrollTop
1750
+ });
1751
+ animationFrameId = null;
1752
+ });
1753
+ }
1754
+ };
1755
+ scrollRef.current.addEventListener("wheel", handleWheel, {
1756
+ passive: false
1757
+ });
1758
+ return () => {
1759
+ scrollRef.current?.removeEventListener("wheel", handleWheel);
1760
+ };
1761
+ }, []);
1762
+ return /* @__PURE__ */ React.createElement(
1763
+ "div",
1764
+ {
1765
+ ref: scrollRef,
1766
+ onMouseUp: () => setIsMouseDown(false),
1767
+ onMouseDown: () => setIsMouseDown(true),
1768
+ onMouseMove: (event) => {
1769
+ if (!scrollRef.current || !isMouseDown || direction !== "x")
1770
+ return;
1771
+ scrollRef.current.scrollLeft += event.movementX * -1;
1772
+ scrollEventSubject.current.next({
1773
+ x: scrollRef.current.scrollLeft,
1774
+ y: scrollRef.current.scrollTop
1775
+ });
1776
+ },
1777
+ onScroll: () => {
1778
+ if (!scrollRef.current) return;
1779
+ scrollEventSubject.current.next({
1780
+ x: scrollRef.current.scrollLeft,
1781
+ y: scrollRef.current.scrollTop
1782
+ });
1783
+ },
1784
+ className: `${className || ""} ${isDefaultScrollStyle ? listScroll_default["default-scroll"] : listScroll_default["list-scroll"]} ${direction ? listScroll_default[direction] : ""}`,
1785
+ ...props
1786
+ },
1787
+ children
1788
+ );
1789
+ };
1790
+ var FlexLayoutSplitScreenScrollBox_default = React2.memo(FlexLayoutSplitScreenScrollBox);
1791
+
1792
+ // src/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.tsx
1793
+ function FlexLayoutSplitScreenDragBoxContainer({
1794
+ className,
1795
+ children,
1796
+ layoutName,
1797
+ ...props
1798
+ }) {
1799
+ return /* @__PURE__ */ React.createElement(
1800
+ FlexLayoutSplitScreenScrollBox_default,
1801
+ {
1802
+ keyName: layoutName,
1803
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-container"]} ${className && className !== "" && className || ""}`,
1804
+ direction: "x",
1805
+ ...props
1806
+ },
1807
+ children
1808
+ );
1809
+ }
1810
+ function FlexLayoutSplitScreenDragBoxItem({
1811
+ children,
1812
+ onClose,
1813
+ isActive,
1814
+ ...props
1815
+ }) {
1816
+ React2.useEffect(() => {
1817
+ allSplitScreenCount.next(allSplitScreenCount.value + 1);
1818
+ return () => {
1819
+ if (allSplitScreenCount.value <= 1) return;
1820
+ allSplitScreenCount.next(allSplitScreenCount.value - 1);
1821
+ };
1822
+ }, []);
1823
+ return /* @__PURE__ */ React.createElement(
1824
+ "div",
1825
+ {
1826
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-item"]} ${isActive ? FlexLayout_default["active"] : ""}`,
1827
+ ...props
1828
+ },
1829
+ children,
1830
+ /* @__PURE__ */ React.createElement("button", { type: "button", onClick: (ev) => onClose(ev) }, "X")
1831
+ );
1832
+ }
1833
+
1834
+ // src/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.tsx
1835
+ function FlexLayoutSplitScreenDragBoxTitleMore({
1836
+ className,
1837
+ ...props
1838
+ }) {
1839
+ return /* @__PURE__ */ React.createElement(
1840
+ "button",
1841
+ {
1842
+ ...props,
1843
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-more"]} ${className || ""}`
1844
+ },
1845
+ /* @__PURE__ */ React.createElement("span", null, "."),
1846
+ /* @__PURE__ */ React.createElement("span", null, "."),
1847
+ /* @__PURE__ */ React.createElement("span", null, ".")
1848
+ );
1849
+ }
1850
+
1851
+ // src/flex-layout/components/FlexLayoutSplitScreen.tsx
1852
+ function isOverDrop({
1853
+ x,
1854
+ y,
1855
+ element
1856
+ }) {
1857
+ const {
1858
+ x: elementX,
1859
+ y: elementY,
1860
+ right: elementRight,
1861
+ bottom: elementBottom
1862
+ } = element.getBoundingClientRect();
1863
+ const isElementOver = x < elementX || x > elementRight || y < elementY || y > elementBottom;
1864
+ return isElementOver;
1865
+ }
1866
+ function isInnerDrop({
1867
+ x,
1868
+ y,
1869
+ element
1870
+ }) {
1871
+ const {
1872
+ x: elementX,
1873
+ y: elementY,
1874
+ right: elementRight,
1875
+ bottom: elementBottom
1876
+ } = element.getBoundingClientRect();
1877
+ const isElementInner = x >= elementX && x <= elementRight && y >= elementY && y <= elementBottom;
1878
+ return isElementInner;
1879
+ }
1880
+ var handleUpdateDropTargetComponents = ({
1881
+ orderName,
1882
+ parentOrderName,
1883
+ containerName,
1884
+ parentLayoutName,
1885
+ layoutName,
1886
+ dropComponent,
1887
+ navigationTitle,
1888
+ nextContainerName,
1889
+ isUsePrefix = true,
1890
+ beforeDropTargetComponent,
1891
+ afterDropTargetComponent,
1892
+ centerDropTargetComponent,
1893
+ dropDocumentOutsideOption,
1894
+ screenKey = Array.from(
1895
+ window.crypto.getRandomValues(new Uint32Array(16)),
1896
+ (e) => e.toString(32).padStart(2, "0")
1897
+ ).join("")
1898
+ }) => {
1899
+ const nextContainerNameOrderName = parentOrderName ? parentOrderName : orderName;
1900
+ let listMap;
1901
+ let list;
1902
+ let key;
1903
+ if (nextContainerNameOrderName === orderName || nextContainerNameOrderName === "center") {
1904
+ listMap = orderName === "before" ? { beforeDropTargetComponent } : orderName === "after" ? { afterDropTargetComponent } : {
1905
+ centerDropTargetComponent: centerDropTargetComponent.filter(
1906
+ (e) => !e.containerName.split("_").at(0).startsWith(
1907
+ containerName.split("_").at(0)
1908
+ )
1909
+ )
1910
+ };
1911
+ } else {
1912
+ listMap = nextContainerNameOrderName === "before" ? { beforeDropTargetComponent } : { afterDropTargetComponent };
1913
+ }
1914
+ const entries = Object.entries(listMap)[0];
1915
+ key = entries[0];
1916
+ list = entries[1];
1917
+ const newComponent = {
1918
+ containerName: `${containerName + "_" + layoutName}${isUsePrefix ? "_" + orderName + "-" + list.length : ""}`,
1919
+ component: React2.cloneElement(
1920
+ dropComponent,
1921
+ { key: screenKey, screenKey }
1922
+ ),
1923
+ navigationTitle,
1924
+ dropDocumentOutsideOption,
1925
+ screenKey: screenKey || Array.from(
1926
+ window.crypto.getRandomValues(new Uint32Array(16)),
1927
+ (e) => e.toString(32).padStart(2, "0")
1928
+ ).join("")
1929
+ };
1930
+ let allComponents;
1931
+ if (nextContainerName) {
1932
+ const index = list.findIndex(
1933
+ (item) => item.containerName === nextContainerName
1934
+ );
1935
+ if (index !== -1) {
1936
+ if (nextContainerNameOrderName === orderName) {
1937
+ if (orderName === "before") {
1938
+ allComponents = [
1939
+ ...list.slice(0, index),
1940
+ newComponent,
1941
+ ...list.slice(index)
1942
+ ];
1943
+ } else {
1944
+ allComponents = [
1945
+ ...list.slice(0, index + 1),
1946
+ newComponent,
1947
+ ...list.slice(index + 1)
1948
+ ];
1949
+ }
1950
+ } else {
1951
+ if (nextContainerNameOrderName === "after" && orderName === "before") {
1952
+ allComponents = [
1953
+ ...list.slice(0, index),
1954
+ newComponent,
1955
+ ...list.slice(index)
1956
+ ];
1957
+ } else if (nextContainerNameOrderName === "before" && orderName === "after") {
1958
+ allComponents = [
1959
+ ...list.slice(0, index + 1),
1960
+ newComponent,
1961
+ ...list.slice(index + 1)
1962
+ ];
1963
+ } else {
1964
+ if (orderName === "before") {
1965
+ allComponents = [
1966
+ ...list.slice(0, index),
1967
+ newComponent,
1968
+ ...list.slice(index)
1969
+ ];
1970
+ } else {
1971
+ allComponents = [
1972
+ ...list.slice(0, index + 1),
1973
+ newComponent,
1974
+ ...list.slice(index + 1)
1975
+ ];
1976
+ }
1977
+ }
1978
+ }
1979
+ } else {
1980
+ if (nextContainerNameOrderName === "center" && orderName === "after") {
1981
+ allComponents = [newComponent, ...list];
1982
+ } else if (nextContainerNameOrderName === "center" && orderName === "before") {
1983
+ allComponents = [...list, newComponent];
1984
+ } else {
1985
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1986
+ }
1987
+ }
1988
+ } else {
1989
+ allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
1990
+ }
1991
+ const seen = /* @__PURE__ */ new Set();
1992
+ const result = allComponents.filter((item) => {
1993
+ if (seen.has(item.containerName)) {
1994
+ return false;
1995
+ }
1996
+ seen.add(item.containerName);
1997
+ return true;
1998
+ });
1999
+ dropMovementEventSubject.next({
2000
+ state: "append",
2001
+ targetParentLayoutName: parentLayoutName,
2002
+ targetLayoutName: layoutName,
2003
+ targetContainerName: containerName,
2004
+ orderName
2005
+ });
2006
+ return { [key]: result };
2007
+ };
2008
+ var handleRemove = (list, targetContainerName, orderNameSetter) => {
2009
+ const result = list.filter((e) => e.containerName !== targetContainerName);
2010
+ if (result.length != list.length)
2011
+ orderNameSetter(list.length - result.length);
2012
+ return result;
2013
+ };
2014
+ function getAdjacentItem(items, currentIndex) {
2015
+ if (currentIndex + 1 < items.length) {
2016
+ return {
2017
+ adjacentItem: items[currentIndex + 1],
2018
+ adjacentIndex: currentIndex + 1
2019
+ };
2020
+ } else if (currentIndex - 1 >= 0) {
2021
+ return {
2022
+ adjacentItem: items[currentIndex - 1],
2023
+ adjacentIndex: currentIndex - 1
2024
+ };
2025
+ }
2026
+ return { adjacentItem: null, adjacentIndex: currentIndex };
2027
+ }
2028
+ var getSelfOrderName = (containerName) => {
2029
+ const result = containerName.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);
2030
+ if (["before", "center", "after"].some((e) => e === result)) {
2031
+ return result;
2032
+ } else {
2033
+ return;
2034
+ }
2035
+ };
2036
+ function FlexLayoutSplitScreen({
2037
+ children,
2038
+ containerName,
2039
+ layoutName,
2040
+ navigationTitle,
2041
+ dropDocumentOutsideOption,
2042
+ screenKey
2043
+ }) {
2044
+ const {
2045
+ direction,
2046
+ isSplit,
2047
+ boundaryContainerSize,
2048
+ afterDropTargetComponent,
2049
+ beforeDropTargetComponent,
2050
+ centerDropTargetComponent,
2051
+ setAfterDropTargetComponent,
2052
+ setBeforeDropTargetComponent,
2053
+ setCenterDropTargetComponent,
2054
+ layoutRef,
2055
+ setIsSplit,
2056
+ setDirection
2057
+ } = useFlexLayoutSplitScreen({
2058
+ isSplitInitial: false,
2059
+ directionInitial: "row",
2060
+ selfContainerName: containerName,
2061
+ parentLayoutName: "",
2062
+ layoutName
2063
+ });
2064
+ React2.useEffect(() => {
2065
+ resetRootSplitScreen(layoutName);
2066
+ const subscribe = getSplitScreen(layoutName, layoutName).subscribe((layoutInfo) => {
2067
+ if (layoutInfo) {
2068
+ setBeforeDropTargetComponent([
2069
+ ...layoutInfo.beforeDropTargetComponent
2070
+ ]);
2071
+ setAfterDropTargetComponent([
2072
+ ...layoutInfo.afterDropTargetComponent
2073
+ ]);
2074
+ setCenterDropTargetComponent([
2075
+ ...layoutInfo.centerDropTargetComponent
2076
+ ]);
2077
+ setDirection(layoutInfo.direction);
2078
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
2079
+ setIsSplit(true);
2080
+ }
2081
+ } else {
2082
+ setSplitScreen(layoutName, layoutName, {
2083
+ afterDropTargetComponent: [],
2084
+ beforeDropTargetComponent: [],
2085
+ centerDropTargetComponent: [
2086
+ {
2087
+ containerName,
2088
+ component: children,
2089
+ navigationTitle,
2090
+ dropDocumentOutsideOption,
2091
+ screenKey: screenKey ? screenKey : Array.from(
2092
+ window.crypto.getRandomValues(
2093
+ new Uint32Array(16)
2094
+ ),
2095
+ (e) => e.toString(32).padStart(2, "0")
2096
+ ).join("")
2097
+ }
2098
+ ],
2099
+ direction
2100
+ });
2101
+ }
2102
+ });
2103
+ return () => {
2104
+ subscribe.unsubscribe();
2105
+ resetRootSplitScreen(layoutName);
2106
+ };
2107
+ }, [layoutName]);
2108
+ React2.useEffect(() => {
2109
+ const subscribe = dropMovementEventSubject.pipe(
2110
+ rxjs.distinctUntilChanged((prev, curr) => {
2111
+ const filterChildren2 = (obj) => {
2112
+ const {
2113
+ children: children2,
2114
+ component,
2115
+ targetComponent,
2116
+ x,
2117
+ y,
2118
+ ...rest
2119
+ } = obj || {};
2120
+ return rest;
2121
+ };
2122
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
2123
+ })
2124
+ ).subscribe((event) => {
2125
+ if (event.state === "remove") {
2126
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
2127
+ requestAnimationFrame(() => {
2128
+ let removeCallback = (removeOrderName) => {
2129
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
2130
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2131
+ orderName: removeOrderName,
2132
+ containerName: event.nextContainerName,
2133
+ parentLayoutName: "",
2134
+ layoutName,
2135
+ dropComponent: event.targetComponent,
2136
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
2137
+ isUsePrefix: true,
2138
+ afterDropTargetComponent,
2139
+ beforeDropTargetComponent,
2140
+ centerDropTargetComponent,
2141
+ dropDocumentOutsideOption,
2142
+ screenKey: event.dropTargetComponentEvent.screenKey
2143
+ });
2144
+ setSplitScreen(layoutName, layoutName, {
2145
+ ...getCurrentSplitScreenComponents(
2146
+ layoutName,
2147
+ layoutName
2148
+ ) || {
2149
+ afterDropTargetComponent,
2150
+ beforeDropTargetComponent,
2151
+ centerDropTargetComponent,
2152
+ direction
2153
+ },
2154
+ ...targetComponentsMap
2155
+ });
2156
+ Promise.resolve().then(
2157
+ () => event.dropEndCallback && event.dropEndCallback({
2158
+ x: event.x,
2159
+ y: event.y,
2160
+ containerName
2161
+ })
2162
+ );
2163
+ }
2164
+ };
2165
+ const currentComponents = getCurrentSplitScreenComponents(
2166
+ layoutName,
2167
+ layoutName
2168
+ );
2169
+ const afterList = handleRemove(
2170
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
2171
+ event.targetContainerName,
2172
+ () => removeCallback("after")
2173
+ );
2174
+ const beforList = handleRemove(
2175
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
2176
+ event.targetContainerName,
2177
+ () => removeCallback("before")
2178
+ );
2179
+ const centerList = handleRemove(
2180
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
2181
+ event.targetContainerName,
2182
+ () => removeCallback("center")
2183
+ );
2184
+ setSplitScreen(layoutName, layoutName, {
2185
+ afterDropTargetComponent: afterList,
2186
+ beforeDropTargetComponent: beforList,
2187
+ centerDropTargetComponent: centerList,
2188
+ direction
2189
+ });
2190
+ });
2191
+ }
2192
+ } else if (event.state === "append") {
2193
+ const {
2194
+ x,
2195
+ y,
2196
+ dropEndCallback,
2197
+ dropTargetComponentEvent,
2198
+ orderName,
2199
+ parentOrderName,
2200
+ targetLayoutName,
2201
+ targetParentLayoutName,
2202
+ targetContainerName,
2203
+ targetComponent,
2204
+ nextContainerName
2205
+ } = event;
2206
+ if (layoutRef.current && orderName && x && y && targetComponent && dropTargetComponentEvent && targetLayoutName === layoutName && isInnerDrop({ x, y, element: layoutRef.current })) {
2207
+ const {
2208
+ direction: dropDirection,
2209
+ navigationTitle: navigationTitle2,
2210
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2211
+ } = dropTargetComponentEvent;
2212
+ const isOrderNameNotCenter = orderName !== "center";
2213
+ const isOrderNameCenterAndFirstScreen = orderName === "center" && centerDropTargetComponent.length <= 1;
2214
+ if (isOrderNameNotCenter || isOrderNameCenterAndFirstScreen) {
2215
+ setIsSplit(true);
2216
+ if (isOrderNameNotCenter) {
2217
+ setDirection(dropDirection);
2218
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2219
+ orderName,
2220
+ parentOrderName,
2221
+ containerName: targetContainerName,
2222
+ nextContainerName,
2223
+ dropComponent: targetComponent,
2224
+ parentLayoutName: "",
2225
+ layoutName,
2226
+ navigationTitle: navigationTitle2,
2227
+ isUsePrefix: true,
2228
+ afterDropTargetComponent,
2229
+ beforeDropTargetComponent,
2230
+ centerDropTargetComponent,
2231
+ dropDocumentOutsideOption: dropDocumentOutsideOption2
2232
+ });
2233
+ setSplitScreen(layoutName, layoutName, {
2234
+ ...{
2235
+ afterDropTargetComponent,
2236
+ beforeDropTargetComponent,
2237
+ centerDropTargetComponent,
2238
+ direction: dropDirection
2239
+ },
2240
+ ...targetComponentsMap,
2241
+ ...{ direction: dropDirection }
2242
+ });
2243
+ Promise.resolve().then(
2244
+ () => dropEndCallback && dropEndCallback({
2245
+ x: event.x,
2246
+ y: event.y,
2247
+ containerName
2248
+ })
2249
+ );
2250
+ } else {
2251
+ const childScreenInfo = getCurrentSplitScreenComponents(
2252
+ layoutName,
2253
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`
2254
+ ) || {
2255
+ afterDropTargetComponent: [],
2256
+ beforeDropTargetComponent: [],
2257
+ centerDropTargetComponent: [],
2258
+ direction
2259
+ };
2260
+ setSplitScreen(
2261
+ layoutName,
2262
+ `${layoutName}_center=${centerDropTargetComponent[0].screenKey}`,
2263
+ {
2264
+ ...childScreenInfo,
2265
+ ...{
2266
+ centerDropTargetComponent: [
2267
+ centerDropTargetComponent[0],
2268
+ {
2269
+ containerName: `${targetContainerName}_${layoutName}_${orderName}`,
2270
+ component: targetComponent,
2271
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2272
+ screenKey: centerDropTargetComponent[0].screenKey,
2273
+ navigationTitle: navigationTitle2
2274
+ }
2275
+ ]
2276
+ }
2277
+ }
2278
+ );
2279
+ }
2280
+ }
2281
+ }
2282
+ }
2283
+ });
2284
+ return () => {
2285
+ subscribe.unsubscribe();
2286
+ };
2287
+ }, [
2288
+ direction,
2289
+ layoutName,
2290
+ isSplit,
2291
+ beforeDropTargetComponent,
2292
+ afterDropTargetComponent,
2293
+ centerDropTargetComponent
2294
+ ]);
2295
+ return /* @__PURE__ */ React.createElement("div", { className: `${FlexLayout_default["flex-split-screen"]}`, ref: layoutRef }, /* @__PURE__ */ React.createElement(
2296
+ FlexLayout,
2297
+ {
2298
+ direction,
2299
+ layoutName,
2300
+ "data-is_split": isSplit,
2301
+ panelMovementMode: "bulldozer"
2302
+ },
2303
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, beforeDropTargetComponent.map(
2304
+ ({
2305
+ containerName: cName,
2306
+ component,
2307
+ navigationTitle: navigationTitle2,
2308
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2309
+ screenKey: screenKey2
2310
+ }, i) => /* @__PURE__ */ React.createElement(
2311
+ FlexLayoutContainer,
2312
+ {
2313
+ containerName: cName,
2314
+ isInitialResizable: true,
2315
+ isResizePanel: true,
2316
+ key: cName
2317
+ },
2318
+ /* @__PURE__ */ React.createElement(
2319
+ FlexLayoutSplitScreenChild,
2320
+ {
2321
+ parentDirection: direction,
2322
+ layoutName: `${layoutName}_before`,
2323
+ parentLayoutName: layoutName,
2324
+ containerName: cName,
2325
+ depth: 1,
2326
+ rootRef: layoutRef,
2327
+ screenKey: screenKey2,
2328
+ initialCenterComponents: [
2329
+ {
2330
+ navigationTitle: navigationTitle2,
2331
+ component,
2332
+ containerName: cName,
2333
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2334
+ screenKey: screenKey2
2335
+ }
2336
+ ],
2337
+ rootName: layoutName
2338
+ }
2339
+ )
2340
+ )
2341
+ )) : /* @__PURE__ */ React.createElement("div", null),
2342
+ centerDropTargetComponent.length === 0 ? /* @__PURE__ */ React.createElement("div", null) : /* @__PURE__ */ React.createElement(
2343
+ FlexLayoutContainer,
2344
+ {
2345
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2346
+ isInitialResizable: true,
2347
+ isResizePanel: isSplit
2348
+ },
2349
+ isSplit ? /* @__PURE__ */ React.createElement(
2350
+ FlexLayoutSplitScreenChild,
2351
+ {
2352
+ parentDirection: direction,
2353
+ layoutName: `${layoutName}_center`,
2354
+ parentLayoutName: layoutName,
2355
+ containerName: `${centerDropTargetComponent[0].containerName}`,
2356
+ depth: 0,
2357
+ rootRef: layoutRef,
2358
+ screenKey: centerDropTargetComponent[0].screenKey,
2359
+ initialCenterComponents: [
2360
+ {
2361
+ navigationTitle: centerDropTargetComponent[0].navigationTitle,
2362
+ component: centerDropTargetComponent[0].component,
2363
+ containerName: centerDropTargetComponent[0].containerName,
2364
+ dropDocumentOutsideOption: centerDropTargetComponent[0].dropDocumentOutsideOption,
2365
+ screenKey: centerDropTargetComponent[0].screenKey
2366
+ }
2367
+ ],
2368
+ rootName: layoutName
2369
+ }
2370
+ ) : /* @__PURE__ */ React.createElement(
2371
+ FlexLayoutSplitScreenScrollBox_default,
2372
+ {
2373
+ keyName: centerDropTargetComponent[0].containerName,
2374
+ isDefaultScrollStyle: true
2375
+ },
2376
+ centerDropTargetComponent[0].component
2377
+ )
2378
+ ),
2379
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, afterDropTargetComponent.map(
2380
+ ({
2381
+ containerName: cName,
2382
+ component,
2383
+ navigationTitle: navigationTitle2,
2384
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2385
+ screenKey: screenKey2
2386
+ }, i) => /* @__PURE__ */ React.createElement(
2387
+ FlexLayoutContainer,
2388
+ {
2389
+ containerName: cName,
2390
+ isInitialResizable: true,
2391
+ isResizePanel: afterDropTargetComponent.length - 1 !== i,
2392
+ key: cName
2393
+ },
2394
+ /* @__PURE__ */ React.createElement(
2395
+ FlexLayoutSplitScreenChild,
2396
+ {
2397
+ parentDirection: direction,
2398
+ layoutName: `${layoutName}_after`,
2399
+ parentLayoutName: layoutName,
2400
+ containerName: cName,
2401
+ depth: 1,
2402
+ rootRef: layoutRef,
2403
+ screenKey: screenKey2,
2404
+ initialCenterComponents: [
2405
+ {
2406
+ navigationTitle: navigationTitle2,
2407
+ component,
2408
+ containerName: cName,
2409
+ dropDocumentOutsideOption: dropDocumentOutsideOption2,
2410
+ screenKey: screenKey2
2411
+ }
2412
+ ],
2413
+ rootName: layoutName
2414
+ }
2415
+ )
2416
+ )
2417
+ )) : /* @__PURE__ */ React.createElement("div", null)
2418
+ ), boundaryContainerSize && /* @__PURE__ */ React.createElement(
2419
+ "div",
2420
+ {
2421
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
2422
+ style: { ...boundaryContainerSize }
2423
+ },
2424
+ "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
2425
+ ));
2426
+ }
2427
+ function FlexLayoutSplitScreenChild({
2428
+ containerName,
2429
+ layoutName,
2430
+ parentLayoutName,
2431
+ parentDirection,
2432
+ depth,
2433
+ //isSplit: isSplitInitial,
2434
+ rootRef,
2435
+ rootName,
2436
+ initialCenterComponents,
2437
+ screenKey
2438
+ }) {
2439
+ const {
2440
+ direction,
2441
+ isSplit,
2442
+ boundaryContainerSize,
2443
+ afterDropTargetComponent,
2444
+ beforeDropTargetComponent,
2445
+ centerDropTargetComponent,
2446
+ setAfterDropTargetComponent,
2447
+ setBeforeDropTargetComponent,
2448
+ setCenterDropTargetComponent,
2449
+ layoutRef,
2450
+ setIsSplit,
2451
+ setDirection
2452
+ } = useFlexLayoutSplitScreen({
2453
+ isSplitInitial: false,
2454
+ directionInitial: "row",
2455
+ parentDirection,
2456
+ selfContainerName: containerName,
2457
+ parentLayoutName,
2458
+ layoutName
2459
+ });
2460
+ const [isEmptyContent, setIsEmptyContent] = React2.useState(false);
2461
+ const [activeIndex, setActiveIndex] = React2.useState(0);
2462
+ const centerDropTargetComponentRef = React2.useRef(centerDropTargetComponent);
2463
+ const activeIndexRef = React2.useRef(activeIndex);
2464
+ React2.useEffect(() => {
2465
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).pipe(rxjs.take(1)).subscribe((layoutInfo) => {
2466
+ setSplitScreen(rootName, `${layoutName}=${screenKey}`, {
2467
+ afterDropTargetComponent: layoutInfo?.afterDropTargetComponent || [],
2468
+ beforeDropTargetComponent: layoutInfo?.beforeDropTargetComponent || [],
2469
+ centerDropTargetComponent: layoutInfo?.centerDropTargetComponent || initialCenterComponents || [],
2470
+ direction: layoutInfo?.direction || direction
2471
+ });
2472
+ });
2473
+ return () => {
2474
+ removeSplitScreenChild(rootName, layoutName);
2475
+ subscribe.unsubscribe();
2476
+ };
2477
+ }, [rootName, layoutName, initialCenterComponents]);
2478
+ React2.useEffect(() => {
2479
+ const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).subscribe((layoutInfo) => {
2480
+ if (layoutInfo) {
2481
+ setBeforeDropTargetComponent([
2482
+ ...layoutInfo.beforeDropTargetComponent
2483
+ ]);
2484
+ setAfterDropTargetComponent([
2485
+ ...layoutInfo.afterDropTargetComponent
2486
+ ]);
2487
+ setCenterDropTargetComponent([
2488
+ ...layoutInfo.centerDropTargetComponent
2489
+ ]);
2490
+ setDirection(layoutInfo.direction);
2491
+ if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
2492
+ setIsSplit(true);
2493
+ } else if (layoutInfo.beforeDropTargetComponent.length === 0 && layoutInfo.centerDropTargetComponent.length === 0 && layoutInfo.afterDropTargetComponent.length === 0) {
2494
+ dropMovementEventSubject.next({
2495
+ state: "remove",
2496
+ targetContainerName: containerName,
2497
+ targetParentLayoutName: "",
2498
+ targetLayoutName: parentLayoutName
2499
+ });
2500
+ setIsEmptyContent(true);
2501
+ }
2502
+ }
2503
+ });
2504
+ return () => {
2505
+ subscribe.unsubscribe();
2506
+ };
2507
+ }, [rootName, layoutName]);
2508
+ React2.useEffect(() => {
2509
+ const subscribe = dropMovementEventSubject.pipe(
2510
+ rxjs.distinctUntilChanged((prev, curr) => {
2511
+ const filterChildren2 = (obj) => {
2512
+ const {
2513
+ children,
2514
+ component,
2515
+ targetComponent,
2516
+ x,
2517
+ y,
2518
+ ...rest
2519
+ } = obj || {};
2520
+ return rest;
2521
+ };
2522
+ return equal__default.default(filterChildren2(prev), filterChildren2(curr));
2523
+ })
2524
+ ).subscribe((event) => {
2525
+ if (event.state === "remove") {
2526
+ if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
2527
+ requestAnimationFrame(() => {
2528
+ let removeCallback = (removeOrderName) => {
2529
+ if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
2530
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2531
+ orderName: removeOrderName,
2532
+ containerName: event.nextContainerName,
2533
+ parentLayoutName,
2534
+ layoutName,
2535
+ dropComponent: event.targetComponent,
2536
+ navigationTitle: event.dropTargetComponentEvent.navigationTitle,
2537
+ isUsePrefix: true,
2538
+ afterDropTargetComponent,
2539
+ beforeDropTargetComponent,
2540
+ centerDropTargetComponent,
2541
+ dropDocumentOutsideOption: event.dropTargetComponentEvent?.dropDocumentOutsideOption,
2542
+ screenKey: event.dropTargetComponentEvent.screenKey
2543
+ });
2544
+ setSplitScreen(
2545
+ rootName,
2546
+ `${layoutName}=${screenKey}`,
2547
+ {
2548
+ ...getCurrentSplitScreenComponents(
2549
+ rootName,
2550
+ `${layoutName}=${screenKey}`
2551
+ ) || {
2552
+ afterDropTargetComponent,
2553
+ beforeDropTargetComponent,
2554
+ centerDropTargetComponent,
2555
+ direction
2556
+ },
2557
+ ...targetComponentsMap
2558
+ }
2559
+ );
2560
+ Promise.resolve().then(
2561
+ () => event.dropEndCallback && event.dropEndCallback({
2562
+ x: event.x,
2563
+ y: event.y,
2564
+ containerName
2565
+ })
2566
+ );
2567
+ }
2568
+ };
2569
+ const currentComponents = getCurrentSplitScreenComponents(
2570
+ rootName,
2571
+ `${layoutName}=${screenKey}`
2572
+ );
2573
+ const afterList = handleRemove(
2574
+ currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
2575
+ event.targetContainerName,
2576
+ () => removeCallback("after")
2577
+ );
2578
+ const beforList = handleRemove(
2579
+ currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
2580
+ event.targetContainerName,
2581
+ () => removeCallback("before")
2582
+ );
2583
+ const centerList = handleRemove(
2584
+ currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
2585
+ event.targetContainerName,
2586
+ () => removeCallback("center")
2587
+ );
2588
+ setSplitScreen(
2589
+ rootName,
2590
+ `${layoutName}=${screenKey}`,
2591
+ {
2592
+ afterDropTargetComponent: afterList,
2593
+ beforeDropTargetComponent: beforList,
2594
+ centerDropTargetComponent: centerList,
2595
+ direction
2596
+ }
2597
+ );
2598
+ });
2599
+ }
2600
+ } else if (event.state === "append") {
2601
+ const {
2602
+ x,
2603
+ y,
2604
+ dropEndCallback,
2605
+ dropTargetComponentEvent,
2606
+ orderName,
2607
+ targetLayoutName,
2608
+ targetParentLayoutName,
2609
+ targetContainerName,
2610
+ targetComponent,
2611
+ nextContainerName,
2612
+ parentOrderName
2613
+ } = event;
2614
+ if (layoutRef.current && orderName && x && y && dropTargetComponentEvent && isInnerDrop({ x, y, element: layoutRef.current })) {
2615
+ const {
2616
+ direction: dropDirection,
2617
+ navigationTitle,
2618
+ dropDocumentOutsideOption,
2619
+ screenKey: containerScreenKey
2620
+ } = dropTargetComponentEvent;
2621
+ if (
2622
+ //orderName !== 'center' &&
2623
+ targetLayoutName === layoutName && targetComponent
2624
+ ) {
2625
+ if (dropDirection === parentDirection && orderName !== "center") {
2626
+ dropMovementEventSubject.next({
2627
+ state: "append",
2628
+ targetContainerName,
2629
+ targetParentLayoutName: "",
2630
+ targetLayoutName: parentLayoutName,
2631
+ targetComponent,
2632
+ nextContainerName: containerName,
2633
+ parentOrderName: getSelfOrderName(layoutName) || orderName,
2634
+ orderName,
2635
+ x,
2636
+ y,
2637
+ dropEndCallback,
2638
+ dropTargetComponentEvent: {
2639
+ navigationTitle,
2640
+ dropDocumentOutsideOption,
2641
+ direction: parentDirection,
2642
+ screenKey
2643
+ }
2644
+ });
2645
+ } else {
2646
+ if (orderName !== "center") {
2647
+ setDirection(dropDirection);
2648
+ setIsSplit(true);
2649
+ }
2650
+ const targetComponentsMap = handleUpdateDropTargetComponents({
2651
+ orderName,
2652
+ parentOrderName,
2653
+ containerName: targetContainerName,
2654
+ nextContainerName,
2655
+ parentLayoutName,
2656
+ layoutName,
2657
+ dropComponent: targetComponent,
2658
+ navigationTitle,
2659
+ isUsePrefix: orderName !== "center",
2660
+ afterDropTargetComponent,
2661
+ beforeDropTargetComponent,
2662
+ centerDropTargetComponent,
2663
+ dropDocumentOutsideOption
2664
+ });
2665
+ setSplitScreen(
2666
+ rootName,
2667
+ `${layoutName}=${screenKey}`,
2668
+ {
2669
+ ...getCurrentSplitScreenComponents(
2670
+ rootName,
2671
+ `${layoutName}=${screenKey}`
2672
+ ) || {
2673
+ afterDropTargetComponent,
2674
+ beforeDropTargetComponent,
2675
+ centerDropTargetComponent,
2676
+ direction
2677
+ },
2678
+ ...targetComponentsMap,
2679
+ ...{ direction: dropDirection }
2680
+ }
2681
+ );
2682
+ Promise.resolve().then(
2683
+ () => event.dropEndCallback && event.dropEndCallback({
2684
+ x: event.x,
2685
+ y: event.y,
2686
+ containerName
2687
+ })
2688
+ );
2689
+ }
2690
+ }
2691
+ }
2692
+ }
2693
+ });
2694
+ return () => {
2695
+ subscribe.unsubscribe();
2696
+ };
2697
+ }, [
2698
+ direction,
2699
+ parentDirection,
2700
+ parentLayoutName,
2701
+ layoutName,
2702
+ beforeDropTargetComponent,
2703
+ afterDropTargetComponent,
2704
+ centerDropTargetComponent
2705
+ ]);
2706
+ React2.useEffect(() => {
2707
+ centerDropTargetComponentRef.current = centerDropTargetComponent;
2708
+ }, [centerDropTargetComponent]);
2709
+ React2.useEffect(() => {
2710
+ activeIndexRef.current = activeIndex;
2711
+ }, [activeIndex]);
2712
+ const [isOnlyOneScreen, setIsOnlyOneScreen] = React2.useState(false);
2713
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !isEmptyContent && /* @__PURE__ */ React.createElement(
2714
+ "div",
2715
+ {
2716
+ className: `${FlexLayout_default["flex-split-screen"]}`,
2717
+ ref: layoutRef
2718
+ },
2719
+ /* @__PURE__ */ React.createElement(
2720
+ FlexLayout,
2721
+ {
2722
+ direction,
2723
+ layoutName: `${layoutName}`,
2724
+ panelMovementMode: "bulldozer"
2725
+ },
2726
+ beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, beforeDropTargetComponent.map(
2727
+ ({
2728
+ containerName: cName,
2729
+ component,
2730
+ navigationTitle,
2731
+ dropDocumentOutsideOption,
2732
+ screenKey: screenKey2
2733
+ }, i) => /* @__PURE__ */ React.createElement(
2734
+ FlexLayoutContainer,
2735
+ {
2736
+ containerName: cName,
2737
+ isInitialResizable: true,
2738
+ isResizePanel: true,
2739
+ key: cName
2740
+ },
2741
+ /* @__PURE__ */ React.createElement(
2742
+ FlexLayoutSplitScreenChild,
2743
+ {
2744
+ parentDirection: direction,
2745
+ layoutName: `${layoutName}_before-${depth}`,
2746
+ parentLayoutName: layoutName,
2747
+ containerName: cName,
2748
+ depth: depth + 1,
2749
+ rootRef,
2750
+ screenKey: screenKey2,
2751
+ initialCenterComponents: [
2752
+ {
2753
+ navigationTitle,
2754
+ component,
2755
+ containerName: cName,
2756
+ dropDocumentOutsideOption,
2757
+ screenKey: screenKey2
2758
+ }
2759
+ ],
2760
+ rootName
2761
+ }
2762
+ )
2763
+ )
2764
+ )) : /* @__PURE__ */ React.createElement("div", null),
2765
+ centerDropTargetComponent.length != 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
2766
+ FlexLayoutContainer,
2767
+ {
2768
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2769
+ isInitialResizable: true,
2770
+ isResizePanel: isSplit,
2771
+ key: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName
2772
+ },
2773
+ isSplit ? /* @__PURE__ */ React.createElement("div", { "data-key": screenKey }, /* @__PURE__ */ React.createElement(
2774
+ FlexLayoutSplitScreenChild,
2775
+ {
2776
+ parentDirection: direction,
2777
+ layoutName: `${layoutName}_center-${depth}`,
2778
+ parentLayoutName: layoutName,
2779
+ containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2780
+ depth: depth + 1,
2781
+ rootRef,
2782
+ initialCenterComponents: centerDropTargetComponent.map(
2783
+ ({
2784
+ navigationTitle,
2785
+ component,
2786
+ containerName: cName,
2787
+ dropDocumentOutsideOption,
2788
+ screenKey: centerScreenKey
2789
+ }) => ({
2790
+ navigationTitle,
2791
+ component,
2792
+ containerName: cName,
2793
+ dropDocumentOutsideOption,
2794
+ screenKey: centerScreenKey
2795
+ })
2796
+ ),
2797
+ screenKey,
2798
+ rootName
2799
+ }
2800
+ )) : /* @__PURE__ */ React.createElement(
2801
+ FlexLayoutSplitScreenScrollBox_default,
2802
+ {
2803
+ keyName: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName,
2804
+ isDefaultScrollStyle: true
2805
+ },
2806
+ !isOnlyOneScreen && /* @__PURE__ */ React.createElement(
2807
+ "div",
2808
+ {
2809
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper-sticky"]}`
2810
+ },
2811
+ /* @__PURE__ */ React.createElement(
2812
+ "div",
2813
+ {
2814
+ "data-is_split": isSplit,
2815
+ "data-layout_name": layoutName,
2816
+ "data-parent_layout_name": parentLayoutName,
2817
+ "data-container_name": `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
2818
+ className: `${FlexLayout_default["flex-split-screen-drag-box-title-wrapper"]}`
2819
+ },
2820
+ /* @__PURE__ */ React.createElement(
2821
+ FlexLayoutSplitScreenDragBoxContainer,
2822
+ {
2823
+ key: layoutName,
2824
+ "data-layout_name": layoutName,
2825
+ layoutName
2826
+ },
2827
+ centerDropTargetComponent.map(
2828
+ (item, index) => /* @__PURE__ */ React.createElement(
2829
+ FlexLayoutSplitScreenDragBoxItem,
2830
+ {
2831
+ onClose: (ev) => {
2832
+ if (activeIndexRef.current === index && centerDropTargetComponent.length === 1) {
2833
+ dropMovementEventSubject.next(
2834
+ {
2835
+ state: "remove",
2836
+ targetContainerName: containerName,
2837
+ targetParentLayoutName: parentLayoutName,
2838
+ targetLayoutName: layoutName
2839
+ }
2840
+ );
2841
+ } else {
2842
+ if (centerDropTargetComponent.length === activeIndexRef.current + 1) {
2843
+ setActiveIndex(
2844
+ activeIndexRef.current - 1
2845
+ );
2846
+ }
2847
+ setCenterDropTargetComponent(
2848
+ (prev) => {
2849
+ const result = handleRemove(
2850
+ prev,
2851
+ item.containerName,
2852
+ () => {
2853
+ }
2854
+ );
2855
+ return result;
2856
+ }
2857
+ );
2858
+ }
2859
+ },
2860
+ key: item.navigationTitle + layoutName + item.containerName,
2861
+ isActive: activeIndex === index
2862
+ },
2863
+ /* @__PURE__ */ React.createElement(
2864
+ FlexLayoutSplitScreenDragBox,
2865
+ {
2866
+ onClick: () => {
2867
+ setActiveIndex(
2868
+ index
2869
+ );
2870
+ },
2871
+ containerName: item.containerName,
2872
+ dropDocumentOutsideOption: item.dropDocumentOutsideOption,
2873
+ targetComponent: item.component,
2874
+ navigationTitle: item.navigationTitle,
2875
+ "data-container-name": item.containerName,
2876
+ "data-layout-name": layoutName,
2877
+ "data-parent-layout-name": parentLayoutName,
2878
+ dropEndCallback: ({
2879
+ x,
2880
+ y,
2881
+ containerName: appendContainerName
2882
+ }) => {
2883
+ if (!rootRef.current || !layoutRef.current)
2884
+ return;
2885
+ const isRootOver = isOverDrop(
2886
+ {
2887
+ x,
2888
+ y,
2889
+ element: rootRef.current
2890
+ }
2891
+ );
2892
+ const isLayoutInner = isInnerDrop(
2893
+ {
2894
+ x,
2895
+ y,
2896
+ element: layoutRef.current
2897
+ }
2898
+ );
2899
+ if (!isRootOver && !isLayoutInner || !isRootOver && isLayoutInner && centerDropTargetComponentRef.current.length > 1) {
2900
+ const option = {};
2901
+ if (centerDropTargetComponentRef.current.length > 1) {
2902
+ const {
2903
+ adjacentItem,
2904
+ adjacentIndex
2905
+ } = getAdjacentItem(
2906
+ centerDropTargetComponentRef.current,
2907
+ activeIndexRef.current
2908
+ );
2909
+ if (adjacentItem && activeIndexRef.current === index) {
2910
+ Object.assign(
2911
+ option,
2912
+ {
2913
+ x,
2914
+ y,
2915
+ targetComponent: adjacentItem.component,
2916
+ nextContainerName: adjacentItem.containerName,
2917
+ orderName: "center",
2918
+ dropTargetComponentEvent: {
2919
+ navigationTitle: adjacentItem.navigationTitle,
2920
+ dropDocumentOutsideOption: adjacentItem.dropDocumentOutsideOption,
2921
+ direction,
2922
+ screenKey
2923
+ }
2924
+ }
2925
+ );
2926
+ }
2927
+ }
2928
+ if (index === 0) {
2929
+ dropMovementEventSubject.next(
2930
+ {
2931
+ state: "remove",
2932
+ targetContainerName: item.containerName,
2933
+ targetParentLayoutName: parentLayoutName,
2934
+ targetLayoutName: layoutName,
2935
+ ...option
2936
+ }
2937
+ );
2938
+ } else {
2939
+ dropMovementEventSubject.next(
2940
+ {
2941
+ state: "remove",
2942
+ targetContainerName: item.containerName,
2943
+ targetParentLayoutName: "",
2944
+ targetLayoutName: layoutName,
2945
+ ...option
2946
+ }
2947
+ );
2948
+ }
2949
+ }
2950
+ }
2951
+ },
2952
+ item.navigationTitle
2953
+ )
2954
+ )
2955
+ )
2956
+ ),
2957
+ /* @__PURE__ */ React.createElement(FlexLayoutSplitScreenDragBoxTitleMore, null)
2958
+ )
2959
+ ),
2960
+ (() => {
2961
+ const target = centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0];
2962
+ return target.component;
2963
+ })()
2964
+ )
2965
+ )) : /* @__PURE__ */ React.createElement("div", null),
2966
+ afterDropTargetComponent.length != 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, afterDropTargetComponent.map(
2967
+ ({
2968
+ containerName: cName,
2969
+ component,
2970
+ navigationTitle,
2971
+ dropDocumentOutsideOption,
2972
+ screenKey: screenKey2
2973
+ }, i) => /* @__PURE__ */ React.createElement(
2974
+ FlexLayoutContainer,
2975
+ {
2976
+ containerName: cName,
2977
+ isInitialResizable: true,
2978
+ isResizePanel: i !== afterDropTargetComponent.length - 1,
2979
+ key: cName
2980
+ },
2981
+ /* @__PURE__ */ React.createElement(
2982
+ FlexLayoutSplitScreenChild,
2983
+ {
2984
+ parentDirection: direction,
2985
+ layoutName: `${layoutName}_after-${depth}`,
2986
+ parentLayoutName: layoutName,
2987
+ containerName: cName,
2988
+ depth: depth + 1,
2989
+ rootRef,
2990
+ screenKey: screenKey2,
2991
+ initialCenterComponents: [
2992
+ {
2993
+ navigationTitle,
2994
+ component,
2995
+ containerName: cName,
2996
+ dropDocumentOutsideOption,
2997
+ screenKey: screenKey2
2998
+ }
2999
+ ],
3000
+ rootName
3001
+ }
3002
+ )
3003
+ )
3004
+ )) : /* @__PURE__ */ React.createElement("div", null)
3005
+ ),
3006
+ boundaryContainerSize && /* @__PURE__ */ React.createElement(
3007
+ "div",
3008
+ {
3009
+ className: `${FlexLayout_default["flex-split-screen-boundary-container"]}`,
3010
+ style: { ...boundaryContainerSize }
3011
+ },
3012
+ "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
3013
+ )
3014
+ ));
3015
+ }
3016
+ function clamp(n, min, max) {
3017
+ return Math.max(min, Math.min(max, n));
3018
+ }
3019
+ function pickDefaultScrollRoot() {
3020
+ if (typeof document === "undefined") return null;
3021
+ let el = document.body;
3022
+ while (el && el !== document.documentElement && el !== document.body) {
3023
+ const style = getComputedStyle(el);
3024
+ const oy = style.overflowY;
3025
+ const ox = style.overflowX;
3026
+ const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
3027
+ if (scrollable) return el;
3028
+ el = el.parentElement;
3029
+ }
3030
+ return null;
3031
+ }
3032
+ function isVerticalScroll(root) {
3033
+ if (typeof window == "undefined") return true;
3034
+ if (!root) {
3035
+ return document.documentElement.scrollHeight > window.innerHeight + 1;
3036
+ }
3037
+ const el = root;
3038
+ return el.scrollHeight > el.clientHeight + 1;
3039
+ }
3040
+ var dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
3041
+ function quantizeToDevicePixel(n) {
3042
+ return Math.round(n * dpr) / dpr;
3043
+ }
3044
+ var FlexLayoutStickyBox = ({
3045
+ edge = "auto",
3046
+ offset = 16,
3047
+ scrollRoot = null,
3048
+ debug = false,
3049
+ children,
3050
+ style,
3051
+ className,
3052
+ onTranslateChange = () => {
3053
+ },
3054
+ ...rest
3055
+ }) => {
3056
+ const offsetRef = React2.useRef(offset);
3057
+ const rootRef = React2.useRef(null);
3058
+ const contentRef = React2.useRef(null);
3059
+ const mutatingRef = React2.useRef(false);
3060
+ const lastOffsetRef = React2.useRef(0);
3061
+ const [resolvedEdge, setResolvedEdge] = React2.useState("top");
3062
+ const rafId = React2.useRef(null);
3063
+ const [contentDynamicStyle, setContentDynamicStyle] = React2.useState({});
3064
+ React2.useEffect(() => {
3065
+ setContentDynamicStyle({
3066
+ willChange: "transform",
3067
+ transition: "transform 50ms linear"
3068
+ });
3069
+ }, []);
3070
+ React2.useEffect(() => {
3071
+ offsetRef.current = offset;
3072
+ scheduleUpdate();
3073
+ }, [offset]);
3074
+ const [ioRoot, setIoRoot] = React2.useState(null);
3075
+ React2.useEffect(() => {
3076
+ const root = scrollRoot ?? pickDefaultScrollRoot();
3077
+ setResolvedEdge(
3078
+ edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
3079
+ );
3080
+ setIoRoot(root);
3081
+ }, [edge, scrollRoot]);
3082
+ React2.useEffect(() => {
3083
+ if (edge !== "auto") {
3084
+ setResolvedEdge(edge);
3085
+ return;
3086
+ }
3087
+ const vertical = isVerticalScroll(ioRoot);
3088
+ setResolvedEdge(vertical ? "top" : "left");
3089
+ }, [edge, ioRoot]);
3090
+ React2.useEffect(() => {
3091
+ }, []);
3092
+ const scheduleUpdate = () => {
3093
+ if (rafId.current != null) return;
3094
+ rafId.current = requestAnimationFrame(() => {
3095
+ rafId.current = null;
3096
+ doUpdate();
3097
+ });
3098
+ };
3099
+ const doUpdate = () => {
3100
+ if (mutatingRef.current) return;
3101
+ mutatingRef.current = true;
3102
+ const rootEl = rootRef.current;
3103
+ const contentEl = contentRef.current;
3104
+ if (!rootEl || !contentEl) {
3105
+ mutatingRef.current = false;
3106
+ return;
3107
+ }
3108
+ const parentEl = rootEl.parentElement;
3109
+ if (!parentEl) {
3110
+ mutatingRef.current = false;
3111
+ return;
3112
+ }
3113
+ const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
3114
+ const parentRect = parentEl.getBoundingClientRect();
3115
+ const contentRect = contentEl.getBoundingClientRect();
3116
+ let newOffset = 0;
3117
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
3118
+ const maxTranslate = Math.max(
3119
+ 0,
3120
+ parentRect.height - contentRect.height
3121
+ );
3122
+ let desiredTop = 0;
3123
+ if (resolvedEdge === "top") {
3124
+ desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
3125
+ } else {
3126
+ const targetBottomFromParentTop = Math.min(
3127
+ parentRect.bottom,
3128
+ rootBounds.bottom - offsetRef.current
3129
+ ) - parentRect.top;
3130
+ desiredTop = targetBottomFromParentTop - contentRect.height;
3131
+ }
3132
+ newOffset = clamp(desiredTop, 0, maxTranslate);
3133
+ } else {
3134
+ const maxTranslate = Math.max(
3135
+ 0,
3136
+ parentRect.width - contentRect.width
3137
+ );
3138
+ let desiredLeft = 0;
3139
+ if (resolvedEdge === "left") {
3140
+ desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
3141
+ } else {
3142
+ const targetRightFromParentLeft = Math.min(
3143
+ parentRect.right,
3144
+ rootBounds.right - offsetRef.current
3145
+ ) - parentRect.left;
3146
+ desiredLeft = targetRightFromParentLeft - contentRect.width;
3147
+ }
3148
+ newOffset = clamp(desiredLeft, 0, maxTranslate);
3149
+ }
3150
+ const nextOffset = quantizeToDevicePixel(newOffset);
3151
+ if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
3152
+ if (resolvedEdge === "top" || resolvedEdge === "bottom") {
3153
+ contentEl.style.transform = `translateY(${nextOffset}px)`;
3154
+ } else {
3155
+ contentEl.style.transform = `translateX(${nextOffset}px)`;
3156
+ }
3157
+ lastOffsetRef.current = nextOffset;
3158
+ onTranslateChange(nextOffset, rootRef, contentRef);
3159
+ }
3160
+ if (debug) {
3161
+ rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
3162
+ contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
3163
+ }
3164
+ queueMicrotask(() => {
3165
+ mutatingRef.current = false;
3166
+ });
3167
+ };
3168
+ React2.useEffect(() => {
3169
+ if (typeof window == "undefined") return;
3170
+ const rootEl = rootRef.current;
3171
+ if (!rootEl) return;
3172
+ const parentEl = rootEl.parentElement;
3173
+ console.log(parentEl);
3174
+ if (!parentEl) return;
3175
+ const targets = [parentEl];
3176
+ const observerCallback = () => {
3177
+ if (!mutatingRef.current) scheduleUpdate();
3178
+ };
3179
+ const io = new IntersectionObserver(observerCallback, {
3180
+ root: ioRoot instanceof Element ? ioRoot : null,
3181
+ threshold: 0,
3182
+ rootMargin: "1px"
3183
+ });
3184
+ const ro = new ResizeObserver(observerCallback);
3185
+ targets.forEach((t) => io.observe(t));
3186
+ ro.observe(parentEl);
3187
+ if (contentRef.current) {
3188
+ ro.observe(contentRef.current);
3189
+ }
3190
+ const scrollTarget = ioRoot || window;
3191
+ scrollTarget.addEventListener("scroll", scheduleUpdate, {
3192
+ passive: true
3193
+ });
3194
+ window.addEventListener("resize", scheduleUpdate);
3195
+ scheduleUpdate();
3196
+ return () => {
3197
+ io.disconnect();
3198
+ ro.disconnect();
3199
+ scrollTarget.removeEventListener("scroll", scheduleUpdate);
3200
+ window.removeEventListener("resize", scheduleUpdate);
3201
+ if (rafId.current != null) {
3202
+ cancelAnimationFrame(rafId.current);
3203
+ rafId.current = null;
3204
+ }
3205
+ };
3206
+ }, [ioRoot, resolvedEdge, offset, debug]);
3207
+ return /* @__PURE__ */ React2__default.default.createElement(
3208
+ "div",
3209
+ {
3210
+ ref: rootRef,
3211
+ className,
3212
+ style: {
3213
+ display: "block",
3214
+ minWidth: 0,
3215
+ minHeight: 0,
3216
+ height: "100%",
3217
+ // 부모 높이를 채우도록 설정
3218
+ ...style
3219
+ },
3220
+ ...rest
3221
+ },
3222
+ /* @__PURE__ */ React2__default.default.createElement(
3223
+ "div",
3224
+ {
3225
+ ref: contentRef,
3226
+ style: contentDynamicStyle
3227
+ },
3228
+ children
3229
+ )
3230
+ );
3231
+ };
3232
+ var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
3233
+ var useListPagingForSentinel = ({
3234
+ //initPageNumber,
3235
+ //initPageSize,
3236
+ onReachTerminal
3237
+ }) => {
3238
+ const [firstChildNode, setFirstChildNode] = React2.useState(null);
3239
+ const [lastChildNode, setLastChildNode] = React2.useState(null);
3240
+ const observerRef = React2.useRef(null);
3241
+ const firstChildRef = React2.useCallback((node) => {
3242
+ setFirstChildNode(node);
3243
+ }, []);
3244
+ const lastChildRef = React2.useCallback((node) => {
3245
+ setLastChildNode(node);
3246
+ }, []);
3247
+ React2.useEffect(() => {
3248
+ if (firstChildNode && observerRef.current)
3249
+ observerRef.current.unobserve(firstChildNode);
3250
+ if (lastChildNode && observerRef.current)
3251
+ observerRef.current.unobserve(lastChildNode);
3252
+ const handleIntersect = (entries, observer2) => {
3253
+ entries.forEach((entry) => {
3254
+ if (entry.isIntersecting) {
3255
+ if (entry.target === firstChildNode) {
3256
+ if (onReachTerminal)
3257
+ onReachTerminal({
3258
+ isFirst: true,
3259
+ isLast: false,
3260
+ observer: observer2
3261
+ });
3262
+ }
3263
+ if (entry.target === lastChildNode) {
3264
+ if (onReachTerminal)
3265
+ onReachTerminal({
3266
+ isFirst: false,
3267
+ isLast: true,
3268
+ observer: observer2
3269
+ });
3270
+ }
3271
+ }
3272
+ });
3273
+ };
3274
+ const observer = new IntersectionObserver(handleIntersect, {
3275
+ threshold: 0.1
3276
+ });
3277
+ observerRef.current = observer;
3278
+ if (firstChildNode) observer.observe(firstChildNode);
3279
+ if (lastChildNode) observer.observe(lastChildNode);
3280
+ return () => {
3281
+ if (observerRef.current) {
3282
+ observerRef.current.disconnect();
3283
+ }
3284
+ };
3285
+ }, [firstChildNode, lastChildNode]);
3286
+ return {
3287
+ firstChildRef,
3288
+ lastChildRef
3289
+ };
3290
+ };
3291
+ var usePaginationViewNumber = ({
3292
+ initPageNumber
3293
+ }) => {
3294
+ const [showCurrentPageNumber, setShowCurrentPageNumber] = React2.useState(initPageNumber);
3295
+ const observerRef = React2.useRef(null);
3296
+ const showCurrentPageObserveTarget = React2.useCallback(
3297
+ (node) => {
3298
+ if (!node) return;
3299
+ if (!observerRef.current) {
3300
+ observerRef.current = new IntersectionObserver(
3301
+ (entries) => {
3302
+ entries.forEach((entry) => {
3303
+ if (entry.isIntersecting) {
3304
+ const pageIndexAttr = entry.target.getAttribute(
3305
+ "data-page-index"
3306
+ );
3307
+ if (!pageIndexAttr) return;
3308
+ const pageIndex = parseInt(pageIndexAttr, 10);
3309
+ setShowCurrentPageNumber(pageIndex);
3310
+ }
3311
+ });
3312
+ },
3313
+ {
3314
+ threshold: 0.1
3315
+ // 예: 10% 이상 보여야 intersect로 판단
3316
+ }
3317
+ );
3318
+ }
3319
+ observerRef.current.observe(node);
3320
+ },
3321
+ []
3322
+ );
3323
+ React2.useEffect(() => {
3324
+ const currentObserver = observerRef.current;
3325
+ return () => {
3326
+ if (currentObserver) {
3327
+ currentObserver.disconnect();
3328
+ }
3329
+ };
3330
+ }, []);
3331
+ return {
3332
+ showCurrentPageNumber,
3333
+ showCurrentPageObserveTarget
3334
+ };
3335
+ };
3336
+ var usePagingHandler = ({
3337
+ lastCallPageNumber,
3338
+ dataListRef
3339
+ }) => {
3340
+ const jumpingPageNumberRef = React2.useRef(lastCallPageNumber);
3341
+ React2.useEffect(() => {
3342
+ if (jumpingPageNumberRef.current) {
3343
+ setTimeout(() => {
3344
+ jumpingPageNumberRef.current = null;
3345
+ }, 1e3);
3346
+ }
3347
+ }, [jumpingPageNumberRef]);
3348
+ const paginationScrollIntoViewTarget = React2.useRef({});
3349
+ const pageNumberRef = React2.useRef(lastCallPageNumber);
3350
+ const setPaginationRef = React2.useCallback(
3351
+ (i) => (node) => {
3352
+ if (!node) return;
3353
+ paginationScrollIntoViewTarget.current[i] = node;
3354
+ if (jumpingPageNumberRef.current !== null && i === jumpingPageNumberRef.current) {
3355
+ node.scrollIntoView({
3356
+ behavior: "instant",
3357
+ // 필요한 경우 'smooth' 등으로 수정 가능
3358
+ block: "start"
3359
+ });
3360
+ jumpingPageNumberRef.current = null;
3361
+ }
3362
+ },
3363
+ []
3364
+ );
3365
+ const handleReachTerminal = ({ isFirst, isLast, observer }, dataCallFetch) => {
3366
+ if (dataListRef.current.length === 0) return;
3367
+ if (jumpingPageNumberRef.current != null) return;
3368
+ if (!isFirst && !isLast) return;
3369
+ const callPageNumber = isFirst ? Math.max(pageNumberRef.current - 1, 0) : pageNumberRef.current + 1;
3370
+ if (dataListRef.current[callPageNumber] != null && (dataListRef.current[callPageNumber]?.length || 0) > 0)
3371
+ return;
3372
+ jumpingPageNumberRef.current = callPageNumber;
3373
+ setTimeout(() => {
3374
+ jumpingPageNumberRef.current = null;
3375
+ }, 1e3);
3376
+ dataCallFetch(callPageNumber);
3377
+ };
3378
+ const handleClickPageChange = (page, dataCallFetch) => {
3379
+ const pageData = dataListRef.current[page];
3380
+ if (pageData != null && Array.isArray(pageData) && pageData.length > 0) {
3381
+ paginationScrollIntoViewTarget.current[page]?.scrollIntoView({
3382
+ behavior: "smooth",
3383
+ block: "start"
3384
+ });
3385
+ return;
3386
+ }
3387
+ jumpingPageNumberRef.current = page;
3388
+ setTimeout(() => {
3389
+ jumpingPageNumberRef.current = null;
3390
+ }, 1e3);
3391
+ dataCallFetch(page);
3392
+ };
3393
+ return {
3394
+ jumpingPageNumberRef,
3395
+ paginationScrollIntoViewTarget,
3396
+ pageNumberRef,
3397
+ setPaginationRef,
3398
+ handleReachTerminal,
3399
+ handleClickPageChange
3400
+ };
3401
+ };
3402
+
3403
+ exports.ContainerOpenCloseProvider = ContainerOpenCloseProvider;
3404
+ exports.FlexLayout = FlexLayout;
3405
+ exports.FlexLayoutContainer = FlexLayoutContainer;
3406
+ exports.FlexLayoutResizePanel = FlexLayoutResizePanel;
3407
+ exports.FlexLayoutSplitScreen = FlexLayoutSplitScreen;
3408
+ exports.FlexLayoutSplitScreenDragBox = FlexLayoutSplitScreenDragBox;
3409
+ exports.FlexLayoutSplitScreenScrollBox = FlexLayoutSplitScreenScrollBox_default;
3410
+ exports.FlexLayoutStickyBox = FlexLayoutStickyBox_default;
3411
+ exports.allSplitScreenCount = allSplitScreenCount;
3412
+ exports.closeFlex = closeFlex;
3413
+ exports.containerOpenCloseSubjectMap = containerOpenCloseSubjectMap;
3414
+ exports.containerSpreadSubjectMap = containerSpreadSubjectMap;
3415
+ exports.dragState = dragState;
3416
+ exports.dropMovementEventSubject = dropMovementEventSubject;
3417
+ exports.findNotCloseFlexContent = findNotCloseFlexContent;
3418
+ exports.flexContainerStore = flexContainerStore;
3419
+ exports.flexResizePanelStore = flexResizePanelStore;
3420
+ exports.folderEventSubject = folderEventSubject;
3421
+ exports.getClientXy = getClientXy;
3422
+ exports.getContainerRef = getContainerRef;
3423
+ exports.getCurrentSplitScreenComponents = getCurrentSplitScreenComponents;
3424
+ exports.getGrow = getGrow;
3425
+ exports.getLayoutInfos = getLayoutInfos;
3426
+ exports.getResizePanelRef = getResizePanelRef;
3427
+ exports.getScrollPosition = getScrollPosition;
3428
+ exports.getSplitScreen = getSplitScreen;
3429
+ exports.isDocumentOut = isDocumentOut;
3430
+ exports.isOverMove = isOverMove;
3431
+ exports.layoutSplitScreenStore = layoutSplitScreenStore;
3432
+ exports.mathGrow = mathGrow;
3433
+ exports.mathWeight = mathWeight;
3434
+ exports.openFlex = openFlex;
3435
+ exports.remain = remain;
3436
+ exports.removeScrollPosition = removeScrollPosition;
3437
+ exports.removeSplitScreenChild = removeSplitScreenChild;
3438
+ exports.resetRootSplitScreen = resetRootSplitScreen;
3439
+ exports.resize = resize;
3440
+ exports.scrollPositions = scrollPositions;
3441
+ exports.setContainerRef = setContainerRef;
3442
+ exports.setFolderEvent = setFolderEvent;
3443
+ exports.setResizePanelRef = setResizePanelRef;
3444
+ exports.setScrollPosition = setScrollPosition;
3445
+ exports.setSplitScreen = setSplitScreen;
3446
+ exports.useContainerSize = useContainerSize;
3447
+ exports.useContainers = useContainers;
3448
+ exports.useDecompositionLayout = useDecompositionLayout;
3449
+ exports.useDoubleClick = useDoubleClick;
3450
+ exports.useDragCapture = useDragCapture;
3451
+ exports.useDragEvents = useDragEvents;
3452
+ exports.useFolderEvent = useFolderEvent;
3453
+ exports.useLayoutName = useLayoutName;
3454
+ exports.useListPagingForSentinel = useListPagingForSentinel;
3455
+ exports.usePaginationViewNumber = usePaginationViewNumber;
3456
+ exports.usePagingHandler = usePagingHandler;
3
3457
  //# sourceMappingURL=index.cjs.map
4
3458
  //# sourceMappingURL=index.cjs.map