@slotted/react 0.1.0-beta.13 → 0.1.0-beta.15

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.
@@ -1,816 +0,0 @@
1
- import { r as e } from "./i18n-D7xXDd8-.js";
2
- import { n as t, t as n } from "./icon-D04-_QFA.js";
3
- import { keyedProps as r } from "@slotted/core/selector-key";
4
- import { createFocusScope as i } from "@slotted/core/focus";
5
- import { createControllable as a } from "@slotted/core/state";
6
- import { createContext as o, useCallback as s, useContext as c, useEffect as l, useId as u, useImperativeHandle as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h, useSyncExternalStore as g } from "react";
7
- import { Fragment as ee, jsx as _, jsxs as te } from "react/jsx-runtime";
8
- import { createPresence as v } from "@slotted/core/presence";
9
- import { drawerMessages as y } from "@slotted/core/i18n";
10
- import { createPortalRoot as b } from "@slotted/core/portal";
11
- import { createDismissableLayer as x } from "@slotted/core/dismissable-layer";
12
- import { createPortal as S, flushSync as ne } from "react-dom";
13
- import { EXTENT_LARGE_STEP_PX as C, EXTENT_STEP_PX as w, SHEET_FLING_PX_PER_S as re, addExtentSample as T, anchorsAtStart as E, attachSheetDrag as D, createSheetMotion as O, dampenExtent as k, extentAtPoint as ie, extentBounds as A, extentVelocity as j, holdResizeGesture as ae, isInlineSide as oe, measureSheetStops as M, sameStop as N, settleExtent as se, sheetMotionHolds as P, stepAmountFromPixels as ce, stepExtent as F, stopAsExtent as I } from "@slotted/core/extent";
14
- import { clamp as L, observeKeyboardInset as R } from "@slotted/core/measure";
15
- //#region src/drawer/drawer-defaults.tsx
16
- var z = o({
17
- back: "close",
18
- escape: "close",
19
- modal: !0,
20
- mode: "overlay",
21
- mount: "active",
22
- outsidePress: "close",
23
- side: "end",
24
- size: void 0,
25
- drag: "panel"
26
- });
27
- function B() {
28
- return c(z);
29
- }
30
- function V({ children: e, ...t }) {
31
- let n = B();
32
- return /* @__PURE__ */ _(z.Provider, {
33
- value: {
34
- back: t.back ?? n.back,
35
- escape: t.escape ?? n.escape,
36
- modal: t.modal ?? n.modal,
37
- mode: t.mode ?? n.mode,
38
- mount: t.mount ?? n.mount,
39
- outsidePress: t.outsidePress ?? n.outsidePress,
40
- side: t.side ?? n.side,
41
- size: t.size ?? n.size,
42
- drag: t.drag ?? n.drag
43
- },
44
- children: e
45
- });
46
- }
47
- //#endregion
48
- //#region src/drawer/drawer.tsx
49
- var H = o(void 0);
50
- function U() {
51
- let e = c(H);
52
- if (e === void 0) throw Error("Every drawer part must be rendered inside Drawer.");
53
- return e;
54
- }
55
- var le = [];
56
- function W({ children: t, back: n, container: r, defaultExtent: i, defaultOpen: o, drag: c, escape: f, extent: g, finalFocus: ee, initialFocus: te, loading: b, maxExtent: x, messages: S, minExtent: ne, modal: C, mode: w, mount: re, onExtentChange: T, onOpenChange: E, onOpenChangeComplete: D, open: O, outsidePress: k, ref: ie, scrimFrom: j, side: ae, size: oe, snapPoints: M }) {
57
- let N = B(), se = e(y, S), P = u(), [ce, F] = h(o ?? !1), I = O ?? ce, [R, z] = h(i), V = g ?? R, [U, W] = h(!1), [ue, G] = h(null), [de, fe] = h(void 0), K = w ?? N.mode, pe = K === "inline" ? !1 : C ?? N.modal, q = re ?? N.mount, J = ae ?? N.side, me = oe ?? N.size ?? (J === "top" || J === "bottom" ? "content" : "md"), he = K === "inline" ? "none" : f ?? N.escape, ge = K === "inline" ? "none" : n ?? N.back, _e = K === "inline" ? "none" : k ?? N.outsidePress, Y = M ?? le, X = p(() => {
58
- let e = A(Y, ne ?? .2, x ?? 1);
59
- return me === "content" ? {
60
- ...e,
61
- max: Math.max(e.max, x ?? 1)
62
- } : e;
63
- }, [
64
- x,
65
- ne,
66
- me,
67
- Y
68
- ]), [Z, ve] = h(I ? "entering" : "unmounted"), Q = m(null), ye = m(D);
69
- ye.current = D, Q.current === null && (Q.current = v({
70
- onEnterComplete: () => ye.current?.(!0),
71
- onExitComplete: () => ye.current?.(!1),
72
- onStatusChange: ve,
73
- present: I,
74
- skipInitialAnimation: !1
75
- })), l(() => {
76
- Q.current?.sync(I);
77
- }, [I]), l(() => {
78
- I && G(null);
79
- }, [I]), l(() => {
80
- let e = Q.current;
81
- return () => e?.stop();
82
- }, []);
83
- let be = m(I);
84
- I && (be.current = !0);
85
- let xe = K === "inline" || q === "eager" ? !0 : q === "lazy" ? be.current : Z !== "unmounted", Se = m({
86
- layer: null,
87
- panel: null,
88
- trigger: null
89
- }), [Ce, we] = h(!1), [Te, Ee] = h(!1), De = s((e) => (e === "title" ? we(!0) : Ee(!0), () => {
90
- e === "title" ? we(!1) : Ee(!1);
91
- }), []), Oe = s((e) => {
92
- Se.current.layer = e, Q.current?.setNode(e);
93
- }, []), $ = s((e, t, n, r) => {
94
- if (e === I) return;
95
- let i = !1, o = a({
96
- controlled: O,
97
- initial: I,
98
- onRequest: (e) => {
99
- i = e.cancelled, E?.(e.value, {
100
- get cancelled() {
101
- return e.cancelled;
102
- },
103
- cancel: () => e.cancel(),
104
- previous: e.previous,
105
- reason: t,
106
- result: n,
107
- source: e.source,
108
- value: e.value
109
- });
110
- }
111
- }).request(e, t, r);
112
- i || o && F(e);
113
- }, [
114
- I,
115
- E,
116
- O
117
- ]), ke = s((e, t, n) => {
118
- let r = e === void 0 ? void 0 : L(e, 0, X.max);
119
- if (r === V) return;
120
- let i = !1, o = a({
121
- controlled: g,
122
- initial: V,
123
- onRequest: (e) => {
124
- i = e.cancelled, T?.(e.value, {
125
- get cancelled() {
126
- return e.cancelled;
127
- },
128
- cancel: () => e.cancel(),
129
- previous: e.previous,
130
- reason: t,
131
- source: e.source,
132
- value: e.value
133
- });
134
- }
135
- }).request(r, t, n);
136
- i || o && z(r);
137
- }, [
138
- X.max,
139
- V,
140
- g,
141
- T
142
- ]);
143
- d(ie, () => ({
144
- open: () => $(!0, "programmatic", void 0, void 0),
145
- close: (e) => $(!1, "programmatic", e, void 0),
146
- focus: () => Se.current.panel?.focus(),
147
- get panel() {
148
- return Se.current.panel;
149
- }
150
- }), [$]);
151
- let Ae = p(() => ({
152
- announce: De,
153
- close: (e, t, n) => $(!1, e, t, n),
154
- container: r,
155
- descriptionId: Te ? `${P}description` : "",
156
- dragging: U,
157
- drag: c ?? N.drag,
158
- scrimFrom: j ?? 0,
159
- live: ue,
160
- setLive: G,
161
- rest: de,
162
- setRest: fe,
163
- back: ge,
164
- escape: he,
165
- extent: V,
166
- finalFocus: ee,
167
- initialFocus: te ?? "first",
168
- loading: b === !0,
169
- defaultExtent: i,
170
- maxExtent: X.max,
171
- minExtent: X.min,
172
- modal: pe,
173
- mode: K,
174
- mounted: xe,
175
- mount: q,
176
- nodes: Se.current,
177
- open: I,
178
- openWith: (e, t) => $(!0, e, void 0, t),
179
- outsidePress: _e,
180
- panelId: `${P}panel`,
181
- registerLayer: Oe,
182
- requestExtent: ke,
183
- setDragging: W,
184
- side: J,
185
- size: me,
186
- snapPoints: Y,
187
- t: se,
188
- titleId: Ce ? `${P}title` : "",
189
- triggerId: `${P}trigger`,
190
- visible: K === "inline" ? I : Z === "open",
191
- interactive: K === "inline" ? I : Z === "entering" || Z === "open"
192
- }), [
193
- De,
194
- P,
195
- X.max,
196
- X.min,
197
- r,
198
- V,
199
- i,
200
- I,
201
- Te,
202
- N.drag,
203
- c,
204
- U,
205
- ue,
206
- de,
207
- j,
208
- ee,
209
- te,
210
- b,
211
- xe,
212
- Oe,
213
- ke,
214
- $,
215
- ge,
216
- he,
217
- pe,
218
- K,
219
- q,
220
- _e,
221
- J,
222
- me,
223
- Y,
224
- Z,
225
- se,
226
- Ce
227
- ]);
228
- return /* @__PURE__ */ _(H.Provider, {
229
- value: Ae,
230
- children: t
231
- });
232
- }
233
- //#endregion
234
- //#region src/drawer/drawer-parts.tsx
235
- function ue(e) {
236
- return e.detail === 0 ? "keyboard" : "pointer";
237
- }
238
- var G = typeof document > "u" ? l : f;
239
- function de(e) {
240
- return e !== null && getComputedStyle(e).direction === "rtl";
241
- }
242
- function fe(e, t) {
243
- if (e === null) return null;
244
- if (t !== "inline") return e;
245
- let n = e.parentElement;
246
- for (; n !== null && K.has(n);) n = n.parentElement;
247
- return n;
248
- }
249
- var K = /* @__PURE__ */ new WeakSet(), pe = () => () => {};
250
- function q() {
251
- return g(pe, () => !0, () => !1);
252
- }
253
- function J({ children: e, className: t, onClick: n, ref: i, render: a, style: o, ...s }) {
254
- let c = U(), l = r({
255
- ...s,
256
- "aria-controls": c.mounted ? c.panelId : void 0,
257
- "aria-expanded": c.open,
258
- ...c.mode === "overlay" ? { "aria-haspopup": "dialog" } : {},
259
- children: e,
260
- className: t,
261
- "data-part": "trigger",
262
- ...c.open ? { "data-open": "" } : {},
263
- id: c.triggerId,
264
- onClick: (e) => {
265
- n?.(e), !e.defaultPrevented && (c.open ? c.close(ue(e), void 0, e) : c.openWith(ue(e), e));
266
- },
267
- ref: (e) => {
268
- c.nodes.trigger = e, typeof i == "function" ? i(e) : i && (i.current = e);
269
- },
270
- style: o,
271
- type: "button"
272
- });
273
- return a === void 0 ? /* @__PURE__ */ _("button", { ...l }) : a(l);
274
- }
275
- function me(e) {
276
- let [t, n] = h(null);
277
- return G(() => {
278
- if (e.mode === "inline" || !e.mounted) return;
279
- let t = b({
280
- origin: e.nodes.trigger,
281
- ...e.container === void 0 ? {} : { container: e.container }
282
- });
283
- return n(t.container), () => {
284
- n(null), t.release();
285
- };
286
- }, [
287
- e.container,
288
- e.mode,
289
- e.mounted,
290
- e.nodes
291
- ]), t;
292
- }
293
- function he(e, t) {
294
- let [n, r] = h(void 0), { mode: i, side: a } = e, o = e.live ?? e.extent;
295
- return G(() => {
296
- let e = fe(t, i);
297
- if (e === null || o === void 0) {
298
- r(void 0);
299
- return;
300
- }
301
- let n = () => {
302
- let t = e.getBoundingClientRect(), n = oe(a) ? t.width : t.height;
303
- n > 0 && r(`${Math.round(o * n)}px`);
304
- };
305
- if (n(), typeof ResizeObserver > "u") return;
306
- let s = new ResizeObserver(n);
307
- return s.observe(e), () => s.disconnect();
308
- }, [
309
- o,
310
- t,
311
- i,
312
- a
313
- ]), n;
314
- }
315
- function ge(e) {
316
- let t = getComputedStyle(e).transitionDuration.split(",").map((e) => e.trim().endsWith("ms") ? Number.parseFloat(e) : Number.parseFloat(e) * 1e3).filter(Number.isFinite), n = Math.max(0, ...t);
317
- return n > 0 ? n : void 0;
318
- }
319
- var _e = "var(--slotted-space-12, 4rem)";
320
- function Y(e, t, n) {
321
- return M({
322
- atRest: e.extent === void 0 && e.live === null,
323
- content: e.size === "content",
324
- panel: t,
325
- reserve: _e,
326
- rest: e.rest,
327
- snapPoints: e.snapPoints,
328
- span: n
329
- });
330
- }
331
- function X(e, t, n) {
332
- return I(t, n, e.size === "content");
333
- }
334
- function Z({ children: e, className: t, ref: n, render: a, style: o, ...c }) {
335
- let u = U(), d = me(u), [f, p] = h(null), [g, v] = h(null), y = he(u, f), b = u.mode === "overlay", C = q(), [w] = h(() => {
336
- if (typeof document > "u") return null;
337
- let e = document.createElement("div");
338
- return e.style.display = "contents", K.add(e), e;
339
- }), re = s((e) => {
340
- e !== null && w !== null && (K.add(e), b ? d !== null && d.append(w) : e.append(w));
341
- }, [
342
- w,
343
- b,
344
- d
345
- ]), T = m(!1), E = C && w !== null && u.mounted && (!b || d !== null || T.current);
346
- G(() => {
347
- T.current = E;
348
- });
349
- let ie = !b || d !== null, A = u.titleId !== "" && c["aria-label"] === void 0 && (b || c.role !== void 0), { registerLayer: j } = u, ae = s((e) => {
350
- p(e), j(e);
351
- }, [j]), M = m(u);
352
- M.current = u, l(() => {
353
- if (g === null || f === null || !u.open || !ie) return;
354
- let e = u.nodes.trigger === null ? [] : [u.nodes.trigger], t = b ? x(f, {
355
- back: u.modal && u.back === "close",
356
- branches: e,
357
- content: g,
358
- escape: u.escape === "close",
359
- modal: u.modal,
360
- onDismiss: (e) => {
361
- if (e.reason === "outsidePress" && M.current.outsidePress === "none") return e.cancel();
362
- M.current.close(e.reason, void 0, e.source);
363
- },
364
- outsidePress: u.outsidePress === "close",
365
- outsidePressEvent: "click"
366
- }) : null, n = u.initialFocus, r = u.finalFocus, a = g.ownerDocument.activeElement, o = a?.parentElement ?? null, s = i(g, {
367
- contain: b && u.modal,
368
- initial: b ? typeof n == "object" && n ? () => n.current : n : !1,
369
- restore: r === void 0 ? () => {
370
- if (a === null || a === a.ownerDocument.body) return M.current.nodes.trigger;
371
- if (a.isConnected) return a;
372
- let e = o;
373
- for (; e !== null && !e.isConnected;) e = e.parentElement;
374
- return e;
375
- } : r === !1 ? !1 : () => r.current
376
- });
377
- return s.enter(), () => {
378
- t?.destroy(), s.destroy();
379
- };
380
- }, [
381
- u.back,
382
- u.escape,
383
- u.finalFocus,
384
- u.initialFocus,
385
- u.modal,
386
- u.open,
387
- u.outsidePress,
388
- f,
389
- b,
390
- g,
391
- ie
392
- ]);
393
- let { setRest: ce, open: F, extent: I, live: L, dragging: z } = u;
394
- G(() => {
395
- let e = fe(f, u.mode);
396
- if (g === null || e === null || !F || I !== void 0 || L !== null || z) return;
397
- let t = oe(u.side), n = () => {
398
- if (P(g)) return;
399
- let n = e.getBoundingClientRect(), r = t ? n.width : n.height;
400
- if (r <= 0) return;
401
- let i = t ? g.offsetWidth : g.offsetHeight;
402
- ce(Math.round(i / r * 1e3) / 1e3);
403
- };
404
- if (typeof ResizeObserver > "u") {
405
- n();
406
- return;
407
- }
408
- let r = new ResizeObserver(n);
409
- return r.observe(g), r.observe(e), () => r.disconnect();
410
- }, [
411
- f,
412
- u.mode,
413
- u.side,
414
- z,
415
- I,
416
- F,
417
- L,
418
- g,
419
- ce
420
- ]), l(() => {
421
- if (!b || f === null || !F) return;
422
- let e = R(f.ownerDocument.defaultView, (e) => {
423
- e === 0 ? f.style.removeProperty("--slotted-keyboard-inset") : f.style.setProperty("--slotted-keyboard-inset", `${e}px`);
424
- });
425
- return () => {
426
- e(), f.style.removeProperty("--slotted-keyboard-inset");
427
- };
428
- }, [
429
- F,
430
- f,
431
- b
432
- ]);
433
- let B = b && u.side === "bottom" && u.drag === "panel", V = m(null);
434
- if (l(() => {
435
- if (!B || g === null || f === null || !F) return;
436
- let e = 0, t = 0, n = 0, r = {
437
- rest: void 0,
438
- stops: []
439
- }, i = !1, a = O(g);
440
- V.current = a;
441
- let o = () => (e = f.getBoundingClientRect().height, e > 0 ? (a.visible() ?? g.offsetHeight) / e : 0), s = () => {
442
- a.end(), f.toggleAttribute("data-undimmed", i);
443
- }, c = () => a.holds() && r.stops.length > 0 ? r : Y(M.current, g, e);
444
- return D(g, {
445
- enabled: () => M.current.open,
446
- canGrow: () => {
447
- let e = o(), t = c().stops.at(-1);
448
- return t !== void 0 && e < t && !N(e, t);
449
- },
450
- onStart: () => {
451
- let s = a.holds(), l = o();
452
- r = c(), s || (i = f.hasAttribute("data-undimmed")), t = a.begin(l * e, (r.stops.at(-1) ?? 0) * e) / e, n = t, f.toggleAttribute("data-dragging", !0);
453
- },
454
- onMove: (i) => {
455
- if (e <= 0) return;
456
- n = Math.max(0, t + i / e);
457
- let o = r.stops.at(-1) ?? t, s = k(n, o);
458
- a.follow(s * e), f.toggleAttribute("data-undimmed", s < M.current.scrimFrom);
459
- },
460
- onEnd: (i) => {
461
- let o = M.current;
462
- f.toggleAttribute("data-dragging", !1);
463
- let c = se({
464
- fraction: Math.min(n, r.stops.at(-1) ?? n),
465
- span: e,
466
- stops: r.stops,
467
- velocity: e > 0 ? i / e : 0
468
- });
469
- if (c === "close") {
470
- a.settle(0, i, ge(f)), o.close("pointer", void 0, null), requestAnimationFrame(() => {
471
- M.current.open && a.settle(t * e, 0).then(s);
472
- });
473
- return;
474
- }
475
- a.settle(c * e, i).then(() => {
476
- ne(() => {
477
- o.requestExtent(X(o, c, r.rest), "pointer", null);
478
- }), s();
479
- });
480
- }
481
- });
482
- }, [
483
- F,
484
- f,
485
- g,
486
- B
487
- ]), l(() => () => {
488
- V.current?.end(), V.current = null;
489
- }, [g]), !u.mounted) return null;
490
- if (!C || w === null) {
491
- if (b) return null;
492
- } else if (!E) return null;
493
- let H = b && u.side === "bottom" && (u.size === "full" || u.extent !== void 0 && N(u.extent, 1)), le = r({
494
- ...c,
495
- ...u.descriptionId === "" ? {} : { "aria-describedby": u.descriptionId },
496
- ...A ? { "aria-labelledby": u.titleId } : {},
497
- ...u.modal ? { "aria-modal": !0 } : {},
498
- children: e,
499
- className: t,
500
- "data-part": "panel",
501
- id: u.panelId,
502
- ref: (e) => {
503
- v(e), u.nodes.panel = e, typeof n == "function" ? n(e) : n && (n.current = e);
504
- },
505
- ...b ? { role: "dialog" } : {},
506
- style: o
507
- }), W = /* @__PURE__ */ te("div", {
508
- "data-mode": u.mode,
509
- "data-mount": u.mount,
510
- "data-part": "root",
511
- "data-part-root": "",
512
- "data-side": u.side,
513
- "data-size": u.size,
514
- "data-ui": "drawer",
515
- "data-ui-drawer": "",
516
- ...u.dragging ? { "data-dragging": "" } : {},
517
- ...b && u.side === "bottom" ? { "data-drag": u.drag } : {},
518
- ...H ? { "data-expanded": "" } : {},
519
- ...b && (u.live ?? u.extent ?? u.rest ?? 1) < u.scrimFrom ? { "data-undimmed": "" } : {},
520
- ...u.loading ? { "data-loading": "" } : {},
521
- ...u.modal ? { "data-modal": "" } : {},
522
- ...u.interactive ? {} : { inert: !0 },
523
- ...u.visible ? { "data-open": "" } : {},
524
- ref: ae,
525
- style: y === void 0 ? void 0 : { "--slotted-drawer-extent": y },
526
- children: [b ? /* @__PURE__ */ _("div", {
527
- "data-part": "backdrop",
528
- "data-part-backdrop": ""
529
- }) : null, a === void 0 ? /* @__PURE__ */ _("div", { ...le }) : a(le)]
530
- });
531
- return !C || w === null ? /* @__PURE__ */ _("div", {
532
- style: ve,
533
- children: W
534
- }) : /* @__PURE__ */ te(ee, { children: [/* @__PURE__ */ _("div", {
535
- ref: re,
536
- style: ve
537
- }), S(W, w)] });
538
- }
539
- var ve = { display: "contents" }, Q = 3;
540
- function ye({ className: e, largeStep: t = C, onDoubleClick: n, onKeyDown: i, onPointerDown: a, ref: o, render: s, step: c = w, style: u, ...d }) {
541
- let f = U(), p = m(null), h = m(null), g = m([]), v = m(null), y = m(null), b = m(null), x = m(null), S = m(null), D = m(null), k = m(null);
542
- l(() => () => x.current?.end(), []);
543
- let A = oe(f.side), M = f.live ?? f.extent ?? f.rest ?? f.minExtent, P = (e) => Math.round(L(e, 0, 1) * 100), I = () => {
544
- let e = fe(f.nodes.layer, f.mode);
545
- return e === null ? null : e.getBoundingClientRect();
546
- }, R = () => {
547
- let e = f.nodes.panel, t = I();
548
- return e === null || t === null || f.snapPoints.length === 0 ? {
549
- rest: f.rest,
550
- stops: []
551
- } : Y(f, e, A ? t.width : t.height);
552
- }, z = (e, t) => {
553
- h.current = e, f.requestExtent(e, "pointer", t);
554
- }, B = (e, t) => ie({
555
- point: {
556
- x: e.clientX,
557
- y: e.clientY
558
- },
559
- rect: t,
560
- rtl: de(p.current),
561
- side: f.side
562
- }), V = (e) => {
563
- if (a?.(e), e.defaultPrevented || e.button !== 0) return;
564
- let t = I();
565
- t !== null && (e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), e.currentTarget.focus(), v.current = {
566
- moved: !1,
567
- offset: M - B(e, t),
568
- x: e.clientX,
569
- y: e.clientY
570
- }, g.current = []);
571
- }, H = (e) => {
572
- let t = v.current;
573
- if (t === null) return;
574
- let n = k.current;
575
- if (x.current !== null && n !== null) {
576
- let r = L((n.bottom - e.clientY) / n.height + t.offset, 0, 1);
577
- g.current = T(g.current, {
578
- at: e.timeStamp,
579
- fraction: r
580
- }), h.current = r, x.current.follow(r * n.height);
581
- return;
582
- }
583
- let r = I();
584
- if (r === null) return;
585
- if (!t.moved) {
586
- if (Math.hypot(e.clientX - t.x, e.clientY - t.y) < Q) return;
587
- t.moved = !0, b.current?.(), b.current = ae(p.current?.ownerDocument, A ? "col-resize" : "row-resize");
588
- let n = f.nodes.panel, i = f.nodes.layer;
589
- if (f.side === "bottom" && f.mode === "overlay" && n !== null && i !== null) {
590
- let a = O(n), o = a.holds(), s = a.visible() ?? (n.offsetHeight || M * r.height);
591
- S.current = o && D.current || R(), D.current = S.current;
592
- let c = S.current.stops.at(-1) ?? f.maxExtent, l = a.begin(s, c * r.height);
593
- x.current = a, k.current = r, i.toggleAttribute("data-dragging", !0), t.offset = l / r.height - (r.bottom - t.y) / r.height, H(e);
594
- return;
595
- }
596
- f.setDragging(!0);
597
- }
598
- let i = L(B(e, r) + t.offset, 0, 1);
599
- g.current = T(g.current, {
600
- at: e.timeStamp,
601
- fraction: i
602
- }), z(i, e);
603
- }, le = (e) => {
604
- let { rest: t, stops: n } = R();
605
- if (n.length < 2) return;
606
- let r = f.live ?? f.extent ?? t ?? M, i = n.find((e) => e > r && !N(e, r)) ?? n[0];
607
- f.requestExtent(X(f, i, t), "pointer", e);
608
- }, W = (e) => {
609
- let t = v.current;
610
- if (t === null) return;
611
- if (v.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), !t.moved) {
612
- e.type === "pointerup" && le(e);
613
- return;
614
- }
615
- b.current?.(), b.current = null;
616
- let n = x.current;
617
- x.current = null;
618
- let r = k.current ?? I();
619
- k.current = null, n === null ? f.setDragging(!1) : f.nodes.layer?.toggleAttribute("data-dragging", !1);
620
- let i = r === null ? 0 : A ? r.width : r.height, a = h.current ?? M, o = e.type === "pointercancel" ? 0 : j(g.current, e.timeStamp);
621
- h.current = null, g.current = [];
622
- let { rest: s, stops: c } = n && S.current || R();
623
- S.current = null;
624
- let l = c.length > 0 ? se({
625
- fraction: a,
626
- span: i,
627
- stops: c,
628
- velocity: o
629
- }) : a < f.minExtent || o * i <= -re ? "close" : L(a, f.minExtent, f.maxExtent), u = (t) => f.requestExtent(c.length > 0 ? X(f, t, s) : t, "pointer", e);
630
- if (l === "close") {
631
- let t = f.nodes.layer, r = c.length > 0 ? c[0] : f.minExtent;
632
- n?.settle(0, o * i, t ? ge(t) : void 0), f.close("pointer", void 0, e), f.requestExtent(r, "pointer", e), n !== null && t !== null && requestAnimationFrame(() => {
633
- t.hasAttribute("data-open") && n.settle(r * i, 0).then(n.end);
634
- });
635
- return;
636
- }
637
- if (n === null) {
638
- u(l);
639
- return;
640
- }
641
- n.settle(l * i, o * i).then(() => {
642
- ne(() => u(l)), n.end();
643
- });
644
- }, ue = (e) => {
645
- if (i?.(e), e.defaultPrevented) return;
646
- let n = E(f.side, de(p.current)), r = A ? "ArrowLeft" : "ArrowUp", a = A ? "ArrowRight" : "ArrowDown", o = (n) => {
647
- e.preventDefault();
648
- let r = I(), i = r === null ? 0 : ce({
649
- pixels: e.shiftKey ? t : c,
650
- rect: r,
651
- side: f.side
652
- }), { rest: a, stops: o } = R(), s = F({
653
- amount: i,
654
- direction: n,
655
- fraction: M,
656
- max: o.at(-1) ?? f.maxExtent,
657
- min: o[0] ?? f.minExtent,
658
- snapPoints: o
659
- });
660
- f.requestExtent(X(f, s, a), "keyboard", e);
661
- }, s = (t) => {
662
- e.preventDefault();
663
- let { rest: n, stops: r } = R(), i = t === "first" ? r[0] ?? f.minExtent : r.at(-1) ?? f.maxExtent;
664
- f.requestExtent(X(f, i, n), "keyboard", e);
665
- };
666
- switch (e.key) {
667
- case r: return o(n ? -1 : 1);
668
- case a: return o(n ? 1 : -1);
669
- case "Home": return s("first");
670
- case "End": return s("last");
671
- case "Enter": return e.preventDefault(), M > f.minExtent ? (y.current = M, f.requestExtent(f.minExtent, "keyboard", e)) : f.requestExtent(y.current ?? f.maxExtent, "keyboard", e);
672
- default: return;
673
- }
674
- }, G = (e) => {
675
- n?.(e), !e.defaultPrevented && (e.preventDefault(), f.requestExtent(f.defaultExtent, "pointer", e));
676
- }, K = f.size === "content" && f.rest !== void 0 ? Math.min(f.minExtent, f.rest) : f.minExtent, pe = r({
677
- "aria-controls": f.panelId,
678
- ...f.titleId === "" ? {} : { "aria-labelledby": f.titleId },
679
- "aria-orientation": A ? "vertical" : "horizontal",
680
- "aria-valuemax": P(f.maxExtent),
681
- "aria-valuemin": P(K),
682
- "aria-valuenow": P(L(M, K, f.maxExtent)),
683
- ...d,
684
- className: e,
685
- "data-part": "resizer",
686
- onDoubleClick: G,
687
- onKeyDown: ue,
688
- onLostPointerCapture: W,
689
- onPointerDown: V,
690
- onPointerMove: H,
691
- onPointerUp: W,
692
- role: "separator",
693
- style: u,
694
- tabIndex: 0
695
- }), q = (e) => {
696
- p.current = e, typeof o == "function" ? o(e) : o && (o.current = e);
697
- }, J = /* @__PURE__ */ te(ee, { children: [
698
- /* @__PURE__ */ _("span", {
699
- "aria-hidden": "true",
700
- "data-part": "line",
701
- "data-part-line": ""
702
- }),
703
- /* @__PURE__ */ _("span", {
704
- "aria-hidden": "true",
705
- "data-part": "grip",
706
- "data-part-grip": ""
707
- }),
708
- /* @__PURE__ */ _("span", {
709
- "aria-hidden": "true",
710
- "data-part": "line",
711
- "data-part-line": ""
712
- })
713
- ] });
714
- return s === void 0 ? /* @__PURE__ */ _("div", {
715
- ...pe,
716
- ref: q,
717
- children: J
718
- }) : s({
719
- ...pe,
720
- children: J,
721
- ref: q
722
- });
723
- }
724
- function be({ children: e, className: t, ref: n, render: i, style: a, ...o }) {
725
- let s = r({
726
- ...o,
727
- children: e,
728
- className: t,
729
- "data-part": "header",
730
- style: a
731
- });
732
- return i === void 0 ? /* @__PURE__ */ _("header", {
733
- ...s,
734
- ref: n
735
- }) : i(s);
736
- }
737
- function xe({ children: e, className: t, ref: n, render: i, style: a, ...o }) {
738
- let s = U();
739
- l(() => s.announce("title"), [s]);
740
- let c = r({
741
- ...o,
742
- children: e,
743
- className: t,
744
- "data-part": "title",
745
- id: s.titleId === "" ? void 0 : s.titleId,
746
- style: a
747
- });
748
- return i === void 0 ? /* @__PURE__ */ _("h2", {
749
- ...c,
750
- ref: n
751
- }) : i(c);
752
- }
753
- function Se({ children: e, className: t, ref: n, render: i, style: a, ...o }) {
754
- let s = U();
755
- l(() => s.announce("description"), [s]);
756
- let c = r({
757
- ...o,
758
- children: e,
759
- className: t,
760
- "data-part": "description",
761
- id: s.descriptionId === "" ? void 0 : s.descriptionId,
762
- style: a
763
- });
764
- return i === void 0 ? /* @__PURE__ */ _("p", {
765
- ...c,
766
- ref: n
767
- }) : i(c);
768
- }
769
- function Ce({ children: e, className: t, inset: n, ref: i, render: a, style: o, ...s }) {
770
- let c = U(), l = r({
771
- ...s,
772
- ...c.loading ? { "aria-busy": !0 } : {},
773
- children: e,
774
- className: t,
775
- ...n === void 0 ? {} : { "data-inset": n },
776
- "data-part": "body",
777
- style: o
778
- });
779
- return a === void 0 ? /* @__PURE__ */ _("div", {
780
- ...l,
781
- ref: i
782
- }) : a(l);
783
- }
784
- function we({ children: e, className: t, ref: n, render: i, style: a, ...o }) {
785
- let s = r({
786
- ...o,
787
- children: e,
788
- className: t,
789
- "data-part": "footer",
790
- style: a
791
- });
792
- return i === void 0 ? /* @__PURE__ */ _("footer", {
793
- ...s,
794
- ref: n
795
- }) : i(s);
796
- }
797
- function Te({ children: e, className: i, onClick: a, ref: o, render: s, style: c, value: l, ...u }) {
798
- let d = U(), f = r({
799
- "aria-label": d.t("close"),
800
- ...u,
801
- children: e ?? /* @__PURE__ */ _(n, { children: /* @__PURE__ */ _(t, { name: "x" }) }),
802
- className: i,
803
- "data-part": "close",
804
- onClick: (e) => {
805
- a?.(e), !e.defaultPrevented && d.close("dismiss", l, e);
806
- },
807
- style: c,
808
- type: "button"
809
- });
810
- return s === void 0 ? /* @__PURE__ */ _("button", {
811
- ...f,
812
- ref: o
813
- }) : s(f);
814
- }
815
- //#endregion
816
- export { be as a, xe as c, U as d, V as f, we as i, J as l, Te as n, Z as o, B as p, Se as r, ye as s, Ce as t, W as u };