@byeolnaerim/flex-layout 0.0.7 → 0.0.9
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 +62 -28
- package/dist/flex-layout/components/FlexLayout.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayout.js +26 -11
- package/dist/flex-layout/components/FlexLayout.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +121 -55
- package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutContainer.js +68 -25
- package/dist/flex-layout/components/FlexLayoutContainer.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +68 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs.map +1 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.d.ts +4 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.js +44 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.js.map +1 -0
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +111 -46
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js +68 -27
- package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +184 -143
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js +71 -32
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +253 -60
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +215 -39
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +40 -17
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +7 -7
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +44 -21
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +7 -8
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +40 -17
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +5 -6
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +53 -29
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +14 -10
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +1 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +46 -27
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +1 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +1 -0
- package/dist/flex-layout/components/FlexLayoutStickyBox.js +13 -8
- package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +1 -1
- package/dist/flex-layout/components/index.cjs +54 -49
- package/dist/flex-layout/components/index.cjs.map +1 -1
- package/dist/flex-layout/components/index.js +16 -8
- package/dist/flex-layout/components/index.js.map +1 -1
- package/dist/flex-layout/hooks/index.cjs +23 -19
- package/dist/flex-layout/hooks/index.cjs.map +1 -1
- package/dist/flex-layout/hooks/index.js +2 -3
- package/dist/flex-layout/hooks/index.js.map +1 -1
- package/dist/flex-layout/hooks/useDrag.cjs +136 -79
- package/dist/flex-layout/hooks/useDrag.cjs.map +1 -1
- package/dist/flex-layout/hooks/useDrag.d.ts +5 -0
- package/dist/flex-layout/hooks/useDrag.js +86 -47
- package/dist/flex-layout/hooks/useDrag.js.map +1 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +40 -19
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +1 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +9 -7
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +1 -1
- package/dist/flex-layout/hooks/useListPaging.cjs +68 -35
- package/dist/flex-layout/hooks/useListPaging.cjs.map +1 -1
- package/dist/flex-layout/hooks/useListPaging.js +34 -18
- package/dist/flex-layout/hooks/useListPaging.js.map +1 -1
- package/dist/flex-layout/hooks/useSizes.cjs +45 -23
- package/dist/flex-layout/hooks/useSizes.cjs.map +1 -1
- package/dist/flex-layout/hooks/useSizes.js +6 -6
- package/dist/flex-layout/hooks/useSizes.js.map +1 -1
- package/dist/flex-layout/index.cjs +29 -40
- package/dist/flex-layout/index.cjs.map +1 -1
- package/dist/flex-layout/index.js +5 -6
- package/dist/flex-layout/index.js.map +1 -1
- package/dist/flex-layout/providers/FlexLayoutContext.cjs +35 -12
- package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +1 -1
- package/dist/flex-layout/providers/FlexLayoutContext.js +7 -6
- package/dist/flex-layout/providers/FlexLayoutContext.js.map +1 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs +82 -53
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +1 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js +33 -8
- package/dist/flex-layout/providers/FlexLayoutHooks.js.map +1 -1
- package/dist/flex-layout/providers/index.cjs +21 -12
- package/dist/flex-layout/providers/index.cjs.map +1 -1
- package/dist/flex-layout/providers/index.js +1 -2
- package/dist/flex-layout/providers/index.js.map +1 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +130 -76
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +1 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +1 -0
- package/dist/flex-layout/store/FlexLayoutContainerStore.js +63 -38
- package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +1 -1
- package/dist/flex-layout/store/index.cjs +21 -12
- package/dist/flex-layout/store/index.cjs.map +1 -1
- package/dist/flex-layout/store/index.js +1 -2
- package/dist/flex-layout/store/index.js.map +1 -1
- package/dist/flex-layout/types/FlexDirectionTypes.cjs +16 -3
- package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +1 -1
- package/dist/flex-layout/types/FlexDirectionTypes.js +0 -2
- package/dist/flex-layout/types/FlexDirectionTypes.js.map +1 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs +16 -3
- package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +1 -1
- package/dist/flex-layout/types/FlexLayoutTypes.d.ts +1 -3
- package/dist/flex-layout/types/FlexLayoutTypes.js +0 -2
- package/dist/flex-layout/types/FlexLayoutTypes.js.map +1 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs +57 -20
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +1 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +4 -4
- package/dist/flex-layout/utils/FlexLayoutUtils.js +23 -8
- package/dist/flex-layout/utils/FlexLayoutUtils.js.map +1 -1
- package/dist/flex-layout/utils/index.cjs +21 -12
- package/dist/flex-layout/utils/index.cjs.map +1 -1
- package/dist/flex-layout/utils/index.js +1 -2
- package/dist/flex-layout/utils/index.js.map +1 -1
- package/dist/index.cjs +21 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/types/css.d.cjs +1 -3
- package/dist/types/css.d.cjs.map +1 -1
- package/dist/types/css.d.js +0 -2
- package/dist/types/css.d.js.map +1 -1
- package/package.json +5 -1
|
@@ -1,33 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var FlexLayoutContainerStore_exports = {};
|
|
31
|
+
__export(FlexLayoutContainerStore_exports, {
|
|
32
|
+
flexContainerStore: () => flexContainerStore,
|
|
33
|
+
flexResizePanelStore: () => flexResizePanelStore,
|
|
34
|
+
getContainerRef: () => getContainerRef,
|
|
35
|
+
getCurrentSplitScreenComponents: () => getCurrentSplitScreenComponents,
|
|
36
|
+
getLayoutInfos: () => getLayoutInfos,
|
|
37
|
+
getResizePanelRef: () => getResizePanelRef,
|
|
38
|
+
getScrollPosition: () => getScrollPosition,
|
|
39
|
+
getSplitScreen: () => getSplitScreen,
|
|
40
|
+
layoutSplitScreenStore: () => layoutSplitScreenStore,
|
|
41
|
+
removeRootSplitScreen: () => removeRootSplitScreen,
|
|
42
|
+
removeScrollPosition: () => removeScrollPosition,
|
|
43
|
+
removeSplitScreenChild: () => removeSplitScreenChild,
|
|
44
|
+
resetRootSplitScreen: () => resetRootSplitScreen,
|
|
45
|
+
scrollPositions: () => scrollPositions,
|
|
46
|
+
setContainerRef: () => setContainerRef,
|
|
47
|
+
setResizePanelRef: () => setResizePanelRef,
|
|
48
|
+
setScrollPosition: () => setScrollPosition,
|
|
49
|
+
setSplitScreen: () => setSplitScreen
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(FlexLayoutContainerStore_exports);
|
|
52
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
53
|
+
var import_rxjs = require("rxjs");
|
|
54
|
+
var import_operators = require("rxjs/operators");
|
|
11
55
|
function updateScrollStore(subject, newValue) {
|
|
12
56
|
const currentValue = subject.getValue();
|
|
13
|
-
if (!
|
|
57
|
+
if (!(0, import_fast_deep_equal.default)(currentValue, newValue)) {
|
|
14
58
|
subject.next(newValue);
|
|
15
59
|
}
|
|
16
60
|
}
|
|
17
|
-
function updateRefStore(store, newState) {
|
|
18
|
-
const prevState = store.getValue();
|
|
19
|
-
if (!equal__default.default(prevState, newState)) {
|
|
20
|
-
store.next(newState);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
61
|
function updateSplitScreenStore(newValue) {
|
|
24
|
-
|
|
25
|
-
if (!equal__default.default(prevValue, newValue)) {
|
|
26
|
-
layoutSplitScreenStore.next(newValue);
|
|
27
|
-
}
|
|
62
|
+
layoutSplitScreenStore.next(newValue);
|
|
28
63
|
}
|
|
29
64
|
const scrollPositions = {};
|
|
30
|
-
const scrollPositionsSubject = new
|
|
65
|
+
const scrollPositionsSubject = new import_rxjs.BehaviorSubject(scrollPositions);
|
|
31
66
|
const setScrollPosition = (layoutName, position) => {
|
|
32
67
|
const current = scrollPositionsSubject.getValue();
|
|
33
68
|
const prevPos = current[layoutName];
|
|
@@ -43,20 +78,19 @@ const setScrollPosition = (layoutName, position) => {
|
|
|
43
78
|
const getScrollPosition = (layoutName) => {
|
|
44
79
|
return scrollPositionsSubject.pipe(
|
|
45
80
|
// 해당 layoutName이 정의되지 않았을 때는 제외
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
(0, import_operators.filter)((e) => e[layoutName] !== void 0),
|
|
82
|
+
(0, import_operators.map)((positions) => positions[layoutName]),
|
|
83
|
+
(0, import_operators.distinctUntilChanged)(
|
|
49
84
|
(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y
|
|
50
85
|
)
|
|
51
86
|
);
|
|
52
87
|
};
|
|
53
88
|
const removeScrollPosition = (layoutName) => {
|
|
54
89
|
const current = scrollPositionsSubject.getValue();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
updateScrollStore(scrollPositionsSubject, newPositions);
|
|
90
|
+
const { [layoutName]: _, ...rest } = current;
|
|
91
|
+
updateScrollStore(scrollPositionsSubject, rest);
|
|
58
92
|
};
|
|
59
|
-
const layoutSplitScreenStore = new
|
|
93
|
+
const layoutSplitScreenStore = new import_rxjs.BehaviorSubject({});
|
|
60
94
|
const setSplitScreen = (rootName, layoutName, newComponents) => {
|
|
61
95
|
const current = layoutSplitScreenStore.getValue();
|
|
62
96
|
const updatedLayout = { ...current[rootName] || {} };
|
|
@@ -75,6 +109,12 @@ const resetRootSplitScreen = (rootName) => {
|
|
|
75
109
|
};
|
|
76
110
|
updateSplitScreenStore(newStoreValue);
|
|
77
111
|
};
|
|
112
|
+
const removeRootSplitScreen = (rootName) => {
|
|
113
|
+
const current = layoutSplitScreenStore.getValue();
|
|
114
|
+
if (!current[rootName]) return;
|
|
115
|
+
const { [rootName]: _, ...rest } = current;
|
|
116
|
+
updateSplitScreenStore(rest);
|
|
117
|
+
};
|
|
78
118
|
const removeSplitScreenChild = (rootName, layoutName) => {
|
|
79
119
|
const current = layoutSplitScreenStore.getValue();
|
|
80
120
|
if (!current[rootName]) return;
|
|
@@ -93,49 +133,59 @@ const getCurrentSplitScreenComponents = (rootName, layoutName) => {
|
|
|
93
133
|
};
|
|
94
134
|
const getSplitScreen = (rootName, layoutName) => {
|
|
95
135
|
return layoutSplitScreenStore.pipe(
|
|
96
|
-
|
|
97
|
-
|
|
136
|
+
(0, import_operators.map)((splitScreen) => splitScreen[rootName]?.[layoutName]),
|
|
137
|
+
(0, import_operators.distinctUntilChanged)((prev, curr) => {
|
|
98
138
|
const filterChildren = (obj) => {
|
|
99
139
|
const { children, component, targetComponent, x, y, ...rest } = obj || {};
|
|
100
140
|
return rest;
|
|
101
141
|
};
|
|
102
|
-
return
|
|
142
|
+
return (0, import_fast_deep_equal.default)(filterChildren(prev), filterChildren(curr));
|
|
103
143
|
})
|
|
104
144
|
);
|
|
105
145
|
};
|
|
106
|
-
const flexContainerStore = new
|
|
107
|
-
const flexResizePanelStore = new
|
|
146
|
+
const flexContainerStore = new import_rxjs.BehaviorSubject({});
|
|
147
|
+
const flexResizePanelStore = new import_rxjs.BehaviorSubject({});
|
|
108
148
|
const setContainerRef = (layoutName, containerName, ref) => {
|
|
109
149
|
const currentRefs = flexContainerStore.getValue();
|
|
110
|
-
const
|
|
150
|
+
const layoutRefs = currentRefs[layoutName] || {};
|
|
111
151
|
if (ref === null) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
152
|
+
if (!(containerName in layoutRefs)) return;
|
|
153
|
+
const { [containerName]: _, ...restLayout } = layoutRefs;
|
|
154
|
+
const next = Object.keys(restLayout).length === 0 ? (() => {
|
|
155
|
+
const { [layoutName]: __, ...rest } = currentRefs;
|
|
156
|
+
return rest;
|
|
157
|
+
})() : { ...currentRefs, [layoutName]: restLayout };
|
|
158
|
+
flexContainerStore.next(next);
|
|
159
|
+
return;
|
|
115
160
|
}
|
|
116
|
-
|
|
161
|
+
if (layoutRefs[containerName] === ref) return;
|
|
162
|
+
flexContainerStore.next({
|
|
117
163
|
...currentRefs,
|
|
118
|
-
[layoutName]:
|
|
119
|
-
};
|
|
120
|
-
updateRefStore(flexContainerStore, newRefs);
|
|
164
|
+
[layoutName]: { ...layoutRefs, [containerName]: ref }
|
|
165
|
+
});
|
|
121
166
|
};
|
|
122
167
|
const setResizePanelRef = (layoutName, containerName, ref) => {
|
|
123
168
|
const currentRefs = flexResizePanelStore.getValue();
|
|
124
|
-
const
|
|
169
|
+
const layoutRefs = currentRefs[layoutName] || {};
|
|
125
170
|
if (ref === null) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
if (!(containerName in layoutRefs)) return;
|
|
172
|
+
const { [containerName]: _, ...restLayout } = layoutRefs;
|
|
173
|
+
const next = Object.keys(restLayout).length === 0 ? (() => {
|
|
174
|
+
const { [layoutName]: __, ...rest } = currentRefs;
|
|
175
|
+
return rest;
|
|
176
|
+
})() : { ...currentRefs, [layoutName]: restLayout };
|
|
177
|
+
flexResizePanelStore.next(next);
|
|
178
|
+
return;
|
|
129
179
|
}
|
|
130
|
-
|
|
180
|
+
if (layoutRefs[containerName] === ref) return;
|
|
181
|
+
flexResizePanelStore.next({
|
|
131
182
|
...currentRefs,
|
|
132
|
-
[layoutName]:
|
|
133
|
-
};
|
|
134
|
-
updateRefStore(flexResizePanelStore, newRefs);
|
|
183
|
+
[layoutName]: { ...layoutRefs, [containerName]: ref }
|
|
184
|
+
});
|
|
135
185
|
};
|
|
136
186
|
const getLayoutInfos = (layoutName) => {
|
|
137
|
-
return
|
|
138
|
-
|
|
187
|
+
return (0, import_rxjs.combineLatest)([flexContainerStore, flexResizePanelStore]).pipe(
|
|
188
|
+
(0, import_operators.map)(([containerRefs, resizePanelRefs]) => {
|
|
139
189
|
const containerData = containerRefs[layoutName] || {};
|
|
140
190
|
const resizePanelData = resizePanelRefs[layoutName] || {};
|
|
141
191
|
return {
|
|
@@ -143,7 +193,9 @@ const getLayoutInfos = (layoutName) => {
|
|
|
143
193
|
resizePanel: resizePanelData
|
|
144
194
|
};
|
|
145
195
|
}),
|
|
146
|
-
|
|
196
|
+
(0, import_operators.filter)(
|
|
197
|
+
(result) => result.container !== null && Object.keys(result.container).length > 0
|
|
198
|
+
)
|
|
147
199
|
// 빈 객체 제외
|
|
148
200
|
);
|
|
149
201
|
};
|
|
@@ -152,7 +204,7 @@ const getContainerRef = ({
|
|
|
152
204
|
layoutName
|
|
153
205
|
}) => {
|
|
154
206
|
return flexContainerStore.pipe(
|
|
155
|
-
|
|
207
|
+
(0, import_operators.map)((refs) => {
|
|
156
208
|
if (layoutName) {
|
|
157
209
|
return refs[layoutName]?.[containerName] || null;
|
|
158
210
|
} else {
|
|
@@ -161,7 +213,7 @@ const getContainerRef = ({
|
|
|
161
213
|
)?.[1][containerName];
|
|
162
214
|
}
|
|
163
215
|
}),
|
|
164
|
-
|
|
216
|
+
(0, import_operators.filter)((ref) => ref !== null)
|
|
165
217
|
);
|
|
166
218
|
};
|
|
167
219
|
const getResizePanelRef = ({
|
|
@@ -169,7 +221,7 @@ const getResizePanelRef = ({
|
|
|
169
221
|
layoutName
|
|
170
222
|
}) => {
|
|
171
223
|
return flexResizePanelStore.pipe(
|
|
172
|
-
|
|
224
|
+
(0, import_operators.map)((refs) => {
|
|
173
225
|
if (layoutName) {
|
|
174
226
|
return refs[layoutName]?.[containerName] || null;
|
|
175
227
|
} else {
|
|
@@ -178,26 +230,28 @@ const getResizePanelRef = ({
|
|
|
178
230
|
)?.[1][containerName];
|
|
179
231
|
}
|
|
180
232
|
}),
|
|
181
|
-
|
|
233
|
+
(0, import_operators.filter)((ref) => ref !== null)
|
|
182
234
|
);
|
|
183
235
|
};
|
|
184
|
-
|
|
185
|
-
exports
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
236
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
237
|
+
0 && (module.exports = {
|
|
238
|
+
flexContainerStore,
|
|
239
|
+
flexResizePanelStore,
|
|
240
|
+
getContainerRef,
|
|
241
|
+
getCurrentSplitScreenComponents,
|
|
242
|
+
getLayoutInfos,
|
|
243
|
+
getResizePanelRef,
|
|
244
|
+
getScrollPosition,
|
|
245
|
+
getSplitScreen,
|
|
246
|
+
layoutSplitScreenStore,
|
|
247
|
+
removeRootSplitScreen,
|
|
248
|
+
removeScrollPosition,
|
|
249
|
+
removeSplitScreenChild,
|
|
250
|
+
resetRootSplitScreen,
|
|
251
|
+
scrollPositions,
|
|
252
|
+
setContainerRef,
|
|
253
|
+
setResizePanelRef,
|
|
254
|
+
setScrollPosition,
|
|
255
|
+
setSplitScreen
|
|
256
|
+
});
|
|
203
257
|
//# sourceMappingURL=FlexLayoutContainerStore.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/flex-layout/store/FlexLayoutContainerSt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IAAA,KAAmB;AACvB,MAAA,IAAI,UAAA,EAAY;AAEf,QAAA,OAAO,IAAA,CAAK,UAAU,CAAA,GAAI,aAAa,CAAA,IAAK,IAAA;AAAA,MAC7C,CAAA,MAAO;AAEN,QAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,IAAA;AAAA,UAC3B,CAAC,CAAC,GAAA,EAAK,KAAK,MAAM,IAAA,CAAK,GAAG,EAAE,aAAa;AAAA,SAC1C,GAAI,CAAC,CAAA,CAAE,aAAa,CAAA;AAAA,MACrB;AAAA,IAUD,CAAC,CAAA;AAAA,IACDD,gBAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,KAAQ,IAAI;AAAA,GAC7B;AACD","file":"FlexLayoutContainerStore.cjs","sourcesContent":["\"use client\";\r\nimport equal from \"fast-deep-equal\";\r\nimport { RefObject } from \"react\";\r\nimport { BehaviorSubject, combineLatest } from \"rxjs\";\r\nimport { distinctUntilChanged, filter, map } from \"rxjs/operators\";\r\nimport { DropTargetComponent } from \"../hooks/useDrag\";\r\n\r\n/**\r\n * 이전 값과 새 값이 동일하지 않을 때만 store를 업데이트하는 유틸 함수\r\n */\r\nfunction updateScrollStore<T>(subject: BehaviorSubject<T>, newValue: T) {\r\n\tconst currentValue = subject.getValue();\r\n\t// deep 비교를 통해 실제 변경이 있는 경우만 next\r\n\tif (!equal(currentValue, newValue)) {\r\n\t\tsubject.next(newValue);\r\n\t}\r\n}\r\n// 동일한지 확인 후 업데이트하는 유틸\r\nfunction updateRefStore(store: BehaviorSubject<RefStore>, newState: RefStore) {\r\n\tconst prevState = store.getValue();\r\n\tif (!equal(prevState, newState)) {\r\n\t\tstore.next(newState);\r\n\t}\r\n}\r\n\r\nfunction updateSplitScreenStore(newValue: LayoutSplitScreenState) {\r\n\tconst prevValue = layoutSplitScreenStore.getValue();\r\n\t// deep-equal 로 비교\r\n\tif (!equal(prevValue, newValue)) {\r\n\t\tlayoutSplitScreenStore.next(newValue);\r\n\t}\r\n}\r\n\r\n// 구독 시 이전 상태들을 축적하여 관리\r\n// const stateWithHistory$ = flexContainerStore.pipe(\r\n// scan((acc, newState) => [...acc, newState], [] as RefStore[])\r\n// );\r\n\r\nexport interface ScrollPosition {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport const scrollPositions: Record<string, ScrollPosition> = {};\r\n\r\nconst scrollPositionsSubject = new BehaviorSubject<\r\n\tRecord<string, ScrollPosition>\r\n>(scrollPositions);\r\n\r\n/**\r\n * 스크롤 위치 업데이트 함수\r\n *\r\n * 기존: 항상 store.next()가 호출됨 → 바뀌지 않았다면 건너뛰도록 변경\r\n */\r\nexport const setScrollPosition = (\r\n\tlayoutName: string,\r\n\tposition: ScrollPosition,\r\n) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst prevPos = current[layoutName];\r\n\r\n\t// x, y 모두 동일하면 업데이트할 필요가 없으므로 조기 반환\r\n\tif (prevPos && prevPos.x === position.x && prevPos.y === position.y) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// 변경사항이 있으면 새 객체를 만들어 넘김\r\n\tconst newPositions = {\r\n\t\t...current,\r\n\t\t[layoutName]: position,\r\n\t};\r\n\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\n/**\r\n * 스크롤 위치 구독\r\n */\r\nexport const getScrollPosition = (layoutName: string) => {\r\n\treturn scrollPositionsSubject.pipe(\r\n\t\t// 해당 layoutName이 정의되지 않았을 때는 제외\r\n\t\tfilter((e) => e[layoutName] !== undefined),\r\n\t\tmap((positions) => positions[layoutName]),\r\n\t\tdistinctUntilChanged(\r\n\t\t\t(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y,\r\n\t\t),\r\n\t);\r\n};\r\n\r\nexport const removeScrollPosition = (layoutName: string) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tdelete current[layoutName];\r\n\r\n\t// 꼭 삭제 후에도 이전 상태와 달라졌는지 확인\r\n\tconst newPositions = { ...current };\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\nexport type SplitScreenComponents = {\r\n\tafterDropTargetComponent: DropTargetComponent[];\r\n\tbeforeDropTargetComponent: DropTargetComponent[];\r\n\tcenterDropTargetComponent: DropTargetComponent[];\r\n\tdirection: \"row\" | \"column\";\r\n};\r\n\r\nexport type LayoutSplitScreenState = Record<\r\n\tstring,\r\n\tRecord<string, SplitScreenComponents>\r\n>;\r\n\r\nexport const layoutSplitScreenStore =\r\n\tnew BehaviorSubject<LayoutSplitScreenState>({});\r\n\r\nexport const setSplitScreen = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n\tnewComponents: SplitScreenComponents,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tconst updatedLayout = { ...(current[rootName] || {}) };\r\n\tupdatedLayout[layoutName] = newComponents;\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const resetRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\t// rootName 아래만 초기화\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: {},\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const removeSplitScreenChild = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\r\n\tconst updatedLayout = { ...current[rootName] };\r\n\tdelete updatedLayout[layoutName];\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const getCurrentSplitScreenComponents = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\treturn current[rootName][layoutName];\r\n};\r\n\r\nexport const getSplitScreen = (rootName: string, layoutName: string) => {\r\n\treturn layoutSplitScreenStore.pipe(\r\n\t\tmap((splitScreen) => splitScreen[rootName][layoutName]),\r\n\t\tdistinctUntilChanged((prev, curr) => {\r\n\t\t\t// 이전 상태와 현재 상태를 비교하여 동일하면 필터링\r\n\t\t\tconst filterChildren = (obj: any) => {\r\n\t\t\t\t// 객체 복사 후 children 속성 제거\r\n\t\t\t\tconst { children, component, targetComponent, x, y, ...rest } =\r\n\t\t\t\t\tobj || {};\r\n\t\t\t\treturn rest;\r\n\t\t\t};\r\n\t\t\treturn equal(filterChildren(prev), filterChildren(curr));\r\n\t\t}),\r\n\t);\r\n};\r\n\r\n// 중첩된 객체 구조로 ref를 관리하는 타입\r\ntype RefStore = {\r\n\t[layoutName: string]: {\r\n\t\t[containerName: string]: RefObject<HTMLElement | null>;\r\n\t};\r\n};\r\n\r\n// 초기값으로 빈 객체를 설정한 BehaviorSubject 생성\r\nexport const flexContainerStore = new BehaviorSubject<RefStore>({});\r\n\r\nexport const flexResizePanelStore = new BehaviorSubject<RefStore>({});\r\n/**\r\n * ref를 업데이트하는 함수\r\n * - 기존: 무조건 next() → 새/이전 상태 비교 후 다를 경우에만 next()\r\n */\r\nexport const setContainerRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexContainerStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexContainerStore, newRefs);\r\n};\r\n\r\nexport const setResizePanelRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexResizePanelStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexResizePanelStore, newRefs);\r\n};\r\n\r\nexport const getLayoutInfos = (layoutName: string) => {\r\n\treturn combineLatest([flexContainerStore, flexResizePanelStore]).pipe(\r\n\t\tmap(([containerRefs, resizePanelRefs]) => {\r\n\t\t\t// 두 Store에서 layoutName에 해당하는 값을 병합\r\n\t\t\tconst containerData = containerRefs[layoutName] || {};\r\n\t\t\tconst resizePanelData = resizePanelRefs[layoutName] || {};\r\n\r\n\t\t\t// container와 resizePanel 데이터 합치기\r\n\t\t\treturn {\r\n\t\t\t\tcontainer: containerData,\r\n\t\t\t\tresizePanel: resizePanelData,\r\n\t\t\t};\r\n\t\t}),\r\n\t\tfilter((result) => result.container !== null), // 빈 객체 제외\r\n\t);\r\n};\r\n\r\n// 특정 containerName의 ref를 구독하는 함수\r\n// layoutName이 지정되지 않으면 전체 layout에서 해당하는 containerName의 ref를 찾음\r\nexport const getContainerRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexContainerStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n\r\nexport const getResizePanelRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexResizePanelStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/flex-layout/store/FlexLayoutContainerStore.ts"],"sourcesContent":["\"use client\";\r\nimport equal from \"fast-deep-equal\";\r\nimport { RefObject } from \"react\";\r\nimport { BehaviorSubject, combineLatest } from \"rxjs\";\r\nimport { distinctUntilChanged, filter, map } from \"rxjs/operators\";\r\nimport { DropTargetComponent } from \"../hooks/useDrag\";\r\n\r\n/**\r\n * 이전 값과 새 값이 동일하지 않을 때만 store를 업데이트하는 유틸 함수\r\n */\r\nfunction updateScrollStore<T>(subject: BehaviorSubject<T>, newValue: T) {\r\n\tconst currentValue = subject.getValue();\r\n\t// deep 비교를 통해 실제 변경이 있는 경우만 next\r\n\tif (!equal(currentValue, newValue)) {\r\n\t\tsubject.next(newValue);\r\n\t}\r\n}\r\n\r\nfunction updateSplitScreenStore(newValue: LayoutSplitScreenState) {\r\n\t// const prevValue = layoutSplitScreenStore.getValue();\r\n\t// deep-equal 로 비교\r\n\t// if (!equal(prevValue, newValue)) {\r\n\tlayoutSplitScreenStore.next(newValue);\r\n\t// }\r\n}\r\n\r\n// 구독 시 이전 상태들을 축적하여 관리\r\n// const stateWithHistory$ = flexContainerStore.pipe(\r\n// scan((acc, newState) => [...acc, newState], [] as RefStore[])\r\n// );\r\n\r\nexport interface ScrollPosition {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport const scrollPositions: Record<string, ScrollPosition> = {};\r\n\r\nconst scrollPositionsSubject = new BehaviorSubject<\r\n\tRecord<string, ScrollPosition>\r\n>(scrollPositions);\r\n\r\n/**\r\n * 스크롤 위치 업데이트 함수\r\n *\r\n * 기존: 항상 store.next()가 호출됨 → 바뀌지 않았다면 건너뛰도록 변경\r\n */\r\nexport const setScrollPosition = (\r\n\tlayoutName: string,\r\n\tposition: ScrollPosition,\r\n) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst prevPos = current[layoutName];\r\n\r\n\t// x, y 모두 동일하면 업데이트할 필요가 없으므로 조기 반환\r\n\tif (prevPos && prevPos.x === position.x && prevPos.y === position.y) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// 변경사항이 있으면 새 객체를 만들어 넘김\r\n\tconst newPositions = {\r\n\t\t...current,\r\n\t\t[layoutName]: position,\r\n\t};\r\n\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\n/**\r\n * 스크롤 위치 구독\r\n */\r\nexport const getScrollPosition = (layoutName: string) => {\r\n\treturn scrollPositionsSubject.pipe(\r\n\t\t// 해당 layoutName이 정의되지 않았을 때는 제외\r\n\t\tfilter((e) => e[layoutName] !== undefined),\r\n\t\tmap((positions) => positions[layoutName]),\r\n\t\tdistinctUntilChanged(\r\n\t\t\t(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y,\r\n\t\t),\r\n\t);\r\n};\r\nexport const removeScrollPosition = (layoutName: string) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst { [layoutName]: _, ...rest } = current;\r\n\tupdateScrollStore(scrollPositionsSubject, rest);\r\n};\r\n\r\nexport type SplitScreenComponents = {\r\n\tafterDropTargetComponent: DropTargetComponent[];\r\n\tbeforeDropTargetComponent: DropTargetComponent[];\r\n\tcenterDropTargetComponent: DropTargetComponent[];\r\n\tdirection: \"row\" | \"column\";\r\n};\r\n\r\nexport type LayoutSplitScreenState = Record<\r\n\tstring,\r\n\tRecord<string, SplitScreenComponents>\r\n>;\r\n\r\nexport const layoutSplitScreenStore =\r\n\tnew BehaviorSubject<LayoutSplitScreenState>({});\r\n\r\nexport const setSplitScreen = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n\tnewComponents: SplitScreenComponents,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tconst updatedLayout = { ...(current[rootName] || {}) };\r\n\tupdatedLayout[layoutName] = newComponents;\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const resetRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\t// rootName 아래만 초기화\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: {},\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const removeRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\tconst { [rootName]: _, ...rest } = current;\r\n\tupdateSplitScreenStore(rest);\r\n};\r\n\r\nexport const removeSplitScreenChild = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\r\n\tconst updatedLayout = { ...current[rootName] };\r\n\tdelete updatedLayout[layoutName];\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const getCurrentSplitScreenComponents = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\treturn current[rootName][layoutName];\r\n};\r\n\r\nexport const getSplitScreen = (rootName: string, layoutName: string) => {\r\n\treturn layoutSplitScreenStore.pipe(\r\n\t\tmap((splitScreen) => splitScreen[rootName]?.[layoutName]),\r\n\t\tdistinctUntilChanged((prev, curr) => {\r\n\t\t\t// 이전 상태와 현재 상태를 비교하여 동일하면 필터링\r\n\t\t\tconst filterChildren = (obj: any) => {\r\n\t\t\t\t// 객체 복사 후 children 속성 제거\r\n\t\t\t\tconst { children, component, targetComponent, x, y, ...rest } =\r\n\t\t\t\t\tobj || {};\r\n\t\t\t\treturn rest;\r\n\t\t\t};\r\n\t\t\treturn equal(filterChildren(prev), filterChildren(curr));\r\n\t\t}),\r\n\t);\r\n};\r\n\r\n// 중첩된 객체 구조로 ref를 관리하는 타입\r\ntype RefStore = {\r\n\t[layoutName: string]: {\r\n\t\t[containerName: string]: RefObject<HTMLElement | null>;\r\n\t};\r\n};\r\n\r\n// 초기값으로 빈 객체를 설정한 BehaviorSubject 생성\r\nexport const flexContainerStore = new BehaviorSubject<RefStore>({});\r\n\r\nexport const flexResizePanelStore = new BehaviorSubject<RefStore>({});\r\n/**\r\n * ref를 업데이트하는 함수\r\n * - 기존: 무조건 next() → 새/이전 상태 비교 후 다를 경우에만 next()\r\n */\r\nexport const setContainerRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexContainerStore.getValue();\r\n\tconst layoutRefs = currentRefs[layoutName] || {};\r\n\r\n\tif (ref === null) {\r\n\t\tif (!(containerName in layoutRefs)) return; //\r\n\t\tconst { [containerName]: _, ...restLayout } = layoutRefs;\r\n\t\tconst next =\r\n\t\t\tObject.keys(restLayout).length === 0\r\n\t\t\t\t? (() => {\r\n\t\t\t\t\t\tconst { [layoutName]: __, ...rest } = currentRefs;\r\n\t\t\t\t\t\treturn rest;\r\n\t\t\t\t\t})()\r\n\t\t\t\t: { ...currentRefs, [layoutName]: restLayout };\r\n\t\tflexContainerStore.next(next);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (layoutRefs[containerName] === ref) return; // 동일 ref면 skip\r\n\r\n\tflexContainerStore.next({\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: { ...layoutRefs, [containerName]: ref },\r\n\t});\r\n};\r\n\r\nexport const setResizePanelRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexResizePanelStore.getValue();\r\n\tconst layoutRefs = currentRefs[layoutName] || {};\r\n\r\n\tif (ref === null) {\r\n\t\tif (!(containerName in layoutRefs)) return; //\r\n\t\tconst { [containerName]: _, ...restLayout } = layoutRefs;\r\n\t\tconst next =\r\n\t\t\tObject.keys(restLayout).length === 0\r\n\t\t\t\t? (() => {\r\n\t\t\t\t\t\tconst { [layoutName]: __, ...rest } = currentRefs;\r\n\t\t\t\t\t\treturn rest;\r\n\t\t\t\t\t})()\r\n\t\t\t\t: { ...currentRefs, [layoutName]: restLayout };\r\n\t\tflexResizePanelStore.next(next);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (layoutRefs[containerName] === ref) return; // 동일 ref면 skip\r\n\r\n\tflexResizePanelStore.next({\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: { ...layoutRefs, [containerName]: ref },\r\n\t});\r\n};\r\n\r\nexport const getLayoutInfos = (layoutName: string) => {\r\n\treturn combineLatest([flexContainerStore, flexResizePanelStore]).pipe(\r\n\t\tmap(([containerRefs, resizePanelRefs]) => {\r\n\t\t\t// 두 Store에서 layoutName에 해당하는 값을 병합\r\n\t\t\tconst containerData = containerRefs[layoutName] || {};\r\n\t\t\tconst resizePanelData = resizePanelRefs[layoutName] || {};\r\n\r\n\t\t\t// container와 resizePanel 데이터 합치기\r\n\t\t\treturn {\r\n\t\t\t\tcontainer: containerData,\r\n\t\t\t\tresizePanel: resizePanelData,\r\n\t\t\t};\r\n\t\t}),\r\n\t\tfilter(\r\n\t\t\t(result) =>\r\n\t\t\t\tresult.container !== null &&\r\n\t\t\t\tObject.keys(result.container).length > 0,\r\n\t\t), // 빈 객체 제외\r\n\t);\r\n};\r\n\r\n// 특정 containerName의 ref를 구독하는 함수\r\n// layoutName이 지정되지 않으면 전체 layout에서 해당하는 containerName의 ref를 찾음\r\nexport const getContainerRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexContainerStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n\r\nexport const getResizePanelRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexResizePanelStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAAkB;AAElB,kBAA+C;AAC/C,uBAAkD;AAMlD,SAAS,kBAAqB,SAA6B,UAAa;AACvE,QAAM,eAAe,QAAQ,SAAS;AAEtC,MAAI,KAAC,uBA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,QAAQ,IAAI,EAAE;AAAA,UAC3B,CAAC,CAAC,KAAK,KAAK,MAAM,KAAK,GAAG,EAAE,aAAa;AAAA,QAC1C,IAAI,CAAC,EAAE,aAAa;AAAA,MACrB;AAAA,IAUD,CAAC;AAAA,QACD,yBAAO,CAAC,QAAQ,QAAQ,IAAI;AAAA,EAC7B;AACD;","names":["equal"]}
|
|
@@ -27,6 +27,7 @@ export type LayoutSplitScreenState = Record<string, Record<string, SplitScreenCo
|
|
|
27
27
|
export declare const layoutSplitScreenStore: BehaviorSubject<LayoutSplitScreenState>;
|
|
28
28
|
export declare const setSplitScreen: (rootName: string, layoutName: string, newComponents: SplitScreenComponents) => void;
|
|
29
29
|
export declare const resetRootSplitScreen: (rootName: string) => void;
|
|
30
|
+
export declare const removeRootSplitScreen: (rootName: string) => void;
|
|
30
31
|
export declare const removeSplitScreenChild: (rootName: string, layoutName: string) => void;
|
|
31
32
|
export declare const getCurrentSplitScreenComponents: (rootName: string, layoutName: string) => SplitScreenComponents | undefined;
|
|
32
33
|
export declare const getSplitScreen: (rootName: string, layoutName: string) => import("rxjs").Observable<SplitScreenComponents>;
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import equal from "fast-deep-equal";
|
|
3
|
+
import { BehaviorSubject, combineLatest } from "rxjs";
|
|
4
|
+
import { distinctUntilChanged, filter, map } from "rxjs/operators";
|
|
5
5
|
function updateScrollStore(subject, newValue) {
|
|
6
6
|
const currentValue = subject.getValue();
|
|
7
7
|
if (!equal(currentValue, newValue)) {
|
|
8
8
|
subject.next(newValue);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
function updateRefStore(store, newState) {
|
|
12
|
-
const prevState = store.getValue();
|
|
13
|
-
if (!equal(prevState, newState)) {
|
|
14
|
-
store.next(newState);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
11
|
function updateSplitScreenStore(newValue) {
|
|
18
|
-
|
|
19
|
-
if (!equal(prevValue, newValue)) {
|
|
20
|
-
layoutSplitScreenStore.next(newValue);
|
|
21
|
-
}
|
|
12
|
+
layoutSplitScreenStore.next(newValue);
|
|
22
13
|
}
|
|
23
14
|
const scrollPositions = {};
|
|
24
15
|
const scrollPositionsSubject = new BehaviorSubject(scrollPositions);
|
|
@@ -46,9 +37,8 @@ const getScrollPosition = (layoutName) => {
|
|
|
46
37
|
};
|
|
47
38
|
const removeScrollPosition = (layoutName) => {
|
|
48
39
|
const current = scrollPositionsSubject.getValue();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
updateScrollStore(scrollPositionsSubject, newPositions);
|
|
40
|
+
const { [layoutName]: _, ...rest } = current;
|
|
41
|
+
updateScrollStore(scrollPositionsSubject, rest);
|
|
52
42
|
};
|
|
53
43
|
const layoutSplitScreenStore = new BehaviorSubject({});
|
|
54
44
|
const setSplitScreen = (rootName, layoutName, newComponents) => {
|
|
@@ -69,6 +59,12 @@ const resetRootSplitScreen = (rootName) => {
|
|
|
69
59
|
};
|
|
70
60
|
updateSplitScreenStore(newStoreValue);
|
|
71
61
|
};
|
|
62
|
+
const removeRootSplitScreen = (rootName) => {
|
|
63
|
+
const current = layoutSplitScreenStore.getValue();
|
|
64
|
+
if (!current[rootName]) return;
|
|
65
|
+
const { [rootName]: _, ...rest } = current;
|
|
66
|
+
updateSplitScreenStore(rest);
|
|
67
|
+
};
|
|
72
68
|
const removeSplitScreenChild = (rootName, layoutName) => {
|
|
73
69
|
const current = layoutSplitScreenStore.getValue();
|
|
74
70
|
if (!current[rootName]) return;
|
|
@@ -87,7 +83,7 @@ const getCurrentSplitScreenComponents = (rootName, layoutName) => {
|
|
|
87
83
|
};
|
|
88
84
|
const getSplitScreen = (rootName, layoutName) => {
|
|
89
85
|
return layoutSplitScreenStore.pipe(
|
|
90
|
-
map((splitScreen) => splitScreen[rootName][layoutName]),
|
|
86
|
+
map((splitScreen) => splitScreen[rootName]?.[layoutName]),
|
|
91
87
|
distinctUntilChanged((prev, curr) => {
|
|
92
88
|
const filterChildren = (obj) => {
|
|
93
89
|
const { children, component, targetComponent, x, y, ...rest } = obj || {};
|
|
@@ -101,31 +97,41 @@ const flexContainerStore = new BehaviorSubject({});
|
|
|
101
97
|
const flexResizePanelStore = new BehaviorSubject({});
|
|
102
98
|
const setContainerRef = (layoutName, containerName, ref) => {
|
|
103
99
|
const currentRefs = flexContainerStore.getValue();
|
|
104
|
-
const
|
|
100
|
+
const layoutRefs = currentRefs[layoutName] || {};
|
|
105
101
|
if (ref === null) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
if (!(containerName in layoutRefs)) return;
|
|
103
|
+
const { [containerName]: _, ...restLayout } = layoutRefs;
|
|
104
|
+
const next = Object.keys(restLayout).length === 0 ? (() => {
|
|
105
|
+
const { [layoutName]: __, ...rest } = currentRefs;
|
|
106
|
+
return rest;
|
|
107
|
+
})() : { ...currentRefs, [layoutName]: restLayout };
|
|
108
|
+
flexContainerStore.next(next);
|
|
109
|
+
return;
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
+
if (layoutRefs[containerName] === ref) return;
|
|
112
|
+
flexContainerStore.next({
|
|
111
113
|
...currentRefs,
|
|
112
|
-
[layoutName]:
|
|
113
|
-
};
|
|
114
|
-
updateRefStore(flexContainerStore, newRefs);
|
|
114
|
+
[layoutName]: { ...layoutRefs, [containerName]: ref }
|
|
115
|
+
});
|
|
115
116
|
};
|
|
116
117
|
const setResizePanelRef = (layoutName, containerName, ref) => {
|
|
117
118
|
const currentRefs = flexResizePanelStore.getValue();
|
|
118
|
-
const
|
|
119
|
+
const layoutRefs = currentRefs[layoutName] || {};
|
|
119
120
|
if (ref === null) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
if (!(containerName in layoutRefs)) return;
|
|
122
|
+
const { [containerName]: _, ...restLayout } = layoutRefs;
|
|
123
|
+
const next = Object.keys(restLayout).length === 0 ? (() => {
|
|
124
|
+
const { [layoutName]: __, ...rest } = currentRefs;
|
|
125
|
+
return rest;
|
|
126
|
+
})() : { ...currentRefs, [layoutName]: restLayout };
|
|
127
|
+
flexResizePanelStore.next(next);
|
|
128
|
+
return;
|
|
123
129
|
}
|
|
124
|
-
|
|
130
|
+
if (layoutRefs[containerName] === ref) return;
|
|
131
|
+
flexResizePanelStore.next({
|
|
125
132
|
...currentRefs,
|
|
126
|
-
[layoutName]:
|
|
127
|
-
};
|
|
128
|
-
updateRefStore(flexResizePanelStore, newRefs);
|
|
133
|
+
[layoutName]: { ...layoutRefs, [containerName]: ref }
|
|
134
|
+
});
|
|
129
135
|
};
|
|
130
136
|
const getLayoutInfos = (layoutName) => {
|
|
131
137
|
return combineLatest([flexContainerStore, flexResizePanelStore]).pipe(
|
|
@@ -137,7 +143,9 @@ const getLayoutInfos = (layoutName) => {
|
|
|
137
143
|
resizePanel: resizePanelData
|
|
138
144
|
};
|
|
139
145
|
}),
|
|
140
|
-
filter(
|
|
146
|
+
filter(
|
|
147
|
+
(result) => result.container !== null && Object.keys(result.container).length > 0
|
|
148
|
+
)
|
|
141
149
|
// 빈 객체 제외
|
|
142
150
|
);
|
|
143
151
|
};
|
|
@@ -175,7 +183,24 @@ const getResizePanelRef = ({
|
|
|
175
183
|
filter((ref) => ref !== null)
|
|
176
184
|
);
|
|
177
185
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
export {
|
|
187
|
+
flexContainerStore,
|
|
188
|
+
flexResizePanelStore,
|
|
189
|
+
getContainerRef,
|
|
190
|
+
getCurrentSplitScreenComponents,
|
|
191
|
+
getLayoutInfos,
|
|
192
|
+
getResizePanelRef,
|
|
193
|
+
getScrollPosition,
|
|
194
|
+
getSplitScreen,
|
|
195
|
+
layoutSplitScreenStore,
|
|
196
|
+
removeRootSplitScreen,
|
|
197
|
+
removeScrollPosition,
|
|
198
|
+
removeSplitScreenChild,
|
|
199
|
+
resetRootSplitScreen,
|
|
200
|
+
scrollPositions,
|
|
201
|
+
setContainerRef,
|
|
202
|
+
setResizePanelRef,
|
|
203
|
+
setScrollPosition,
|
|
204
|
+
setSplitScreen
|
|
205
|
+
};
|
|
181
206
|
//# sourceMappingURL=FlexLayoutContainerStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/flex-layout/store/FlexLayoutContainerStore.ts"],"names":[],"mappings":";;;;AAUA,SAAS,iBAAA,CAAqB,SAA6B,QAAA,EAAa;AACvE,EAAA,MAAM,YAAA,GAAe,QAAQ,QAAA,EAAS;AAEtC,EAAA,IAAI,CAAC,KAAA,CAAM,YAAA,EAAc,QAAQ,CAAA,EAAG;AACnC,IAAA,OAAA,CAAQ,KAAK,QAAQ,CAAA;AAAA,EACtB;AACD;AAEA,SAAS,cAAA,CAAe,OAAkC,QAAA,EAAoB;AAC7E,EAAA,MAAM,SAAA,GAAY,MAAM,QAAA,EAAS;AACjC,EAAA,IAAI,CAAC,KAAA,CAAM,SAAA,EAAW,QAAQ,CAAA,EAAG;AAChC,IAAA,KAAA,CAAM,KAAK,QAAQ,CAAA;AAAA,EACpB;AACD;AAEA,SAAS,uBAAuB,QAAA,EAAkC;AACjE,EAAA,MAAM,SAAA,GAAY,uBAAuB,QAAA,EAAS;AAElD,EAAA,IAAI,CAAC,KAAA,CAAM,SAAA,EAAW,QAAQ,CAAA,EAAG;AAChC,IAAA,sBAAA,CAAuB,KAAK,QAAQ,CAAA;AAAA,EACrC;AACD;AAYO,MAAM,kBAAkD;AAE/D,MAAM,sBAAA,GAAyB,IAAI,eAAA,CAEjC,eAAe,CAAA;AAOV,MAAM,iBAAA,GAAoB,CAChC,UAAA,EACA,QAAA,KACI;AACJ,EAAA,MAAM,OAAA,GAAU,uBAAuB,QAAA,EAAS;AAChD,EAAA,MAAM,OAAA,GAAU,QAAQ,UAAU,CAAA;AAGlC,EAAA,IAAI,OAAA,IAAW,QAAQ,CAAA,KAAM,QAAA,CAAS,KAAK,OA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I;AAAA,GAC7B;AACD;AAEO,MAAM,oBAAoB,CAAC;AAAA,EACjC,aAAA;AAAA,EACA;AACD,CAAA,KAGM;AACL,EAAA,OAAO,oBAAA,CAAqB,IAAA;AAAA,IAC3B,GAAA,CAAI,CAAC,IAAA,KAAmB;AACvB,MAAA,IAAI,UAAA,EAAY;AAEf,QAAA,OAAO,IAAA,CAAK,UAAU,CAAA,GAAI,aAAa,CAAA,IAAK,IAAA;AAAA,MAC7C,CAAA,MAAO;AAEN,QAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,CAAE,IAAA;AAAA,UAC3B,CAAC,CAAC,GAAA,EAAK,KAAK,MAAM,IAAA,CAAK,GAAG,EAAE,aAAa;AAAA,SAC1C,GAAI,CAAC,CAAA,CAAE,aAAa,CAAA;AAAA,MACrB;AAAA,IAUD,CAAC,CAAA;AAAA,IACD,MAAA,CAAO,CAAC,GAAA,KAAQ,GAAA,KAAQ,IAAI;AAAA,GAC7B;AACD","file":"FlexLayoutContainerStore.js","sourcesContent":["\"use client\";\r\nimport equal from \"fast-deep-equal\";\r\nimport { RefObject } from \"react\";\r\nimport { BehaviorSubject, combineLatest } from \"rxjs\";\r\nimport { distinctUntilChanged, filter, map } from \"rxjs/operators\";\r\nimport { DropTargetComponent } from \"../hooks/useDrag\";\r\n\r\n/**\r\n * 이전 값과 새 값이 동일하지 않을 때만 store를 업데이트하는 유틸 함수\r\n */\r\nfunction updateScrollStore<T>(subject: BehaviorSubject<T>, newValue: T) {\r\n\tconst currentValue = subject.getValue();\r\n\t// deep 비교를 통해 실제 변경이 있는 경우만 next\r\n\tif (!equal(currentValue, newValue)) {\r\n\t\tsubject.next(newValue);\r\n\t}\r\n}\r\n// 동일한지 확인 후 업데이트하는 유틸\r\nfunction updateRefStore(store: BehaviorSubject<RefStore>, newState: RefStore) {\r\n\tconst prevState = store.getValue();\r\n\tif (!equal(prevState, newState)) {\r\n\t\tstore.next(newState);\r\n\t}\r\n}\r\n\r\nfunction updateSplitScreenStore(newValue: LayoutSplitScreenState) {\r\n\tconst prevValue = layoutSplitScreenStore.getValue();\r\n\t// deep-equal 로 비교\r\n\tif (!equal(prevValue, newValue)) {\r\n\t\tlayoutSplitScreenStore.next(newValue);\r\n\t}\r\n}\r\n\r\n// 구독 시 이전 상태들을 축적하여 관리\r\n// const stateWithHistory$ = flexContainerStore.pipe(\r\n// scan((acc, newState) => [...acc, newState], [] as RefStore[])\r\n// );\r\n\r\nexport interface ScrollPosition {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport const scrollPositions: Record<string, ScrollPosition> = {};\r\n\r\nconst scrollPositionsSubject = new BehaviorSubject<\r\n\tRecord<string, ScrollPosition>\r\n>(scrollPositions);\r\n\r\n/**\r\n * 스크롤 위치 업데이트 함수\r\n *\r\n * 기존: 항상 store.next()가 호출됨 → 바뀌지 않았다면 건너뛰도록 변경\r\n */\r\nexport const setScrollPosition = (\r\n\tlayoutName: string,\r\n\tposition: ScrollPosition,\r\n) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst prevPos = current[layoutName];\r\n\r\n\t// x, y 모두 동일하면 업데이트할 필요가 없으므로 조기 반환\r\n\tif (prevPos && prevPos.x === position.x && prevPos.y === position.y) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// 변경사항이 있으면 새 객체를 만들어 넘김\r\n\tconst newPositions = {\r\n\t\t...current,\r\n\t\t[layoutName]: position,\r\n\t};\r\n\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\n/**\r\n * 스크롤 위치 구독\r\n */\r\nexport const getScrollPosition = (layoutName: string) => {\r\n\treturn scrollPositionsSubject.pipe(\r\n\t\t// 해당 layoutName이 정의되지 않았을 때는 제외\r\n\t\tfilter((e) => e[layoutName] !== undefined),\r\n\t\tmap((positions) => positions[layoutName]),\r\n\t\tdistinctUntilChanged(\r\n\t\t\t(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y,\r\n\t\t),\r\n\t);\r\n};\r\n\r\nexport const removeScrollPosition = (layoutName: string) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tdelete current[layoutName];\r\n\r\n\t// 꼭 삭제 후에도 이전 상태와 달라졌는지 확인\r\n\tconst newPositions = { ...current };\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\nexport type SplitScreenComponents = {\r\n\tafterDropTargetComponent: DropTargetComponent[];\r\n\tbeforeDropTargetComponent: DropTargetComponent[];\r\n\tcenterDropTargetComponent: DropTargetComponent[];\r\n\tdirection: \"row\" | \"column\";\r\n};\r\n\r\nexport type LayoutSplitScreenState = Record<\r\n\tstring,\r\n\tRecord<string, SplitScreenComponents>\r\n>;\r\n\r\nexport const layoutSplitScreenStore =\r\n\tnew BehaviorSubject<LayoutSplitScreenState>({});\r\n\r\nexport const setSplitScreen = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n\tnewComponents: SplitScreenComponents,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tconst updatedLayout = { ...(current[rootName] || {}) };\r\n\tupdatedLayout[layoutName] = newComponents;\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const resetRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\t// rootName 아래만 초기화\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: {},\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const removeSplitScreenChild = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\r\n\tconst updatedLayout = { ...current[rootName] };\r\n\tdelete updatedLayout[layoutName];\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const getCurrentSplitScreenComponents = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\treturn current[rootName][layoutName];\r\n};\r\n\r\nexport const getSplitScreen = (rootName: string, layoutName: string) => {\r\n\treturn layoutSplitScreenStore.pipe(\r\n\t\tmap((splitScreen) => splitScreen[rootName][layoutName]),\r\n\t\tdistinctUntilChanged((prev, curr) => {\r\n\t\t\t// 이전 상태와 현재 상태를 비교하여 동일하면 필터링\r\n\t\t\tconst filterChildren = (obj: any) => {\r\n\t\t\t\t// 객체 복사 후 children 속성 제거\r\n\t\t\t\tconst { children, component, targetComponent, x, y, ...rest } =\r\n\t\t\t\t\tobj || {};\r\n\t\t\t\treturn rest;\r\n\t\t\t};\r\n\t\t\treturn equal(filterChildren(prev), filterChildren(curr));\r\n\t\t}),\r\n\t);\r\n};\r\n\r\n// 중첩된 객체 구조로 ref를 관리하는 타입\r\ntype RefStore = {\r\n\t[layoutName: string]: {\r\n\t\t[containerName: string]: RefObject<HTMLElement | null>;\r\n\t};\r\n};\r\n\r\n// 초기값으로 빈 객체를 설정한 BehaviorSubject 생성\r\nexport const flexContainerStore = new BehaviorSubject<RefStore>({});\r\n\r\nexport const flexResizePanelStore = new BehaviorSubject<RefStore>({});\r\n/**\r\n * ref를 업데이트하는 함수\r\n * - 기존: 무조건 next() → 새/이전 상태 비교 후 다를 경우에만 next()\r\n */\r\nexport const setContainerRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexContainerStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexContainerStore, newRefs);\r\n};\r\n\r\nexport const setResizePanelRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexResizePanelStore.getValue();\r\n\tconst updatedLayoutRefs = { ...(currentRefs[layoutName] || {}) };\r\n\r\n\tif (ref === null) {\r\n\t\tdelete updatedLayoutRefs[containerName];\r\n\t} else {\r\n\t\tupdatedLayoutRefs[containerName] = ref;\r\n\t}\r\n\r\n\tconst newRefs: RefStore = {\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: updatedLayoutRefs,\r\n\t};\r\n\r\n\tupdateRefStore(flexResizePanelStore, newRefs);\r\n};\r\n\r\nexport const getLayoutInfos = (layoutName: string) => {\r\n\treturn combineLatest([flexContainerStore, flexResizePanelStore]).pipe(\r\n\t\tmap(([containerRefs, resizePanelRefs]) => {\r\n\t\t\t// 두 Store에서 layoutName에 해당하는 값을 병합\r\n\t\t\tconst containerData = containerRefs[layoutName] || {};\r\n\t\t\tconst resizePanelData = resizePanelRefs[layoutName] || {};\r\n\r\n\t\t\t// container와 resizePanel 데이터 합치기\r\n\t\t\treturn {\r\n\t\t\t\tcontainer: containerData,\r\n\t\t\t\tresizePanel: resizePanelData,\r\n\t\t\t};\r\n\t\t}),\r\n\t\tfilter((result) => result.container !== null), // 빈 객체 제외\r\n\t);\r\n};\r\n\r\n// 특정 containerName의 ref를 구독하는 함수\r\n// layoutName이 지정되지 않으면 전체 layout에서 해당하는 containerName의 ref를 찾음\r\nexport const getContainerRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexContainerStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n\r\nexport const getResizePanelRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexResizePanelStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/flex-layout/store/FlexLayoutContainerStore.ts"],"sourcesContent":["\"use client\";\r\nimport equal from \"fast-deep-equal\";\r\nimport { RefObject } from \"react\";\r\nimport { BehaviorSubject, combineLatest } from \"rxjs\";\r\nimport { distinctUntilChanged, filter, map } from \"rxjs/operators\";\r\nimport { DropTargetComponent } from \"../hooks/useDrag\";\r\n\r\n/**\r\n * 이전 값과 새 값이 동일하지 않을 때만 store를 업데이트하는 유틸 함수\r\n */\r\nfunction updateScrollStore<T>(subject: BehaviorSubject<T>, newValue: T) {\r\n\tconst currentValue = subject.getValue();\r\n\t// deep 비교를 통해 실제 변경이 있는 경우만 next\r\n\tif (!equal(currentValue, newValue)) {\r\n\t\tsubject.next(newValue);\r\n\t}\r\n}\r\n\r\nfunction updateSplitScreenStore(newValue: LayoutSplitScreenState) {\r\n\t// const prevValue = layoutSplitScreenStore.getValue();\r\n\t// deep-equal 로 비교\r\n\t// if (!equal(prevValue, newValue)) {\r\n\tlayoutSplitScreenStore.next(newValue);\r\n\t// }\r\n}\r\n\r\n// 구독 시 이전 상태들을 축적하여 관리\r\n// const stateWithHistory$ = flexContainerStore.pipe(\r\n// scan((acc, newState) => [...acc, newState], [] as RefStore[])\r\n// );\r\n\r\nexport interface ScrollPosition {\r\n\tx: number;\r\n\ty: number;\r\n}\r\n\r\nexport const scrollPositions: Record<string, ScrollPosition> = {};\r\n\r\nconst scrollPositionsSubject = new BehaviorSubject<\r\n\tRecord<string, ScrollPosition>\r\n>(scrollPositions);\r\n\r\n/**\r\n * 스크롤 위치 업데이트 함수\r\n *\r\n * 기존: 항상 store.next()가 호출됨 → 바뀌지 않았다면 건너뛰도록 변경\r\n */\r\nexport const setScrollPosition = (\r\n\tlayoutName: string,\r\n\tposition: ScrollPosition,\r\n) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst prevPos = current[layoutName];\r\n\r\n\t// x, y 모두 동일하면 업데이트할 필요가 없으므로 조기 반환\r\n\tif (prevPos && prevPos.x === position.x && prevPos.y === position.y) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// 변경사항이 있으면 새 객체를 만들어 넘김\r\n\tconst newPositions = {\r\n\t\t...current,\r\n\t\t[layoutName]: position,\r\n\t};\r\n\r\n\tupdateScrollStore(scrollPositionsSubject, newPositions);\r\n};\r\n\r\n/**\r\n * 스크롤 위치 구독\r\n */\r\nexport const getScrollPosition = (layoutName: string) => {\r\n\treturn scrollPositionsSubject.pipe(\r\n\t\t// 해당 layoutName이 정의되지 않았을 때는 제외\r\n\t\tfilter((e) => e[layoutName] !== undefined),\r\n\t\tmap((positions) => positions[layoutName]),\r\n\t\tdistinctUntilChanged(\r\n\t\t\t(prev, curr) => prev?.x === curr?.x && prev?.y === curr?.y,\r\n\t\t),\r\n\t);\r\n};\r\nexport const removeScrollPosition = (layoutName: string) => {\r\n\tconst current = scrollPositionsSubject.getValue();\r\n\tconst { [layoutName]: _, ...rest } = current;\r\n\tupdateScrollStore(scrollPositionsSubject, rest);\r\n};\r\n\r\nexport type SplitScreenComponents = {\r\n\tafterDropTargetComponent: DropTargetComponent[];\r\n\tbeforeDropTargetComponent: DropTargetComponent[];\r\n\tcenterDropTargetComponent: DropTargetComponent[];\r\n\tdirection: \"row\" | \"column\";\r\n};\r\n\r\nexport type LayoutSplitScreenState = Record<\r\n\tstring,\r\n\tRecord<string, SplitScreenComponents>\r\n>;\r\n\r\nexport const layoutSplitScreenStore =\r\n\tnew BehaviorSubject<LayoutSplitScreenState>({});\r\n\r\nexport const setSplitScreen = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n\tnewComponents: SplitScreenComponents,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tconst updatedLayout = { ...(current[rootName] || {}) };\r\n\tupdatedLayout[layoutName] = newComponents;\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const resetRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\t// rootName 아래만 초기화\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: {},\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const removeRootSplitScreen = (rootName: string) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\tconst { [rootName]: _, ...rest } = current;\r\n\tupdateSplitScreenStore(rest);\r\n};\r\n\r\nexport const removeSplitScreenChild = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\r\n\tconst updatedLayout = { ...current[rootName] };\r\n\tdelete updatedLayout[layoutName];\r\n\r\n\tconst newStoreValue = {\r\n\t\t...current,\r\n\t\t[rootName]: updatedLayout,\r\n\t};\r\n\tupdateSplitScreenStore(newStoreValue);\r\n};\r\n\r\nexport const getCurrentSplitScreenComponents = (\r\n\trootName: string,\r\n\tlayoutName: string,\r\n) => {\r\n\tconst current = layoutSplitScreenStore.getValue();\r\n\tif (!current[rootName]) return;\r\n\treturn current[rootName][layoutName];\r\n};\r\n\r\nexport const getSplitScreen = (rootName: string, layoutName: string) => {\r\n\treturn layoutSplitScreenStore.pipe(\r\n\t\tmap((splitScreen) => splitScreen[rootName]?.[layoutName]),\r\n\t\tdistinctUntilChanged((prev, curr) => {\r\n\t\t\t// 이전 상태와 현재 상태를 비교하여 동일하면 필터링\r\n\t\t\tconst filterChildren = (obj: any) => {\r\n\t\t\t\t// 객체 복사 후 children 속성 제거\r\n\t\t\t\tconst { children, component, targetComponent, x, y, ...rest } =\r\n\t\t\t\t\tobj || {};\r\n\t\t\t\treturn rest;\r\n\t\t\t};\r\n\t\t\treturn equal(filterChildren(prev), filterChildren(curr));\r\n\t\t}),\r\n\t);\r\n};\r\n\r\n// 중첩된 객체 구조로 ref를 관리하는 타입\r\ntype RefStore = {\r\n\t[layoutName: string]: {\r\n\t\t[containerName: string]: RefObject<HTMLElement | null>;\r\n\t};\r\n};\r\n\r\n// 초기값으로 빈 객체를 설정한 BehaviorSubject 생성\r\nexport const flexContainerStore = new BehaviorSubject<RefStore>({});\r\n\r\nexport const flexResizePanelStore = new BehaviorSubject<RefStore>({});\r\n/**\r\n * ref를 업데이트하는 함수\r\n * - 기존: 무조건 next() → 새/이전 상태 비교 후 다를 경우에만 next()\r\n */\r\nexport const setContainerRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexContainerStore.getValue();\r\n\tconst layoutRefs = currentRefs[layoutName] || {};\r\n\r\n\tif (ref === null) {\r\n\t\tif (!(containerName in layoutRefs)) return; //\r\n\t\tconst { [containerName]: _, ...restLayout } = layoutRefs;\r\n\t\tconst next =\r\n\t\t\tObject.keys(restLayout).length === 0\r\n\t\t\t\t? (() => {\r\n\t\t\t\t\t\tconst { [layoutName]: __, ...rest } = currentRefs;\r\n\t\t\t\t\t\treturn rest;\r\n\t\t\t\t\t})()\r\n\t\t\t\t: { ...currentRefs, [layoutName]: restLayout };\r\n\t\tflexContainerStore.next(next);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (layoutRefs[containerName] === ref) return; // 동일 ref면 skip\r\n\r\n\tflexContainerStore.next({\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: { ...layoutRefs, [containerName]: ref },\r\n\t});\r\n};\r\n\r\nexport const setResizePanelRef = <T extends HTMLElement>(\r\n\tlayoutName: string,\r\n\tcontainerName: string,\r\n\tref: RefObject<T | null> | null,\r\n) => {\r\n\tconst currentRefs = flexResizePanelStore.getValue();\r\n\tconst layoutRefs = currentRefs[layoutName] || {};\r\n\r\n\tif (ref === null) {\r\n\t\tif (!(containerName in layoutRefs)) return; //\r\n\t\tconst { [containerName]: _, ...restLayout } = layoutRefs;\r\n\t\tconst next =\r\n\t\t\tObject.keys(restLayout).length === 0\r\n\t\t\t\t? (() => {\r\n\t\t\t\t\t\tconst { [layoutName]: __, ...rest } = currentRefs;\r\n\t\t\t\t\t\treturn rest;\r\n\t\t\t\t\t})()\r\n\t\t\t\t: { ...currentRefs, [layoutName]: restLayout };\r\n\t\tflexResizePanelStore.next(next);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (layoutRefs[containerName] === ref) return; // 동일 ref면 skip\r\n\r\n\tflexResizePanelStore.next({\r\n\t\t...currentRefs,\r\n\t\t[layoutName]: { ...layoutRefs, [containerName]: ref },\r\n\t});\r\n};\r\n\r\nexport const getLayoutInfos = (layoutName: string) => {\r\n\treturn combineLatest([flexContainerStore, flexResizePanelStore]).pipe(\r\n\t\tmap(([containerRefs, resizePanelRefs]) => {\r\n\t\t\t// 두 Store에서 layoutName에 해당하는 값을 병합\r\n\t\t\tconst containerData = containerRefs[layoutName] || {};\r\n\t\t\tconst resizePanelData = resizePanelRefs[layoutName] || {};\r\n\r\n\t\t\t// container와 resizePanel 데이터 합치기\r\n\t\t\treturn {\r\n\t\t\t\tcontainer: containerData,\r\n\t\t\t\tresizePanel: resizePanelData,\r\n\t\t\t};\r\n\t\t}),\r\n\t\tfilter(\r\n\t\t\t(result) =>\r\n\t\t\t\tresult.container !== null &&\r\n\t\t\t\tObject.keys(result.container).length > 0,\r\n\t\t), // 빈 객체 제외\r\n\t);\r\n};\r\n\r\n// 특정 containerName의 ref를 구독하는 함수\r\n// layoutName이 지정되지 않으면 전체 layout에서 해당하는 containerName의 ref를 찾음\r\nexport const getContainerRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexContainerStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n\r\nexport const getResizePanelRef = ({\r\n\tcontainerName,\r\n\tlayoutName,\r\n}: {\r\n\tcontainerName: string;\r\n\tlayoutName?: string;\r\n}) => {\r\n\treturn flexResizePanelStore.pipe(\r\n\t\tmap((refs: RefStore) => {\r\n\t\t\tif (layoutName) {\r\n\t\t\t\t// 지정된 layoutName에서 해당 containerName의 ref 반환\r\n\t\t\t\treturn refs[layoutName]?.[containerName] || null;\r\n\t\t\t} else {\r\n\t\t\t\t// 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t\treturn Object.entries(refs).find(\r\n\t\t\t\t\t([key, value]) => refs[key][containerName],\r\n\t\t\t\t)?.[1][containerName];\r\n\t\t\t}\r\n\t\t\t// else {\r\n\t\t\t// // 모든 layout에서 해당 containerName의 ref 찾기\r\n\t\t\t// for (const layout in refs) {\r\n\t\t\t// if (refs[layout][containerName]) {\r\n\t\t\t// return refs[layout][containerName];\r\n\t\t\t// }\r\n\t\t\t// }\r\n\t\t\t// return null;\r\n\t\t\t// }\r\n\t\t}),\r\n\t\tfilter((ref) => ref !== null),\r\n\t);\r\n};\r\n"],"mappings":";AACA,OAAO,WAAW;AAElB,SAAS,iBAAiB,qBAAqB;AAC/C,SAAS,sBAAsB,QAAQ,WAAW;AAMlD,SAAS,kBAAqB,SAA6B,UAAa;AACvE,QAAM,eAAe,QAAQ,S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