@byeolnaerim/flex-layout 0.0.8 → 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 -76
- package/dist/flex-layout/components/FlexLayout.js +1 -70
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -196
- package/dist/flex-layout/components/FlexLayoutContainer.js +1 -189
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.d.ts +4 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -0
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -192
- package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -186
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1211
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1197
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -339
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -333
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -32
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -40
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -34
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -30
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -24
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -109
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -103
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -226
- package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +1 -0
- package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -224
- package/dist/flex-layout/components/index.cjs +1 -52
- package/dist/flex-layout/components/index.js +1 -9
- package/dist/flex-layout/hooks/index.cjs +1 -21
- package/dist/flex-layout/hooks/index.js +1 -4
- package/dist/flex-layout/hooks/useDrag.cjs +1 -232
- package/dist/flex-layout/hooks/useDrag.d.ts +20 -0
- package/dist/flex-layout/hooks/useDrag.js +1 -219
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -118
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -116
- package/dist/flex-layout/hooks/useListPaging.cjs +1 -179
- package/dist/flex-layout/hooks/useListPaging.js +1 -175
- package/dist/flex-layout/hooks/useSizes.cjs +1 -104
- package/dist/flex-layout/hooks/useSizes.js +1 -101
- package/dist/flex-layout/index.cjs +1 -42
- package/dist/flex-layout/index.js +1 -7
- package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -26
- package/dist/flex-layout/providers/FlexLayoutContext.js +1 -23
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -247
- package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -238
- package/dist/flex-layout/providers/index.cjs +1 -14
- package/dist/flex-layout/providers/index.js +1 -3
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -203
- package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +1 -0
- package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -181
- package/dist/flex-layout/store/index.cjs +1 -14
- package/dist/flex-layout/store/index.js +1 -3
- package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
- package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -4
- package/dist/flex-layout/types/FlexDirectionTypes.js +0 -3
- package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -4
- package/dist/flex-layout/types/FlexLayoutTypes.d.ts +1 -3
- package/dist/flex-layout/types/FlexLayoutTypes.js +0 -3
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -208
- package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +4 -4
- package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -196
- package/dist/flex-layout/utils/index.cjs +1 -14
- package/dist/flex-layout/utils/index.js +1 -3
- package/dist/index.cjs +1 -14
- package/dist/index.js +1 -3
- package/dist/types/css.d.cjs +1 -4
- package/dist/types/css.d.js +0 -3
- package/package.json +116 -109
- 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/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/types/css.d.cjs.map +0 -1
- package/dist/types/css.d.js.map +0 -1
|
@@ -1,339 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
var useDrag = require('../hooks/useDrag');
|
|
6
|
-
var styles = require('../styles/FlexLayout.module.css');
|
|
7
|
-
var FlexLayoutUtils = require('../utils/FlexLayoutUtils');
|
|
8
|
-
|
|
9
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
|
|
11
|
-
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
12
|
-
|
|
13
|
-
const MAX_STEP = 18;
|
|
14
|
-
function edgeVelocity(x, y) {
|
|
15
|
-
const w = window.innerWidth, h = window.innerHeight;
|
|
16
|
-
const mx = w * 0.15, my = h * 0.15;
|
|
17
|
-
let vx = 0;
|
|
18
|
-
if (x < mx)
|
|
19
|
-
vx = -((mx - x) / mx) * MAX_STEP;
|
|
20
|
-
else if (x > w - mx)
|
|
21
|
-
vx = (x - (w - mx)) / mx * MAX_STEP;
|
|
22
|
-
let vy = 0;
|
|
23
|
-
if (y < my)
|
|
24
|
-
vy = -((my - y) / my) * MAX_STEP;
|
|
25
|
-
else if (y > h - my)
|
|
26
|
-
vy = (y - (h - my)) / my * MAX_STEP;
|
|
27
|
-
return { vx, vy };
|
|
28
|
-
}
|
|
29
|
-
function FlexLayoutSplitScreenDragBox({
|
|
30
|
-
onMouseDown,
|
|
31
|
-
onTouchStart,
|
|
32
|
-
dropEndCallback,
|
|
33
|
-
style,
|
|
34
|
-
navigationTitle,
|
|
35
|
-
targetComponent,
|
|
36
|
-
containerName,
|
|
37
|
-
children,
|
|
38
|
-
className,
|
|
39
|
-
dropDocumentOutsideOption,
|
|
40
|
-
screenKey = Array.from(
|
|
41
|
-
window.crypto.getRandomValues(new Uint32Array(16)),
|
|
42
|
-
(e) => e.toString(32).padStart(2, "0")
|
|
43
|
-
).join(""),
|
|
44
|
-
isBlockingActiveInput = false,
|
|
45
|
-
customData = {},
|
|
46
|
-
scrollTargetRef,
|
|
47
|
-
...props
|
|
48
|
-
}) {
|
|
49
|
-
const scrollRAF = react.useRef(null);
|
|
50
|
-
const velocity = react.useRef({ vx: 0, vy: 0 });
|
|
51
|
-
const ref = react.useRef(null);
|
|
52
|
-
const clonedNodeRef = react.useRef(null);
|
|
53
|
-
const clonedWidth = react.useRef(null);
|
|
54
|
-
const clonedHeight = react.useRef(null);
|
|
55
|
-
const hrefUrlRef = react.useRef("");
|
|
56
|
-
const { handleStart, handleMove, handleEnd } = useDrag.useDragEvents({
|
|
57
|
-
isBlockingActiveInput
|
|
58
|
-
});
|
|
59
|
-
const handleMoveWrapper = (event) => {
|
|
60
|
-
let x = 0;
|
|
61
|
-
let y = 0;
|
|
62
|
-
if (event.type === "touchmove") {
|
|
63
|
-
const t = event.touches[0];
|
|
64
|
-
x = t.clientX;
|
|
65
|
-
y = t.clientY;
|
|
66
|
-
} else {
|
|
67
|
-
const m = event;
|
|
68
|
-
x = m.clientX;
|
|
69
|
-
y = m.clientY;
|
|
70
|
-
}
|
|
71
|
-
const { vx, vy } = edgeVelocity(x, y);
|
|
72
|
-
const inEdge = vx !== 0 || vy !== 0;
|
|
73
|
-
if (clonedNodeRef.current?.isConnected && !inEdge) {
|
|
74
|
-
event.preventDefault();
|
|
75
|
-
if (scrollRAF.current) {
|
|
76
|
-
cancelAnimationFrame(scrollRAF.current);
|
|
77
|
-
scrollRAF.current = null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (clonedNodeRef.current?.isConnected && inEdge) {
|
|
81
|
-
event.preventDefault();
|
|
82
|
-
velocity.current = { vx, vy };
|
|
83
|
-
if (!scrollRAF.current) {
|
|
84
|
-
const step = () => {
|
|
85
|
-
const target = scrollTargetRef?.current ?? document.scrollingElement;
|
|
86
|
-
if (target?.scrollBy) {
|
|
87
|
-
target.scrollBy(
|
|
88
|
-
velocity.current.vx,
|
|
89
|
-
velocity.current.vy
|
|
90
|
-
);
|
|
91
|
-
} else {
|
|
92
|
-
window.scrollBy(
|
|
93
|
-
velocity.current.vx,
|
|
94
|
-
velocity.current.vy
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
if (velocity.current.vx === 0 && velocity.current.vy === 0) {
|
|
98
|
-
scrollRAF.current = null;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
scrollRAF.current = requestAnimationFrame(step);
|
|
102
|
-
};
|
|
103
|
-
scrollRAF.current = requestAnimationFrame(step);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (event.type !== "touchmove") {
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
}
|
|
109
|
-
handleMove({
|
|
110
|
-
event,
|
|
111
|
-
notDragCallback: ({ x: x2, y: y2 }) => {
|
|
112
|
-
if (clonedNodeRef.current) clonedNodeRef.current.remove();
|
|
113
|
-
},
|
|
114
|
-
dragStartCallback: ({ x: x2, y: y2 }) => {
|
|
115
|
-
if (!clonedNodeRef.current) return;
|
|
116
|
-
navigator.vibrate(100);
|
|
117
|
-
clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
|
|
118
|
-
clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
|
|
119
|
-
},
|
|
120
|
-
moveingCallback: ({ x: x2, y: y2 }) => {
|
|
121
|
-
if (clonedNodeRef.current?.isConnected) {
|
|
122
|
-
clonedNodeRef.current.style.left = `${x2 - (clonedWidth.current || 0) / 2}px`;
|
|
123
|
-
clonedNodeRef.current.style.top = `${y2 - (clonedHeight.current || 0) / 2}px`;
|
|
124
|
-
}
|
|
125
|
-
useDrag.dragState.next({
|
|
126
|
-
isDragging: true,
|
|
127
|
-
isDrop: false,
|
|
128
|
-
navigationTitle,
|
|
129
|
-
children: targetComponent,
|
|
130
|
-
x: x2,
|
|
131
|
-
y: y2,
|
|
132
|
-
containerName,
|
|
133
|
-
dropDocumentOutsideOption,
|
|
134
|
-
customData
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
const handleEndWrapper = (event) => {
|
|
140
|
-
if (scrollRAF.current !== null) {
|
|
141
|
-
cancelAnimationFrame(scrollRAF.current);
|
|
142
|
-
scrollRAF.current = null;
|
|
143
|
-
}
|
|
144
|
-
velocity.current = { vx: 0, vy: 0 };
|
|
145
|
-
handleEnd({
|
|
146
|
-
event,
|
|
147
|
-
dragEndCallback: ({ x, y }) => {
|
|
148
|
-
const href = hrefUrlRef.current;
|
|
149
|
-
if (clonedNodeRef.current) clonedNodeRef.current.remove();
|
|
150
|
-
if (dropDocumentOutsideOption && FlexLayoutUtils.isDocumentOut({ x, y })) {
|
|
151
|
-
if (dropDocumentOutsideOption.isNewTap || !dropDocumentOutsideOption.widthRatio && !dropDocumentOutsideOption.heightRatio) {
|
|
152
|
-
window.open(href, "_blank");
|
|
153
|
-
} else {
|
|
154
|
-
const width = window.innerWidth * (dropDocumentOutsideOption.widthRatio || 1);
|
|
155
|
-
const height = window.innerHeight * (dropDocumentOutsideOption.heightRatio || 1);
|
|
156
|
-
window.open(
|
|
157
|
-
href,
|
|
158
|
-
"_blank",
|
|
159
|
-
`width=${width},height=${height},left=${window.screenLeft - x * -1 - width},top=${window.screenTop + y}`
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
useDrag.dragState.next({
|
|
164
|
-
isDragging: false,
|
|
165
|
-
isDrop: true,
|
|
166
|
-
navigationTitle,
|
|
167
|
-
children: targetComponent,
|
|
168
|
-
x,
|
|
169
|
-
y,
|
|
170
|
-
containerName,
|
|
171
|
-
dropDocumentOutsideOption,
|
|
172
|
-
dropEndCallback,
|
|
173
|
-
screenKey,
|
|
174
|
-
customData
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
react.useEffect(() => {
|
|
180
|
-
if (ref.current) {
|
|
181
|
-
const clone = ref.current.cloneNode(true);
|
|
182
|
-
const originRect = ref.current.getBoundingClientRect();
|
|
183
|
-
clone.style.width = originRect.width + "px";
|
|
184
|
-
clone.style.height = originRect.height + "px";
|
|
185
|
-
clone.style.opacity = "0.3";
|
|
186
|
-
clone.style.backdropFilter = "blur(6px)";
|
|
187
|
-
clonedWidth.current = originRect.width;
|
|
188
|
-
clonedHeight.current = originRect.height;
|
|
189
|
-
if (dropDocumentOutsideOption?.openUrl) {
|
|
190
|
-
hrefUrlRef.current = dropDocumentOutsideOption.openUrl;
|
|
191
|
-
const href = document.createElement("span");
|
|
192
|
-
href.textContent = hrefUrlRef.current;
|
|
193
|
-
clone.prepend(href);
|
|
194
|
-
}
|
|
195
|
-
if (navigationTitle) {
|
|
196
|
-
const title = document.createElement("span");
|
|
197
|
-
title.textContent = navigationTitle;
|
|
198
|
-
clone.prepend(title);
|
|
199
|
-
}
|
|
200
|
-
clone.style.position = "fixed";
|
|
201
|
-
clonedNodeRef.current = clone;
|
|
202
|
-
clonedNodeRef.current.classList.add(
|
|
203
|
-
styles__default.default["flex-split-screen-drag-box-clone"]
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
}, []);
|
|
207
|
-
react.useEffect(() => {
|
|
208
|
-
const moveEvents = [
|
|
209
|
-
"mousemove",
|
|
210
|
-
"touchmove"
|
|
211
|
-
];
|
|
212
|
-
const endEvents = ["mouseup", "touchend"];
|
|
213
|
-
moveEvents.forEach((eventName) => {
|
|
214
|
-
window.addEventListener(eventName, handleMoveWrapper, {
|
|
215
|
-
passive: false
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
endEvents.forEach((eventName) => {
|
|
219
|
-
window.addEventListener(eventName, handleEndWrapper);
|
|
220
|
-
});
|
|
221
|
-
return () => {
|
|
222
|
-
moveEvents.forEach((eventName) => {
|
|
223
|
-
window.removeEventListener(eventName, handleMoveWrapper);
|
|
224
|
-
});
|
|
225
|
-
endEvents.forEach((eventName) => {
|
|
226
|
-
window.removeEventListener(eventName, handleEndWrapper);
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
}, [
|
|
230
|
-
customData,
|
|
231
|
-
targetComponent,
|
|
232
|
-
dropDocumentOutsideOption,
|
|
233
|
-
screenKey,
|
|
234
|
-
isBlockingActiveInput,
|
|
235
|
-
containerName,
|
|
236
|
-
navigationTitle,
|
|
237
|
-
dropEndCallback
|
|
238
|
-
]);
|
|
239
|
-
react.useEffect(() => {
|
|
240
|
-
const el = ref.current;
|
|
241
|
-
if (!el) return;
|
|
242
|
-
const onCtx = (e) => e.preventDefault();
|
|
243
|
-
el.addEventListener("contextmenu", onCtx);
|
|
244
|
-
return () => {
|
|
245
|
-
el.removeEventListener("contextmenu", onCtx);
|
|
246
|
-
};
|
|
247
|
-
}, []);
|
|
248
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
249
|
-
"div",
|
|
250
|
-
{
|
|
251
|
-
className: `${className || ""} ${styles__default.default["flex-split-screen-drag-box"]}`,
|
|
252
|
-
ref,
|
|
253
|
-
onContextMenu: (e) => e.preventDefault(),
|
|
254
|
-
onMouseDown: (ev) => {
|
|
255
|
-
if (onMouseDown) {
|
|
256
|
-
Promise.resolve().then(() => onMouseDown(ev));
|
|
257
|
-
}
|
|
258
|
-
handleStart({
|
|
259
|
-
event: ev,
|
|
260
|
-
dragStartCallback: ({ x, y }) => {
|
|
261
|
-
if (clonedNodeRef.current) {
|
|
262
|
-
document.body.appendChild(
|
|
263
|
-
clonedNodeRef.current
|
|
264
|
-
);
|
|
265
|
-
if (ref.current) {
|
|
266
|
-
const originRect = ref.current.getBoundingClientRect();
|
|
267
|
-
clonedNodeRef.current.style.width = originRect.width + "px";
|
|
268
|
-
clonedNodeRef.current.style.height = originRect.height + "px";
|
|
269
|
-
clonedWidth.current = originRect.width;
|
|
270
|
-
clonedHeight.current = originRect.height;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (clonedNodeRef.current?.isConnected) {
|
|
274
|
-
navigator.vibrate(100);
|
|
275
|
-
clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
|
|
276
|
-
clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
|
|
277
|
-
}
|
|
278
|
-
useDrag.dragState.next({
|
|
279
|
-
isDragging: true,
|
|
280
|
-
isDrop: false,
|
|
281
|
-
navigationTitle,
|
|
282
|
-
children: targetComponent,
|
|
283
|
-
x,
|
|
284
|
-
y,
|
|
285
|
-
containerName,
|
|
286
|
-
dropDocumentOutsideOption,
|
|
287
|
-
customData
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
onTouchStart: (ev) => {
|
|
293
|
-
if (onTouchStart) {
|
|
294
|
-
Promise.resolve().then(() => onTouchStart(ev));
|
|
295
|
-
}
|
|
296
|
-
handleStart({
|
|
297
|
-
event: ev,
|
|
298
|
-
dragStartCallback: ({ x, y }) => {
|
|
299
|
-
if (clonedNodeRef.current) {
|
|
300
|
-
document.body.appendChild(
|
|
301
|
-
clonedNodeRef.current
|
|
302
|
-
);
|
|
303
|
-
if (ref.current) {
|
|
304
|
-
const originRect = ref.current.getBoundingClientRect();
|
|
305
|
-
clonedNodeRef.current.style.width = originRect.width + "px";
|
|
306
|
-
clonedNodeRef.current.style.height = originRect.height + "px";
|
|
307
|
-
clonedWidth.current = originRect.width;
|
|
308
|
-
clonedHeight.current = originRect.height;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
if (clonedNodeRef.current?.isConnected) {
|
|
312
|
-
navigator.vibrate(100);
|
|
313
|
-
clonedNodeRef.current.style.left = `${x - (clonedWidth.current || 0) / 2}px`;
|
|
314
|
-
clonedNodeRef.current.style.top = `${y - (clonedHeight.current || 0) / 2}px`;
|
|
315
|
-
}
|
|
316
|
-
useDrag.dragState.next({
|
|
317
|
-
isDragging: true,
|
|
318
|
-
isDrop: false,
|
|
319
|
-
navigationTitle,
|
|
320
|
-
children: targetComponent,
|
|
321
|
-
x,
|
|
322
|
-
y,
|
|
323
|
-
containerName,
|
|
324
|
-
dropDocumentOutsideOption,
|
|
325
|
-
customData
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
},
|
|
330
|
-
style: { ...style },
|
|
331
|
-
...props,
|
|
332
|
-
children
|
|
333
|
-
}
|
|
334
|
-
) });
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
module.exports = FlexLayoutSplitScreenDragBox;
|
|
338
|
-
//# sourceMappingURL=FlexLayoutSplitScreenDragBox.cjs.map
|
|
339
|
-
//# sourceMappingURL=FlexLayoutSplitScreenDragBox.cjs.map
|
|
1
|
+
"use strict";"use client";var re=Object.create;var F=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var ie=(r,c)=>{for(var u in c)F(r,u,{get:c[u],enumerable:!0})},z=(r,c,u,d)=>{if(c&&typeof c=="object"||typeof c=="function")for(let i of te(c))!ce.call(r,i)&&i!==u&&F(r,i,{get:()=>c[i],enumerable:!(d=ne(c,i))||d.enumerable});return r};var oe=(r,c,u)=>(u=r!=null?re(le(r)):{},z(c||!r||!r.__esModule?F(u,"default",{value:r,enumerable:!0}):u,r)),ue=r=>z(F({},"__esModule",{value:!0}),r);var he={};ie(he,{default:()=>Q});module.exports=ue(he);var T=require("react/jsx-runtime"),f=require("react"),k=require("../hooks/useDrag"),K=oe(require("../styles/FlexLayout.module.css"),1),G=require("../utils/FlexLayoutUtils"),J=require("./FlexLayoutIFramePane");const H=18;function ae(r,c){const u=window.innerWidth,d=window.innerHeight,i=u*.15,a=d*.15;return r<i||r>u-i||c<a||c>d-a}function se(r,c){const u=window.innerWidth,d=window.innerHeight,i=u*.15,a=d*.15;let h=0;r<i?h=-((i-r)/i)*H:r>u-i&&(h=(r-(u-i))/i*H);let m=0;return c<a?m=-((a-c)/a)*H:c>d-a&&(m=(c-(d-a))/a*H),{vx:h,vy:m}}function xe(r,c,u,d){const i=window.innerWidth,a=window.innerHeight,h=i*.15,m=a*.15,$=u<h?1+(h-u)/h*3:u>i-h?1+(u-(i-h))/h*3:1,n=d<m?1+(m-d)/m*3:d>a-m?1+(d-(a-m))/m*3:1;return{vx:-r*$,vy:-c*n}}function fe(){const r=globalThis.crypto;return r?.randomUUID?r.randomUUID():r?.getRandomValues?Array.from(r.getRandomValues(new Uint32Array(16)),c=>c.toString(32).padStart(2,"0")).join(""):`${Date.now().toString(32)}-${Math.random().toString(32).slice(2)}`}function L(r,c){if(r)return r;if(c)return(0,T.jsx)(J.FlexLayoutIFramePane,{url:c})}function S(r){if(r)try{return new URL(r).hostname}catch{return r}}function Q({onMouseDown:r,onTouchStart:c,dropEndCallback:u,style:d,navigationTitle:i,targetComponent:a,containerName:h,children:m,className:$,dropDocumentOutsideOption:n,screenKey:D,isBlockingActiveInput:V=!1,customData:E={},scrollTargetRef:Z,...O}){const[Y,I]=(0,f.useState)();(0,f.useEffect)(()=>{I(D||fe())},[D]);const g=(0,f.useRef)(null),w=(0,f.useRef)({vx:0,vy:0}),y=(0,f.useRef)(null),t=(0,f.useRef)(null),b=(0,f.useRef)(null),x=(0,f.useRef)(null),P=(0,f.useRef)(""),U=(0,f.useRef)(null),C=(0,f.useRef)(null),B=(0,f.useRef)({x:0,y:0}),W=(0,f.useRef)(!1),R=e=>{C.current=e,U.current==null&&(U.current=requestAnimationFrame(()=>{C.current&&k.dragStateSubject.next(C.current),C.current=null,U.current=null}))};(0,f.useEffect)(()=>()=>{U.current!=null&&cancelAnimationFrame(U.current)},[]);const{handleStart:j,handleMove:ee,handleEnd:X}=(0,k.useDragEvents)({isBlockingActiveInput:V}),q=e=>{let o=!1,l=0,s=0;if(e.type==="touchmove"){const v=e.touches[0];l=v.clientX,s=v.clientY}else{const v=e;l=v.clientX,s=v.clientY}const{vx:M,vy:A}=se(l,s),_=M!==0||A!==0;if(o=ae(l,s),t.current?.isConnected&&!_&&(e.preventDefault(),g.current&&(cancelAnimationFrame(g.current),g.current=null)),t.current?.isConnected&&_&&(e.preventDefault(),w.current={vx:M,vy:A},!g.current)){const v=()=>{const p=Z?.current??document.scrollingElement;if(p?.scrollBy?p.scrollBy(w.current.vx,w.current.vy):window.scrollBy(w.current.vx,w.current.vy),w.current.vx===0&&w.current.vy===0){g.current=null;return}g.current=requestAnimationFrame(v)};g.current=requestAnimationFrame(v)}e.type!=="touchmove"&&e.preventDefault(),ee({event:e,notDragCallback:({x:v,y:p})=>{t.current&&t.current.remove()},dragStartCallback:({x:v,y:p})=>{t.current&&(navigator.vibrate(100),t.current.style.transform=`translate3d(${v-(b.current||0)/2}px, ${p-(x.current||0)/2}px, 0)`)},moveingCallback:({x:v,y:p})=>{B.current={x:v,y:p},t.current?.isConnected&&(t.current.style.transform=`translate3d(${v-(b.current||0)/2}px, ${p-(x.current||0)/2}px, 0)`),R({isDragging:!0,isDrop:!1,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:v,y:p,containerName:h,dropDocumentOutsideOption:n,customData:E})}})},N=e=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),w.current={vx:0,vy:0},(e.type==="blur"||e.type==="touchcancel"||e.type==="pointercancel")&&t.current&&t.current.remove(),X({event:e,dragEndCallback:({x:o,y:l})=>{if(W.current){W.current=!1,t.current&&t.current.remove(),R({isDragging:!1,isDrop:!1,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:o,y:l,containerName:h,dropDocumentOutsideOption:n,customData:E});return}const s=P.current;if(t.current&&t.current.remove(),n&&(0,G.isDocumentOut)({x:o,y:l}))if(n.isNewTap||!n.widthRatio&&!n.heightRatio)window.open(s,"_blank");else{const M=window.innerWidth*(n.widthRatio||1),A=window.innerHeight*(n.heightRatio||1);window.open(s,"_blank",`width=${M},height=${A},left=${window.screenLeft-o*-1-M},top=${window.screenTop+l}`)}R({isDragging:!1,isDrop:!0,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:o,y:l,containerName:h,dropDocumentOutsideOption:n,dropEndCallback:u,screenKey:Y,customData:E})}})};return(0,f.useEffect)(()=>{if(y.current){const e=y.current.cloneNode(!0),o=y.current.getBoundingClientRect();if(e.style.width=o.width+"px",e.style.height=o.height+"px",e.style.opacity="0.3",e.style.backdropFilter="blur(6px)",b.current=o.width,x.current=o.height,n?.openUrl){P.current=n.openUrl;const s=document.createElement("span");s.textContent=P.current,e.prepend(s)}const l=document.createElement("span");l.textContent=i??S(n?.openUrl)??"",e.prepend(l),e.style.position="fixed",e.style.left="0px",e.style.top="0px",e.style.margin="0px",e.style.willChange="transform",e.style.transform="translate3d(-9999px, -9999px, 0)",e.style.pointerEvents="none",t.current=e,t.current.classList.add(K.default["flex-split-screen-drag-box-clone"])}},[]),(0,f.useEffect)(()=>{const e=["mousemove","touchmove"],o=["mouseup","touchend","touchcancel","pointerup","pointercancel","blur"];return e.forEach(l=>{window.addEventListener(l,q,{passive:!1})}),o.forEach(l=>{window.addEventListener(l,N)}),()=>{e.forEach(l=>{window.removeEventListener(l,q)}),o.forEach(l=>{window.removeEventListener(l,N)})}},[E,a,n,Y,V,h,i,u]),(0,f.useEffect)(()=>{const e=y.current;if(!e)return;const o=l=>l.preventDefault();return e.addEventListener("contextmenu",o),()=>{e.removeEventListener("contextmenu",o)}},[]),(0,f.useEffect)(()=>()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),w.current={vx:0,vy:0},t.current?.remove()},[]),(0,f.useEffect)(()=>{const e=o=>{if(o.key!=="Escape"||!t.current?.isConnected)return;o.preventDefault(),o.stopPropagation(),W.current=!0,g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),w.current={vx:0,vy:0},t.current?.remove(),X({event:new Event("pointercancel"),dragEndCallback:()=>{}});const{x:l,y:s}=B.current;R({isDragging:!1,isDrop:!1,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:l,y:s,containerName:h,dropDocumentOutsideOption:n,customData:E})};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[X,h,i,n,a,E]),(0,T.jsx)(T.Fragment,{children:(0,T.jsx)("div",{className:`${$||""} ${K.default["flex-split-screen-drag-box"]}`,ref:y,onContextMenu:e=>e.preventDefault(),onMouseDown:e=>{r&&Promise.resolve().then(()=>r(e)),j({event:e,dragStartCallback:({x:o,y:l})=>{if(B.current={x:o,y:l},t.current&&(document.body.appendChild(t.current),y.current)){const s=y.current.getBoundingClientRect();t.current.style.width=s.width+"px",t.current.style.height=s.height+"px",b.current=s.width,x.current=s.height}t.current?.isConnected&&(navigator.vibrate(100),t.current.style.transform=`translate3d(${o-(b.current||0)/2}px, ${l-(x.current||0)/2}px, 0)`),R({isDragging:!0,isDrop:!1,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:o,y:l,containerName:h,dropDocumentOutsideOption:n,customData:E})}})},onTouchStart:e=>{c&&Promise.resolve().then(()=>c(e)),j({event:e,dragStartCallback:({x:o,y:l})=>{if(t.current&&(document.body.appendChild(t.current),y.current)){const s=y.current.getBoundingClientRect();t.current.style.width=s.width+"px",t.current.style.height=s.height+"px",b.current=s.width,x.current=s.height}t.current?.isConnected&&(navigator.vibrate(100),t.current.style.transform=`translate3d(${o-(b.current||0)/2}px, ${l-(x.current||0)/2}px, 0)`),R({isDragging:!0,isDrop:!1,navigationTitle:i??S(n?.openUrl),children:L(a,n?.openUrl),x:o,y:l,containerName:h,dropDocumentOutsideOption:n,customData:E})}})},style:{...d},...O,children:m})})}
|
|
@@ -24,4 +24,4 @@ export interface DropDocumentOutsideOption {
|
|
|
24
24
|
heightRatio?: number;
|
|
25
25
|
isNewTap?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export default function FlexLayoutSplitScreenDragBox<E extends HTMLElement>({ onMouseDown, onTouchStart, dropEndCallback, style, navigationTitle, targetComponent, containerName, children, className, dropDocumentOutsideOption, screenKey, isBlockingActiveInput, customData, scrollTargetRef, ...props }: FlexLayoutSplitScreenDragBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default function FlexLayoutSplitScreenDragBox<E extends HTMLElement>({ onMouseDown, onTouchStart, dropEndCallback, style, navigationTitle, targetComponent, containerName, children, className, dropDocumentOutsideOption, screenKey: _screenKey, isBlockingActiveInput, customData, scrollTargetRef, ...props }: FlexLayoutSplitScreenDragBoxProps): import("react/jsx-runtime").JSX.Element;
|