@byeolnaerim/flex-layout 0.0.6 → 0.0.7

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