@orioncactuscorp/ui 1.12.2 → 1.14.0
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/CHANGELOG.md +100 -0
- package/README.md +92 -12
- package/dist/components/Badge/Badge.css +1 -1
- package/dist/components/Badge/Badge.module.scss.js +12 -12
- package/dist/components/FloatingWindow/FloatingWindow.css +1 -0
- package/dist/components/FloatingWindow/FloatingWindow.js +692 -0
- package/dist/components/FloatingWindow/FloatingWindow.module.scss.js +17 -0
- package/dist/components/FloatingWindow/FloatingWindowManager.js +36 -0
- package/dist/components/FloatingWindow/contexts.js +25 -0
- package/dist/components/FloatingWindow/geometry.js +222 -0
- package/dist/components/FloatingWindow/stack.js +31 -0
- package/dist/components/FloatingWindow.d.ts +6 -0
- package/dist/components/FloatingWindow.js +18 -0
- package/dist/components/Modal/Modal.css +1 -1
- package/dist/components/Modal/Modal.js +534 -715
- package/dist/components/Modal/Modal.module.scss.js +46 -44
- package/dist/components/Modal/initialFocus.js +11 -0
- package/dist/components/Modal/useModalDrag.js +328 -310
- package/dist/components/internal/ModalPresentation.js +359 -0
- package/dist/index.js +108 -92
- package/dist/styles.css +3 -2
- package/dist/ui/src/components/Badge/types.d.ts +1 -1
- package/dist/ui/src/components/Badge/types.d.ts.map +1 -1
- package/dist/ui/src/components/FloatingWindow/FloatingWindow.d.ts +32 -0
- package/dist/ui/src/components/FloatingWindow/FloatingWindow.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/FloatingWindowManager.d.ts +4 -0
- package/dist/ui/src/components/FloatingWindow/FloatingWindowManager.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/contexts.d.ts +36 -0
- package/dist/ui/src/components/FloatingWindow/contexts.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/geometry.d.ts +31 -0
- package/dist/ui/src/components/FloatingWindow/geometry.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/index.d.ts +4 -0
- package/dist/ui/src/components/FloatingWindow/index.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/stack.d.ts +9 -0
- package/dist/ui/src/components/FloatingWindow/stack.d.ts.map +1 -0
- package/dist/ui/src/components/FloatingWindow/types.d.ts +121 -0
- package/dist/ui/src/components/FloatingWindow/types.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
- package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/contexts.d.ts +3 -0
- package/dist/ui/src/components/Modal/contexts.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/initialFocus.d.ts +18 -0
- package/dist/ui/src/components/Modal/initialFocus.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/types.d.ts +9 -1
- package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
- package/dist/ui/src/components/internal/ModalPresentation.d.ts +61 -0
- package/dist/ui/src/components/internal/ModalPresentation.d.ts.map +1 -0
- package/dist/ui/src/index.d.ts +2 -0
- package/dist/ui/src/index.d.ts.map +1 -1
- package/dist/ui/src/utils/motion.d.ts.map +1 -1
- package/dist/utils/motion.js +194 -135
- package/docs/api-conventions.md +2 -5
- package/docs/motion.md +4 -0
- package/docs/selector-contract.md +58 -0
- package/package.json +2 -2
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as l, jsxs as Qe } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as A, useState as R, useMemo as X, useCallback as L, useLayoutEffect as Ne, useEffect as oe } from "react";
|
|
4
|
+
import { Dialog as T } from "@base-ui-components/react/dialog";
|
|
5
|
+
import Ze from "@orioncactuscorp/icons/orioncactus/CloseThick";
|
|
6
|
+
import { mergeRefs as Ee } from "../../utils/mergeRefs.js";
|
|
7
|
+
import _e from "../BackgroundIconButton/BackgroundIconButton.js";
|
|
8
|
+
import H from "../Modal/Modal.module.scss.js";
|
|
9
|
+
import { resolveModalInitialFocus as et } from "../Modal/initialFocus.js";
|
|
10
|
+
import { useModalBodyScrollState as tt, ModalBodyFrame as ot, ModalSurfaceFrame as nt, resolveModalFooterBackground as rt, ModalFooterFrame as it, ModalHeaderFrame as at, ModalNavigationSectionFrame as dt, mergeModalClassName as st } from "../internal/ModalPresentation.js";
|
|
11
|
+
import { useFloatingWindowContentContext as q, useFloatingWindowRootContext as Le, FloatingWindowContentContext as ct, useFloatingWindowManagerContext as lt, FloatingWindowRootContext as ut } from "./contexts.js";
|
|
12
|
+
import { constrainFloatingWindowPosition as gt, getFloatingWindowBoundaryRect as Re, resolveCenteredFloatingWindowPosition as Ce, resolveAnchoredFloatingWindowPosition as ft, getFloatingWindowRect as wt } from "./geometry.js";
|
|
13
|
+
import z from "./FloatingWindow.module.scss.js";
|
|
14
|
+
import { FloatingWindowManager as mt } from "./FloatingWindowManager.js";
|
|
15
|
+
const pt = {
|
|
16
|
+
topLeft: { side: "top", alignment: "start" },
|
|
17
|
+
top: { side: "top", alignment: "center" },
|
|
18
|
+
topRight: { side: "top", alignment: "end" },
|
|
19
|
+
rightTop: { side: "right", alignment: "start" },
|
|
20
|
+
right: { side: "right", alignment: "center" },
|
|
21
|
+
rightBottom: { side: "right", alignment: "end" },
|
|
22
|
+
bottomLeft: { side: "bottom", alignment: "start" },
|
|
23
|
+
bottom: { side: "bottom", alignment: "center" },
|
|
24
|
+
bottomRight: { side: "bottom", alignment: "end" },
|
|
25
|
+
leftTop: { side: "left", alignment: "start" },
|
|
26
|
+
left: { side: "left", alignment: "center" },
|
|
27
|
+
leftBottom: { side: "left", alignment: "end" }
|
|
28
|
+
}, vt = {
|
|
29
|
+
small: H.small,
|
|
30
|
+
medium: H.medium,
|
|
31
|
+
large: H.large
|
|
32
|
+
}, $ = st;
|
|
33
|
+
function Se(e, o) {
|
|
34
|
+
return e?.x === o.x && e.y === o.y;
|
|
35
|
+
}
|
|
36
|
+
function ht(e) {
|
|
37
|
+
return e instanceof Element && !!e.closest(
|
|
38
|
+
'button, a, input, select, textarea, [contenteditable="true"], [data-oc-window-no-drag]'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function Me(e) {
|
|
42
|
+
return !(e instanceof Element && e.closest('[data-oc-part="close"]'));
|
|
43
|
+
}
|
|
44
|
+
function Te(e, o) {
|
|
45
|
+
return e ? typeof e == "function" ? e() : "current" in e ? e.current : e : o;
|
|
46
|
+
}
|
|
47
|
+
function Ft(e, o) {
|
|
48
|
+
return e.x === o.x && e.y === o.y && e.width === o.width && e.height === o.height;
|
|
49
|
+
}
|
|
50
|
+
function bt(e, o) {
|
|
51
|
+
if (typeof IntersectionObserver > "u") return;
|
|
52
|
+
let c = null, n;
|
|
53
|
+
const r = () => {
|
|
54
|
+
n !== void 0 && window.clearTimeout(n), c?.disconnect(), c = null;
|
|
55
|
+
}, a = (m = !1, h = 1) => {
|
|
56
|
+
r();
|
|
57
|
+
const g = e.getBoundingClientRect(), u = e.ownerDocument.documentElement;
|
|
58
|
+
if (m && o(), !g.width || !g.height) return;
|
|
59
|
+
const p = Math.floor(g.top), F = Math.floor(
|
|
60
|
+
u.clientWidth - (g.left + g.width)
|
|
61
|
+
), w = Math.floor(
|
|
62
|
+
u.clientHeight - (g.top + g.height)
|
|
63
|
+
), b = Math.floor(g.left);
|
|
64
|
+
let C = !0;
|
|
65
|
+
c = new IntersectionObserver(
|
|
66
|
+
(x) => {
|
|
67
|
+
const E = x[0]?.intersectionRatio ?? 0, y = !Ft(
|
|
68
|
+
g,
|
|
69
|
+
e.getBoundingClientRect()
|
|
70
|
+
);
|
|
71
|
+
if (y || E !== h) {
|
|
72
|
+
if (!C || y) {
|
|
73
|
+
a(!0);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
E ? a(!0, E) : n = window.setTimeout(() => a(!0, 1e-7), 1e3);
|
|
77
|
+
}
|
|
78
|
+
C = !1;
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
rootMargin: `${-p}px ${-F}px ${-w}px ${-b}px`,
|
|
82
|
+
threshold: Math.max(0, Math.min(1, h)) || 1
|
|
83
|
+
}
|
|
84
|
+
), c.observe(e);
|
|
85
|
+
};
|
|
86
|
+
return a(), r;
|
|
87
|
+
}
|
|
88
|
+
function Ie({
|
|
89
|
+
children: e,
|
|
90
|
+
modal: o = !1,
|
|
91
|
+
defaultBackdrop: c,
|
|
92
|
+
presentation: n,
|
|
93
|
+
disablePointerDismissal: r = o !== !0,
|
|
94
|
+
windowId: a,
|
|
95
|
+
onActivate: m,
|
|
96
|
+
onOpenChange: h,
|
|
97
|
+
...g
|
|
98
|
+
}) {
|
|
99
|
+
const u = lt(), [p, F] = R(null);
|
|
100
|
+
if (u && !a)
|
|
101
|
+
throw new Error(
|
|
102
|
+
"FloatingWindowRoot requires windowId inside FloatingWindowManager."
|
|
103
|
+
);
|
|
104
|
+
const w = u !== null && u.activeWindowId !== void 0 && u.activeWindowId !== a, b = w && o !== !1 ? !1 : o, C = w ? !0 : r, x = X(
|
|
105
|
+
() => ({
|
|
106
|
+
defaultBackdrop: c,
|
|
107
|
+
manager: u,
|
|
108
|
+
modal: o,
|
|
109
|
+
onActivate: m,
|
|
110
|
+
presentation: n,
|
|
111
|
+
setTriggerNode: F,
|
|
112
|
+
triggerNode: p,
|
|
113
|
+
windowId: a
|
|
114
|
+
}),
|
|
115
|
+
[
|
|
116
|
+
c,
|
|
117
|
+
u,
|
|
118
|
+
o,
|
|
119
|
+
m,
|
|
120
|
+
n,
|
|
121
|
+
p,
|
|
122
|
+
a
|
|
123
|
+
]
|
|
124
|
+
), E = L(
|
|
125
|
+
(y, v) => {
|
|
126
|
+
const Y = v && typeof v == "object" && "reason" in v ? v.reason : void 0;
|
|
127
|
+
if (!y && (Y === "escape-key" || Y === "outside-press") && u && a && u.activeWindowId !== a) {
|
|
128
|
+
v && typeof v == "object" && "cancel" in v && typeof v.cancel == "function" && v.cancel();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
h?.(y, v);
|
|
132
|
+
},
|
|
133
|
+
[u, h, a]
|
|
134
|
+
);
|
|
135
|
+
return /* @__PURE__ */ l(ut.Provider, { value: x, children: /* @__PURE__ */ l(
|
|
136
|
+
T.Root,
|
|
137
|
+
{
|
|
138
|
+
...g,
|
|
139
|
+
modal: b,
|
|
140
|
+
disablePointerDismissal: C,
|
|
141
|
+
onOpenChange: E,
|
|
142
|
+
children: e
|
|
143
|
+
}
|
|
144
|
+
) });
|
|
145
|
+
}
|
|
146
|
+
function xe(e) {
|
|
147
|
+
return /* @__PURE__ */ l(
|
|
148
|
+
Ie,
|
|
149
|
+
{
|
|
150
|
+
...e,
|
|
151
|
+
defaultBackdrop: e.modal === !0 ? "visible" : "hidden",
|
|
152
|
+
presentation: "floating"
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
function yt({
|
|
157
|
+
modal: e = !0,
|
|
158
|
+
...o
|
|
159
|
+
}) {
|
|
160
|
+
return /* @__PURE__ */ l(
|
|
161
|
+
Ie,
|
|
162
|
+
{
|
|
163
|
+
...o,
|
|
164
|
+
defaultBackdrop: "visible",
|
|
165
|
+
modal: e,
|
|
166
|
+
presentation: "modal"
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
function Wt({
|
|
171
|
+
children: e,
|
|
172
|
+
className: o = "",
|
|
173
|
+
render: c,
|
|
174
|
+
nativeButton: n,
|
|
175
|
+
ref: r
|
|
176
|
+
}) {
|
|
177
|
+
const a = Le("FloatingWindowTrigger"), m = X(
|
|
178
|
+
() => Ee(a.setTriggerNode, r),
|
|
179
|
+
[r, a.setTriggerNode]
|
|
180
|
+
);
|
|
181
|
+
return /* @__PURE__ */ l(
|
|
182
|
+
T.Trigger,
|
|
183
|
+
{
|
|
184
|
+
ref: m,
|
|
185
|
+
className: c ? void 0 : $(z.trigger, o),
|
|
186
|
+
render: c,
|
|
187
|
+
nativeButton: n,
|
|
188
|
+
"data-oc-component": "floating-window-trigger",
|
|
189
|
+
children: e
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
function Nt({
|
|
194
|
+
children: e,
|
|
195
|
+
className: o = "",
|
|
196
|
+
style: c,
|
|
197
|
+
position: n,
|
|
198
|
+
defaultPosition: r,
|
|
199
|
+
placement: a,
|
|
200
|
+
side: m = "bottom",
|
|
201
|
+
alignment: h = "center",
|
|
202
|
+
sideOffset: g = 12,
|
|
203
|
+
alignOffset: u = 0,
|
|
204
|
+
anchor: p,
|
|
205
|
+
onPositionChange: F,
|
|
206
|
+
onPositionCommit: w,
|
|
207
|
+
collisionBoundary: b = "viewport",
|
|
208
|
+
collisionPadding: C = 16,
|
|
209
|
+
collisionAvoidance: x,
|
|
210
|
+
dragHandleVisibility: E = 48,
|
|
211
|
+
draggable: y = !0,
|
|
212
|
+
backdrop: v = "auto",
|
|
213
|
+
size: Y = "medium",
|
|
214
|
+
resize: ne = "content",
|
|
215
|
+
container: Be,
|
|
216
|
+
initialFocus: De,
|
|
217
|
+
stackLevel: Ae = 0,
|
|
218
|
+
...K
|
|
219
|
+
}) {
|
|
220
|
+
const s = Le("FloatingWindowContent"), I = A(null), re = A(null), ie = A(!1), [Q, ae] = R(null), [de, ze] = R(null), [Z, He] = R({
|
|
221
|
+
canScroll: !1,
|
|
222
|
+
scrolledFromTop: !1,
|
|
223
|
+
scrolledToBottom: !0
|
|
224
|
+
}), P = A(null), se = n !== void 0 || r !== void 0, _ = A(se), U = A(null), [W, $e] = R(
|
|
225
|
+
null
|
|
226
|
+
), [ce, le] = R(r ?? null), [ee, ue] = R(se), [qe, G] = R(!1), [je, Oe] = R(m), [Ve, Xe] = R(h), Ye = s.windowId ? s.manager?.stackLevels.get(s.windowId) : void 0, te = s.manager?.registerWindow, ge = Ye ?? Ae, j = s.manager ? s.manager.activeWindowId === s.windowId : void 0, fe = a ? pt[a] : void 0, we = fe?.side ?? m, me = fe?.alignment ?? h, pe = X(
|
|
227
|
+
() => ({
|
|
228
|
+
side: x?.side ?? "flip",
|
|
229
|
+
alignment: x?.alignment ?? "shift"
|
|
230
|
+
}),
|
|
231
|
+
[x?.alignment, x?.side]
|
|
232
|
+
), ve = v === "auto" ? s.defaultBackdrop : v, Ue = L(
|
|
233
|
+
(t) => {
|
|
234
|
+
const d = I.current !== null;
|
|
235
|
+
if (I.current = t, $e(t), !t) {
|
|
236
|
+
G(!1);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
!d && n === void 0 && r === void 0 && (P.current = null, _.current = !1, ue(!1), le(null));
|
|
240
|
+
},
|
|
241
|
+
[r, n]
|
|
242
|
+
), he = L((t) => {
|
|
243
|
+
const d = I.current;
|
|
244
|
+
d && (P.current = t, d.style.setProperty("--oc-floating-window-x", `${t.x}px`), d.style.setProperty("--oc-floating-window-y", `${t.y}px`));
|
|
245
|
+
}, []), B = L(
|
|
246
|
+
(t) => {
|
|
247
|
+
const d = I.current;
|
|
248
|
+
if (!d) return t;
|
|
249
|
+
const i = d.getBoundingClientRect();
|
|
250
|
+
return gt({
|
|
251
|
+
boundary: Re(b),
|
|
252
|
+
dragHandleHeight: E,
|
|
253
|
+
padding: C,
|
|
254
|
+
position: t,
|
|
255
|
+
size: { width: i.width, height: i.height }
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
[b, C, E]
|
|
259
|
+
), k = L(
|
|
260
|
+
(t) => {
|
|
261
|
+
const d = !Se(P.current, t);
|
|
262
|
+
he(t), d && F?.(t);
|
|
263
|
+
},
|
|
264
|
+
[he, F]
|
|
265
|
+
), O = L(
|
|
266
|
+
(t, d) => {
|
|
267
|
+
const i = B(t);
|
|
268
|
+
return k(i), n === void 0 && le(
|
|
269
|
+
(f) => Se(f, i) ? f : i
|
|
270
|
+
), d && w?.(i), i;
|
|
271
|
+
},
|
|
272
|
+
[B, k, w, n]
|
|
273
|
+
), J = L(() => {
|
|
274
|
+
const t = W ?? I.current;
|
|
275
|
+
if (!t) return;
|
|
276
|
+
const d = t.getBoundingClientRect(), i = { width: d.width, height: d.height }, f = Re(b), S = n ?? ce;
|
|
277
|
+
if (_.current || S) {
|
|
278
|
+
O(
|
|
279
|
+
S ?? P.current ?? Ce({
|
|
280
|
+
boundary: f,
|
|
281
|
+
size: i
|
|
282
|
+
}),
|
|
283
|
+
!1
|
|
284
|
+
), G(!0);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const D = Te(p, s.triggerNode);
|
|
288
|
+
if (!D) {
|
|
289
|
+
k(
|
|
290
|
+
B(
|
|
291
|
+
Ce({
|
|
292
|
+
boundary: f,
|
|
293
|
+
size: i
|
|
294
|
+
})
|
|
295
|
+
)
|
|
296
|
+
), G(!0);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const M = ft({
|
|
300
|
+
alignOffset: u,
|
|
301
|
+
alignment: me,
|
|
302
|
+
anchor: wt(D),
|
|
303
|
+
boundary: f,
|
|
304
|
+
collisionAvoidance: pe,
|
|
305
|
+
direction: window.getComputedStyle(D).direction === "rtl" ? "rtl" : "ltr",
|
|
306
|
+
padding: C,
|
|
307
|
+
side: we,
|
|
308
|
+
sideOffset: g,
|
|
309
|
+
size: i
|
|
310
|
+
});
|
|
311
|
+
k(M.position), Oe(
|
|
312
|
+
(N) => N === M.side ? N : M.side
|
|
313
|
+
), Xe(
|
|
314
|
+
(N) => N === M.alignment ? N : M.alignment
|
|
315
|
+
), G(!0);
|
|
316
|
+
}, [
|
|
317
|
+
u,
|
|
318
|
+
p,
|
|
319
|
+
b,
|
|
320
|
+
C,
|
|
321
|
+
O,
|
|
322
|
+
B,
|
|
323
|
+
ce,
|
|
324
|
+
k,
|
|
325
|
+
n,
|
|
326
|
+
me,
|
|
327
|
+
we,
|
|
328
|
+
pe,
|
|
329
|
+
s.triggerNode,
|
|
330
|
+
g,
|
|
331
|
+
W
|
|
332
|
+
]);
|
|
333
|
+
Ne(() => {
|
|
334
|
+
J();
|
|
335
|
+
}, [J]), oe(() => {
|
|
336
|
+
const t = I.current;
|
|
337
|
+
if (!t) return;
|
|
338
|
+
const d = Te(p, s.triggerNode), i = () => J(), f = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(i);
|
|
339
|
+
f?.observe(t), d && f?.observe(d), b !== "viewport" && f?.observe(b);
|
|
340
|
+
const S = d && !ee && n === void 0 && r === void 0 ? bt(d, i) : void 0;
|
|
341
|
+
return window.addEventListener("resize", i), window.addEventListener("scroll", i, !0), window.visualViewport?.addEventListener("resize", i), window.visualViewport?.addEventListener("scroll", i), () => {
|
|
342
|
+
S?.(), f?.disconnect(), window.removeEventListener("resize", i), window.removeEventListener("scroll", i, !0), window.visualViewport?.removeEventListener("resize", i), window.visualViewport?.removeEventListener("scroll", i);
|
|
343
|
+
};
|
|
344
|
+
}, [
|
|
345
|
+
p,
|
|
346
|
+
b,
|
|
347
|
+
r,
|
|
348
|
+
ee,
|
|
349
|
+
J,
|
|
350
|
+
n,
|
|
351
|
+
s.triggerNode
|
|
352
|
+
]), oe(
|
|
353
|
+
() => () => {
|
|
354
|
+
U.current?.();
|
|
355
|
+
},
|
|
356
|
+
[]
|
|
357
|
+
), Ne(() => {
|
|
358
|
+
if (!(!W || !te || !s.windowId))
|
|
359
|
+
return te(s.windowId, s.modal);
|
|
360
|
+
}, [te, s.modal, s.windowId, W]), oe(() => {
|
|
361
|
+
const t = j === !0 && !ie.current;
|
|
362
|
+
if (ie.current = j === !0, !t || s.modal === !1 || !W) return;
|
|
363
|
+
const d = window.requestAnimationFrame(() => {
|
|
364
|
+
const i = re.current, f = i && W.contains(i) ? i : Q ?? W;
|
|
365
|
+
W.contains(document.activeElement) || f.focus({ preventScroll: !0 });
|
|
366
|
+
});
|
|
367
|
+
return () => window.cancelAnimationFrame(d);
|
|
368
|
+
}, [j, s.modal, Q, W]);
|
|
369
|
+
const Fe = L(
|
|
370
|
+
(t) => {
|
|
371
|
+
if (!y || !t.isPrimary || t.button !== 0 || ht(t.target))
|
|
372
|
+
return;
|
|
373
|
+
const d = I.current;
|
|
374
|
+
if (!d) return;
|
|
375
|
+
t.preventDefault(), U.current?.(), _.current = !0, ue(!0);
|
|
376
|
+
const i = t.pointerId, f = { x: t.clientX, y: t.clientY }, S = P.current ?? { x: 0, y: 0 };
|
|
377
|
+
d.dataset.ocWindowDragging = "true";
|
|
378
|
+
const D = (V) => {
|
|
379
|
+
V.pointerId === i && k(
|
|
380
|
+
B({
|
|
381
|
+
x: S.x + V.clientX - f.x,
|
|
382
|
+
y: S.y + V.clientY - f.y
|
|
383
|
+
})
|
|
384
|
+
);
|
|
385
|
+
}, M = () => {
|
|
386
|
+
window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", N), window.removeEventListener("pointercancel", N), window.removeEventListener("blur", We), delete d.dataset.ocWindowDragging, U.current = null;
|
|
387
|
+
}, N = (V) => {
|
|
388
|
+
V.pointerId === i && (M(), O(P.current ?? S, !0));
|
|
389
|
+
}, We = () => {
|
|
390
|
+
M(), O(P.current ?? S, !0);
|
|
391
|
+
};
|
|
392
|
+
U.current = M, window.addEventListener("pointermove", D), window.addEventListener("pointerup", N), window.addEventListener("pointercancel", N), window.addEventListener("blur", We);
|
|
393
|
+
},
|
|
394
|
+
[
|
|
395
|
+
O,
|
|
396
|
+
B,
|
|
397
|
+
y,
|
|
398
|
+
k
|
|
399
|
+
]
|
|
400
|
+
), Ge = X(
|
|
401
|
+
() => ({
|
|
402
|
+
bodyNode: de,
|
|
403
|
+
draggable: y,
|
|
404
|
+
scrollState: Z,
|
|
405
|
+
setBodyNode: ze,
|
|
406
|
+
setScrollState: He,
|
|
407
|
+
setTitleNode: ae,
|
|
408
|
+
startDrag: Fe
|
|
409
|
+
}),
|
|
410
|
+
[de, y, Z, ae, Fe]
|
|
411
|
+
), Je = et({
|
|
412
|
+
contentNode: W,
|
|
413
|
+
initialFocus: De,
|
|
414
|
+
modal: s.modal,
|
|
415
|
+
titleNode: Q
|
|
416
|
+
}), be = {
|
|
417
|
+
"--oc-floating-window-stack-offset": ge * 2
|
|
418
|
+
}, Ke = {
|
|
419
|
+
...c,
|
|
420
|
+
"--oc-floating-window-stack-offset": ge * 2
|
|
421
|
+
}, ye = () => {
|
|
422
|
+
s.windowId && s.manager?.activateWindow(s.windowId), s.onActivate?.(s.windowId);
|
|
423
|
+
};
|
|
424
|
+
return /* @__PURE__ */ Qe(T.Portal, { container: Be, children: [
|
|
425
|
+
ve === "visible" ? /* @__PURE__ */ l(
|
|
426
|
+
T.Backdrop,
|
|
427
|
+
{
|
|
428
|
+
className: z.backdrop,
|
|
429
|
+
"data-oc-component": "floating-window-backdrop",
|
|
430
|
+
"data-oc-part": "backdrop",
|
|
431
|
+
style: be
|
|
432
|
+
}
|
|
433
|
+
) : null,
|
|
434
|
+
/* @__PURE__ */ l(
|
|
435
|
+
"div",
|
|
436
|
+
{
|
|
437
|
+
className: z.positioner,
|
|
438
|
+
"data-oc-component": "floating-window-positioner",
|
|
439
|
+
style: be,
|
|
440
|
+
children: /* @__PURE__ */ l(ct.Provider, { value: Ge, children: /* @__PURE__ */ l(
|
|
441
|
+
T.Popup,
|
|
442
|
+
{
|
|
443
|
+
...K,
|
|
444
|
+
ref: Ue,
|
|
445
|
+
initialFocus: Je,
|
|
446
|
+
className: $(z.window, o),
|
|
447
|
+
"data-oc-alignment": Ve,
|
|
448
|
+
"data-oc-side": je,
|
|
449
|
+
"data-oc-component": "floating-window",
|
|
450
|
+
"data-oc-part": "window",
|
|
451
|
+
"data-oc-positioned": qe ? "true" : "false",
|
|
452
|
+
"data-oc-window-positioning": ee || n !== void 0 || r !== void 0 ? "free" : "anchored",
|
|
453
|
+
"data-oc-window-presentation": s.presentation,
|
|
454
|
+
"data-oc-window-modality": s.modal === !0 ? "modal" : s.modal === "trap-focus" ? "trap-focus" : "modeless",
|
|
455
|
+
"data-oc-window-active": j === void 0 ? void 0 : j ? "true" : "false",
|
|
456
|
+
onFocusCapture: (t) => {
|
|
457
|
+
K.onFocusCapture?.(t);
|
|
458
|
+
const d = Me(t.target);
|
|
459
|
+
d && t.target instanceof HTMLElement && (re.current = t.target), !t.defaultPrevented && d && ye();
|
|
460
|
+
},
|
|
461
|
+
onPointerDownCapture: (t) => {
|
|
462
|
+
K.onPointerDownCapture?.(t), !t.defaultPrevented && Me(t.target) && ye();
|
|
463
|
+
},
|
|
464
|
+
style: Ke,
|
|
465
|
+
children: /* @__PURE__ */ l(
|
|
466
|
+
"div",
|
|
467
|
+
{
|
|
468
|
+
className: $(
|
|
469
|
+
H.surfaceMotion,
|
|
470
|
+
z.presentationMotion,
|
|
471
|
+
vt[Y]
|
|
472
|
+
),
|
|
473
|
+
"data-oc-modal-backdrop": ve,
|
|
474
|
+
"data-oc-modal-placement": "popup",
|
|
475
|
+
"data-oc-resize": ne,
|
|
476
|
+
"data-oc-part": "surface-motion",
|
|
477
|
+
children: /* @__PURE__ */ l(
|
|
478
|
+
nt,
|
|
479
|
+
{
|
|
480
|
+
contentTransition: "none",
|
|
481
|
+
placement: "popup",
|
|
482
|
+
resize: ne,
|
|
483
|
+
scrollable: Z.canScroll,
|
|
484
|
+
children: e
|
|
485
|
+
}
|
|
486
|
+
)
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
) })
|
|
491
|
+
}
|
|
492
|
+
)
|
|
493
|
+
] });
|
|
494
|
+
}
|
|
495
|
+
function Rt({
|
|
496
|
+
children: e,
|
|
497
|
+
className: o = "",
|
|
498
|
+
onPointerDown: c,
|
|
499
|
+
...n
|
|
500
|
+
}) {
|
|
501
|
+
const r = q("FloatingWindowDragHandle");
|
|
502
|
+
return /* @__PURE__ */ l(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
...n,
|
|
506
|
+
className: $(z.dragHandle, o),
|
|
507
|
+
"data-oc-part": "drag-handle",
|
|
508
|
+
"data-oc-draggable": r.draggable ? "true" : "false",
|
|
509
|
+
onPointerDown: (a) => {
|
|
510
|
+
c?.(a), a.defaultPrevented || r.startDrag(a);
|
|
511
|
+
},
|
|
512
|
+
children: e
|
|
513
|
+
}
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
function Ct({
|
|
517
|
+
title: e,
|
|
518
|
+
leadingContent: o,
|
|
519
|
+
trailingContent: c,
|
|
520
|
+
closeButton: n = !0,
|
|
521
|
+
closeLabel: r = "닫기",
|
|
522
|
+
draggable: a = !0,
|
|
523
|
+
children: m,
|
|
524
|
+
className: h = "",
|
|
525
|
+
onPointerDown: g,
|
|
526
|
+
ref: u,
|
|
527
|
+
...p
|
|
528
|
+
}) {
|
|
529
|
+
const F = q("FloatingWindowHeader");
|
|
530
|
+
return /* @__PURE__ */ l(
|
|
531
|
+
at,
|
|
532
|
+
{
|
|
533
|
+
...p,
|
|
534
|
+
ref: u,
|
|
535
|
+
className: h,
|
|
536
|
+
closeContent: n ? /* @__PURE__ */ l(ke, { label: r }) : null,
|
|
537
|
+
dragEnabled: a && F.draggable,
|
|
538
|
+
leadingContent: o,
|
|
539
|
+
sticky: F.scrollState.scrolledFromTop,
|
|
540
|
+
titleContent: e ? /* @__PURE__ */ l(Pe, { children: e }) : void 0,
|
|
541
|
+
trailingContent: c,
|
|
542
|
+
onPointerDown: (w) => {
|
|
543
|
+
g?.(w), !w.defaultPrevented && a && F.startDrag(w);
|
|
544
|
+
},
|
|
545
|
+
children: m
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
function St({
|
|
550
|
+
handle: e = !0,
|
|
551
|
+
...o
|
|
552
|
+
}) {
|
|
553
|
+
const c = q(
|
|
554
|
+
"FloatingWindowNavigationSection"
|
|
555
|
+
);
|
|
556
|
+
return /* @__PURE__ */ l(
|
|
557
|
+
dt,
|
|
558
|
+
{
|
|
559
|
+
...o,
|
|
560
|
+
canRenderHandle: e && c.draggable,
|
|
561
|
+
handleProps: { onPointerDown: c.startDrag }
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
function Mt({
|
|
566
|
+
children: e,
|
|
567
|
+
className: o = "",
|
|
568
|
+
layout: c = "content",
|
|
569
|
+
containerClassName: n = "",
|
|
570
|
+
containerProps: r,
|
|
571
|
+
ref: a,
|
|
572
|
+
...m
|
|
573
|
+
}) {
|
|
574
|
+
const { bodyNode: h, setBodyNode: g, setScrollState: u } = q("FloatingWindowBody"), { setBodyRef: p, updateScrollState: F } = tt({
|
|
575
|
+
bodyNode: h,
|
|
576
|
+
setBodyNode: g,
|
|
577
|
+
setScrollState: u
|
|
578
|
+
});
|
|
579
|
+
return /* @__PURE__ */ l(
|
|
580
|
+
ot,
|
|
581
|
+
{
|
|
582
|
+
bodyContainerProps: {
|
|
583
|
+
...r,
|
|
584
|
+
ref: p,
|
|
585
|
+
onScroll: (w) => {
|
|
586
|
+
r?.onScroll?.(w), F(w.currentTarget);
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
bodyContentProps: { ...m, ref: a, className: n },
|
|
590
|
+
layout: c,
|
|
591
|
+
scrollAreaProps: { className: o },
|
|
592
|
+
children: e
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
function Tt({
|
|
597
|
+
children: e,
|
|
598
|
+
className: o = "",
|
|
599
|
+
background: c = "auto",
|
|
600
|
+
...n
|
|
601
|
+
}) {
|
|
602
|
+
const { scrollState: r } = q(
|
|
603
|
+
"FloatingWindowFooter"
|
|
604
|
+
), a = rt(
|
|
605
|
+
c,
|
|
606
|
+
r
|
|
607
|
+
);
|
|
608
|
+
return /* @__PURE__ */ l(
|
|
609
|
+
it,
|
|
610
|
+
{
|
|
611
|
+
...n,
|
|
612
|
+
backgroundActive: a,
|
|
613
|
+
className: o,
|
|
614
|
+
children: e
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
function Pe({
|
|
619
|
+
className: e = "",
|
|
620
|
+
ref: o,
|
|
621
|
+
...c
|
|
622
|
+
}) {
|
|
623
|
+
const n = q("FloatingWindowTitle"), r = X(
|
|
624
|
+
() => Ee(n.setTitleNode, o),
|
|
625
|
+
[n.setTitleNode, o]
|
|
626
|
+
);
|
|
627
|
+
return /* @__PURE__ */ l(
|
|
628
|
+
T.Title,
|
|
629
|
+
{
|
|
630
|
+
...c,
|
|
631
|
+
ref: r,
|
|
632
|
+
className: $(H.initialFocusTitle, e),
|
|
633
|
+
tabIndex: -1
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
function xt(e) {
|
|
638
|
+
return /* @__PURE__ */ l(T.Description, { ...e });
|
|
639
|
+
}
|
|
640
|
+
function ke(e) {
|
|
641
|
+
if (e.render !== void 0)
|
|
642
|
+
return /* @__PURE__ */ l(T.Close, { ...e });
|
|
643
|
+
const { className: o = "", label: c = "닫기", size: n = 24, ...r } = e;
|
|
644
|
+
return /* @__PURE__ */ l(
|
|
645
|
+
T.Close,
|
|
646
|
+
{
|
|
647
|
+
render: /* @__PURE__ */ l(
|
|
648
|
+
_e,
|
|
649
|
+
{
|
|
650
|
+
...r,
|
|
651
|
+
className: $(H.close, o),
|
|
652
|
+
"aria-label": r["aria-label"] ?? c,
|
|
653
|
+
"data-oc-component": "modal-close",
|
|
654
|
+
"data-oc-part": "close",
|
|
655
|
+
size: n,
|
|
656
|
+
children: /* @__PURE__ */ l(Ze, {})
|
|
657
|
+
}
|
|
658
|
+
)
|
|
659
|
+
}
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
const Ot = Object.assign(xe, {
|
|
663
|
+
Manager: mt,
|
|
664
|
+
Root: xe,
|
|
665
|
+
ModalRoot: yt,
|
|
666
|
+
Trigger: Wt,
|
|
667
|
+
Content: Nt,
|
|
668
|
+
DragHandle: Rt,
|
|
669
|
+
Header: Ct,
|
|
670
|
+
NavigationSection: St,
|
|
671
|
+
Body: Mt,
|
|
672
|
+
Footer: Tt,
|
|
673
|
+
Title: Pe,
|
|
674
|
+
Description: xt,
|
|
675
|
+
Close: ke
|
|
676
|
+
});
|
|
677
|
+
export {
|
|
678
|
+
Mt as FloatingWindowBody,
|
|
679
|
+
ke as FloatingWindowClose,
|
|
680
|
+
Nt as FloatingWindowContent,
|
|
681
|
+
xt as FloatingWindowDescription,
|
|
682
|
+
Rt as FloatingWindowDragHandle,
|
|
683
|
+
Tt as FloatingWindowFooter,
|
|
684
|
+
Ct as FloatingWindowHeader,
|
|
685
|
+
mt as FloatingWindowManager,
|
|
686
|
+
St as FloatingWindowNavigationSection,
|
|
687
|
+
xe as FloatingWindowRoot,
|
|
688
|
+
Pe as FloatingWindowTitle,
|
|
689
|
+
Wt as FloatingWindowTrigger,
|
|
690
|
+
yt as ModalWindowRoot,
|
|
691
|
+
Ot as default
|
|
692
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import './FloatingWindow.css';const o = "oc-FloatingWindow-module__trigger__qlrNq", n = "oc-FloatingWindow-module__backdrop__53p3-", t = "oc-FloatingWindow-module__positioner__yoopu", i = "oc-FloatingWindow-module__window__7l1n6", d = "oc-FloatingWindow-module__presentationMotion__DWXpt", e = "oc-FloatingWindow-module__dragHandle__MfwPD", _ = {
|
|
2
|
+
trigger: o,
|
|
3
|
+
backdrop: n,
|
|
4
|
+
positioner: t,
|
|
5
|
+
window: i,
|
|
6
|
+
presentationMotion: d,
|
|
7
|
+
dragHandle: e
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
n as backdrop,
|
|
11
|
+
_ as default,
|
|
12
|
+
e as dragHandle,
|
|
13
|
+
t as positioner,
|
|
14
|
+
d as presentationMotion,
|
|
15
|
+
o as trigger,
|
|
16
|
+
i as window
|
|
17
|
+
};
|