@byeolnaerim/flex-layout 0.0.6 → 0.0.8

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