altitude-design 0.1.2 → 0.2.1
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/README.md +8 -3
- package/dist/altitude.css +85 -16
- package/dist/altitude.iife.js +5 -3
- package/dist/altitude.no-fonts.css +1701 -0
- package/dist/fonts.css +1 -0
- package/dist/index.cjs +840 -417
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +840 -417
- package/dist/index.js.map +4 -4
- package/dist/types/collections.d.ts +6 -2
- package/dist/types/command.d.ts +5 -1
- package/dist/types/controls.d.ts +37 -8
- package/dist/types/core.d.ts +23 -2
- package/dist/types/empty.d.ts +24 -0
- package/dist/types/index.d.ts +6 -2
- package/dist/types/overlays.d.ts +9 -2
- package/dist/types/suspense.d.ts +74 -0
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
AltitudeProvider: () => AltitudeProvider,
|
|
38
38
|
Avatar: () => Avatar,
|
|
39
39
|
AvatarGroup: () => AvatarGroup,
|
|
40
|
+
Await: () => Await,
|
|
40
41
|
Badge: () => Badge,
|
|
41
42
|
Board: () => Board,
|
|
42
43
|
BoardCard: () => BoardCard,
|
|
@@ -56,6 +57,7 @@ __export(index_exports, {
|
|
|
56
57
|
Drilldown: () => Drilldown,
|
|
57
58
|
DropZone: () => DropZone,
|
|
58
59
|
DropdownMenu: () => DropdownMenu,
|
|
60
|
+
EmptyState: () => EmptyState,
|
|
59
61
|
Field: () => Field,
|
|
60
62
|
HoldButton: () => HoldButton,
|
|
61
63
|
HoverCard: () => HoverCard,
|
|
@@ -63,11 +65,13 @@ __export(index_exports, {
|
|
|
63
65
|
Input: () => Input,
|
|
64
66
|
Kbd: () => Kbd,
|
|
65
67
|
Layer: () => Layer,
|
|
68
|
+
LoadingScope: () => LoadingScope,
|
|
66
69
|
Pile: () => Pile,
|
|
67
70
|
Popover: () => Popover,
|
|
68
71
|
Progress: () => Progress,
|
|
69
72
|
Radio: () => Radio,
|
|
70
73
|
RadioGroup: () => RadioGroup,
|
|
74
|
+
RevealGroup: () => RevealGroup,
|
|
71
75
|
ScrollArea: () => ScrollArea,
|
|
72
76
|
Select: () => Select,
|
|
73
77
|
SelectItem: () => SelectItem,
|
|
@@ -98,9 +102,11 @@ __export(index_exports, {
|
|
|
98
102
|
Textarea: () => Textarea,
|
|
99
103
|
Toaster: () => Toaster,
|
|
100
104
|
Tooltip: () => Tooltip,
|
|
105
|
+
checkScheme: () => checkScheme,
|
|
101
106
|
commandScore: () => commandScore,
|
|
102
107
|
contrast: () => contrast,
|
|
103
108
|
deriveAccent: () => deriveAccent,
|
|
109
|
+
readPromised: () => readPromised,
|
|
104
110
|
riseDelay: () => riseDelay,
|
|
105
111
|
toast: () => toast,
|
|
106
112
|
useAltitude: () => useAltitude,
|
|
@@ -340,6 +346,63 @@ function deriveAccent(accent, surfaces) {
|
|
|
340
346
|
"--accent-soft": rgbToHex(mix(hexToRgb(ground), a, dark ? 0.2 : 0.13))
|
|
341
347
|
};
|
|
342
348
|
}
|
|
349
|
+
var SURFACES = ["surface-trench", "surface-well", "surface-ground", "surface-raised", "surface-lifted", "surface-floating", "surface-overlay", "surface-modal"];
|
|
350
|
+
var PAIRS = [];
|
|
351
|
+
for (const t of ["ink", "ink-muted", "accent-ink", "positive", "caution", "critical"]) for (const g of SURFACES) PAIRS.push([t, g, 4.5]);
|
|
352
|
+
for (const [t, g] of [
|
|
353
|
+
["ink", "accent-soft"],
|
|
354
|
+
["accent-ink", "accent-soft"],
|
|
355
|
+
["positive", "positive-soft"],
|
|
356
|
+
["caution", "caution-soft"],
|
|
357
|
+
["critical", "critical-soft"],
|
|
358
|
+
["ink", "critical-soft"],
|
|
359
|
+
["ink", "positive-soft"],
|
|
360
|
+
["ink", "caution-soft"],
|
|
361
|
+
["ink-muted", "accent-soft"],
|
|
362
|
+
["on-accent", "accent"],
|
|
363
|
+
["on-critical", "critical"]
|
|
364
|
+
]) PAIRS.push([t, g, 4.5]);
|
|
365
|
+
for (const g of ["surface-ground", "surface-well", "surface-raised", "surface-trench"]) PAIRS.push(["line-control", g, 3], ["accent", g, 3]);
|
|
366
|
+
for (const p of ["presence-1", "presence-2", "presence-3"]) {
|
|
367
|
+
PAIRS.push(["on-presence", p, 4.5]);
|
|
368
|
+
for (const g of SURFACES) PAIRS.push([p, g, 3]);
|
|
369
|
+
}
|
|
370
|
+
var isHex = (v) => /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(v);
|
|
371
|
+
function checkScheme(colors) {
|
|
372
|
+
const cs = typeof Element !== "undefined" && colors instanceof Element ? getComputedStyle(colors) : null;
|
|
373
|
+
const get = (n) => (cs ? cs.getPropertyValue("--" + n) : colors[n] ?? "").trim();
|
|
374
|
+
const out = [];
|
|
375
|
+
const seen = /* @__PURE__ */ new Set();
|
|
376
|
+
const ok = (n) => {
|
|
377
|
+
const v = get(n);
|
|
378
|
+
if (isHex(v)) return true;
|
|
379
|
+
if (!seen.has(n)) {
|
|
380
|
+
seen.add(n);
|
|
381
|
+
out.push(v ? `${n} is ${v}: use a 3- or 6-digit hex colour so it can be checked.` : `${n} is missing.`);
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
};
|
|
385
|
+
const L = (n) => lum(hexToRgb(get(n)));
|
|
386
|
+
for (let i = 1; i < SURFACES.length; i++) {
|
|
387
|
+
const lo = SURFACES[i - 1], hi = SURFACES[i];
|
|
388
|
+
if (!ok(lo) || !ok(hi)) continue;
|
|
389
|
+
if (i <= 3 ? L(hi) <= L(lo) : L(hi) < L(lo)) out.push(`${hi} (${get(hi)}) must be ${i <= 3 ? "lighter than" : "at least as light as"} ${lo} (${get(lo)}).`);
|
|
390
|
+
}
|
|
391
|
+
for (const [t, g, min] of PAIRS) {
|
|
392
|
+
if (!ok(t) || !ok(g)) continue;
|
|
393
|
+
const r = contrast(get(t), get(g));
|
|
394
|
+
if (r < min) out.push(`${t} on ${g} is ${r.toFixed(2)}:1; it needs ${min}:1.`);
|
|
395
|
+
}
|
|
396
|
+
return out;
|
|
397
|
+
}
|
|
398
|
+
var SHADOW_OR_LINE = /^(trench|well|elev-\d|lip-top|lip-bottom|line)$/;
|
|
399
|
+
function schemeCss(sel, tokens) {
|
|
400
|
+
const decl = (keep) => Object.entries(tokens).filter(([k, v]) => keep(k) && typeof v === "string" && /^[\w-]+$/.test(k) && !/[;{}<>]/.test(v)).map(([k, v]) => `--${k}: ${v};`).join(" ");
|
|
401
|
+
const plain = decl((k) => !SHADOW_OR_LINE.test(k)), soft = decl((k) => SHADOW_OR_LINE.test(k));
|
|
402
|
+
let css = plain ? `${sel} { ${plain} }` : "";
|
|
403
|
+
if (soft) css += `@media not (prefers-contrast: more) { ${sel}:not([data-contrast="more"], [data-contrast="more"] *) { ${soft} } }`;
|
|
404
|
+
return css;
|
|
405
|
+
}
|
|
343
406
|
var AltitudeContext = React.createContext(null);
|
|
344
407
|
var useAltitude = () => React.useContext(AltitudeContext);
|
|
345
408
|
function AltitudeProvider({ scheme, accent, motion = "system", contrast: contrast2 = "system", recede = true, approach = true, className, style, children, ...rest }) {
|
|
@@ -347,6 +410,18 @@ function AltitudeProvider({ scheme, accent, motion = "system", contrast: contras
|
|
|
347
410
|
const [host, setHost] = React.useState(null);
|
|
348
411
|
const [layers, setLayers] = React.useState(0);
|
|
349
412
|
const [accentVars, setAccentVars] = React.useState(null);
|
|
413
|
+
const custom = scheme && typeof scheme === "object" ? scheme : null;
|
|
414
|
+
const schemeKey = custom ? JSON.stringify(custom) : scheme;
|
|
415
|
+
const scope = React.useId();
|
|
416
|
+
const schemeSel = `.alt-root[data-scheme-id="${scope}"]`;
|
|
417
|
+
const warned = React.useRef("");
|
|
418
|
+
React.useEffect(() => {
|
|
419
|
+
if (!custom || !rootRef.current || warned.current === schemeKey) return;
|
|
420
|
+
warned.current = schemeKey;
|
|
421
|
+
const issues = checkScheme(rootRef.current);
|
|
422
|
+
if (issues.length) console.warn(`Altitude: the scheme "${custom.name}" breaks ${issues.length} of the scheme invariants (see Theming.md):
|
|
423
|
+
` + issues.join("\n"));
|
|
424
|
+
}, [schemeKey]);
|
|
350
425
|
useIsoLayoutEffect(() => {
|
|
351
426
|
if (!accent || !rootRef.current) {
|
|
352
427
|
setAccentVars(null);
|
|
@@ -362,7 +437,7 @@ function AltitudeProvider({ scheme, accent, motion = "system", contrast: contras
|
|
|
362
437
|
const mo = new MutationObserver(compute);
|
|
363
438
|
mo.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
|
|
364
439
|
return () => mo.disconnect();
|
|
365
|
-
}, [accent,
|
|
440
|
+
}, [accent, schemeKey]);
|
|
366
441
|
const api = React.useMemo(() => ({
|
|
367
442
|
host,
|
|
368
443
|
pushLayer: () => {
|
|
@@ -375,13 +450,16 @@ function AltitudeProvider({ scheme, accent, motion = "system", contrast: contras
|
|
|
375
450
|
{
|
|
376
451
|
ref: rootRef,
|
|
377
452
|
className: cx("alt-root", className),
|
|
378
|
-
"data-theme": scheme,
|
|
453
|
+
"data-theme": custom ? custom.base ?? "daylight" : scheme,
|
|
454
|
+
"data-scheme": custom?.name,
|
|
455
|
+
"data-scheme-id": custom ? scope : void 0,
|
|
379
456
|
"data-motion": motion === "system" ? void 0 : motion,
|
|
380
457
|
"data-contrast": contrast2 === "more" ? "more" : void 0,
|
|
381
458
|
"data-approach-off": approach ? void 0 : "",
|
|
382
459
|
style: { ...accentVars, ...style },
|
|
383
460
|
...rest
|
|
384
461
|
},
|
|
462
|
+
custom && /* @__PURE__ */ React.createElement("style", null, schemeCss(schemeSel, custom.tokens)),
|
|
385
463
|
/* @__PURE__ */ React.createElement("div", { className: "alt-stage", "data-receded": recede && layers > 0 ? "" : void 0 }, children),
|
|
386
464
|
/* @__PURE__ */ React.createElement("div", { className: "alt-layers", ref: setHost })
|
|
387
465
|
));
|
|
@@ -473,9 +551,190 @@ function Kbd({ listen, className, children, ...rest }) {
|
|
|
473
551
|
}
|
|
474
552
|
|
|
475
553
|
// project/components/src/controls.tsx
|
|
554
|
+
var React3 = __toESM(require("react"), 1);
|
|
555
|
+
|
|
556
|
+
// project/components/src/suspense.tsx
|
|
476
557
|
var React2 = __toESM(require("react"), 1);
|
|
477
|
-
var
|
|
558
|
+
var isPromise = (v) => !!v && (typeof v === "object" || typeof v === "function") && typeof v.then === "function";
|
|
559
|
+
var hasPromise = (children) => Array.isArray(children) ? children.some(isPromise) : isPromise(children);
|
|
560
|
+
var settled = /* @__PURE__ */ new WeakMap();
|
|
561
|
+
var reactUse = React2.use;
|
|
562
|
+
function readPromised(v) {
|
|
563
|
+
if (!isPromise(v)) return v;
|
|
564
|
+
if (reactUse) return reactUse(v);
|
|
565
|
+
let r = settled.get(v);
|
|
566
|
+
if (!r) {
|
|
567
|
+
const rec = { s: "pending" };
|
|
568
|
+
settled.set(v, rec);
|
|
569
|
+
v.then((x) => {
|
|
570
|
+
rec.s = "done";
|
|
571
|
+
rec.v = x;
|
|
572
|
+
}, (e) => {
|
|
573
|
+
rec.s = "error";
|
|
574
|
+
rec.e = e;
|
|
575
|
+
});
|
|
576
|
+
r = rec;
|
|
577
|
+
}
|
|
578
|
+
if (r.s === "done") return r.v;
|
|
579
|
+
if (r.s === "error") throw r.e;
|
|
580
|
+
throw v;
|
|
581
|
+
}
|
|
582
|
+
function readChildren(children) {
|
|
583
|
+
return Array.isArray(children) ? children.map((c) => readPromised(c)) : readPromised(children);
|
|
584
|
+
}
|
|
585
|
+
function useArrival(waiting) {
|
|
586
|
+
const d = React2.useRef(null);
|
|
587
|
+
if (waiting && !d.current) {
|
|
588
|
+
let done;
|
|
589
|
+
d.current = { p: new Promise((r) => {
|
|
590
|
+
done = r;
|
|
591
|
+
}), done };
|
|
592
|
+
}
|
|
593
|
+
const cur = d.current;
|
|
594
|
+
useIsoLayoutEffect(() => {
|
|
595
|
+
if (!waiting && cur) {
|
|
596
|
+
cur.done();
|
|
597
|
+
if (d.current === cur) d.current = null;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
return waiting && cur ? cur.p : null;
|
|
601
|
+
}
|
|
602
|
+
function Arrive({ when, children }) {
|
|
603
|
+
if (when) readPromised(when);
|
|
604
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
|
|
605
|
+
}
|
|
606
|
+
function useHasWaited(waiting) {
|
|
607
|
+
const r = React2.useRef(false);
|
|
608
|
+
if (waiting) r.current = true;
|
|
609
|
+
return r.current;
|
|
610
|
+
}
|
|
611
|
+
var ScopeContext = React2.createContext(null);
|
|
612
|
+
function LoadingScope({ children }) {
|
|
613
|
+
const [members] = React2.useState(() => /* @__PURE__ */ new Set());
|
|
614
|
+
const [waiting, setWaiting] = React2.useState(false);
|
|
615
|
+
const report = React2.useCallback((id, w) => {
|
|
616
|
+
if (w) members.add(id);
|
|
617
|
+
else members.delete(id);
|
|
618
|
+
setWaiting(members.size > 0);
|
|
619
|
+
}, [members]);
|
|
620
|
+
const value = React2.useMemo(() => ({ report, waiting }), [report, waiting]);
|
|
621
|
+
return /* @__PURE__ */ React2.createElement(ScopeContext.Provider, { value }, children);
|
|
622
|
+
}
|
|
623
|
+
function useReportWaiting(waiting) {
|
|
624
|
+
const scope = React2.useContext(ScopeContext);
|
|
625
|
+
const [id] = React2.useState(() => ({}));
|
|
626
|
+
const report = scope?.report;
|
|
627
|
+
useIsoLayoutEffect(() => {
|
|
628
|
+
report?.(id, waiting);
|
|
629
|
+
}, [report, waiting]);
|
|
630
|
+
useIsoLayoutEffect(() => () => report?.(id, false), [report]);
|
|
631
|
+
}
|
|
632
|
+
var useScopeWaiting = () => !!React2.useContext(ScopeContext)?.waiting;
|
|
633
|
+
var Group = class {
|
|
634
|
+
constructor() {
|
|
635
|
+
this.waiting = /* @__PURE__ */ new Set();
|
|
636
|
+
this.held = /* @__PURE__ */ new Map();
|
|
637
|
+
}
|
|
638
|
+
wait(id) {
|
|
639
|
+
this.waiting.add(id);
|
|
640
|
+
}
|
|
641
|
+
/** Returns true when this was the last one: everything held is released together. */
|
|
642
|
+
land(id, release) {
|
|
643
|
+
this.waiting.delete(id);
|
|
644
|
+
this.held.set(id, release);
|
|
645
|
+
if (this.waiting.size) return false;
|
|
646
|
+
this.flush();
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
leave(id) {
|
|
650
|
+
this.waiting.delete(id);
|
|
651
|
+
this.held.delete(id);
|
|
652
|
+
if (!this.waiting.size && this.held.size) this.flush();
|
|
653
|
+
}
|
|
654
|
+
flush() {
|
|
655
|
+
const all = Array.from(this.held.values());
|
|
656
|
+
this.held.clear();
|
|
657
|
+
all.forEach((f) => f());
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
var GroupContext = React2.createContext(null);
|
|
661
|
+
function RevealGroup({ children }) {
|
|
662
|
+
const group = React2.useMemo(() => new Group(), []);
|
|
663
|
+
return /* @__PURE__ */ React2.createElement(GroupContext.Provider, { value: group }, children);
|
|
664
|
+
}
|
|
665
|
+
var GRACE = 300;
|
|
666
|
+
function Await({ imprint, shape = "block", inline, enabled = true, className, children }) {
|
|
667
|
+
const group = React2.useContext(GroupContext);
|
|
668
|
+
const box = React2.useRef({ id: {}, since: null });
|
|
669
|
+
React2.useEffect(() => () => group?.leave(box.current.id), [group]);
|
|
670
|
+
if (!enabled) return /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
|
|
671
|
+
return /* @__PURE__ */ React2.createElement(React2.Suspense, { fallback: /* @__PURE__ */ React2.createElement(Imprint, { box, group, inline }, imprint) }, /* @__PURE__ */ React2.createElement(Landed, { box, group, shape, inline, className, imprint }, children));
|
|
672
|
+
}
|
|
673
|
+
function Imprint({ box, group, inline, children }) {
|
|
674
|
+
useIsoLayoutEffect(() => {
|
|
675
|
+
if (box.current.since === null) box.current.since = performance.now();
|
|
676
|
+
group?.wait(box.current.id);
|
|
677
|
+
}, []);
|
|
678
|
+
return /* @__PURE__ */ React2.createElement("span", { className: "alt-await-wait", "data-inline": inline ? "" : void 0, "aria-busy": "true" }, children, /* @__PURE__ */ React2.createElement("span", { className: "alt-sr" }, "Loading"));
|
|
679
|
+
}
|
|
680
|
+
function Landed({ box, group, shape, inline, className, imprint, children }) {
|
|
681
|
+
const [phase, setPhase] = React2.useState(null);
|
|
682
|
+
const [delay, setDelay] = React2.useState(0);
|
|
683
|
+
const [graceLeft, setGraceLeft] = React2.useState(0);
|
|
684
|
+
const done = React2.useRef(void 0);
|
|
685
|
+
useIsoLayoutEffect(() => {
|
|
686
|
+
const since = box.current.since;
|
|
687
|
+
box.current.since = null;
|
|
688
|
+
if (since === null) return;
|
|
689
|
+
const release = () => {
|
|
690
|
+
clearTimeout(done.current);
|
|
691
|
+
if (performance.now() - since < GRACE) {
|
|
692
|
+
setPhase(null);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const d = riseDelay();
|
|
696
|
+
setDelay(d);
|
|
697
|
+
setPhase("reveal");
|
|
698
|
+
done.current = setTimeout(() => setPhase(null), d + 320);
|
|
699
|
+
};
|
|
700
|
+
if (group && !group.land(box.current.id, release)) {
|
|
701
|
+
setGraceLeft(Math.max(0, GRACE - (performance.now() - since)));
|
|
702
|
+
setPhase("held");
|
|
703
|
+
} else if (!group) release();
|
|
704
|
+
}, []);
|
|
705
|
+
React2.useEffect(() => () => clearTimeout(done.current), []);
|
|
478
706
|
return /* @__PURE__ */ React2.createElement(
|
|
707
|
+
"span",
|
|
708
|
+
{
|
|
709
|
+
className: cx("alt-await", className),
|
|
710
|
+
"data-phase": phase ?? void 0,
|
|
711
|
+
"data-inline": inline ? "" : void 0,
|
|
712
|
+
"data-shape": shape,
|
|
713
|
+
"aria-busy": phase === "held" || void 0,
|
|
714
|
+
style: phase ? { ["--alt-rise-delay"]: delay + "ms", ["--alt-grace-left"]: graceLeft + "ms" } : void 0
|
|
715
|
+
},
|
|
716
|
+
phase === "held" && /* @__PURE__ */ React2.createElement("span", { className: "alt-await-held", "data-early": graceLeft > 0 ? "" : void 0, "aria-hidden": "true" }, imprint),
|
|
717
|
+
phase === "reveal" && shape !== "none" && /* @__PURE__ */ React2.createElement("span", { className: "alt-skeleton alt-await-imprint", "data-shape": shape, "aria-hidden": "true" }),
|
|
718
|
+
/* @__PURE__ */ React2.createElement("span", { className: "alt-await-face" }, children)
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
var LINE_WIDTHS = ["100%", "94%", "82%", "97%", "64%"];
|
|
722
|
+
function TextImprint({ lines = 1, width, className }) {
|
|
723
|
+
return /* @__PURE__ */ React2.createElement("span", { className: cx("alt-await-lines", className), style: { ["--lines"]: lines, width } }, Array.from({ length: lines }, (_, i) => /* @__PURE__ */ React2.createElement(
|
|
724
|
+
"span",
|
|
725
|
+
{
|
|
726
|
+
key: i,
|
|
727
|
+
className: "alt-skeleton",
|
|
728
|
+
"data-shape": "text",
|
|
729
|
+
style: { width: lines === 1 ? "100%" : i === lines - 1 ? "60%" : LINE_WIDTHS[i % LINE_WIDTHS.length], ["--i"]: i }
|
|
730
|
+
}
|
|
731
|
+
)));
|
|
732
|
+
}
|
|
733
|
+
var hint = (s) => typeof s === "object" ? s : {};
|
|
734
|
+
|
|
735
|
+
// project/components/src/controls.tsx
|
|
736
|
+
var Button = React3.forwardRef(function Button2({ variant = "secondary", size = "md", square, loading, leading, trailing, className, children, disabled, type = "button", ...rest }, ref) {
|
|
737
|
+
return /* @__PURE__ */ React3.createElement(
|
|
479
738
|
"button",
|
|
480
739
|
{
|
|
481
740
|
ref,
|
|
@@ -490,14 +749,15 @@ var Button = React2.forwardRef(function Button2({ variant = "secondary", size =
|
|
|
490
749
|
...rest,
|
|
491
750
|
onClick: loading ? (e) => e.preventDefault() : rest.onClick
|
|
492
751
|
},
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
loading && /* @__PURE__ */
|
|
752
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-btn-label" }, leading, children, trailing),
|
|
753
|
+
loading && /* @__PURE__ */ React3.createElement("span", { className: "alt-btn-spinner" }, /* @__PURE__ */ React3.createElement(Spinner, { size: size === "sm" ? 14 : 16 }))
|
|
495
754
|
);
|
|
496
755
|
});
|
|
497
|
-
var Card =
|
|
756
|
+
var Card = React3.forwardRef(function Card2({ interactive, className, onKeyDown, settle, status, heldBy, relevance, style, skeleton, children, ...rest }, ref) {
|
|
498
757
|
const actionable = interactive && !!rest.onClick;
|
|
499
758
|
const { style: depthStyle, ...depth } = useDepth({ settle, status, heldBy, relevance });
|
|
500
|
-
|
|
759
|
+
const { lines = 3 } = hint(skeleton);
|
|
760
|
+
return /* @__PURE__ */ React3.createElement(
|
|
501
761
|
"div",
|
|
502
762
|
{
|
|
503
763
|
ref,
|
|
@@ -514,29 +774,51 @@ var Card = React2.forwardRef(function Card2({ interactive, className, onKeyDown,
|
|
|
514
774
|
...depth,
|
|
515
775
|
style: { ...depthStyle, ...style },
|
|
516
776
|
...rest
|
|
517
|
-
}
|
|
777
|
+
},
|
|
778
|
+
/* @__PURE__ */ React3.createElement(LoadingScope, null, /* @__PURE__ */ React3.createElement(Await, { shape: "none", enabled: skeleton !== false, imprint: /* @__PURE__ */ React3.createElement("span", { className: "alt-await-card" }, /* @__PURE__ */ React3.createElement(TextImprint, { className: "alt-card-title", width: "45%" }), /* @__PURE__ */ React3.createElement(TextImprint, { className: "alt-await-card-body", lines })) }, children))
|
|
518
779
|
);
|
|
519
780
|
});
|
|
520
|
-
var CardHeader = ({ className, ...p }) => /* @__PURE__ */
|
|
521
|
-
var
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
781
|
+
var CardHeader = ({ className, ...p }) => /* @__PURE__ */ React3.createElement("div", { className: cx("alt-card-header", className), ...p });
|
|
782
|
+
var Promised$ = ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, readChildren(children));
|
|
783
|
+
function usePendingText(children, skeleton, required) {
|
|
784
|
+
const scopeWaiting = useScopeWaiting();
|
|
785
|
+
const missing = skeleton !== false && children === void 0 && (required || scopeWaiting);
|
|
786
|
+
useReportWaiting(required && skeleton !== false && (children === void 0 || hasPromise(children)));
|
|
787
|
+
const arrival = useArrival(missing);
|
|
788
|
+
const waited = useHasWaited(missing || hasPromise(children));
|
|
789
|
+
return { arrival, waited };
|
|
790
|
+
}
|
|
791
|
+
function PendingText({ children, skeleton, lines, width, required }) {
|
|
792
|
+
const { arrival, waited } = usePendingText(children, skeleton, required);
|
|
793
|
+
if (!waited) return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
794
|
+
const h = hint(skeleton);
|
|
795
|
+
return /* @__PURE__ */ React3.createElement(Await, { shape: "text", enabled: skeleton !== false, imprint: /* @__PURE__ */ React3.createElement(TextImprint, { lines: h.lines ?? lines, width: h.width ?? width }) }, /* @__PURE__ */ React3.createElement(Arrive, { when: arrival }, /* @__PURE__ */ React3.createElement(Promised$, null, children)));
|
|
796
|
+
}
|
|
797
|
+
var CardTitle = ({ className, children, skeleton, ...p }) => /* @__PURE__ */ React3.createElement("h3", { className: cx("alt-card-title", className), ...p }, /* @__PURE__ */ React3.createElement(PendingText, { skeleton, lines: 1, width: "55%", required: true }, children));
|
|
798
|
+
var CardDescription = ({ className, children, skeleton, ...p }) => /* @__PURE__ */ React3.createElement("p", { className: cx("alt-card-desc", className), ...p }, /* @__PURE__ */ React3.createElement(PendingText, { skeleton, lines: 2, required: false }, children));
|
|
799
|
+
var CardContent = ({ className, skeleton, children, ...p }) => {
|
|
800
|
+
const { lines = 3 } = hint(skeleton);
|
|
801
|
+
const scopeWaiting = useScopeWaiting();
|
|
802
|
+
const missing = skeleton !== false && children === void 0 && scopeWaiting;
|
|
803
|
+
const arrival = useArrival(missing);
|
|
804
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-card-content", className), ...p }, /* @__PURE__ */ React3.createElement(Await, { shape: "none", enabled: skeleton !== false, imprint: /* @__PURE__ */ React3.createElement(TextImprint, { lines }) }, /* @__PURE__ */ React3.createElement(Arrive, { when: arrival }, children)));
|
|
805
|
+
};
|
|
806
|
+
var CardFooter = ({ className, ...p }) => /* @__PURE__ */ React3.createElement("div", { className: cx("alt-card-footer", className), ...p });
|
|
807
|
+
var Input = React3.forwardRef(function Input2({ invalid, leading, trailing, size = "md", className, disabled, placeholder, ...rest }, ref) {
|
|
526
808
|
useApproach();
|
|
527
809
|
useKeyFocus();
|
|
528
|
-
return /* @__PURE__ */
|
|
810
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-input", className), "data-size": size, "data-approach": "56", "data-invalid": invalid ? "" : void 0, "data-disabled": disabled ? "" : void 0 }, leading && /* @__PURE__ */ React3.createElement("span", { className: "alt-input-adorn" }, leading), /* @__PURE__ */ React3.createElement("input", { ref, disabled, "aria-invalid": invalid || void 0, placeholder: placeholder ?? " ", ...rest }), trailing && /* @__PURE__ */ React3.createElement("span", { className: "alt-input-adorn" }, trailing));
|
|
529
811
|
});
|
|
530
|
-
var Textarea =
|
|
531
|
-
const [len, setLen] =
|
|
532
|
-
|
|
812
|
+
var Textarea = React3.forwardRef(function Textarea2({ invalid, className, disabled, placeholder, maxLength, showFill = true, onChange, value, defaultValue, ...rest }, ref) {
|
|
813
|
+
const [len, setLen] = React3.useState(() => String(value ?? defaultValue ?? "").length);
|
|
814
|
+
React3.useEffect(() => {
|
|
533
815
|
if (value !== void 0) setLen(String(value).length);
|
|
534
816
|
}, [value]);
|
|
535
817
|
const gauge = showFill && maxLength ? Math.min(1, len / maxLength) : null;
|
|
536
818
|
const level = gauge === null ? void 0 : len >= maxLength ? "full" : gauge >= 0.9 ? "near" : "ok";
|
|
537
819
|
useApproach();
|
|
538
820
|
useKeyFocus();
|
|
539
|
-
return /* @__PURE__ */
|
|
821
|
+
return /* @__PURE__ */ React3.createElement(
|
|
540
822
|
"div",
|
|
541
823
|
{
|
|
542
824
|
className: cx("alt-input", className),
|
|
@@ -547,8 +829,8 @@ var Textarea = React2.forwardRef(function Textarea2({ invalid, className, disabl
|
|
|
547
829
|
"data-fill": level,
|
|
548
830
|
style: gauge !== null ? { ["--alt-fill"]: gauge } : void 0
|
|
549
831
|
},
|
|
550
|
-
gauge !== null && /* @__PURE__ */
|
|
551
|
-
/* @__PURE__ */
|
|
832
|
+
gauge !== null && /* @__PURE__ */ React3.createElement("span", { className: "alt-input-gauge", "aria-hidden": "true" }),
|
|
833
|
+
/* @__PURE__ */ React3.createElement(
|
|
552
834
|
"textarea",
|
|
553
835
|
{
|
|
554
836
|
ref,
|
|
@@ -565,22 +847,22 @@ var Textarea = React2.forwardRef(function Textarea2({ invalid, className, disabl
|
|
|
565
847
|
}
|
|
566
848
|
}
|
|
567
849
|
),
|
|
568
|
-
gauge !== null && /* @__PURE__ */
|
|
850
|
+
gauge !== null && /* @__PURE__ */ React3.createElement("span", { className: "alt-input-count", "aria-live": "polite" }, len, " / ", maxLength)
|
|
569
851
|
);
|
|
570
852
|
});
|
|
571
|
-
function Field({ label, hint, error, required, className, children }) {
|
|
572
|
-
const id =
|
|
853
|
+
function Field({ label, hint: hint2, error, required, className, children }) {
|
|
854
|
+
const id = React3.useId();
|
|
573
855
|
const controlId = children.props.id || id + "-control";
|
|
574
|
-
const describedBy = [
|
|
575
|
-
return /* @__PURE__ */
|
|
856
|
+
const describedBy = [hint2 && id + "-hint", error && id + "-error"].filter(Boolean).join(" ") || void 0;
|
|
857
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-field", className) }, /* @__PURE__ */ React3.createElement("label", { className: "alt-field-label", htmlFor: controlId }, label, required && /* @__PURE__ */ React3.createElement("span", { className: "alt-field-req", "aria-hidden": "true" }, " *")), React3.cloneElement(children, { id: controlId, "aria-describedby": describedBy, invalid: !!error || children.props.invalid, required }), hint2 && !error && /* @__PURE__ */ React3.createElement("p", { className: "alt-field-hint", id: id + "-hint" }, hint2), error && /* @__PURE__ */ React3.createElement("p", { className: "alt-field-error", id: id + "-error", role: "alert" }, /* @__PURE__ */ React3.createElement(Icons.AlertCircle, { size: 14 }), error));
|
|
576
858
|
}
|
|
577
|
-
var Checkbox =
|
|
578
|
-
const inner =
|
|
579
|
-
|
|
580
|
-
|
|
859
|
+
var Checkbox = React3.forwardRef(function Checkbox2({ label, description, indeterminate, onCheckedChange, onChange, className, disabled, ...rest }, ref) {
|
|
860
|
+
const inner = React3.useRef(null);
|
|
861
|
+
React3.useImperativeHandle(ref, () => inner.current);
|
|
862
|
+
React3.useEffect(() => {
|
|
581
863
|
if (inner.current) inner.current.indeterminate = !!indeterminate;
|
|
582
864
|
}, [indeterminate]);
|
|
583
|
-
return /* @__PURE__ */
|
|
865
|
+
return /* @__PURE__ */ React3.createElement("label", { className: cx("alt-check", className), "data-disabled": disabled ? "" : void 0 }, /* @__PURE__ */ React3.createElement(
|
|
584
866
|
"input",
|
|
585
867
|
{
|
|
586
868
|
ref: inner,
|
|
@@ -592,20 +874,20 @@ var Checkbox = React2.forwardRef(function Checkbox2({ label, description, indete
|
|
|
592
874
|
onCheckedChange?.(e.target.checked);
|
|
593
875
|
}
|
|
594
876
|
}
|
|
595
|
-
), /* @__PURE__ */
|
|
877
|
+
), /* @__PURE__ */ React3.createElement("span", { className: "alt-check-track", "aria-hidden": "true" }, /* @__PURE__ */ React3.createElement("span", { className: "alt-check-fill" }), /* @__PURE__ */ React3.createElement("svg", { className: "alt-check-mark", viewBox: "0 0 16 16", width: "14", height: "14", fill: "none", stroke: "currentColor", strokeWidth: "2.25", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React3.createElement("path", { className: "alt-check-tick", d: "M3.5 8.5l3 3 6-6.5", pathLength: 16 }), /* @__PURE__ */ React3.createElement("path", { className: "alt-check-dash", d: "M4 8h8", pathLength: 16 }))), (label || description) && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-text" }, label && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-label" }, label), description && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-desc" }, description)));
|
|
596
878
|
});
|
|
597
|
-
var RadioCtx =
|
|
879
|
+
var RadioCtx = React3.createContext(null);
|
|
598
880
|
function RadioGroup({ value, defaultValue = "", onValueChange, name, disabled, orientation = "vertical", className, children, ...rest }) {
|
|
599
|
-
const auto =
|
|
881
|
+
const auto = React3.useId();
|
|
600
882
|
const [v, set] = useControllable(value, defaultValue, onValueChange);
|
|
601
|
-
const root =
|
|
602
|
-
const slots =
|
|
603
|
-
const [bead, setBead] =
|
|
604
|
-
const register =
|
|
883
|
+
const root = React3.useRef(null);
|
|
884
|
+
const slots = React3.useRef(/* @__PURE__ */ new Map());
|
|
885
|
+
const [bead, setBead] = React3.useState(null);
|
|
886
|
+
const register = React3.useCallback((val, el) => {
|
|
605
887
|
if (el) slots.current.set(val, el);
|
|
606
888
|
else slots.current.delete(val);
|
|
607
889
|
}, []);
|
|
608
|
-
const measure =
|
|
890
|
+
const measure = React3.useCallback(() => {
|
|
609
891
|
const el = slots.current.get(v), r = root.current;
|
|
610
892
|
if (!el || !r) {
|
|
611
893
|
setBead(null);
|
|
@@ -618,13 +900,13 @@ function RadioGroup({ value, defaultValue = "", onValueChange, name, disabled, o
|
|
|
618
900
|
useIsoLayoutEffect(() => {
|
|
619
901
|
measure();
|
|
620
902
|
}, [measure]);
|
|
621
|
-
|
|
903
|
+
React3.useEffect(() => {
|
|
622
904
|
const ro = new ResizeObserver(() => measure());
|
|
623
905
|
if (root.current) ro.observe(root.current);
|
|
624
906
|
document.fonts?.ready.then(() => measure());
|
|
625
907
|
return () => ro.disconnect();
|
|
626
908
|
}, [measure]);
|
|
627
|
-
return /* @__PURE__ */
|
|
909
|
+
return /* @__PURE__ */ React3.createElement(RadioCtx.Provider, { value: { name: name || auto, value: v, set, disabled, register } }, /* @__PURE__ */ React3.createElement("div", { ref: root, role: "radiogroup", className: cx("alt-radio-group", className), "data-orientation": orientation, "data-disabled": disabled ? "" : void 0, ...rest }, children, bead && /* @__PURE__ */ React3.createElement(
|
|
628
910
|
"span",
|
|
629
911
|
{
|
|
630
912
|
className: "alt-radio-thumb",
|
|
@@ -635,9 +917,9 @@ function RadioGroup({ value, defaultValue = "", onValueChange, name, disabled, o
|
|
|
635
917
|
)));
|
|
636
918
|
}
|
|
637
919
|
function Radio({ value, label, description, disabled, className }) {
|
|
638
|
-
const g =
|
|
920
|
+
const g = React3.useContext(RadioCtx);
|
|
639
921
|
const off = disabled || g?.disabled;
|
|
640
|
-
return /* @__PURE__ */
|
|
922
|
+
return /* @__PURE__ */ React3.createElement("label", { className: cx("alt-check alt-radio", className), "data-disabled": off ? "" : void 0 }, /* @__PURE__ */ React3.createElement(
|
|
641
923
|
"input",
|
|
642
924
|
{
|
|
643
925
|
type: "radio",
|
|
@@ -647,11 +929,11 @@ function Radio({ value, label, description, disabled, className }) {
|
|
|
647
929
|
checked: g ? g.value === value : void 0,
|
|
648
930
|
onChange: () => g?.set(value)
|
|
649
931
|
}
|
|
650
|
-
), /* @__PURE__ */
|
|
932
|
+
), /* @__PURE__ */ React3.createElement("span", { className: "alt-check-track", "data-round": "", "aria-hidden": "true", ref: (el) => g?.register(value, el) }, /* @__PURE__ */ React3.createElement("span", { className: "alt-check-fill" })), (label || description) && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-text" }, label && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-label" }, label), description && /* @__PURE__ */ React3.createElement("span", { className: "alt-check-desc" }, description)));
|
|
651
933
|
}
|
|
652
934
|
function Switch({ checked, defaultChecked = false, onCheckedChange, label, className, disabled, ...rest }) {
|
|
653
935
|
const [on, set] = useControllable(checked, defaultChecked, onCheckedChange);
|
|
654
|
-
const control = /* @__PURE__ */
|
|
936
|
+
const control = /* @__PURE__ */ React3.createElement(
|
|
655
937
|
"button",
|
|
656
938
|
{
|
|
657
939
|
type: "button",
|
|
@@ -665,29 +947,29 @@ function Switch({ checked, defaultChecked = false, onCheckedChange, label, class
|
|
|
665
947
|
set(!on);
|
|
666
948
|
}
|
|
667
949
|
},
|
|
668
|
-
/* @__PURE__ */
|
|
669
|
-
/* @__PURE__ */
|
|
950
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-switch-fill" }),
|
|
951
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-switch-thumb" })
|
|
670
952
|
);
|
|
671
953
|
if (!label) return control;
|
|
672
|
-
return /* @__PURE__ */
|
|
954
|
+
return /* @__PURE__ */ React3.createElement("label", { className: cx("alt-switch-row", className), "data-disabled": disabled ? "" : void 0 }, control, /* @__PURE__ */ React3.createElement("span", null, label));
|
|
673
955
|
}
|
|
674
|
-
var TabsCtx =
|
|
956
|
+
var TabsCtx = React3.createContext(null);
|
|
675
957
|
function Tabs({ value, defaultValue = "", onValueChange, variant = "folder", className, children, ...rest }) {
|
|
676
958
|
const [v, set] = useControllable(value, defaultValue, onValueChange);
|
|
677
|
-
const id =
|
|
678
|
-
const nodes =
|
|
679
|
-
const register =
|
|
959
|
+
const id = React3.useId();
|
|
960
|
+
const nodes = React3.useRef(/* @__PURE__ */ new Map());
|
|
961
|
+
const register = React3.useCallback((val, el) => {
|
|
680
962
|
if (el) nodes.current.set(val, el);
|
|
681
963
|
else nodes.current.delete(val);
|
|
682
964
|
}, []);
|
|
683
|
-
return /* @__PURE__ */
|
|
965
|
+
return /* @__PURE__ */ React3.createElement(TabsCtx.Provider, { value: { value: v, set, id, variant, register, nodes } }, /* @__PURE__ */ React3.createElement("div", { className: cx("alt-tabs", className), "data-variant": variant, ...rest }, children));
|
|
684
966
|
}
|
|
685
967
|
function TabsList({ className, children, ...rest }) {
|
|
686
|
-
const t =
|
|
687
|
-
const listRef =
|
|
968
|
+
const t = React3.useContext(TabsCtx);
|
|
969
|
+
const listRef = React3.useRef(null);
|
|
688
970
|
const pill = t.variant === "segmented";
|
|
689
|
-
const [ind, setInd] =
|
|
690
|
-
const measure =
|
|
971
|
+
const [ind, setInd] = React3.useState({ x: 0, w: 0, ready: false });
|
|
972
|
+
const measure = React3.useCallback(() => {
|
|
691
973
|
if (!pill) return;
|
|
692
974
|
const el = t.nodes.current.get(t.value);
|
|
693
975
|
if (!el) return;
|
|
@@ -696,7 +978,7 @@ function TabsList({ className, children, ...rest }) {
|
|
|
696
978
|
useIsoLayoutEffect(() => {
|
|
697
979
|
measure();
|
|
698
980
|
}, [measure]);
|
|
699
|
-
|
|
981
|
+
React3.useEffect(() => {
|
|
700
982
|
if (!pill) return;
|
|
701
983
|
const ro = new ResizeObserver(measure);
|
|
702
984
|
if (listRef.current) ro.observe(listRef.current);
|
|
@@ -713,7 +995,7 @@ function TabsList({ className, children, ...rest }) {
|
|
|
713
995
|
t.nodes.current.get(next)?.focus();
|
|
714
996
|
}
|
|
715
997
|
};
|
|
716
|
-
return /* @__PURE__ */
|
|
998
|
+
return /* @__PURE__ */ React3.createElement("div", { ref: listRef, role: "tablist", className: cx("alt-tabs-list", className), onKeyDown, ...rest }, pill && /* @__PURE__ */ React3.createElement(
|
|
717
999
|
"span",
|
|
718
1000
|
{
|
|
719
1001
|
className: "alt-tabs-indicator",
|
|
@@ -724,9 +1006,9 @@ function TabsList({ className, children, ...rest }) {
|
|
|
724
1006
|
), children);
|
|
725
1007
|
}
|
|
726
1008
|
function TabsTrigger({ value, className, children, ...rest }) {
|
|
727
|
-
const t =
|
|
1009
|
+
const t = React3.useContext(TabsCtx);
|
|
728
1010
|
const on = t.value === value;
|
|
729
|
-
return /* @__PURE__ */
|
|
1011
|
+
return /* @__PURE__ */ React3.createElement(
|
|
730
1012
|
"button",
|
|
731
1013
|
{
|
|
732
1014
|
ref: (el) => t.register(value, el),
|
|
@@ -744,21 +1026,21 @@ function TabsTrigger({ value, className, children, ...rest }) {
|
|
|
744
1026
|
);
|
|
745
1027
|
}
|
|
746
1028
|
function TabsContent({ value, className, ...rest }) {
|
|
747
|
-
const t =
|
|
1029
|
+
const t = React3.useContext(TabsCtx);
|
|
748
1030
|
if (t.value !== value) return null;
|
|
749
|
-
return /* @__PURE__ */
|
|
1031
|
+
return /* @__PURE__ */ React3.createElement("div", { role: "tabpanel", id: `${t.id}-p-${value}`, "aria-labelledby": `${t.id}-t-${value}`, tabIndex: 0, className: cx("alt-tabs-content", className), ...rest });
|
|
750
1032
|
}
|
|
751
1033
|
function Slider({ value, defaultValue = 50, onValueChange, min = 0, max = 100, step = 1, disabled, format = (v) => v, className, ...rest }) {
|
|
752
1034
|
const [v, set] = useControllable(value, defaultValue, onValueChange);
|
|
753
|
-
const [drag, setDrag] =
|
|
754
|
-
const track =
|
|
1035
|
+
const [drag, setDrag] = React3.useState(false);
|
|
1036
|
+
const track = React3.useRef(null);
|
|
755
1037
|
const clamp = (n) => Math.min(max, Math.max(min, Math.round((n - min) / step) * step + min));
|
|
756
1038
|
const fromX = (x) => {
|
|
757
1039
|
const r = track.current.getBoundingClientRect();
|
|
758
1040
|
return clamp(min + (x - r.left) / r.width * (max - min));
|
|
759
1041
|
};
|
|
760
1042
|
const pct = (v - min) / (max - min) * 100;
|
|
761
|
-
return /* @__PURE__ */
|
|
1043
|
+
return /* @__PURE__ */ React3.createElement(
|
|
762
1044
|
"div",
|
|
763
1045
|
{
|
|
764
1046
|
className: cx("alt-slider", className),
|
|
@@ -778,8 +1060,8 @@ function Slider({ value, defaultValue = 50, onValueChange, min = 0, max = 100, s
|
|
|
778
1060
|
onPointerCancel: () => setDrag(false),
|
|
779
1061
|
...rest
|
|
780
1062
|
},
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
1063
|
+
/* @__PURE__ */ React3.createElement("div", { className: "alt-slider-track", ref: track }, /* @__PURE__ */ React3.createElement("div", { className: "alt-slider-fill", style: { width: pct + "%" } })),
|
|
1064
|
+
/* @__PURE__ */ React3.createElement(
|
|
783
1065
|
"div",
|
|
784
1066
|
{
|
|
785
1067
|
className: "alt-slider-thumb",
|
|
@@ -800,13 +1082,13 @@ function Slider({ value, defaultValue = 50, onValueChange, min = 0, max = 100, s
|
|
|
800
1082
|
}
|
|
801
1083
|
}
|
|
802
1084
|
},
|
|
803
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-slider-bubble", "aria-hidden": "true" }, format(v))
|
|
804
1086
|
)
|
|
805
1087
|
);
|
|
806
1088
|
}
|
|
807
1089
|
function Progress({ value = null, max = 100, className, ...rest }) {
|
|
808
1090
|
const ind = value === null || value === void 0;
|
|
809
|
-
return /* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ React3.createElement(
|
|
810
1092
|
"div",
|
|
811
1093
|
{
|
|
812
1094
|
role: "progressbar",
|
|
@@ -817,31 +1099,72 @@ function Progress({ value = null, max = 100, className, ...rest }) {
|
|
|
817
1099
|
"data-indeterminate": ind ? "" : void 0,
|
|
818
1100
|
...rest
|
|
819
1101
|
},
|
|
820
|
-
/* @__PURE__ */
|
|
1102
|
+
/* @__PURE__ */ React3.createElement("div", { className: "alt-progress-fill", style: ind ? void 0 : { width: `${Math.max(0, Math.min(100, value / max * 100))}%` } })
|
|
821
1103
|
);
|
|
822
1104
|
}
|
|
823
|
-
function Badge({
|
|
1105
|
+
function Badge({ children, skeleton, ...props }) {
|
|
1106
|
+
const missing = skeleton !== false && children === void 0;
|
|
1107
|
+
useReportWaiting(missing || skeleton !== false && hasPromise(children));
|
|
1108
|
+
const arrival = useArrival(missing);
|
|
1109
|
+
if (!useHasWaited(missing || hasPromise(children))) return /* @__PURE__ */ React3.createElement(BadgeFace, { ...props }, children);
|
|
1110
|
+
const h = hint(skeleton);
|
|
1111
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1112
|
+
Await,
|
|
1113
|
+
{
|
|
1114
|
+
inline: true,
|
|
1115
|
+
shape: "block",
|
|
1116
|
+
enabled: skeleton !== false,
|
|
1117
|
+
imprint: /* @__PURE__ */ React3.createElement("span", { className: "alt-skeleton alt-badge-imprint", "data-variant": props.variant === "count" ? "count" : void 0, style: { width: h.width } })
|
|
1118
|
+
},
|
|
1119
|
+
/* @__PURE__ */ React3.createElement(Arrive, { when: arrival }, /* @__PURE__ */ React3.createElement(BadgeLanded, { ...props }, children))
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
function BadgeLanded({ children, ...props }) {
|
|
1123
|
+
return /* @__PURE__ */ React3.createElement(BadgeFace, { ...props }, readChildren(children));
|
|
1124
|
+
}
|
|
1125
|
+
function BadgeFace({ tone = "neutral", variant = "plate", lamp, dot, className, children, ...rest }) {
|
|
824
1126
|
const v = variant === "soft" ? "tinted" : variant;
|
|
825
1127
|
const showLamp = v !== "count" && !!(lamp ?? (dot || tone === "positive" || tone === "caution" || tone === "critical"));
|
|
826
1128
|
const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
827
|
-
const [stamp, setStamp] =
|
|
828
|
-
const [lit, setLit] =
|
|
829
|
-
const prev =
|
|
830
|
-
|
|
1129
|
+
const [stamp, setStamp] = React3.useState(void 0);
|
|
1130
|
+
const [lit, setLit] = React3.useState(0);
|
|
1131
|
+
const prev = React3.useRef({ tone, label });
|
|
1132
|
+
React3.useEffect(() => {
|
|
831
1133
|
const p = prev.current;
|
|
832
1134
|
if (p.label !== label) setStamp((x) => x === "a" ? "b" : "a");
|
|
833
1135
|
if (p.tone !== tone) setLit((n) => n + 1);
|
|
834
1136
|
prev.current = { tone, label };
|
|
835
1137
|
}, [tone, label]);
|
|
836
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ React3.createElement("span", { className: cx("alt-badge", className), "data-tone": tone, "data-variant": v, "data-stamp": stamp, ...rest }, showLamp && /* @__PURE__ */ React3.createElement("span", { key: lit, className: "alt-badge-lamp", "aria-hidden": "true", "data-lit": lit ? "" : void 0, "data-pulse": lamp === "pulse" ? "" : void 0 }), children);
|
|
837
1139
|
}
|
|
838
1140
|
var TINTS = ["accent", "positive", "caution", "critical"];
|
|
839
|
-
function Avatar({
|
|
1141
|
+
function Avatar({ skeleton, ...props }) {
|
|
1142
|
+
const missing = skeleton !== false && props.name === void 0;
|
|
1143
|
+
const promised = isPromise(props.name) || isPromise(props.src);
|
|
1144
|
+
useReportWaiting(missing || skeleton !== false && isPromise(props.name));
|
|
1145
|
+
const arrival = useArrival(missing);
|
|
1146
|
+
if (!useHasWaited(missing || promised)) return /* @__PURE__ */ React3.createElement(AvatarFace, { ...props, name: props.name ?? "", src: props.src });
|
|
1147
|
+
const size = props.size ?? 36;
|
|
1148
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1149
|
+
Await,
|
|
1150
|
+
{
|
|
1151
|
+
inline: true,
|
|
1152
|
+
shape: "circle",
|
|
1153
|
+
enabled: skeleton !== false,
|
|
1154
|
+
imprint: /* @__PURE__ */ React3.createElement("span", { className: "alt-skeleton alt-avatar-imprint", "data-shape": "circle", style: { width: size, height: size } })
|
|
1155
|
+
},
|
|
1156
|
+
/* @__PURE__ */ React3.createElement(Arrive, { when: arrival }, /* @__PURE__ */ React3.createElement(AvatarLanded, { ...props }))
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
function AvatarLanded(props) {
|
|
1160
|
+
return /* @__PURE__ */ React3.createElement(AvatarFace, { ...props, name: readPromised(props.name) ?? "", src: readPromised(props.src) });
|
|
1161
|
+
}
|
|
1162
|
+
function AvatarFace({ name, src, size = 36, status, live, presence, lamp, className, style, onClick, ...rest }) {
|
|
840
1163
|
const initials = name.split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0].toUpperCase()).join("");
|
|
841
1164
|
const tint = TINTS[[...name].reduce((a, c) => a + c.charCodeAt(0), 0) % TINTS.length];
|
|
842
1165
|
const label = [name, status, live && "live"].filter(Boolean).join(", ");
|
|
843
1166
|
const showLamp = (lamp ?? size >= 24) && (status === "active" || status === "idle");
|
|
844
|
-
return /* @__PURE__ */
|
|
1167
|
+
return /* @__PURE__ */ React3.createElement(
|
|
845
1168
|
"span",
|
|
846
1169
|
{
|
|
847
1170
|
className: cx("alt-avatar", className),
|
|
@@ -864,29 +1187,29 @@ function Avatar({ name, src, size = 36, status, live, presence, lamp, className,
|
|
|
864
1187
|
style: { ["--size"]: size + "px", ...style },
|
|
865
1188
|
...rest
|
|
866
1189
|
},
|
|
867
|
-
/* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
-
showLamp && /* @__PURE__ */
|
|
1190
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-avatar-shadow", "aria-hidden": "true" }),
|
|
1191
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-avatar-face" }, src ? /* @__PURE__ */ React3.createElement("img", { src, alt: "" }) : initials),
|
|
1192
|
+
showLamp && /* @__PURE__ */ React3.createElement("span", { className: "alt-avatar-lamp", "aria-hidden": "true" })
|
|
870
1193
|
);
|
|
871
1194
|
}
|
|
872
1195
|
function AvatarGroup({ className, children, max, style, ...rest }) {
|
|
873
|
-
const all =
|
|
1196
|
+
const all = React3.Children.toArray(children);
|
|
874
1197
|
const shown = max ? all.slice(0, max) : all;
|
|
875
1198
|
const extra = all.length - shown.length;
|
|
876
1199
|
const size = shown[0]?.props?.size || 36;
|
|
877
|
-
return /* @__PURE__ */
|
|
1200
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-avatar-group", className), style: { ["--size"]: size + "px", ...style }, ...rest }, shown, extra > 0 && /* @__PURE__ */ React3.createElement("span", { className: "alt-avatar", "data-tint": "more", role: "img", "aria-label": `${extra} more`, style: { ["--size"]: size + "px" } }, /* @__PURE__ */ React3.createElement("span", { className: "alt-avatar-shadow", "aria-hidden": "true" }), /* @__PURE__ */ React3.createElement("span", { className: "alt-avatar-face" }, "+", extra)));
|
|
878
1201
|
}
|
|
879
|
-
var
|
|
1202
|
+
var LINE_WIDTHS2 = ["100%", "94%", "82%", "97%", "64%"];
|
|
880
1203
|
function Skeleton({ loaded, shape = "block", lines = 3, width, height, radius, className, style, children, ...rest }) {
|
|
881
|
-
const [reveal, setReveal] =
|
|
882
|
-
const was =
|
|
883
|
-
|
|
1204
|
+
const [reveal, setReveal] = React3.useState(null);
|
|
1205
|
+
const was = React3.useRef(loaded);
|
|
1206
|
+
React3.useEffect(() => {
|
|
884
1207
|
if (loaded && !was.current) setReveal(riseDelay());
|
|
885
1208
|
if (!loaded) setReveal(null);
|
|
886
1209
|
was.current = loaded;
|
|
887
1210
|
}, [loaded]);
|
|
888
1211
|
if (loaded) {
|
|
889
|
-
return /* @__PURE__ */
|
|
1212
|
+
return /* @__PURE__ */ React3.createElement(
|
|
890
1213
|
"div",
|
|
891
1214
|
{
|
|
892
1215
|
className: cx("alt-reveal", className),
|
|
@@ -894,14 +1217,14 @@ function Skeleton({ loaded, shape = "block", lines = 3, width, height, radius, c
|
|
|
894
1217
|
style: { ...reveal ? { ["--alt-rise-delay"]: reveal + "ms" } : null, ...style },
|
|
895
1218
|
...rest
|
|
896
1219
|
},
|
|
897
|
-
/* @__PURE__ */
|
|
1220
|
+
/* @__PURE__ */ React3.createElement("div", { className: "alt-reveal-inner" }, children)
|
|
898
1221
|
);
|
|
899
1222
|
}
|
|
900
1223
|
if (shape === "text") {
|
|
901
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-skeleton-lines", className), "aria-hidden": "true", style: { width, ...style }, ...rest }, Array.from({ length: lines }, (_, i) => /* @__PURE__ */ React3.createElement("div", { key: i, className: "alt-skeleton", "data-shape": "text", style: { width: i === lines - 1 && lines > 1 ? "60%" : LINE_WIDTHS2[i % LINE_WIDTHS2.length], height: height ?? 12, ["--i"]: i } })));
|
|
902
1225
|
}
|
|
903
1226
|
const d = shape === "circle" ? width ?? height ?? 40 : void 0;
|
|
904
|
-
return /* @__PURE__ */
|
|
1227
|
+
return /* @__PURE__ */ React3.createElement(
|
|
905
1228
|
"div",
|
|
906
1229
|
{
|
|
907
1230
|
className: cx("alt-skeleton", className),
|
|
@@ -915,13 +1238,13 @@ function Skeleton({ loaded, shape = "block", lines = 3, width, height, radius, c
|
|
|
915
1238
|
var toneIcon = { neutral: Icons.Info, accent: Icons.Info, positive: Icons.CircleCheck, caution: Icons.AlertTriangle, critical: Icons.AlertCircle };
|
|
916
1239
|
function Alert({ tone = "neutral", variant = "flat", title, action, icon: icon2, onDismiss, settle, className, style, children, ...rest }) {
|
|
917
1240
|
const I = toneIcon[tone];
|
|
918
|
-
const [closing, setClosing] =
|
|
1241
|
+
const [closing, setClosing] = React3.useState(false);
|
|
919
1242
|
const { style: depthStyle, ...depth } = useDepth({ settle });
|
|
920
1243
|
const dismiss = () => {
|
|
921
1244
|
setClosing(true);
|
|
922
1245
|
window.setTimeout(() => onDismiss?.(), 400);
|
|
923
1246
|
};
|
|
924
|
-
return /* @__PURE__ */
|
|
1247
|
+
return /* @__PURE__ */ React3.createElement(
|
|
925
1248
|
"div",
|
|
926
1249
|
{
|
|
927
1250
|
role: tone === "critical" ? "alert" : "status",
|
|
@@ -933,16 +1256,16 @@ function Alert({ tone = "neutral", variant = "flat", title, action, icon: icon2,
|
|
|
933
1256
|
style: { ...depthStyle, ...style },
|
|
934
1257
|
...rest
|
|
935
1258
|
},
|
|
936
|
-
/* @__PURE__ */
|
|
1259
|
+
/* @__PURE__ */ React3.createElement("div", { className: "alt-alert-inner" }, /* @__PURE__ */ React3.createElement("span", { className: "alt-alert-icon", "aria-hidden": "true" }, icon2 ?? /* @__PURE__ */ React3.createElement(I, { size: 18 })), /* @__PURE__ */ React3.createElement("div", { className: "alt-alert-body" }, title && /* @__PURE__ */ React3.createElement("p", { className: "alt-alert-title" }, title), children && /* @__PURE__ */ React3.createElement("div", { className: "alt-alert-text" }, children)), action && /* @__PURE__ */ React3.createElement("div", { className: "alt-alert-action" }, action), onDismiss && /* @__PURE__ */ React3.createElement("button", { type: "button", className: "alt-alert-close", "aria-label": "Dismiss", onClick: dismiss }, /* @__PURE__ */ React3.createElement(Icons.X, { size: 14 })))
|
|
937
1260
|
);
|
|
938
1261
|
}
|
|
939
1262
|
function AlertStack({ children, expanded, defaultExpanded = false, onExpandedChange, moreLabel = (n) => `+${n} more`, lessLabel = "Show less", className, ...rest }) {
|
|
940
|
-
const list =
|
|
1263
|
+
const list = React3.Children.toArray(children).filter(React3.isValidElement);
|
|
941
1264
|
const [open, setOpen] = useControllable(expanded, defaultExpanded, onExpandedChange);
|
|
942
1265
|
const topKey = list[0]?.key;
|
|
943
|
-
const prevTop =
|
|
944
|
-
const [risen, setRisen] =
|
|
945
|
-
|
|
1266
|
+
const prevTop = React3.useRef(topKey);
|
|
1267
|
+
const [risen, setRisen] = React3.useState(0);
|
|
1268
|
+
React3.useEffect(() => {
|
|
946
1269
|
if (prevTop.current !== topKey) {
|
|
947
1270
|
prevTop.current = topKey;
|
|
948
1271
|
if (topKey != null) setRisen((r) => r + 1);
|
|
@@ -950,20 +1273,20 @@ function AlertStack({ children, expanded, defaultExpanded = false, onExpandedCha
|
|
|
950
1273
|
}, [topKey]);
|
|
951
1274
|
const hidden = list.length - 1;
|
|
952
1275
|
const all = open || hidden < 1;
|
|
953
|
-
return /* @__PURE__ */
|
|
1276
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-alert-stack", className), "data-expanded": all ? "" : void 0, "data-sheets": all ? void 0 : Math.min(hidden, 2), ...rest }, all ? list.map((el, i) => /* @__PURE__ */ React3.createElement("div", { key: el.key, className: "alt-alert-stack-item", style: { ["--i"]: i } }, el)) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, list.slice(1, 3).map((el, i) => /* @__PURE__ */ React3.createElement("span", { key: el.key, className: "alt-alert-sheet", "aria-hidden": "true", "data-tone": el.props.tone ?? "neutral", style: { ["--i"]: i + 1 } })), /* @__PURE__ */ React3.createElement("div", { key: String(topKey) + risen, className: "alt-alert-stack-top", "data-risen": risen ? "" : void 0 }, list[0])), hidden > 0 && /* @__PURE__ */ React3.createElement("button", { type: "button", className: "alt-alert-more", "aria-expanded": all, onClick: () => setOpen(!open) }, all ? lessLabel : moreLabel(hidden)));
|
|
954
1277
|
}
|
|
955
1278
|
function Accordion({ items, type = "single", defaultValue = [], className, ...rest }) {
|
|
956
|
-
const [open, setOpen] =
|
|
957
|
-
const id =
|
|
1279
|
+
const [open, setOpen] = React3.useState(defaultValue);
|
|
1280
|
+
const id = React3.useId();
|
|
958
1281
|
const toggle = (v) => setOpen((o) => o.includes(v) ? o.filter((x) => x !== v) : type === "single" ? [v] : [...o, v]);
|
|
959
|
-
return /* @__PURE__ */
|
|
1282
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-acc", className), ...rest }, items.map((it) => {
|
|
960
1283
|
const on = open.includes(it.value);
|
|
961
|
-
return /* @__PURE__ */
|
|
1284
|
+
return /* @__PURE__ */ React3.createElement("div", { key: it.value, className: "alt-acc-item", "data-state": on ? "open" : "closed" }, /* @__PURE__ */ React3.createElement("h3", { className: "alt-acc-heading" }, /* @__PURE__ */ React3.createElement("button", { type: "button", className: "alt-acc-trigger", "aria-expanded": on, "aria-controls": `${id}-${it.value}`, onClick: () => toggle(it.value) }, /* @__PURE__ */ React3.createElement("span", null, it.title), /* @__PURE__ */ React3.createElement(Icons.ChevronDown, { className: "alt-acc-chevron", size: 18 }))), /* @__PURE__ */ React3.createElement("div", { className: "alt-acc-panel", id: `${id}-${it.value}`, role: "region", ...on ? {} : inert }, /* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement("div", { className: "alt-acc-content" }, it.content))));
|
|
962
1285
|
}));
|
|
963
1286
|
}
|
|
964
1287
|
function HoldButton({ onConfirm, duration = 1e3, variant = "danger", holdingLabel, doneLabel, repeatable = false, className, children, style, disabled, onClick, ...rest }) {
|
|
965
|
-
const [state, setState] =
|
|
966
|
-
const timer =
|
|
1288
|
+
const [state, setState] = React3.useState("idle");
|
|
1289
|
+
const timer = React3.useRef(void 0);
|
|
967
1290
|
const done = state === "done";
|
|
968
1291
|
const start = () => {
|
|
969
1292
|
if (disabled || state !== "idle") return;
|
|
@@ -980,9 +1303,9 @@ function HoldButton({ onConfirm, duration = 1e3, variant = "danger", holdingLabe
|
|
|
980
1303
|
window.clearTimeout(timer.current);
|
|
981
1304
|
setState("idle");
|
|
982
1305
|
};
|
|
983
|
-
|
|
1306
|
+
React3.useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
984
1307
|
const label = done ? doneLabel ?? children : state === "holding" ? holdingLabel ?? children : children;
|
|
985
|
-
return /* @__PURE__ */
|
|
1308
|
+
return /* @__PURE__ */ React3.createElement(
|
|
986
1309
|
Button,
|
|
987
1310
|
{
|
|
988
1311
|
...rest,
|
|
@@ -1017,16 +1340,16 @@ function HoldButton({ onConfirm, duration = 1e3, variant = "danger", holdingLabe
|
|
|
1017
1340
|
},
|
|
1018
1341
|
onContextMenu: (e) => e.preventDefault()
|
|
1019
1342
|
},
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
/* @__PURE__ */
|
|
1343
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-hold-fill", "aria-hidden": "true" }),
|
|
1344
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-hold-text" }, label),
|
|
1345
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-sr", "aria-live": "polite" }, state === "holding" ? "Keep holding to confirm" : done ? "Confirmed" : "")
|
|
1023
1346
|
);
|
|
1024
1347
|
}
|
|
1025
1348
|
function ScrollArea({ header, maxHeight = 280, className, children, ...rest }) {
|
|
1026
|
-
const body =
|
|
1027
|
-
const inner =
|
|
1028
|
-
const [edges, setEdges] =
|
|
1029
|
-
const update =
|
|
1349
|
+
const body = React3.useRef(null);
|
|
1350
|
+
const inner = React3.useRef(null);
|
|
1351
|
+
const [edges, setEdges] = React3.useState({ top: false, bottom: false });
|
|
1352
|
+
const update = React3.useCallback(() => {
|
|
1030
1353
|
const el = body.current;
|
|
1031
1354
|
if (!el) return;
|
|
1032
1355
|
const top = el.scrollTop > 1, bottom = el.scrollTop + el.clientHeight < el.scrollHeight - 1;
|
|
@@ -1039,15 +1362,15 @@ function ScrollArea({ header, maxHeight = 280, className, children, ...rest }) {
|
|
|
1039
1362
|
if (inner.current) ro.observe(inner.current);
|
|
1040
1363
|
return () => ro.disconnect();
|
|
1041
1364
|
}, [update]);
|
|
1042
|
-
return /* @__PURE__ */
|
|
1365
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-scroll", className), "data-top": edges.top ? "" : void 0, "data-bottom": edges.bottom ? "" : void 0, ...rest }, header && /* @__PURE__ */ React3.createElement("div", { className: "alt-scroll-header" }, header), /* @__PURE__ */ React3.createElement("div", { className: "alt-scroll-body", ref: body, onScroll: update, style: { maxHeight }, tabIndex: 0, "aria-label": rest["aria-label"] }, /* @__PURE__ */ React3.createElement("div", { ref: inner }, children)), /* @__PURE__ */ React3.createElement("span", { className: "alt-scroll-lip", "data-edge": "top", "aria-hidden": "true" }), /* @__PURE__ */ React3.createElement("span", { className: "alt-scroll-lip", "data-edge": "bottom", "aria-hidden": "true" }));
|
|
1043
1366
|
}
|
|
1044
1367
|
function DropZone({ onFiles, accept, multiple = true, state, className, children, ...rest }) {
|
|
1045
|
-
const [armed, setArmed] =
|
|
1046
|
-
const [over, setOver] =
|
|
1047
|
-
const [landed, setLanded] =
|
|
1048
|
-
const input =
|
|
1368
|
+
const [armed, setArmed] = React3.useState(false);
|
|
1369
|
+
const [over, setOver] = React3.useState(false);
|
|
1370
|
+
const [landed, setLanded] = React3.useState(0);
|
|
1371
|
+
const input = React3.useRef(null);
|
|
1049
1372
|
const { style: depthStyle, ...depth } = useDepth({ settle: landed || void 0 });
|
|
1050
|
-
|
|
1373
|
+
React3.useEffect(() => {
|
|
1051
1374
|
let n = 0;
|
|
1052
1375
|
const hasFiles = (e) => Array.from(e.dataTransfer?.types || []).includes("Files");
|
|
1053
1376
|
const enter = (e) => {
|
|
@@ -1085,7 +1408,7 @@ function DropZone({ onFiles, accept, multiple = true, state, className, children
|
|
|
1085
1408
|
setLanded((x) => x + 1);
|
|
1086
1409
|
};
|
|
1087
1410
|
const visual = state ?? (over ? "over" : armed ? "armed" : "idle");
|
|
1088
|
-
return /* @__PURE__ */
|
|
1411
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1089
1412
|
"div",
|
|
1090
1413
|
{
|
|
1091
1414
|
className: cx("alt-drop", className),
|
|
@@ -1114,7 +1437,7 @@ function DropZone({ onFiles, accept, multiple = true, state, className, children
|
|
|
1114
1437
|
},
|
|
1115
1438
|
...rest
|
|
1116
1439
|
},
|
|
1117
|
-
/* @__PURE__ */
|
|
1440
|
+
/* @__PURE__ */ React3.createElement("input", { ref: input, type: "file", hidden: true, accept, multiple, onChange: (e) => take(Array.from(e.target.files || [])) }),
|
|
1118
1441
|
children
|
|
1119
1442
|
);
|
|
1120
1443
|
}
|
|
@@ -1125,12 +1448,12 @@ var move = (arr, from, to) => {
|
|
|
1125
1448
|
return a;
|
|
1126
1449
|
};
|
|
1127
1450
|
function SortableList({ items, getKey, onReorder, renderItem, getLabel = (i) => String(getKey(i)), gap = 8, className, ...rest }) {
|
|
1128
|
-
const nodes =
|
|
1129
|
-
const before =
|
|
1130
|
-
const start =
|
|
1131
|
-
const [drag, setDrag] =
|
|
1132
|
-
const [kb, setKb] =
|
|
1133
|
-
const [msg, setMsg] =
|
|
1451
|
+
const nodes = React3.useRef(/* @__PURE__ */ new Map());
|
|
1452
|
+
const before = React3.useRef(/* @__PURE__ */ new Map());
|
|
1453
|
+
const start = React3.useRef(null);
|
|
1454
|
+
const [drag, setDrag] = React3.useState(null);
|
|
1455
|
+
const [kb, setKb] = React3.useState(null);
|
|
1456
|
+
const [msg, setMsg] = React3.useState("");
|
|
1134
1457
|
const snapshot = () => {
|
|
1135
1458
|
before.current.clear();
|
|
1136
1459
|
nodes.current.forEach((el, k) => before.current.set(k, el.getBoundingClientRect().top));
|
|
@@ -1209,7 +1532,7 @@ function SortableList({ items, getKey, onReorder, renderItem, getLabel = (i) =>
|
|
|
1209
1532
|
const s = start.current;
|
|
1210
1533
|
const h = drag && s ? s.hs[drag.from] + gap : 0;
|
|
1211
1534
|
const slotTop = drag && s ? drag.to <= drag.from ? s.tops[drag.to] : s.tops[drag.to] + s.hs[drag.to] - s.hs[drag.from] : 0;
|
|
1212
|
-
return /* @__PURE__ */
|
|
1535
|
+
return /* @__PURE__ */ React3.createElement("div", { className: cx("alt-sort", className), style: { gap }, role: "list", "aria-label": rest["aria-label"], "data-dragging": drag ? "" : void 0 }, drag && s && /* @__PURE__ */ React3.createElement("div", { className: "alt-sort-slot", "aria-hidden": "true", style: { top: slotTop, height: s.hs[drag.from] } }), items.map((item, i) => {
|
|
1213
1536
|
const key = keys[i];
|
|
1214
1537
|
const held = drag?.key === key || kb === key;
|
|
1215
1538
|
let shift = 0;
|
|
@@ -1218,7 +1541,7 @@ function SortableList({ items, getKey, onReorder, renderItem, getLabel = (i) =>
|
|
|
1218
1541
|
if (drag.to < drag.from && i >= drag.to && i < drag.from) shift = h;
|
|
1219
1542
|
}
|
|
1220
1543
|
const transform = drag?.key === key ? `translateY(${drag.dy}px)` : shift ? `translateY(${shift}px)` : void 0;
|
|
1221
|
-
return /* @__PURE__ */
|
|
1544
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1222
1545
|
"div",
|
|
1223
1546
|
{
|
|
1224
1547
|
key,
|
|
@@ -1240,14 +1563,14 @@ function SortableList({ items, getKey, onReorder, renderItem, getLabel = (i) =>
|
|
|
1240
1563
|
onPointerCancel: onPointerUp,
|
|
1241
1564
|
onKeyDown: (e) => onKeyDown(e, key, i)
|
|
1242
1565
|
},
|
|
1243
|
-
/* @__PURE__ */
|
|
1244
|
-
/* @__PURE__ */
|
|
1566
|
+
/* @__PURE__ */ React3.createElement("span", { className: "alt-sort-grip", "aria-hidden": "true" }, /* @__PURE__ */ React3.createElement("svg", { width: "12", height: "16", viewBox: "0 0 12 16", fill: "currentColor" }, /* @__PURE__ */ React3.createElement("circle", { cx: "3", cy: "3", r: "1.3" }), /* @__PURE__ */ React3.createElement("circle", { cx: "9", cy: "3", r: "1.3" }), /* @__PURE__ */ React3.createElement("circle", { cx: "3", cy: "8", r: "1.3" }), /* @__PURE__ */ React3.createElement("circle", { cx: "9", cy: "8", r: "1.3" }), /* @__PURE__ */ React3.createElement("circle", { cx: "3", cy: "13", r: "1.3" }), /* @__PURE__ */ React3.createElement("circle", { cx: "9", cy: "13", r: "1.3" }))),
|
|
1567
|
+
/* @__PURE__ */ React3.createElement("div", { className: "alt-sort-body" }, renderItem(item, { held }))
|
|
1245
1568
|
);
|
|
1246
|
-
}), /* @__PURE__ */
|
|
1569
|
+
}), /* @__PURE__ */ React3.createElement("span", { className: "alt-sr", "aria-live": "assertive" }, msg));
|
|
1247
1570
|
}
|
|
1248
1571
|
|
|
1249
1572
|
// project/components/src/pile.tsx
|
|
1250
|
-
var
|
|
1573
|
+
var React4 = __toESM(require("react"), 1);
|
|
1251
1574
|
function Pile({
|
|
1252
1575
|
count,
|
|
1253
1576
|
interactive,
|
|
@@ -1269,15 +1592,15 @@ function Pile({
|
|
|
1269
1592
|
const live = interactive || openable;
|
|
1270
1593
|
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
1271
1594
|
const { mounted, state } = usePresence(openable && isOpen, 260);
|
|
1272
|
-
const root =
|
|
1273
|
-
const top =
|
|
1274
|
-
const id =
|
|
1595
|
+
const root = React4.useRef(null);
|
|
1596
|
+
const top = React4.useRef(null);
|
|
1597
|
+
const id = React4.useId();
|
|
1275
1598
|
const toggle = () => {
|
|
1276
1599
|
if (openable) setOpen(!isOpen);
|
|
1277
1600
|
};
|
|
1278
|
-
const close =
|
|
1601
|
+
const close = React4.useCallback(() => setOpen(false), [setOpen]);
|
|
1279
1602
|
useOutside(root, openable && isOpen, close);
|
|
1280
|
-
return /* @__PURE__ */
|
|
1603
|
+
return /* @__PURE__ */ React4.createElement(
|
|
1281
1604
|
"div",
|
|
1282
1605
|
{
|
|
1283
1606
|
ref: root,
|
|
@@ -1286,8 +1609,8 @@ function Pile({
|
|
|
1286
1609
|
"data-open": openable && isOpen ? "" : void 0,
|
|
1287
1610
|
...rest
|
|
1288
1611
|
},
|
|
1289
|
-
Array.from({ length: sheets }, (_, i) => /* @__PURE__ */
|
|
1290
|
-
/* @__PURE__ */
|
|
1612
|
+
Array.from({ length: sheets }, (_, i) => /* @__PURE__ */ React4.createElement("span", { key: i, className: "alt-pile-sheet", "aria-hidden": "true", style: { ["--i"]: i + 1 } })),
|
|
1613
|
+
/* @__PURE__ */ React4.createElement(
|
|
1291
1614
|
"div",
|
|
1292
1615
|
{
|
|
1293
1616
|
ref: top,
|
|
@@ -1306,8 +1629,8 @@ function Pile({
|
|
|
1306
1629
|
},
|
|
1307
1630
|
children
|
|
1308
1631
|
),
|
|
1309
|
-
n > 1 && /* @__PURE__ */
|
|
1310
|
-
openable && mounted && /* @__PURE__ */
|
|
1632
|
+
n > 1 && /* @__PURE__ */ React4.createElement("span", { className: "alt-pile-count", "aria-label": `${n} items` }, n),
|
|
1633
|
+
openable && mounted && /* @__PURE__ */ React4.createElement(
|
|
1311
1634
|
"div",
|
|
1312
1635
|
{
|
|
1313
1636
|
className: "alt-pile-list",
|
|
@@ -1321,23 +1644,23 @@ function Pile({
|
|
|
1321
1644
|
}
|
|
1322
1645
|
}
|
|
1323
1646
|
},
|
|
1324
|
-
/* @__PURE__ */
|
|
1647
|
+
/* @__PURE__ */ React4.createElement("ul", { className: "alt-pile-list-inner", style: { maxHeight } }, items.map((it, i) => /* @__PURE__ */ React4.createElement("li", { key: getKey ? getKey(it, i) : i }, /* @__PURE__ */ React4.createElement("button", { type: "button", className: "alt-pile-item", style: { ["--i"]: Math.min(i, 10) }, onClick: () => onSelect?.(it, i) }, renderItem(it, { index: i })))))
|
|
1325
1648
|
)
|
|
1326
1649
|
);
|
|
1327
1650
|
}
|
|
1328
1651
|
|
|
1329
1652
|
// project/components/src/overlays.tsx
|
|
1330
|
-
var
|
|
1653
|
+
var React5 = __toESM(require("react"), 1);
|
|
1331
1654
|
var EXIT_3 = 160;
|
|
1332
1655
|
var EXIT_4 = 190;
|
|
1333
1656
|
var EXIT_5 = 220;
|
|
1334
1657
|
var lastTipClose = 0;
|
|
1335
1658
|
var openCard = null;
|
|
1336
1659
|
function Tooltip({ content, side = "top", delay = 450, defaultOpen = false, children }) {
|
|
1337
|
-
const [open, setOpen] =
|
|
1338
|
-
const [warm, setWarm] =
|
|
1339
|
-
const timer =
|
|
1340
|
-
const id =
|
|
1660
|
+
const [open, setOpen] = React5.useState(defaultOpen);
|
|
1661
|
+
const [warm, setWarm] = React5.useState(false);
|
|
1662
|
+
const timer = React5.useRef(void 0);
|
|
1663
|
+
const id = React5.useId();
|
|
1341
1664
|
const { mounted, state } = usePresence(open, EXIT_3);
|
|
1342
1665
|
const show = () => {
|
|
1343
1666
|
const isWarm = Date.now() - lastTipClose < 400;
|
|
@@ -1352,8 +1675,8 @@ function Tooltip({ content, side = "top", delay = 450, defaultOpen = false, chil
|
|
|
1352
1675
|
return false;
|
|
1353
1676
|
});
|
|
1354
1677
|
};
|
|
1355
|
-
|
|
1356
|
-
return /* @__PURE__ */
|
|
1678
|
+
React5.useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
1679
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1357
1680
|
"span",
|
|
1358
1681
|
{
|
|
1359
1682
|
className: "alt-tip-anchor",
|
|
@@ -1369,27 +1692,27 @@ function Tooltip({ content, side = "top", delay = 450, defaultOpen = false, chil
|
|
|
1369
1692
|
if (e.key === "Escape") hide();
|
|
1370
1693
|
}
|
|
1371
1694
|
},
|
|
1372
|
-
|
|
1373
|
-
mounted && /* @__PURE__ */
|
|
1695
|
+
React5.cloneElement(children, { "aria-describedby": open ? id : void 0 }),
|
|
1696
|
+
mounted && /* @__PURE__ */ React5.createElement("span", { role: "tooltip", id, className: "alt-tip", "data-side": side, "data-state": state, "data-warm": warm ? "" : void 0 }, content)
|
|
1374
1697
|
);
|
|
1375
1698
|
}
|
|
1376
1699
|
function Popover({ trigger, children, open, defaultOpen = false, onOpenChange, side = "bottom", align = "start", className, ...rest }) {
|
|
1377
1700
|
const [isOpen, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
1378
|
-
const ref =
|
|
1379
|
-
const panel =
|
|
1380
|
-
const id =
|
|
1701
|
+
const ref = React5.useRef(null);
|
|
1702
|
+
const panel = React5.useRef(null);
|
|
1703
|
+
const id = React5.useId();
|
|
1381
1704
|
const { mounted, state } = usePresence(isOpen, EXIT_3);
|
|
1382
|
-
const close =
|
|
1705
|
+
const close = React5.useCallback(() => set(false), [set]);
|
|
1383
1706
|
useOutside(ref, isOpen, close);
|
|
1384
|
-
|
|
1707
|
+
React5.useEffect(() => {
|
|
1385
1708
|
if (state !== "open" || !panel.current) return;
|
|
1386
1709
|
const f = panel.current.querySelector('input, textarea, select, button, [href], [tabindex]:not([tabindex="-1"])');
|
|
1387
1710
|
(f || panel.current).focus({ preventScroll: true });
|
|
1388
1711
|
}, [state]);
|
|
1389
|
-
return /* @__PURE__ */
|
|
1712
|
+
return /* @__PURE__ */ React5.createElement("span", { className: "alt-pop-anchor", ref }, React5.cloneElement(trigger, { "aria-expanded": isOpen, "aria-controls": id, "aria-haspopup": "dialog", onClick: (e) => {
|
|
1390
1713
|
trigger.props.onClick?.(e);
|
|
1391
1714
|
set(!isOpen);
|
|
1392
|
-
} }), mounted && /* @__PURE__ */
|
|
1715
|
+
} }), mounted && /* @__PURE__ */ React5.createElement(
|
|
1393
1716
|
"div",
|
|
1394
1717
|
{
|
|
1395
1718
|
ref: panel,
|
|
@@ -1413,15 +1736,15 @@ function Popover({ trigger, children, open, defaultOpen = false, onOpenChange, s
|
|
|
1413
1736
|
));
|
|
1414
1737
|
}
|
|
1415
1738
|
function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaultOpen = false, className }) {
|
|
1416
|
-
const [open, setOpen] =
|
|
1417
|
-
const [active, setActive] =
|
|
1418
|
-
const [hl, setHl] =
|
|
1419
|
-
const anchor =
|
|
1420
|
-
const menu =
|
|
1421
|
-
const refs =
|
|
1422
|
-
const id =
|
|
1739
|
+
const [open, setOpen] = React5.useState(defaultOpen);
|
|
1740
|
+
const [active, setActive] = React5.useState(-1);
|
|
1741
|
+
const [hl, setHl] = React5.useState(null);
|
|
1742
|
+
const anchor = React5.useRef(null);
|
|
1743
|
+
const menu = React5.useRef(null);
|
|
1744
|
+
const refs = React5.useRef([]);
|
|
1745
|
+
const id = React5.useId();
|
|
1423
1746
|
const { mounted, state } = usePresence(open, EXIT_3);
|
|
1424
|
-
const close =
|
|
1747
|
+
const close = React5.useCallback(() => {
|
|
1425
1748
|
setOpen(false);
|
|
1426
1749
|
setActive(-1);
|
|
1427
1750
|
}, []);
|
|
@@ -1431,7 +1754,7 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1431
1754
|
const el = active >= 0 ? refs.current[active] : null;
|
|
1432
1755
|
setHl(el ? { y: el.offsetTop, h: el.offsetHeight } : null);
|
|
1433
1756
|
}, [active, mounted]);
|
|
1434
|
-
|
|
1757
|
+
React5.useEffect(() => {
|
|
1435
1758
|
if (state === "open") menu.current?.focus({ preventScroll: true });
|
|
1436
1759
|
}, [state]);
|
|
1437
1760
|
const choose = (i) => {
|
|
@@ -1465,7 +1788,7 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1465
1788
|
};
|
|
1466
1789
|
let n = 0;
|
|
1467
1790
|
const activeTone = active >= 0 ? items[active].tone : void 0;
|
|
1468
|
-
return /* @__PURE__ */
|
|
1791
|
+
return /* @__PURE__ */ React5.createElement("span", { className: "alt-pop-anchor", ref: anchor }, React5.cloneElement(trigger, {
|
|
1469
1792
|
"aria-haspopup": "menu",
|
|
1470
1793
|
"aria-expanded": open,
|
|
1471
1794
|
"aria-controls": id,
|
|
@@ -1480,7 +1803,7 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1480
1803
|
setActive(enabled[0]);
|
|
1481
1804
|
}
|
|
1482
1805
|
}
|
|
1483
|
-
}), mounted && /* @__PURE__ */
|
|
1806
|
+
}), mounted && /* @__PURE__ */ React5.createElement(
|
|
1484
1807
|
"div",
|
|
1485
1808
|
{
|
|
1486
1809
|
ref: menu,
|
|
@@ -1496,7 +1819,7 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1496
1819
|
onKeyDown,
|
|
1497
1820
|
onPointerLeave: () => setActive(-1)
|
|
1498
1821
|
},
|
|
1499
|
-
/* @__PURE__ */
|
|
1822
|
+
/* @__PURE__ */ React5.createElement(
|
|
1500
1823
|
"span",
|
|
1501
1824
|
{
|
|
1502
1825
|
className: "alt-menu-hl",
|
|
@@ -1506,10 +1829,10 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1506
1829
|
}
|
|
1507
1830
|
),
|
|
1508
1831
|
items.map((it, i) => {
|
|
1509
|
-
if (it.type === "separator") return /* @__PURE__ */
|
|
1510
|
-
if (it.type === "label") return /* @__PURE__ */
|
|
1832
|
+
if (it.type === "separator") return /* @__PURE__ */ React5.createElement("div", { key: i, className: "alt-menu-sep", role: "separator" });
|
|
1833
|
+
if (it.type === "label") return /* @__PURE__ */ React5.createElement("div", { key: i, className: "alt-menu-label", style: { ["--i"]: n++ } }, it.label);
|
|
1511
1834
|
const item = it;
|
|
1512
|
-
return /* @__PURE__ */
|
|
1835
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1513
1836
|
"div",
|
|
1514
1837
|
{
|
|
1515
1838
|
key: i,
|
|
@@ -1526,9 +1849,9 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1526
1849
|
onPointerMove: () => !item.disabled && active !== i && setActive(i),
|
|
1527
1850
|
onClick: () => choose(i)
|
|
1528
1851
|
},
|
|
1529
|
-
item.icon && /* @__PURE__ */
|
|
1530
|
-
/* @__PURE__ */
|
|
1531
|
-
item.shortcut && /* @__PURE__ */
|
|
1852
|
+
item.icon && /* @__PURE__ */ React5.createElement("span", { className: "alt-menu-icon" }, item.icon),
|
|
1853
|
+
/* @__PURE__ */ React5.createElement("span", { className: "alt-menu-text" }, item.label),
|
|
1854
|
+
item.shortcut && /* @__PURE__ */ React5.createElement("span", { className: "alt-menu-shortcut" }, item.shortcut)
|
|
1532
1855
|
);
|
|
1533
1856
|
})
|
|
1534
1857
|
));
|
|
@@ -1536,10 +1859,10 @@ function DropdownMenu({ trigger, items, align = "start", side = "bottom", defaul
|
|
|
1536
1859
|
function HoverCard({ trigger, children, side = "bottom", align = "start", openDelay = 400, closeDelay = 250, open, defaultOpen = false, onOpenChange, className }) {
|
|
1537
1860
|
const [isOpen, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
1538
1861
|
const { mounted, state } = usePresence(isOpen, EXIT_3);
|
|
1539
|
-
const timer =
|
|
1540
|
-
const closeMe =
|
|
1862
|
+
const timer = React5.useRef(void 0);
|
|
1863
|
+
const closeMe = React5.useRef(() => set(false));
|
|
1541
1864
|
closeMe.current = () => set(false);
|
|
1542
|
-
|
|
1865
|
+
React5.useEffect(() => {
|
|
1543
1866
|
if (!isOpen) return;
|
|
1544
1867
|
const mine = () => closeMe.current();
|
|
1545
1868
|
if (openCard && openCard !== mine) {
|
|
@@ -1563,8 +1886,8 @@ function HoverCard({ trigger, children, side = "bottom", align = "start", openDe
|
|
|
1563
1886
|
if (isOpen) lastTipClose = Date.now();
|
|
1564
1887
|
}, delay);
|
|
1565
1888
|
};
|
|
1566
|
-
|
|
1567
|
-
return /* @__PURE__ */
|
|
1889
|
+
React5.useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
1890
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1568
1891
|
"span",
|
|
1569
1892
|
{
|
|
1570
1893
|
className: "alt-pop-anchor alt-hovercard-anchor",
|
|
@@ -1588,7 +1911,7 @@ function HoverCard({ trigger, children, side = "bottom", align = "start", openDe
|
|
|
1588
1911
|
}
|
|
1589
1912
|
},
|
|
1590
1913
|
trigger,
|
|
1591
|
-
mounted && /* @__PURE__ */
|
|
1914
|
+
mounted && /* @__PURE__ */ React5.createElement(
|
|
1592
1915
|
"div",
|
|
1593
1916
|
{
|
|
1594
1917
|
className: cx("alt-pop alt-hovercard", className),
|
|
@@ -1603,6 +1926,7 @@ function HoverCard({ trigger, children, side = "bottom", align = "start", openDe
|
|
|
1603
1926
|
}
|
|
1604
1927
|
var summits = 0;
|
|
1605
1928
|
var summitTaken = () => summits > 0;
|
|
1929
|
+
var MODAL_FOCUS = "[data-autofocus], input, textarea, select";
|
|
1606
1930
|
function useModal({
|
|
1607
1931
|
open,
|
|
1608
1932
|
onDismiss,
|
|
@@ -1612,12 +1936,13 @@ function useModal({
|
|
|
1612
1936
|
dismissible = true,
|
|
1613
1937
|
summit = false,
|
|
1614
1938
|
autoFocus = true,
|
|
1615
|
-
focusSelector =
|
|
1939
|
+
focusSelector = MODAL_FOCUS,
|
|
1940
|
+
restoreFocus = autoFocus
|
|
1616
1941
|
}) {
|
|
1617
1942
|
const ctx = useAltitude();
|
|
1618
|
-
const restore =
|
|
1943
|
+
const restore = React5.useRef(null);
|
|
1619
1944
|
const presence = usePresence(open, exitMs);
|
|
1620
|
-
|
|
1945
|
+
React5.useEffect(() => {
|
|
1621
1946
|
if (!open) return;
|
|
1622
1947
|
restore.current = document.activeElement;
|
|
1623
1948
|
const pop = modal ? ctx?.pushLayer() : void 0;
|
|
@@ -1628,10 +1953,10 @@ function useModal({
|
|
|
1628
1953
|
pop?.();
|
|
1629
1954
|
if (modal) document.body.style.overflow = prev;
|
|
1630
1955
|
if (summit) summits--;
|
|
1631
|
-
if (
|
|
1956
|
+
if (restoreFocus) restore.current?.focus?.({ preventScroll: true });
|
|
1632
1957
|
};
|
|
1633
1958
|
}, [open]);
|
|
1634
|
-
|
|
1959
|
+
React5.useEffect(() => {
|
|
1635
1960
|
if (presence.state !== "open" || !autoFocus) return;
|
|
1636
1961
|
let raf = 0;
|
|
1637
1962
|
const tryFocus = () => {
|
|
@@ -1664,15 +1989,39 @@ function useModal({
|
|
|
1664
1989
|
};
|
|
1665
1990
|
return { ...presence, onKeyDown };
|
|
1666
1991
|
}
|
|
1667
|
-
function Dialog({
|
|
1992
|
+
function Dialog({
|
|
1993
|
+
open,
|
|
1994
|
+
defaultOpen = false,
|
|
1995
|
+
onOpenChange,
|
|
1996
|
+
trigger,
|
|
1997
|
+
title,
|
|
1998
|
+
description,
|
|
1999
|
+
children,
|
|
2000
|
+
footer,
|
|
2001
|
+
size = "md",
|
|
2002
|
+
dismissible = true,
|
|
2003
|
+
initialFocus = "first-field",
|
|
2004
|
+
focusSelector = MODAL_FOCUS,
|
|
2005
|
+
className
|
|
2006
|
+
}) {
|
|
1668
2007
|
const [isOpen, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
1669
|
-
const panel =
|
|
1670
|
-
const id =
|
|
1671
|
-
const { mounted, state, onKeyDown } = useModal({
|
|
1672
|
-
|
|
2008
|
+
const panel = React5.useRef(null);
|
|
2009
|
+
const id = React5.useId();
|
|
2010
|
+
const { mounted, state, onKeyDown } = useModal({
|
|
2011
|
+
open: isOpen,
|
|
2012
|
+
onDismiss: () => set(false),
|
|
2013
|
+
exitMs: EXIT_5,
|
|
2014
|
+
panel,
|
|
2015
|
+
dismissible,
|
|
2016
|
+
summit: true,
|
|
2017
|
+
autoFocus: initialFocus !== false,
|
|
2018
|
+
focusSelector: initialFocus === "title" ? ".alt-dialog-title" : focusSelector,
|
|
2019
|
+
restoreFocus: true
|
|
2020
|
+
});
|
|
2021
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, trigger && React5.cloneElement(trigger, { "aria-haspopup": "dialog", onClick: (e) => {
|
|
1673
2022
|
trigger.props.onClick?.(e);
|
|
1674
2023
|
set(true);
|
|
1675
|
-
} }), mounted && /* @__PURE__ */
|
|
2024
|
+
} }), mounted && /* @__PURE__ */ React5.createElement(Layer, null, /* @__PURE__ */ React5.createElement("div", { className: "alt-dialog-root", "data-state": state, onKeyDown }, /* @__PURE__ */ React5.createElement("div", { className: "alt-scrim", onClick: () => dismissible && set(false) }), /* @__PURE__ */ React5.createElement(
|
|
1676
2025
|
"div",
|
|
1677
2026
|
{
|
|
1678
2027
|
ref: panel,
|
|
@@ -1684,10 +2033,10 @@ function Dialog({ open, defaultOpen = false, onOpenChange, trigger, title, descr
|
|
|
1684
2033
|
className: cx("alt-dialog", className),
|
|
1685
2034
|
"data-size": size
|
|
1686
2035
|
},
|
|
1687
|
-
/* @__PURE__ */
|
|
1688
|
-
children && /* @__PURE__ */
|
|
1689
|
-
footer && /* @__PURE__ */
|
|
1690
|
-
dismissible && /* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ React5.createElement("div", { className: "alt-dialog-head" }, /* @__PURE__ */ React5.createElement("h2", { className: "alt-dialog-title", id: `${id}-t`, tabIndex: initialFocus === "title" ? -1 : void 0 }, title), description && /* @__PURE__ */ React5.createElement("p", { className: "alt-dialog-desc", id: `${id}-d` }, description)),
|
|
2037
|
+
children && /* @__PURE__ */ React5.createElement("div", { className: "alt-dialog-body" }, children),
|
|
2038
|
+
footer && /* @__PURE__ */ React5.createElement("div", { className: "alt-dialog-footer" }, footer),
|
|
2039
|
+
dismissible && /* @__PURE__ */ React5.createElement(Button, { variant: "ghost", size: "sm", square: true, "aria-label": "Close", className: "alt-dialog-close", onClick: () => set(false) }, /* @__PURE__ */ React5.createElement(Icons.X, null))
|
|
1691
2040
|
))));
|
|
1692
2041
|
}
|
|
1693
2042
|
var toasts = [];
|
|
@@ -1717,16 +2066,16 @@ var toastIcon = { neutral: Icons.Info, positive: Icons.CircleCheck, caution: Ico
|
|
|
1717
2066
|
var STACK = 3;
|
|
1718
2067
|
var GAP = 8;
|
|
1719
2068
|
function Toaster({ className }) {
|
|
1720
|
-
const [, force] =
|
|
1721
|
-
const [expanded, setExpanded] =
|
|
1722
|
-
const heights =
|
|
1723
|
-
|
|
2069
|
+
const [, force] = React5.useReducer((n) => n + 1, 0);
|
|
2070
|
+
const [expanded, setExpanded] = React5.useState(false);
|
|
2071
|
+
const heights = React5.useRef(/* @__PURE__ */ new Map());
|
|
2072
|
+
React5.useEffect(() => {
|
|
1724
2073
|
subs.add(force);
|
|
1725
2074
|
return () => {
|
|
1726
2075
|
subs.delete(force);
|
|
1727
2076
|
};
|
|
1728
2077
|
}, []);
|
|
1729
|
-
|
|
2078
|
+
React5.useEffect(() => {
|
|
1730
2079
|
if (expanded) return;
|
|
1731
2080
|
const timers = toasts.filter((t) => !t.leaving && t.duration > 0).map((t) => setTimeout(() => toast.dismiss(t.id), t.duration));
|
|
1732
2081
|
return () => timers.forEach(clearTimeout);
|
|
@@ -1735,7 +2084,7 @@ function Toaster({ className }) {
|
|
|
1735
2084
|
const frontH = live[0] ? heights.current.get(live[0].id) || 64 : 64;
|
|
1736
2085
|
let offset = 0;
|
|
1737
2086
|
const total = live.slice(0, 5).reduce((a, t) => a + (heights.current.get(t.id) || 64) + GAP, 0);
|
|
1738
|
-
return /* @__PURE__ */
|
|
2087
|
+
return /* @__PURE__ */ React5.createElement(Layer, null, /* @__PURE__ */ React5.createElement(
|
|
1739
2088
|
"section",
|
|
1740
2089
|
{
|
|
1741
2090
|
"aria-label": "Notifications",
|
|
@@ -1777,7 +2126,7 @@ function Toaster({ className }) {
|
|
|
1777
2126
|
}
|
|
1778
2127
|
if (!t.leaving && i >= 0) offset += h + GAP;
|
|
1779
2128
|
const I = toastIcon[t.tone || "neutral"];
|
|
1780
|
-
return /* @__PURE__ */
|
|
2129
|
+
return /* @__PURE__ */ React5.createElement(
|
|
1781
2130
|
"div",
|
|
1782
2131
|
{
|
|
1783
2132
|
key: t.id,
|
|
@@ -1795,28 +2144,28 @@ function Toaster({ className }) {
|
|
|
1795
2144
|
},
|
|
1796
2145
|
style: { transform: `translateY(${y}) scale(${s})`, opacity: o, boxShadow: sh, zIndex: 100 - Math.max(i, 0), height: behind ? frontH : void 0, pointerEvents: o ? void 0 : "none" }
|
|
1797
2146
|
},
|
|
1798
|
-
/* @__PURE__ */
|
|
1799
|
-
/* @__PURE__ */
|
|
1800
|
-
t.action && /* @__PURE__ */
|
|
2147
|
+
/* @__PURE__ */ React5.createElement("span", { className: "alt-toast-icon" }, /* @__PURE__ */ React5.createElement(I, { size: 18 })),
|
|
2148
|
+
/* @__PURE__ */ React5.createElement("div", { className: "alt-toast-body" }, /* @__PURE__ */ React5.createElement("p", { className: "alt-toast-title" }, t.title), t.description && /* @__PURE__ */ React5.createElement("p", { className: "alt-toast-desc" }, t.description)),
|
|
2149
|
+
t.action && /* @__PURE__ */ React5.createElement(Button, { size: "sm", variant: "secondary", className: "alt-toast-action", onClick: () => {
|
|
1801
2150
|
t.action.onClick();
|
|
1802
2151
|
toast.dismiss(t.id);
|
|
1803
2152
|
} }, t.action.label),
|
|
1804
|
-
/* @__PURE__ */
|
|
2153
|
+
/* @__PURE__ */ React5.createElement("button", { type: "button", className: "alt-toast-close", "aria-label": "Dismiss", onClick: () => toast.dismiss(t.id) }, /* @__PURE__ */ React5.createElement(Icons.X, { size: 14 }))
|
|
1805
2154
|
);
|
|
1806
2155
|
})
|
|
1807
2156
|
));
|
|
1808
2157
|
}
|
|
1809
2158
|
|
|
1810
2159
|
// project/components/src/nav.tsx
|
|
1811
|
-
var
|
|
2160
|
+
var React6 = __toESM(require("react"), 1);
|
|
1812
2161
|
function Drilldown({ root, className, ...rest }) {
|
|
1813
|
-
const [path, setPath] =
|
|
1814
|
-
const [dir, setDir] =
|
|
1815
|
-
const [out, setOut] =
|
|
1816
|
-
const view =
|
|
2162
|
+
const [path, setPath] = React6.useState([root]);
|
|
2163
|
+
const [dir, setDir] = React6.useState("down");
|
|
2164
|
+
const [out, setOut] = React6.useState(null);
|
|
2165
|
+
const view = React6.useRef(null);
|
|
1817
2166
|
const depth = path.length - 1;
|
|
1818
2167
|
const current = path[depth];
|
|
1819
|
-
|
|
2168
|
+
React6.useEffect(() => {
|
|
1820
2169
|
if (!out) return;
|
|
1821
2170
|
const t = setTimeout(() => setOut(null), 220);
|
|
1822
2171
|
return () => clearTimeout(t);
|
|
@@ -1832,18 +2181,18 @@ function Drilldown({ root, className, ...rest }) {
|
|
|
1832
2181
|
setOut(current);
|
|
1833
2182
|
setPath(path.slice(0, i + 1));
|
|
1834
2183
|
};
|
|
1835
|
-
|
|
2184
|
+
React6.useEffect(() => {
|
|
1836
2185
|
view.current?.focus({ preventScroll: true });
|
|
1837
2186
|
}, [current.id]);
|
|
1838
|
-
const render = (node) => node.children?.length ? /* @__PURE__ */
|
|
2187
|
+
const render = (node) => node.children?.length ? /* @__PURE__ */ React6.createElement("ul", { className: "alt-drill-list" }, node.children.map((c) => /* @__PURE__ */ React6.createElement("li", { key: c.id }, /* @__PURE__ */ React6.createElement("button", { type: "button", className: "alt-drill-row", onClick: () => go(c) }, /* @__PURE__ */ React6.createElement("span", { className: "alt-drill-row-text" }, /* @__PURE__ */ React6.createElement("span", { className: "alt-drill-row-title" }, c.title), c.description && /* @__PURE__ */ React6.createElement("span", { className: "alt-drill-row-desc" }, c.description)), c.children?.length ? /* @__PURE__ */ React6.createElement("span", { className: "alt-drill-count" }, c.children.length) : null, /* @__PURE__ */ React6.createElement(Icons.ChevronDown, { className: "alt-drill-chev", size: 16 }))))) : /* @__PURE__ */ React6.createElement("div", { className: "alt-drill-leaf" }, node.content);
|
|
1839
2188
|
const sheets = Math.min(depth, 3);
|
|
1840
|
-
return /* @__PURE__ */
|
|
2189
|
+
return /* @__PURE__ */ React6.createElement("div", { className: cx("alt-drill", className), "data-dir": dir, ...rest }, /* @__PURE__ */ React6.createElement("nav", { className: "alt-crumbs", "aria-label": "Location" }, /* @__PURE__ */ React6.createElement("ol", null, path.map((n, i) => /* @__PURE__ */ React6.createElement("li", { key: n.id, "data-d": Math.min(i, 3), style: { ["--d"]: i, zIndex: i + 1 }, "data-current": i === depth ? "" : void 0, "data-new": i === depth && dir === "down" && i > 0 ? "" : void 0 }, /* @__PURE__ */ React6.createElement("button", { type: "button", onClick: () => back(i), "aria-current": i === depth ? "location" : void 0 }, n.title))))), /* @__PURE__ */ React6.createElement("div", { className: "alt-pile alt-drill-pile", "data-sheets": sheets }, Array.from({ length: sheets }, (_, i) => /* @__PURE__ */ React6.createElement("span", { key: i, className: "alt-pile-sheet", "aria-hidden": "true", style: { ["--i"]: i + 1 } })), /* @__PURE__ */ React6.createElement("div", { className: "alt-pile-top alt-drill-stage" }, out && /* @__PURE__ */ React6.createElement("div", { key: "out-" + out.id, className: "alt-drill-view", "data-phase": "out", "aria-hidden": "true" }, render(out)), /* @__PURE__ */ React6.createElement("div", { key: current.id, ref: view, tabIndex: -1, className: "alt-drill-view", "data-phase": "in", "aria-label": typeof current.title === "string" ? current.title : void 0 }, render(current)))));
|
|
1841
2190
|
}
|
|
1842
2191
|
|
|
1843
2192
|
// project/components/src/sheet.tsx
|
|
1844
|
-
var
|
|
2193
|
+
var React7 = __toESM(require("react"), 1);
|
|
1845
2194
|
var EXIT_42 = 190;
|
|
1846
|
-
var SheetCtx =
|
|
2195
|
+
var SheetCtx = React7.createContext(null);
|
|
1847
2196
|
function Sheet({
|
|
1848
2197
|
open,
|
|
1849
2198
|
defaultOpen = false,
|
|
@@ -1859,28 +2208,28 @@ function Sheet({
|
|
|
1859
2208
|
...rest
|
|
1860
2209
|
}) {
|
|
1861
2210
|
const [isOpen, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
1862
|
-
const panel =
|
|
1863
|
-
const scroller =
|
|
1864
|
-
const inner =
|
|
1865
|
-
const id =
|
|
1866
|
-
const [titled, setTitled] =
|
|
1867
|
-
const [described, setDescribed] =
|
|
1868
|
-
const [edges, setEdges] =
|
|
1869
|
-
const [drag, setDrag] =
|
|
1870
|
-
const pull =
|
|
1871
|
-
const [panelEl, setPanelEl] =
|
|
1872
|
-
const panelRef =
|
|
2211
|
+
const panel = React7.useRef(null);
|
|
2212
|
+
const scroller = React7.useRef(null);
|
|
2213
|
+
const inner = React7.useRef(null);
|
|
2214
|
+
const id = React7.useId();
|
|
2215
|
+
const [titled, setTitled] = React7.useState(false);
|
|
2216
|
+
const [described, setDescribed] = React7.useState(false);
|
|
2217
|
+
const [edges, setEdges] = React7.useState({ top: false, bottom: false });
|
|
2218
|
+
const [drag, setDrag] = React7.useState(null);
|
|
2219
|
+
const pull = React7.useRef(null);
|
|
2220
|
+
const [panelEl, setPanelEl] = React7.useState(null);
|
|
2221
|
+
const panelRef = React7.useCallback((el) => {
|
|
1873
2222
|
panel.current = el;
|
|
1874
2223
|
setPanelEl(el);
|
|
1875
2224
|
}, []);
|
|
1876
|
-
const underSummit =
|
|
1877
|
-
const close =
|
|
2225
|
+
const underSummit = React7.useMemo(() => isOpen && summitTaken(), [isOpen]);
|
|
2226
|
+
const close = React7.useCallback(() => set(false), [set]);
|
|
1878
2227
|
const { mounted, state, onKeyDown } = useModal({ open: isOpen, onDismiss: close, exitMs: EXIT_42, panel, modal, dismissible, autoFocus: !underSummit });
|
|
1879
2228
|
useApproach(side === "bottom" && dismissible);
|
|
1880
|
-
|
|
2229
|
+
React7.useEffect(() => {
|
|
1881
2230
|
if (isOpen) setDrag(null);
|
|
1882
2231
|
}, [isOpen]);
|
|
1883
|
-
const measure =
|
|
2232
|
+
const measure = React7.useCallback(() => {
|
|
1884
2233
|
const el = scroller.current;
|
|
1885
2234
|
if (!el) return;
|
|
1886
2235
|
const top = el.scrollTop > 1, bottom = el.scrollTop + el.clientHeight < el.scrollHeight - 1;
|
|
@@ -1916,17 +2265,17 @@ function Sheet({
|
|
|
1916
2265
|
close();
|
|
1917
2266
|
} else setDrag(null);
|
|
1918
2267
|
};
|
|
1919
|
-
const ctx =
|
|
2268
|
+
const ctx = React7.useMemo(() => ({ titleId: `${id}-t`, descId: `${id}-d`, setTitled, setDescribed }), [id]);
|
|
1920
2269
|
const dragging = !!drag && !drag.leaving && !!pull.current;
|
|
1921
2270
|
const dragStyle = drag ? drag.leaving ? { transform: `translateY(${drag.dy + 24}px)` } : { transform: `translateY(${drag.dy}px)`, transition: dragging ? "none" : void 0 } : void 0;
|
|
1922
|
-
return /* @__PURE__ */
|
|
2271
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, trigger && React7.cloneElement(trigger, {
|
|
1923
2272
|
"aria-haspopup": "dialog",
|
|
1924
2273
|
"aria-expanded": isOpen,
|
|
1925
2274
|
onClick: (e) => {
|
|
1926
2275
|
trigger.props.onClick?.(e);
|
|
1927
2276
|
set(modal ? true : !isOpen);
|
|
1928
2277
|
}
|
|
1929
|
-
}), mounted && /* @__PURE__ */
|
|
2278
|
+
}), mounted && /* @__PURE__ */ React7.createElement(Layer, null, /* @__PURE__ */ React7.createElement(SheetCtx.Provider, { value: ctx }, /* @__PURE__ */ React7.createElement("div", { className: "alt-sheet-root", "data-state": state, "data-exit": !isOpen ? "" : void 0, "data-modal": modal ? "" : void 0, onKeyDown }, modal && /* @__PURE__ */ React7.createElement("div", { className: "alt-scrim", onClick: () => dismissible && close() }), /* @__PURE__ */ React7.createElement(
|
|
1930
2279
|
"div",
|
|
1931
2280
|
{
|
|
1932
2281
|
ref: panelRef,
|
|
@@ -1944,7 +2293,7 @@ function Sheet({
|
|
|
1944
2293
|
style: { ...style, ...dragStyle },
|
|
1945
2294
|
...rest
|
|
1946
2295
|
},
|
|
1947
|
-
side === "bottom" && dismissible && /* @__PURE__ */
|
|
2296
|
+
side === "bottom" && dismissible && /* @__PURE__ */ React7.createElement(
|
|
1948
2297
|
"span",
|
|
1949
2298
|
{
|
|
1950
2299
|
className: "alt-sheet-pull",
|
|
@@ -1956,35 +2305,35 @@ function Sheet({
|
|
|
1956
2305
|
onPointerCancel: onPullUp
|
|
1957
2306
|
}
|
|
1958
2307
|
),
|
|
1959
|
-
/* @__PURE__ */
|
|
1960
|
-
dismissible && /* @__PURE__ */
|
|
2308
|
+
/* @__PURE__ */ React7.createElement("div", { className: "alt-sheet-scroll", ref: scroller, onScroll: measure }, /* @__PURE__ */ React7.createElement("div", { className: "alt-sheet-inner", ref: inner }, children)),
|
|
2309
|
+
dismissible && /* @__PURE__ */ React7.createElement(Button, { variant: "ghost", size: "sm", square: true, "aria-label": "Close", className: "alt-sheet-close", onClick: close }, /* @__PURE__ */ React7.createElement(Icons.X, null))
|
|
1961
2310
|
)))));
|
|
1962
2311
|
}
|
|
1963
2312
|
function SheetHeader({ className, ...p }) {
|
|
1964
|
-
return /* @__PURE__ */
|
|
2313
|
+
return /* @__PURE__ */ React7.createElement("div", { className: cx("alt-sheet-header", className), ...p });
|
|
1965
2314
|
}
|
|
1966
2315
|
function SheetTitle({ className, ...p }) {
|
|
1967
|
-
const c =
|
|
1968
|
-
|
|
2316
|
+
const c = React7.useContext(SheetCtx);
|
|
2317
|
+
React7.useEffect(() => {
|
|
1969
2318
|
c?.setTitled(true);
|
|
1970
2319
|
return () => c?.setTitled(false);
|
|
1971
2320
|
}, [c]);
|
|
1972
|
-
return /* @__PURE__ */
|
|
2321
|
+
return /* @__PURE__ */ React7.createElement("h2", { id: c?.titleId, className: cx("alt-sheet-title", className), ...p });
|
|
1973
2322
|
}
|
|
1974
2323
|
function SheetDescription({ className, ...p }) {
|
|
1975
|
-
const c =
|
|
1976
|
-
|
|
2324
|
+
const c = React7.useContext(SheetCtx);
|
|
2325
|
+
React7.useEffect(() => {
|
|
1977
2326
|
c?.setDescribed(true);
|
|
1978
2327
|
return () => c?.setDescribed(false);
|
|
1979
2328
|
}, [c]);
|
|
1980
|
-
return /* @__PURE__ */
|
|
2329
|
+
return /* @__PURE__ */ React7.createElement("p", { id: c?.descId, className: cx("alt-sheet-desc", className), ...p });
|
|
1981
2330
|
}
|
|
1982
2331
|
function SheetFooter({ className, ...p }) {
|
|
1983
|
-
return /* @__PURE__ */
|
|
2332
|
+
return /* @__PURE__ */ React7.createElement("div", { className: cx("alt-sheet-footer", className), ...p });
|
|
1984
2333
|
}
|
|
1985
2334
|
|
|
1986
2335
|
// project/components/src/command.tsx
|
|
1987
|
-
var
|
|
2336
|
+
var React8 = __toESM(require("react"), 1);
|
|
1988
2337
|
var EXIT_52 = 220;
|
|
1989
2338
|
function commandScore(text, query) {
|
|
1990
2339
|
const t = text.toLowerCase(), q = query.toLowerCase().trim();
|
|
@@ -2035,18 +2384,18 @@ function matchRanges(label, query) {
|
|
|
2035
2384
|
return out;
|
|
2036
2385
|
}
|
|
2037
2386
|
function Marked({ text, ranges }) {
|
|
2038
|
-
if (!ranges.length) return /* @__PURE__ */
|
|
2387
|
+
if (!ranges.length) return /* @__PURE__ */ React8.createElement(React8.Fragment, null, text);
|
|
2039
2388
|
const parts = [];
|
|
2040
2389
|
let i = 0;
|
|
2041
2390
|
ranges.forEach(([a, b], k) => {
|
|
2042
2391
|
if (a > i) parts.push(text.slice(i, a));
|
|
2043
|
-
parts.push(/* @__PURE__ */
|
|
2392
|
+
parts.push(/* @__PURE__ */ React8.createElement("mark", { key: k, className: "alt-cmd-match" }, text.slice(a, b)));
|
|
2044
2393
|
i = b;
|
|
2045
2394
|
});
|
|
2046
2395
|
if (i < text.length) parts.push(text.slice(i));
|
|
2047
|
-
return /* @__PURE__ */
|
|
2396
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, parts);
|
|
2048
2397
|
}
|
|
2049
|
-
var SearchIcon = () => /* @__PURE__ */
|
|
2398
|
+
var SearchIcon = () => /* @__PURE__ */ React8.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", "aria-hidden": "true" }, /* @__PURE__ */ React8.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ React8.createElement("path", { d: "M20 20l-3.5-3.5" }));
|
|
2050
2399
|
var ms = (cs, name, fallback) => parseFloat(cs.getPropertyValue(name)) || fallback;
|
|
2051
2400
|
function CommandPalette({
|
|
2052
2401
|
items,
|
|
@@ -2058,6 +2407,8 @@ function CommandPalette({
|
|
|
2058
2407
|
filter,
|
|
2059
2408
|
empty,
|
|
2060
2409
|
shortcut = "k",
|
|
2410
|
+
query: queryProp,
|
|
2411
|
+
defaultQuery = "",
|
|
2061
2412
|
onQueryChange,
|
|
2062
2413
|
closeOnSelect = true,
|
|
2063
2414
|
hints = true,
|
|
@@ -2065,26 +2416,30 @@ function CommandPalette({
|
|
|
2065
2416
|
...rest
|
|
2066
2417
|
}) {
|
|
2067
2418
|
const [isOpen, set] = useControllable(open, defaultOpen, onOpenChange);
|
|
2068
|
-
const [
|
|
2069
|
-
const
|
|
2070
|
-
const [
|
|
2071
|
-
const [
|
|
2072
|
-
const
|
|
2073
|
-
const
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2076
|
-
const
|
|
2077
|
-
const
|
|
2078
|
-
const
|
|
2079
|
-
const
|
|
2080
|
-
const
|
|
2419
|
+
const [innerQuery, setInnerQuery] = React8.useState(defaultQuery);
|
|
2420
|
+
const query = queryProp ?? innerQuery;
|
|
2421
|
+
const [active, setActive] = React8.useState(0);
|
|
2422
|
+
const [onset, setOnset] = React8.useState(true);
|
|
2423
|
+
const [said, setSaid] = React8.useState("");
|
|
2424
|
+
const panel = React8.useRef(null);
|
|
2425
|
+
const viewport = React8.useRef(null);
|
|
2426
|
+
const list = React8.useRef(null);
|
|
2427
|
+
const sizer = React8.useRef(null);
|
|
2428
|
+
const rowEls = React8.useRef(/* @__PURE__ */ new Map());
|
|
2429
|
+
const prevTops = React8.useRef(null);
|
|
2430
|
+
const byKeyboard = React8.useRef(false);
|
|
2431
|
+
const caretPlaced = React8.useRef(false);
|
|
2432
|
+
const seed = React8.useRef(defaultQuery);
|
|
2433
|
+
seed.current = defaultQuery;
|
|
2434
|
+
const [panelEl, setPanelEl] = React8.useState(null);
|
|
2435
|
+
const panelRef = React8.useCallback((el) => {
|
|
2081
2436
|
panel.current = el;
|
|
2082
2437
|
setPanelEl(el);
|
|
2083
2438
|
}, []);
|
|
2084
|
-
const id =
|
|
2085
|
-
const close =
|
|
2439
|
+
const id = React8.useId();
|
|
2440
|
+
const close = React8.useCallback(() => set(false), [set]);
|
|
2086
2441
|
const { mounted, state, onKeyDown } = useModal({ open: isOpen, onDismiss: close, exitMs: EXIT_52, panel, summit: true });
|
|
2087
|
-
|
|
2442
|
+
React8.useEffect(() => {
|
|
2088
2443
|
if (!shortcut) return;
|
|
2089
2444
|
const key = shortcut.toLowerCase();
|
|
2090
2445
|
const on = (e) => {
|
|
@@ -2100,13 +2455,17 @@ function CommandPalette({
|
|
|
2100
2455
|
window.addEventListener("keydown", on);
|
|
2101
2456
|
return () => window.removeEventListener("keydown", on);
|
|
2102
2457
|
}, [shortcut, isOpen, set]);
|
|
2103
|
-
|
|
2458
|
+
React8.useEffect(() => {
|
|
2104
2459
|
if (isOpen) {
|
|
2105
|
-
|
|
2460
|
+
setInnerQuery(seed.current);
|
|
2106
2461
|
setActive(0);
|
|
2107
2462
|
setOnset(true);
|
|
2463
|
+
caretPlaced.current = false;
|
|
2108
2464
|
}
|
|
2109
2465
|
}, [isOpen]);
|
|
2466
|
+
React8.useEffect(() => {
|
|
2467
|
+
setActive(0);
|
|
2468
|
+
}, [query]);
|
|
2110
2469
|
const q = query.trim();
|
|
2111
2470
|
const score = filter ?? itemScore;
|
|
2112
2471
|
const view = items.map((g, gi) => {
|
|
@@ -2170,14 +2529,14 @@ function CommandPalette({
|
|
|
2170
2529
|
ro.disconnect();
|
|
2171
2530
|
};
|
|
2172
2531
|
}, [panelEl]);
|
|
2173
|
-
const [hl, setHl] =
|
|
2532
|
+
const [hl, setHl] = React8.useState(null);
|
|
2174
2533
|
useIsoLayoutEffect(() => {
|
|
2175
2534
|
const el = activeRow ? rowEls.current.get(activeRow.key) : null;
|
|
2176
2535
|
setHl(el ? { y: el.offsetTop, h: el.offsetHeight } : null);
|
|
2177
2536
|
if (el && byKeyboard.current) el.scrollIntoView({ block: "nearest" });
|
|
2178
2537
|
byKeyboard.current = false;
|
|
2179
2538
|
}, [activeRow?.key, rowsKey, panelEl]);
|
|
2180
|
-
|
|
2539
|
+
React8.useEffect(() => {
|
|
2181
2540
|
if (!q) {
|
|
2182
2541
|
setSaid("");
|
|
2183
2542
|
return;
|
|
@@ -2207,7 +2566,7 @@ function CommandPalette({
|
|
|
2207
2566
|
const label = rest["aria-label"] ?? "Command palette";
|
|
2208
2567
|
const activeIndex = activeRow ? flat.indexOf(activeRow) : -1;
|
|
2209
2568
|
let n = 0;
|
|
2210
|
-
return /* @__PURE__ */
|
|
2569
|
+
return /* @__PURE__ */ React8.createElement(Layer, null, /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-root", "data-state": state, onKeyDown }, /* @__PURE__ */ React8.createElement("div", { className: "alt-scrim", onClick: close }), /* @__PURE__ */ React8.createElement("div", { ref: panelRef, role: "dialog", "aria-modal": "true", "aria-label": label, tabIndex: -1, className: cx("alt-cmd", className), "data-ephemeral": ephemeral ? "" : void 0 }, /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-head" }, /* @__PURE__ */ React8.createElement(
|
|
2211
2570
|
Input,
|
|
2212
2571
|
{
|
|
2213
2572
|
className: "alt-cmd-field",
|
|
@@ -2221,17 +2580,23 @@ function CommandPalette({
|
|
|
2221
2580
|
"aria-controls": `${id}-list`,
|
|
2222
2581
|
"aria-autocomplete": "list",
|
|
2223
2582
|
"aria-activedescendant": activeIndex >= 0 ? `${id}-o-${activeIndex}` : void 0,
|
|
2224
|
-
leading: /* @__PURE__ */
|
|
2225
|
-
trailing: /* @__PURE__ */
|
|
2583
|
+
leading: /* @__PURE__ */ React8.createElement(SearchIcon, null),
|
|
2584
|
+
trailing: /* @__PURE__ */ React8.createElement("span", { "aria-hidden": "true" }, /* @__PURE__ */ React8.createElement(Kbd, null, "esc")),
|
|
2226
2585
|
onChange: (e) => {
|
|
2227
|
-
|
|
2586
|
+
setInnerQuery(e.target.value);
|
|
2228
2587
|
setActive(0);
|
|
2229
2588
|
setOnset(false);
|
|
2230
2589
|
onQueryChange?.(e.target.value);
|
|
2231
2590
|
},
|
|
2591
|
+
onFocus: (e) => {
|
|
2592
|
+
if (caretPlaced.current) return;
|
|
2593
|
+
caretPlaced.current = true;
|
|
2594
|
+
const n2 = e.currentTarget.value.length;
|
|
2595
|
+
e.currentTarget.setSelectionRange(n2, n2);
|
|
2596
|
+
},
|
|
2232
2597
|
onKeyDown: onInputKeyDown
|
|
2233
2598
|
}
|
|
2234
|
-
)), /* @__PURE__ */
|
|
2599
|
+
)), /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-viewport", ref: viewport }, /* @__PURE__ */ React8.createElement("div", { ref: sizer }, /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-list", ref: list, role: "listbox", id: `${id}-list`, "aria-label": "Results" }, /* @__PURE__ */ React8.createElement(
|
|
2235
2600
|
"span",
|
|
2236
2601
|
{
|
|
2237
2602
|
className: "alt-cmd-hl",
|
|
@@ -2242,10 +2607,10 @@ function CommandPalette({
|
|
|
2242
2607
|
), view.map((v) => {
|
|
2243
2608
|
const labelId = `${id}-g-${v.gi}`;
|
|
2244
2609
|
const groupPredicted = !!v.g.predicted || v.rows.every((r) => r.item.predicted);
|
|
2245
|
-
return /* @__PURE__ */
|
|
2610
|
+
return /* @__PURE__ */ React8.createElement("div", { key: v.gk, role: "group", "aria-labelledby": v.g.label ? labelId : void 0, className: "alt-cmd-group" }, v.g.label && /* @__PURE__ */ React8.createElement("div", { id: labelId, role: "presentation", className: "alt-cmd-label", "data-flip": "g:" + v.gk, "data-predicted": groupPredicted ? "" : void 0 }, v.g.label), v.rows.map(() => {
|
|
2246
2611
|
const i = n++, r = flat[i], item = r.item;
|
|
2247
2612
|
const on = r === activeRow;
|
|
2248
|
-
return /* @__PURE__ */
|
|
2613
|
+
return /* @__PURE__ */ React8.createElement(
|
|
2249
2614
|
"div",
|
|
2250
2615
|
{
|
|
2251
2616
|
key: r.key,
|
|
@@ -2266,16 +2631,16 @@ function CommandPalette({
|
|
|
2266
2631
|
},
|
|
2267
2632
|
onClick: () => choose(r)
|
|
2268
2633
|
},
|
|
2269
|
-
item.icon && /* @__PURE__ */
|
|
2270
|
-
/* @__PURE__ */
|
|
2271
|
-
item.shortcut && /* @__PURE__ */
|
|
2634
|
+
item.icon && /* @__PURE__ */ React8.createElement("span", { className: "alt-cmd-icon", "aria-hidden": "true" }, item.icon),
|
|
2635
|
+
/* @__PURE__ */ React8.createElement("span", { className: "alt-cmd-text" }, /* @__PURE__ */ React8.createElement("span", { className: "alt-cmd-title" }, /* @__PURE__ */ React8.createElement(Marked, { text: item.label, ranges: matchRanges(item.label, q) })), item.description && /* @__PURE__ */ React8.createElement("span", { className: "alt-cmd-desc" }, item.description)),
|
|
2636
|
+
item.shortcut && /* @__PURE__ */ React8.createElement("span", { className: "alt-cmd-keys" }, item.shortcut.map((k, j) => /* @__PURE__ */ React8.createElement(Kbd, { key: j }, k)))
|
|
2272
2637
|
);
|
|
2273
2638
|
}));
|
|
2274
|
-
})), q && !flat.length && /* @__PURE__ */
|
|
2639
|
+
})), q && !flat.length && /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-empty" }, typeof empty === "function" ? empty(q) : empty ?? /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("b", null, "No results for \u201C", q, "\u201D"), "Try another word, or check the spelling.")))), hints && /* @__PURE__ */ React8.createElement("div", { className: "alt-cmd-foot", "aria-hidden": "true" }, /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement(Kbd, null, "\u2191"), /* @__PURE__ */ React8.createElement(Kbd, null, "\u2193"), "Move"), /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement(Kbd, null, "\u21B5"), "Choose"), /* @__PURE__ */ React8.createElement("span", null, /* @__PURE__ */ React8.createElement(Kbd, null, "esc"), "Close")), /* @__PURE__ */ React8.createElement("span", { className: "alt-sr", "aria-live": "polite" }, said))));
|
|
2275
2640
|
}
|
|
2276
2641
|
|
|
2277
2642
|
// project/components/src/select.tsx
|
|
2278
|
-
var
|
|
2643
|
+
var React9 = __toESM(require("react"), 1);
|
|
2279
2644
|
var EXIT_32 = 160;
|
|
2280
2645
|
function SelectItem(_) {
|
|
2281
2646
|
return null;
|
|
@@ -2284,17 +2649,17 @@ var textOf = (o) => o.textValue ?? (typeof o.label === "string" || typeof o.labe
|
|
|
2284
2649
|
function collect(items, children) {
|
|
2285
2650
|
if (items) return items;
|
|
2286
2651
|
const out = [];
|
|
2287
|
-
|
|
2288
|
-
if (!
|
|
2652
|
+
React9.Children.forEach(children, (c) => {
|
|
2653
|
+
if (!React9.isValidElement(c) || c.type !== SelectItem) return;
|
|
2289
2654
|
const p = c.props;
|
|
2290
2655
|
out.push({ value: p.value, label: p.children, textValue: p.textValue, description: p.description, icon: p.icon, disabled: p.disabled });
|
|
2291
2656
|
});
|
|
2292
2657
|
return out;
|
|
2293
2658
|
}
|
|
2294
|
-
var Tick = () => /* @__PURE__ */
|
|
2295
|
-
var Chevron = () => /* @__PURE__ */
|
|
2659
|
+
var Tick = () => /* @__PURE__ */ React9.createElement("svg", { className: "alt-select-tick", viewBox: "0 0 16 16", width: "15", height: "15", fill: "none", stroke: "currentColor", strokeWidth: "2.25", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ React9.createElement("path", { d: "M3.5 8.5l3 3 6-6.5", pathLength: 16 }));
|
|
2660
|
+
var Chevron = () => /* @__PURE__ */ React9.createElement(Icons.ChevronDown, { className: "alt-select-chevron", size: 16 });
|
|
2296
2661
|
function useSide(open, anchor, list) {
|
|
2297
|
-
const [side, setSide] =
|
|
2662
|
+
const [side, setSide] = React9.useState("bottom");
|
|
2298
2663
|
useIsoLayoutEffect(() => {
|
|
2299
2664
|
if (!open || !anchor.current || !list.current) return;
|
|
2300
2665
|
const a = anchor.current.getBoundingClientRect(), need = list.current.offsetHeight + 12;
|
|
@@ -2312,9 +2677,9 @@ function useSide(open, anchor, list) {
|
|
|
2312
2677
|
return side;
|
|
2313
2678
|
}
|
|
2314
2679
|
function useGlow(value) {
|
|
2315
|
-
const [glow, setGlow] =
|
|
2316
|
-
const first =
|
|
2317
|
-
|
|
2680
|
+
const [glow, setGlow] = React9.useState(void 0);
|
|
2681
|
+
const first = React9.useRef(true);
|
|
2682
|
+
React9.useEffect(() => {
|
|
2318
2683
|
if (first.current) {
|
|
2319
2684
|
first.current = false;
|
|
2320
2685
|
return;
|
|
@@ -2324,8 +2689,8 @@ function useGlow(value) {
|
|
|
2324
2689
|
return glow;
|
|
2325
2690
|
}
|
|
2326
2691
|
function useLabelId(controlId, fallback) {
|
|
2327
|
-
const [labelId, setLabelId] =
|
|
2328
|
-
|
|
2692
|
+
const [labelId, setLabelId] = React9.useState(void 0);
|
|
2693
|
+
React9.useEffect(() => {
|
|
2329
2694
|
const label = document.querySelector(`label[for="${CSS.escape(controlId)}"]`);
|
|
2330
2695
|
if (!label) {
|
|
2331
2696
|
setLabelId(void 0);
|
|
@@ -2337,8 +2702,8 @@ function useLabelId(controlId, fallback) {
|
|
|
2337
2702
|
return labelId;
|
|
2338
2703
|
}
|
|
2339
2704
|
function OptionList({ id, options, active, value, state, side, query, empty, listRef, labelledBy, label, focusable, onActive, onChoose, onKeyDown }) {
|
|
2340
|
-
const rows =
|
|
2341
|
-
const [hl, setHl] =
|
|
2705
|
+
const rows = React9.useRef([]);
|
|
2706
|
+
const [hl, setHl] = React9.useState(null);
|
|
2342
2707
|
useIsoLayoutEffect(() => {
|
|
2343
2708
|
const el = active >= 0 ? rows.current[active] : null;
|
|
2344
2709
|
setHl(el ? { y: el.offsetTop, h: el.offsetHeight } : null);
|
|
@@ -2353,9 +2718,9 @@ function OptionList({ id, options, active, value, state, side, query, empty, lis
|
|
|
2353
2718
|
if (!query || typeof o.label !== "string") return o.label;
|
|
2354
2719
|
const i = t.toLowerCase().indexOf(query.toLowerCase());
|
|
2355
2720
|
if (i < 0) return o.label;
|
|
2356
|
-
return /* @__PURE__ */
|
|
2721
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, t.slice(0, i), /* @__PURE__ */ React9.createElement("mark", { className: "alt-cmd-match" }, t.slice(i, i + query.length)), t.slice(i + query.length));
|
|
2357
2722
|
};
|
|
2358
|
-
return /* @__PURE__ */
|
|
2723
|
+
return /* @__PURE__ */ React9.createElement(
|
|
2359
2724
|
"div",
|
|
2360
2725
|
{
|
|
2361
2726
|
ref: listRef,
|
|
@@ -2371,8 +2736,8 @@ function OptionList({ id, options, active, value, state, side, query, empty, lis
|
|
|
2371
2736
|
onKeyDown,
|
|
2372
2737
|
onMouseDown: (e) => e.preventDefault()
|
|
2373
2738
|
},
|
|
2374
|
-
/* @__PURE__ */
|
|
2375
|
-
options.map((o, i) => /* @__PURE__ */
|
|
2739
|
+
/* @__PURE__ */ React9.createElement("span", { className: "alt-menu-hl", "aria-hidden": "true", style: hl ? { transform: `translateY(${hl.y}px)`, height: hl.h, opacity: 1 } : { opacity: 0 } }),
|
|
2740
|
+
options.map((o, i) => /* @__PURE__ */ React9.createElement(
|
|
2376
2741
|
"div",
|
|
2377
2742
|
{
|
|
2378
2743
|
key: o.value,
|
|
@@ -2391,11 +2756,11 @@ function OptionList({ id, options, active, value, state, side, query, empty, lis
|
|
|
2391
2756
|
},
|
|
2392
2757
|
onClick: () => onChoose(i)
|
|
2393
2758
|
},
|
|
2394
|
-
o.icon && /* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
o.value === value && /* @__PURE__ */
|
|
2759
|
+
o.icon && /* @__PURE__ */ React9.createElement("span", { className: "alt-menu-icon" }, o.icon),
|
|
2760
|
+
/* @__PURE__ */ React9.createElement("span", { className: "alt-menu-text" }, marks(o), o.description && /* @__PURE__ */ React9.createElement("span", { className: "alt-select-desc" }, o.description)),
|
|
2761
|
+
o.value === value && /* @__PURE__ */ React9.createElement(Tick, null)
|
|
2397
2762
|
)),
|
|
2398
|
-
!options.length && /* @__PURE__ */
|
|
2763
|
+
!options.length && /* @__PURE__ */ React9.createElement("div", { className: "alt-select-empty" }, empty)
|
|
2399
2764
|
);
|
|
2400
2765
|
}
|
|
2401
2766
|
function Select({
|
|
@@ -2417,16 +2782,16 @@ function Select({
|
|
|
2417
2782
|
}) {
|
|
2418
2783
|
const options = collect(items, children);
|
|
2419
2784
|
const [v, set] = useControllable(value, defaultValue, onValueChange);
|
|
2420
|
-
const [open, setOpen] =
|
|
2421
|
-
const [active, setActive] =
|
|
2422
|
-
const auto =
|
|
2785
|
+
const [open, setOpen] = React9.useState(defaultOpen);
|
|
2786
|
+
const [active, setActive] = React9.useState(() => defaultOpen ? options.findIndex((o) => o.value === (value ?? defaultValue)) : -1);
|
|
2787
|
+
const auto = React9.useId();
|
|
2423
2788
|
const triggerId = id ?? auto + "-trigger";
|
|
2424
2789
|
const listId = auto + "-list";
|
|
2425
|
-
const root =
|
|
2426
|
-
const field =
|
|
2427
|
-
const trigger =
|
|
2428
|
-
const list =
|
|
2429
|
-
const typed =
|
|
2790
|
+
const root = React9.useRef(null);
|
|
2791
|
+
const field = React9.useRef(null);
|
|
2792
|
+
const trigger = React9.useRef(null);
|
|
2793
|
+
const list = React9.useRef(null);
|
|
2794
|
+
const typed = React9.useRef({ text: "", at: 0 });
|
|
2430
2795
|
const { mounted, state } = usePresence(open, EXIT_32);
|
|
2431
2796
|
const side = useSide(mounted, field, list);
|
|
2432
2797
|
const glow = useGlow(v);
|
|
@@ -2435,12 +2800,12 @@ function Select({
|
|
|
2435
2800
|
useKeyFocus();
|
|
2436
2801
|
const chosen = options.find((o) => o.value === v);
|
|
2437
2802
|
const enabled = options.map((o, i) => o.disabled ? -1 : i).filter((i) => i >= 0);
|
|
2438
|
-
const close =
|
|
2803
|
+
const close = React9.useCallback((refocus = true) => {
|
|
2439
2804
|
setOpen(false);
|
|
2440
2805
|
if (refocus) trigger.current?.focus({ preventScroll: true });
|
|
2441
2806
|
}, []);
|
|
2442
2807
|
useOutside(root, open, () => close(false));
|
|
2443
|
-
|
|
2808
|
+
React9.useEffect(() => {
|
|
2444
2809
|
if (state === "open") list.current?.focus({ preventScroll: true });
|
|
2445
2810
|
}, [state]);
|
|
2446
2811
|
const openAt = (i) => {
|
|
@@ -2512,7 +2877,7 @@ function Select({
|
|
|
2512
2877
|
}
|
|
2513
2878
|
}
|
|
2514
2879
|
};
|
|
2515
|
-
return /* @__PURE__ */
|
|
2880
|
+
return /* @__PURE__ */ React9.createElement("div", { ref: root, className: cx("alt-select", className), "data-open": open ? "" : void 0 }, /* @__PURE__ */ React9.createElement(
|
|
2516
2881
|
"div",
|
|
2517
2882
|
{
|
|
2518
2883
|
ref: field,
|
|
@@ -2523,7 +2888,7 @@ function Select({
|
|
|
2523
2888
|
"data-invalid": invalid ? "" : void 0,
|
|
2524
2889
|
"data-disabled": disabled ? "" : void 0
|
|
2525
2890
|
},
|
|
2526
|
-
/* @__PURE__ */
|
|
2891
|
+
/* @__PURE__ */ React9.createElement(
|
|
2527
2892
|
"button",
|
|
2528
2893
|
{
|
|
2529
2894
|
ref: trigger,
|
|
@@ -2540,10 +2905,10 @@ function Select({
|
|
|
2540
2905
|
onClick: () => open ? close() : openAt(current()),
|
|
2541
2906
|
onKeyDown: onTriggerKey
|
|
2542
2907
|
},
|
|
2543
|
-
/* @__PURE__ */
|
|
2544
|
-
/* @__PURE__ */
|
|
2908
|
+
/* @__PURE__ */ React9.createElement("span", { className: "alt-select-value", "data-placeholder": chosen ? void 0 : "", "data-glow": glow }, chosen ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, chosen.icon && /* @__PURE__ */ React9.createElement("span", { className: "alt-select-icon" }, chosen.icon), chosen.label) : placeholder),
|
|
2909
|
+
/* @__PURE__ */ React9.createElement(Chevron, null)
|
|
2545
2910
|
)
|
|
2546
|
-
), name && /* @__PURE__ */
|
|
2911
|
+
), name && /* @__PURE__ */ React9.createElement("input", { type: "hidden", name, value: v }), mounted && /* @__PURE__ */ React9.createElement(
|
|
2547
2912
|
OptionList,
|
|
2548
2913
|
{
|
|
2549
2914
|
id: listId,
|
|
@@ -2582,24 +2947,24 @@ function Combobox({
|
|
|
2582
2947
|
}) {
|
|
2583
2948
|
const [v, set] = useControllable(value, defaultValue, onValueChange);
|
|
2584
2949
|
const chosen = items.find((o) => o.value === v);
|
|
2585
|
-
const [text, setText] =
|
|
2586
|
-
const [typing, setTyping] =
|
|
2587
|
-
const [open, setOpen] =
|
|
2588
|
-
const [active, setActive] =
|
|
2589
|
-
const auto =
|
|
2950
|
+
const [text, setText] = React9.useState(chosen ? textOf(chosen) : "");
|
|
2951
|
+
const [typing, setTyping] = React9.useState(false);
|
|
2952
|
+
const [open, setOpen] = React9.useState(defaultOpen);
|
|
2953
|
+
const [active, setActive] = React9.useState(() => defaultOpen ? items.findIndex((o) => o.value === (value ?? defaultValue)) : -1);
|
|
2954
|
+
const auto = React9.useId();
|
|
2590
2955
|
const inputId = id ?? auto + "-input";
|
|
2591
2956
|
const listId = auto + "-list";
|
|
2592
|
-
const root =
|
|
2593
|
-
const field =
|
|
2594
|
-
const input =
|
|
2595
|
-
const list =
|
|
2957
|
+
const root = React9.useRef(null);
|
|
2958
|
+
const field = React9.useRef(null);
|
|
2959
|
+
const input = React9.useRef(null);
|
|
2960
|
+
const list = React9.useRef(null);
|
|
2596
2961
|
const { mounted, state } = usePresence(open, EXIT_32);
|
|
2597
2962
|
const side = useSide(mounted, field, list);
|
|
2598
2963
|
const glow = useGlow(v);
|
|
2599
2964
|
const labelId = useLabelId(inputId, auto + "-label");
|
|
2600
2965
|
useApproach();
|
|
2601
2966
|
useKeyFocus();
|
|
2602
|
-
|
|
2967
|
+
React9.useEffect(() => {
|
|
2603
2968
|
if (!typing) setText(chosen ? textOf(chosen) : "");
|
|
2604
2969
|
}, [v]);
|
|
2605
2970
|
const q = typing ? text.trim() : "";
|
|
@@ -2666,7 +3031,7 @@ function Combobox({
|
|
|
2666
3031
|
if (!root.current?.contains(e.relatedTarget)) commit();
|
|
2667
3032
|
};
|
|
2668
3033
|
const filled = !!chosen && !typing;
|
|
2669
|
-
return /* @__PURE__ */
|
|
3034
|
+
return /* @__PURE__ */ React9.createElement("div", { ref: root, className: cx("alt-select alt-combobox", className), "data-open": open ? "" : void 0 }, /* @__PURE__ */ React9.createElement(
|
|
2670
3035
|
"div",
|
|
2671
3036
|
{
|
|
2672
3037
|
ref: field,
|
|
@@ -2677,7 +3042,7 @@ function Combobox({
|
|
|
2677
3042
|
"data-invalid": invalid ? "" : void 0,
|
|
2678
3043
|
"data-disabled": disabled ? "" : void 0
|
|
2679
3044
|
},
|
|
2680
|
-
/* @__PURE__ */
|
|
3045
|
+
/* @__PURE__ */ React9.createElement(
|
|
2681
3046
|
"input",
|
|
2682
3047
|
{
|
|
2683
3048
|
ref: input,
|
|
@@ -2707,7 +3072,7 @@ function Combobox({
|
|
|
2707
3072
|
}
|
|
2708
3073
|
}
|
|
2709
3074
|
),
|
|
2710
|
-
/* @__PURE__ */
|
|
3075
|
+
/* @__PURE__ */ React9.createElement(
|
|
2711
3076
|
"button",
|
|
2712
3077
|
{
|
|
2713
3078
|
type: "button",
|
|
@@ -2728,9 +3093,9 @@ function Combobox({
|
|
|
2728
3093
|
input.current?.focus();
|
|
2729
3094
|
}
|
|
2730
3095
|
},
|
|
2731
|
-
/* @__PURE__ */
|
|
3096
|
+
/* @__PURE__ */ React9.createElement(Chevron, null)
|
|
2732
3097
|
)
|
|
2733
|
-
), name && /* @__PURE__ */
|
|
3098
|
+
), name && /* @__PURE__ */ React9.createElement("input", { type: "hidden", name, value: v }), mounted && /* @__PURE__ */ React9.createElement(
|
|
2734
3099
|
OptionList,
|
|
2735
3100
|
{
|
|
2736
3101
|
id: listId,
|
|
@@ -2752,30 +3117,30 @@ function Combobox({
|
|
|
2752
3117
|
}
|
|
2753
3118
|
|
|
2754
3119
|
// project/components/src/stepper.tsx
|
|
2755
|
-
var
|
|
2756
|
-
var Tick2 = () => /* @__PURE__ */
|
|
3120
|
+
var React10 = __toESM(require("react"), 1);
|
|
3121
|
+
var Tick2 = () => /* @__PURE__ */ React10.createElement("svg", { viewBox: "0 0 16 16", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ React10.createElement("path", { d: "M3.5 8.5l3 3 6-6.5", pathLength: 16 }));
|
|
2757
3122
|
var word = { done: "completed", current: "current", upcoming: "not started" };
|
|
2758
3123
|
function Stepper({ steps, current, onStepChange, orientation = "horizontal", className, ...rest }) {
|
|
2759
|
-
const [seen, setSeen] =
|
|
2760
|
-
const [motion, setMotion] =
|
|
2761
|
-
const [said, setSaid] =
|
|
3124
|
+
const [seen, setSeen] = React10.useState(current);
|
|
3125
|
+
const [motion, setMotion] = React10.useState(null);
|
|
3126
|
+
const [said, setSaid] = React10.useState("");
|
|
2762
3127
|
if (seen !== current) {
|
|
2763
3128
|
setSeen(current);
|
|
2764
3129
|
setMotion({ pressed: seen, risen: current, stamp: current > seen ? seen : -1, delay: (current > seen ? 150 : 60) + riseDelay(), key: (motion?.key ?? 0) + 1 });
|
|
2765
3130
|
}
|
|
2766
|
-
|
|
3131
|
+
React10.useEffect(() => {
|
|
2767
3132
|
if (!motion) return;
|
|
2768
3133
|
const t = steps[current];
|
|
2769
3134
|
setSaid(t ? `Step ${current + 1} of ${steps.length}: ${typeof t.title === "string" ? t.title : ""}` : "All steps complete");
|
|
2770
3135
|
const done = setTimeout(() => setMotion(null), 900);
|
|
2771
3136
|
return () => clearTimeout(done);
|
|
2772
3137
|
}, [motion?.key]);
|
|
2773
|
-
return /* @__PURE__ */
|
|
3138
|
+
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("ol", { className: cx("alt-stepper", className), "data-orientation": orientation, "aria-label": rest["aria-label"] ?? "Progress", ...rest }, steps.map((s, i) => {
|
|
2774
3139
|
const state = i < current ? "done" : i === current ? "current" : "upcoming";
|
|
2775
3140
|
const back = state === "done" && !!onStepChange;
|
|
2776
3141
|
const rising = motion && motion.risen === i;
|
|
2777
3142
|
const stamped = motion && motion.stamp === i;
|
|
2778
|
-
return /* @__PURE__ */
|
|
3143
|
+
return /* @__PURE__ */ React10.createElement("li", { key: s.id ?? i, className: "alt-step-item", "data-state": state, "aria-current": state === "current" ? "step" : void 0 }, /* @__PURE__ */ React10.createElement(
|
|
2779
3144
|
"div",
|
|
2780
3145
|
{
|
|
2781
3146
|
className: "alt-step",
|
|
@@ -2794,14 +3159,59 @@ function Stepper({ steps, current, onStepChange, orientation = "horizontal", cla
|
|
|
2794
3159
|
} : {},
|
|
2795
3160
|
style: rising ? { ["--alt-rise-delay"]: motion.delay + "ms" } : void 0
|
|
2796
3161
|
},
|
|
2797
|
-
/* @__PURE__ */
|
|
2798
|
-
/* @__PURE__ */
|
|
2799
|
-
), i < steps.length - 1 && /* @__PURE__ */
|
|
2800
|
-
})), /* @__PURE__ */
|
|
3162
|
+
/* @__PURE__ */ React10.createElement("span", { className: "alt-step-mark", "data-stamp": stamped ? motion.key % 2 ? "a" : "b" : void 0 }, state === "done" ? /* @__PURE__ */ React10.createElement(Tick2, null) : i + 1),
|
|
3163
|
+
/* @__PURE__ */ React10.createElement("span", { className: "alt-step-text" }, /* @__PURE__ */ React10.createElement("span", { className: "alt-sr" }, "Step ", i + 1, " of ", steps.length, ", ", word[state], ": "), /* @__PURE__ */ React10.createElement("span", { className: "alt-step-title" }, s.title), s.description && /* @__PURE__ */ React10.createElement("span", { className: "alt-step-desc" }, s.description))
|
|
3164
|
+
), i < steps.length - 1 && /* @__PURE__ */ React10.createElement("span", { className: "alt-step-line", "aria-hidden": "true", "data-done": i < current ? "" : void 0 }));
|
|
3165
|
+
})), /* @__PURE__ */ React10.createElement("span", { className: "alt-sr", "aria-live": "polite" }, said));
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
// project/components/src/empty.tsx
|
|
3169
|
+
var React11 = __toESM(require("react"), 1);
|
|
3170
|
+
function EmptyState({
|
|
3171
|
+
icon: icon2,
|
|
3172
|
+
title,
|
|
3173
|
+
description,
|
|
3174
|
+
action,
|
|
3175
|
+
secondary,
|
|
3176
|
+
size = "md",
|
|
3177
|
+
headingLevel = 3,
|
|
3178
|
+
announce,
|
|
3179
|
+
className,
|
|
3180
|
+
children,
|
|
3181
|
+
...rest
|
|
3182
|
+
}) {
|
|
3183
|
+
const id = React11.useId();
|
|
3184
|
+
const H = `h${headingLevel}`;
|
|
3185
|
+
const words = typeof announce === "string" ? announce : announce && typeof title === "string" ? title : "";
|
|
3186
|
+
const [said, setSaid] = React11.useState("");
|
|
3187
|
+
React11.useEffect(() => {
|
|
3188
|
+
if (!words) {
|
|
3189
|
+
setSaid("");
|
|
3190
|
+
return;
|
|
3191
|
+
}
|
|
3192
|
+
const t = setTimeout(() => setSaid(words), 100);
|
|
3193
|
+
return () => clearTimeout(t);
|
|
3194
|
+
}, [words]);
|
|
3195
|
+
return /* @__PURE__ */ React11.createElement(
|
|
3196
|
+
"section",
|
|
3197
|
+
{
|
|
3198
|
+
className: cx("alt-empty", className),
|
|
3199
|
+
"data-size": size,
|
|
3200
|
+
"aria-labelledby": `${id}-t`,
|
|
3201
|
+
"aria-describedby": description ? `${id}-d` : void 0,
|
|
3202
|
+
...rest
|
|
3203
|
+
},
|
|
3204
|
+
icon2 && /* @__PURE__ */ React11.createElement("span", { className: "alt-empty-icon", "aria-hidden": "true" }, icon2),
|
|
3205
|
+
/* @__PURE__ */ React11.createElement(H, { id: `${id}-t`, className: "alt-empty-title" }, title),
|
|
3206
|
+
description && /* @__PURE__ */ React11.createElement("p", { id: `${id}-d`, className: "alt-empty-desc" }, description),
|
|
3207
|
+
children,
|
|
3208
|
+
(action || secondary) && /* @__PURE__ */ React11.createElement("div", { className: "alt-empty-actions" }, action, secondary),
|
|
3209
|
+
announce && /* @__PURE__ */ React11.createElement("span", { className: "alt-sr", "aria-live": "polite" }, said)
|
|
3210
|
+
);
|
|
2801
3211
|
}
|
|
2802
3212
|
|
|
2803
3213
|
// project/components/src/collections.tsx
|
|
2804
|
-
var
|
|
3214
|
+
var React12 = __toESM(require("react"), 1);
|
|
2805
3215
|
var dropSnapshots = /* @__PURE__ */ new WeakMap();
|
|
2806
3216
|
var ms2 = (cs, name, fallback) => parseFloat(cs.getPropertyValue(name)) || fallback;
|
|
2807
3217
|
function pagePlace(el) {
|
|
@@ -2823,7 +3233,7 @@ function placeIn(el, host) {
|
|
|
2823
3233
|
return { x: a.x - b.x, y: a.y - b.y };
|
|
2824
3234
|
}
|
|
2825
3235
|
function useCarry(host, selector, attr, durToken = "--dur-travel-3") {
|
|
2826
|
-
const prev =
|
|
3236
|
+
const prev = React12.useRef(null);
|
|
2827
3237
|
useIsoLayoutEffect(() => {
|
|
2828
3238
|
const root = host.current;
|
|
2829
3239
|
if (!root) return;
|
|
@@ -2852,12 +3262,12 @@ var moveItem = (arr, from, to) => {
|
|
|
2852
3262
|
a.splice(to, 0, x);
|
|
2853
3263
|
return a;
|
|
2854
3264
|
};
|
|
2855
|
-
var Table =
|
|
2856
|
-
const wrap =
|
|
2857
|
-
const table =
|
|
2858
|
-
|
|
2859
|
-
const [edges, setEdges] =
|
|
2860
|
-
const measure =
|
|
3265
|
+
var Table = React12.forwardRef(function Table2({ maxHeight, underlay, className, children, ...rest }, ref) {
|
|
3266
|
+
const wrap = React12.useRef(null);
|
|
3267
|
+
const table = React12.useRef(null);
|
|
3268
|
+
React12.useImperativeHandle(ref, () => table.current);
|
|
3269
|
+
const [edges, setEdges] = React12.useState({ top: false, bottom: false });
|
|
3270
|
+
const measure = React12.useCallback(() => {
|
|
2861
3271
|
const el = wrap.current;
|
|
2862
3272
|
if (!el) return;
|
|
2863
3273
|
const top = el.scrollTop > 1, bottom = el.scrollTop + el.clientHeight < el.scrollHeight - 1;
|
|
@@ -2878,7 +3288,7 @@ var Table = React10.forwardRef(function Table2({ maxHeight, underlay, className,
|
|
|
2878
3288
|
}, [measure]);
|
|
2879
3289
|
useCarry(table, "tbody > tr[data-row]", "data-row");
|
|
2880
3290
|
const scrolls = maxHeight !== void 0;
|
|
2881
|
-
return /* @__PURE__ */
|
|
3291
|
+
return /* @__PURE__ */ React12.createElement(
|
|
2882
3292
|
"div",
|
|
2883
3293
|
{
|
|
2884
3294
|
ref: wrap,
|
|
@@ -2890,27 +3300,27 @@ var Table = React10.forwardRef(function Table2({ maxHeight, underlay, className,
|
|
|
2890
3300
|
...scrolls ? { tabIndex: 0, role: "region", "aria-label": rest["aria-label"] } : {}
|
|
2891
3301
|
},
|
|
2892
3302
|
underlay,
|
|
2893
|
-
/* @__PURE__ */
|
|
3303
|
+
/* @__PURE__ */ React12.createElement("table", { ref: table, className: cx("alt-table", className), ...rest }, children)
|
|
2894
3304
|
);
|
|
2895
3305
|
});
|
|
2896
|
-
var TableHeader = ({ className, ...p }) => /* @__PURE__ */
|
|
2897
|
-
var TableBody =
|
|
2898
|
-
return /* @__PURE__ */
|
|
3306
|
+
var TableHeader = ({ className, ...p }) => /* @__PURE__ */ React12.createElement("thead", { className: cx("alt-table-head", className), ...p });
|
|
3307
|
+
var TableBody = React12.forwardRef(function TableBody2({ className, ...p }, ref) {
|
|
3308
|
+
return /* @__PURE__ */ React12.createElement("tbody", { ref, className: cx("alt-table-body", className), ...p });
|
|
2899
3309
|
});
|
|
2900
|
-
var TableFooter = ({ className, ...p }) => /* @__PURE__ */
|
|
2901
|
-
var TableCaption = ({ className, ...p }) => /* @__PURE__ */
|
|
2902
|
-
var TableRow =
|
|
2903
|
-
const [glow, setGlow] =
|
|
2904
|
-
const [delay, setDelay] =
|
|
2905
|
-
const first =
|
|
2906
|
-
|
|
3310
|
+
var TableFooter = ({ className, ...p }) => /* @__PURE__ */ React12.createElement("tfoot", { className: cx("alt-table-foot", className), ...p });
|
|
3311
|
+
var TableCaption = ({ className, ...p }) => /* @__PURE__ */ React12.createElement("caption", { className: cx("alt-table-caption", className), ...p });
|
|
3312
|
+
var TableRow = React12.forwardRef(function TableRow2({ rowId, selected, interactive, relevance, settle, held, className, style, ...rest }, ref) {
|
|
3313
|
+
const [glow, setGlow] = React12.useState(void 0);
|
|
3314
|
+
const [delay, setDelay] = React12.useState(0);
|
|
3315
|
+
const first = React12.useRef(true);
|
|
3316
|
+
React12.useEffect(() => {
|
|
2907
3317
|
const wasFirst = first.current;
|
|
2908
3318
|
first.current = false;
|
|
2909
3319
|
if (settle === void 0 || settle === null || settle === false || wasFirst && settle !== true) return;
|
|
2910
3320
|
setDelay(riseDelay());
|
|
2911
3321
|
setGlow((g) => g === "a" ? "b" : "a");
|
|
2912
3322
|
}, [settle]);
|
|
2913
|
-
return /* @__PURE__ */
|
|
3323
|
+
return /* @__PURE__ */ React12.createElement(
|
|
2914
3324
|
"tr",
|
|
2915
3325
|
{
|
|
2916
3326
|
ref,
|
|
@@ -2926,15 +3336,28 @@ var TableRow = React10.forwardRef(function TableRow2({ rowId, selected, interact
|
|
|
2926
3336
|
}
|
|
2927
3337
|
);
|
|
2928
3338
|
});
|
|
2929
|
-
var SortIcon = () => /* @__PURE__ */
|
|
3339
|
+
var SortIcon = () => /* @__PURE__ */ React12.createElement("svg", { className: "alt-table-sort-icon", width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement("path", { d: "M6 15l6-6 6 6" }));
|
|
2930
3340
|
function TableHead({ align, sort, onSort, className, children, ...rest }) {
|
|
2931
|
-
return /* @__PURE__ */
|
|
3341
|
+
return /* @__PURE__ */ React12.createElement("th", { scope: "col", className: cx("alt-th", className), "data-align": align, "aria-sort": onSort ? sort ?? "none" : void 0, ...rest }, onSort ? /* @__PURE__ */ React12.createElement("button", { type: "button", className: "alt-table-sort", "data-sort": sort ?? "none", onClick: onSort }, children, /* @__PURE__ */ React12.createElement(SortIcon, null)) : children);
|
|
2932
3342
|
}
|
|
2933
3343
|
function TableCell({ align, className, ...rest }) {
|
|
2934
|
-
return /* @__PURE__ */
|
|
2935
|
-
}
|
|
2936
|
-
var GripIcon = () => /* @__PURE__ */
|
|
2937
|
-
function DataTable({
|
|
3344
|
+
return /* @__PURE__ */ React12.createElement("td", { className: cx("alt-td", className), "data-align": align, ...rest });
|
|
3345
|
+
}
|
|
3346
|
+
var GripIcon = () => /* @__PURE__ */ React12.createElement("svg", { width: "12", height: "16", viewBox: "0 0 12 16", fill: "currentColor", "aria-hidden": "true" }, /* @__PURE__ */ React12.createElement("circle", { cx: "3", cy: "3", r: "1.3" }), /* @__PURE__ */ React12.createElement("circle", { cx: "9", cy: "3", r: "1.3" }), /* @__PURE__ */ React12.createElement("circle", { cx: "3", cy: "8", r: "1.3" }), /* @__PURE__ */ React12.createElement("circle", { cx: "9", cy: "8", r: "1.3" }), /* @__PURE__ */ React12.createElement("circle", { cx: "3", cy: "13", r: "1.3" }), /* @__PURE__ */ React12.createElement("circle", { cx: "9", cy: "13", r: "1.3" }));
|
|
3347
|
+
function DataTable({ skeleton, ...props }) {
|
|
3348
|
+
const missing = skeleton !== false && props.rows === void 0;
|
|
3349
|
+
useReportWaiting(missing || skeleton !== false && isPromise(props.rows));
|
|
3350
|
+
const arrival = useArrival(missing);
|
|
3351
|
+
if (!useHasWaited(missing || isPromise(props.rows))) return /* @__PURE__ */ React12.createElement(DataTableFace, { ...props, rows: props.rows ?? [] });
|
|
3352
|
+
const { lines = 5 } = hint(skeleton);
|
|
3353
|
+
const { columns, selectable, toolbar, maxHeight, className } = props;
|
|
3354
|
+
return /* @__PURE__ */ React12.createElement(Await, { shape: "none", enabled: skeleton !== false, imprint: /* @__PURE__ */ React12.createElement("div", { className: cx("alt-data-table", className) }, (selectable || toolbar) && /* @__PURE__ */ React12.createElement("div", { className: "alt-table-tools" }, toolbar && /* @__PURE__ */ React12.createElement("div", { className: "alt-table-tools-end" }, toolbar)), /* @__PURE__ */ React12.createElement(Table, { maxHeight, "aria-label": props["aria-label"] }, /* @__PURE__ */ React12.createElement(TableHeader, null, /* @__PURE__ */ React12.createElement(TableRow, null, selectable && /* @__PURE__ */ React12.createElement(TableHead, { className: "alt-th-check" }, /* @__PURE__ */ React12.createElement("span", { className: "alt-skeleton alt-check-imprint" })), columns.map((c) => /* @__PURE__ */ React12.createElement(TableHead, { key: c.key, align: c.align, style: { width: c.width } }, c.header)))), /* @__PURE__ */ React12.createElement(TableBody, null, Array.from({ length: lines }, (_, i) => /* @__PURE__ */ React12.createElement(TableRow, { key: i }, selectable && /* @__PURE__ */ React12.createElement(TableCell, { className: "alt-td-check" }, /* @__PURE__ */ React12.createElement("span", { className: "alt-skeleton alt-check-imprint" })), columns.map((c, ci) => /* @__PURE__ */ React12.createElement(TableCell, { key: c.key, align: c.align }, /* @__PURE__ */ React12.createElement("span", { className: "alt-skeleton alt-cell-imprint", "data-shape": "text", style: { width: CELL_WIDTHS[(i + ci) % CELL_WIDTHS.length], ["--i"]: i } })))))))) }, /* @__PURE__ */ React12.createElement(Arrive, { when: arrival }, /* @__PURE__ */ React12.createElement(DataTableLanded, { ...props })));
|
|
3355
|
+
}
|
|
3356
|
+
var CELL_WIDTHS = ["72%", "54%", "86%", "63%", "78%"];
|
|
3357
|
+
function DataTableLanded(props) {
|
|
3358
|
+
return /* @__PURE__ */ React12.createElement(DataTableFace, { ...props, rows: readPromised(props.rows) ?? [] });
|
|
3359
|
+
}
|
|
3360
|
+
function DataTableFace({
|
|
2938
3361
|
columns,
|
|
2939
3362
|
rows,
|
|
2940
3363
|
getRowId,
|
|
@@ -2958,11 +3381,11 @@ function DataTable({
|
|
|
2958
3381
|
}) {
|
|
2959
3382
|
const [sel, setSel] = useControllable(selected, defaultSelected, onSelectedChange);
|
|
2960
3383
|
const [srt, setSrt] = useControllable(sort, defaultSort, onSortChange);
|
|
2961
|
-
const [said, setSaid] =
|
|
2962
|
-
const table =
|
|
2963
|
-
const body =
|
|
3384
|
+
const [said, setSaid] = React12.useState("");
|
|
3385
|
+
const table = React12.useRef(null);
|
|
3386
|
+
const body = React12.useRef(null);
|
|
2964
3387
|
const name = (r) => getRowLabel?.(r) ?? getRowId(r);
|
|
2965
|
-
const view =
|
|
3388
|
+
const view = React12.useMemo(() => {
|
|
2966
3389
|
const col = srt && columns.find((c) => c.key === srt.key);
|
|
2967
3390
|
if (!srt || !col?.sortValue) return rows;
|
|
2968
3391
|
const d = srt.direction === "descending" ? -1 : 1;
|
|
@@ -2979,9 +3402,9 @@ function DataTable({
|
|
|
2979
3402
|
setSaid(next ? `Sorted by ${typeof c.header === "string" ? c.header : c.key}, ${next.direction}.` : "Sort cleared.");
|
|
2980
3403
|
};
|
|
2981
3404
|
const toggle = (id, on) => setSel(on ? [...sel.filter((x) => x !== id), id] : sel.filter((x) => x !== id));
|
|
2982
|
-
const start =
|
|
2983
|
-
const [drag, setDrag] =
|
|
2984
|
-
const [held, setHeld] =
|
|
3405
|
+
const start = React12.useRef(null);
|
|
3406
|
+
const [drag, setDrag] = React12.useState(null);
|
|
3407
|
+
const [held, setHeld] = React12.useState(null);
|
|
2985
3408
|
const rowEls = () => Array.from(body.current?.querySelectorAll("tr[data-row]") ?? []);
|
|
2986
3409
|
const snapshot = (at) => {
|
|
2987
3410
|
if (!table.current) return;
|
|
@@ -3051,24 +3474,24 @@ function DataTable({
|
|
|
3051
3474
|
setSaid(`Move cancelled; ${name(view[index])} is back at position ${held.origin + 1}.`);
|
|
3052
3475
|
}
|
|
3053
3476
|
};
|
|
3054
|
-
|
|
3477
|
+
React12.useEffect(() => {
|
|
3055
3478
|
if (!movable) setHeld(null);
|
|
3056
3479
|
}, [movable]);
|
|
3057
3480
|
const s = start.current;
|
|
3058
3481
|
const h = drag && s ? s.hs[drag.from] : 0;
|
|
3059
3482
|
const slotTop = drag && s ? drag.to <= drag.from ? s.tops[drag.to] : s.tops[drag.to] + s.hs[drag.to] - s.hs[drag.from] : 0;
|
|
3060
3483
|
const span = columns.length + (selectable ? 1 : 0) + (movable ? 1 : 0);
|
|
3061
|
-
return /* @__PURE__ */
|
|
3484
|
+
return /* @__PURE__ */ React12.createElement("div", { className: cx("alt-data-table", className) }, (selectable || toolbar) && /* @__PURE__ */ React12.createElement("div", { className: "alt-table-tools" }, sel.length > 0 && /* @__PURE__ */ React12.createElement("div", { className: "alt-table-selection" }, /* @__PURE__ */ React12.createElement(Badge, { variant: "count", tone: "accent", "aria-hidden": "true" }, sel.length), /* @__PURE__ */ React12.createElement("span", null, "selected"), actions?.(sel), /* @__PURE__ */ React12.createElement(Button, { size: "sm", variant: "ghost", onClick: () => setSel([]) }, "Clear")), toolbar && /* @__PURE__ */ React12.createElement("div", { className: "alt-table-tools-end" }, toolbar)), /* @__PURE__ */ React12.createElement(
|
|
3062
3485
|
Table,
|
|
3063
3486
|
{
|
|
3064
3487
|
ref: table,
|
|
3065
3488
|
maxHeight,
|
|
3066
3489
|
"aria-label": rest["aria-label"],
|
|
3067
3490
|
"data-dragging": drag ? "" : void 0,
|
|
3068
|
-
underlay: drag && s ? /* @__PURE__ */
|
|
3491
|
+
underlay: drag && s ? /* @__PURE__ */ React12.createElement("span", { className: "alt-table-slot", "aria-hidden": "true", style: { top: slotTop + (table.current?.offsetTop ?? 0), height: h } }) : null
|
|
3069
3492
|
},
|
|
3070
|
-
/* @__PURE__ */
|
|
3071
|
-
/* @__PURE__ */
|
|
3493
|
+
/* @__PURE__ */ React12.createElement(TableHeader, null, /* @__PURE__ */ React12.createElement(TableRow, null, movable && /* @__PURE__ */ React12.createElement(TableHead, { className: "alt-th-grip" }, /* @__PURE__ */ React12.createElement("span", { className: "alt-sr" }, "Move")), selectable && /* @__PURE__ */ React12.createElement(TableHead, { className: "alt-th-check" }, /* @__PURE__ */ React12.createElement(Checkbox, { "aria-label": "Select all rows", checked: all, indeterminate: some, onCheckedChange: (on) => setSel(on ? Array.from(/* @__PURE__ */ new Set([...sel, ...ids])) : sel.filter((x) => !ids.includes(x))) })), columns.map((c) => /* @__PURE__ */ React12.createElement(TableHead, { key: c.key, align: c.align, style: { width: c.width }, sort: srt?.key === c.key ? srt.direction : "none", onSort: c.sortValue ? () => cycle(c) : void 0 }, c.header)))),
|
|
3494
|
+
/* @__PURE__ */ React12.createElement(TableBody, { ref: body }, !view.length && /* @__PURE__ */ React12.createElement("tr", null, /* @__PURE__ */ React12.createElement("td", { className: "alt-td alt-table-empty", colSpan: span }, empty)), view.map((r, i) => {
|
|
3072
3495
|
const id = ids[i];
|
|
3073
3496
|
let shift = 0;
|
|
3074
3497
|
if (drag && id !== drag.id && h) {
|
|
@@ -3076,7 +3499,7 @@ function DataTable({
|
|
|
3076
3499
|
if (drag.to < drag.from && i >= drag.to && i < drag.from) shift = h;
|
|
3077
3500
|
}
|
|
3078
3501
|
const following = drag?.id === id;
|
|
3079
|
-
return /* @__PURE__ */
|
|
3502
|
+
return /* @__PURE__ */ React12.createElement(
|
|
3080
3503
|
TableRow,
|
|
3081
3504
|
{
|
|
3082
3505
|
key: id,
|
|
@@ -3091,7 +3514,7 @@ function DataTable({
|
|
|
3091
3514
|
if (!e.target.closest("button, a, input, label, select, textarea")) onRowClick(r);
|
|
3092
3515
|
} : void 0
|
|
3093
3516
|
},
|
|
3094
|
-
movable && /* @__PURE__ */
|
|
3517
|
+
movable && /* @__PURE__ */ React12.createElement(TableCell, { className: "alt-td-grip" }, /* @__PURE__ */ React12.createElement(
|
|
3095
3518
|
"button",
|
|
3096
3519
|
{
|
|
3097
3520
|
type: "button",
|
|
@@ -3107,18 +3530,18 @@ function DataTable({
|
|
|
3107
3530
|
if (held?.id === id && !drag) setTimeout(() => setHeld((x) => x?.id === id && document.activeElement?.closest(`tr[data-row="${CSS.escape(id)}"]`) === null ? null : x), 0);
|
|
3108
3531
|
}
|
|
3109
3532
|
},
|
|
3110
|
-
/* @__PURE__ */
|
|
3533
|
+
/* @__PURE__ */ React12.createElement(GripIcon, null)
|
|
3111
3534
|
)),
|
|
3112
|
-
selectable && /* @__PURE__ */
|
|
3535
|
+
selectable && /* @__PURE__ */ React12.createElement(TableCell, { className: "alt-td-check" }, /* @__PURE__ */ React12.createElement(Checkbox, { "aria-label": `Select ${name(r)}`, checked: chosen.has(id), onCheckedChange: (on) => toggle(id, on) })),
|
|
3113
3536
|
columns.map((c, ci) => {
|
|
3114
3537
|
const content = c.cell ? c.cell(r) : String(r[c.key] ?? "");
|
|
3115
|
-
return /* @__PURE__ */
|
|
3538
|
+
return /* @__PURE__ */ React12.createElement(TableCell, { key: c.key, align: c.align }, onRowClick && ci === 0 ? /* @__PURE__ */ React12.createElement("button", { type: "button", className: "alt-table-rowbtn", onClick: () => onRowClick(r) }, content) : content);
|
|
3116
3539
|
})
|
|
3117
3540
|
);
|
|
3118
3541
|
}))
|
|
3119
|
-
), /* @__PURE__ */
|
|
3542
|
+
), /* @__PURE__ */ React12.createElement("span", { className: "alt-sr", "aria-live": "polite" }, selectable && sel.length ? `${sel.length} selected. ` : "", said));
|
|
3120
3543
|
}
|
|
3121
|
-
var BoardCtx =
|
|
3544
|
+
var BoardCtx = React12.createContext(null);
|
|
3122
3545
|
function readBoard(root) {
|
|
3123
3546
|
return Array.from(root.querySelectorAll("[data-board-col]")).map((col) => {
|
|
3124
3547
|
const list = col.querySelector(".alt-board-list");
|
|
@@ -3165,18 +3588,18 @@ function plan(cols, id, cx2, cy, h) {
|
|
|
3165
3588
|
}
|
|
3166
3589
|
return { to: { column: tc.id, index }, shifts, slotTop, gap: tc.gap };
|
|
3167
3590
|
}
|
|
3168
|
-
var Board =
|
|
3169
|
-
const root =
|
|
3170
|
-
|
|
3171
|
-
const hintId =
|
|
3172
|
-
const [carry, setCarry] =
|
|
3173
|
-
const [kb, setKb] =
|
|
3174
|
-
const [landing, setLanding] =
|
|
3175
|
-
const [said, setSaid] =
|
|
3176
|
-
const start =
|
|
3177
|
-
const dragged =
|
|
3591
|
+
var Board = React12.forwardRef(function Board2({ onMove, className, children, ...rest }, ref) {
|
|
3592
|
+
const root = React12.useRef(null);
|
|
3593
|
+
React12.useImperativeHandle(ref, () => root.current);
|
|
3594
|
+
const hintId = React12.useId();
|
|
3595
|
+
const [carry, setCarry] = React12.useState(null);
|
|
3596
|
+
const [kb, setKb] = React12.useState(null);
|
|
3597
|
+
const [landing, setLanding] = React12.useState(null);
|
|
3598
|
+
const [said, setSaid] = React12.useState("");
|
|
3599
|
+
const start = React12.useRef(null);
|
|
3600
|
+
const dragged = React12.useRef(false);
|
|
3178
3601
|
useCarry(root, "[data-board-card]", "data-board-card");
|
|
3179
|
-
|
|
3602
|
+
React12.useEffect(() => {
|
|
3180
3603
|
if (!landing) return;
|
|
3181
3604
|
const t = setTimeout(() => setLanding(null), 450);
|
|
3182
3605
|
return () => clearTimeout(t);
|
|
@@ -3305,17 +3728,17 @@ var Board = React10.forwardRef(function Board2({ onMove, className, children, ..
|
|
|
3305
3728
|
return d;
|
|
3306
3729
|
};
|
|
3307
3730
|
const ctx = { carry, kb, landing, hintId, onPointerDown, onPointerMove, onPointerUp, onKeyDown, onBlur, swallowClick };
|
|
3308
|
-
return /* @__PURE__ */
|
|
3731
|
+
return /* @__PURE__ */ React12.createElement(BoardCtx.Provider, { value: ctx }, /* @__PURE__ */ React12.createElement("div", { ref: root, role: "group", "aria-label": rest["aria-label"] ?? "Board", className: cx("alt-board", className), "data-carrying": carry || kb ? "" : void 0, ...rest }, children, /* @__PURE__ */ React12.createElement("span", { id: hintId, className: "alt-sr" }, "Press Space to pick up. While holding a card, use the arrow keys to move it, Space to drop it, Escape to cancel."), /* @__PURE__ */ React12.createElement("span", { className: "alt-sr", "aria-live": "assertive" }, said)));
|
|
3309
3732
|
});
|
|
3310
3733
|
function BoardColumn({ id, title, collapsed, defaultCollapsed = false, onCollapsedChange, collapsible, className, children, ...rest }) {
|
|
3311
|
-
const ctx =
|
|
3734
|
+
const ctx = React12.useContext(BoardCtx);
|
|
3312
3735
|
const [isCollapsed, setCollapsed] = useControllable(collapsed, defaultCollapsed, onCollapsedChange);
|
|
3313
|
-
const count =
|
|
3736
|
+
const count = React12.Children.toArray(children).filter(React12.isValidElement).length;
|
|
3314
3737
|
const label = typeof title === "string" ? title : id;
|
|
3315
3738
|
const carry = ctx?.carry;
|
|
3316
3739
|
const over = carry ? carry.to.column === id : ctx?.kb?.at.column === id;
|
|
3317
3740
|
const receiving = !!carry && carry.to.column === id && carry.from.column !== id && !isCollapsed;
|
|
3318
|
-
return /* @__PURE__ */
|
|
3741
|
+
return /* @__PURE__ */ React12.createElement(
|
|
3319
3742
|
"section",
|
|
3320
3743
|
{
|
|
3321
3744
|
className: cx("alt-board-col", className),
|
|
@@ -3326,7 +3749,7 @@ function BoardColumn({ id, title, collapsed, defaultCollapsed = false, onCollaps
|
|
|
3326
3749
|
"data-over": over ? "" : void 0,
|
|
3327
3750
|
...rest
|
|
3328
3751
|
},
|
|
3329
|
-
/* @__PURE__ */
|
|
3752
|
+
/* @__PURE__ */ React12.createElement("header", { className: "alt-board-head" }, /* @__PURE__ */ React12.createElement("h3", { className: "alt-board-title" }, title), /* @__PURE__ */ React12.createElement("span", { className: "alt-board-count", "aria-label": `${count} ${count === 1 ? "card" : "cards"}` }, count), collapsible && /* @__PURE__ */ React12.createElement(
|
|
3330
3753
|
Button,
|
|
3331
3754
|
{
|
|
3332
3755
|
variant: "ghost",
|
|
@@ -3338,20 +3761,20 @@ function BoardColumn({ id, title, collapsed, defaultCollapsed = false, onCollaps
|
|
|
3338
3761
|
"data-collapsed": isCollapsed ? "" : void 0,
|
|
3339
3762
|
onClick: () => setCollapsed(!isCollapsed)
|
|
3340
3763
|
},
|
|
3341
|
-
/* @__PURE__ */
|
|
3764
|
+
/* @__PURE__ */ React12.createElement(Icons.ChevronDown, null)
|
|
3342
3765
|
)),
|
|
3343
|
-
isCollapsed ? /* @__PURE__ */
|
|
3766
|
+
isCollapsed ? /* @__PURE__ */ React12.createElement(Pile, { count: Math.max(count, 1), className: "alt-board-pile" }, /* @__PURE__ */ React12.createElement("div", { className: "alt-board-pile-face" }, /* @__PURE__ */ React12.createElement("b", null, title), /* @__PURE__ */ React12.createElement("span", null, count ? `${count} ${count === 1 ? "card" : "cards"}` : "No cards"))) : /* @__PURE__ */ React12.createElement("div", { className: "alt-board-list", style: receiving ? { paddingBottom: carry.h + carry.gap } : void 0 }, carry && carry.to.column === id && /* @__PURE__ */ React12.createElement("span", { className: "alt-board-slot", "aria-hidden": "true", style: { top: carry.slotTop, height: carry.h } }), children, !count && !carry && /* @__PURE__ */ React12.createElement("div", { className: "alt-board-empty" }, "No cards"))
|
|
3344
3767
|
);
|
|
3345
3768
|
}
|
|
3346
|
-
var BoardCard =
|
|
3347
|
-
const ctx =
|
|
3769
|
+
var BoardCard = React12.forwardRef(function BoardCard2({ id, label, heldBy, settle, className, style, onClickCapture, children, ...rest }, ref) {
|
|
3770
|
+
const ctx = React12.useContext(BoardCtx);
|
|
3348
3771
|
const depth = useDepth({ heldBy, settle });
|
|
3349
3772
|
const carry = ctx?.carry;
|
|
3350
3773
|
const following = carry?.id === id;
|
|
3351
3774
|
const carried = following || ctx?.kb?.id === id;
|
|
3352
3775
|
const shift = carry?.shifts[id];
|
|
3353
3776
|
const transform = following ? `translate(${carry.dx}px, ${carry.dy}px)` : shift ? `translateY(${shift}px)` : void 0;
|
|
3354
|
-
return /* @__PURE__ */
|
|
3777
|
+
return /* @__PURE__ */ React12.createElement(
|
|
3355
3778
|
"div",
|
|
3356
3779
|
{
|
|
3357
3780
|
ref,
|