@byeolnaerim/flex-layout 0.0.9 → 0.0.10
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.
- package/dist/flex-layout/components/FlexLayout.cjs +1 -110
- package/dist/flex-layout/components/FlexLayout.js +1 -85
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -262
- package/dist/flex-layout/components/FlexLayoutContainer.js +1 -232
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -68
- package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -44
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -246
- package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -216
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1252
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1236
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -532
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -509
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -55
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -63
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -33
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -53
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -23
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -133
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -107
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -245
- package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -229
- package/dist/flex-layout/components/index.cjs +1 -57
- package/dist/flex-layout/components/index.js +1 -17
- package/dist/flex-layout/hooks/index.cjs +1 -25
- package/dist/flex-layout/hooks/index.js +1 -3
- package/dist/flex-layout/hooks/useDrag.cjs +1 -289
- package/dist/flex-layout/hooks/useDrag.d.ts +15 -0
- package/dist/flex-layout/hooks/useDrag.js +1 -258
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -139
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -118
- package/dist/flex-layout/hooks/useListPaging.cjs +1 -212
- package/dist/flex-layout/hooks/useListPaging.js +1 -191
- package/dist/flex-layout/hooks/useSizes.cjs +1 -126
- package/dist/flex-layout/hooks/useSizes.js +1 -101
- package/dist/flex-layout/index.cjs +1 -31
- package/dist/flex-layout/index.js +1 -6
- package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -49
- package/dist/flex-layout/providers/FlexLayoutContext.js +1 -24
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -276
- package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -263
- package/dist/flex-layout/providers/index.cjs +1 -23
- package/dist/flex-layout/providers/index.js +1 -2
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -257
- package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -206
- package/dist/flex-layout/store/index.cjs +1 -23
- package/dist/flex-layout/store/index.js +1 -2
- package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
- package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -17
- package/dist/flex-layout/types/FlexDirectionTypes.js +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -17
- package/dist/flex-layout/types/FlexLayoutTypes.js +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -245
- package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -211
- package/dist/flex-layout/utils/index.cjs +1 -23
- package/dist/flex-layout/utils/index.js +1 -2
- package/dist/index.cjs +1 -23
- package/dist/index.js +1 -2
- package/dist/types/css.d.cjs +0 -1
- package/dist/types/css.d.js +0 -1
- package/package.json +116 -113
- package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayout.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutIFramePane.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
- package/dist/flex-layout/components/index.cjs.map +0 -1
- package/dist/flex-layout/components/index.js.map +0 -1
- package/dist/flex-layout/hooks/index.cjs.map +0 -1
- package/dist/flex-layout/hooks/index.js.map +0 -1
- package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
- package/dist/flex-layout/hooks/useDrag.js.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
- package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
- package/dist/flex-layout/hooks/useSizes.js.map +0 -1
- package/dist/flex-layout/index.cjs.map +0 -1
- package/dist/flex-layout/index.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
- package/dist/flex-layout/providers/index.cjs.map +0 -1
- package/dist/flex-layout/providers/index.js.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
- package/dist/flex-layout/store/index.cjs.map +0 -1
- package/dist/flex-layout/store/index.js.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
- package/dist/flex-layout/utils/index.cjs.map +0 -1
- package/dist/flex-layout/utils/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/types/css.d.cjs.map +0 -1
- package/dist/types/css.d.js.map +0 -1
|
@@ -1,1236 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
cloneElement,
|
|
5
|
-
useEffect,
|
|
6
|
-
useRef,
|
|
7
|
-
useState
|
|
8
|
-
} from "react";
|
|
9
|
-
import {
|
|
10
|
-
dropMovementEventSubject
|
|
11
|
-
} from "../hooks/useDrag";
|
|
12
|
-
import { useFlexLayoutSplitScreen } from "../hooks/useFlexLayoutSplitScreen";
|
|
13
|
-
import {
|
|
14
|
-
getCurrentSplitScreenComponents,
|
|
15
|
-
getSplitScreen,
|
|
16
|
-
removeRootSplitScreen,
|
|
17
|
-
removeSplitScreenChild,
|
|
18
|
-
resetRootSplitScreen,
|
|
19
|
-
setSplitScreen
|
|
20
|
-
} from "../store/FlexLayoutContainerStore";
|
|
21
|
-
import styles from "../styles/FlexLayout.module.css";
|
|
22
|
-
import FlexLayout from "./FlexLayout";
|
|
23
|
-
import FlexLayoutContainer from "./FlexLayoutContainer";
|
|
24
|
-
import FlexLayoutSplitScreenDragBox from "./FlexLayoutSplitScreenDragBox";
|
|
25
|
-
import equal from "fast-deep-equal";
|
|
26
|
-
import { distinctUntilChanged, take } from "rxjs";
|
|
27
|
-
import FlexLayoutSplitScreenDragBoxContainer from "./FlexLayoutSplitScreenDragBoxContainer";
|
|
28
|
-
import FlexLayoutSplitScreenDragBoxItem from "./FlexLayoutSplitScreenDragBoxItem";
|
|
29
|
-
import FlexLayoutSplitScreenDragBoxTitleMore from "./FlexLayoutSplitScreenDragBoxTitleMore";
|
|
30
|
-
import FlexLayoutSplitScreenScrollBox from "./FlexLayoutSplitScreenScrollBox";
|
|
31
|
-
function isOverDrop({
|
|
32
|
-
x,
|
|
33
|
-
y,
|
|
34
|
-
element
|
|
35
|
-
}) {
|
|
36
|
-
const {
|
|
37
|
-
x: elementX,
|
|
38
|
-
y: elementY,
|
|
39
|
-
right: elementRight,
|
|
40
|
-
bottom: elementBottom
|
|
41
|
-
} = element.getBoundingClientRect();
|
|
42
|
-
const isElementOver = x < elementX || x > elementRight || y < elementY || y > elementBottom;
|
|
43
|
-
return isElementOver;
|
|
44
|
-
}
|
|
45
|
-
function isInnerDrop({
|
|
46
|
-
x,
|
|
47
|
-
y,
|
|
48
|
-
element
|
|
49
|
-
}) {
|
|
50
|
-
const {
|
|
51
|
-
x: elementX,
|
|
52
|
-
y: elementY,
|
|
53
|
-
right: elementRight,
|
|
54
|
-
bottom: elementBottom
|
|
55
|
-
} = element.getBoundingClientRect();
|
|
56
|
-
const isElementInner = x >= elementX && x <= elementRight && y >= elementY && y <= elementBottom;
|
|
57
|
-
return isElementInner;
|
|
58
|
-
}
|
|
59
|
-
const handleUpdateDropTargetComponents = ({
|
|
60
|
-
orderName,
|
|
61
|
-
parentOrderName,
|
|
62
|
-
containerName,
|
|
63
|
-
parentLayoutName,
|
|
64
|
-
layoutName,
|
|
65
|
-
dropComponent,
|
|
66
|
-
navigationTitle,
|
|
67
|
-
nextContainerName,
|
|
68
|
-
isUsePrefix = true,
|
|
69
|
-
beforeDropTargetComponent,
|
|
70
|
-
afterDropTargetComponent,
|
|
71
|
-
centerDropTargetComponent,
|
|
72
|
-
dropDocumentOutsideOption,
|
|
73
|
-
screenKey = Array.from(
|
|
74
|
-
window.crypto.getRandomValues(new Uint32Array(16)),
|
|
75
|
-
(e) => e.toString(32).padStart(2, "0")
|
|
76
|
-
).join("")
|
|
77
|
-
}) => {
|
|
78
|
-
const nextContainerNameOrderName = parentOrderName ? parentOrderName : orderName;
|
|
79
|
-
let listMap;
|
|
80
|
-
let list;
|
|
81
|
-
let key;
|
|
82
|
-
if (nextContainerNameOrderName === orderName || nextContainerNameOrderName === "center") {
|
|
83
|
-
listMap = orderName === "before" ? { beforeDropTargetComponent } : orderName === "after" ? { afterDropTargetComponent } : {
|
|
84
|
-
centerDropTargetComponent: centerDropTargetComponent.filter(
|
|
85
|
-
(e) => !e.containerName.split("_").at(0).startsWith(
|
|
86
|
-
containerName.split("_").at(0)
|
|
87
|
-
)
|
|
88
|
-
)
|
|
89
|
-
};
|
|
90
|
-
} else {
|
|
91
|
-
listMap = nextContainerNameOrderName === "before" ? { beforeDropTargetComponent } : { afterDropTargetComponent };
|
|
92
|
-
}
|
|
93
|
-
const entries = Object.entries(listMap)[0];
|
|
94
|
-
key = entries[0];
|
|
95
|
-
list = entries[1];
|
|
96
|
-
const newComponent = {
|
|
97
|
-
containerName: `${containerName + "_" + layoutName}${isUsePrefix ? "_" + orderName + "-" + list.length : ""}`,
|
|
98
|
-
component: cloneElement(
|
|
99
|
-
dropComponent,
|
|
100
|
-
{ key: screenKey, screenKey }
|
|
101
|
-
),
|
|
102
|
-
navigationTitle,
|
|
103
|
-
dropDocumentOutsideOption,
|
|
104
|
-
screenKey: screenKey || Array.from(
|
|
105
|
-
window.crypto.getRandomValues(new Uint32Array(16)),
|
|
106
|
-
(e) => e.toString(32).padStart(2, "0")
|
|
107
|
-
).join("")
|
|
108
|
-
};
|
|
109
|
-
let allComponents;
|
|
110
|
-
if (nextContainerName) {
|
|
111
|
-
const index = list.findIndex(
|
|
112
|
-
(item) => item.containerName === nextContainerName
|
|
113
|
-
);
|
|
114
|
-
if (index !== -1) {
|
|
115
|
-
if (nextContainerNameOrderName === orderName) {
|
|
116
|
-
if (orderName === "before") {
|
|
117
|
-
allComponents = [
|
|
118
|
-
...list.slice(0, index),
|
|
119
|
-
newComponent,
|
|
120
|
-
...list.slice(index)
|
|
121
|
-
];
|
|
122
|
-
} else {
|
|
123
|
-
allComponents = [
|
|
124
|
-
...list.slice(0, index + 1),
|
|
125
|
-
newComponent,
|
|
126
|
-
...list.slice(index + 1)
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
if (nextContainerNameOrderName === "after" && orderName === "before") {
|
|
131
|
-
allComponents = [
|
|
132
|
-
...list.slice(0, index),
|
|
133
|
-
newComponent,
|
|
134
|
-
...list.slice(index)
|
|
135
|
-
];
|
|
136
|
-
} else if (nextContainerNameOrderName === "before" && orderName === "after") {
|
|
137
|
-
allComponents = [
|
|
138
|
-
...list.slice(0, index + 1),
|
|
139
|
-
newComponent,
|
|
140
|
-
...list.slice(index + 1)
|
|
141
|
-
];
|
|
142
|
-
} else {
|
|
143
|
-
if (orderName === "before") {
|
|
144
|
-
allComponents = [
|
|
145
|
-
...list.slice(0, index),
|
|
146
|
-
newComponent,
|
|
147
|
-
...list.slice(index)
|
|
148
|
-
];
|
|
149
|
-
} else {
|
|
150
|
-
allComponents = [
|
|
151
|
-
...list.slice(0, index + 1),
|
|
152
|
-
newComponent,
|
|
153
|
-
...list.slice(index + 1)
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
if (nextContainerNameOrderName === "center" && orderName === "after") {
|
|
160
|
-
allComponents = [newComponent, ...list];
|
|
161
|
-
} else if (nextContainerNameOrderName === "center" && orderName === "before") {
|
|
162
|
-
allComponents = [...list, newComponent];
|
|
163
|
-
} else {
|
|
164
|
-
allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
allComponents = orderName === "before" ? [newComponent, ...list] : [...list, newComponent];
|
|
169
|
-
}
|
|
170
|
-
const seen = /* @__PURE__ */ new Set();
|
|
171
|
-
const result = allComponents.filter((item) => {
|
|
172
|
-
if (seen.has(item.containerName)) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
seen.add(item.containerName);
|
|
176
|
-
return true;
|
|
177
|
-
});
|
|
178
|
-
dropMovementEventSubject.next({
|
|
179
|
-
state: "append",
|
|
180
|
-
targetParentLayoutName: parentLayoutName,
|
|
181
|
-
targetLayoutName: layoutName,
|
|
182
|
-
targetContainerName: containerName,
|
|
183
|
-
orderName
|
|
184
|
-
});
|
|
185
|
-
return { [key]: result };
|
|
186
|
-
};
|
|
187
|
-
const handleRemove = (list, targetContainerName, orderNameSetter) => {
|
|
188
|
-
const result = list.filter((e) => e.containerName !== targetContainerName);
|
|
189
|
-
if (result.length != list.length)
|
|
190
|
-
orderNameSetter(list.length - result.length);
|
|
191
|
-
return result;
|
|
192
|
-
};
|
|
193
|
-
function getAdjacentItem(items, currentIndex) {
|
|
194
|
-
if (currentIndex + 1 < items.length) {
|
|
195
|
-
return {
|
|
196
|
-
adjacentItem: items[currentIndex + 1],
|
|
197
|
-
adjacentIndex: currentIndex + 1
|
|
198
|
-
};
|
|
199
|
-
} else if (currentIndex - 1 >= 0) {
|
|
200
|
-
return {
|
|
201
|
-
adjacentItem: items[currentIndex - 1],
|
|
202
|
-
adjacentIndex: currentIndex - 1
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return { adjacentItem: null, adjacentIndex: currentIndex };
|
|
206
|
-
}
|
|
207
|
-
const getSelfOrderName = (containerName) => {
|
|
208
|
-
const result = containerName.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);
|
|
209
|
-
if (["before", "center", "after"].some((e) => e === result)) {
|
|
210
|
-
return result;
|
|
211
|
-
} else {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
function FlexLayoutSplitScreen({
|
|
216
|
-
children,
|
|
217
|
-
containerName,
|
|
218
|
-
layoutName,
|
|
219
|
-
navigationTitle,
|
|
220
|
-
dropDocumentOutsideOption,
|
|
221
|
-
screenKey
|
|
222
|
-
}) {
|
|
223
|
-
const {
|
|
224
|
-
direction,
|
|
225
|
-
isSplit,
|
|
226
|
-
boundaryContainerSize,
|
|
227
|
-
afterDropTargetComponent,
|
|
228
|
-
beforeDropTargetComponent,
|
|
229
|
-
centerDropTargetComponent,
|
|
230
|
-
setAfterDropTargetComponent,
|
|
231
|
-
setBeforeDropTargetComponent,
|
|
232
|
-
setCenterDropTargetComponent,
|
|
233
|
-
layoutRef,
|
|
234
|
-
setIsSplit,
|
|
235
|
-
setDirection
|
|
236
|
-
} = useFlexLayoutSplitScreen({
|
|
237
|
-
isSplitInitial: false,
|
|
238
|
-
directionInitial: "row",
|
|
239
|
-
selfContainerName: containerName,
|
|
240
|
-
parentLayoutName: "",
|
|
241
|
-
layoutName
|
|
242
|
-
});
|
|
243
|
-
useEffect(() => {
|
|
244
|
-
resetRootSplitScreen(layoutName);
|
|
245
|
-
const subscribe = getSplitScreen(layoutName, layoutName).subscribe((layoutInfo) => {
|
|
246
|
-
if (layoutInfo) {
|
|
247
|
-
setBeforeDropTargetComponent([
|
|
248
|
-
...layoutInfo.beforeDropTargetComponent
|
|
249
|
-
]);
|
|
250
|
-
setAfterDropTargetComponent([
|
|
251
|
-
...layoutInfo.afterDropTargetComponent
|
|
252
|
-
]);
|
|
253
|
-
setCenterDropTargetComponent([
|
|
254
|
-
...layoutInfo.centerDropTargetComponent
|
|
255
|
-
]);
|
|
256
|
-
setDirection(layoutInfo.direction);
|
|
257
|
-
if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
|
|
258
|
-
setIsSplit(true);
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
setSplitScreen(layoutName, layoutName, {
|
|
262
|
-
afterDropTargetComponent: [],
|
|
263
|
-
beforeDropTargetComponent: [],
|
|
264
|
-
centerDropTargetComponent: [
|
|
265
|
-
{
|
|
266
|
-
containerName,
|
|
267
|
-
component: children,
|
|
268
|
-
navigationTitle,
|
|
269
|
-
dropDocumentOutsideOption,
|
|
270
|
-
screenKey: screenKey ? screenKey : Array.from(
|
|
271
|
-
window.crypto.getRandomValues(
|
|
272
|
-
new Uint32Array(16)
|
|
273
|
-
),
|
|
274
|
-
(e) => e.toString(32).padStart(2, "0")
|
|
275
|
-
).join("")
|
|
276
|
-
}
|
|
277
|
-
],
|
|
278
|
-
direction
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
return () => {
|
|
283
|
-
subscribe.unsubscribe();
|
|
284
|
-
removeRootSplitScreen(layoutName);
|
|
285
|
-
};
|
|
286
|
-
}, [layoutName, screenKey, navigationTitle, children, direction]);
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
const subscribe = dropMovementEventSubject.pipe(
|
|
289
|
-
distinctUntilChanged((prev, curr) => {
|
|
290
|
-
const filterChildren = (obj) => {
|
|
291
|
-
const {
|
|
292
|
-
children: children2,
|
|
293
|
-
component,
|
|
294
|
-
targetComponent,
|
|
295
|
-
x,
|
|
296
|
-
y,
|
|
297
|
-
...rest
|
|
298
|
-
} = obj || {};
|
|
299
|
-
return rest;
|
|
300
|
-
};
|
|
301
|
-
return equal(filterChildren(prev), filterChildren(curr));
|
|
302
|
-
})
|
|
303
|
-
).subscribe((event) => {
|
|
304
|
-
if (event.state === "remove") {
|
|
305
|
-
if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
|
|
306
|
-
requestAnimationFrame(() => {
|
|
307
|
-
let removeCallback = (removeOrderName) => {
|
|
308
|
-
if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
|
|
309
|
-
const targetComponentsMap = handleUpdateDropTargetComponents({
|
|
310
|
-
orderName: removeOrderName,
|
|
311
|
-
containerName: event.nextContainerName,
|
|
312
|
-
parentLayoutName: "",
|
|
313
|
-
layoutName,
|
|
314
|
-
dropComponent: event.targetComponent,
|
|
315
|
-
navigationTitle: event.dropTargetComponentEvent.navigationTitle,
|
|
316
|
-
isUsePrefix: true,
|
|
317
|
-
afterDropTargetComponent,
|
|
318
|
-
beforeDropTargetComponent,
|
|
319
|
-
centerDropTargetComponent,
|
|
320
|
-
dropDocumentOutsideOption,
|
|
321
|
-
screenKey: event.dropTargetComponentEvent.screenKey
|
|
322
|
-
});
|
|
323
|
-
setSplitScreen(layoutName, layoutName, {
|
|
324
|
-
...getCurrentSplitScreenComponents(
|
|
325
|
-
layoutName,
|
|
326
|
-
layoutName
|
|
327
|
-
) || {
|
|
328
|
-
afterDropTargetComponent,
|
|
329
|
-
beforeDropTargetComponent,
|
|
330
|
-
centerDropTargetComponent,
|
|
331
|
-
direction
|
|
332
|
-
},
|
|
333
|
-
...targetComponentsMap
|
|
334
|
-
});
|
|
335
|
-
Promise.resolve().then(
|
|
336
|
-
() => event.dropEndCallback && event.dropEndCallback({
|
|
337
|
-
x: event.x,
|
|
338
|
-
y: event.y,
|
|
339
|
-
containerName
|
|
340
|
-
})
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
const currentComponents = getCurrentSplitScreenComponents(
|
|
345
|
-
layoutName,
|
|
346
|
-
layoutName
|
|
347
|
-
);
|
|
348
|
-
const afterList = handleRemove(
|
|
349
|
-
currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
|
|
350
|
-
event.targetContainerName,
|
|
351
|
-
() => removeCallback("after")
|
|
352
|
-
);
|
|
353
|
-
const beforList = handleRemove(
|
|
354
|
-
currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
|
|
355
|
-
event.targetContainerName,
|
|
356
|
-
() => removeCallback("before")
|
|
357
|
-
);
|
|
358
|
-
const centerList = handleRemove(
|
|
359
|
-
currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
|
|
360
|
-
event.targetContainerName,
|
|
361
|
-
() => removeCallback("center")
|
|
362
|
-
);
|
|
363
|
-
setSplitScreen(layoutName, layoutName, {
|
|
364
|
-
afterDropTargetComponent: afterList,
|
|
365
|
-
beforeDropTargetComponent: beforList,
|
|
366
|
-
centerDropTargetComponent: centerList,
|
|
367
|
-
direction
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
} else if (event.state === "append") {
|
|
372
|
-
const {
|
|
373
|
-
x,
|
|
374
|
-
y,
|
|
375
|
-
dropEndCallback,
|
|
376
|
-
dropTargetComponentEvent,
|
|
377
|
-
orderName,
|
|
378
|
-
parentOrderName,
|
|
379
|
-
targetLayoutName,
|
|
380
|
-
targetParentLayoutName,
|
|
381
|
-
targetContainerName,
|
|
382
|
-
targetComponent,
|
|
383
|
-
nextContainerName
|
|
384
|
-
} = event;
|
|
385
|
-
if (layoutRef.current && orderName && x && y && targetComponent && dropTargetComponentEvent && targetLayoutName === layoutName && isInnerDrop({ x, y, element: layoutRef.current })) {
|
|
386
|
-
const {
|
|
387
|
-
direction: dropDirection,
|
|
388
|
-
navigationTitle: navigationTitle2,
|
|
389
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2
|
|
390
|
-
} = dropTargetComponentEvent;
|
|
391
|
-
const isOrderNameNotCenter = orderName !== "center";
|
|
392
|
-
const isOrderNameCenterAndFirstScreen = orderName === "center" && centerDropTargetComponent.length <= 1;
|
|
393
|
-
if (isOrderNameNotCenter || isOrderNameCenterAndFirstScreen) {
|
|
394
|
-
setIsSplit(true);
|
|
395
|
-
if (isOrderNameNotCenter) {
|
|
396
|
-
setDirection(dropDirection);
|
|
397
|
-
const targetComponentsMap = handleUpdateDropTargetComponents({
|
|
398
|
-
orderName,
|
|
399
|
-
parentOrderName,
|
|
400
|
-
containerName: targetContainerName,
|
|
401
|
-
nextContainerName,
|
|
402
|
-
dropComponent: targetComponent,
|
|
403
|
-
parentLayoutName: "",
|
|
404
|
-
layoutName,
|
|
405
|
-
navigationTitle: navigationTitle2,
|
|
406
|
-
isUsePrefix: true,
|
|
407
|
-
afterDropTargetComponent,
|
|
408
|
-
beforeDropTargetComponent,
|
|
409
|
-
centerDropTargetComponent,
|
|
410
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2
|
|
411
|
-
});
|
|
412
|
-
setSplitScreen(layoutName, layoutName, {
|
|
413
|
-
...{
|
|
414
|
-
afterDropTargetComponent,
|
|
415
|
-
beforeDropTargetComponent,
|
|
416
|
-
centerDropTargetComponent,
|
|
417
|
-
direction: dropDirection
|
|
418
|
-
},
|
|
419
|
-
...targetComponentsMap,
|
|
420
|
-
...{ direction: dropDirection }
|
|
421
|
-
});
|
|
422
|
-
Promise.resolve().then(
|
|
423
|
-
() => dropEndCallback && dropEndCallback({
|
|
424
|
-
x: event.x,
|
|
425
|
-
y: event.y,
|
|
426
|
-
containerName
|
|
427
|
-
})
|
|
428
|
-
);
|
|
429
|
-
} else {
|
|
430
|
-
const childScreenInfo = getCurrentSplitScreenComponents(
|
|
431
|
-
layoutName,
|
|
432
|
-
`${layoutName}_center=${centerDropTargetComponent[0].screenKey}`
|
|
433
|
-
) || {
|
|
434
|
-
afterDropTargetComponent: [],
|
|
435
|
-
beforeDropTargetComponent: [],
|
|
436
|
-
centerDropTargetComponent: [],
|
|
437
|
-
direction
|
|
438
|
-
};
|
|
439
|
-
setSplitScreen(
|
|
440
|
-
layoutName,
|
|
441
|
-
`${layoutName}_center=${centerDropTargetComponent[0].screenKey}`,
|
|
442
|
-
{
|
|
443
|
-
...childScreenInfo,
|
|
444
|
-
...{
|
|
445
|
-
centerDropTargetComponent: [
|
|
446
|
-
centerDropTargetComponent[0],
|
|
447
|
-
{
|
|
448
|
-
containerName: `${targetContainerName}_${layoutName}_${orderName}`,
|
|
449
|
-
component: targetComponent,
|
|
450
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2,
|
|
451
|
-
screenKey: dropTargetComponentEvent.screenKey,
|
|
452
|
-
navigationTitle: navigationTitle2
|
|
453
|
-
}
|
|
454
|
-
]
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
});
|
|
463
|
-
return () => {
|
|
464
|
-
subscribe.unsubscribe();
|
|
465
|
-
};
|
|
466
|
-
}, [
|
|
467
|
-
direction,
|
|
468
|
-
layoutName,
|
|
469
|
-
isSplit,
|
|
470
|
-
beforeDropTargetComponent,
|
|
471
|
-
afterDropTargetComponent,
|
|
472
|
-
centerDropTargetComponent
|
|
473
|
-
]);
|
|
474
|
-
return /* @__PURE__ */ jsxs("div", { className: `${styles["flex-split-screen"]}`, ref: layoutRef, children: [
|
|
475
|
-
/* @__PURE__ */ jsxs(
|
|
476
|
-
FlexLayout,
|
|
477
|
-
{
|
|
478
|
-
direction,
|
|
479
|
-
layoutName,
|
|
480
|
-
"data-is_split": isSplit,
|
|
481
|
-
panelMovementMode: "bulldozer",
|
|
482
|
-
children: [
|
|
483
|
-
beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
|
|
484
|
-
({
|
|
485
|
-
containerName: cName,
|
|
486
|
-
component,
|
|
487
|
-
navigationTitle: navigationTitle2,
|
|
488
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2,
|
|
489
|
-
screenKey: screenKey2
|
|
490
|
-
}, i) => /* @__PURE__ */ jsx(
|
|
491
|
-
FlexLayoutContainer,
|
|
492
|
-
{
|
|
493
|
-
containerName: cName,
|
|
494
|
-
isInitialResizable: true,
|
|
495
|
-
isResizePanel: true,
|
|
496
|
-
children: /* @__PURE__ */ jsx(
|
|
497
|
-
FlexLayoutSplitScreenChild,
|
|
498
|
-
{
|
|
499
|
-
parentDirection: direction,
|
|
500
|
-
layoutName: `${layoutName}_before`,
|
|
501
|
-
parentLayoutName: layoutName,
|
|
502
|
-
containerName: cName,
|
|
503
|
-
depth: 1,
|
|
504
|
-
rootRef: layoutRef,
|
|
505
|
-
screenKey: screenKey2,
|
|
506
|
-
initialCenterComponents: [
|
|
507
|
-
{
|
|
508
|
-
navigationTitle: navigationTitle2,
|
|
509
|
-
component,
|
|
510
|
-
containerName: cName,
|
|
511
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2,
|
|
512
|
-
screenKey: screenKey2
|
|
513
|
-
}
|
|
514
|
-
],
|
|
515
|
-
rootName: layoutName
|
|
516
|
-
}
|
|
517
|
-
)
|
|
518
|
-
},
|
|
519
|
-
cName
|
|
520
|
-
)
|
|
521
|
-
) }) : /* @__PURE__ */ jsx("div", {}),
|
|
522
|
-
centerDropTargetComponent.length === 0 ? /* @__PURE__ */ jsx("div", {}) : /* @__PURE__ */ jsx(
|
|
523
|
-
FlexLayoutContainer,
|
|
524
|
-
{
|
|
525
|
-
containerName: `${centerDropTargetComponent[0].containerName}`,
|
|
526
|
-
isInitialResizable: true,
|
|
527
|
-
isResizePanel: isSplit,
|
|
528
|
-
children: isSplit ? /* @__PURE__ */ jsx(
|
|
529
|
-
FlexLayoutSplitScreenChild,
|
|
530
|
-
{
|
|
531
|
-
parentDirection: direction,
|
|
532
|
-
layoutName: `${layoutName}_center`,
|
|
533
|
-
parentLayoutName: layoutName,
|
|
534
|
-
containerName: `${centerDropTargetComponent[0].containerName}`,
|
|
535
|
-
depth: 0,
|
|
536
|
-
rootRef: layoutRef,
|
|
537
|
-
screenKey: centerDropTargetComponent[0].screenKey,
|
|
538
|
-
initialCenterComponents: [
|
|
539
|
-
{
|
|
540
|
-
navigationTitle: centerDropTargetComponent[0].navigationTitle,
|
|
541
|
-
component: centerDropTargetComponent[0].component,
|
|
542
|
-
containerName: centerDropTargetComponent[0].containerName,
|
|
543
|
-
dropDocumentOutsideOption: centerDropTargetComponent[0].dropDocumentOutsideOption,
|
|
544
|
-
screenKey: centerDropTargetComponent[0].screenKey
|
|
545
|
-
}
|
|
546
|
-
],
|
|
547
|
-
rootName: layoutName
|
|
548
|
-
}
|
|
549
|
-
) : /* @__PURE__ */ jsx(
|
|
550
|
-
FlexLayoutSplitScreenScrollBox,
|
|
551
|
-
{
|
|
552
|
-
keyName: centerDropTargetComponent[0].containerName,
|
|
553
|
-
isDefaultScrollStyle: true,
|
|
554
|
-
children: centerDropTargetComponent[0].component
|
|
555
|
-
}
|
|
556
|
-
)
|
|
557
|
-
}
|
|
558
|
-
),
|
|
559
|
-
afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
|
|
560
|
-
({
|
|
561
|
-
containerName: cName,
|
|
562
|
-
component,
|
|
563
|
-
navigationTitle: navigationTitle2,
|
|
564
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2,
|
|
565
|
-
screenKey: screenKey2
|
|
566
|
-
}, i) => /* @__PURE__ */ jsx(
|
|
567
|
-
FlexLayoutContainer,
|
|
568
|
-
{
|
|
569
|
-
containerName: cName,
|
|
570
|
-
isInitialResizable: true,
|
|
571
|
-
isResizePanel: afterDropTargetComponent.length - 1 !== i,
|
|
572
|
-
children: /* @__PURE__ */ jsx(
|
|
573
|
-
FlexLayoutSplitScreenChild,
|
|
574
|
-
{
|
|
575
|
-
parentDirection: direction,
|
|
576
|
-
layoutName: `${layoutName}_after`,
|
|
577
|
-
parentLayoutName: layoutName,
|
|
578
|
-
containerName: cName,
|
|
579
|
-
depth: 1,
|
|
580
|
-
rootRef: layoutRef,
|
|
581
|
-
screenKey: screenKey2,
|
|
582
|
-
initialCenterComponents: [
|
|
583
|
-
{
|
|
584
|
-
navigationTitle: navigationTitle2,
|
|
585
|
-
component,
|
|
586
|
-
containerName: cName,
|
|
587
|
-
dropDocumentOutsideOption: dropDocumentOutsideOption2,
|
|
588
|
-
screenKey: screenKey2
|
|
589
|
-
}
|
|
590
|
-
],
|
|
591
|
-
rootName: layoutName
|
|
592
|
-
}
|
|
593
|
-
)
|
|
594
|
-
},
|
|
595
|
-
cName
|
|
596
|
-
)
|
|
597
|
-
) }) : /* @__PURE__ */ jsx("div", {})
|
|
598
|
-
]
|
|
599
|
-
}
|
|
600
|
-
),
|
|
601
|
-
boundaryContainerSize && /* @__PURE__ */ jsx(
|
|
602
|
-
"div",
|
|
603
|
-
{
|
|
604
|
-
className: `${styles["flex-split-screen-boundary-container"]}`,
|
|
605
|
-
style: { ...boundaryContainerSize },
|
|
606
|
-
children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
|
|
607
|
-
}
|
|
608
|
-
)
|
|
609
|
-
] });
|
|
610
|
-
}
|
|
611
|
-
function FlexLayoutSplitScreenChild({
|
|
612
|
-
containerName,
|
|
613
|
-
layoutName,
|
|
614
|
-
parentLayoutName,
|
|
615
|
-
parentDirection,
|
|
616
|
-
depth,
|
|
617
|
-
//isSplit: isSplitInitial,
|
|
618
|
-
rootRef,
|
|
619
|
-
rootName,
|
|
620
|
-
initialCenterComponents,
|
|
621
|
-
screenKey
|
|
622
|
-
}) {
|
|
623
|
-
const {
|
|
624
|
-
direction,
|
|
625
|
-
isSplit,
|
|
626
|
-
boundaryContainerSize,
|
|
627
|
-
afterDropTargetComponent,
|
|
628
|
-
beforeDropTargetComponent,
|
|
629
|
-
centerDropTargetComponent,
|
|
630
|
-
setAfterDropTargetComponent,
|
|
631
|
-
setBeforeDropTargetComponent,
|
|
632
|
-
setCenterDropTargetComponent,
|
|
633
|
-
layoutRef,
|
|
634
|
-
setIsSplit,
|
|
635
|
-
setDirection
|
|
636
|
-
} = useFlexLayoutSplitScreen({
|
|
637
|
-
isSplitInitial: false,
|
|
638
|
-
directionInitial: "row",
|
|
639
|
-
parentDirection,
|
|
640
|
-
selfContainerName: containerName,
|
|
641
|
-
parentLayoutName,
|
|
642
|
-
layoutName
|
|
643
|
-
});
|
|
644
|
-
const [isEmptyContent, setIsEmptyContent] = useState(false);
|
|
645
|
-
const [activeIndex, setActiveIndex] = useState(0);
|
|
646
|
-
const centerDropTargetComponentRef = useRef(centerDropTargetComponent);
|
|
647
|
-
const initialCenterRef = useRef(
|
|
648
|
-
initialCenterComponents ?? []
|
|
649
|
-
);
|
|
650
|
-
const activeIndexRef = useRef(activeIndex);
|
|
651
|
-
useEffect(() => {
|
|
652
|
-
const storeKey = `${layoutName}=${screenKey}`;
|
|
653
|
-
const subscribe = getSplitScreen(rootName, storeKey).pipe(take(1)).subscribe((layoutInfo) => {
|
|
654
|
-
if (layoutInfo) return;
|
|
655
|
-
setSplitScreen(rootName, storeKey, {
|
|
656
|
-
afterDropTargetComponent: [],
|
|
657
|
-
beforeDropTargetComponent: [],
|
|
658
|
-
centerDropTargetComponent: initialCenterRef.current,
|
|
659
|
-
direction
|
|
660
|
-
});
|
|
661
|
-
});
|
|
662
|
-
return () => {
|
|
663
|
-
removeSplitScreenChild(rootName, `${layoutName}=${screenKey}`);
|
|
664
|
-
subscribe.unsubscribe();
|
|
665
|
-
};
|
|
666
|
-
}, [rootName, layoutName, screenKey]);
|
|
667
|
-
useEffect(() => {
|
|
668
|
-
const subscribe = getSplitScreen(rootName, `${layoutName}=${screenKey}`).subscribe((layoutInfo) => {
|
|
669
|
-
if (layoutInfo) {
|
|
670
|
-
setBeforeDropTargetComponent([
|
|
671
|
-
...layoutInfo.beforeDropTargetComponent
|
|
672
|
-
]);
|
|
673
|
-
setAfterDropTargetComponent([
|
|
674
|
-
...layoutInfo.afterDropTargetComponent
|
|
675
|
-
]);
|
|
676
|
-
setCenterDropTargetComponent([
|
|
677
|
-
...layoutInfo.centerDropTargetComponent
|
|
678
|
-
]);
|
|
679
|
-
setDirection(layoutInfo.direction);
|
|
680
|
-
if (layoutInfo.beforeDropTargetComponent.length !== 0 || layoutInfo.afterDropTargetComponent.length !== 0) {
|
|
681
|
-
setIsSplit(true);
|
|
682
|
-
} else if (layoutInfo.beforeDropTargetComponent.length === 0 && layoutInfo.centerDropTargetComponent.length === 0 && layoutInfo.afterDropTargetComponent.length === 0) {
|
|
683
|
-
dropMovementEventSubject.next({
|
|
684
|
-
state: "remove",
|
|
685
|
-
targetContainerName: containerName,
|
|
686
|
-
targetParentLayoutName: "",
|
|
687
|
-
targetLayoutName: parentLayoutName
|
|
688
|
-
});
|
|
689
|
-
setIsEmptyContent(true);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
return () => {
|
|
694
|
-
subscribe.unsubscribe();
|
|
695
|
-
removeRootSplitScreen(layoutName);
|
|
696
|
-
};
|
|
697
|
-
}, [rootName, layoutName]);
|
|
698
|
-
useEffect(() => {
|
|
699
|
-
const subscribe = dropMovementEventSubject.pipe(
|
|
700
|
-
distinctUntilChanged((prev, curr) => {
|
|
701
|
-
const filterChildren = (obj) => {
|
|
702
|
-
const {
|
|
703
|
-
children,
|
|
704
|
-
component,
|
|
705
|
-
targetComponent,
|
|
706
|
-
x,
|
|
707
|
-
y,
|
|
708
|
-
...rest
|
|
709
|
-
} = obj || {};
|
|
710
|
-
return rest;
|
|
711
|
-
};
|
|
712
|
-
return equal(filterChildren(prev), filterChildren(curr));
|
|
713
|
-
})
|
|
714
|
-
).subscribe((event) => {
|
|
715
|
-
if (event.state === "remove") {
|
|
716
|
-
if (event.targetParentLayoutName === layoutName || event.targetParentLayoutName === "" && event.targetLayoutName === layoutName) {
|
|
717
|
-
requestAnimationFrame(() => {
|
|
718
|
-
let removeCallback = (removeOrderName) => {
|
|
719
|
-
if (event.nextContainerName && event.dropTargetComponentEvent && event.targetComponent) {
|
|
720
|
-
const targetComponentsMap = handleUpdateDropTargetComponents({
|
|
721
|
-
orderName: removeOrderName,
|
|
722
|
-
containerName: event.nextContainerName,
|
|
723
|
-
parentLayoutName,
|
|
724
|
-
layoutName,
|
|
725
|
-
dropComponent: event.targetComponent,
|
|
726
|
-
navigationTitle: event.dropTargetComponentEvent.navigationTitle,
|
|
727
|
-
isUsePrefix: true,
|
|
728
|
-
afterDropTargetComponent,
|
|
729
|
-
beforeDropTargetComponent,
|
|
730
|
-
centerDropTargetComponent,
|
|
731
|
-
dropDocumentOutsideOption: event.dropTargetComponentEvent?.dropDocumentOutsideOption,
|
|
732
|
-
screenKey: event.dropTargetComponentEvent.screenKey
|
|
733
|
-
});
|
|
734
|
-
setSplitScreen(
|
|
735
|
-
rootName,
|
|
736
|
-
`${layoutName}=${screenKey}`,
|
|
737
|
-
{
|
|
738
|
-
...getCurrentSplitScreenComponents(
|
|
739
|
-
rootName,
|
|
740
|
-
`${layoutName}=${screenKey}`
|
|
741
|
-
) || {
|
|
742
|
-
afterDropTargetComponent,
|
|
743
|
-
beforeDropTargetComponent,
|
|
744
|
-
centerDropTargetComponent,
|
|
745
|
-
direction
|
|
746
|
-
},
|
|
747
|
-
...targetComponentsMap
|
|
748
|
-
}
|
|
749
|
-
);
|
|
750
|
-
Promise.resolve().then(
|
|
751
|
-
() => event.dropEndCallback && event.dropEndCallback({
|
|
752
|
-
x: event.x,
|
|
753
|
-
y: event.y,
|
|
754
|
-
containerName
|
|
755
|
-
})
|
|
756
|
-
);
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
const currentComponents = getCurrentSplitScreenComponents(
|
|
760
|
-
rootName,
|
|
761
|
-
`${layoutName}=${screenKey}`
|
|
762
|
-
);
|
|
763
|
-
const afterList = handleRemove(
|
|
764
|
-
currentComponents?.afterDropTargetComponent || afterDropTargetComponent,
|
|
765
|
-
event.targetContainerName,
|
|
766
|
-
() => removeCallback("after")
|
|
767
|
-
);
|
|
768
|
-
const beforList = handleRemove(
|
|
769
|
-
currentComponents?.beforeDropTargetComponent || beforeDropTargetComponent,
|
|
770
|
-
event.targetContainerName,
|
|
771
|
-
() => removeCallback("before")
|
|
772
|
-
);
|
|
773
|
-
const centerList = handleRemove(
|
|
774
|
-
currentComponents?.centerDropTargetComponent || centerDropTargetComponent,
|
|
775
|
-
event.targetContainerName,
|
|
776
|
-
() => removeCallback("center")
|
|
777
|
-
);
|
|
778
|
-
setSplitScreen(
|
|
779
|
-
rootName,
|
|
780
|
-
`${layoutName}=${screenKey}`,
|
|
781
|
-
{
|
|
782
|
-
afterDropTargetComponent: afterList,
|
|
783
|
-
beforeDropTargetComponent: beforList,
|
|
784
|
-
centerDropTargetComponent: centerList,
|
|
785
|
-
direction
|
|
786
|
-
}
|
|
787
|
-
);
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
} else if (event.state === "append") {
|
|
791
|
-
const {
|
|
792
|
-
x,
|
|
793
|
-
y,
|
|
794
|
-
dropEndCallback,
|
|
795
|
-
dropTargetComponentEvent,
|
|
796
|
-
orderName,
|
|
797
|
-
targetLayoutName,
|
|
798
|
-
targetParentLayoutName,
|
|
799
|
-
targetContainerName,
|
|
800
|
-
targetComponent,
|
|
801
|
-
nextContainerName,
|
|
802
|
-
parentOrderName
|
|
803
|
-
} = event;
|
|
804
|
-
if (layoutRef.current && orderName && x && y && dropTargetComponentEvent && isInnerDrop({ x, y, element: layoutRef.current })) {
|
|
805
|
-
const {
|
|
806
|
-
direction: dropDirection,
|
|
807
|
-
navigationTitle,
|
|
808
|
-
dropDocumentOutsideOption,
|
|
809
|
-
screenKey: containerScreenKey
|
|
810
|
-
} = dropTargetComponentEvent;
|
|
811
|
-
if (
|
|
812
|
-
//orderName !== 'center' &&
|
|
813
|
-
targetLayoutName === layoutName && targetComponent
|
|
814
|
-
) {
|
|
815
|
-
if (dropDirection === parentDirection && orderName !== "center") {
|
|
816
|
-
dropMovementEventSubject.next({
|
|
817
|
-
state: "append",
|
|
818
|
-
targetContainerName,
|
|
819
|
-
targetParentLayoutName: "",
|
|
820
|
-
targetLayoutName: parentLayoutName,
|
|
821
|
-
targetComponent,
|
|
822
|
-
nextContainerName: containerName,
|
|
823
|
-
parentOrderName: getSelfOrderName(layoutName) || orderName,
|
|
824
|
-
orderName,
|
|
825
|
-
x,
|
|
826
|
-
y,
|
|
827
|
-
dropEndCallback,
|
|
828
|
-
dropTargetComponentEvent: {
|
|
829
|
-
navigationTitle,
|
|
830
|
-
dropDocumentOutsideOption,
|
|
831
|
-
direction: parentDirection,
|
|
832
|
-
screenKey
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
} else {
|
|
836
|
-
if (orderName !== "center") {
|
|
837
|
-
setDirection(dropDirection);
|
|
838
|
-
setIsSplit(true);
|
|
839
|
-
}
|
|
840
|
-
const targetComponentsMap = handleUpdateDropTargetComponents({
|
|
841
|
-
orderName,
|
|
842
|
-
parentOrderName,
|
|
843
|
-
containerName: targetContainerName,
|
|
844
|
-
nextContainerName,
|
|
845
|
-
parentLayoutName,
|
|
846
|
-
layoutName,
|
|
847
|
-
dropComponent: targetComponent,
|
|
848
|
-
navigationTitle,
|
|
849
|
-
isUsePrefix: orderName !== "center",
|
|
850
|
-
afterDropTargetComponent,
|
|
851
|
-
beforeDropTargetComponent,
|
|
852
|
-
centerDropTargetComponent,
|
|
853
|
-
dropDocumentOutsideOption
|
|
854
|
-
});
|
|
855
|
-
setSplitScreen(
|
|
856
|
-
rootName,
|
|
857
|
-
`${layoutName}=${screenKey}`,
|
|
858
|
-
{
|
|
859
|
-
...getCurrentSplitScreenComponents(
|
|
860
|
-
rootName,
|
|
861
|
-
`${layoutName}=${screenKey}`
|
|
862
|
-
) || {
|
|
863
|
-
afterDropTargetComponent,
|
|
864
|
-
beforeDropTargetComponent,
|
|
865
|
-
centerDropTargetComponent,
|
|
866
|
-
direction
|
|
867
|
-
},
|
|
868
|
-
...targetComponentsMap,
|
|
869
|
-
...{ direction: dropDirection }
|
|
870
|
-
}
|
|
871
|
-
);
|
|
872
|
-
Promise.resolve().then(
|
|
873
|
-
() => event.dropEndCallback && event.dropEndCallback({
|
|
874
|
-
x: event.x,
|
|
875
|
-
y: event.y,
|
|
876
|
-
containerName
|
|
877
|
-
})
|
|
878
|
-
);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
return () => {
|
|
885
|
-
subscribe.unsubscribe();
|
|
886
|
-
};
|
|
887
|
-
}, [
|
|
888
|
-
direction,
|
|
889
|
-
parentDirection,
|
|
890
|
-
parentLayoutName,
|
|
891
|
-
layoutName,
|
|
892
|
-
beforeDropTargetComponent,
|
|
893
|
-
afterDropTargetComponent,
|
|
894
|
-
centerDropTargetComponent
|
|
895
|
-
]);
|
|
896
|
-
useEffect(() => {
|
|
897
|
-
centerDropTargetComponentRef.current = centerDropTargetComponent;
|
|
898
|
-
}, [centerDropTargetComponent]);
|
|
899
|
-
useEffect(() => {
|
|
900
|
-
activeIndexRef.current = activeIndex;
|
|
901
|
-
}, [activeIndex]);
|
|
902
|
-
const [isOnlyOneScreen, setIsOnlyOneScreen] = useState(false);
|
|
903
|
-
return /* @__PURE__ */ jsx(Fragment, { children: !isEmptyContent && /* @__PURE__ */ jsxs(
|
|
904
|
-
"div",
|
|
905
|
-
{
|
|
906
|
-
className: `${styles["flex-split-screen"]}`,
|
|
907
|
-
ref: layoutRef,
|
|
908
|
-
children: [
|
|
909
|
-
/* @__PURE__ */ jsxs(
|
|
910
|
-
FlexLayout,
|
|
911
|
-
{
|
|
912
|
-
direction,
|
|
913
|
-
layoutName: `${layoutName}`,
|
|
914
|
-
panelMovementMode: "bulldozer",
|
|
915
|
-
children: [
|
|
916
|
-
beforeDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: beforeDropTargetComponent.map(
|
|
917
|
-
({
|
|
918
|
-
containerName: cName,
|
|
919
|
-
component,
|
|
920
|
-
navigationTitle,
|
|
921
|
-
dropDocumentOutsideOption,
|
|
922
|
-
screenKey: screenKey2
|
|
923
|
-
}, i) => /* @__PURE__ */ jsx(
|
|
924
|
-
FlexLayoutContainer,
|
|
925
|
-
{
|
|
926
|
-
containerName: cName,
|
|
927
|
-
isInitialResizable: true,
|
|
928
|
-
isResizePanel: true,
|
|
929
|
-
children: /* @__PURE__ */ jsx(
|
|
930
|
-
FlexLayoutSplitScreenChild,
|
|
931
|
-
{
|
|
932
|
-
parentDirection: direction,
|
|
933
|
-
layoutName: `${layoutName}_before-${depth}`,
|
|
934
|
-
parentLayoutName: layoutName,
|
|
935
|
-
containerName: cName,
|
|
936
|
-
depth: depth + 1,
|
|
937
|
-
rootRef,
|
|
938
|
-
screenKey: screenKey2,
|
|
939
|
-
initialCenterComponents: [
|
|
940
|
-
{
|
|
941
|
-
navigationTitle,
|
|
942
|
-
component,
|
|
943
|
-
containerName: cName,
|
|
944
|
-
dropDocumentOutsideOption,
|
|
945
|
-
screenKey: screenKey2
|
|
946
|
-
}
|
|
947
|
-
],
|
|
948
|
-
rootName
|
|
949
|
-
}
|
|
950
|
-
)
|
|
951
|
-
},
|
|
952
|
-
cName
|
|
953
|
-
)
|
|
954
|
-
) }) : /* @__PURE__ */ jsx("div", {}),
|
|
955
|
-
centerDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
956
|
-
FlexLayoutContainer,
|
|
957
|
-
{
|
|
958
|
-
containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
|
|
959
|
-
isInitialResizable: true,
|
|
960
|
-
isResizePanel: isSplit,
|
|
961
|
-
children: isSplit ? /* @__PURE__ */ jsx("div", { "data-key": screenKey, children: /* @__PURE__ */ jsx(
|
|
962
|
-
FlexLayoutSplitScreenChild,
|
|
963
|
-
{
|
|
964
|
-
parentDirection: direction,
|
|
965
|
-
layoutName: `${layoutName}_center-${depth}`,
|
|
966
|
-
parentLayoutName: layoutName,
|
|
967
|
-
containerName: `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
|
|
968
|
-
depth: depth + 1,
|
|
969
|
-
rootRef,
|
|
970
|
-
initialCenterComponents: centerDropTargetComponent.map(
|
|
971
|
-
({
|
|
972
|
-
navigationTitle,
|
|
973
|
-
component,
|
|
974
|
-
containerName: cName,
|
|
975
|
-
dropDocumentOutsideOption,
|
|
976
|
-
screenKey: centerScreenKey
|
|
977
|
-
}) => ({
|
|
978
|
-
navigationTitle,
|
|
979
|
-
component,
|
|
980
|
-
containerName: cName,
|
|
981
|
-
dropDocumentOutsideOption,
|
|
982
|
-
screenKey: centerScreenKey
|
|
983
|
-
})
|
|
984
|
-
),
|
|
985
|
-
screenKey,
|
|
986
|
-
rootName
|
|
987
|
-
}
|
|
988
|
-
) }) : /* @__PURE__ */ jsxs(
|
|
989
|
-
FlexLayoutSplitScreenScrollBox,
|
|
990
|
-
{
|
|
991
|
-
keyName: (centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName,
|
|
992
|
-
isDefaultScrollStyle: true,
|
|
993
|
-
children: [
|
|
994
|
-
!isOnlyOneScreen && /* @__PURE__ */ jsx(
|
|
995
|
-
"div",
|
|
996
|
-
{
|
|
997
|
-
className: `${styles["flex-split-screen-drag-box-title-wrapper-sticky"]}`,
|
|
998
|
-
children: /* @__PURE__ */ jsxs(
|
|
999
|
-
"div",
|
|
1000
|
-
{
|
|
1001
|
-
"data-is_split": isSplit,
|
|
1002
|
-
"data-layout_name": layoutName,
|
|
1003
|
-
"data-parent_layout_name": parentLayoutName,
|
|
1004
|
-
"data-container_name": `${(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName}`,
|
|
1005
|
-
className: `${styles["flex-split-screen-drag-box-title-wrapper"]}`,
|
|
1006
|
-
children: [
|
|
1007
|
-
/* @__PURE__ */ jsx(
|
|
1008
|
-
FlexLayoutSplitScreenDragBoxContainer,
|
|
1009
|
-
{
|
|
1010
|
-
"data-layout_name": layoutName,
|
|
1011
|
-
layoutName,
|
|
1012
|
-
children: centerDropTargetComponent.map(
|
|
1013
|
-
(item, index) => /* @__PURE__ */ jsx(
|
|
1014
|
-
FlexLayoutSplitScreenDragBoxItem,
|
|
1015
|
-
{
|
|
1016
|
-
onClose: (ev) => {
|
|
1017
|
-
if (activeIndexRef.current === index && centerDropTargetComponent.length === 1) {
|
|
1018
|
-
dropMovementEventSubject.next(
|
|
1019
|
-
{
|
|
1020
|
-
state: "remove",
|
|
1021
|
-
targetContainerName: containerName,
|
|
1022
|
-
targetParentLayoutName: parentLayoutName,
|
|
1023
|
-
targetLayoutName: layoutName
|
|
1024
|
-
}
|
|
1025
|
-
);
|
|
1026
|
-
} else {
|
|
1027
|
-
if (centerDropTargetComponent.length === activeIndexRef.current + 1) {
|
|
1028
|
-
setActiveIndex(
|
|
1029
|
-
activeIndexRef.current - 1
|
|
1030
|
-
);
|
|
1031
|
-
}
|
|
1032
|
-
setCenterDropTargetComponent(
|
|
1033
|
-
(prev) => {
|
|
1034
|
-
const next = handleRemove(
|
|
1035
|
-
prev,
|
|
1036
|
-
item.containerName,
|
|
1037
|
-
() => {
|
|
1038
|
-
}
|
|
1039
|
-
);
|
|
1040
|
-
const key = `${layoutName}=${screenKey}`;
|
|
1041
|
-
const current = getCurrentSplitScreenComponents(
|
|
1042
|
-
rootName,
|
|
1043
|
-
key
|
|
1044
|
-
) || {
|
|
1045
|
-
afterDropTargetComponent,
|
|
1046
|
-
beforeDropTargetComponent,
|
|
1047
|
-
centerDropTargetComponent: prev,
|
|
1048
|
-
direction
|
|
1049
|
-
};
|
|
1050
|
-
setSplitScreen(
|
|
1051
|
-
rootName,
|
|
1052
|
-
key,
|
|
1053
|
-
{
|
|
1054
|
-
...current,
|
|
1055
|
-
centerDropTargetComponent: next
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
1058
|
-
return next;
|
|
1059
|
-
}
|
|
1060
|
-
);
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
isActive: activeIndex === index,
|
|
1064
|
-
children: /* @__PURE__ */ jsx(
|
|
1065
|
-
FlexLayoutSplitScreenDragBox,
|
|
1066
|
-
{
|
|
1067
|
-
screenKey: item.screenKey,
|
|
1068
|
-
onClick: () => {
|
|
1069
|
-
setActiveIndex(
|
|
1070
|
-
index
|
|
1071
|
-
);
|
|
1072
|
-
},
|
|
1073
|
-
containerName: item.containerName,
|
|
1074
|
-
dropDocumentOutsideOption: item.dropDocumentOutsideOption,
|
|
1075
|
-
targetComponent: item.component,
|
|
1076
|
-
navigationTitle: item.navigationTitle,
|
|
1077
|
-
"data-container-name": item.containerName,
|
|
1078
|
-
"data-layout-name": layoutName,
|
|
1079
|
-
"data-parent-layout-name": parentLayoutName,
|
|
1080
|
-
dropEndCallback: ({
|
|
1081
|
-
x,
|
|
1082
|
-
y,
|
|
1083
|
-
containerName: appendContainerName
|
|
1084
|
-
}) => {
|
|
1085
|
-
if (!rootRef.current || !layoutRef.current)
|
|
1086
|
-
return;
|
|
1087
|
-
const isRootOver = isOverDrop(
|
|
1088
|
-
{
|
|
1089
|
-
x,
|
|
1090
|
-
y,
|
|
1091
|
-
element: rootRef.current
|
|
1092
|
-
}
|
|
1093
|
-
);
|
|
1094
|
-
const isLayoutInner = isInnerDrop(
|
|
1095
|
-
{
|
|
1096
|
-
x,
|
|
1097
|
-
y,
|
|
1098
|
-
element: layoutRef.current
|
|
1099
|
-
}
|
|
1100
|
-
);
|
|
1101
|
-
if (!isRootOver && !isLayoutInner || !isRootOver && isLayoutInner && centerDropTargetComponentRef.current.length > 1) {
|
|
1102
|
-
const option = {};
|
|
1103
|
-
if (centerDropTargetComponentRef.current.length > 1) {
|
|
1104
|
-
const {
|
|
1105
|
-
adjacentItem,
|
|
1106
|
-
adjacentIndex
|
|
1107
|
-
} = getAdjacentItem(
|
|
1108
|
-
centerDropTargetComponentRef.current,
|
|
1109
|
-
activeIndexRef.current
|
|
1110
|
-
);
|
|
1111
|
-
if (adjacentItem && activeIndexRef.current === index) {
|
|
1112
|
-
Object.assign(
|
|
1113
|
-
option,
|
|
1114
|
-
{
|
|
1115
|
-
x,
|
|
1116
|
-
y,
|
|
1117
|
-
targetComponent: adjacentItem.component,
|
|
1118
|
-
nextContainerName: adjacentItem.containerName,
|
|
1119
|
-
orderName: "center",
|
|
1120
|
-
dropTargetComponentEvent: {
|
|
1121
|
-
navigationTitle: adjacentItem.navigationTitle,
|
|
1122
|
-
dropDocumentOutsideOption: adjacentItem.dropDocumentOutsideOption,
|
|
1123
|
-
direction,
|
|
1124
|
-
screenKey
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
if (index === 0) {
|
|
1131
|
-
dropMovementEventSubject.next(
|
|
1132
|
-
{
|
|
1133
|
-
state: "remove",
|
|
1134
|
-
targetContainerName: item.containerName,
|
|
1135
|
-
targetParentLayoutName: parentLayoutName,
|
|
1136
|
-
targetLayoutName: layoutName,
|
|
1137
|
-
...option
|
|
1138
|
-
}
|
|
1139
|
-
);
|
|
1140
|
-
} else {
|
|
1141
|
-
dropMovementEventSubject.next(
|
|
1142
|
-
{
|
|
1143
|
-
state: "remove",
|
|
1144
|
-
targetContainerName: item.containerName,
|
|
1145
|
-
targetParentLayoutName: "",
|
|
1146
|
-
targetLayoutName: layoutName,
|
|
1147
|
-
...option
|
|
1148
|
-
}
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
},
|
|
1153
|
-
children: item.navigationTitle
|
|
1154
|
-
}
|
|
1155
|
-
)
|
|
1156
|
-
},
|
|
1157
|
-
item.navigationTitle + layoutName + item.containerName
|
|
1158
|
-
)
|
|
1159
|
-
)
|
|
1160
|
-
},
|
|
1161
|
-
layoutName
|
|
1162
|
-
),
|
|
1163
|
-
/* @__PURE__ */ jsx(FlexLayoutSplitScreenDragBoxTitleMore, {})
|
|
1164
|
-
]
|
|
1165
|
-
}
|
|
1166
|
-
)
|
|
1167
|
-
}
|
|
1168
|
-
),
|
|
1169
|
-
(() => {
|
|
1170
|
-
const target = centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0];
|
|
1171
|
-
return target.component;
|
|
1172
|
-
})()
|
|
1173
|
-
]
|
|
1174
|
-
}
|
|
1175
|
-
)
|
|
1176
|
-
},
|
|
1177
|
-
(centerDropTargetComponent[activeIndex] || centerDropTargetComponent[0]).containerName
|
|
1178
|
-
) }) : /* @__PURE__ */ jsx("div", {}),
|
|
1179
|
-
afterDropTargetComponent.length != 0 ? /* @__PURE__ */ jsx(Fragment, { children: afterDropTargetComponent.map(
|
|
1180
|
-
({
|
|
1181
|
-
containerName: cName,
|
|
1182
|
-
component,
|
|
1183
|
-
navigationTitle,
|
|
1184
|
-
dropDocumentOutsideOption,
|
|
1185
|
-
screenKey: screenKey2
|
|
1186
|
-
}, i) => /* @__PURE__ */ jsx(
|
|
1187
|
-
FlexLayoutContainer,
|
|
1188
|
-
{
|
|
1189
|
-
containerName: cName,
|
|
1190
|
-
isInitialResizable: true,
|
|
1191
|
-
isResizePanel: i !== afterDropTargetComponent.length - 1,
|
|
1192
|
-
children: /* @__PURE__ */ jsx(
|
|
1193
|
-
FlexLayoutSplitScreenChild,
|
|
1194
|
-
{
|
|
1195
|
-
parentDirection: direction,
|
|
1196
|
-
layoutName: `${layoutName}_after-${depth}`,
|
|
1197
|
-
parentLayoutName: layoutName,
|
|
1198
|
-
containerName: cName,
|
|
1199
|
-
depth: depth + 1,
|
|
1200
|
-
rootRef,
|
|
1201
|
-
screenKey: screenKey2,
|
|
1202
|
-
initialCenterComponents: [
|
|
1203
|
-
{
|
|
1204
|
-
navigationTitle,
|
|
1205
|
-
component,
|
|
1206
|
-
containerName: cName,
|
|
1207
|
-
dropDocumentOutsideOption,
|
|
1208
|
-
screenKey: screenKey2
|
|
1209
|
-
}
|
|
1210
|
-
],
|
|
1211
|
-
rootName
|
|
1212
|
-
}
|
|
1213
|
-
)
|
|
1214
|
-
},
|
|
1215
|
-
cName
|
|
1216
|
-
)
|
|
1217
|
-
) }) : /* @__PURE__ */ jsx("div", {})
|
|
1218
|
-
]
|
|
1219
|
-
}
|
|
1220
|
-
),
|
|
1221
|
-
boundaryContainerSize && /* @__PURE__ */ jsx(
|
|
1222
|
-
"div",
|
|
1223
|
-
{
|
|
1224
|
-
className: `${styles["flex-split-screen-boundary-container"]}`,
|
|
1225
|
-
style: { ...boundaryContainerSize },
|
|
1226
|
-
children: "\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."
|
|
1227
|
-
}
|
|
1228
|
-
)
|
|
1229
|
-
]
|
|
1230
|
-
}
|
|
1231
|
-
) });
|
|
1232
|
-
}
|
|
1233
|
-
export {
|
|
1234
|
-
FlexLayoutSplitScreen as default
|
|
1235
|
-
};
|
|
1236
|
-
//# sourceMappingURL=FlexLayoutSplitScreen.js.map
|
|
1
|
+
"use client";import{Fragment as X,jsx as c,jsxs as Y}from"react/jsx-runtime";import{cloneElement as fe,useEffect as M,useRef as ee,useState as te}from"react";import{dropMovementEventSubject as z}from"../hooks/useDrag";import{useFlexLayoutSplitScreen as ae}from"../hooks/useFlexLayoutSplitScreen";import{getCurrentSplitScreenComponents as A,getSplitScreen as ne,removeRootSplitScreen as pe,removeSplitScreenChild as ue,resetRootSplitScreen as De,setSplitScreen as F}from"../store/FlexLayoutContainerStore";import q from"../styles/FlexLayout.module.css";import se from"./FlexLayout";import H from"./FlexLayoutContainer";import be from"./FlexLayoutSplitScreenDragBox";import ce from"fast-deep-equal";import{distinctUntilChanged as le,take as Te}from"rxjs";import Se from"./FlexLayoutSplitScreenDragBoxContainer";import xe from"./FlexLayoutSplitScreenDragBoxItem";import Le from"./FlexLayoutSplitScreenDragBoxTitleMore";import me from"./FlexLayoutSplitScreenScrollBox";function he({x:o,y:e,element:t}){const{x:L,y:S,right:$,bottom:p}=t.getBoundingClientRect();return o<L||o>$||e<S||e>p}function re({x:o,y:e,element:t}){const{x:L,y:S,right:$,bottom:p}=t.getBoundingClientRect();return o>=L&&o<=$&&e>=S&&e<=p}const Q=({orderName:o,parentOrderName:e,containerName:t,parentLayoutName:L,layoutName:S,dropComponent:$,navigationTitle:p,nextContainerName:P,isUsePrefix:D=!0,beforeDropTargetComponent:f,afterDropTargetComponent:y,centerDropTargetComponent:m,dropDocumentOutsideOption:R,screenKey:v=Array.from(window.crypto.getRandomValues(new Uint32Array(16)),a=>a.toString(32).padStart(2,"0")).join("")})=>{const a=e||o;let N,g,B;a===o||a==="center"?N=o==="before"?{beforeDropTargetComponent:f}:o==="after"?{afterDropTargetComponent:y}:{centerDropTargetComponent:m.filter(i=>!i.containerName.split("_").at(0).startsWith(t.split("_").at(0)))}:N=a==="before"?{beforeDropTargetComponent:f}:{afterDropTargetComponent:y};const u=Object.entries(N)[0];B=u[0],g=u[1];const r={containerName:`${t+"_"+S}${D?"_"+o+"-"+g.length:""}`,component:fe($,{key:v,screenKey:v}),navigationTitle:p,dropDocumentOutsideOption:R,screenKey:v||Array.from(window.crypto.getRandomValues(new Uint32Array(16)),i=>i.toString(32).padStart(2,"0")).join("")};let l;if(P){const i=g.findIndex(E=>E.containerName===P);i!==-1?a===o?o==="before"?l=[...g.slice(0,i),r,...g.slice(i)]:l=[...g.slice(0,i+1),r,...g.slice(i+1)]:a==="after"&&o==="before"?l=[...g.slice(0,i),r,...g.slice(i)]:a==="before"&&o==="after"?l=[...g.slice(0,i+1),r,...g.slice(i+1)]:o==="before"?l=[...g.slice(0,i),r,...g.slice(i)]:l=[...g.slice(0,i+1),r,...g.slice(i+1)]:a==="center"&&o==="after"?l=[r,...g]:a==="center"&&o==="before"?l=[...g,r]:l=o==="before"?[r,...g]:[...g,r]}else l=o==="before"?[r,...g]:[...g,r];const x=new Set,h=l.filter(i=>x.has(i.containerName)?!1:(x.add(i.containerName),!0));return z.next({state:"append",targetParentLayoutName:L,targetLayoutName:S,targetContainerName:t,orderName:o}),{[B]:h}},I=(o,e,t)=>{const L=o.filter(S=>S.containerName!==e);return L.length!=o.length&&t(o.length-L.length),L};function Oe(o,e){return e+1<o.length?{adjacentItem:o[e+1],adjacentIndex:e+1}:e-1>=0?{adjacentItem:o[e-1],adjacentIndex:e-1}:{adjacentItem:null,adjacentIndex:e}}const $e=o=>{const e=o.split("_").at(-1)?.split("-").at(0)?.split("=").at(0);if(["before","center","after"].some(t=>t===e))return e};function ye({children:o,containerName:e,layoutName:t,navigationTitle:L,dropDocumentOutsideOption:S,screenKey:$}){const{direction:p,isSplit:P,boundaryContainerSize:D,afterDropTargetComponent:f,beforeDropTargetComponent:y,centerDropTargetComponent:m,setAfterDropTargetComponent:R,setBeforeDropTargetComponent:v,setCenterDropTargetComponent:a,layoutRef:N,setIsSplit:g,setDirection:B}=ae({isSplitInitial:!1,directionInitial:"row",selfContainerName:e,parentLayoutName:"",layoutName:t});return M(()=>{De(t);const u=ne(t,t).subscribe(r=>{r?(v([...r.beforeDropTargetComponent]),R([...r.afterDropTargetComponent]),a([...r.centerDropTargetComponent]),B(r.direction),(r.beforeDropTargetComponent.length!==0||r.afterDropTargetComponent.length!==0)&&g(!0)):F(t,t,{afterDropTargetComponent:[],beforeDropTargetComponent:[],centerDropTargetComponent:[{containerName:e,component:o,navigationTitle:L,dropDocumentOutsideOption:S,screenKey:$||Array.from(window.crypto.getRandomValues(new Uint32Array(16)),l=>l.toString(32).padStart(2,"0")).join("")}],direction:p})});return()=>{u.unsubscribe(),pe(t)}},[t,$,L,o,p]),M(()=>{const u=z.pipe(le((r,l)=>{const x=h=>{const{children:i,component:E,targetComponent:k,x:U,y:j,...K}=h||{};return K};return ce(x(r),x(l))})).subscribe(r=>{if(r.state==="remove")(r.targetParentLayoutName===t||r.targetParentLayoutName===""&&r.targetLayoutName===t)&&requestAnimationFrame(()=>{let l=k=>{if(r.nextContainerName&&r.dropTargetComponentEvent&&r.targetComponent){const U=Q({orderName:k,containerName:r.nextContainerName,parentLayoutName:"",layoutName:t,dropComponent:r.targetComponent,navigationTitle:r.dropTargetComponentEvent.navigationTitle,isUsePrefix:!0,afterDropTargetComponent:f,beforeDropTargetComponent:y,centerDropTargetComponent:m,dropDocumentOutsideOption:S,screenKey:r.dropTargetComponentEvent.screenKey});F(t,t,{...A(t,t)||{afterDropTargetComponent:f,beforeDropTargetComponent:y,centerDropTargetComponent:m,direction:p},...U}),Promise.resolve().then(()=>r.dropEndCallback&&r.dropEndCallback({x:r.x,y:r.y,containerName:e}))}};const x=A(t,t),h=I(x?.afterDropTargetComponent||f,r.targetContainerName,()=>l("after")),i=I(x?.beforeDropTargetComponent||y,r.targetContainerName,()=>l("before")),E=I(x?.centerDropTargetComponent||m,r.targetContainerName,()=>l("center"));F(t,t,{afterDropTargetComponent:h,beforeDropTargetComponent:i,centerDropTargetComponent:E,direction:p})});else if(r.state==="append"){const{x:l,y:x,dropEndCallback:h,dropTargetComponentEvent:i,orderName:E,parentOrderName:k,targetLayoutName:U,targetParentLayoutName:j,targetContainerName:K,targetComponent:G,nextContainerName:s}=r;if(N.current&&E&&l&&x&&G&&i&&U===t&&re({x:l,y:x,element:N.current})){const{direction:n,navigationTitle:d,dropDocumentOutsideOption:C}=i,b=E!=="center",O=E==="center"&&m.length<=1;if(b||O)if(g(!0),b){B(n);const T=Q({orderName:E,parentOrderName:k,containerName:K,nextContainerName:s,dropComponent:G,parentLayoutName:"",layoutName:t,navigationTitle:d,isUsePrefix:!0,afterDropTargetComponent:f,beforeDropTargetComponent:y,centerDropTargetComponent:m,dropDocumentOutsideOption:C});F(t,t,{afterDropTargetComponent:f,beforeDropTargetComponent:y,centerDropTargetComponent:m,direction:n,...T,direction:n}),Promise.resolve().then(()=>h&&h({x:r.x,y:r.y,containerName:e}))}else{const T=A(t,`${t}_center=${m[0].screenKey}`)||{afterDropTargetComponent:[],beforeDropTargetComponent:[],centerDropTargetComponent:[],direction:p};F(t,`${t}_center=${m[0].screenKey}`,{...T,centerDropTargetComponent:[m[0],{containerName:`${K}_${t}_${E}`,component:G,dropDocumentOutsideOption:C,screenKey:i.screenKey,navigationTitle:d}]})}}}});return()=>{u.unsubscribe()}},[p,t,P,y,f,m]),Y("div",{className:`${q["flex-split-screen"]}`,ref:N,children:[Y(se,{direction:p,layoutName:t,"data-is_split":P,panelMovementMode:"bulldozer",children:[y.length!=0?c(X,{children:y.map(({containerName:u,component:r,navigationTitle:l,dropDocumentOutsideOption:x,screenKey:h},i)=>c(H,{containerName:u,isInitialResizable:!0,isResizePanel:!0,children:c(V,{parentDirection:p,layoutName:`${t}_before`,parentLayoutName:t,containerName:u,depth:1,rootRef:N,screenKey:h,initialCenterComponents:[{navigationTitle:l,component:r,containerName:u,dropDocumentOutsideOption:x,screenKey:h}],rootName:t})},u))}):c("div",{}),m.length===0?c("div",{}):c(H,{containerName:`${m[0].containerName}`,isInitialResizable:!0,isResizePanel:P,children:P?c(V,{parentDirection:p,layoutName:`${t}_center`,parentLayoutName:t,containerName:`${m[0].containerName}`,depth:0,rootRef:N,screenKey:m[0].screenKey,initialCenterComponents:[{navigationTitle:m[0].navigationTitle,component:m[0].component,containerName:m[0].containerName,dropDocumentOutsideOption:m[0].dropDocumentOutsideOption,screenKey:m[0].screenKey}],rootName:t}):c(me,{keyName:m[0].containerName,isDefaultScrollStyle:!0,children:m[0].component})}),f.length!=0?c(X,{children:f.map(({containerName:u,component:r,navigationTitle:l,dropDocumentOutsideOption:x,screenKey:h},i)=>c(H,{containerName:u,isInitialResizable:!0,isResizePanel:f.length-1!==i,children:c(V,{parentDirection:p,layoutName:`${t}_after`,parentLayoutName:t,containerName:u,depth:1,rootRef:N,screenKey:h,initialCenterComponents:[{navigationTitle:l,component:r,containerName:u,dropDocumentOutsideOption:x,screenKey:h}],rootName:t})},u))}):c("div",{})]}),D&&c("div",{className:`${q["flex-split-screen-boundary-container"]}`,style:{...D},children:"\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."})]})}function V({containerName:o,layoutName:e,parentLayoutName:t,parentDirection:L,depth:S,rootRef:$,rootName:p,initialCenterComponents:P,screenKey:D}){const{direction:f,isSplit:y,boundaryContainerSize:m,afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:a,setAfterDropTargetComponent:N,setBeforeDropTargetComponent:g,setCenterDropTargetComponent:B,layoutRef:u,setIsSplit:r,setDirection:l}=ae({isSplitInitial:!1,directionInitial:"row",parentDirection:L,selfContainerName:o,parentLayoutName:t,layoutName:e}),[x,h]=te(!1),[i,E]=te(0),k=ee(a),U=ee(P??[]),j=ee(i);M(()=>{const s=`${e}=${D}`,n=ne(p,s).pipe(Te(1)).subscribe(d=>{d||F(p,s,{afterDropTargetComponent:[],beforeDropTargetComponent:[],centerDropTargetComponent:U.current,direction:f})});return()=>{ue(p,`${e}=${D}`),n.unsubscribe()}},[p,e,D]),M(()=>{const s=ne(p,`${e}=${D}`).subscribe(n=>{n&&(g([...n.beforeDropTargetComponent]),N([...n.afterDropTargetComponent]),B([...n.centerDropTargetComponent]),l(n.direction),n.beforeDropTargetComponent.length!==0||n.afterDropTargetComponent.length!==0?r(!0):n.beforeDropTargetComponent.length===0&&n.centerDropTargetComponent.length===0&&n.afterDropTargetComponent.length===0&&(z.next({state:"remove",targetContainerName:o,targetParentLayoutName:"",targetLayoutName:t}),h(!0)))});return()=>{s.unsubscribe(),pe(e)}},[p,e]),M(()=>{const s=z.pipe(le((n,d)=>{const C=b=>{const{children:O,component:T,targetComponent:w,x:_,y:J,...W}=b||{};return W};return ce(C(n),C(d))})).subscribe(n=>{if(n.state==="remove")(n.targetParentLayoutName===e||n.targetParentLayoutName===""&&n.targetLayoutName===e)&&requestAnimationFrame(()=>{let d=w=>{if(n.nextContainerName&&n.dropTargetComponentEvent&&n.targetComponent){const _=Q({orderName:w,containerName:n.nextContainerName,parentLayoutName:t,layoutName:e,dropComponent:n.targetComponent,navigationTitle:n.dropTargetComponentEvent.navigationTitle,isUsePrefix:!0,afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:a,dropDocumentOutsideOption:n.dropTargetComponentEvent?.dropDocumentOutsideOption,screenKey:n.dropTargetComponentEvent.screenKey});F(p,`${e}=${D}`,{...A(p,`${e}=${D}`)||{afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:a,direction:f},..._}),Promise.resolve().then(()=>n.dropEndCallback&&n.dropEndCallback({x:n.x,y:n.y,containerName:o}))}};const C=A(p,`${e}=${D}`),b=I(C?.afterDropTargetComponent||R,n.targetContainerName,()=>d("after")),O=I(C?.beforeDropTargetComponent||v,n.targetContainerName,()=>d("before")),T=I(C?.centerDropTargetComponent||a,n.targetContainerName,()=>d("center"));F(p,`${e}=${D}`,{afterDropTargetComponent:b,beforeDropTargetComponent:O,centerDropTargetComponent:T,direction:f})});else if(n.state==="append"){const{x:d,y:C,dropEndCallback:b,dropTargetComponentEvent:O,orderName:T,targetLayoutName:w,targetParentLayoutName:_,targetContainerName:J,targetComponent:W,nextContainerName:ge,parentOrderName:Ce}=n;if(u.current&&T&&d&&C&&O&&re({x:d,y:C,element:u.current})){const{direction:Z,navigationTitle:oe,dropDocumentOutsideOption:ie,screenKey:ve}=O;if(w===e&&W)if(Z===L&&T!=="center")z.next({state:"append",targetContainerName:J,targetParentLayoutName:"",targetLayoutName:t,targetComponent:W,nextContainerName:o,parentOrderName:$e(e)||T,orderName:T,x:d,y:C,dropEndCallback:b,dropTargetComponentEvent:{navigationTitle:oe,dropDocumentOutsideOption:ie,direction:L,screenKey:D}});else{T!=="center"&&(l(Z),r(!0));const de=Q({orderName:T,parentOrderName:Ce,containerName:J,nextContainerName:ge,parentLayoutName:t,layoutName:e,dropComponent:W,navigationTitle:oe,isUsePrefix:T!=="center",afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:a,dropDocumentOutsideOption:ie});F(p,`${e}=${D}`,{...A(p,`${e}=${D}`)||{afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:a,direction:f},...de,direction:Z}),Promise.resolve().then(()=>n.dropEndCallback&&n.dropEndCallback({x:n.x,y:n.y,containerName:o}))}}}});return()=>{s.unsubscribe()}},[f,L,t,e,v,R,a]),M(()=>{k.current=a},[a]),M(()=>{j.current=i},[i]);const[K,G]=te(!1);return c(X,{children:!x&&Y("div",{className:`${q["flex-split-screen"]}`,ref:u,children:[Y(se,{direction:f,layoutName:`${e}`,panelMovementMode:"bulldozer",children:[v.length!=0?c(X,{children:v.map(({containerName:s,component:n,navigationTitle:d,dropDocumentOutsideOption:C,screenKey:b},O)=>c(H,{containerName:s,isInitialResizable:!0,isResizePanel:!0,children:c(V,{parentDirection:f,layoutName:`${e}_before-${S}`,parentLayoutName:e,containerName:s,depth:S+1,rootRef:$,screenKey:b,initialCenterComponents:[{navigationTitle:d,component:n,containerName:s,dropDocumentOutsideOption:C,screenKey:b}],rootName:p})},s))}):c("div",{}),a.length!=0?c(X,{children:c(H,{containerName:`${(a[i]||a[0]).containerName}`,isInitialResizable:!0,isResizePanel:y,children:y?c("div",{"data-key":D,children:c(V,{parentDirection:f,layoutName:`${e}_center-${S}`,parentLayoutName:e,containerName:`${(a[i]||a[0]).containerName}`,depth:S+1,rootRef:$,initialCenterComponents:a.map(({navigationTitle:s,component:n,containerName:d,dropDocumentOutsideOption:C,screenKey:b})=>({navigationTitle:s,component:n,containerName:d,dropDocumentOutsideOption:C,screenKey:b})),screenKey:D,rootName:p})}):Y(me,{keyName:(a[i]||a[0]).containerName,isDefaultScrollStyle:!0,children:[!K&&c("div",{className:`${q["flex-split-screen-drag-box-title-wrapper-sticky"]}`,children:Y("div",{"data-is_split":y,"data-layout_name":e,"data-parent_layout_name":t,"data-container_name":`${(a[i]||a[0]).containerName}`,className:`${q["flex-split-screen-drag-box-title-wrapper"]}`,children:[c(Se,{"data-layout_name":e,layoutName:e,children:a.map((s,n)=>c(xe,{onClose:d=>{j.current===n&&a.length===1?z.next({state:"remove",targetContainerName:o,targetParentLayoutName:t,targetLayoutName:e}):(a.length===j.current+1&&E(j.current-1),B(C=>{const b=I(C,s.containerName,()=>{}),O=`${e}=${D}`,T=A(p,O)||{afterDropTargetComponent:R,beforeDropTargetComponent:v,centerDropTargetComponent:C,direction:f};return F(p,O,{...T,centerDropTargetComponent:b}),b}))},isActive:i===n,children:c(be,{screenKey:s.screenKey,onClick:()=>{E(n)},containerName:s.containerName,dropDocumentOutsideOption:s.dropDocumentOutsideOption,targetComponent:s.component,navigationTitle:s.navigationTitle,"data-container-name":s.containerName,"data-layout-name":e,"data-parent-layout-name":t,dropEndCallback:({x:d,y:C,containerName:b})=>{if(!$.current||!u.current)return;const O=he({x:d,y:C,element:$.current}),T=re({x:d,y:C,element:u.current});if(!O&&!T||!O&&T&&k.current.length>1){const w={};if(k.current.length>1){const{adjacentItem:_,adjacentIndex:J}=Oe(k.current,j.current);_&&j.current===n&&Object.assign(w,{x:d,y:C,targetComponent:_.component,nextContainerName:_.containerName,orderName:"center",dropTargetComponentEvent:{navigationTitle:_.navigationTitle,dropDocumentOutsideOption:_.dropDocumentOutsideOption,direction:f,screenKey:D}})}n===0?z.next({state:"remove",targetContainerName:s.containerName,targetParentLayoutName:t,targetLayoutName:e,...w}):z.next({state:"remove",targetContainerName:s.containerName,targetParentLayoutName:"",targetLayoutName:e,...w})}},children:s.navigationTitle})},s.navigationTitle+e+s.containerName))},e),c(Le,{})]})}),(a[i]||a[0]).component]})},(a[i]||a[0]).containerName)}):c("div",{}),R.length!=0?c(X,{children:R.map(({containerName:s,component:n,navigationTitle:d,dropDocumentOutsideOption:C,screenKey:b},O)=>c(H,{containerName:s,isInitialResizable:!0,isResizePanel:O!==R.length-1,children:c(V,{parentDirection:f,layoutName:`${e}_after-${S}`,parentLayoutName:e,containerName:s,depth:S+1,rootRef:$,screenKey:b,initialCenterComponents:[{navigationTitle:d,component:n,containerName:s,dropDocumentOutsideOption:C,screenKey:b}],rootName:p})},s))}):c("div",{})]}),m&&c("div",{className:`${q["flex-split-screen-boundary-container"]}`,style:{...m},children:"\u2B07\uFE0F\uB4DC\uB86D\uD558\uBA74 \uD654\uBA74\uC774 \uBD84\uD560\uB429\uB2C8\uB2E4."})]})})}export{ye as default};
|