@photon-ai/pho-ui 4.25.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunks/{avatar-PgBOfszL.js → avatar-BJvgi8ON.js} +24 -30
- package/dist/chunks/avatar-BJvgi8ON.js.map +1 -0
- package/dist/chunks/{basic-page-DYBjCadG.js → basic-page-DSPzDKrZ.js} +80 -83
- package/dist/chunks/basic-page-DSPzDKrZ.js.map +1 -0
- package/dist/chunks/{box-search-CMl5bQ7Y.js → box-search-DD2EPtDy.js} +18 -19
- package/dist/chunks/box-search-DD2EPtDy.js.map +1 -0
- package/dist/chunks/{calendar-DDWITGo4.js → calendar-s-QRks1Z.js} +66 -69
- package/dist/chunks/calendar-s-QRks1Z.js.map +1 -0
- package/dist/chunks/{chat-D98GCjbe.js → chat-D6SGRahp.js} +226 -276
- package/dist/chunks/chat-D6SGRahp.js.map +1 -0
- package/dist/chunks/{checkbox-D8smFViR.js → checkbox-B3fVczYP.js} +2 -2
- package/dist/chunks/checkbox-B3fVczYP.js.map +1 -0
- package/dist/chunks/{close-button-Ck4rY1Fp.js → close-button-Bwv_OoCZ.js} +2 -2
- package/dist/chunks/close-button-Bwv_OoCZ.js.map +1 -0
- package/dist/chunks/{code-block-CthLWfxd.js → code-block-CiZWZBO2.js} +169 -238
- package/dist/chunks/code-block-CiZWZBO2.js.map +1 -0
- package/dist/chunks/copy-button-DNNZu6r4.js +69 -0
- package/dist/chunks/copy-button-DNNZu6r4.js.map +1 -0
- package/dist/chunks/{data-table-C1tLUdw0.js → data-table-CshUlqIu.js} +11 -12
- package/dist/chunks/data-table-CshUlqIu.js.map +1 -0
- package/dist/chunks/{date-picker-D-sWo3i8.js → date-picker-BaAkim2u.js} +126 -151
- package/dist/chunks/date-picker-BaAkim2u.js.map +1 -0
- package/dist/chunks/{description-list-DcTvBHzI.js → description-list-VTNz1MmJ.js} +2 -2
- package/dist/chunks/{description-list-DcTvBHzI.js.map → description-list-VTNz1MmJ.js.map} +1 -1
- package/dist/chunks/{dialog-H72fZGtf.js → dialog-C116Qr0w.js} +2 -2
- package/dist/chunks/{dialog-H72fZGtf.js.map → dialog-C116Qr0w.js.map} +1 -1
- package/dist/chunks/{filter-bar-D_sBAT5Y.js → filter-bar-DI5JO1Cd.js} +63 -72
- package/dist/chunks/filter-bar-DI5JO1Cd.js.map +1 -0
- package/dist/chunks/{ghost-search-CMUI2UH0.js → ghost-search-DhADxaWi.js} +11 -12
- package/dist/chunks/ghost-search-DhADxaWi.js.map +1 -0
- package/dist/chunks/icons-eq5FZ3Yc.js +1254 -0
- package/dist/chunks/icons-eq5FZ3Yc.js.map +1 -0
- package/dist/chunks/{input-DWnb33UF.js → input-hrrPhzXp.js} +37 -56
- package/dist/chunks/input-hrrPhzXp.js.map +1 -0
- package/dist/chunks/{select-Dux2SBVc.js → select-DlyDd7AB.js} +10 -10
- package/dist/chunks/select-DlyDd7AB.js.map +1 -0
- package/dist/chunks/{sidebar-ttBkgGRh.js → sidebar-DTRcoxrB.js} +95 -111
- package/dist/chunks/sidebar-DTRcoxrB.js.map +1 -0
- package/dist/chunks/{toast-Cbnn8lcA.js → toast-Btwu5Kjk.js} +7 -7
- package/dist/chunks/toast-Btwu5Kjk.js.map +1 -0
- package/dist/chunks/{trace-ClMpG82z.js → trace-CKYAff2U.js} +498 -607
- package/dist/chunks/trace-CKYAff2U.js.map +1 -0
- package/dist/components/avatar.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/chat.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/code-block.js +1 -1
- package/dist/components/command.js +36 -37
- package/dist/components/command.js.map +1 -1
- package/dist/components/copy-button.js +1 -1
- package/dist/components/data-table.js +2 -2
- package/dist/components/date-picker.js +1 -1
- package/dist/components/description-list.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/error.js +252 -11
- package/dist/components/error.js.map +1 -0
- package/dist/components/filter-bar.js +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/notification.js +27 -34
- package/dist/components/notification.js.map +1 -1
- package/dist/components/phone-input.js +3 -4
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/scope.js +52 -53
- package/dist/components/scope.js.map +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/theme-toggle.js +69 -95
- package/dist/components/theme-toggle.js.map +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/trace.js +1 -1
- package/dist/icons.js +235 -78
- package/dist/icons.js.map +1 -1
- package/dist/index.js +158 -158
- package/dist/sections/basic-page.js +2 -2
- package/dist/sections/sidebar.js +1 -1
- package/dist/src/components/avatar/avatar.d.ts +1 -1
- package/dist/src/components/notification/notification.d.ts +2 -2
- package/dist/src/components/trace/decorations.d.ts +3 -3
- package/dist/src/icons/index.d.ts +1 -0
- package/dist/src/icons/photon/icons.d.ts +315 -0
- package/dist/src/icons/photon/index.d.ts +2 -0
- package/dist/src/icons/photon/photon-icon.d.ts +51 -0
- package/package.json +5 -3
- package/src/styles/fonts.css +2 -1
- package/src/styles/theme.css +3 -1
- package/dist/chunks/IconArrowUpRight-OK8Fp0KQ.js +0 -14
- package/dist/chunks/IconArrowUpRight-OK8Fp0KQ.js.map +0 -1
- package/dist/chunks/IconCheck-DwSMn1wK.js +0 -11
- package/dist/chunks/IconCheck-DwSMn1wK.js.map +0 -1
- package/dist/chunks/IconChevronDown-Cd68NnX2.js +0 -11
- package/dist/chunks/IconChevronDown-Cd68NnX2.js.map +0 -1
- package/dist/chunks/IconChevronLeft-CptqhdxO.js +0 -11
- package/dist/chunks/IconChevronLeft-CptqhdxO.js.map +0 -1
- package/dist/chunks/IconChevronRight-BNkXCTk6.js +0 -11
- package/dist/chunks/IconChevronRight-BNkXCTk6.js.map +0 -1
- package/dist/chunks/IconChevronUp-Bxllwz8J.js +0 -11
- package/dist/chunks/IconChevronUp-Bxllwz8J.js.map +0 -1
- package/dist/chunks/IconInfoCircle-CTAynhe8.js +0 -21
- package/dist/chunks/IconInfoCircle-CTAynhe8.js.map +0 -1
- package/dist/chunks/IconSearch-DkcWWZ1H.js +0 -14
- package/dist/chunks/IconSearch-DkcWWZ1H.js.map +0 -1
- package/dist/chunks/IconX-DnPlFC68.js +0 -14
- package/dist/chunks/IconX-DnPlFC68.js.map +0 -1
- package/dist/chunks/avatar-PgBOfszL.js.map +0 -1
- package/dist/chunks/basic-page-DYBjCadG.js.map +0 -1
- package/dist/chunks/box-search-CMl5bQ7Y.js.map +0 -1
- package/dist/chunks/calendar-DDWITGo4.js.map +0 -1
- package/dist/chunks/chat-D98GCjbe.js.map +0 -1
- package/dist/chunks/checkbox-D8smFViR.js.map +0 -1
- package/dist/chunks/close-button-Ck4rY1Fp.js.map +0 -1
- package/dist/chunks/code-block-CthLWfxd.js.map +0 -1
- package/dist/chunks/copy-button-BLvirhXk.js +0 -76
- package/dist/chunks/copy-button-BLvirhXk.js.map +0 -1
- package/dist/chunks/data-table-C1tLUdw0.js.map +0 -1
- package/dist/chunks/date-picker-D-sWo3i8.js.map +0 -1
- package/dist/chunks/error-BT71wcUd.js +0 -270
- package/dist/chunks/error-BT71wcUd.js.map +0 -1
- package/dist/chunks/filter-bar-D_sBAT5Y.js.map +0 -1
- package/dist/chunks/ghost-search-CMUI2UH0.js.map +0 -1
- package/dist/chunks/input-DWnb33UF.js.map +0 -1
- package/dist/chunks/select-Dux2SBVc.js.map +0 -1
- package/dist/chunks/sidebar-ttBkgGRh.js.map +0 -1
- package/dist/chunks/toast-Cbnn8lcA.js.map +0 -1
- package/dist/chunks/trace-ClMpG82z.js.map +0 -1
package/dist/components/scope.js
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
import { t as d } from "../chunks/cn-CPbhpG1q.js";
|
|
3
3
|
import { revealIn as st } from "../motion.js";
|
|
4
4
|
import { u as lt } from "../chunks/button-KM0lAQ4x.js";
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import { r as ce } from "../chunks/checkbox-D8smFViR.js";
|
|
5
|
+
import { M as it, j as ye } from "../chunks/icons-eq5FZ3Yc.js";
|
|
6
|
+
import { t as ct } from "../chunks/close-button-Bwv_OoCZ.js";
|
|
7
|
+
import { r as ce } from "../chunks/checkbox-B3fVczYP.js";
|
|
9
8
|
import { t as I } from "../chunks/skeleton-CqZlGphn.js";
|
|
10
|
-
import { t as dt } from "../chunks/ghost-search-
|
|
9
|
+
import { t as dt } from "../chunks/ghost-search-DhADxaWi.js";
|
|
11
10
|
import { t as A } from "../chunks/tooltip-4J1PUJmB.js";
|
|
12
|
-
import { t as p } from "../chunks/select-
|
|
11
|
+
import { t as p } from "../chunks/select-DlyDd7AB.js";
|
|
13
12
|
import { useEffect as Ne, useId as ut, useLayoutEffect as pt, useMemo as G, useRef as S, useState as X } from "react";
|
|
14
13
|
import { jsx as n, jsxs as a } from "react/jsx-runtime";
|
|
15
14
|
import { AnimatePresence as H, motion as b, useReducedMotion as ht } from "motion/react";
|
|
16
|
-
import { Field as
|
|
17
|
-
import { Tooltip as
|
|
15
|
+
import { Field as ft } from "@base-ui/react/field";
|
|
16
|
+
import { Tooltip as mt } from "@base-ui/react/tooltip";
|
|
18
17
|
var vt = "group/scope relative w-full min-w-0 overflow-clip rounded-base border border-pho-secondary bg-pho-primary [--scope-inset:var(--choice-card-inset,0.75rem)]", Se = "px-[var(--scope-inset)]", gt = "flex min-h-11 items-center gap-3 border-b border-pho-secondary px-[var(--scope-inset)]", bt = "text-pho-secondary hover:bg-pho-ghost-hover hover:text-pho-secondary-hover data-[popup-open]:bg-pho-ghost-hover outline-pho-brand shrink-0 gap-1.5 rounded-full py-1.5 pr-2 pl-3 font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-solid", de = "custom", Ce = "grid auto-rows-max grid-cols-1 group-data-[wide]/scope:grid-cols-[fit-content(45%)_minmax(0,1fr)] group-data-[wide]/scope:gap-x-4", Oe = "col-span-full grid auto-rows-max grid-cols-subgrid border-t border-pho-secondary first:border-t-0", Ee = "group col-span-full flex min-w-0 cursor-pointer flex-col px-[var(--scope-inset)] py-2 transition-colors select-none hover:bg-pho-primary-hover group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center data-[disabled]:cursor-not-allowed data-[disabled]:hover:bg-transparent", wt = "col-span-full flex min-w-0 flex-col px-[var(--scope-inset)] py-2 group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center", ke = "group col-span-full flex h-8 min-w-0 cursor-pointer items-center gap-2 border-b border-pho-secondary bg-pho-page px-[var(--scope-inset)] text-xs font-medium text-pho-secondary select-none data-[disabled]:cursor-not-allowed", Ie = "line-clamp-2 min-w-0 pl-6 text-xs text-pho-description group-data-[wide]/scope:block group-data-[wide]/scope:truncate group-data-[wide]/scope:pl-0", Re = "flex w-full min-w-0 items-center gap-3 px-[var(--scope-inset)] py-2.5 text-left outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-2", xt = 34, yt = 18;
|
|
19
18
|
function Nt(r) {
|
|
20
|
-
const [s,
|
|
19
|
+
const [s, f] = X({
|
|
21
20
|
wide: !0,
|
|
22
21
|
roomy: !0
|
|
23
22
|
}), i = S({
|
|
@@ -38,7 +37,7 @@ function Nt(r) {
|
|
|
38
37
|
wide: W >= xt * L,
|
|
39
38
|
roomy: W >= yt * L
|
|
40
39
|
};
|
|
41
|
-
|
|
40
|
+
f((w) => w.wide === u.wide && w.roomy === u.roomy ? w : u);
|
|
42
41
|
};
|
|
43
42
|
c();
|
|
44
43
|
const _ = new ResizeObserver(c);
|
|
@@ -49,14 +48,14 @@ function Nt(r) {
|
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
function St(r) {
|
|
52
|
-
const s = [],
|
|
51
|
+
const s = [], f = /* @__PURE__ */ new Map();
|
|
53
52
|
for (const i of r) {
|
|
54
53
|
const o = i.group ?? null;
|
|
55
|
-
let c =
|
|
54
|
+
let c = f.get(o);
|
|
56
55
|
c || (c = {
|
|
57
56
|
label: o,
|
|
58
57
|
items: []
|
|
59
|
-
},
|
|
58
|
+
}, f.set(o, c), s.push(c)), c.items.push(i);
|
|
60
59
|
}
|
|
61
60
|
return [...s.filter((i) => i.label === null), ...s.filter((i) => i.label !== null)];
|
|
62
61
|
}
|
|
@@ -67,24 +66,24 @@ function Ct(r) {
|
|
|
67
66
|
return ze(r).split(/\s+/).filter(Boolean);
|
|
68
67
|
}
|
|
69
68
|
function Pe(r, ...s) {
|
|
70
|
-
const
|
|
71
|
-
return r.every((i) =>
|
|
69
|
+
const f = ze(s.filter(Boolean).join(" "));
|
|
70
|
+
return r.every((i) => f.includes(i));
|
|
72
71
|
}
|
|
73
72
|
function $e(r) {
|
|
74
73
|
return r.label ?? r.value;
|
|
75
74
|
}
|
|
76
75
|
function _e(r, s) {
|
|
77
76
|
if (r.length !== s.length) return !1;
|
|
78
|
-
const
|
|
79
|
-
return s.every((i) =>
|
|
77
|
+
const f = new Set(r);
|
|
78
|
+
return s.every((i) => f.has(i));
|
|
80
79
|
}
|
|
81
|
-
function J(r, s,
|
|
80
|
+
function J(r, s, f = "fade") {
|
|
82
81
|
return {
|
|
83
82
|
...r,
|
|
84
83
|
initial: {
|
|
85
84
|
...r.initial,
|
|
86
85
|
height: s,
|
|
87
|
-
opacity:
|
|
86
|
+
opacity: f === "down" ? 1 : 0
|
|
88
87
|
},
|
|
89
88
|
exit: { opacity: 0 }
|
|
90
89
|
};
|
|
@@ -94,53 +93,53 @@ function Ot(r) {
|
|
|
94
93
|
const s = r.closest("[data-scope-description]");
|
|
95
94
|
return s == null ? !1 : s.scrollWidth > s.clientWidth + 1 || s.scrollHeight > s.clientHeight + 1;
|
|
96
95
|
}
|
|
97
|
-
function Et({ items: r, value: s, defaultValue:
|
|
98
|
-
const [De, Ae] = X(
|
|
99
|
-
for (const e of O) e !== o?.value && !
|
|
100
|
-
const k = Z.current.filter((e) => !
|
|
96
|
+
function Et({ items: r, value: s, defaultValue: f, onValueChange: i, all: o, presets: c, placeholder: _ = "Search", collapsible: C = !1, open: z, defaultOpen: L = !1, onOpenChange: W, loading: u = !1, disabled: w = !1, className: Me, ref: B, ...Te }) {
|
|
97
|
+
const [De, Ae] = X(f ?? []), O = s ?? De, [Ge, He] = X(L), E = C ? z ?? Ge : !0, [F, M] = X(""), Le = ht(), ue = S(null), { wide: We, roomy: Be, heights: V } = Nt(ue), v = ut(), pe = `${v}-list`, he = S(null), fe = S(null), j = S(null), me = G(() => mt.createHandle(), []), q = G(() => St(r), [r]), U = G(() => new Set(r.map((e) => e.value)), [r]), Fe = G(() => new Map(r.map((e, t) => [e.value, t])), [r]), Ve = G(() => new Map(q.map((e, t) => [e.label, t])), [q]), Z = S([]);
|
|
98
|
+
for (const e of O) e !== o?.value && !U.has(e) && !Z.current.includes(e) && Z.current.push(e);
|
|
99
|
+
const k = Z.current.filter((e) => !U.has(e)), m = o?.value, T = new Set(O), N = m !== void 0 && T.has(m), K = (e) => N ? U.has(e) : T.has(e), R = r.filter((e) => K(e.value)).length, ee = k.filter((e) => T.has(e)).length, Y = (e) => {
|
|
101
100
|
s === void 0 && Ae(e), i?.(e);
|
|
102
|
-
}, te = (e) => Y([...r.filter((t) => e.has(t.value)).map((t) => t.value), ...k.filter((t) => e.has(t))]),
|
|
103
|
-
const l =
|
|
101
|
+
}, te = (e) => Y([...r.filter((t) => e.has(t.value)).map((t) => t.value), ...k.filter((t) => e.has(t))]), je = () => N ? new Set(r.map((e) => e.value)) : new Set(O.filter((e) => e !== m)), ne = (e, t) => {
|
|
102
|
+
const l = je();
|
|
104
103
|
for (const h of e) t ? l.add(h) : l.delete(h);
|
|
105
104
|
te(l);
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
}, re = (e) => e.filter((t) => t ===
|
|
105
|
+
}, qe = (e) => {
|
|
106
|
+
m === void 0 ? ne(r.map((t) => t.value), e) : e ? Y([m]) : te(new Set(r.map((t) => t.value)));
|
|
107
|
+
}, re = (e) => e.filter((t) => t === m || U.has(t)), P = u || r.length === 0 ? void 0 : c?.find((e) => {
|
|
109
108
|
const t = re(e.value);
|
|
110
109
|
return t.length > 0 && _e(t, re(O));
|
|
111
|
-
}),
|
|
110
|
+
}), Ue = (e) => {
|
|
112
111
|
const t = re(e.value);
|
|
113
|
-
|
|
112
|
+
m !== void 0 && t.includes(m) ? Y([m]) : te(/* @__PURE__ */ new Set([...t, ...k.filter((l) => T.has(l))]));
|
|
114
113
|
}, ve = (e) => {
|
|
115
114
|
z === void 0 && He(e), W?.(e);
|
|
116
115
|
}, Ke = () => {
|
|
117
|
-
|
|
116
|
+
j.current = "search", ve(!0);
|
|
118
117
|
}, Ye = () => {
|
|
119
|
-
|
|
118
|
+
j.current = "summary", M(""), ve(!1);
|
|
120
119
|
}, oe = S(O);
|
|
121
120
|
oe.current = O;
|
|
122
121
|
const ge = S(E ? O : null);
|
|
123
122
|
Ne(() => {
|
|
124
|
-
ge.current = E ? oe.current : null, E ||
|
|
123
|
+
ge.current = E ? oe.current : null, E || M("");
|
|
125
124
|
}, [E]);
|
|
126
125
|
const be = () => {
|
|
127
126
|
const e = ge.current;
|
|
128
127
|
e != null && !_e(e, oe.current) && Y([...e]), Ye();
|
|
129
128
|
};
|
|
130
129
|
Ne(() => {
|
|
131
|
-
const e =
|
|
130
|
+
const e = j.current;
|
|
132
131
|
if (e == null) return;
|
|
133
|
-
|
|
132
|
+
j.current = null;
|
|
134
133
|
let t = 0, l = 0;
|
|
135
134
|
const h = () => {
|
|
136
|
-
const x = e === "search" ? he.current :
|
|
135
|
+
const x = e === "search" ? he.current : fe.current;
|
|
137
136
|
x != null && (x.focus({ preventScroll: !0 }), document.activeElement !== x && l++ < 5 && (t = requestAnimationFrame(h)));
|
|
138
137
|
};
|
|
139
138
|
return t = requestAnimationFrame(h), () => cancelAnimationFrame(t);
|
|
140
139
|
}, [E]);
|
|
141
140
|
const Qe = (e) => {
|
|
142
|
-
e.key === "Enter" && e.preventDefault(), e.key === "Escape" && (F !== "" ? (e.preventDefault(),
|
|
143
|
-
}, ae = Ct(F), Q = ae.length > 0, we =
|
|
141
|
+
e.key === "Enter" && e.preventDefault(), e.key === "Escape" && (F !== "" ? (e.preventDefault(), M("")) : C && !w && (e.preventDefault(), be()));
|
|
142
|
+
}, ae = Ct(F), Q = ae.length > 0, we = q.map((e) => ({
|
|
144
143
|
...e,
|
|
145
144
|
items: Q ? e.items.filter((t) => Pe(ae, e.label, t.value, t.label, t.description)) : e.items
|
|
146
145
|
})).filter((e) => e.items.length > 0), se = Q ? k.filter((e) => Pe(ae, e)) : k, D = N || r.length === 0 ? null : `${R} of ${r.length}`, le = (() => {
|
|
@@ -152,16 +151,16 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
152
151
|
title: P.label,
|
|
153
152
|
detail: P.description ?? D ?? ""
|
|
154
153
|
};
|
|
155
|
-
if (o &&
|
|
154
|
+
if (o && m === void 0 && r.length > 0 && R === r.length && ee === 0) return {
|
|
156
155
|
title: o.label,
|
|
157
156
|
detail: o.description ?? D ?? ""
|
|
158
157
|
};
|
|
159
158
|
const e = [];
|
|
160
|
-
for (const t of
|
|
159
|
+
for (const t of q) {
|
|
161
160
|
const l = t.items.filter((h) => K(h.value));
|
|
162
161
|
t.label !== null && t.items.length > 1 && l.length === t.items.length ? e.push(t.label) : e.push(...l.map($e));
|
|
163
162
|
}
|
|
164
|
-
return e.push(...k.filter((t) =>
|
|
163
|
+
return e.push(...k.filter((t) => T.has(t))), {
|
|
165
164
|
title: e.length > 0 ? e.join(", ") : "None",
|
|
166
165
|
detail: D ?? ""
|
|
167
166
|
};
|
|
@@ -187,7 +186,7 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
187
186
|
children: $e(e)
|
|
188
187
|
})]
|
|
189
188
|
}), e.description ? /* @__PURE__ */ n(A.Trigger, {
|
|
190
|
-
handle:
|
|
189
|
+
handle: me,
|
|
191
190
|
payload: e.description,
|
|
192
191
|
render: /* @__PURE__ */ n("span", {
|
|
193
192
|
id: x,
|
|
@@ -260,12 +259,12 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
260
259
|
className: "flex min-w-0 items-center gap-2",
|
|
261
260
|
children: [/* @__PURE__ */ n(ce, {
|
|
262
261
|
size: "sm",
|
|
263
|
-
checked:
|
|
264
|
-
indeterminate:
|
|
262
|
+
checked: m === void 0 ? r.length > 0 && R === r.length : N,
|
|
263
|
+
indeterminate: m === void 0 ? R > 0 && R < r.length : !N && R + ee > 0,
|
|
265
264
|
disabled: $ || N && r.length === 0,
|
|
266
265
|
"aria-labelledby": `${v}-all`,
|
|
267
266
|
"aria-describedby": o.description ? `${v}-all-description` : void 0,
|
|
268
|
-
onCheckedChange: (e) =>
|
|
267
|
+
onCheckedChange: (e) => qe(e)
|
|
269
268
|
}), /* @__PURE__ */ n("span", {
|
|
270
269
|
id: `${v}-all`,
|
|
271
270
|
className: "text-pho-primary truncate text-base font-medium",
|
|
@@ -345,7 +344,7 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
345
344
|
children: /* @__PURE__ */ n(I, { className: d("h-3 max-w-full", e.text) })
|
|
346
345
|
})]
|
|
347
346
|
}, t))
|
|
348
|
-
}, "bones"), rt = c != null && c.length > 0 ? /* @__PURE__ */ n(
|
|
347
|
+
}, "bones"), rt = c != null && c.length > 0 ? /* @__PURE__ */ n(ft.Root, {
|
|
349
348
|
className: "contents",
|
|
350
349
|
children: /* @__PURE__ */ a(p.Root, {
|
|
351
350
|
items: [...c.map((e, t) => ({
|
|
@@ -358,7 +357,7 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
358
357
|
value: P ? `preset:${c.indexOf(P)}` : de,
|
|
359
358
|
onValueChange: (e) => {
|
|
360
359
|
const t = c[Number(String(e).slice(7))];
|
|
361
|
-
t != null && t !== P &&
|
|
360
|
+
t != null && t !== P && Ue(t);
|
|
362
361
|
},
|
|
363
362
|
disabled: w || u,
|
|
364
363
|
children: [/* @__PURE__ */ a(p.Trigger, {
|
|
@@ -397,8 +396,8 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
397
396
|
/* @__PURE__ */ n(dt, {
|
|
398
397
|
ref: he,
|
|
399
398
|
value: F,
|
|
400
|
-
onChange:
|
|
401
|
-
onClear: () =>
|
|
399
|
+
onChange: M,
|
|
400
|
+
onClear: () => M(""),
|
|
402
401
|
onKeyDown: Qe,
|
|
403
402
|
placeholder: _,
|
|
404
403
|
"aria-label": _,
|
|
@@ -450,7 +449,7 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
450
449
|
className: Re,
|
|
451
450
|
children: xe
|
|
452
451
|
}) : /* @__PURE__ */ a("button", {
|
|
453
|
-
ref:
|
|
452
|
+
ref: fe,
|
|
454
453
|
type: "button",
|
|
455
454
|
"aria-expanded": !1,
|
|
456
455
|
className: d(Re, "group hover:bg-pho-primary-hover cursor-pointer transition-colors"),
|
|
@@ -473,8 +472,8 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
473
472
|
"data-open": E ? "" : void 0,
|
|
474
473
|
"data-wide": We ? "" : void 0,
|
|
475
474
|
"data-roomy": Be ? "" : void 0,
|
|
476
|
-
className: d(vt,
|
|
477
|
-
...
|
|
475
|
+
className: d(vt, Me),
|
|
476
|
+
...Te,
|
|
478
477
|
ref: (e) => {
|
|
479
478
|
ue.current = e, typeof B == "function" ? B(e) : B != null && (B.current = e);
|
|
480
479
|
},
|
|
@@ -483,7 +482,7 @@ function Et({ items: r, value: s, defaultValue: m, onValueChange: i, all: o, pre
|
|
|
483
482
|
mode: "popLayout",
|
|
484
483
|
children: E ? ot : at
|
|
485
484
|
}), /* @__PURE__ */ n(A.Root, {
|
|
486
|
-
handle:
|
|
485
|
+
handle: me,
|
|
487
486
|
onOpenChange: (e, t) => {
|
|
488
487
|
e && !Ot(t.event?.target) && t.cancel();
|
|
489
488
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","names":["BaseTooltip","Tooltip","BaseField","cn","revealIn","buttonVariants","IconCheck","IconChevronDown","CloseButton","Checkbox","Skeleton","GhostSearch","Tooltip$1","Select","useEffect","useId","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","AnimatePresence","motion","useReducedMotion","Field","Tooltip","SCOPE_SURFACE","SCOPE_INSET","SCOPE_SEARCH_ROW","SCOPE_PRESET_TRIGGER","CUSTOM","SCOPE_LIST","SCOPE_GROUP","SCOPE_ROW","SCOPE_BONE_ROW","SCOPE_GROUP_BAND","SCOPE_DESCRIPTION","SCOPE_SUMMARY","WIDE_REM","ROOMY_REM","useCardSize","ref","size","setSize","heights","node","measure","list","bones","rem","width","next","current","observer","groupItems","items","groups","byLabel","item","label","group","normalize","text","tokenize","query","matches","tokens","fields","haystack","token","nameOf","sameSelection","a","b","held","value","takeOver","reveal","from","ink","isClipped","target","Scope","valueProp","defaultValue","onValueChange","all","presets","placeholder","collapsible","openProp","defaultOpen","onOpenChange","loading","disabled","className","props","innerValue","setInnerValue","innerOpen","setInnerOpen","open","setQuery","reduceMotion","cardRef","wide","roomy","baseId","listId","searchRef","summaryRef","focusNext","handle","offered","position","index","groupPosition","retiredSeen","retired","wildcard","selected","everything","isOn","offeredOn","retiredOn","setValue","emit","explicit","toggle","values","on","toggleAll","named","preset","option","its","choosePreset","setOpen","unfold","fold","valueRef","openedWith","dismiss","before","frame","tries","attempt","onSearchKeyDown","event","searching","shownGroups","shownRetired","count","summary","names","rowDisabled","renderRow","retiredRow","rowId","nameId","descriptionId","renderGroup","labelId","members","checked","retiredGroup","allRow","nothing","bone","presetPicker","picker","summaryText","folded","details","payload"],"sources":["../../src/components/scope/scope.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ComponentProps,\n type KeyboardEvent,\n type Ref,\n type RefObject,\n} from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { IconCheck, IconChevronDown } from \"@tabler/icons-react\";\nimport { CloseButton, buttonVariants } from \"../button\";\nimport { Checkbox } from \"../checkbox\";\nimport { Select } from \"../select\";\nimport { Skeleton } from \"../skeleton\";\nimport { Tooltip } from \"../tooltip\";\nimport { revealIn } from \"../../motion\";\nimport { cn } from \"../../utils/cn\";\nimport { GhostSearch } from \"../../utils/ghost-search\";\n\n/**\n * Scope — pick what something covers out of a catalog: the events a webhook\n * destination receives, the permissions an app or key holds. A searchable,\n * grouped checklist with a catch-all row; `collapsible` folds it to a\n * two-line summary for a resource that already exists, opening on click.\n */\n\nexport interface ScopeItem {\n /**\n * What the selection holds — an event type, a permission id. It is also\n * the row's name unless `label` says otherwise.\n */\n value: string;\n /** The row's name, when it shouldn't be the value itself. */\n label?: string;\n /** One line on what it covers. Searched along with the name. */\n description?: string;\n /**\n * The group it files under — the resource, the namespace. Groups keep\n * the order they first appear in; items without one come first.\n */\n group?: string;\n}\n\nexport interface ScopeAll {\n /** The row's name — `All events`. */\n label: string;\n /** What choosing it means — `Every current and future event.` */\n description?: string;\n /**\n * A wildcard the selection holds in place of the items — `*`. With it,\n * the row stands for every item, now and later: choosing it sets the\n * selection to `[value]`, and leaving it spells every item out by name so\n * the reader prunes from there, never from nothing. Without it, the row\n * selects every item listed.\n */\n value?: string;\n}\n\nexport interface ScopePreset {\n /**\n * Its name: in the search row's picker, and on a folded list whose\n * selection is exactly this one — `Read only`.\n */\n label: string;\n /** What it covers, under its name in the picker and on the folded list. */\n description?: string;\n /** The selection it stands for. */\n value: readonly string[];\n}\n\nexport interface ScopeProps extends Omit<\n ComponentProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> {\n /** The catalog — everything that can be picked, in display order. */\n items: readonly ScopeItem[];\n /** The selected values, controlled. */\n value?: readonly string[];\n /** The selected values at first, uncontrolled. */\n defaultValue?: readonly string[];\n /**\n * Called with the next selection, in catalog order (values no longer in\n * the catalog follow in the order they were held).\n */\n onValueChange?: (value: string[]) => void;\n /** The catch-all row at the top. Leave it out for no such row. */\n all?: ScopeAll;\n /**\n * Named selections to start from, picked at the search row's end. One\n * chosen sets the list to its values; values the catalog doesn't offer\n * stay as they are. A selection that is exactly a preset goes by its\n * name there and on the folded list; any other reads Custom.\n */\n presets?: readonly ScopePreset[];\n /** The search field's placeholder, which also names it. @default \"Search\" */\n placeholder?: string;\n /**\n * Fold to a two-line summary of the selection, opening to the full list\n * on click — for a resource that already exists, where the scope is read\n * far more often than it changes. The page saves the change (its \"Save\n * changes\" below the card) and folds the list through `open`; the ✕ in\n * the search row, or `Escape` on an empty search, drops the edit: the\n * selection goes back to what it was when the list opened, and folds.\n */\n collapsible?: boolean;\n /** Whether the collapsible list is open, controlled. */\n open?: boolean;\n /** Whether the collapsible list starts open. @default false */\n defaultOpen?: boolean;\n /** Called when the collapsible list opens or folds. */\n onOpenChange?: (open: boolean) => void;\n /** The catalog is on its way: bones in place of rows. */\n loading?: boolean;\n /**\n * Read-only: the list can be searched but not changed, and a folded one\n * stays folded. Held open by `open` (a save in flight), nothing in it\n * changes the selection, the ✕ and Escape included.\n */\n disabled?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\n/* ------------------------------- class map ------------------------------- */\n\n/**\n * The card: the BasicPage card's stroke, corner, and fill. `overflow-clip`\n * rounds a hovered edge row into the corners without making the card a\n * scroll container. The rows lay out by the card's width, not the\n * viewport's: it is measured (`data-wide`, `data-roomy`) rather than made a\n * CSS query container, because Chromium drops a query container's\n * children from layout when a `Reveal` mounts beside it in a Base UI form\n * (a BasicPage `Footer` appearing under the card left it 2px tall).\n *\n * Positioned: a face (or the bones) leaving steps out of the flow and fades\n * where it stood, clipped by the card as the one arriving takes its place.\n *\n * Its words stand `--scope-inset` in from its edges, which is the page's\n * choice inset (the one `RadioCard` and `CheckboxCard` pad by): 20px when\n * the card stands on a `BasicPage.Stack`, on the headings' line like any\n * card's rows; 12px inside a sheet, a card, or a dialog, where it is a\n * field among fields and its words line up with theirs.\n */\nconst SCOPE_SURFACE =\n \"group/scope relative w-full min-w-0 overflow-clip rounded-base border border-pho-secondary bg-pho-primary [--scope-inset:var(--choice-card-inset,0.75rem)]\";\n\n/** The side padding every row of the card shares. */\nconst SCOPE_INSET = \"px-[var(--scope-inset)]\";\n\n/**\n * The search, the card's first row: no box of its own. The magnifier stands\n * on the checkbox column and the query on the names' line, the count at the\n * row's end and, on a collapsible list, the ✕ that drops the edit after it,\n * its glyph as far in from the right edge as the magnifier's from the left.\n * 44px with the hairline below, the DataTable toolbar band's height.\n */\nconst SCOPE_SEARCH_ROW =\n \"flex min-h-11 items-center gap-3 border-b border-pho-secondary px-[var(--scope-inset)]\";\n\n/**\n * The preset picker at the search row's end: a `Select` on its inline face,\n * dressed as a ghost pill like the ✕ beside it — no box in the band, as\n * DataTable's toolbar filters. The ✕'s geometry: 8px round the chevron,\n * the pill hanging that far past the words' edge so the chevron mirrors the\n * magnifier's inset, never onto the card's border; the label side 4px\n * wider, a Button's icon-side tuck. It draws its own focus ring, the row\n * having none to lend it.\n */\nconst SCOPE_PRESET_TRIGGER =\n \"text-pho-secondary hover:bg-pho-ghost-hover hover:text-pho-secondary-hover data-[popup-open]:bg-pho-ghost-hover outline-pho-brand shrink-0 gap-1.5 rounded-full py-1.5 pr-2 pl-3 font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-solid\";\n\n/** The picker's value for a selection no preset names. */\nconst CUSTOM = \"custom\";\n\n/**\n * Two columns once the card is wide enough: the names, as wide as the\n * longest (never past 45%), then the descriptions on one shared edge.\n * Narrower, each row stacks its description under its name.\n *\n * Every row track is as tall as its row (`auto-rows-max`). A row clips for\n * its own reveal, which lets an `auto` track shrink to nothing: while the\n * list's height opens (taking over from the bones) the grid would squeeze\n * every row at once and each would open from its middle. At their own\n * height the rows stand still and the edge uncovers them from the top.\n */\nconst SCOPE_LIST =\n \"grid auto-rows-max grid-cols-1 group-data-[wide]/scope:grid-cols-[fit-content(45%)_minmax(0,1fr)] group-data-[wide]/scope:gap-x-4\";\n\n/** A group: its band and its rows, on the list's columns and track rule. */\nconst SCOPE_GROUP =\n \"col-span-full grid auto-rows-max grid-cols-subgrid border-t border-pho-secondary first:border-t-0\";\n\n/**\n * One row: 36px on the wide layout — a 20px line and 8px either side.\n * Stacked, the description sits flush under the name, so the row sets no\n * gap of its own: the columns' gap is the list's, and a subgrid that set\n * its own would let a long name run into its description.\n */\nconst SCOPE_ROW =\n \"group col-span-full flex min-w-0 cursor-pointer flex-col px-[var(--scope-inset)] py-2 transition-colors select-none hover:bg-pho-primary-hover group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center data-[disabled]:cursor-not-allowed data-[disabled]:hover:bg-transparent\";\n\n/** A bone row: a row's layout, nothing to hover or click. */\nconst SCOPE_BONE_ROW =\n \"col-span-full flex min-w-0 flex-col px-[var(--scope-inset)] py-2 group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center\";\n\n/**\n * A group's band — DataTable's section wash, thinner than the rows it\n * heads, with the group's own checkbox on the rows' checkbox column.\n */\nconst SCOPE_GROUP_BAND =\n \"group col-span-full flex h-8 min-w-0 cursor-pointer items-center gap-2 border-b border-pho-secondary bg-pho-page px-[var(--scope-inset)] text-xs font-medium text-pho-secondary select-none data-[disabled]:cursor-not-allowed\";\n\n/**\n * A description: under the name (two lines at most) on the narrow layout,\n * one line in its own column on the wide one — the rest opens on hover.\n */\nconst SCOPE_DESCRIPTION =\n \"line-clamp-2 min-w-0 pl-6 text-xs text-pho-description group-data-[wide]/scope:block group-data-[wide]/scope:truncate group-data-[wide]/scope:pl-0\";\n\n/** The folded summary: two lines, the whole card its hit target. */\nconst SCOPE_SUMMARY =\n \"flex w-full min-w-0 items-center gap-3 px-[var(--scope-inset)] py-2.5 text-left outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-2\";\n\n/** Two columns (names, then descriptions) from this card width up. */\nconst WIDE_REM = 34;\n/** The count stands in the search row from this card width up. */\nconst ROOMY_REM = 18;\n\n/**\n * The card's width against the two breakpoints, measured before paint and\n * followed as it changes. Desktop-first until measured, so a server render\n * shows the common layout.\n *\n * Its heights ride along for the next swap: the face standing now (the\n * card's inner height), and the list or the bones, whichever shows. What\n * takes their place opens from there.\n */\nfunction useCardSize(ref: RefObject<HTMLElement | null>) {\n const [size, setSize] = useState({ wide: true, roomy: true });\n const heights = useRef({ face: 0, list: 0, bones: 0 });\n useLayoutEffect(() => {\n const node = ref.current;\n if (node == null) return;\n const measure = () => {\n heights.current.face = node.clientHeight;\n const list = node.querySelector<HTMLElement>(\"[data-scope-list]\");\n if (list != null) heights.current.list = list.offsetHeight;\n const bones = node.querySelector<HTMLElement>(\"[data-scope-bones]\");\n if (bones != null) heights.current.bones = bones.offsetHeight;\n const rem =\n parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n const width = node.getBoundingClientRect().width;\n const next = {\n wide: width >= WIDE_REM * rem,\n roomy: width >= ROOMY_REM * rem,\n };\n setSize((current) =>\n current.wide === next.wide && current.roomy === next.roomy\n ? current\n : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [ref]);\n return { ...size, heights };\n}\n\n/* -------------------------------- model --------------------------------- */\n\ninterface ScopeGroup {\n label: string | null;\n items: ScopeItem[];\n}\n\n/** Items by group, groups in first-appearance order, ungrouped first. */\nfunction groupItems(items: readonly ScopeItem[]): ScopeGroup[] {\n const groups: ScopeGroup[] = [];\n const byLabel = new Map<string | null, ScopeGroup>();\n for (const item of items) {\n const label = item.group ?? null;\n let group = byLabel.get(label);\n if (!group) {\n group = { label, items: [] };\n byLabel.set(label, group);\n groups.push(group);\n }\n group.items.push(item);\n }\n return [\n ...groups.filter((group) => group.label === null),\n ...groups.filter((group) => group.label !== null),\n ];\n}\n\n/**\n * Lowercase, with the separators ids are written in (`.`, `:`, `-`, `_`,\n * `/`) read as spaces — `call ended` finds `call.ended`.\n */\nfunction normalize(text: string): string {\n return text.toLowerCase().replace(/[.:\\-_/]/g, \" \");\n}\n\nfunction tokenize(query: string): string[] {\n return normalize(query).split(/\\s+/).filter(Boolean);\n}\n\n/** Every word of the query somewhere in the group, name, or description. */\nfunction matches(\n tokens: readonly string[],\n ...fields: (string | null | undefined)[]\n) {\n const haystack = normalize(fields.filter(Boolean).join(\" \"));\n return tokens.every((token) => haystack.includes(token));\n}\n\nfunction nameOf(item: ScopeItem): string {\n return item.label ?? item.value;\n}\n\n/** The same values, whatever their order. */\nfunction sameSelection(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const held = new Set(a);\n return b.every((value) => held.has(value));\n}\n\n/**\n * Reveal for a block taking another's place: it opens from the height the\n * other stood at rather than from none, while the other steps out of the\n * flow (`popLayout`) and fades where it stood. The card moves at its bottom\n * edge only, and what it loses rolls up under the top.\n *\n * `ink` is how the arriving block shows. Rows (the open face, the list)\n * come with their ink `down`, so the edge uncovers them from the top, one\n * after another. Faded in over the growth, the whole list would come up\n * at once, and a list that shows everywhere at once reads as opening from\n * the middle. A stand-in (the folded summary, the bones) `fade`s in where\n * it stands, crossing the block that leaves.\n */\nfunction takeOver(\n reveal: ReturnType<typeof revealIn>,\n from: number,\n ink: \"down\" | \"fade\" = \"fade\",\n) {\n return {\n ...reveal,\n initial: {\n ...reveal.initial,\n height: from,\n opacity: ink === \"down\" ? 1 : 0,\n },\n exit: { opacity: 0 },\n };\n}\n\n/** Whether a description shows whole, measured when the pointer asks. */\nfunction isClipped(target: EventTarget | null | undefined): boolean {\n if (!(target instanceof Element)) return false;\n const text = target.closest<HTMLElement>(\"[data-scope-description]\");\n if (text == null) return false;\n return (\n text.scrollWidth > text.clientWidth + 1 ||\n text.scrollHeight > text.clientHeight + 1\n );\n}\n\n/* ------------------------------- component ------------------------------- */\n\n/**\n * A searchable, grouped checklist for choosing what something covers.\n *\n * Every row is one line on a wide card — the name, then its description in\n * a second column that opens whole on hover when it doesn't fit. Groups are\n * thin tinted bands carrying a checkbox for the whole group (mixed when\n * partly chosen). The search matches names, descriptions, and group names,\n * word by word; while it holds a query the catch-all row steps aside and a\n * group's checkbox covers the rows it shows.\n *\n * With `collapsible`, the card rests as a summary — whole groups by name,\n * the rest by item, over a count — and opens in place, the search taking\n * focus, when clicked; its ✕ drops the edit and folds it back, the page's\n * own save below the card commits it. Values the catalog no longer offers keep a row\n * under \"No longer offered\": they can be removed, never added in bulk.\n */\nexport function Scope({\n items,\n value: valueProp,\n defaultValue,\n onValueChange,\n all,\n presets,\n placeholder = \"Search\",\n collapsible = false,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n loading = false,\n disabled = false,\n className,\n ref,\n ...props\n}: ScopeProps) {\n const [innerValue, setInnerValue] = useState<readonly string[]>(\n defaultValue ?? [],\n );\n const value = valueProp ?? innerValue;\n const [innerOpen, setInnerOpen] = useState(defaultOpen);\n const open = collapsible ? (openProp ?? innerOpen) : true;\n const [query, setQuery] = useState(\"\");\n\n const reduceMotion = useReducedMotion();\n const cardRef = useRef<HTMLDivElement | null>(null);\n const { wide, roomy, heights } = useCardSize(cardRef);\n const baseId = useId();\n const listId = `${baseId}-list`;\n const searchRef = useRef<HTMLInputElement | null>(null);\n const summaryRef = useRef<HTMLButtonElement | null>(null);\n // Where focus goes once the next face has mounted — set only by our own\n // controls, so a host flipping `open` doesn't pull focus around.\n const focusNext = useRef<\"search\" | \"summary\" | null>(null);\n const handle = useMemo(() => BaseTooltip.createHandle<string>(), []);\n\n const groups = useMemo(() => groupItems(items), [items]);\n const offered = useMemo(\n () => new Set(items.map((item) => item.value)),\n [items],\n );\n // Ids go by catalog position: values may hold characters an id shouldn't.\n const position = useMemo(\n () => new Map(items.map((item, index) => [item.value, index])),\n [items],\n );\n const groupPosition = useMemo(\n () => new Map(groups.map((group, index) => [group.label, index])),\n [groups],\n );\n\n // Values held that the catalog doesn't offer. Remembered while mounted,\n // so one unticked stays on the list and can be ticked back.\n const retiredSeen = useRef<string[]>([]);\n for (const held of value) {\n if (\n held !== all?.value &&\n !offered.has(held) &&\n !retiredSeen.current.includes(held)\n ) {\n retiredSeen.current.push(held);\n }\n }\n const retired = retiredSeen.current.filter((held) => !offered.has(held));\n\n const wildcard = all?.value;\n const selected = new Set(value);\n const everything = wildcard !== undefined && selected.has(wildcard);\n const isOn = (item: string) =>\n everything ? offered.has(item) : selected.has(item);\n const offeredOn = items.filter((item) => isOn(item.value)).length;\n const retiredOn = retired.filter((held) => selected.has(held)).length;\n\n const setValue = (next: string[]) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n /** Catalog order, then what's no longer offered in the order it was held. */\n const emit = (next: Set<string>) =>\n setValue([\n ...items.filter((item) => next.has(item.value)).map((item) => item.value),\n ...retired.filter((held) => next.has(held)),\n ]);\n /** The selection by name — under the wildcard, every item it stands for. */\n const explicit = () =>\n everything\n ? new Set(items.map((item) => item.value))\n : new Set(value.filter((held) => held !== wildcard));\n const toggle = (values: readonly string[], on: boolean) => {\n const next = explicit();\n for (const item of values) {\n if (on) next.add(item);\n else next.delete(item);\n }\n emit(next);\n };\n const toggleAll = (on: boolean) => {\n if (wildcard === undefined) {\n toggle(\n items.map((item) => item.value),\n on,\n );\n } else if (on) {\n setValue([wildcard]);\n } else {\n emit(new Set(items.map((item) => item.value)));\n }\n };\n\n // Presets name selections among what the catalog offers (and the\n // wildcard): what it no longer offers sits outside every one of them.\n const named = (values: readonly string[]) =>\n values.filter((held) => held === wildcard || offered.has(held));\n const preset =\n loading || items.length === 0\n ? undefined\n : presets?.find((option) => {\n const its = named(option.value);\n return its.length > 0 && sameSelection(its, named(value));\n });\n const choosePreset = (option: ScopePreset) => {\n const its = named(option.value);\n if (wildcard !== undefined && its.includes(wildcard)) {\n setValue([wildcard]);\n } else {\n emit(new Set([...its, ...retired.filter((held) => selected.has(held))]));\n }\n };\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setInnerOpen(next);\n onOpenChange?.(next);\n };\n const unfold = () => {\n focusNext.current = \"search\";\n setOpen(true);\n };\n const fold = () => {\n focusNext.current = \"summary\";\n setQuery(\"\");\n setOpen(false);\n };\n\n // The selection as it stood when the list opened, whoever opened it:\n // dismissing the edit puts it back.\n const valueRef = useRef(value);\n valueRef.current = value;\n const openedWith = useRef<readonly string[] | null>(open ? value : null);\n useEffect(() => {\n openedWith.current = open ? valueRef.current : null;\n // Folded by the page (after its save) or by the ✕, the next opening\n // starts from the whole list.\n if (!open) setQuery(\"\");\n }, [open]);\n /** The ✕ (or Escape): the edit is dropped and the list folds. */\n const dismiss = () => {\n const before = openedWith.current;\n if (before != null && !sameSelection(before, valueRef.current)) {\n setValue([...before]);\n }\n fold();\n };\n\n // Focus lands once the face can take it: it fades in, and a field asked\n // to focus on its first frame may still refuse. Try a frame at a time.\n useEffect(() => {\n const target = focusNext.current;\n if (target == null) return;\n focusNext.current = null;\n let frame = 0;\n let tries = 0;\n const attempt = () => {\n const node = target === \"search\" ? searchRef.current : summaryRef.current;\n if (node == null) return;\n // Not scrolled into view: the face opening around it would scroll\n // inside its own clip and jump when it settles.\n node.focus({ preventScroll: true });\n if (document.activeElement !== node && tries++ < 5) {\n frame = requestAnimationFrame(attempt);\n }\n };\n frame = requestAnimationFrame(attempt);\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onSearchKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n // A search, not the form's submit.\n if (event.key === \"Enter\") event.preventDefault();\n if (event.key !== \"Escape\") return;\n if (query !== \"\") {\n // Ours — not an enclosing dialog's or aside's close.\n event.preventDefault();\n setQuery(\"\");\n } else if (collapsible && !disabled) {\n event.preventDefault();\n dismiss();\n }\n };\n\n const tokens = tokenize(query);\n const searching = tokens.length > 0;\n const shownGroups = groups\n .map((group) => ({\n ...group,\n items: searching\n ? group.items.filter((item) =>\n matches(\n tokens,\n group.label,\n item.value,\n item.label,\n item.description,\n ),\n )\n : group.items,\n }))\n .filter((group) => group.items.length > 0);\n const shownRetired = searching\n ? retired.filter((held) => matches(tokens, held))\n : retired;\n\n // The count reads the catalog: under the wildcard every item is in and\n // more will be, so it steps aside for the catch-all's own words.\n const count =\n everything || items.length === 0 ? null : `${offeredOn} of ${items.length}`;\n\n const summary = (() => {\n if (everything && all) {\n return { title: all.label, detail: all.description ?? \"\" };\n }\n if (preset && retiredOn === 0) {\n return { title: preset.label, detail: preset.description ?? count ?? \"\" };\n }\n if (\n all &&\n wildcard === undefined &&\n items.length > 0 &&\n offeredOn === items.length &&\n retiredOn === 0\n ) {\n return { title: all.label, detail: all.description ?? count ?? \"\" };\n }\n // Whole groups by name, the rest item by item. A group of one is just\n // its item: the id says more than the heading over it.\n const names: string[] = [];\n for (const group of groups) {\n const on = group.items.filter((item) => isOn(item.value));\n if (\n group.label !== null &&\n group.items.length > 1 &&\n on.length === group.items.length\n ) {\n names.push(group.label);\n } else {\n names.push(...on.map(nameOf));\n }\n }\n names.push(...retired.filter((held) => selected.has(held)));\n return {\n title: names.length > 0 ? names.join(\", \") : \"None\",\n detail: count ?? \"\",\n };\n })();\n\n const rowDisabled = disabled || loading;\n // Every block that comes and goes (the folded face and the open one,\n // bones and rows, a group or a row a search sets aside) opens and closes\n // on `BasicPage.Reveal`'s motion.\n const reveal = revealIn(reduceMotion);\n\n /**\n * One row. A retired row is a value the catalog no longer offers: its\n * name goes quiet and it has no description to show.\n */\n const renderRow = (item: ScopeItem, retiredRow = false) => {\n const rowId = retiredRow\n ? `${baseId}-r${retired.indexOf(item.value)}`\n : `${baseId}-i${position.get(item.value)}`;\n const nameId = `${rowId}-name`;\n const descriptionId = `${rowId}-description`;\n return (\n <motion.label\n key={item.value}\n {...reveal}\n className={cn(SCOPE_ROW, \"overflow-hidden\")}\n data-scope-row=\"\"\n data-disabled={rowDisabled || undefined}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Checkbox\n size=\"sm\"\n checked={isOn(item.value)}\n disabled={rowDisabled}\n aria-labelledby={nameId}\n aria-describedby={item.description ? descriptionId : undefined}\n onCheckedChange={(on: boolean) => toggle([item.value], on)}\n />\n <span\n id={nameId}\n className={cn(\n \"truncate text-base\",\n retiredRow ? \"text-pho-description\" : \"text-pho-secondary\",\n )}\n >\n {nameOf(item)}\n </span>\n </span>\n {item.description ? (\n <Tooltip.Trigger\n handle={handle}\n payload={item.description}\n render={\n <span\n id={descriptionId}\n data-scope-description=\"\"\n className={SCOPE_DESCRIPTION}\n />\n }\n >\n {item.description}\n </Tooltip.Trigger>\n ) : null}\n </motion.label>\n );\n };\n\n const renderGroup = (group: ScopeGroup) => {\n // Ungrouped items stand on the list's own columns.\n if (group.label === null) {\n return group.items.map((item) => renderRow(item));\n }\n const labelId = `${baseId}-g${groupPosition.get(group.label)}`;\n const members = group.items.map((item) => item.value);\n const on = members.filter(isOn).length;\n const checked = on === members.length;\n return (\n <motion.div\n key={`group:${group.label}`}\n {...reveal}\n // A fieldset's min-content width and legend layout don't sit on the\n // list's grid; the role says the same.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-labelledby={labelId}\n className={cn(SCOPE_GROUP, \"overflow-hidden\")}\n >\n <label\n className={SCOPE_GROUP_BAND}\n data-disabled={rowDisabled || undefined}\n >\n <Checkbox\n size=\"sm\"\n checked={checked}\n indeterminate={on > 0 && !checked}\n disabled={rowDisabled}\n aria-labelledby={labelId}\n onCheckedChange={(next: boolean) => toggle(members, next)}\n />\n <span id={labelId} className=\"truncate\">\n {group.label}\n </span>\n {/* The rows it heads — while searching, the ones that match. */}\n <span className=\"text-pho-description tabular-nums\">\n {members.length}\n </span>\n </label>\n <AnimatePresence initial={false}>\n {group.items.map((item) => renderRow(item))}\n </AnimatePresence>\n </motion.div>\n );\n };\n\n const retiredGroup =\n shownRetired.length > 0 ? (\n <motion.div\n key=\"retired\"\n {...reveal}\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-labelledby={`${baseId}-retired`}\n className={cn(SCOPE_GROUP, \"overflow-hidden\")}\n >\n <div className={cn(SCOPE_GROUP_BAND, \"cursor-default\")}>\n {/* The checkbox column stays: nothing here is added in bulk. */}\n <span aria-hidden className=\"size-4 shrink-0\" />\n <span id={`${baseId}-retired`} className=\"truncate\">\n No longer offered\n </span>\n </div>\n <AnimatePresence initial={false}>\n {shownRetired.map((held) => renderRow({ value: held }, true))}\n </AnimatePresence>\n </motion.div>\n ) : null;\n\n const allRow = all ? (\n <motion.label\n key=\"all\"\n {...reveal}\n className={cn(SCOPE_ROW, \"overflow-hidden\")}\n data-scope-row=\"\"\n data-disabled={\n rowDisabled || (everything && items.length === 0) || undefined\n }\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Checkbox\n size=\"sm\"\n checked={\n wildcard === undefined\n ? items.length > 0 && offeredOn === items.length\n : everything\n }\n indeterminate={\n wildcard === undefined\n ? offeredOn > 0 && offeredOn < items.length\n : !everything && offeredOn + retiredOn > 0\n }\n // With no catalog to spell out, leaving the wildcard could only\n // mean nothing.\n disabled={rowDisabled || (everything && items.length === 0)}\n aria-labelledby={`${baseId}-all`}\n aria-describedby={\n all.description ? `${baseId}-all-description` : undefined\n }\n onCheckedChange={(on: boolean) => toggleAll(on)}\n />\n <span\n id={`${baseId}-all`}\n className=\"text-pho-primary truncate text-base font-medium\"\n >\n {all.label}\n </span>\n </span>\n {all.description ? (\n <span id={`${baseId}-all-description`} className={SCOPE_DESCRIPTION}>\n {all.description}\n </span>\n ) : null}\n </motion.label>\n ) : null;\n\n const nothing =\n searching && shownGroups.length === 0 && shownRetired.length === 0 ? (\n <motion.p\n key=\"nothing\"\n {...reveal}\n className={cn(\n \"text-pho-description col-span-full overflow-hidden text-center text-base\",\n SCOPE_INSET,\n )}\n >\n <span className=\"block py-6\">Nothing matches “{query}”.</span>\n </motion.p>\n ) : null;\n\n const list = (\n <motion.div\n key=\"list\"\n // Past the bones (fading where they stood), the rows unroll.\n {...takeOver(reveal, heights.current.bones, \"down\")}\n id={listId}\n data-scope-list=\"\"\n className={cn(SCOPE_LIST, \"overflow-hidden\")}\n >\n <AnimatePresence initial={false}>\n {!searching ? allRow : null}\n {shownGroups.map(renderGroup)}\n {retiredGroup}\n {nothing}\n </AnimatePresence>\n </motion.div>\n );\n\n // The bones are the list's own shape — the catch-all row, a group's\n // band, rows with their descriptions — so the rows open into it.\n const bones = (\n <motion.div\n key=\"bones\"\n // Back to bones (the catalog reloading), they open from the list's\n // height while the rows fade where they stood.\n {...takeOver(reveal, heights.current.list)}\n data-scope-bones=\"\"\n aria-hidden\n className={cn(SCOPE_LIST, \"overflow-hidden\")}\n >\n {[\n { band: false, name: \"w-20\", text: \"w-44\" },\n { band: true, name: \"w-12\", text: \"\" },\n { band: false, name: \"w-28\", text: \"w-56\" },\n { band: false, name: \"w-32\", text: \"w-48\" },\n { band: false, name: \"w-24\", text: \"w-60\" },\n ].map((bone, index) =>\n bone.band ? (\n <div\n key={index}\n className={cn(\n \"border-pho-secondary bg-pho-page col-span-full flex h-8 items-center gap-2 border-y\",\n SCOPE_INSET,\n )}\n >\n <Skeleton className=\"size-4 rounded-sm\" />\n <Skeleton className={cn(\"h-3\", bone.name)} />\n </div>\n ) : (\n <div key={index} className={SCOPE_BONE_ROW}>\n <span className=\"flex h-5 min-w-0 items-center gap-2\">\n <Skeleton className=\"size-4 shrink-0 rounded-sm\" />\n <Skeleton className={cn(\"h-3.5 max-w-full\", bone.name)} />\n </span>\n <span className=\"flex h-4.5 items-center pl-6 group-data-[wide]/scope:pl-0\">\n <Skeleton className={cn(\"h-3 max-w-full\", bone.text)} />\n </span>\n </div>\n ),\n )}\n </motion.div>\n );\n\n const presetPicker =\n presets != null && presets.length > 0 ? (\n // A field of its own: inside a host `Field` (the page's Permissions)\n // the select would take that field's label for its name, its\n // description, and its name in the form. Laid out as its trigger.\n <BaseField.Root className=\"contents\">\n <Select.Root\n items={[\n ...presets.map((option, index) => ({\n value: `preset:${index}`,\n label: option.label,\n })),\n { value: CUSTOM, label: \"Custom\" },\n ]}\n value={preset ? `preset:${presets.indexOf(preset)}` : CUSTOM}\n onValueChange={(next) => {\n const option =\n presets[Number(String(next).slice(\"preset:\".length))];\n if (option != null && option !== preset) choosePreset(option);\n }}\n disabled={disabled || loading}\n >\n <Select.Trigger\n variant=\"inline\"\n aria-label=\"Preset\"\n // Last in the row, out by its padding (see the class); before\n // the ✕, a little closer to it.\n className={cn(\n SCOPE_PRESET_TRIGGER,\n collapsible ? \"-mr-1\" : \"-mr-2\",\n )}\n >\n <Select.Value />\n <Select.Icon>\n <IconChevronDown />\n </Select.Icon>\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner align=\"end\">\n <Select.Popup>\n <Select.List>\n {presets.map((option, index) => (\n <Select.Item key={index} value={`preset:${index}`}>\n <Select.ItemIndicator>\n <IconCheck />\n </Select.ItemIndicator>\n <Select.ItemText>{option.label}</Select.ItemText>\n {option.description ? (\n <span className=\"text-pho-description col-start-2 text-xs\">\n {option.description}\n </span>\n ) : null}\n </Select.Item>\n ))}\n {/* Not picked, only shown: what a hand-made selection reads. */}\n <Select.Item value={CUSTOM} disabled>\n <Select.ItemIndicator>\n <IconCheck />\n </Select.ItemIndicator>\n <Select.ItemText>Custom</Select.ItemText>\n </Select.Item>\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </BaseField.Root>\n ) : null;\n\n const picker = (\n <motion.div\n key=\"picker\"\n {...takeOver(reveal, heights.current.face, \"down\")}\n className=\"overflow-hidden\"\n >\n {/* The row the folded summary gives way to: the two cross where they\n stand, while the list under it unrolls with its ink down. */}\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n transition={reveal.transition}\n className={SCOPE_SEARCH_ROW}\n >\n <GhostSearch\n ref={searchRef}\n value={query}\n onChange={setQuery}\n onClear={() => setQuery(\"\")}\n onKeyDown={onSearchKeyDown}\n placeholder={placeholder}\n aria-label={placeholder}\n aria-controls={loading ? undefined : listId}\n disabled={loading}\n trailing={\n count != null && !loading ? (\n // A card too narrow for both gives the room to the query; the\n // folded summary carries the count there.\n <span className=\"hidden group-data-[roomy]/scope:inline\">\n {count}\n </span>\n ) : undefined\n }\n autoComplete=\"off\"\n spellCheck={false}\n />\n {presetPicker}\n {collapsible ? (\n <CloseButton\n size=\"sm\"\n label=\"Cancel\"\n // Held open while the page saves: dropping the edit now would\n // show the old selection under a save that sends the new one.\n disabled={disabled}\n onClick={dismiss}\n // Out by its own padding: the ✕ stands as far from the right\n // edge as the magnifier from the left. Its ring inside, as a\n // Button's: the blocks around it clip.\n className=\"-mr-2 shrink-0 focus-visible:-outline-offset-2\"\n />\n ) : null}\n </motion.div>\n <AnimatePresence initial={false} mode=\"popLayout\">\n {loading ? bones : list}\n </AnimatePresence>\n </motion.div>\n );\n\n // The bones stand in the two lines' own boxes, so the card keeps its\n // height when the words arrive.\n const summaryText = loading ? (\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"flex h-5 items-center\">\n <Skeleton className=\"h-3.5 w-48 max-w-full\" />\n </span>\n <span className=\"flex h-4.5 items-center\">\n <Skeleton className=\"h-3 w-16\" />\n </span>\n </span>\n ) : (\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"text-pho-primary truncate text-base\">\n {summary.title}\n </span>\n {summary.detail ? (\n <span className=\"text-pho-description truncate text-xs tabular-nums\">\n {summary.detail}\n </span>\n ) : null}\n </span>\n );\n\n const folded = (\n <motion.div\n key=\"folded\"\n {...takeOver(reveal, heights.current.face)}\n className=\"overflow-hidden\"\n >\n {disabled || loading ? (\n <div className={SCOPE_SUMMARY}>{summaryText}</div>\n ) : (\n <button\n ref={summaryRef}\n type=\"button\"\n aria-expanded={false}\n className={cn(\n SCOPE_SUMMARY,\n \"group hover:bg-pho-primary-hover cursor-pointer transition-colors\",\n )}\n onClick={unfold}\n >\n {summaryText}\n <span\n aria-hidden\n className={buttonVariants({\n variant: \"ghost\",\n size: \"sm\",\n className:\n \"group-hover:bg-pho-ghost-hover group-hover:text-pho-secondary-hover pointer-events-none shrink-0\",\n })}\n >\n Edit\n </span>\n </button>\n )}\n </motion.div>\n );\n\n return (\n <div\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-busy={loading || undefined}\n data-scope=\"\"\n data-open={open ? \"\" : undefined}\n data-wide={wide ? \"\" : undefined}\n data-roomy={roomy ? \"\" : undefined}\n className={cn(SCOPE_SURFACE, className)}\n {...props}\n ref={(node: HTMLDivElement | null) => {\n cardRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref != null) ref.current = node;\n }}\n >\n {/* Folding and opening, the faces trade places on Reveal's motion:\n the one arriving opens from the height the other stood at, the\n other fades where it stood. The card moves at its bottom edge, so\n the list unrolls from the top down, row by row, and rolls back up\n under it. */}\n <AnimatePresence initial={false} mode=\"popLayout\">\n {open ? picker : folded}\n </AnimatePresence>\n <Tooltip.Root\n handle={handle}\n onOpenChange={(next, details) => {\n // Only a description the row cuts short opens.\n if (next && !isClipped(details.event?.target)) details.cancel();\n }}\n >\n {({ payload }) => (\n <Tooltip.Portal>\n <Tooltip.Positioner side=\"top\" align=\"start\">\n <Tooltip.Popup className=\"max-w-80 font-normal\">\n {payload}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n )}\n </Tooltip.Root>\n </div>\n );\n}\n\nScope.displayName = \"Scope\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAoJA,IAAM2B,KACJ,8JAGIC,KAAc,2BASdC,KACJ,0FAWIC,KACJ,oRAGIC,KAAS,UAaTC,KACJ,qIAGIC,KACJ,qGAQIC,KACJ,sUAGIC,KACJ,gLAMIC,KACJ,kOAMIC,KACJ,sJAGIC,KACJ,6JAGIC,KAAW,IAEXC,KAAY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xG,EAAGwB,IAAeqE,EAAS;AAAA,IACtC,GAAIC;AAAA,IACJ,KAAA,CAAMnD,MAAgC;AACpC,MAAA2D,GAAQ,UAAU3D,GACd,OAAOJ,KAAQ,aAAYA,EAAII,CAAI,IAC9BJ,KAAO,SAAMA,EAAI,UAAUI;AAAA,IACtC;AAAA,IAdF,UAAA,CAqBE,gBAAA1B,EAACE,GAAD;AAAA,MAAiB,SAAS;AAAA,MAAO,MAAK;AAAA,MACnC,UAAAgF,IAAOqE,KAASE;AAAA,IACF,CAAA,GACjB,gBAAAzJ,EAACnB,EAAQ,MAAT;AAAA,MACU,QAAAgH;AAAA,MACR,cAAA,CAAe7D,GAAM0H,MAAY;AAE/B,QAAI1H,KAAQ,CAAC6B,GAAU6F,EAAQ,OAAO,MAAM,KAAGA,EAAQ,OAAO;AAAA,MAChE;AAAA,MAEE,UAAA,CAAA,EAAE,SAAAC,EAAA,MACF,gBAAA3J,EAACnB,EAAQ,QAAT,EAAA,UACE,gBAAAmB,EAACnB,EAAQ,YAAT;AAAA,QAAoB,MAAK;AAAA,QAAM,OAAM;AAAA,QACnC,UAAA,gBAAAmB,EAACnB,EAAQ,OAAT;AAAA,UAAe,WAAU;AAAA,UACtB,UAAA8K;AAAA,QACY,CAAA;AAAA,MACG,CAAA,EACN,CAAA;AAAA,IAEN,CAAA,CACX;AAAA,E;AAET;AAEA5F,GAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"scope.js","names":["BaseTooltip","Tooltip","BaseField","cn","revealIn","buttonVariants","ChevronDownIcon","CheckIcon","CloseButton","Checkbox","Skeleton","GhostSearch","Tooltip$1","Select","useEffect","useId","useLayoutEffect","useMemo","useRef","useState","jsx","jsxs","AnimatePresence","motion","useReducedMotion","Field","Tooltip","SCOPE_SURFACE","SCOPE_INSET","SCOPE_SEARCH_ROW","SCOPE_PRESET_TRIGGER","CUSTOM","SCOPE_LIST","SCOPE_GROUP","SCOPE_ROW","SCOPE_BONE_ROW","SCOPE_GROUP_BAND","SCOPE_DESCRIPTION","SCOPE_SUMMARY","WIDE_REM","ROOMY_REM","useCardSize","ref","size","setSize","heights","node","measure","list","bones","rem","width","next","current","observer","groupItems","items","groups","byLabel","item","label","group","normalize","text","tokenize","query","matches","tokens","fields","haystack","token","nameOf","sameSelection","a","b","held","value","takeOver","reveal","from","ink","isClipped","target","Scope","valueProp","defaultValue","onValueChange","all","presets","placeholder","collapsible","openProp","defaultOpen","onOpenChange","loading","disabled","className","props","innerValue","setInnerValue","innerOpen","setInnerOpen","open","setQuery","reduceMotion","cardRef","wide","roomy","baseId","listId","searchRef","summaryRef","focusNext","handle","offered","position","index","groupPosition","retiredSeen","retired","wildcard","selected","everything","isOn","offeredOn","retiredOn","setValue","emit","explicit","toggle","values","on","toggleAll","named","preset","option","its","choosePreset","setOpen","unfold","fold","valueRef","openedWith","dismiss","before","frame","tries","attempt","onSearchKeyDown","event","searching","shownGroups","shownRetired","count","summary","names","rowDisabled","renderRow","retiredRow","rowId","nameId","descriptionId","renderGroup","labelId","members","checked","retiredGroup","allRow","nothing","bone","presetPicker","picker","summaryText","folded","details","payload"],"sources":["../../src/components/scope/scope.tsx"],"sourcesContent":["import {\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ComponentProps,\n type KeyboardEvent,\n type Ref,\n type RefObject,\n} from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { Tooltip as BaseTooltip } from \"@base-ui/react/tooltip\";\nimport { CheckIcon, ChevronDownIcon } from \"../../icons/photon\";\nimport { CloseButton, buttonVariants } from \"../button\";\nimport { Checkbox } from \"../checkbox\";\nimport { Select } from \"../select\";\nimport { Skeleton } from \"../skeleton\";\nimport { Tooltip } from \"../tooltip\";\nimport { revealIn } from \"../../motion\";\nimport { cn } from \"../../utils/cn\";\nimport { GhostSearch } from \"../../utils/ghost-search\";\n\n/**\n * Scope — pick what something covers out of a catalog: the events a webhook\n * destination receives, the permissions an app or key holds. A searchable,\n * grouped checklist with a catch-all row; `collapsible` folds it to a\n * two-line summary for a resource that already exists, opening on click.\n */\n\nexport interface ScopeItem {\n /**\n * What the selection holds — an event type, a permission id. It is also\n * the row's name unless `label` says otherwise.\n */\n value: string;\n /** The row's name, when it shouldn't be the value itself. */\n label?: string;\n /** One line on what it covers. Searched along with the name. */\n description?: string;\n /**\n * The group it files under — the resource, the namespace. Groups keep\n * the order they first appear in; items without one come first.\n */\n group?: string;\n}\n\nexport interface ScopeAll {\n /** The row's name — `All events`. */\n label: string;\n /** What choosing it means — `Every current and future event.` */\n description?: string;\n /**\n * A wildcard the selection holds in place of the items — `*`. With it,\n * the row stands for every item, now and later: choosing it sets the\n * selection to `[value]`, and leaving it spells every item out by name so\n * the reader prunes from there, never from nothing. Without it, the row\n * selects every item listed.\n */\n value?: string;\n}\n\nexport interface ScopePreset {\n /**\n * Its name: in the search row's picker, and on a folded list whose\n * selection is exactly this one — `Read only`.\n */\n label: string;\n /** What it covers, under its name in the picker and on the folded list. */\n description?: string;\n /** The selection it stands for. */\n value: readonly string[];\n}\n\nexport interface ScopeProps extends Omit<\n ComponentProps<\"div\">,\n \"defaultValue\" | \"onChange\" | \"children\"\n> {\n /** The catalog — everything that can be picked, in display order. */\n items: readonly ScopeItem[];\n /** The selected values, controlled. */\n value?: readonly string[];\n /** The selected values at first, uncontrolled. */\n defaultValue?: readonly string[];\n /**\n * Called with the next selection, in catalog order (values no longer in\n * the catalog follow in the order they were held).\n */\n onValueChange?: (value: string[]) => void;\n /** The catch-all row at the top. Leave it out for no such row. */\n all?: ScopeAll;\n /**\n * Named selections to start from, picked at the search row's end. One\n * chosen sets the list to its values; values the catalog doesn't offer\n * stay as they are. A selection that is exactly a preset goes by its\n * name there and on the folded list; any other reads Custom.\n */\n presets?: readonly ScopePreset[];\n /** The search field's placeholder, which also names it. @default \"Search\" */\n placeholder?: string;\n /**\n * Fold to a two-line summary of the selection, opening to the full list\n * on click — for a resource that already exists, where the scope is read\n * far more often than it changes. The page saves the change (its \"Save\n * changes\" below the card) and folds the list through `open`; the ✕ in\n * the search row, or `Escape` on an empty search, drops the edit: the\n * selection goes back to what it was when the list opened, and folds.\n */\n collapsible?: boolean;\n /** Whether the collapsible list is open, controlled. */\n open?: boolean;\n /** Whether the collapsible list starts open. @default false */\n defaultOpen?: boolean;\n /** Called when the collapsible list opens or folds. */\n onOpenChange?: (open: boolean) => void;\n /** The catalog is on its way: bones in place of rows. */\n loading?: boolean;\n /**\n * Read-only: the list can be searched but not changed, and a folded one\n * stays folded. Held open by `open` (a save in flight), nothing in it\n * changes the selection, the ✕ and Escape included.\n */\n disabled?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\n/* ------------------------------- class map ------------------------------- */\n\n/**\n * The card: the BasicPage card's stroke, corner, and fill. `overflow-clip`\n * rounds a hovered edge row into the corners without making the card a\n * scroll container. The rows lay out by the card's width, not the\n * viewport's: it is measured (`data-wide`, `data-roomy`) rather than made a\n * CSS query container, because Chromium drops a query container's\n * children from layout when a `Reveal` mounts beside it in a Base UI form\n * (a BasicPage `Footer` appearing under the card left it 2px tall).\n *\n * Positioned: a face (or the bones) leaving steps out of the flow and fades\n * where it stood, clipped by the card as the one arriving takes its place.\n *\n * Its words stand `--scope-inset` in from its edges, which is the page's\n * choice inset (the one `RadioCard` and `CheckboxCard` pad by): 20px when\n * the card stands on a `BasicPage.Stack`, on the headings' line like any\n * card's rows; 12px inside a sheet, a card, or a dialog, where it is a\n * field among fields and its words line up with theirs.\n */\nconst SCOPE_SURFACE =\n \"group/scope relative w-full min-w-0 overflow-clip rounded-base border border-pho-secondary bg-pho-primary [--scope-inset:var(--choice-card-inset,0.75rem)]\";\n\n/** The side padding every row of the card shares. */\nconst SCOPE_INSET = \"px-[var(--scope-inset)]\";\n\n/**\n * The search, the card's first row: no box of its own. The magnifier stands\n * on the checkbox column and the query on the names' line, the count at the\n * row's end and, on a collapsible list, the ✕ that drops the edit after it,\n * its glyph as far in from the right edge as the magnifier's from the left.\n * 44px with the hairline below, the DataTable toolbar band's height.\n */\nconst SCOPE_SEARCH_ROW =\n \"flex min-h-11 items-center gap-3 border-b border-pho-secondary px-[var(--scope-inset)]\";\n\n/**\n * The preset picker at the search row's end: a `Select` on its inline face,\n * dressed as a ghost pill like the ✕ beside it — no box in the band, as\n * DataTable's toolbar filters. The ✕'s geometry: 8px round the chevron,\n * the pill hanging that far past the words' edge so the chevron mirrors the\n * magnifier's inset, never onto the card's border; the label side 4px\n * wider, a Button's icon-side tuck. It draws its own focus ring, the row\n * having none to lend it.\n */\nconst SCOPE_PRESET_TRIGGER =\n \"text-pho-secondary hover:bg-pho-ghost-hover hover:text-pho-secondary-hover data-[popup-open]:bg-pho-ghost-hover outline-pho-brand shrink-0 gap-1.5 rounded-full py-1.5 pr-2 pl-3 font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-solid\";\n\n/** The picker's value for a selection no preset names. */\nconst CUSTOM = \"custom\";\n\n/**\n * Two columns once the card is wide enough: the names, as wide as the\n * longest (never past 45%), then the descriptions on one shared edge.\n * Narrower, each row stacks its description under its name.\n *\n * Every row track is as tall as its row (`auto-rows-max`). A row clips for\n * its own reveal, which lets an `auto` track shrink to nothing: while the\n * list's height opens (taking over from the bones) the grid would squeeze\n * every row at once and each would open from its middle. At their own\n * height the rows stand still and the edge uncovers them from the top.\n */\nconst SCOPE_LIST =\n \"grid auto-rows-max grid-cols-1 group-data-[wide]/scope:grid-cols-[fit-content(45%)_minmax(0,1fr)] group-data-[wide]/scope:gap-x-4\";\n\n/** A group: its band and its rows, on the list's columns and track rule. */\nconst SCOPE_GROUP =\n \"col-span-full grid auto-rows-max grid-cols-subgrid border-t border-pho-secondary first:border-t-0\";\n\n/**\n * One row: 36px on the wide layout — a 20px line and 8px either side.\n * Stacked, the description sits flush under the name, so the row sets no\n * gap of its own: the columns' gap is the list's, and a subgrid that set\n * its own would let a long name run into its description.\n */\nconst SCOPE_ROW =\n \"group col-span-full flex min-w-0 cursor-pointer flex-col px-[var(--scope-inset)] py-2 transition-colors select-none hover:bg-pho-primary-hover group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center data-[disabled]:cursor-not-allowed data-[disabled]:hover:bg-transparent\";\n\n/** A bone row: a row's layout, nothing to hover or click. */\nconst SCOPE_BONE_ROW =\n \"col-span-full flex min-w-0 flex-col px-[var(--scope-inset)] py-2 group-data-[wide]/scope:grid group-data-[wide]/scope:grid-cols-subgrid group-data-[wide]/scope:items-center\";\n\n/**\n * A group's band — DataTable's section wash, thinner than the rows it\n * heads, with the group's own checkbox on the rows' checkbox column.\n */\nconst SCOPE_GROUP_BAND =\n \"group col-span-full flex h-8 min-w-0 cursor-pointer items-center gap-2 border-b border-pho-secondary bg-pho-page px-[var(--scope-inset)] text-xs font-medium text-pho-secondary select-none data-[disabled]:cursor-not-allowed\";\n\n/**\n * A description: under the name (two lines at most) on the narrow layout,\n * one line in its own column on the wide one — the rest opens on hover.\n */\nconst SCOPE_DESCRIPTION =\n \"line-clamp-2 min-w-0 pl-6 text-xs text-pho-description group-data-[wide]/scope:block group-data-[wide]/scope:truncate group-data-[wide]/scope:pl-0\";\n\n/** The folded summary: two lines, the whole card its hit target. */\nconst SCOPE_SUMMARY =\n \"flex w-full min-w-0 items-center gap-3 px-[var(--scope-inset)] py-2.5 text-left outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-2\";\n\n/** Two columns (names, then descriptions) from this card width up. */\nconst WIDE_REM = 34;\n/** The count stands in the search row from this card width up. */\nconst ROOMY_REM = 18;\n\n/**\n * The card's width against the two breakpoints, measured before paint and\n * followed as it changes. Desktop-first until measured, so a server render\n * shows the common layout.\n *\n * Its heights ride along for the next swap: the face standing now (the\n * card's inner height), and the list or the bones, whichever shows. What\n * takes their place opens from there.\n */\nfunction useCardSize(ref: RefObject<HTMLElement | null>) {\n const [size, setSize] = useState({ wide: true, roomy: true });\n const heights = useRef({ face: 0, list: 0, bones: 0 });\n useLayoutEffect(() => {\n const node = ref.current;\n if (node == null) return;\n const measure = () => {\n heights.current.face = node.clientHeight;\n const list = node.querySelector<HTMLElement>(\"[data-scope-list]\");\n if (list != null) heights.current.list = list.offsetHeight;\n const bones = node.querySelector<HTMLElement>(\"[data-scope-bones]\");\n if (bones != null) heights.current.bones = bones.offsetHeight;\n const rem =\n parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;\n const width = node.getBoundingClientRect().width;\n const next = {\n wide: width >= WIDE_REM * rem,\n roomy: width >= ROOMY_REM * rem,\n };\n setSize((current) =>\n current.wide === next.wide && current.roomy === next.roomy\n ? current\n : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(node);\n return () => observer.disconnect();\n }, [ref]);\n return { ...size, heights };\n}\n\n/* -------------------------------- model --------------------------------- */\n\ninterface ScopeGroup {\n label: string | null;\n items: ScopeItem[];\n}\n\n/** Items by group, groups in first-appearance order, ungrouped first. */\nfunction groupItems(items: readonly ScopeItem[]): ScopeGroup[] {\n const groups: ScopeGroup[] = [];\n const byLabel = new Map<string | null, ScopeGroup>();\n for (const item of items) {\n const label = item.group ?? null;\n let group = byLabel.get(label);\n if (!group) {\n group = { label, items: [] };\n byLabel.set(label, group);\n groups.push(group);\n }\n group.items.push(item);\n }\n return [\n ...groups.filter((group) => group.label === null),\n ...groups.filter((group) => group.label !== null),\n ];\n}\n\n/**\n * Lowercase, with the separators ids are written in (`.`, `:`, `-`, `_`,\n * `/`) read as spaces — `call ended` finds `call.ended`.\n */\nfunction normalize(text: string): string {\n return text.toLowerCase().replace(/[.:\\-_/]/g, \" \");\n}\n\nfunction tokenize(query: string): string[] {\n return normalize(query).split(/\\s+/).filter(Boolean);\n}\n\n/** Every word of the query somewhere in the group, name, or description. */\nfunction matches(\n tokens: readonly string[],\n ...fields: (string | null | undefined)[]\n) {\n const haystack = normalize(fields.filter(Boolean).join(\" \"));\n return tokens.every((token) => haystack.includes(token));\n}\n\nfunction nameOf(item: ScopeItem): string {\n return item.label ?? item.value;\n}\n\n/** The same values, whatever their order. */\nfunction sameSelection(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const held = new Set(a);\n return b.every((value) => held.has(value));\n}\n\n/**\n * Reveal for a block taking another's place: it opens from the height the\n * other stood at rather than from none, while the other steps out of the\n * flow (`popLayout`) and fades where it stood. The card moves at its bottom\n * edge only, and what it loses rolls up under the top.\n *\n * `ink` is how the arriving block shows. Rows (the open face, the list)\n * come with their ink `down`, so the edge uncovers them from the top, one\n * after another. Faded in over the growth, the whole list would come up\n * at once, and a list that shows everywhere at once reads as opening from\n * the middle. A stand-in (the folded summary, the bones) `fade`s in where\n * it stands, crossing the block that leaves.\n */\nfunction takeOver(\n reveal: ReturnType<typeof revealIn>,\n from: number,\n ink: \"down\" | \"fade\" = \"fade\",\n) {\n return {\n ...reveal,\n initial: {\n ...reveal.initial,\n height: from,\n opacity: ink === \"down\" ? 1 : 0,\n },\n exit: { opacity: 0 },\n };\n}\n\n/** Whether a description shows whole, measured when the pointer asks. */\nfunction isClipped(target: EventTarget | null | undefined): boolean {\n if (!(target instanceof Element)) return false;\n const text = target.closest<HTMLElement>(\"[data-scope-description]\");\n if (text == null) return false;\n return (\n text.scrollWidth > text.clientWidth + 1 ||\n text.scrollHeight > text.clientHeight + 1\n );\n}\n\n/* ------------------------------- component ------------------------------- */\n\n/**\n * A searchable, grouped checklist for choosing what something covers.\n *\n * Every row is one line on a wide card — the name, then its description in\n * a second column that opens whole on hover when it doesn't fit. Groups are\n * thin tinted bands carrying a checkbox for the whole group (mixed when\n * partly chosen). The search matches names, descriptions, and group names,\n * word by word; while it holds a query the catch-all row steps aside and a\n * group's checkbox covers the rows it shows.\n *\n * With `collapsible`, the card rests as a summary — whole groups by name,\n * the rest by item, over a count — and opens in place, the search taking\n * focus, when clicked; its ✕ drops the edit and folds it back, the page's\n * own save below the card commits it. Values the catalog no longer offers keep a row\n * under \"No longer offered\": they can be removed, never added in bulk.\n */\nexport function Scope({\n items,\n value: valueProp,\n defaultValue,\n onValueChange,\n all,\n presets,\n placeholder = \"Search\",\n collapsible = false,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n loading = false,\n disabled = false,\n className,\n ref,\n ...props\n}: ScopeProps) {\n const [innerValue, setInnerValue] = useState<readonly string[]>(\n defaultValue ?? [],\n );\n const value = valueProp ?? innerValue;\n const [innerOpen, setInnerOpen] = useState(defaultOpen);\n const open = collapsible ? (openProp ?? innerOpen) : true;\n const [query, setQuery] = useState(\"\");\n\n const reduceMotion = useReducedMotion();\n const cardRef = useRef<HTMLDivElement | null>(null);\n const { wide, roomy, heights } = useCardSize(cardRef);\n const baseId = useId();\n const listId = `${baseId}-list`;\n const searchRef = useRef<HTMLInputElement | null>(null);\n const summaryRef = useRef<HTMLButtonElement | null>(null);\n // Where focus goes once the next face has mounted — set only by our own\n // controls, so a host flipping `open` doesn't pull focus around.\n const focusNext = useRef<\"search\" | \"summary\" | null>(null);\n const handle = useMemo(() => BaseTooltip.createHandle<string>(), []);\n\n const groups = useMemo(() => groupItems(items), [items]);\n const offered = useMemo(\n () => new Set(items.map((item) => item.value)),\n [items],\n );\n // Ids go by catalog position: values may hold characters an id shouldn't.\n const position = useMemo(\n () => new Map(items.map((item, index) => [item.value, index])),\n [items],\n );\n const groupPosition = useMemo(\n () => new Map(groups.map((group, index) => [group.label, index])),\n [groups],\n );\n\n // Values held that the catalog doesn't offer. Remembered while mounted,\n // so one unticked stays on the list and can be ticked back.\n const retiredSeen = useRef<string[]>([]);\n for (const held of value) {\n if (\n held !== all?.value &&\n !offered.has(held) &&\n !retiredSeen.current.includes(held)\n ) {\n retiredSeen.current.push(held);\n }\n }\n const retired = retiredSeen.current.filter((held) => !offered.has(held));\n\n const wildcard = all?.value;\n const selected = new Set(value);\n const everything = wildcard !== undefined && selected.has(wildcard);\n const isOn = (item: string) =>\n everything ? offered.has(item) : selected.has(item);\n const offeredOn = items.filter((item) => isOn(item.value)).length;\n const retiredOn = retired.filter((held) => selected.has(held)).length;\n\n const setValue = (next: string[]) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n /** Catalog order, then what's no longer offered in the order it was held. */\n const emit = (next: Set<string>) =>\n setValue([\n ...items.filter((item) => next.has(item.value)).map((item) => item.value),\n ...retired.filter((held) => next.has(held)),\n ]);\n /** The selection by name — under the wildcard, every item it stands for. */\n const explicit = () =>\n everything\n ? new Set(items.map((item) => item.value))\n : new Set(value.filter((held) => held !== wildcard));\n const toggle = (values: readonly string[], on: boolean) => {\n const next = explicit();\n for (const item of values) {\n if (on) next.add(item);\n else next.delete(item);\n }\n emit(next);\n };\n const toggleAll = (on: boolean) => {\n if (wildcard === undefined) {\n toggle(\n items.map((item) => item.value),\n on,\n );\n } else if (on) {\n setValue([wildcard]);\n } else {\n emit(new Set(items.map((item) => item.value)));\n }\n };\n\n // Presets name selections among what the catalog offers (and the\n // wildcard): what it no longer offers sits outside every one of them.\n const named = (values: readonly string[]) =>\n values.filter((held) => held === wildcard || offered.has(held));\n const preset =\n loading || items.length === 0\n ? undefined\n : presets?.find((option) => {\n const its = named(option.value);\n return its.length > 0 && sameSelection(its, named(value));\n });\n const choosePreset = (option: ScopePreset) => {\n const its = named(option.value);\n if (wildcard !== undefined && its.includes(wildcard)) {\n setValue([wildcard]);\n } else {\n emit(new Set([...its, ...retired.filter((held) => selected.has(held))]));\n }\n };\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setInnerOpen(next);\n onOpenChange?.(next);\n };\n const unfold = () => {\n focusNext.current = \"search\";\n setOpen(true);\n };\n const fold = () => {\n focusNext.current = \"summary\";\n setQuery(\"\");\n setOpen(false);\n };\n\n // The selection as it stood when the list opened, whoever opened it:\n // dismissing the edit puts it back.\n const valueRef = useRef(value);\n valueRef.current = value;\n const openedWith = useRef<readonly string[] | null>(open ? value : null);\n useEffect(() => {\n openedWith.current = open ? valueRef.current : null;\n // Folded by the page (after its save) or by the ✕, the next opening\n // starts from the whole list.\n if (!open) setQuery(\"\");\n }, [open]);\n /** The ✕ (or Escape): the edit is dropped and the list folds. */\n const dismiss = () => {\n const before = openedWith.current;\n if (before != null && !sameSelection(before, valueRef.current)) {\n setValue([...before]);\n }\n fold();\n };\n\n // Focus lands once the face can take it: it fades in, and a field asked\n // to focus on its first frame may still refuse. Try a frame at a time.\n useEffect(() => {\n const target = focusNext.current;\n if (target == null) return;\n focusNext.current = null;\n let frame = 0;\n let tries = 0;\n const attempt = () => {\n const node = target === \"search\" ? searchRef.current : summaryRef.current;\n if (node == null) return;\n // Not scrolled into view: the face opening around it would scroll\n // inside its own clip and jump when it settles.\n node.focus({ preventScroll: true });\n if (document.activeElement !== node && tries++ < 5) {\n frame = requestAnimationFrame(attempt);\n }\n };\n frame = requestAnimationFrame(attempt);\n return () => cancelAnimationFrame(frame);\n }, [open]);\n\n const onSearchKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n // A search, not the form's submit.\n if (event.key === \"Enter\") event.preventDefault();\n if (event.key !== \"Escape\") return;\n if (query !== \"\") {\n // Ours — not an enclosing dialog's or aside's close.\n event.preventDefault();\n setQuery(\"\");\n } else if (collapsible && !disabled) {\n event.preventDefault();\n dismiss();\n }\n };\n\n const tokens = tokenize(query);\n const searching = tokens.length > 0;\n const shownGroups = groups\n .map((group) => ({\n ...group,\n items: searching\n ? group.items.filter((item) =>\n matches(\n tokens,\n group.label,\n item.value,\n item.label,\n item.description,\n ),\n )\n : group.items,\n }))\n .filter((group) => group.items.length > 0);\n const shownRetired = searching\n ? retired.filter((held) => matches(tokens, held))\n : retired;\n\n // The count reads the catalog: under the wildcard every item is in and\n // more will be, so it steps aside for the catch-all's own words.\n const count =\n everything || items.length === 0 ? null : `${offeredOn} of ${items.length}`;\n\n const summary = (() => {\n if (everything && all) {\n return { title: all.label, detail: all.description ?? \"\" };\n }\n if (preset && retiredOn === 0) {\n return { title: preset.label, detail: preset.description ?? count ?? \"\" };\n }\n if (\n all &&\n wildcard === undefined &&\n items.length > 0 &&\n offeredOn === items.length &&\n retiredOn === 0\n ) {\n return { title: all.label, detail: all.description ?? count ?? \"\" };\n }\n // Whole groups by name, the rest item by item. A group of one is just\n // its item: the id says more than the heading over it.\n const names: string[] = [];\n for (const group of groups) {\n const on = group.items.filter((item) => isOn(item.value));\n if (\n group.label !== null &&\n group.items.length > 1 &&\n on.length === group.items.length\n ) {\n names.push(group.label);\n } else {\n names.push(...on.map(nameOf));\n }\n }\n names.push(...retired.filter((held) => selected.has(held)));\n return {\n title: names.length > 0 ? names.join(\", \") : \"None\",\n detail: count ?? \"\",\n };\n })();\n\n const rowDisabled = disabled || loading;\n // Every block that comes and goes (the folded face and the open one,\n // bones and rows, a group or a row a search sets aside) opens and closes\n // on `BasicPage.Reveal`'s motion.\n const reveal = revealIn(reduceMotion);\n\n /**\n * One row. A retired row is a value the catalog no longer offers: its\n * name goes quiet and it has no description to show.\n */\n const renderRow = (item: ScopeItem, retiredRow = false) => {\n const rowId = retiredRow\n ? `${baseId}-r${retired.indexOf(item.value)}`\n : `${baseId}-i${position.get(item.value)}`;\n const nameId = `${rowId}-name`;\n const descriptionId = `${rowId}-description`;\n return (\n <motion.label\n key={item.value}\n {...reveal}\n className={cn(SCOPE_ROW, \"overflow-hidden\")}\n data-scope-row=\"\"\n data-disabled={rowDisabled || undefined}\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Checkbox\n size=\"sm\"\n checked={isOn(item.value)}\n disabled={rowDisabled}\n aria-labelledby={nameId}\n aria-describedby={item.description ? descriptionId : undefined}\n onCheckedChange={(on: boolean) => toggle([item.value], on)}\n />\n <span\n id={nameId}\n className={cn(\n \"truncate text-base\",\n retiredRow ? \"text-pho-description\" : \"text-pho-secondary\",\n )}\n >\n {nameOf(item)}\n </span>\n </span>\n {item.description ? (\n <Tooltip.Trigger\n handle={handle}\n payload={item.description}\n render={\n <span\n id={descriptionId}\n data-scope-description=\"\"\n className={SCOPE_DESCRIPTION}\n />\n }\n >\n {item.description}\n </Tooltip.Trigger>\n ) : null}\n </motion.label>\n );\n };\n\n const renderGroup = (group: ScopeGroup) => {\n // Ungrouped items stand on the list's own columns.\n if (group.label === null) {\n return group.items.map((item) => renderRow(item));\n }\n const labelId = `${baseId}-g${groupPosition.get(group.label)}`;\n const members = group.items.map((item) => item.value);\n const on = members.filter(isOn).length;\n const checked = on === members.length;\n return (\n <motion.div\n key={`group:${group.label}`}\n {...reveal}\n // A fieldset's min-content width and legend layout don't sit on the\n // list's grid; the role says the same.\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-labelledby={labelId}\n className={cn(SCOPE_GROUP, \"overflow-hidden\")}\n >\n <label\n className={SCOPE_GROUP_BAND}\n data-disabled={rowDisabled || undefined}\n >\n <Checkbox\n size=\"sm\"\n checked={checked}\n indeterminate={on > 0 && !checked}\n disabled={rowDisabled}\n aria-labelledby={labelId}\n onCheckedChange={(next: boolean) => toggle(members, next)}\n />\n <span id={labelId} className=\"truncate\">\n {group.label}\n </span>\n {/* The rows it heads — while searching, the ones that match. */}\n <span className=\"text-pho-description tabular-nums\">\n {members.length}\n </span>\n </label>\n <AnimatePresence initial={false}>\n {group.items.map((item) => renderRow(item))}\n </AnimatePresence>\n </motion.div>\n );\n };\n\n const retiredGroup =\n shownRetired.length > 0 ? (\n <motion.div\n key=\"retired\"\n {...reveal}\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-labelledby={`${baseId}-retired`}\n className={cn(SCOPE_GROUP, \"overflow-hidden\")}\n >\n <div className={cn(SCOPE_GROUP_BAND, \"cursor-default\")}>\n {/* The checkbox column stays: nothing here is added in bulk. */}\n <span aria-hidden className=\"size-4 shrink-0\" />\n <span id={`${baseId}-retired`} className=\"truncate\">\n No longer offered\n </span>\n </div>\n <AnimatePresence initial={false}>\n {shownRetired.map((held) => renderRow({ value: held }, true))}\n </AnimatePresence>\n </motion.div>\n ) : null;\n\n const allRow = all ? (\n <motion.label\n key=\"all\"\n {...reveal}\n className={cn(SCOPE_ROW, \"overflow-hidden\")}\n data-scope-row=\"\"\n data-disabled={\n rowDisabled || (everything && items.length === 0) || undefined\n }\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Checkbox\n size=\"sm\"\n checked={\n wildcard === undefined\n ? items.length > 0 && offeredOn === items.length\n : everything\n }\n indeterminate={\n wildcard === undefined\n ? offeredOn > 0 && offeredOn < items.length\n : !everything && offeredOn + retiredOn > 0\n }\n // With no catalog to spell out, leaving the wildcard could only\n // mean nothing.\n disabled={rowDisabled || (everything && items.length === 0)}\n aria-labelledby={`${baseId}-all`}\n aria-describedby={\n all.description ? `${baseId}-all-description` : undefined\n }\n onCheckedChange={(on: boolean) => toggleAll(on)}\n />\n <span\n id={`${baseId}-all`}\n className=\"text-pho-primary truncate text-base font-medium\"\n >\n {all.label}\n </span>\n </span>\n {all.description ? (\n <span id={`${baseId}-all-description`} className={SCOPE_DESCRIPTION}>\n {all.description}\n </span>\n ) : null}\n </motion.label>\n ) : null;\n\n const nothing =\n searching && shownGroups.length === 0 && shownRetired.length === 0 ? (\n <motion.p\n key=\"nothing\"\n {...reveal}\n className={cn(\n \"text-pho-description col-span-full overflow-hidden text-center text-base\",\n SCOPE_INSET,\n )}\n >\n <span className=\"block py-6\">Nothing matches “{query}”.</span>\n </motion.p>\n ) : null;\n\n const list = (\n <motion.div\n key=\"list\"\n // Past the bones (fading where they stood), the rows unroll.\n {...takeOver(reveal, heights.current.bones, \"down\")}\n id={listId}\n data-scope-list=\"\"\n className={cn(SCOPE_LIST, \"overflow-hidden\")}\n >\n <AnimatePresence initial={false}>\n {!searching ? allRow : null}\n {shownGroups.map(renderGroup)}\n {retiredGroup}\n {nothing}\n </AnimatePresence>\n </motion.div>\n );\n\n // The bones are the list's own shape — the catch-all row, a group's\n // band, rows with their descriptions — so the rows open into it.\n const bones = (\n <motion.div\n key=\"bones\"\n // Back to bones (the catalog reloading), they open from the list's\n // height while the rows fade where they stood.\n {...takeOver(reveal, heights.current.list)}\n data-scope-bones=\"\"\n aria-hidden\n className={cn(SCOPE_LIST, \"overflow-hidden\")}\n >\n {[\n { band: false, name: \"w-20\", text: \"w-44\" },\n { band: true, name: \"w-12\", text: \"\" },\n { band: false, name: \"w-28\", text: \"w-56\" },\n { band: false, name: \"w-32\", text: \"w-48\" },\n { band: false, name: \"w-24\", text: \"w-60\" },\n ].map((bone, index) =>\n bone.band ? (\n <div\n key={index}\n className={cn(\n \"border-pho-secondary bg-pho-page col-span-full flex h-8 items-center gap-2 border-y\",\n SCOPE_INSET,\n )}\n >\n <Skeleton className=\"size-4 rounded-sm\" />\n <Skeleton className={cn(\"h-3\", bone.name)} />\n </div>\n ) : (\n <div key={index} className={SCOPE_BONE_ROW}>\n <span className=\"flex h-5 min-w-0 items-center gap-2\">\n <Skeleton className=\"size-4 shrink-0 rounded-sm\" />\n <Skeleton className={cn(\"h-3.5 max-w-full\", bone.name)} />\n </span>\n <span className=\"flex h-4.5 items-center pl-6 group-data-[wide]/scope:pl-0\">\n <Skeleton className={cn(\"h-3 max-w-full\", bone.text)} />\n </span>\n </div>\n ),\n )}\n </motion.div>\n );\n\n const presetPicker =\n presets != null && presets.length > 0 ? (\n // A field of its own: inside a host `Field` (the page's Permissions)\n // the select would take that field's label for its name, its\n // description, and its name in the form. Laid out as its trigger.\n <BaseField.Root className=\"contents\">\n <Select.Root\n items={[\n ...presets.map((option, index) => ({\n value: `preset:${index}`,\n label: option.label,\n })),\n { value: CUSTOM, label: \"Custom\" },\n ]}\n value={preset ? `preset:${presets.indexOf(preset)}` : CUSTOM}\n onValueChange={(next) => {\n const option =\n presets[Number(String(next).slice(\"preset:\".length))];\n if (option != null && option !== preset) choosePreset(option);\n }}\n disabled={disabled || loading}\n >\n <Select.Trigger\n variant=\"inline\"\n aria-label=\"Preset\"\n // Last in the row, out by its padding (see the class); before\n // the ✕, a little closer to it.\n className={cn(\n SCOPE_PRESET_TRIGGER,\n collapsible ? \"-mr-1\" : \"-mr-2\",\n )}\n >\n <Select.Value />\n <Select.Icon>\n <ChevronDownIcon />\n </Select.Icon>\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner align=\"end\">\n <Select.Popup>\n <Select.List>\n {presets.map((option, index) => (\n <Select.Item key={index} value={`preset:${index}`}>\n <Select.ItemIndicator>\n <CheckIcon />\n </Select.ItemIndicator>\n <Select.ItemText>{option.label}</Select.ItemText>\n {option.description ? (\n <span className=\"text-pho-description col-start-2 text-xs\">\n {option.description}\n </span>\n ) : null}\n </Select.Item>\n ))}\n {/* Not picked, only shown: what a hand-made selection reads. */}\n <Select.Item value={CUSTOM} disabled>\n <Select.ItemIndicator>\n <CheckIcon />\n </Select.ItemIndicator>\n <Select.ItemText>Custom</Select.ItemText>\n </Select.Item>\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </BaseField.Root>\n ) : null;\n\n const picker = (\n <motion.div\n key=\"picker\"\n {...takeOver(reveal, heights.current.face, \"down\")}\n className=\"overflow-hidden\"\n >\n {/* The row the folded summary gives way to: the two cross where they\n stand, while the list under it unrolls with its ink down. */}\n <motion.div\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n transition={reveal.transition}\n className={SCOPE_SEARCH_ROW}\n >\n <GhostSearch\n ref={searchRef}\n value={query}\n onChange={setQuery}\n onClear={() => setQuery(\"\")}\n onKeyDown={onSearchKeyDown}\n placeholder={placeholder}\n aria-label={placeholder}\n aria-controls={loading ? undefined : listId}\n disabled={loading}\n trailing={\n count != null && !loading ? (\n // A card too narrow for both gives the room to the query; the\n // folded summary carries the count there.\n <span className=\"hidden group-data-[roomy]/scope:inline\">\n {count}\n </span>\n ) : undefined\n }\n autoComplete=\"off\"\n spellCheck={false}\n />\n {presetPicker}\n {collapsible ? (\n <CloseButton\n size=\"sm\"\n label=\"Cancel\"\n // Held open while the page saves: dropping the edit now would\n // show the old selection under a save that sends the new one.\n disabled={disabled}\n onClick={dismiss}\n // Out by its own padding: the ✕ stands as far from the right\n // edge as the magnifier from the left. Its ring inside, as a\n // Button's: the blocks around it clip.\n className=\"-mr-2 shrink-0 focus-visible:-outline-offset-2\"\n />\n ) : null}\n </motion.div>\n <AnimatePresence initial={false} mode=\"popLayout\">\n {loading ? bones : list}\n </AnimatePresence>\n </motion.div>\n );\n\n // The bones stand in the two lines' own boxes, so the card keeps its\n // height when the words arrive.\n const summaryText = loading ? (\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"flex h-5 items-center\">\n <Skeleton className=\"h-3.5 w-48 max-w-full\" />\n </span>\n <span className=\"flex h-4.5 items-center\">\n <Skeleton className=\"h-3 w-16\" />\n </span>\n </span>\n ) : (\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"text-pho-primary truncate text-base\">\n {summary.title}\n </span>\n {summary.detail ? (\n <span className=\"text-pho-description truncate text-xs tabular-nums\">\n {summary.detail}\n </span>\n ) : null}\n </span>\n );\n\n const folded = (\n <motion.div\n key=\"folded\"\n {...takeOver(reveal, heights.current.face)}\n className=\"overflow-hidden\"\n >\n {disabled || loading ? (\n <div className={SCOPE_SUMMARY}>{summaryText}</div>\n ) : (\n <button\n ref={summaryRef}\n type=\"button\"\n aria-expanded={false}\n className={cn(\n SCOPE_SUMMARY,\n \"group hover:bg-pho-primary-hover cursor-pointer transition-colors\",\n )}\n onClick={unfold}\n >\n {summaryText}\n <span\n aria-hidden\n className={buttonVariants({\n variant: \"ghost\",\n size: \"sm\",\n className:\n \"group-hover:bg-pho-ghost-hover group-hover:text-pho-secondary-hover pointer-events-none shrink-0\",\n })}\n >\n Edit\n </span>\n </button>\n )}\n </motion.div>\n );\n\n return (\n <div\n // oxlint-disable-next-line jsx-a11y/prefer-tag-over-role\n role=\"group\"\n aria-busy={loading || undefined}\n data-scope=\"\"\n data-open={open ? \"\" : undefined}\n data-wide={wide ? \"\" : undefined}\n data-roomy={roomy ? \"\" : undefined}\n className={cn(SCOPE_SURFACE, className)}\n {...props}\n ref={(node: HTMLDivElement | null) => {\n cardRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref != null) ref.current = node;\n }}\n >\n {/* Folding and opening, the faces trade places on Reveal's motion:\n the one arriving opens from the height the other stood at, the\n other fades where it stood. The card moves at its bottom edge, so\n the list unrolls from the top down, row by row, and rolls back up\n under it. */}\n <AnimatePresence initial={false} mode=\"popLayout\">\n {open ? picker : folded}\n </AnimatePresence>\n <Tooltip.Root\n handle={handle}\n onOpenChange={(next, details) => {\n // Only a description the row cuts short opens.\n if (next && !isClipped(details.event?.target)) details.cancel();\n }}\n >\n {({ payload }) => (\n <Tooltip.Portal>\n <Tooltip.Positioner side=\"top\" align=\"start\">\n <Tooltip.Popup className=\"max-w-80 font-normal\">\n {payload}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n )}\n </Tooltip.Root>\n </div>\n );\n}\n\nScope.displayName = \"Scope\";\n"],"mappings":";;;;;;;;;;;;;;;;AAoJA,IAAM2B,KACJ,8JAGIC,KAAc,2BASdC,KACJ,0FAWIC,KACJ,oRAGIC,KAAS,UAaTC,KACJ,qIAGIC,KACJ,qGAQIC,KACJ,sUAGIC,KACJ,gLAMIC,KACJ,kOAMIC,KACJ,sJAGIC,KACJ,6JAGIC,KAAW,IAEXC,KAAY;AAWlB,SAASC,GAAYC,GAAoC;AACvD,QAAM,CAACC,GAAMC,CAAA,IAAWzB,EAAS;AAAA,IAAE,MAAM;AAAA,IAAM,OAAO;AAAA,EAAK,CAAC,GACtD0B,IAAU3B,EAAO;AAAA,IAAE,MAAM;AAAA,IAAG,MAAM;AAAA,IAAG,OAAO;AAAA,EAAE,CAAC;AACrD,SAAAF,GAAA,MAAsB;AACpB,UAAM8B,IAAOJ,EAAI;AACjB,QAAII,KAAQ,KAAM;AAClB,UAAMC,IAAA,MAAgB;AACpB,MAAAF,EAAQ,QAAQ,OAAOC,EAAK;AAC5B,YAAME,IAAOF,EAAK,cAA2B,mBAAmB;AAChE,MAAIE,KAAQ,SAAMH,EAA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