@byeolnaerim/flex-layout 0.0.9 → 0.0.12
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.d.ts +2 -1
- package/dist/flex-layout/components/FlexLayout.js +1 -85
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -262
- package/dist/flex-layout/components/FlexLayoutContainer.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutContainer.js +1 -232
- package/dist/flex-layout/components/FlexLayoutDynamicHeight.cjs +1 -0
- package/dist/flex-layout/components/FlexLayoutDynamicHeight.d.ts +6 -0
- package/dist/flex-layout/components/FlexLayoutDynamicHeight.js +1 -0
- 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.d.ts +14 -1
- 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.d.ts +1 -0
- 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.d.ts +6 -3
- 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 +499 -416
- package/dist/flex-layout/styles/sentinelStyle.module.css +11 -0
- 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.d.ts +38 -2
- 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,216 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
4
|
-
import { isResizingSubject } from "../hooks";
|
|
5
|
-
import { setResizePanelRef } from "../store/FlexLayoutContainerStore";
|
|
6
|
-
import styles from "../styles/FlexLayout.module.css";
|
|
7
|
-
import { findNotCloseFlexContent, isOverMove } from "../utils/FlexLayoutUtils";
|
|
8
|
-
const flexDirectionModel = {
|
|
9
|
-
row: {
|
|
10
|
-
xy: "x",
|
|
11
|
-
targetDirection: "left",
|
|
12
|
-
nextDirection: "right",
|
|
13
|
-
sizeName: "width",
|
|
14
|
-
resizeCursor: "ew-resize"
|
|
15
|
-
},
|
|
16
|
-
column: {
|
|
17
|
-
xy: "y",
|
|
18
|
-
targetDirection: "top",
|
|
19
|
-
nextDirection: "bottom",
|
|
20
|
-
sizeName: "height",
|
|
21
|
-
resizeCursor: "ns-resize"
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function FlexLayoutResizePanel({
|
|
25
|
-
direction,
|
|
26
|
-
containerCount,
|
|
27
|
-
panelMode = "default",
|
|
28
|
-
containerName,
|
|
29
|
-
layoutName,
|
|
30
|
-
panelClassName,
|
|
31
|
-
panelMovementMode,
|
|
32
|
-
onResizingChange
|
|
33
|
-
}) {
|
|
34
|
-
const directionRef = useRef(direction);
|
|
35
|
-
const movementModeRef = useRef(panelMovementMode);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
directionRef.current = direction;
|
|
38
|
-
}, [direction]);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
movementModeRef.current = panelMovementMode;
|
|
41
|
-
}, [panelMovementMode]);
|
|
42
|
-
const isResizePanelClickRef = useRef(false);
|
|
43
|
-
const prevTouchEventRef = useRef(null);
|
|
44
|
-
const parentSizeRef = useRef(0);
|
|
45
|
-
const totalMovementRef = useRef(0);
|
|
46
|
-
const containerCountRef = useRef(containerCount);
|
|
47
|
-
const panelRef = useRef(null);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
return () => {
|
|
50
|
-
isResizingSubject.next(false);
|
|
51
|
-
document.body.style.cursor = "";
|
|
52
|
-
};
|
|
53
|
-
}, []);
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
containerCountRef.current = containerCount;
|
|
56
|
-
}, [containerCount]);
|
|
57
|
-
const panelMouseDownEvent = (event) => {
|
|
58
|
-
if (!panelRef.current || !panelRef.current.parentElement) return;
|
|
59
|
-
isResizePanelClickRef.current = true;
|
|
60
|
-
onResizingChange?.(true);
|
|
61
|
-
containerCountRef.current = [
|
|
62
|
-
...panelRef.current.parentElement.children
|
|
63
|
-
].filter((e) => e.hasAttribute("data-container_name")).length;
|
|
64
|
-
const sizeName = flexDirectionModel[direction].sizeName;
|
|
65
|
-
parentSizeRef.current = panelRef.current.parentElement.getBoundingClientRect()[sizeName];
|
|
66
|
-
prevTouchEventRef.current = null;
|
|
67
|
-
totalMovementRef.current = 0;
|
|
68
|
-
isResizingSubject.next(true);
|
|
69
|
-
if (!parentSizeRef.current) return;
|
|
70
|
-
document.body.style.cursor = flexDirectionModel[direction].resizeCursor;
|
|
71
|
-
};
|
|
72
|
-
const panelMouseUpEvent = () => {
|
|
73
|
-
isResizePanelClickRef.current = false;
|
|
74
|
-
onResizingChange?.(false);
|
|
75
|
-
parentSizeRef.current = 0;
|
|
76
|
-
totalMovementRef.current = 0;
|
|
77
|
-
prevTouchEventRef.current = null;
|
|
78
|
-
isResizingSubject.next(false);
|
|
79
|
-
document.body.style.cursor = "";
|
|
80
|
-
};
|
|
81
|
-
function moveMouseFlex(originTarget, resizePanel, moveEvent, dir, mode) {
|
|
82
|
-
const model = flexDirectionModel[dir];
|
|
83
|
-
const movement = moveEvent["movement" + model.xy.toUpperCase()];
|
|
84
|
-
totalMovementRef.current += movement;
|
|
85
|
-
const minSizeName = "min-" + model.sizeName;
|
|
86
|
-
const maxSizeName = "max-" + model.sizeName;
|
|
87
|
-
let targetElement = findNotCloseFlexContent(
|
|
88
|
-
originTarget,
|
|
89
|
-
"previousElementSibling"
|
|
90
|
-
);
|
|
91
|
-
if (panelMovementMode === "divorce" && totalMovementRef.current > 0 || panelMovementMode === "bulldozer" && movement > 0 || !targetElement)
|
|
92
|
-
targetElement = originTarget;
|
|
93
|
-
let nextElement = findNotCloseFlexContent(
|
|
94
|
-
resizePanel.nextElementSibling,
|
|
95
|
-
"nextElementSibling"
|
|
96
|
-
);
|
|
97
|
-
if (panelMovementMode === "divorce" && totalMovementRef.current < 0 || panelMovementMode === "bulldozer" && movement < 0 || !nextElement)
|
|
98
|
-
nextElement = resizePanel.nextElementSibling;
|
|
99
|
-
if (!targetElement || !nextElement) return;
|
|
100
|
-
const targetRect = targetElement.getBoundingClientRect();
|
|
101
|
-
const targetStyle = window.getComputedStyle(targetElement);
|
|
102
|
-
const targetMinSize = parseFloat(targetStyle.getPropertyValue(minSizeName)) || 0;
|
|
103
|
-
const targetMaxSize = parseFloat(targetStyle.getPropertyValue(maxSizeName)) || 0;
|
|
104
|
-
const nextRect = nextElement.getBoundingClientRect();
|
|
105
|
-
const nextStyle = window.getComputedStyle(nextElement);
|
|
106
|
-
const nextMinSize = parseFloat(nextStyle.getPropertyValue(minSizeName)) || 0;
|
|
107
|
-
const nextMaxSize = parseFloat(nextStyle.getPropertyValue(maxSizeName)) || 0;
|
|
108
|
-
let targetSize = targetRect[model.sizeName] + movement;
|
|
109
|
-
let nextElementSize = nextRect[model.sizeName] - movement;
|
|
110
|
-
if (targetMaxSize > 0 && targetSize > targetMaxSize) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (nextMaxSize > 0 && nextElementSize > nextMaxSize) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (isOverMove(targetSize, targetMinSize)) {
|
|
117
|
-
targetSize = 0;
|
|
118
|
-
nextElementSize = nextRect[model.sizeName];
|
|
119
|
-
} else if (isOverMove(nextElementSize, nextMinSize)) {
|
|
120
|
-
nextElementSize = 0;
|
|
121
|
-
targetSize = targetRect[model.sizeName];
|
|
122
|
-
}
|
|
123
|
-
const targetFlexGrow = targetSize / (parentSizeRef.current - 1) * containerCountRef.current;
|
|
124
|
-
const nextElementFlexGrow = nextElementSize / (parentSizeRef.current - 1) * containerCountRef.current;
|
|
125
|
-
if (!(targetElement instanceof HTMLElement)) return;
|
|
126
|
-
if (!(nextElement instanceof HTMLElement)) return;
|
|
127
|
-
targetElement.style.flex = `${targetFlexGrow} 1 0%`;
|
|
128
|
-
nextElement.style.flex = `${nextElementFlexGrow} 1 0%`;
|
|
129
|
-
}
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
const addGlobalMoveEvent = (event) => {
|
|
132
|
-
if (!isResizePanelClickRef.current || !panelRef.current) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
const dir = directionRef.current;
|
|
137
|
-
const mode = movementModeRef.current;
|
|
138
|
-
const targetElement = panelRef.current.previousElementSibling;
|
|
139
|
-
const targetPanel = panelRef.current;
|
|
140
|
-
if (!targetElement || !targetPanel) return;
|
|
141
|
-
let move = { movementX: 0, movementY: 0 };
|
|
142
|
-
if (window.TouchEvent && event instanceof window.TouchEvent) {
|
|
143
|
-
const prev = prevTouchEventRef.current;
|
|
144
|
-
if (!prev) {
|
|
145
|
-
prevTouchEventRef.current = event;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
move.movementX = (prev.touches[0].pageX - event.touches[0].pageX) * -1;
|
|
149
|
-
move.movementY = (prev.touches[0].pageY - event.touches[0].pageY) * -1;
|
|
150
|
-
prevTouchEventRef.current = event;
|
|
151
|
-
} else {
|
|
152
|
-
move.movementX = event.movementX;
|
|
153
|
-
move.movementY = event.movementY;
|
|
154
|
-
}
|
|
155
|
-
moveMouseFlex(targetElement, targetPanel, move, dir, mode);
|
|
156
|
-
};
|
|
157
|
-
["mousemove", "touchmove"].forEach((eventName) => {
|
|
158
|
-
window.addEventListener(eventName, addGlobalMoveEvent, {
|
|
159
|
-
passive: false
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
[
|
|
163
|
-
"mouseup",
|
|
164
|
-
"touchend",
|
|
165
|
-
"touchcancel",
|
|
166
|
-
// 터치 제스처 시스템 인터럽트
|
|
167
|
-
"pointerup",
|
|
168
|
-
// 범용 포인터 이벤트
|
|
169
|
-
"pointercancel",
|
|
170
|
-
"blur"
|
|
171
|
-
// 윈도우 포커스 아웃 (Alt+Tab 등)
|
|
172
|
-
].forEach((eventName) => {
|
|
173
|
-
window.addEventListener(eventName, panelMouseUpEvent);
|
|
174
|
-
});
|
|
175
|
-
return () => {
|
|
176
|
-
["mousemove", "touchmove"].forEach((eventName) => {
|
|
177
|
-
window.removeEventListener(eventName, addGlobalMoveEvent);
|
|
178
|
-
});
|
|
179
|
-
[
|
|
180
|
-
"mouseup",
|
|
181
|
-
"touchend",
|
|
182
|
-
"touchcancel",
|
|
183
|
-
// 터치 제스처 시스템 인터럽트
|
|
184
|
-
"pointerup",
|
|
185
|
-
// 범용 포인터 이벤트
|
|
186
|
-
"pointercancel",
|
|
187
|
-
"blur"
|
|
188
|
-
// 윈도우 포커스 아웃 (Alt+Tab 등)
|
|
189
|
-
].forEach((eventName) => {
|
|
190
|
-
window.removeEventListener(eventName, panelMouseUpEvent);
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
}, []);
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
if (!panelRef.current) return;
|
|
196
|
-
setResizePanelRef(layoutName, containerName, panelRef);
|
|
197
|
-
return () => {
|
|
198
|
-
setResizePanelRef(layoutName, containerName, null);
|
|
199
|
-
};
|
|
200
|
-
}, [containerName, layoutName]);
|
|
201
|
-
return /* @__PURE__ */ jsx(
|
|
202
|
-
"div",
|
|
203
|
-
{
|
|
204
|
-
id: containerName + "_resize_panel",
|
|
205
|
-
className: `${styles["flex-resize-panel"]} ${styles[panelMode]} ${panelClassName && panelClassName !== "" ? panelClassName : ""}`,
|
|
206
|
-
ref: panelRef,
|
|
207
|
-
onMouseDown: panelMouseDownEvent,
|
|
208
|
-
onTouchStart: panelMouseDownEvent,
|
|
209
|
-
children: /* @__PURE__ */ jsx("div", { className: styles.hover })
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
export {
|
|
214
|
-
FlexLayoutResizePanel as default
|
|
215
|
-
};
|
|
216
|
-
//# sourceMappingURL=FlexLayoutResizePanel.js.map
|
|
1
|
+
"use client";import{jsx as se}from"react/jsx-runtime";import{useEffect as H,useMemo as de,useRef as S}from"react";import{isResizingSubject as W,resizeDragSubject as I}from"../hooks";import{setResizePanelRef as Z}from"../store/FlexLayoutContainerStore";import P from"../styles/FlexLayout.module.css";import{findNotCloseFlexContent as ee,getClientXy as te,isOverMove as ne}from"../utils/FlexLayoutUtils";const j={row:{xy:"x",targetDirection:"left",nextDirection:"right",sizeName:"width",resizeCursor:"ew-resize"},column:{xy:"y",targetDirection:"top",nextDirection:"bottom",sizeName:"height",resizeCursor:"ns-resize"}},d=4,re=(n,e,r,t)=>{const g=new Map,l=(c,p)=>{const s=document.elementsFromPoint(c,p);for(const u of s){const v=u.closest?.(`.${P["flex-resize-panel"]}`);if(!v)continue;const a=v.dataset.resize_panel_key;a&&(g.has(a)||g.set(a,{el:v,key:a,dir:v.dataset.direction}))}};if([[0,0],[-d,0],[d,0],[0,-d],[0,d],[-d,-d],[d,-d],[-d,d],[d,d]].forEach(([c,p])=>l(n+c,e+p)),r&&t){const c=r.getBoundingClientRect(),p=t==="row"?c.width:t==="column"?c.height:1,s=Math.max(1,Math.ceil(p/2)),u=Math.ceil(d+p*2),f=Math.max(d,Math.ceil(p*2)),v=Array.from(new Set([1,Math.floor(f/2),Math.max(1,f-1)]));if(t==="row")for(let a=-u;a<=u;a+=s)for(const y of v)l(c.left-y,e+a),l(c.right+y,e+a);else if(t==="column")for(let a=-u;a<=u;a+=s)for(const y of v)l(n+a,c.top-y),l(n+a,c.bottom+y)}if(t){const p=[...g.values()].filter(s=>s.dir&&s.dir!==t);for(const s of p){const u=s.el.getBoundingClientRect(),f=s.dir==="row"?u.width:s.dir==="column"?u.height:1,v=Math.max(1,Math.ceil(f/2)),a=Math.ceil(d+f*2),y=Math.max(d,Math.ceil(f*2)),T=Array.from(new Set([1,Math.floor(y/2),Math.max(1,y-1)]));if(t==="column"&&s.dir==="row")for(let M=-a;M<=a;M+=v)for(const o of T)l(u.left-o,e+M),l(u.right+o,e+M);else if(t==="row"&&s.dir==="column")for(let M=-a;M<=a;M+=v)for(const o of T)l(n+M,u.top-o),l(n+M,u.bottom+o)}}return[...g.values()]},C=(n,e)=>{if(!n||n==="auto")return null;if(n.endsWith("px")){const t=parseFloat(n);return Number.isFinite(t)?t:null}if(n.endsWith("%")){const t=parseFloat(n);return Number.isFinite(t)?e*t/100:null}const r=parseFloat(n);return Number.isFinite(r)?r:null},pe=(n,e,r)=>n>=r.left&&n<=r.right&&e>=r.top&&e<=r.bottom,he=n=>{const e=n.getBoundingClientRect(),r=getComputedStyle(n,"::after");if(!r||r.content==="none"||r.content==="normal"||r.display==="none"||r.visibility==="hidden")return null;const t=C(r.width,e.width),g=C(r.height,e.height);if(!t||!g)return null;const l=C(r.left,e.width),c=C(r.right,e.width),p=C(r.top,e.height),s=C(r.bottom,e.height);let u=e.left;l!==null?u=e.left+l:c!==null&&(u=e.right-c-t);let f=e.top;return p!==null?f=e.top+p:s!==null&&(f=e.bottom-s-g),{left:u,top:f,right:u+t,bottom:f+g}},oe=(n,e,r,t,g)=>{const l=r.getBoundingClientRect(),c=he(r);if(c&&pe(n,e,c))return!1;const p=t==="row"?l.width:t==="column"?l.height:1,s=Math.max(g,Math.ceil(p));return t==="row"?n>=l.left-s&&n<=l.right+s:t==="column"?e>=l.top-s&&e<=l.bottom+s:!0};function ge({direction:n,containerCount:e,panelMode:r="default",containerName:t,layoutName:g,panelClassName:l,panelMovementMode:c,onResizingChange:p}){const s=S(n),u=S(c),f=de(()=>`${g}::${t}`,[g,t]);H(()=>{s.current=n},[n]),H(()=>{u.current=c},[c]);const v=S(!1),a=S(null),y=S(0),T=S(0),M=S(e),o=S(null),V=S(null),D=S(null);H(()=>()=>{W.next(!1),document.body.style.cursor="",D.current?.()},[]),H(()=>{M.current=e},[e]);const ie=()=>{if(!o.current||!o.current.parentElement)return;v.current=!0,p?.(!0),M.current=[...o.current.parentElement.children].filter(i=>i.hasAttribute("data-container_name")).length;const m=j[n].sizeName;y.current=o.current.parentElement.getBoundingClientRect()[m],a.current=null,T.current=0,W.next(!0)},le=()=>{v.current=!1,p?.(!1),y.current=0,T.current=0,V.current=null,W.next(!1),document.body.style.cursor="",B()};function ce(m,i,b,z,x){const h=j[z],L=b["movement"+h.xy.toUpperCase()];T.current+=L;const k="min-"+h.sizeName,O="max-"+h.sizeName;let R=ee(m,"previousElementSibling");(x==="divorce"&&T.current>0||x==="bulldozer"&&L>0||!R)&&(R=m);let w=ee(i.nextElementSibling,"nextElementSibling");if((x==="divorce"&&T.current<0||x==="bulldozer"&&L<0||!w)&&(w=i.nextElementSibling),!R||!w)return;const A=R.getBoundingClientRect(),N=window.getComputedStyle(R),X=parseFloat(N.getPropertyValue(k))||0,E=parseFloat(N.getPropertyValue(O))||0,F=w.getBoundingClientRect(),Y=window.getComputedStyle(w),U=parseFloat(Y.getPropertyValue(k))||0,Q=parseFloat(Y.getPropertyValue(O))||0;let $=A[h.sizeName]+L,_=F[h.sizeName]-L;if(E>0&&$>E||Q>0&&_>Q)return;ne($,X)?($=0,_=F[h.sizeName]):ne(_,U)&&(_=0,$=A[h.sizeName]);const me=$/(y.current-1)*M.current,fe=_/(y.current-1)*M.current;R instanceof HTMLElement&&w instanceof HTMLElement&&(R.style.flex=`${me} 1 0%`,w.style.flex=`${fe} 1 0%`)}H(()=>{const m=I.subscribe(i=>{if(i.type==="START"){if(!i.targets.includes(f))return;V.current=i.sessionId,ie(),i.cursor&&(document.body.style.cursor=i.cursor);return}if(i.type==="MOVE"){if(V.current!==i.sessionId||!v.current||!o.current)return;const b=s.current,z=u.current,x=o.current.previousElementSibling,h=o.current;if(!x||!h)return;ce(x,h,{movementX:i.movementX,movementY:i.movementY},b,z);return}if(i.type==="END"){if(V.current!==i.sessionId)return;le()}});return()=>m.unsubscribe()},[f]);const K=m=>{if(!o.current)return;m.preventDefault?.();const i=m.nativeEvent,b=te(i);if(!b)return;const z=s.current,x=oe(b.clientX,b.clientY,o.current,z,d),h=x?re(b.clientX,b.clientY,o.current,z):[{el:o.current,key:f,dir:z}],L=new Set([f]);h.forEach(E=>L.add(E.key));const k=[...L],O=x&&k.length>=2?"move":j[z].resizeCursor,R=`${Date.now()}_${Math.random().toString(16).slice(2)}`;I.next({type:"START",sessionId:R,targets:k,cursor:O}),D.current?.();let w=b.clientX,A=b.clientY;const N=E=>{E.preventDefault?.();const F=te(E);if(!F)return;const Y=F.clientX-w,U=F.clientY-A;w=F.clientX,A=F.clientY,I.next({type:"MOVE",sessionId:R,movementX:Y,movementY:U})},X=()=>{D.current?.(),D.current=null,I.next({type:"END",sessionId:R})};["mousemove","touchmove"].forEach(E=>{window.addEventListener(E,N,{passive:!1})}),["mouseup","touchend","touchcancel","pointerup","pointercancel","blur"].forEach(E=>window.addEventListener(E,X)),D.current=()=>{["mousemove","touchmove"].forEach(E=>window.removeEventListener(E,N)),["mouseup","touchend","touchcancel","pointerup","pointercancel","blur"].forEach(E=>window.removeEventListener(E,X))}};H(()=>{if(o.current)return Z(g,t,o),()=>{Z(g,t,null)}},[t,g]);const G=S([]),q=S(null),B=()=>{for(const m of G.current)m.querySelector(`.${P.hover}`)?.removeAttribute("data-is_hover");G.current=[]},ue=m=>{B();for(const i of m)i.querySelector(`.${P.hover}`)?.setAttribute("data-is_hover","");G.current=m},J=m=>{o.current&&(q.current&&cancelAnimationFrame(q.current),q.current=requestAnimationFrame(()=>{const i=s.current;if(!oe(m.clientX,m.clientY,o.current,i,d)){o.current.style.cursor="",B();return}const x=re(m.clientX,m.clientY,o.current,i).filter(h=>h.dir&&h.dir!==i).map(h=>h.el);o.current.style.cursor=x.length>0?"move":"",ue(x)}))},ae=()=>{o.current&&(o.current.style.cursor="",B())};return se("div",{id:t+"_resize_panel","data-resize_panel_key":f,"data-direction":n,className:`${P["flex-resize-panel"]} ${P[r]} ${l&&l!==""?l:""}`,ref:o,onMouseDown:K,onTouchStart:K,onMouseMove:J,onMouseEnter:J,onMouseLeave:ae,children:se("div",{className:P.hover,"aria-hidden":!0})})}export{ge as default};
|