@byeolnaerim/flex-layout 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flex-layout/components/FlexLayout.cjs +1 -110
- package/dist/flex-layout/components/FlexLayout.js +1 -85
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -262
- package/dist/flex-layout/components/FlexLayoutContainer.js +1 -232
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -68
- package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -44
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -246
- package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -216
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1252
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1236
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -532
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -509
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -55
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -63
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -33
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -53
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -23
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -133
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -107
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -245
- package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -229
- package/dist/flex-layout/components/index.cjs +1 -57
- package/dist/flex-layout/components/index.js +1 -17
- package/dist/flex-layout/hooks/index.cjs +1 -25
- package/dist/flex-layout/hooks/index.js +1 -3
- package/dist/flex-layout/hooks/useDrag.cjs +1 -289
- package/dist/flex-layout/hooks/useDrag.d.ts +15 -0
- package/dist/flex-layout/hooks/useDrag.js +1 -258
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -139
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -118
- package/dist/flex-layout/hooks/useListPaging.cjs +1 -212
- package/dist/flex-layout/hooks/useListPaging.js +1 -191
- package/dist/flex-layout/hooks/useSizes.cjs +1 -126
- package/dist/flex-layout/hooks/useSizes.js +1 -101
- package/dist/flex-layout/index.cjs +1 -31
- package/dist/flex-layout/index.js +1 -6
- package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -49
- package/dist/flex-layout/providers/FlexLayoutContext.js +1 -24
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -276
- package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -263
- package/dist/flex-layout/providers/index.cjs +1 -23
- package/dist/flex-layout/providers/index.js +1 -2
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -257
- package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -206
- package/dist/flex-layout/store/index.cjs +1 -23
- package/dist/flex-layout/store/index.js +1 -2
- package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
- package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -17
- package/dist/flex-layout/types/FlexDirectionTypes.js +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -17
- package/dist/flex-layout/types/FlexLayoutTypes.js +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -245
- package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -211
- package/dist/flex-layout/utils/index.cjs +1 -23
- package/dist/flex-layout/utils/index.js +1 -2
- package/dist/index.cjs +1 -23
- package/dist/index.js +1 -2
- package/dist/types/css.d.cjs +0 -1
- package/dist/types/css.d.js +0 -1
- package/package.json +116 -113
- package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayout.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutIFramePane.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
- package/dist/flex-layout/components/index.cjs.map +0 -1
- package/dist/flex-layout/components/index.js.map +0 -1
- package/dist/flex-layout/hooks/index.cjs.map +0 -1
- package/dist/flex-layout/hooks/index.js.map +0 -1
- package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
- package/dist/flex-layout/hooks/useDrag.js.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
- package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
- package/dist/flex-layout/hooks/useSizes.js.map +0 -1
- package/dist/flex-layout/index.cjs.map +0 -1
- package/dist/flex-layout/index.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
- package/dist/flex-layout/providers/index.cjs.map +0 -1
- package/dist/flex-layout/providers/index.js.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
- package/dist/flex-layout/store/index.cjs.map +0 -1
- package/dist/flex-layout/store/index.js.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
- package/dist/flex-layout/utils/index.cjs.map +0 -1
- package/dist/flex-layout/utils/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/types/css.d.cjs.map +0 -1
- package/dist/types/css.d.js.map +0 -1
|
@@ -1,258 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
useCallback,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState
|
|
7
|
-
} from "react";
|
|
8
|
-
import {
|
|
9
|
-
animationFrameScheduler,
|
|
10
|
-
auditTime,
|
|
11
|
-
BehaviorSubject,
|
|
12
|
-
distinctUntilChanged,
|
|
13
|
-
map,
|
|
14
|
-
Subject
|
|
15
|
-
} from "rxjs";
|
|
16
|
-
import { getClientXy } from "../utils/FlexLayoutUtils";
|
|
17
|
-
const dragStateSubject = new Subject();
|
|
18
|
-
const dragState = dragStateSubject;
|
|
19
|
-
const isResizingSubject = new BehaviorSubject(false);
|
|
20
|
-
const filterChildren = (obj) => {
|
|
21
|
-
const { children, ...rest } = obj || {};
|
|
22
|
-
return rest;
|
|
23
|
-
};
|
|
24
|
-
const useDragCapture = (targetRef) => {
|
|
25
|
-
const [state, setState] = useState(null);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const subscription = dragStateSubject.pipe(
|
|
28
|
-
auditTime(0, animationFrameScheduler),
|
|
29
|
-
map((value) => {
|
|
30
|
-
if (!targetRef || !targetRef.current) return null;
|
|
31
|
-
const { x, y } = value;
|
|
32
|
-
const rect = targetRef.current.getBoundingClientRect();
|
|
33
|
-
const {
|
|
34
|
-
width,
|
|
35
|
-
height,
|
|
36
|
-
x: rectX,
|
|
37
|
-
y: rectY,
|
|
38
|
-
right,
|
|
39
|
-
bottom
|
|
40
|
-
} = rect;
|
|
41
|
-
let isOver = false;
|
|
42
|
-
if (x < rectX || x > right || y < rectY || y > bottom) {
|
|
43
|
-
isOver = true;
|
|
44
|
-
}
|
|
45
|
-
const leftBoundary = rectX + width * 0.2;
|
|
46
|
-
const rightBoundary = right - width * 0.2;
|
|
47
|
-
const topBoundary = rectY + height * 0.2;
|
|
48
|
-
const bottomBoundary = bottom - height * 0.2;
|
|
49
|
-
let position = "centerBoundary";
|
|
50
|
-
if (x < leftBoundary) {
|
|
51
|
-
position = "leftBoundary";
|
|
52
|
-
} else if (x > rightBoundary) {
|
|
53
|
-
position = "rightBoundary";
|
|
54
|
-
} else if (y < topBoundary) {
|
|
55
|
-
position = "topBoundary";
|
|
56
|
-
} else if (y > bottomBoundary) {
|
|
57
|
-
position = "bottomBoundary";
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
positionName: position,
|
|
61
|
-
isOver,
|
|
62
|
-
...value
|
|
63
|
-
};
|
|
64
|
-
}),
|
|
65
|
-
distinctUntilChanged((prev, curr) => {
|
|
66
|
-
const { children: prevChildren, ..._prev } = prev || {};
|
|
67
|
-
const { children: currChildren, ..._curr } = curr || {};
|
|
68
|
-
return equal(filterChildren(_prev), filterChildren(_curr));
|
|
69
|
-
})
|
|
70
|
-
).subscribe({
|
|
71
|
-
next: setState,
|
|
72
|
-
error: (err) => console.error(err)
|
|
73
|
-
});
|
|
74
|
-
return () => subscription.unsubscribe();
|
|
75
|
-
}, [targetRef]);
|
|
76
|
-
return state;
|
|
77
|
-
};
|
|
78
|
-
const dropMovementEventSubject = new Subject();
|
|
79
|
-
const allSplitScreenCount = new BehaviorSubject(0);
|
|
80
|
-
const useDragEvents = ({
|
|
81
|
-
isBlockingActiveInput = false
|
|
82
|
-
}) => {
|
|
83
|
-
const dragResumeTimer = useRef(null);
|
|
84
|
-
const dragStartDelayTimer = useRef(
|
|
85
|
-
null
|
|
86
|
-
);
|
|
87
|
-
const scrollThreshold = 10;
|
|
88
|
-
const isScrolling = useRef(false);
|
|
89
|
-
const isPending = useRef(false);
|
|
90
|
-
const isMouseDown = useRef(false);
|
|
91
|
-
const isDragging = useRef(false);
|
|
92
|
-
const touchStartX = useRef(0);
|
|
93
|
-
const touchStartY = useRef(0);
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
return () => {
|
|
96
|
-
if (dragResumeTimer.current) {
|
|
97
|
-
clearTimeout(dragResumeTimer.current);
|
|
98
|
-
dragResumeTimer.current = null;
|
|
99
|
-
}
|
|
100
|
-
if (dragStartDelayTimer.current) {
|
|
101
|
-
clearTimeout(dragStartDelayTimer.current);
|
|
102
|
-
dragStartDelayTimer.current = null;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}, []);
|
|
106
|
-
const handleStart = useCallback(
|
|
107
|
-
({
|
|
108
|
-
event: _event,
|
|
109
|
-
dragStartCallback
|
|
110
|
-
}) => {
|
|
111
|
-
const event = _event instanceof Event ? _event : _event.nativeEvent;
|
|
112
|
-
if (dragResumeTimer.current) {
|
|
113
|
-
clearTimeout(dragResumeTimer.current);
|
|
114
|
-
dragResumeTimer.current = null;
|
|
115
|
-
}
|
|
116
|
-
if (dragStartDelayTimer.current) {
|
|
117
|
-
clearTimeout(dragStartDelayTimer.current);
|
|
118
|
-
dragStartDelayTimer.current = null;
|
|
119
|
-
}
|
|
120
|
-
if (event.target.contentEditable === "true" || isBlockingActiveInput && document.activeElement === event.target) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (event.cancelable && !(event instanceof globalThis.TouchEvent)) {
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
}
|
|
126
|
-
isPending.current = true;
|
|
127
|
-
isMouseDown.current = true;
|
|
128
|
-
isScrolling.current = false;
|
|
129
|
-
const xy = getClientXy(event);
|
|
130
|
-
if (!xy) return;
|
|
131
|
-
touchStartX.current = xy.clientX;
|
|
132
|
-
touchStartY.current = xy.clientY;
|
|
133
|
-
if (event.type.toLowerCase().startsWith("touch") || event instanceof globalThis.TouchEvent) {
|
|
134
|
-
isPending.current = false;
|
|
135
|
-
isDragging.current = true;
|
|
136
|
-
dragStartCallback({ x: xy.clientX, y: xy.clientY });
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
dragStartDelayTimer.current = setTimeout(() => {
|
|
140
|
-
if (!isPending.current || isScrolling.current) return;
|
|
141
|
-
isPending.current = false;
|
|
142
|
-
isDragging.current = true;
|
|
143
|
-
const xy2 = getClientXy(event);
|
|
144
|
-
if (!xy2) return;
|
|
145
|
-
const { clientX, clientY } = xy2;
|
|
146
|
-
dragStartCallback({ x: clientX, y: clientY });
|
|
147
|
-
}, 300);
|
|
148
|
-
},
|
|
149
|
-
[isBlockingActiveInput]
|
|
150
|
-
);
|
|
151
|
-
const handleMove = useCallback(
|
|
152
|
-
({
|
|
153
|
-
event: _event,
|
|
154
|
-
notDragCallback,
|
|
155
|
-
dragStartCallback,
|
|
156
|
-
moveingCallback
|
|
157
|
-
}) => {
|
|
158
|
-
if (!isMouseDown.current) return;
|
|
159
|
-
const event = _event instanceof Event ? _event : _event.nativeEvent;
|
|
160
|
-
const xy = getClientXy(event);
|
|
161
|
-
if (!xy) return;
|
|
162
|
-
const { clientX, clientY } = xy;
|
|
163
|
-
const deltaX = Math.abs(clientX - touchStartX.current);
|
|
164
|
-
const deltaY = Math.abs(clientY - touchStartY.current);
|
|
165
|
-
if (isPending.current && (event.type.toLowerCase().startsWith("touch") || event instanceof globalThis.TouchEvent) && (deltaX > scrollThreshold || deltaY > scrollThreshold)) {
|
|
166
|
-
if (dragStartDelayTimer.current) {
|
|
167
|
-
clearTimeout(dragStartDelayTimer.current);
|
|
168
|
-
dragStartDelayTimer.current = null;
|
|
169
|
-
}
|
|
170
|
-
isScrolling.current = true;
|
|
171
|
-
isPending.current = false;
|
|
172
|
-
isDragging.current = false;
|
|
173
|
-
if (notDragCallback)
|
|
174
|
-
notDragCallback({ x: clientX, y: clientY });
|
|
175
|
-
if (dragResumeTimer.current) {
|
|
176
|
-
clearTimeout(dragResumeTimer.current);
|
|
177
|
-
dragResumeTimer.current = null;
|
|
178
|
-
}
|
|
179
|
-
dragResumeTimer.current = setTimeout(() => {
|
|
180
|
-
if (!isMouseDown.current) return;
|
|
181
|
-
touchStartX.current = clientX;
|
|
182
|
-
touchStartY.current = clientY;
|
|
183
|
-
isPending.current = true;
|
|
184
|
-
isScrolling.current = false;
|
|
185
|
-
handleStart({ event: _event, dragStartCallback });
|
|
186
|
-
}, 400);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (!isDragging.current || isPending.current) return;
|
|
190
|
-
moveingCallback({ x: clientX, y: clientY });
|
|
191
|
-
},
|
|
192
|
-
[isBlockingActiveInput]
|
|
193
|
-
);
|
|
194
|
-
const handleEnd = useCallback(
|
|
195
|
-
({
|
|
196
|
-
event: _event,
|
|
197
|
-
dragEndCallback
|
|
198
|
-
}) => {
|
|
199
|
-
isScrolling.current = false;
|
|
200
|
-
isMouseDown.current = false;
|
|
201
|
-
if (isPending.current) {
|
|
202
|
-
isPending.current = false;
|
|
203
|
-
if (dragStartDelayTimer.current) {
|
|
204
|
-
clearTimeout(dragStartDelayTimer.current);
|
|
205
|
-
dragStartDelayTimer.current = null;
|
|
206
|
-
}
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const event = _event instanceof Event ? _event : _event.nativeEvent;
|
|
210
|
-
if (!isDragging.current) return;
|
|
211
|
-
isDragging.current = false;
|
|
212
|
-
const xy = getClientXy(event);
|
|
213
|
-
if (!xy) return;
|
|
214
|
-
const { clientX, clientY } = xy;
|
|
215
|
-
dragEndCallback({ x: clientX, y: clientY });
|
|
216
|
-
},
|
|
217
|
-
[isBlockingActiveInput]
|
|
218
|
-
);
|
|
219
|
-
return {
|
|
220
|
-
handleStart,
|
|
221
|
-
handleMove,
|
|
222
|
-
handleEnd
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
const folderEventSubject = new Subject();
|
|
226
|
-
const setFolderEvent = (newValue) => {
|
|
227
|
-
folderEventSubject.next(newValue);
|
|
228
|
-
};
|
|
229
|
-
const useFolderEvent = () => {
|
|
230
|
-
const [folderEvent, setFolderEvent2] = useState(
|
|
231
|
-
null
|
|
232
|
-
);
|
|
233
|
-
useEffect(() => {
|
|
234
|
-
const subscription = folderEventSubject.subscribe((e) => {
|
|
235
|
-
if (!e) return;
|
|
236
|
-
setFolderEvent2(e);
|
|
237
|
-
});
|
|
238
|
-
return () => {
|
|
239
|
-
if (subscription) {
|
|
240
|
-
subscription.unsubscribe();
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}, []);
|
|
244
|
-
return { folderEvent };
|
|
245
|
-
};
|
|
246
|
-
export {
|
|
247
|
-
allSplitScreenCount,
|
|
248
|
-
dragState,
|
|
249
|
-
dragStateSubject,
|
|
250
|
-
dropMovementEventSubject,
|
|
251
|
-
folderEventSubject,
|
|
252
|
-
isResizingSubject,
|
|
253
|
-
setFolderEvent,
|
|
254
|
-
useDragCapture,
|
|
255
|
-
useDragEvents,
|
|
256
|
-
useFolderEvent
|
|
257
|
-
};
|
|
258
|
-
//# sourceMappingURL=useDrag.js.map
|
|
1
|
+
import X from"fast-deep-equal";import{useCallback as S,useEffect as C,useRef as y,useState as N}from"react";import{animationFrameScheduler as F,auditTime as Y,BehaviorSubject as O,distinctUntilChanged as P,map as L,Subject as h}from"rxjs";import{getClientXy as D}from"../utils/FlexLayoutUtils";const R=new h,J=R,Q=new O(!1),Z=new h,B=n=>{const{children:r,...e}=n||{};return e},$=n=>{const[r,e]=N(null);return C(()=>{const b=R.pipe(Y(0,F),L(c=>{if(!n||!n.current)return null;const{x:t,y:s}=c,l=n.current.getBoundingClientRect(),{width:g,height:d,x:v,y:E,right:x,bottom:o}=l;let m=!1;(t<v||t>x||s<E||s>o)&&(m=!0);const u=v+g*.2,i=x-g*.2,p=E+d*.2,f=o-d*.2;let a="centerBoundary";return t<u?a="leftBoundary":t>i?a="rightBoundary":s<p?a="topBoundary":s>f&&(a="bottomBoundary"),{positionName:a,isOver:m,...c}}),P((c,t)=>{const{children:s,...l}=c||{},{children:g,...d}=t||{};return X(B(l),B(d))})).subscribe({next:e,error:c=>console.error(c)});return()=>b.unsubscribe()},[n]),r},A=new h,_=new O(0),ee=({isBlockingActiveInput:n=!1})=>{const r=y(null),e=y(null),b=10,c=y(!1),t=y(!1),s=y(!1),l=y(!1),g=y(0),d=y(0);C(()=>()=>{r.current&&(clearTimeout(r.current),r.current=null),e.current&&(clearTimeout(e.current),e.current=null)},[]);const v=S(({event:o,dragStartCallback:m})=>{const u=o instanceof Event?o:o.nativeEvent;if(r.current&&(clearTimeout(r.current),r.current=null),e.current&&(clearTimeout(e.current),e.current=null),u.target.contentEditable==="true"||n&&document.activeElement===u.target)return;u.cancelable&&!(u instanceof globalThis.TouchEvent)&&u.preventDefault(),t.current=!0,s.current=!0,c.current=!1;const i=D(u);if(i){if(g.current=i.clientX,d.current=i.clientY,u.type.toLowerCase().startsWith("touch")||u instanceof globalThis.TouchEvent){t.current=!1,l.current=!0,m({x:i.clientX,y:i.clientY});return}e.current=setTimeout(()=>{if(!t.current||c.current)return;t.current=!1,l.current=!0;const p=D(u);if(!p)return;const{clientX:f,clientY:a}=p;m({x:f,y:a})},300)}},[n]),E=S(({event:o,notDragCallback:m,dragStartCallback:u,moveingCallback:i})=>{if(!s.current)return;const p=o instanceof Event?o:o.nativeEvent,f=D(p);if(!f)return;const{clientX:a,clientY:T}=f,w=Math.abs(a-g.current),j=Math.abs(T-d.current);if(t.current&&(p.type.toLowerCase().startsWith("touch")||p instanceof globalThis.TouchEvent)&&(w>b||j>b)){e.current&&(clearTimeout(e.current),e.current=null),c.current=!0,t.current=!1,l.current=!1,m&&m({x:a,y:T}),r.current&&(clearTimeout(r.current),r.current=null),r.current=setTimeout(()=>{s.current&&(g.current=a,d.current=T,t.current=!0,c.current=!1,v({event:o,dragStartCallback:u}))},400);return}!l.current||t.current||i({x:a,y:T})},[n]),x=S(({event:o,dragEndCallback:m})=>{if(c.current=!1,s.current=!1,t.current){t.current=!1,e.current&&(clearTimeout(e.current),e.current=null);return}const u=o instanceof Event?o:o.nativeEvent;if(!l.current)return;l.current=!1;const i=D(u);if(!i)return;const{clientX:p,clientY:f}=i;m({x:p,y:f})},[n]);return{handleStart:v,handleMove:E,handleEnd:x}},M=new h,te=n=>{M.next(n)},ne=()=>{const[n,r]=N(null);return C(()=>{const e=M.subscribe(b=>{b&&r(b)});return()=>{e&&e.unsubscribe()}},[]),{folderEvent:n}};export{_ as allSplitScreenCount,J as dragState,R as dragStateSubject,A as dropMovementEventSubject,M as folderEventSubject,Q as isResizingSubject,Z as resizeDragSubject,te as setFolderEvent,$ as useDragCapture,ee as useDragEvents,ne as useFolderEvent};
|
|
@@ -1,139 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useFlexLayoutSplitScreen_exports = {};
|
|
20
|
-
__export(useFlexLayoutSplitScreen_exports, {
|
|
21
|
-
useFlexLayoutSplitScreen: () => useFlexLayoutSplitScreen
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useFlexLayoutSplitScreen_exports);
|
|
24
|
-
var import_react = require("react");
|
|
25
|
-
var import_useDrag = require("./useDrag");
|
|
26
|
-
function useFlexLayoutSplitScreen({
|
|
27
|
-
isSplitInitial = false,
|
|
28
|
-
parentDirection,
|
|
29
|
-
directionInitial = "row",
|
|
30
|
-
selfContainerName,
|
|
31
|
-
parentLayoutName,
|
|
32
|
-
layoutName
|
|
33
|
-
}) {
|
|
34
|
-
const [direction, setDirection] = (0, import_react.useState)(
|
|
35
|
-
directionInitial
|
|
36
|
-
);
|
|
37
|
-
const [isSplit, setIsSplit] = (0, import_react.useState)(isSplitInitial);
|
|
38
|
-
const [boundaryContainerSize, setBoundaryContainerSize] = (0, import_react.useState)(null);
|
|
39
|
-
const [centerDropTargetComponent, setCenterDropTargetComponent] = (0, import_react.useState)([]);
|
|
40
|
-
const [afterDropTargetComponent, setAfterDropTargetComponent] = (0, import_react.useState)([]);
|
|
41
|
-
const [beforeDropTargetComponent, setBeforeDropTargetComponent] = (0, import_react.useState)([]);
|
|
42
|
-
const layoutRef = (0, import_react.useRef)(null);
|
|
43
|
-
const dragState = (0, import_useDrag.useDragCapture)(layoutRef);
|
|
44
|
-
(0, import_react.useEffect)(() => {
|
|
45
|
-
if (!dragState) {
|
|
46
|
-
setBoundaryContainerSize(null);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const {
|
|
50
|
-
isDrop,
|
|
51
|
-
isDragging,
|
|
52
|
-
positionName,
|
|
53
|
-
containerName,
|
|
54
|
-
children: dropComponent,
|
|
55
|
-
isOver,
|
|
56
|
-
navigationTitle,
|
|
57
|
-
dropEndCallback,
|
|
58
|
-
x,
|
|
59
|
-
y,
|
|
60
|
-
screenKey
|
|
61
|
-
} = dragState;
|
|
62
|
-
const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
|
|
63
|
-
if ((isOver || isDrop) && boundaryContainerSize) {
|
|
64
|
-
setBoundaryContainerSize(null);
|
|
65
|
-
}
|
|
66
|
-
if (selfContainerName === containerName || selfContainerName.startsWith(containerName + "_")) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (isDrop && screenKey) {
|
|
70
|
-
const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
|
|
71
|
-
if (!isSplit && !isOver) {
|
|
72
|
-
if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
|
|
73
|
-
setIsSplit(true);
|
|
74
|
-
setDirection(dropDirection);
|
|
75
|
-
}
|
|
76
|
-
import_useDrag.dropMovementEventSubject.next({
|
|
77
|
-
state: "append",
|
|
78
|
-
targetContainerName: containerName,
|
|
79
|
-
targetParentLayoutName: parentLayoutName,
|
|
80
|
-
targetLayoutName: layoutName,
|
|
81
|
-
targetComponent: dropComponent,
|
|
82
|
-
orderName,
|
|
83
|
-
x,
|
|
84
|
-
y,
|
|
85
|
-
dropEndCallback,
|
|
86
|
-
dropTargetComponentEvent: {
|
|
87
|
-
navigationTitle,
|
|
88
|
-
dropDocumentOutsideOption: dragState?.dropDocumentOutsideOption,
|
|
89
|
-
direction: dropDirection,
|
|
90
|
-
screenKey
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (isDragging && !isSplit && !isOver) {
|
|
96
|
-
const newSize = {
|
|
97
|
-
left: positionName === "rightBoundary" ? "50%" : "0",
|
|
98
|
-
top: positionName === "bottomBoundary" ? "50%" : "0",
|
|
99
|
-
width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
|
|
100
|
-
height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
|
|
101
|
-
};
|
|
102
|
-
if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
|
|
103
|
-
setBoundaryContainerSize(newSize);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}, [
|
|
107
|
-
dragState,
|
|
108
|
-
isSplit,
|
|
109
|
-
boundaryContainerSize,
|
|
110
|
-
parentLayoutName,
|
|
111
|
-
layoutName,
|
|
112
|
-
selfContainerName,
|
|
113
|
-
direction
|
|
114
|
-
]);
|
|
115
|
-
return {
|
|
116
|
-
direction,
|
|
117
|
-
setDirection,
|
|
118
|
-
isSplit,
|
|
119
|
-
setIsSplit,
|
|
120
|
-
boundaryContainerSize,
|
|
121
|
-
//setBoundaryContainerSize,
|
|
122
|
-
centerDropTargetComponent,
|
|
123
|
-
afterDropTargetComponent,
|
|
124
|
-
beforeDropTargetComponent,
|
|
125
|
-
setAfterDropTargetComponent,
|
|
126
|
-
setBeforeDropTargetComponent,
|
|
127
|
-
setCenterDropTargetComponent,
|
|
128
|
-
//dropTargetComponent,
|
|
129
|
-
//setDropTargetComponent,
|
|
130
|
-
//setDropPosition,
|
|
131
|
-
isOver: dragState?.isOver,
|
|
132
|
-
layoutRef
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
-
0 && (module.exports = {
|
|
137
|
-
useFlexLayoutSplitScreen
|
|
138
|
-
});
|
|
139
|
-
//# sourceMappingURL=useFlexLayoutSplitScreen.cjs.map
|
|
1
|
+
"use strict";var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var F=(n,o)=>{for(var i in o)f(n,i,{get:o[i],enumerable:!0})},H=(n,o,i,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of k(o))!A.call(n,r)&&r!==i&&f(n,r,{get:()=>o[r],enumerable:!(a=j(o,r))||a.enumerable});return n};var K=n=>H(f({},"__esModule",{value:!0}),n);var W={};F(W,{useFlexLayoutSplitScreen:()=>P});module.exports=K(W);var e=require("react"),l=require("./useDrag");function P({isSplitInitial:n=!1,parentDirection:o,directionInitial:i="row",selfContainerName:a,parentLayoutName:r,layoutName:y}){const[D,C]=(0,e.useState)(i),[u,B]=(0,e.useState)(n),[g,c]=(0,e.useState)(null),[b,O]=(0,e.useState)([]),[v,w]=(0,e.useState)([]),[N,E]=(0,e.useState)([]),S=(0,e.useRef)(null),s=(0,l.useDragCapture)(S);return(0,e.useEffect)(()=>{if(!s){c(null);return}const{isDrop:T,isDragging:x,positionName:t,containerName:d,children:L,isOver:m,navigationTitle:z,dropEndCallback:I,x:J,y:M,screenKey:h}=s,R=t==="leftBoundary"||t==="topBoundary"?"before":t==="rightBoundary"||t==="bottomBoundary"?"after":"center";if((m||T)&&g&&c(null),!(a===d||a.startsWith(d+"_"))){if(T&&h){const p=t==="leftBoundary"||t==="rightBoundary"?"row":"column";!u&&!m&&(t!=="centerBoundary"&&p!==o&&(B(!0),C(p)),l.dropMovementEventSubject.next({state:"append",targetContainerName:d,targetParentLayoutName:r,targetLayoutName:y,targetComponent:L,orderName:R,x:J,y:M,dropEndCallback:I,dropTargetComponentEvent:{navigationTitle:z,dropDocumentOutsideOption:s?.dropDocumentOutsideOption,direction:p,screenKey:h}}))}if(x&&!u&&!m){const p={left:t==="rightBoundary"?"50%":"0",top:t==="bottomBoundary"?"50%":"0",width:t==="leftBoundary"||t==="rightBoundary"?"50%":"100%",height:t==="topBoundary"||t==="bottomBoundary"?"50%":"100%"};JSON.stringify(g)!==JSON.stringify(p)&&c(p)}}},[s,u,g,r,y,a,D]),{direction:D,setDirection:C,isSplit:u,setIsSplit:B,boundaryContainerSize:g,centerDropTargetComponent:b,afterDropTargetComponent:v,beforeDropTargetComponent:N,setAfterDropTargetComponent:w,setBeforeDropTargetComponent:E,setCenterDropTargetComponent:O,isOver:s?.isOver,layoutRef:S}}0&&(module.exports={useFlexLayoutSplitScreen});
|
|
@@ -1,118 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
dropMovementEventSubject,
|
|
4
|
-
useDragCapture
|
|
5
|
-
} from "./useDrag";
|
|
6
|
-
function useFlexLayoutSplitScreen({
|
|
7
|
-
isSplitInitial = false,
|
|
8
|
-
parentDirection,
|
|
9
|
-
directionInitial = "row",
|
|
10
|
-
selfContainerName,
|
|
11
|
-
parentLayoutName,
|
|
12
|
-
layoutName
|
|
13
|
-
}) {
|
|
14
|
-
const [direction, setDirection] = useState(
|
|
15
|
-
directionInitial
|
|
16
|
-
);
|
|
17
|
-
const [isSplit, setIsSplit] = useState(isSplitInitial);
|
|
18
|
-
const [boundaryContainerSize, setBoundaryContainerSize] = useState(null);
|
|
19
|
-
const [centerDropTargetComponent, setCenterDropTargetComponent] = useState([]);
|
|
20
|
-
const [afterDropTargetComponent, setAfterDropTargetComponent] = useState([]);
|
|
21
|
-
const [beforeDropTargetComponent, setBeforeDropTargetComponent] = useState([]);
|
|
22
|
-
const layoutRef = useRef(null);
|
|
23
|
-
const dragState = useDragCapture(layoutRef);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!dragState) {
|
|
26
|
-
setBoundaryContainerSize(null);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const {
|
|
30
|
-
isDrop,
|
|
31
|
-
isDragging,
|
|
32
|
-
positionName,
|
|
33
|
-
containerName,
|
|
34
|
-
children: dropComponent,
|
|
35
|
-
isOver,
|
|
36
|
-
navigationTitle,
|
|
37
|
-
dropEndCallback,
|
|
38
|
-
x,
|
|
39
|
-
y,
|
|
40
|
-
screenKey
|
|
41
|
-
} = dragState;
|
|
42
|
-
const orderName = positionName === "leftBoundary" || positionName === "topBoundary" ? "before" : positionName === "rightBoundary" || positionName === "bottomBoundary" ? "after" : "center";
|
|
43
|
-
if ((isOver || isDrop) && boundaryContainerSize) {
|
|
44
|
-
setBoundaryContainerSize(null);
|
|
45
|
-
}
|
|
46
|
-
if (selfContainerName === containerName || selfContainerName.startsWith(containerName + "_")) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (isDrop && screenKey) {
|
|
50
|
-
const dropDirection = positionName === "leftBoundary" || positionName === "rightBoundary" ? "row" : "column";
|
|
51
|
-
if (!isSplit && !isOver) {
|
|
52
|
-
if (positionName !== "centerBoundary" && dropDirection !== parentDirection) {
|
|
53
|
-
setIsSplit(true);
|
|
54
|
-
setDirection(dropDirection);
|
|
55
|
-
}
|
|
56
|
-
dropMovementEventSubject.next({
|
|
57
|
-
state: "append",
|
|
58
|
-
targetContainerName: containerName,
|
|
59
|
-
targetParentLayoutName: parentLayoutName,
|
|
60
|
-
targetLayoutName: layoutName,
|
|
61
|
-
targetComponent: dropComponent,
|
|
62
|
-
orderName,
|
|
63
|
-
x,
|
|
64
|
-
y,
|
|
65
|
-
dropEndCallback,
|
|
66
|
-
dropTargetComponentEvent: {
|
|
67
|
-
navigationTitle,
|
|
68
|
-
dropDocumentOutsideOption: dragState?.dropDocumentOutsideOption,
|
|
69
|
-
direction: dropDirection,
|
|
70
|
-
screenKey
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (isDragging && !isSplit && !isOver) {
|
|
76
|
-
const newSize = {
|
|
77
|
-
left: positionName === "rightBoundary" ? "50%" : "0",
|
|
78
|
-
top: positionName === "bottomBoundary" ? "50%" : "0",
|
|
79
|
-
width: positionName === "leftBoundary" || positionName === "rightBoundary" ? "50%" : "100%",
|
|
80
|
-
height: positionName === "topBoundary" || positionName === "bottomBoundary" ? "50%" : "100%"
|
|
81
|
-
};
|
|
82
|
-
if (JSON.stringify(boundaryContainerSize) !== JSON.stringify(newSize)) {
|
|
83
|
-
setBoundaryContainerSize(newSize);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}, [
|
|
87
|
-
dragState,
|
|
88
|
-
isSplit,
|
|
89
|
-
boundaryContainerSize,
|
|
90
|
-
parentLayoutName,
|
|
91
|
-
layoutName,
|
|
92
|
-
selfContainerName,
|
|
93
|
-
direction
|
|
94
|
-
]);
|
|
95
|
-
return {
|
|
96
|
-
direction,
|
|
97
|
-
setDirection,
|
|
98
|
-
isSplit,
|
|
99
|
-
setIsSplit,
|
|
100
|
-
boundaryContainerSize,
|
|
101
|
-
//setBoundaryContainerSize,
|
|
102
|
-
centerDropTargetComponent,
|
|
103
|
-
afterDropTargetComponent,
|
|
104
|
-
beforeDropTargetComponent,
|
|
105
|
-
setAfterDropTargetComponent,
|
|
106
|
-
setBeforeDropTargetComponent,
|
|
107
|
-
setCenterDropTargetComponent,
|
|
108
|
-
//dropTargetComponent,
|
|
109
|
-
//setDropTargetComponent,
|
|
110
|
-
//setDropPosition,
|
|
111
|
-
isOver: dragState?.isOver,
|
|
112
|
-
layoutRef
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
export {
|
|
116
|
-
useFlexLayoutSplitScreen
|
|
117
|
-
};
|
|
118
|
-
//# sourceMappingURL=useFlexLayoutSplitScreen.js.map
|
|
1
|
+
import{useEffect as M,useRef as R,useState as e}from"react";import{dropMovementEventSubject as j,useDragCapture as k}from"./useDrag";function K({isSplitInitial:C=!1,parentDirection:B,directionInitial:S="row",selfContainerName:a,parentLayoutName:g,layoutName:l}){const[c,d]=e(S),[r,m]=e(C),[i,p]=e(null),[T,h]=e([]),[b,O]=e([]),[v,w]=e([]),f=R(null),n=k(f);return M(()=>{if(!n){p(null);return}const{isDrop:y,isDragging:N,positionName:t,containerName:s,children:E,isOver:u,navigationTitle:x,dropEndCallback:L,x:z,y:I,screenKey:D}=n,J=t==="leftBoundary"||t==="topBoundary"?"before":t==="rightBoundary"||t==="bottomBoundary"?"after":"center";if((u||y)&&i&&p(null),!(a===s||a.startsWith(s+"_"))){if(y&&D){const o=t==="leftBoundary"||t==="rightBoundary"?"row":"column";!r&&!u&&(t!=="centerBoundary"&&o!==B&&(m(!0),d(o)),j.next({state:"append",targetContainerName:s,targetParentLayoutName:g,targetLayoutName:l,targetComponent:E,orderName:J,x:z,y:I,dropEndCallback:L,dropTargetComponentEvent:{navigationTitle:x,dropDocumentOutsideOption:n?.dropDocumentOutsideOption,direction:o,screenKey:D}}))}if(N&&!r&&!u){const o={left:t==="rightBoundary"?"50%":"0",top:t==="bottomBoundary"?"50%":"0",width:t==="leftBoundary"||t==="rightBoundary"?"50%":"100%",height:t==="topBoundary"||t==="bottomBoundary"?"50%":"100%"};JSON.stringify(i)!==JSON.stringify(o)&&p(o)}}},[n,r,i,g,l,a,c]),{direction:c,setDirection:d,isSplit:r,setIsSplit:m,boundaryContainerSize:i,centerDropTargetComponent:T,afterDropTargetComponent:b,beforeDropTargetComponent:v,setAfterDropTargetComponent:O,setBeforeDropTargetComponent:w,setCenterDropTargetComponent:h,isOver:n?.isOver,layoutRef:f}}export{K as useFlexLayoutSplitScreen};
|