@stackone/malachite 2.101.0 → 2.102.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/COMPONENTS.md +1 -1
- package/dist/ShadowRootWrapper.js +15 -14
- package/dist/ShadowRootWrapper.js.map +1 -1
- package/dist/components/FilterSearch.js +423 -308
- package/dist/components/FilterSearch.js.map +1 -1
- package/dist/components/droppedFocus.js +35 -0
- package/dist/components/droppedFocus.js.map +1 -0
- package/dist/components/filterSearchModel.js.map +1 -1
- package/dist/components/overlayBehaviour.js +77 -76
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useSyncExternalStore as O, useRef as p, useCallback as L, useEffect as C, useLayoutEffect as g } from "react";
|
|
2
|
-
import { getDeepActiveElement as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
2
|
+
import { getDeepActiveElement as K, containsComposed as W } from "./activeElement.js";
|
|
3
|
+
import { ensureDroppedFocusTracking as $, focusReturnTarget as q } from "./droppedFocus.js";
|
|
4
|
+
import { pushEscapeLayer as J } from "./escapeLayers.js";
|
|
5
|
+
import { FOCUS_RING as Q } from "./focusRing.js";
|
|
6
|
+
import { nextLayerTicket as X, popupLayerHolding as tt } from "./overlayLayers.js";
|
|
7
|
+
import { useOwnedByPopover as et } from "./popoverTree.js";
|
|
8
|
+
import { OVERLAY_Z_BASE as U, ensureElevatedOverlayStyles as nt } from "./portalOverlay.js";
|
|
9
|
+
import { lockBodyScroll as rt } from "./scrollLock.js";
|
|
10
|
+
import { leaveTopLayer as V, raiseToTopLayer as B } from "./topLayer.js";
|
|
11
|
+
const kt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-[4px] text-[var(--malachite-text-secondary)] hover:text-[var(--malachite-text-primary)] transition-colors ${Q}`, ot = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])', st = (t) => t.assignedSlot ?? t.parentElement ?? (t.parentNode instanceof ShadowRoot ? t.parentNode.host : null), ct = (t) => Array.from(t.children).find((r) => r.tagName === "SUMMARY"), at = () => {
|
|
11
12
|
const t = /* @__PURE__ */ new Map(), r = (e) => {
|
|
12
13
|
const n = t.get(e);
|
|
13
14
|
if (n)
|
|
14
15
|
return n;
|
|
15
|
-
const { display: a, visibility: o, contentVisibility: s } = getComputedStyle(e), c =
|
|
16
|
+
const { display: a, visibility: o, contentVisibility: s } = getComputedStyle(e), c = st(e), d = c ? r(c) : null, f = c instanceof HTMLDetailsElement && !c.open && ct(c) !== e, h = {
|
|
16
17
|
hidden: e.hasAttribute("inert") || a === "none" || f || !!(d && (d.hidden || d.hidesContent)),
|
|
17
18
|
invisible: o === "hidden" || o === "collapse",
|
|
18
19
|
hidesContent: s === "hidden"
|
|
@@ -20,43 +21,43 @@ const Lt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md
|
|
|
20
21
|
return t.set(e, h), h;
|
|
21
22
|
};
|
|
22
23
|
return r;
|
|
23
|
-
},
|
|
24
|
+
}, it = (t, r) => {
|
|
24
25
|
if (t.tabIndex < 0 || t.matches(":disabled"))
|
|
25
26
|
return !1;
|
|
26
27
|
const { hidden: e, invisible: n } = r(t);
|
|
27
28
|
return !e && !n;
|
|
28
|
-
},
|
|
29
|
-
if (!
|
|
29
|
+
}, G = (t) => t instanceof HTMLInputElement && t.type === "radio" && t.name !== "", ut = (t, r) => {
|
|
30
|
+
if (!G(t))
|
|
30
31
|
return !1;
|
|
31
32
|
const e = r.filter(
|
|
32
|
-
(n) =>
|
|
33
|
+
(n) => G(n) && n.name === t.name && n.form === t.form
|
|
33
34
|
);
|
|
34
35
|
return (e.find((n) => n.checked) ?? e[0]) !== t;
|
|
35
|
-
},
|
|
36
|
+
}, dt = (t, r) => t.map((e, n) => ({ element: e, index: n, tabIndex: r(e) })).sort((e, n) => e.tabIndex !== n.tabIndex ? e.tabIndex === 0 ? 1 : n.tabIndex === 0 ? -1 : e.tabIndex - n.tabIndex : e.index - n.index).map(({ element: e }) => e), w = (t) => t instanceof HTMLSlotElement && t.getRootNode() instanceof ShadowRoot, T = (t, r = []) => {
|
|
36
37
|
for (const e of t)
|
|
37
|
-
r.push(e), !e.shadowRoot && !
|
|
38
|
+
r.push(e), !e.shadowRoot && !w(e) && T(e.children, r);
|
|
38
39
|
return r;
|
|
39
40
|
}, R = (t, r) => {
|
|
40
41
|
const e = t.filter(
|
|
41
|
-
(o) => o instanceof HTMLElement && o.matches(
|
|
42
|
+
(o) => o instanceof HTMLElement && o.matches(ot) && it(o, r)
|
|
42
43
|
), n = new Set(
|
|
43
|
-
e.filter((o) => !
|
|
44
|
+
e.filter((o) => !ut(o, e))
|
|
44
45
|
), a = t.filter(
|
|
45
|
-
(o) => n.has(o) || o.shadowRoot ||
|
|
46
|
+
(o) => n.has(o) || o.shadowRoot || w(o)
|
|
46
47
|
);
|
|
47
|
-
return
|
|
48
|
+
return dt(
|
|
48
49
|
a,
|
|
49
50
|
(o) => n.has(o) ? o.tabIndex : 0
|
|
50
51
|
).flatMap((o) => {
|
|
51
|
-
if (
|
|
52
|
-
return R(
|
|
52
|
+
if (w(o))
|
|
53
|
+
return R(T(o.assignedElements({ flatten: !0 })), r);
|
|
53
54
|
const s = o.shadowRoot;
|
|
54
55
|
if (s && Number.parseInt(o.getAttribute("tabindex") ?? "", 10) < 0)
|
|
55
56
|
return [];
|
|
56
57
|
const c = n.has(o) && !(s != null && s.delegatesFocus) ? [o] : [];
|
|
57
|
-
return s ? [...c, ...R(
|
|
58
|
+
return s ? [...c, ...R(T(s.children), r)] : c;
|
|
58
59
|
});
|
|
59
|
-
}, D = (t) => R(
|
|
60
|
+
}, D = (t) => R(T(t.children), at()), ft = (t, r) => {
|
|
60
61
|
const e = (o) => {
|
|
61
62
|
const s = [o];
|
|
62
63
|
for (let c = o.getRootNode(); c instanceof ShadowRoot; c = c.host.getRootNode())
|
|
@@ -69,10 +70,10 @@ const Lt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md
|
|
|
69
70
|
return o !== s ? o.compareDocumentPosition(s) : o === t ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
|
70
71
|
}
|
|
71
72
|
return Node.DOCUMENT_POSITION_DISCONNECTED;
|
|
72
|
-
},
|
|
73
|
+
}, lt = (t) => D(t)[0] ?? null, i = [], S = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set(), pt = () => {
|
|
73
74
|
};
|
|
74
75
|
let b = [];
|
|
75
|
-
const A = /* @__PURE__ */ new Set(),
|
|
76
|
+
const A = /* @__PURE__ */ new Set(), ht = () => {
|
|
76
77
|
const t = S.size ? i.map((e) => {
|
|
77
78
|
var n;
|
|
78
79
|
return (n = M.get(e)) == null ? void 0 : n();
|
|
@@ -83,26 +84,26 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
83
84
|
for (const e of b)
|
|
84
85
|
r.has(e) || V(e);
|
|
85
86
|
for (const e of t)
|
|
86
|
-
|
|
87
|
+
B(e);
|
|
87
88
|
b = t;
|
|
88
89
|
for (const e of A)
|
|
89
|
-
|
|
90
|
-
},
|
|
90
|
+
B(e);
|
|
91
|
+
}, wt = (t) => (A.add(t), () => {
|
|
91
92
|
A.delete(t);
|
|
92
|
-
}),
|
|
93
|
+
}), I = () => {
|
|
93
94
|
for (const t of v)
|
|
94
95
|
t();
|
|
95
96
|
}, Y = (t) => (v.add(t), () => {
|
|
96
97
|
v.delete(t);
|
|
97
|
-
}),
|
|
98
|
+
}), P = (t, r, e, n) => {
|
|
98
99
|
const a = n[0], o = n[n.length - 1], s = W(e, r);
|
|
99
100
|
if (r && s && r !== e && !n.includes(r)) {
|
|
100
101
|
const c = t.shiftKey ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
|
|
101
|
-
n.some((d) =>
|
|
102
|
+
n.some((d) => ft(r, d) & c) || (t.preventDefault(), (t.shiftKey ? o : a).focus());
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
t.shiftKey ? (!s || r === a || r === e) && (t.preventDefault(), o.focus()) : (!s || r === o || r === e) && (t.preventDefault(), a.focus());
|
|
105
|
-
},
|
|
106
|
+
}, H = (t) => {
|
|
106
107
|
if (t.key !== "Tab" || t.defaultPrevented)
|
|
107
108
|
return;
|
|
108
109
|
let r = null, e = 0;
|
|
@@ -110,14 +111,14 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
110
111
|
r = i[s](), r && (e = _.get(i[s]) ?? 0);
|
|
111
112
|
if (!r)
|
|
112
113
|
return;
|
|
113
|
-
const n =
|
|
114
|
+
const n = K(), a = n ? tt(n) : null;
|
|
114
115
|
if (n && a && a.ticket > e) {
|
|
115
116
|
const s = a.popup.shadowRoot ?? a.popup, c = D(s);
|
|
116
117
|
if (c.length === 0) {
|
|
117
118
|
t.preventDefault();
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
+
P(t, n, s, c);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
const o = D(r);
|
|
@@ -125,32 +126,32 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
125
126
|
t.preventDefault(), r.focus();
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
-
},
|
|
129
|
+
P(t, n, r, o);
|
|
130
|
+
}, St = (t, r) => (i.length === 0 && document.addEventListener("keydown", H), i.push(t), M.set(t, r), _.set(t, X()), I(), () => {
|
|
130
131
|
const e = i.lastIndexOf(t);
|
|
131
132
|
e !== -1 && i.splice(e, 1), S.delete(t), M.delete(t), _.delete(t);
|
|
132
133
|
const n = r();
|
|
133
|
-
n && V(n), i.length === 0 && document.removeEventListener("keydown",
|
|
134
|
-
}),
|
|
134
|
+
n && V(n), i.length === 0 && document.removeEventListener("keydown", H), I();
|
|
135
|
+
}), yt = (t) => {
|
|
135
136
|
const r = i.lastIndexOf(t);
|
|
136
137
|
return r === -1 ? void 0 : i.slice(r + 1).find((e) => {
|
|
137
138
|
var n;
|
|
138
139
|
return ((n = e()) == null ? void 0 : n.isConnected) === !0;
|
|
139
140
|
});
|
|
140
|
-
},
|
|
141
|
+
}, k = /* @__PURE__ */ new Map(), Rt = () => O(
|
|
141
142
|
Y,
|
|
142
143
|
() => i.length > 0,
|
|
143
144
|
() => !1
|
|
144
|
-
),
|
|
145
|
+
), z = (t, r) => {
|
|
145
146
|
if (r === "content") {
|
|
146
|
-
const e =
|
|
147
|
+
const e = K();
|
|
147
148
|
if (W(t, e))
|
|
148
149
|
return;
|
|
149
|
-
(
|
|
150
|
+
(lt(t) ?? t).focus();
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
t.focus();
|
|
153
|
-
},
|
|
154
|
+
}, Dt = ({
|
|
154
155
|
open: t,
|
|
155
156
|
onClose: r,
|
|
156
157
|
elevated: e = !1,
|
|
@@ -159,77 +160,77 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
159
160
|
onYield: o
|
|
160
161
|
}) => {
|
|
161
162
|
const s = p(null), c = p(() => s.current).current;
|
|
162
|
-
|
|
163
|
+
et(
|
|
163
164
|
L(() => (n == null ? void 0 : n.current) ?? s.current, [n]),
|
|
164
165
|
t
|
|
165
166
|
);
|
|
166
|
-
const d = p(null), f = p(null), h = p(a),
|
|
167
|
+
const d = p(null), f = p(null), h = p(a), F = p(r), m = p(o);
|
|
167
168
|
C(() => {
|
|
168
|
-
|
|
169
|
+
F.current = r, m.current = o;
|
|
169
170
|
}, [r, o]), C(() => {
|
|
170
|
-
if (t)
|
|
171
|
-
return d.current =
|
|
171
|
+
if ($(), !!t)
|
|
172
|
+
return d.current = q(), () => {
|
|
172
173
|
const u = d.current;
|
|
173
174
|
d.current = null;
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
175
|
+
const E = k.get(c);
|
|
176
|
+
if (k.delete(c), f.current === null)
|
|
176
177
|
return;
|
|
177
|
-
const l = u != null && u.isConnected ? u :
|
|
178
|
-
x && l &&
|
|
178
|
+
const l = u != null && u.isConnected ? u : E, x = yt(c);
|
|
179
|
+
x && l && k.set(x, l), !x && (l != null && l.isConnected) && l.focus();
|
|
179
180
|
};
|
|
180
181
|
}, [t, c]), C(() => {
|
|
181
182
|
if (!t)
|
|
182
183
|
return;
|
|
183
|
-
if (
|
|
184
|
-
|
|
184
|
+
if (m.current && i.length > 0) {
|
|
185
|
+
m.current();
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
188
|
f.current = c;
|
|
188
|
-
const u =
|
|
189
|
-
return s.current &&
|
|
190
|
-
f.current = null, l(), u(),
|
|
189
|
+
const u = J(() => F.current()), E = rt(), l = St(c, () => (n == null ? void 0 : n.current) ?? null);
|
|
190
|
+
return s.current && z(s.current, h.current), () => {
|
|
191
|
+
f.current = null, l(), u(), E();
|
|
191
192
|
};
|
|
192
193
|
}, [t, n, c]), g(() => {
|
|
193
194
|
if (!(!t || !e))
|
|
194
|
-
return S.add(c),
|
|
195
|
-
S.delete(c),
|
|
195
|
+
return S.add(c), I(), () => {
|
|
196
|
+
S.delete(c), I();
|
|
196
197
|
};
|
|
197
198
|
}, [t, e, c]);
|
|
198
|
-
const
|
|
199
|
-
(u) => t ? Y(u) :
|
|
199
|
+
const N = L(
|
|
200
|
+
(u) => t ? Y(u) : pt,
|
|
200
201
|
[t]
|
|
201
202
|
), j = O(
|
|
202
|
-
|
|
203
|
+
N,
|
|
203
204
|
// Gated on `open` so an overlay fading out stops claiming modal. Before it registers
|
|
204
205
|
// it is the one about to go on top, or aria-modal would drop for a frame on open.
|
|
205
206
|
() => t && (f.current === null || i[i.length - 1] === f.current),
|
|
206
207
|
() => !0
|
|
207
208
|
), y = O(
|
|
208
|
-
|
|
209
|
+
N,
|
|
209
210
|
() => t && (e || S.size > 0),
|
|
210
211
|
() => !1
|
|
211
212
|
), Z = O(
|
|
212
|
-
|
|
213
|
+
N,
|
|
213
214
|
() => {
|
|
214
215
|
const u = f.current;
|
|
215
|
-
return
|
|
216
|
+
return U + (t && u ? Math.max(0, i.indexOf(u)) : 0);
|
|
216
217
|
},
|
|
217
|
-
() =>
|
|
218
|
+
() => U
|
|
218
219
|
);
|
|
219
220
|
return g(() => {
|
|
220
|
-
y &&
|
|
221
|
+
y && nt();
|
|
221
222
|
}, [y]), g(() => {
|
|
222
|
-
|
|
223
|
+
ht();
|
|
223
224
|
}), { ref: L((u) => {
|
|
224
|
-
s.current = u, u && f.current !== null &&
|
|
225
|
+
s.current = u, u && f.current !== null && z(u, h.current);
|
|
225
226
|
}, []), isTopmost: j, zIndex: y ? void 0 : Z, elevated: y };
|
|
226
227
|
};
|
|
227
228
|
export {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
ot as FOCUSABLE_SELECTOR,
|
|
230
|
+
kt as OVERLAY_ICON_BUTTON_CLASSES,
|
|
231
|
+
lt as firstTabStopIn,
|
|
232
|
+
wt as keepAboveOverlayStack,
|
|
233
|
+
Rt as useHasOpenOverlay,
|
|
234
|
+
Dt as useOverlayBehaviour
|
|
234
235
|
};
|
|
235
236
|
//# sourceMappingURL=overlayBehaviour.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlayBehaviour.js","sources":["../../src/components/overlayBehaviour.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useSyncExternalStore } from 'react';\nimport { containsComposed, getDeepActiveElement } from './activeElement';\nimport { pushEscapeLayer } from './escapeLayers';\nimport { FOCUS_RING } from './focusRing';\nimport { nextLayerTicket, popupLayerHolding } from './overlayLayers';\nimport { useOwnedByPopover } from './popoverTree';\nimport { OVERLAY_Z_BASE, ensureElevatedOverlayStyles } from './portalOverlay';\nimport { lockBodyScroll } from './scrollLock';\nimport { leaveTopLayer, raiseToTopLayer } from './topLayer';\n\n/** Back/close button chrome, shared so the two overlays cannot drift apart. */\nexport const OVERLAY_ICON_BUTTON_CLASSES = `flex shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-[4px] text-[var(--malachite-text-secondary)] hover:text-[var(--malachite-text-primary)] transition-colors ${FOCUS_RING}`;\n\n// `summary`: a disclosure's first one is a native tab stop and its only keyboard control. A loose\n// one reports `tabIndex === -1`, which `isTabStop` drops.\nexport const FOCUSABLE_SELECTOR =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex=\"-1\"])';\n\n// The flat-tree parent: a slotted element renders under its slot, a shadow root under its host.\nconst flatParent = (element: Element): Element | null =>\n element.assignedSlot ??\n element.parentElement ??\n (element.parentNode instanceof ShadowRoot ? element.parentNode.host : null);\n\n// `children`, not `:scope > summary`: inside a shadow root jsdom's selector engine matches\n// nothing for `:scope`, which silently hid the summary along with the rest.\nconst firstSummaryOf = (details: HTMLDetailsElement): Element | undefined =>\n Array.from(details.children).find((child) => child.tagName === 'SUMMARY');\n\ntype RenderState = { hidden: boolean; invisible: boolean; hidesContent: boolean };\n\n// Reads computed style: call at interaction time only, never from a mount path. Under jsdom,\n// `offsetParent`, `getClientRects()` and `checkVisibility()` report every element invisible.\n// One per Tab press, so an ancestor shared by many controls has its style read once.\nconst createRenderStates = (): ((element: Element) => RenderState) => {\n const states = new Map<Element, RenderState>();\n const stateOf = (element: Element): RenderState => {\n const cached = states.get(element);\n if (cached) {\n return cached;\n }\n const { display, visibility, contentVisibility } = getComputedStyle(element);\n const parent = flatParent(element);\n const parentState = parent ? stateOf(parent) : null;\n // A closed `<details>` hides all but its summary in the UA shadow slot, so the hidden\n // descendants keep `tabIndex === 0` and a normal computed display.\n const closedDisclosure =\n parent instanceof HTMLDetailsElement &&\n !parent.open &&\n firstSummaryOf(parent) !== element;\n const state = {\n hidden:\n element.hasAttribute('inert') ||\n display === 'none' ||\n closedDisclosure ||\n Boolean(parentState && (parentState.hidden || parentState.hidesContent)),\n invisible: visibility === 'hidden' || visibility === 'collapse',\n hidesContent: contentVisibility === 'hidden',\n };\n states.set(element, state);\n return state;\n };\n return stateOf;\n};\n\nconst isTabStop = (element: HTMLElement, stateOf: (element: Element) => RenderState): boolean => {\n if (element.tabIndex < 0 || element.matches(':disabled')) {\n return false;\n }\n const { hidden, invisible } = stateOf(element);\n\n return !hidden && !invisible;\n};\n\nconst isGroupedRadio = (element: Element): element is HTMLInputElement =>\n element instanceof HTMLInputElement && element.type === 'radio' && element.name !== '';\n\n// Only a group's checked radio, or its first with none checked, is a tab stop, yet every member\n// reports `tabIndex === 0`.\nconst skipsWithinRadioGroup = (element: HTMLElement, reachable: HTMLElement[]): boolean => {\n if (!isGroupedRadio(element)) {\n return false;\n }\n const group = reachable.filter(\n (candidate): candidate is HTMLInputElement =>\n isGroupedRadio(candidate) &&\n candidate.name === element.name &&\n candidate.form === element.form,\n );\n\n return (group.find((radio) => radio.checked) ?? group[0]) !== element;\n};\n\nconst inTabOrder = (entries: Element[], tabIndexOf: (element: Element) => number): Element[] =>\n entries\n .map((element, index) => ({ element, index, tabIndex: tabIndexOf(element) }))\n .sort((left, right) => {\n if (left.tabIndex !== right.tabIndex) {\n if (left.tabIndex === 0) {\n return 1;\n }\n if (right.tabIndex === 0) {\n return -1;\n }\n\n return left.tabIndex - right.tabIndex;\n }\n\n return left.index - right.index;\n })\n .map(({ element }) => element);\n\n// Only a slot inside a shadow root projects assigned content; elsewhere it renders its children.\nconst isShadowSlot = (element: Element): element is HTMLSlotElement =>\n element instanceof HTMLSlotElement && element.getRootNode() instanceof ShadowRoot;\n\n// One focus navigation scope in tree order. A host's light children render only through its\n// slots, and hosts and slots each own a scope, so the walk descends into neither.\nconst scopeMembers = (elements: Iterable<Element>, into: Element[] = []): Element[] => {\n for (const element of elements) {\n into.push(element);\n if (!element.shadowRoot && !isShadowSlot(element)) {\n scopeMembers(element.children, into);\n }\n }\n return into;\n};\n\n// Ordered per scope, as browsers do: positive tabindex orders within its own scope, and a nested\n// scope takes its owner's place, an owner that is no stop itself ordering as tabindex 0.\nconst stopsInScope = (\n members: Element[],\n stateOf: (element: Element) => RenderState,\n): HTMLElement[] => {\n const reachable = members.filter(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n element.matches(FOCUSABLE_SELECTOR) &&\n isTabStop(element, stateOf),\n );\n const stops = new Set<Element>(\n reachable.filter((element) => !skipsWithinRadioGroup(element, reachable)),\n );\n const entries = members.filter(\n (element) => stops.has(element) || element.shadowRoot || isShadowSlot(element),\n );\n\n return inTabOrder(entries, (element) =>\n stops.has(element) ? (element as HTMLElement).tabIndex : 0,\n ).flatMap((element) => {\n if (isShadowSlot(element)) {\n return stopsInScope(scopeMembers(element.assignedElements({ flatten: true })), stateOf);\n }\n const root = element.shadowRoot;\n // A host given a negative tabindex keeps its whole shadow tree out of the order; an\n // unparsable value counts as absent, as it does for any element.\n if (root && Number.parseInt(element.getAttribute('tabindex') ?? '', 10) < 0) {\n return [];\n }\n const own = stops.has(element) && !root?.delegatesFocus ? [element as HTMLElement] : [];\n\n return root ? [...own, ...stopsInScope(scopeMembers(root.children), stateOf)] : own;\n });\n};\n\nconst tabStopsIn = (root: ParentNode): HTMLElement[] =>\n stopsInScope(scopeMembers(root.children), createRenderStates());\n\n// `compareDocumentPosition` calls nodes in different shadow trees disconnected, so lift both\n// into their deepest shared tree first; a host precedes its own shadow content.\nconst composedPosition = (from: Node, to: Node): number => {\n const ancestry = (node: Node): Node[] => {\n const chain = [node];\n for (\n let root = node.getRootNode();\n root instanceof ShadowRoot;\n root = root.host.getRootNode()\n ) {\n chain.push(root.host);\n }\n return chain;\n };\n const fromChain = ancestry(from);\n const toChain = ancestry(to);\n for (const fromStep of fromChain) {\n const toStep = toChain.find((step) => step.getRootNode() === fromStep.getRootNode());\n if (!toStep) {\n continue;\n }\n if (fromStep !== toStep) {\n return fromStep.compareDocumentPosition(toStep);\n }\n\n return fromStep === from\n ? Node.DOCUMENT_POSITION_FOLLOWING\n : Node.DOCUMENT_POSITION_PRECEDING;\n }\n\n return Node.DOCUMENT_POSITION_DISCONNECTED;\n};\n\n/** Where Tab would land first, for initial focus: the raw selector also matches hidden controls. */\nexport const firstTabStopIn = (root: ParentNode): HTMLElement | null => tabStopsIn(root)[0] ?? null;\n\ntype PanelSource = () => HTMLElement | null;\n\n// LIFO like escapeLayers: with a listener per overlay the first-registered one wins, which\n// sent Tab from a dialog into the panel behind it.\nconst trapLayers: PanelSource[] = [];\n// Elevation belongs to the stack: a Modal left in the base band opens behind the panel that\n// elevated it.\nconst elevatedLayers = new Set<PanelSource>();\n// The shadow host per layer, so promotion can replay in stack order.\nconst hostSources = new Map<PanelSource, () => HTMLElement | null>();\nconst trapTickets = new Map<PanelSource, number>();\nconst stackListeners = new Set<() => void>();\nconst NO_SUBSCRIPTION = () => {\n // Nothing to tear down: a closed overlay never subscribed.\n};\n\n// Top-layer paint order is entry order, so replay the whole stack bottom-up rather than letting\n// each overlay promote itself: those effects run in React tree order, which need not match.\nlet promoted: HTMLElement[] = [];\nconst aboveStack = new Set<HTMLElement>();\n\nconst syncTopLayer = (): void => {\n const wanted = elevatedLayers.size\n ? trapLayers\n .map((layer) => hostSources.get(layer)?.())\n .filter((host): host is HTMLElement => Boolean(host))\n : [];\n // Compared, not reapplied: this runs on every commit, because a host can appear a commit\n // after the layer that owns it, and re-entering the top layer unprompted costs a recalc.\n if (\n wanted.length === promoted.length &&\n wanted.every((host, index) => host === promoted[index])\n ) {\n return;\n }\n const stillWanted = new Set(wanted);\n for (const host of promoted) {\n if (!stillWanted.has(host)) {\n leaveTopLayer(host);\n }\n }\n for (const host of wanted) {\n raiseToTopLayer(host);\n }\n promoted = wanted;\n for (const host of aboveStack) {\n raiseToTopLayer(host);\n }\n};\n\n/** Keeps a promoted host above the elevated stack each time the stack is replayed. */\nexport const keepAboveOverlayStack = (host: HTMLElement): (() => void) => {\n aboveStack.add(host);\n return () => {\n aboveStack.delete(host);\n };\n};\n\nconst notifyStackChanged = (): void => {\n for (const listener of stackListeners) {\n listener();\n }\n};\n\nconst subscribeToStack = (listener: () => void): (() => void) => {\n stackListeners.add(listener);\n return () => {\n stackListeners.delete(listener);\n };\n};\n\nconst wrapTab = (\n event: KeyboardEvent,\n active: HTMLElement | null,\n within: Node,\n stops: HTMLElement[],\n): void => {\n const first = stops[0];\n const last = stops[stops.length - 1];\n const inside = containsComposed(within, active);\n // A mouse-only control, such as a search Dropdown's caret, is no edge: Tab resumes from its\n // place in the DOM and would leave the overlay where no real stop follows it.\n if (active && inside && active !== within && !stops.includes(active)) {\n const wanted = event.shiftKey\n ? Node.DOCUMENT_POSITION_PRECEDING\n : Node.DOCUMENT_POSITION_FOLLOWING;\n if (!stops.some((stop) => composedPosition(active, stop) & wanted)) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n\n return;\n }\n if (event.shiftKey) {\n if (!inside || active === first || active === within) {\n event.preventDefault();\n last.focus();\n }\n } else if (!inside || active === last || active === within) {\n event.preventDefault();\n first.focus();\n }\n};\n\nconst handleTabKeyDown = (event: KeyboardEvent): void => {\n if (event.key !== 'Tab' || event.defaultPrevented) {\n return;\n }\n // Walk down rather than bail: React detaches refs before flushing the cleanup that pops\n // the layer, so the topmost can be registered-but-null and Tab would escape entirely.\n let panel: HTMLElement | null = null;\n let trapTicket = 0;\n for (let index = trapLayers.length - 1; index >= 0 && !panel; index -= 1) {\n panel = trapLayers[index]();\n if (panel) {\n trapTicket = trapTickets.get(trapLayers[index]) ?? 0;\n }\n }\n if (!panel) {\n return;\n }\n const active = getDeepActiveElement();\n const layer = active ? popupLayerHolding(active) : null;\n if (active && layer && layer.ticket > trapTicket) {\n const root = layer.popup.shadowRoot ?? layer.popup;\n const popupStops = tabStopsIn(root);\n if (popupStops.length === 0) {\n event.preventDefault();\n return;\n }\n wrapTab(event, active, root, popupStops);\n return;\n }\n const focusables = tabStopsIn(panel);\n if (focusables.length === 0) {\n event.preventDefault();\n panel.focus();\n return;\n }\n wrapTab(event, active, panel, focusables);\n};\n\n// On `document` so it also catches focus that escaped behind the overlay.\nconst pushFocusTrapLayer = (getPanel: PanelSource, getHost: () => HTMLElement | null) => {\n if (trapLayers.length === 0) {\n document.addEventListener('keydown', handleTabKeyDown);\n }\n trapLayers.push(getPanel);\n hostSources.set(getPanel, getHost);\n trapTickets.set(getPanel, nextLayerTicket());\n notifyStackChanged();\n return () => {\n const index = trapLayers.lastIndexOf(getPanel);\n if (index !== -1) {\n trapLayers.splice(index, 1);\n }\n elevatedLayers.delete(getPanel);\n hostSources.delete(getPanel);\n trapTickets.delete(getPanel);\n const host = getHost();\n if (host) {\n leaveTopLayer(host);\n }\n if (trapLayers.length === 0) {\n document.removeEventListener('keydown', handleTabKeyDown);\n }\n notifyStackChanged();\n };\n};\n\n// A layer unmounting in the same commit has already left the DOM when passive cleanups run.\nconst coveringLayer = (source: PanelSource): PanelSource | undefined => {\n const index = trapLayers.lastIndexOf(source);\n return index === -1\n ? undefined\n : trapLayers.slice(index + 1).find((layer) => layer()?.isConnected === true);\n};\n\nconst inheritedRestoreTargets = new Map<PanelSource, HTMLElement>();\n\n/**\n * Whether a SidePanel, Modal or CommandPalette is open anywhere, for host chrome that has to move out of the way.\n * Overlays portal, so the only other signal is this module's markers, which a host cannot read\n * without coupling to an internal. Dropdowns and tooltips do not count: they trap no focus.\n */\nexport const useHasOpenOverlay = (): boolean =>\n useSyncExternalStore(\n subscribeToStack,\n () => trapLayers.length > 0,\n () => false,\n );\n\nconst takeInitialFocus = (panel: HTMLElement, initialFocus: 'panel' | 'content'): void => {\n if (initialFocus === 'content') {\n const active = getDeepActiveElement();\n if (containsComposed(panel, active)) {\n return;\n }\n (firstTabStopIn(panel) ?? panel).focus();\n return;\n }\n panel.focus();\n};\n\n/**\n * The modal-overlay behaviour shared by SidePanel, Modal and CommandPalette: ESC and the Tab focus trap\n * (topmost overlay only, so these may be stacked), background scroll lock, and focus moved\n * into the overlay on open then restored to the trigger on close.\n *\n * Returns the ref callback the dialog element must take, whether this overlay is the topmost\n * one — only that one may claim `aria-modal`, or a screen reader can still browse the overlay\n * underneath — the z-index its host must carry, which keeps paint order with the focus stack,\n * and whether it is elevated. Presentation otherwise stays with the calling component.\n */\nexport const useOverlayBehaviour = ({\n open,\n onClose,\n elevated = false,\n hostRef,\n initialFocus = 'panel',\n onYield,\n}: {\n open: boolean;\n onClose: () => void;\n elevated?: boolean;\n /** The shadow host, which the stack promotes into the top layer while elevated. */\n hostRef?: { current: HTMLElement | null };\n /** Where focus lands on open: the panel itself, or the content's own first control. */\n initialFocus?: 'panel' | 'content';\n /** Called instead of opening while another overlay is open; the caller must then render closed. */\n onYield?: () => void;\n}): {\n ref: (node: HTMLElement | null) => void;\n isTopmost: boolean;\n zIndex: number | undefined;\n elevated: boolean;\n} => {\n const panelRef = useRef<HTMLElement | null>(null);\n // One identity for the life of the instance: elevation registers it in the layout phase,\n // before the effect below pushes it onto the stack.\n const source = useRef<PanelSource>(() => panelRef.current).current;\n useOwnedByPopover(\n useCallback(() => hostRef?.current ?? panelRef.current, [hostRef]),\n open,\n );\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const layerRef = useRef<PanelSource | null>(null);\n const initialFocusRef = useRef(initialFocus);\n\n // Ref so the ESC layer registers once per open, not on every inline-onClose change.\n const onCloseRef = useRef(onClose);\n const onYieldRef = useRef(onYield);\n useEffect(() => {\n onCloseRef.current = onClose;\n onYieldRef.current = onYield;\n }, [onClose, onYield]);\n\n // Before the trap effect, so the trigger is recorded before focus moves in.\n useEffect(() => {\n if (!open) {\n return;\n }\n previousFocusRef.current = getDeepActiveElement();\n return () => {\n const recorded = previousFocusRef.current;\n previousFocusRef.current = null;\n const inherited = inheritedRestoreTargets.get(source);\n inheritedRestoreTargets.delete(source);\n if (layerRef.current === null) {\n return;\n }\n const target = recorded?.isConnected ? recorded : inherited;\n // Runs before the trap cleanup below, so a registered layer is still on the stack.\n const above = coveringLayer(source);\n if (above && target) {\n inheritedRestoreTargets.set(above, target);\n }\n if (!above && target?.isConnected) {\n target.focus();\n }\n };\n }, [open, source]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n // Checked here, not at render: a dialog opening in the same commit registers only in its effects.\n if (onYieldRef.current && trapLayers.length > 0) {\n onYieldRef.current();\n return;\n }\n layerRef.current = source;\n const popEscapeLayer = pushEscapeLayer(() => onCloseRef.current());\n const releaseScrollLock = lockBodyScroll();\n const popFocusTrapLayer = pushFocusTrapLayer(source, () => hostRef?.current ?? null);\n // Reopening inside the exit transition reuses the same node, so the ref callback\n // never fires again and nothing would take focus.\n if (panelRef.current) {\n takeInitialFocus(panelRef.current, initialFocusRef.current);\n }\n return () => {\n layerRef.current = null;\n popFocusTrapLayer();\n popEscapeLayer();\n releaseScrollLock();\n };\n }, [open, hostRef, source]);\n\n // Its own effect: re-pushing the trap layer to change elevation would move this overlay to\n // the top of the stack, handing it the Escape and Tab that belong to a dialog above it.\n // Layout, and declared above the sync below, so that sync sees it in the same commit.\n useLayoutEffect(() => {\n if (!open || !elevated) {\n return;\n }\n elevatedLayers.add(source);\n notifyStackChanged();\n return () => {\n elevatedLayers.delete(source);\n notifyStackChanged();\n };\n }, [open, elevated, source]);\n\n // Only an open overlay subscribes: a mounted-but-idle one must carry no at-rest cost,\n // and its snapshot is a constant `false` regardless of what the stack does.\n const subscribe = useCallback(\n (onStackChange: () => void) => (open ? subscribeToStack(onStackChange) : NO_SUBSCRIPTION),\n [open],\n );\n\n const isTopmost = useSyncExternalStore(\n subscribe,\n // Gated on `open` so an overlay fading out stops claiming modal. Before it registers\n // it is the one about to go on top, or aria-modal would drop for a frame on open.\n () =>\n open &&\n (layerRef.current === null || trapLayers[trapLayers.length - 1] === layerRef.current),\n () => true,\n );\n\n // Its own request counts before the stack has it: the layer is not pushed until effects run.\n const stackElevated = useSyncExternalStore(\n subscribe,\n () => open && (elevated || elevatedLayers.size > 0),\n () => false,\n );\n\n // Overlay hosts share one z-index band, so paint order would otherwise fall out of body\n // order: an overlay reopened over a newer one takes the keyboard while painting under it.\n const zIndex = useSyncExternalStore(\n subscribe,\n () => {\n const layer = layerRef.current;\n return OVERLAY_Z_BASE + (open && layer ? Math.max(0, trapLayers.indexOf(layer)) : 0);\n },\n () => OVERLAY_Z_BASE,\n );\n\n // Layout, not passive: the rule has to exist before the first paint the attribute applies to.\n useLayoutEffect(() => {\n if (stackElevated) {\n ensureElevatedOverlayStyles();\n }\n }, [stackElevated]);\n\n // No deps: the host mounts a commit after the layer that owns it, so there is no stack\n // change left to key this on. `syncTopLayer` compares before it touches anything.\n useLayoutEffect(() => {\n syncTopLayer();\n });\n\n const ref = useCallback((node: HTMLElement | null) => {\n panelRef.current = node;\n // A panel portaled in after its layer registered takes focus here; any other, from the effect.\n if (node && layerRef.current !== null) {\n takeInitialFocus(node, initialFocusRef.current);\n }\n }, []);\n\n return { ref, isTopmost, zIndex: stackElevated ? undefined : zIndex, elevated: stackElevated };\n};\n\nexport default useOverlayBehaviour;\n"],"names":["OVERLAY_ICON_BUTTON_CLASSES","FOCUS_RING","FOCUSABLE_SELECTOR","flatParent","element","firstSummaryOf","details","child","createRenderStates","states","stateOf","cached","display","visibility","contentVisibility","parent","parentState","closedDisclosure","state","isTabStop","hidden","invisible","isGroupedRadio","skipsWithinRadioGroup","reachable","group","candidate","radio","inTabOrder","entries","tabIndexOf","index","left","right","isShadowSlot","scopeMembers","elements","into","stopsInScope","members","stops","root","own","tabStopsIn","composedPosition","from","to","ancestry","node","chain","fromChain","toChain","fromStep","toStep","step","firstTabStopIn","trapLayers","elevatedLayers","hostSources","trapTickets","stackListeners","NO_SUBSCRIPTION","promoted","aboveStack","syncTopLayer","wanted","layer","_a","host","stillWanted","leaveTopLayer","raiseToTopLayer","keepAboveOverlayStack","notifyStackChanged","listener","subscribeToStack","wrapTab","event","active","within","first","last","inside","containsComposed","stop","handleTabKeyDown","panel","trapTicket","getDeepActiveElement","popupLayerHolding","popupStops","focusables","pushFocusTrapLayer","getPanel","getHost","nextLayerTicket","coveringLayer","source","inheritedRestoreTargets","useHasOpenOverlay","useSyncExternalStore","takeInitialFocus","initialFocus","useOverlayBehaviour","open","onClose","elevated","hostRef","onYield","panelRef","useRef","useOwnedByPopover","useCallback","previousFocusRef","layerRef","initialFocusRef","onCloseRef","onYieldRef","useEffect","recorded","inherited","target","above","popEscapeLayer","pushEscapeLayer","releaseScrollLock","lockBodyScroll","popFocusTrapLayer","useLayoutEffect","subscribe","onStackChange","isTopmost","stackElevated","zIndex","OVERLAY_Z_BASE","ensureElevatedOverlayStyles"],"mappings":";;;;;;;;;AAWO,MAAMA,KAA8B,2MAA2MC,CAAU,IAInPC,KACT,sJAGEC,KAAa,CAACC,MAChBA,EAAQ,gBACRA,EAAQ,kBACPA,EAAQ,sBAAsB,aAAaA,EAAQ,WAAW,OAAO,OAIpEC,KAAiB,CAACC,MACpB,MAAM,KAAKA,EAAQ,QAAQ,EAAE,KAAK,CAACC,MAAUA,EAAM,YAAY,SAAS,GAOtEC,KAAqB,MAA2C;AAClE,QAAMC,wBAAa,IAAA,GACbC,IAAU,CAACN,MAAkC;AAC/C,UAAMO,IAASF,EAAO,IAAIL,CAAO;AACjC,QAAIO;AACA,aAAOA;AAEX,UAAM,EAAE,SAAAC,GAAS,YAAAC,GAAY,mBAAAC,EAAA,IAAsB,iBAAiBV,CAAO,GACrEW,IAASZ,GAAWC,CAAO,GAC3BY,IAAcD,IAASL,EAAQK,CAAM,IAAI,MAGzCE,IACFF,aAAkB,sBAClB,CAACA,EAAO,QACRV,GAAeU,CAAM,MAAMX,GACzBc,IAAQ;AAAA,MACV,QACId,EAAQ,aAAa,OAAO,KAC5BQ,MAAY,UACZK,KACA,GAAQD,MAAgBA,EAAY,UAAUA,EAAY;AAAA,MAC9D,WAAWH,MAAe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,MACCU,EAAS,YAAY,QAAQ1D,EAAWA,EAAW,SAAS,CAAC,MAAM0D,EAAS;AAAA,IACjF,MAAM;AAAA,EAAA,GAIJkB,IAAgBhC;AAAA,IAClB6B;AAAA,IACA,MAAMzB,MAASE,KAAYjD,EAAe,OAAO;AAAA,IACjD,MAAM;AAAA,EAAA,GAKJ4E,IAASjC;AAAA,IACX6B;AAAA,IACA,MAAM;AACF,YAAM/D,IAAQgD,EAAS;AACvB,aAAOoB,KAAkB9B,KAAQtC,IAAQ,KAAK,IAAI,GAAGV,EAAW,QAAQU,CAAK,CAAC,IAAI;AAAA,IACtF;AAAA,IACA,MAAMoE;AAAA,EAAA;AAIV,SAAAN,EAAgB,MAAM;AAClB,IAAII,KACAG,GAAA;AAAA,EAER,GAAG,CAACH,CAAa,CAAC,GAIlBJ,EAAgB,MAAM;AAClB,IAAAhE,GAAA;AAAA,EACJ,CAAC,GAUM,EAAE,KARGgD,EAAY,CAAChE,MAA6B;AAClD,IAAA6D,EAAS,UAAU7D,GAEfA,KAAQkE,EAAS,YAAY,QAC7Bb,EAAiBrD,GAAMmE,EAAgB,OAAO;AAAA,EAEtD,GAAG,CAAA,CAAE,GAES,WAAAgB,GAAW,QAAQC,IAAgB,SAAYC,GAAQ,UAAUD,EAAA;AACnF;"}
|
|
1
|
+
{"version":3,"file":"overlayBehaviour.js","sources":["../../src/components/overlayBehaviour.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useRef, useSyncExternalStore } from 'react';\nimport { containsComposed, getDeepActiveElement } from './activeElement';\nimport { ensureDroppedFocusTracking, focusReturnTarget } from './droppedFocus';\nimport { pushEscapeLayer } from './escapeLayers';\nimport { FOCUS_RING } from './focusRing';\nimport { nextLayerTicket, popupLayerHolding } from './overlayLayers';\nimport { useOwnedByPopover } from './popoverTree';\nimport { OVERLAY_Z_BASE, ensureElevatedOverlayStyles } from './portalOverlay';\nimport { lockBodyScroll } from './scrollLock';\nimport { leaveTopLayer, raiseToTopLayer } from './topLayer';\n\n/** Back/close button chrome, shared so the two overlays cannot drift apart. */\nexport const OVERLAY_ICON_BUTTON_CLASSES = `flex shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-[4px] text-[var(--malachite-text-secondary)] hover:text-[var(--malachite-text-primary)] transition-colors ${FOCUS_RING}`;\n\n// `summary`: a disclosure's first one is a native tab stop and its only keyboard control. A loose\n// one reports `tabIndex === -1`, which `isTabStop` drops.\nexport const FOCUSABLE_SELECTOR =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex=\"-1\"])';\n\n// The flat-tree parent: a slotted element renders under its slot, a shadow root under its host.\nconst flatParent = (element: Element): Element | null =>\n element.assignedSlot ??\n element.parentElement ??\n (element.parentNode instanceof ShadowRoot ? element.parentNode.host : null);\n\n// `children`, not `:scope > summary`: inside a shadow root jsdom's selector engine matches\n// nothing for `:scope`, which silently hid the summary along with the rest.\nconst firstSummaryOf = (details: HTMLDetailsElement): Element | undefined =>\n Array.from(details.children).find((child) => child.tagName === 'SUMMARY');\n\ntype RenderState = { hidden: boolean; invisible: boolean; hidesContent: boolean };\n\n// Reads computed style: call at interaction time only, never from a mount path. Under jsdom,\n// `offsetParent`, `getClientRects()` and `checkVisibility()` report every element invisible.\n// One per Tab press, so an ancestor shared by many controls has its style read once.\nconst createRenderStates = (): ((element: Element) => RenderState) => {\n const states = new Map<Element, RenderState>();\n const stateOf = (element: Element): RenderState => {\n const cached = states.get(element);\n if (cached) {\n return cached;\n }\n const { display, visibility, contentVisibility } = getComputedStyle(element);\n const parent = flatParent(element);\n const parentState = parent ? stateOf(parent) : null;\n // A closed `<details>` hides all but its summary in the UA shadow slot, so the hidden\n // descendants keep `tabIndex === 0` and a normal computed display.\n const closedDisclosure =\n parent instanceof HTMLDetailsElement &&\n !parent.open &&\n firstSummaryOf(parent) !== element;\n const state = {\n hidden:\n element.hasAttribute('inert') ||\n display === 'none' ||\n closedDisclosure ||\n Boolean(parentState && (parentState.hidden || parentState.hidesContent)),\n invisible: visibility === 'hidden' || visibility === 'collapse',\n hidesContent: contentVisibility === 'hidden',\n };\n states.set(element, state);\n return state;\n };\n return stateOf;\n};\n\nconst isTabStop = (element: HTMLElement, stateOf: (element: Element) => RenderState): boolean => {\n if (element.tabIndex < 0 || element.matches(':disabled')) {\n return false;\n }\n const { hidden, invisible } = stateOf(element);\n\n return !hidden && !invisible;\n};\n\nconst isGroupedRadio = (element: Element): element is HTMLInputElement =>\n element instanceof HTMLInputElement && element.type === 'radio' && element.name !== '';\n\n// Only a group's checked radio, or its first with none checked, is a tab stop, yet every member\n// reports `tabIndex === 0`.\nconst skipsWithinRadioGroup = (element: HTMLElement, reachable: HTMLElement[]): boolean => {\n if (!isGroupedRadio(element)) {\n return false;\n }\n const group = reachable.filter(\n (candidate): candidate is HTMLInputElement =>\n isGroupedRadio(candidate) &&\n candidate.name === element.name &&\n candidate.form === element.form,\n );\n\n return (group.find((radio) => radio.checked) ?? group[0]) !== element;\n};\n\nconst inTabOrder = (entries: Element[], tabIndexOf: (element: Element) => number): Element[] =>\n entries\n .map((element, index) => ({ element, index, tabIndex: tabIndexOf(element) }))\n .sort((left, right) => {\n if (left.tabIndex !== right.tabIndex) {\n if (left.tabIndex === 0) {\n return 1;\n }\n if (right.tabIndex === 0) {\n return -1;\n }\n\n return left.tabIndex - right.tabIndex;\n }\n\n return left.index - right.index;\n })\n .map(({ element }) => element);\n\n// Only a slot inside a shadow root projects assigned content; elsewhere it renders its children.\nconst isShadowSlot = (element: Element): element is HTMLSlotElement =>\n element instanceof HTMLSlotElement && element.getRootNode() instanceof ShadowRoot;\n\n// One focus navigation scope in tree order. A host's light children render only through its\n// slots, and hosts and slots each own a scope, so the walk descends into neither.\nconst scopeMembers = (elements: Iterable<Element>, into: Element[] = []): Element[] => {\n for (const element of elements) {\n into.push(element);\n if (!element.shadowRoot && !isShadowSlot(element)) {\n scopeMembers(element.children, into);\n }\n }\n return into;\n};\n\n// Ordered per scope, as browsers do: positive tabindex orders within its own scope, and a nested\n// scope takes its owner's place, an owner that is no stop itself ordering as tabindex 0.\nconst stopsInScope = (\n members: Element[],\n stateOf: (element: Element) => RenderState,\n): HTMLElement[] => {\n const reachable = members.filter(\n (element): element is HTMLElement =>\n element instanceof HTMLElement &&\n element.matches(FOCUSABLE_SELECTOR) &&\n isTabStop(element, stateOf),\n );\n const stops = new Set<Element>(\n reachable.filter((element) => !skipsWithinRadioGroup(element, reachable)),\n );\n const entries = members.filter(\n (element) => stops.has(element) || element.shadowRoot || isShadowSlot(element),\n );\n\n return inTabOrder(entries, (element) =>\n stops.has(element) ? (element as HTMLElement).tabIndex : 0,\n ).flatMap((element) => {\n if (isShadowSlot(element)) {\n return stopsInScope(scopeMembers(element.assignedElements({ flatten: true })), stateOf);\n }\n const root = element.shadowRoot;\n // A host given a negative tabindex keeps its whole shadow tree out of the order; an\n // unparsable value counts as absent, as it does for any element.\n if (root && Number.parseInt(element.getAttribute('tabindex') ?? '', 10) < 0) {\n return [];\n }\n const own = stops.has(element) && !root?.delegatesFocus ? [element as HTMLElement] : [];\n\n return root ? [...own, ...stopsInScope(scopeMembers(root.children), stateOf)] : own;\n });\n};\n\nconst tabStopsIn = (root: ParentNode): HTMLElement[] =>\n stopsInScope(scopeMembers(root.children), createRenderStates());\n\n// `compareDocumentPosition` calls nodes in different shadow trees disconnected, so lift both\n// into their deepest shared tree first; a host precedes its own shadow content.\nconst composedPosition = (from: Node, to: Node): number => {\n const ancestry = (node: Node): Node[] => {\n const chain = [node];\n for (\n let root = node.getRootNode();\n root instanceof ShadowRoot;\n root = root.host.getRootNode()\n ) {\n chain.push(root.host);\n }\n return chain;\n };\n const fromChain = ancestry(from);\n const toChain = ancestry(to);\n for (const fromStep of fromChain) {\n const toStep = toChain.find((step) => step.getRootNode() === fromStep.getRootNode());\n if (!toStep) {\n continue;\n }\n if (fromStep !== toStep) {\n return fromStep.compareDocumentPosition(toStep);\n }\n\n return fromStep === from\n ? Node.DOCUMENT_POSITION_FOLLOWING\n : Node.DOCUMENT_POSITION_PRECEDING;\n }\n\n return Node.DOCUMENT_POSITION_DISCONNECTED;\n};\n\n/** Where Tab would land first, for initial focus: the raw selector also matches hidden controls. */\nexport const firstTabStopIn = (root: ParentNode): HTMLElement | null => tabStopsIn(root)[0] ?? null;\n\ntype PanelSource = () => HTMLElement | null;\n\n// LIFO like escapeLayers: with a listener per overlay the first-registered one wins, which\n// sent Tab from a dialog into the panel behind it.\nconst trapLayers: PanelSource[] = [];\n// Elevation belongs to the stack: a Modal left in the base band opens behind the panel that\n// elevated it.\nconst elevatedLayers = new Set<PanelSource>();\n// The shadow host per layer, so promotion can replay in stack order.\nconst hostSources = new Map<PanelSource, () => HTMLElement | null>();\nconst trapTickets = new Map<PanelSource, number>();\nconst stackListeners = new Set<() => void>();\nconst NO_SUBSCRIPTION = () => {\n // Nothing to tear down: a closed overlay never subscribed.\n};\n\n// Top-layer paint order is entry order, so replay the whole stack bottom-up rather than letting\n// each overlay promote itself: those effects run in React tree order, which need not match.\nlet promoted: HTMLElement[] = [];\nconst aboveStack = new Set<HTMLElement>();\n\nconst syncTopLayer = (): void => {\n const wanted = elevatedLayers.size\n ? trapLayers\n .map((layer) => hostSources.get(layer)?.())\n .filter((host): host is HTMLElement => Boolean(host))\n : [];\n // Compared, not reapplied: this runs on every commit, because a host can appear a commit\n // after the layer that owns it, and re-entering the top layer unprompted costs a recalc.\n if (\n wanted.length === promoted.length &&\n wanted.every((host, index) => host === promoted[index])\n ) {\n return;\n }\n const stillWanted = new Set(wanted);\n for (const host of promoted) {\n if (!stillWanted.has(host)) {\n leaveTopLayer(host);\n }\n }\n for (const host of wanted) {\n raiseToTopLayer(host);\n }\n promoted = wanted;\n for (const host of aboveStack) {\n raiseToTopLayer(host);\n }\n};\n\n/** Keeps a promoted host above the elevated stack each time the stack is replayed. */\nexport const keepAboveOverlayStack = (host: HTMLElement): (() => void) => {\n aboveStack.add(host);\n return () => {\n aboveStack.delete(host);\n };\n};\n\nconst notifyStackChanged = (): void => {\n for (const listener of stackListeners) {\n listener();\n }\n};\n\nconst subscribeToStack = (listener: () => void): (() => void) => {\n stackListeners.add(listener);\n return () => {\n stackListeners.delete(listener);\n };\n};\n\nconst wrapTab = (\n event: KeyboardEvent,\n active: HTMLElement | null,\n within: Node,\n stops: HTMLElement[],\n): void => {\n const first = stops[0];\n const last = stops[stops.length - 1];\n const inside = containsComposed(within, active);\n // A mouse-only control, such as a search Dropdown's caret, is no edge: Tab resumes from its\n // place in the DOM and would leave the overlay where no real stop follows it.\n if (active && inside && active !== within && !stops.includes(active)) {\n const wanted = event.shiftKey\n ? Node.DOCUMENT_POSITION_PRECEDING\n : Node.DOCUMENT_POSITION_FOLLOWING;\n if (!stops.some((stop) => composedPosition(active, stop) & wanted)) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n\n return;\n }\n if (event.shiftKey) {\n if (!inside || active === first || active === within) {\n event.preventDefault();\n last.focus();\n }\n } else if (!inside || active === last || active === within) {\n event.preventDefault();\n first.focus();\n }\n};\n\nconst handleTabKeyDown = (event: KeyboardEvent): void => {\n if (event.key !== 'Tab' || event.defaultPrevented) {\n return;\n }\n // Walk down rather than bail: React detaches refs before flushing the cleanup that pops\n // the layer, so the topmost can be registered-but-null and Tab would escape entirely.\n let panel: HTMLElement | null = null;\n let trapTicket = 0;\n for (let index = trapLayers.length - 1; index >= 0 && !panel; index -= 1) {\n panel = trapLayers[index]();\n if (panel) {\n trapTicket = trapTickets.get(trapLayers[index]) ?? 0;\n }\n }\n if (!panel) {\n return;\n }\n const active = getDeepActiveElement();\n const layer = active ? popupLayerHolding(active) : null;\n if (active && layer && layer.ticket > trapTicket) {\n const root = layer.popup.shadowRoot ?? layer.popup;\n const popupStops = tabStopsIn(root);\n if (popupStops.length === 0) {\n event.preventDefault();\n return;\n }\n wrapTab(event, active, root, popupStops);\n return;\n }\n const focusables = tabStopsIn(panel);\n if (focusables.length === 0) {\n event.preventDefault();\n panel.focus();\n return;\n }\n wrapTab(event, active, panel, focusables);\n};\n\n// On `document` so it also catches focus that escaped behind the overlay.\nconst pushFocusTrapLayer = (getPanel: PanelSource, getHost: () => HTMLElement | null) => {\n if (trapLayers.length === 0) {\n document.addEventListener('keydown', handleTabKeyDown);\n }\n trapLayers.push(getPanel);\n hostSources.set(getPanel, getHost);\n trapTickets.set(getPanel, nextLayerTicket());\n notifyStackChanged();\n return () => {\n const index = trapLayers.lastIndexOf(getPanel);\n if (index !== -1) {\n trapLayers.splice(index, 1);\n }\n elevatedLayers.delete(getPanel);\n hostSources.delete(getPanel);\n trapTickets.delete(getPanel);\n const host = getHost();\n if (host) {\n leaveTopLayer(host);\n }\n if (trapLayers.length === 0) {\n document.removeEventListener('keydown', handleTabKeyDown);\n }\n notifyStackChanged();\n };\n};\n\n// A layer unmounting in the same commit has already left the DOM when passive cleanups run.\nconst coveringLayer = (source: PanelSource): PanelSource | undefined => {\n const index = trapLayers.lastIndexOf(source);\n return index === -1\n ? undefined\n : trapLayers.slice(index + 1).find((layer) => layer()?.isConnected === true);\n};\n\nconst inheritedRestoreTargets = new Map<PanelSource, HTMLElement>();\n\n/**\n * Whether a SidePanel, Modal or CommandPalette is open anywhere, for host chrome that has to move out of the way.\n * Overlays portal, so the only other signal is this module's markers, which a host cannot read\n * without coupling to an internal. Dropdowns and tooltips do not count: they trap no focus.\n */\nexport const useHasOpenOverlay = (): boolean =>\n useSyncExternalStore(\n subscribeToStack,\n () => trapLayers.length > 0,\n () => false,\n );\n\nconst takeInitialFocus = (panel: HTMLElement, initialFocus: 'panel' | 'content'): void => {\n if (initialFocus === 'content') {\n const active = getDeepActiveElement();\n if (containsComposed(panel, active)) {\n return;\n }\n (firstTabStopIn(panel) ?? panel).focus();\n return;\n }\n panel.focus();\n};\n\n/**\n * The modal-overlay behaviour shared by SidePanel, Modal and CommandPalette: ESC and the Tab focus trap\n * (topmost overlay only, so these may be stacked), background scroll lock, and focus moved\n * into the overlay on open then restored to the trigger on close.\n *\n * Returns the ref callback the dialog element must take, whether this overlay is the topmost\n * one — only that one may claim `aria-modal`, or a screen reader can still browse the overlay\n * underneath — the z-index its host must carry, which keeps paint order with the focus stack,\n * and whether it is elevated. Presentation otherwise stays with the calling component.\n */\nexport const useOverlayBehaviour = ({\n open,\n onClose,\n elevated = false,\n hostRef,\n initialFocus = 'panel',\n onYield,\n}: {\n open: boolean;\n onClose: () => void;\n elevated?: boolean;\n /** The shadow host, which the stack promotes into the top layer while elevated. */\n hostRef?: { current: HTMLElement | null };\n /** Where focus lands on open: the panel itself, or the content's own first control. */\n initialFocus?: 'panel' | 'content';\n /** Called instead of opening while another overlay is open; the caller must then render closed. */\n onYield?: () => void;\n}): {\n ref: (node: HTMLElement | null) => void;\n isTopmost: boolean;\n zIndex: number | undefined;\n elevated: boolean;\n} => {\n const panelRef = useRef<HTMLElement | null>(null);\n // One identity for the life of the instance: elevation registers it in the layout phase,\n // before the effect below pushes it onto the stack.\n const source = useRef<PanelSource>(() => panelRef.current).current;\n useOwnedByPopover(\n useCallback(() => hostRef?.current ?? panelRef.current, [hostRef]),\n open,\n );\n const previousFocusRef = useRef<HTMLElement | null>(null);\n const layerRef = useRef<PanelSource | null>(null);\n const initialFocusRef = useRef(initialFocus);\n\n // Ref so the ESC layer registers once per open, not on every inline-onClose change.\n const onCloseRef = useRef(onClose);\n const onYieldRef = useRef(onYield);\n useEffect(() => {\n onCloseRef.current = onClose;\n onYieldRef.current = onYield;\n }, [onClose, onYield]);\n\n // Before the trap effect, so the trigger is recorded before focus moves in.\n useEffect(() => {\n ensureDroppedFocusTracking();\n if (!open) {\n return;\n }\n previousFocusRef.current = focusReturnTarget();\n return () => {\n const recorded = previousFocusRef.current;\n previousFocusRef.current = null;\n const inherited = inheritedRestoreTargets.get(source);\n inheritedRestoreTargets.delete(source);\n if (layerRef.current === null) {\n return;\n }\n const target = recorded?.isConnected ? recorded : inherited;\n // Runs before the trap cleanup below, so a registered layer is still on the stack.\n const above = coveringLayer(source);\n if (above && target) {\n inheritedRestoreTargets.set(above, target);\n }\n if (!above && target?.isConnected) {\n target.focus();\n }\n };\n }, [open, source]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n // Checked here, not at render: a dialog opening in the same commit registers only in its effects.\n if (onYieldRef.current && trapLayers.length > 0) {\n onYieldRef.current();\n return;\n }\n layerRef.current = source;\n const popEscapeLayer = pushEscapeLayer(() => onCloseRef.current());\n const releaseScrollLock = lockBodyScroll();\n const popFocusTrapLayer = pushFocusTrapLayer(source, () => hostRef?.current ?? null);\n // Reopening inside the exit transition reuses the same node, so the ref callback\n // never fires again and nothing would take focus.\n if (panelRef.current) {\n takeInitialFocus(panelRef.current, initialFocusRef.current);\n }\n return () => {\n layerRef.current = null;\n popFocusTrapLayer();\n popEscapeLayer();\n releaseScrollLock();\n };\n }, [open, hostRef, source]);\n\n // Its own effect: re-pushing the trap layer to change elevation would move this overlay to\n // the top of the stack, handing it the Escape and Tab that belong to a dialog above it.\n // Layout, and declared above the sync below, so that sync sees it in the same commit.\n useLayoutEffect(() => {\n if (!open || !elevated) {\n return;\n }\n elevatedLayers.add(source);\n notifyStackChanged();\n return () => {\n elevatedLayers.delete(source);\n notifyStackChanged();\n };\n }, [open, elevated, source]);\n\n // Only an open overlay subscribes: a mounted-but-idle one must carry no at-rest cost,\n // and its snapshot is a constant `false` regardless of what the stack does.\n const subscribe = useCallback(\n (onStackChange: () => void) => (open ? subscribeToStack(onStackChange) : NO_SUBSCRIPTION),\n [open],\n );\n\n const isTopmost = useSyncExternalStore(\n subscribe,\n // Gated on `open` so an overlay fading out stops claiming modal. Before it registers\n // it is the one about to go on top, or aria-modal would drop for a frame on open.\n () =>\n open &&\n (layerRef.current === null || trapLayers[trapLayers.length - 1] === layerRef.current),\n () => true,\n );\n\n // Its own request counts before the stack has it: the layer is not pushed until effects run.\n const stackElevated = useSyncExternalStore(\n subscribe,\n () => open && (elevated || elevatedLayers.size > 0),\n () => false,\n );\n\n // Overlay hosts share one z-index band, so paint order would otherwise fall out of body\n // order: an overlay reopened over a newer one takes the keyboard while painting under it.\n const zIndex = useSyncExternalStore(\n subscribe,\n () => {\n const layer = layerRef.current;\n return OVERLAY_Z_BASE + (open && layer ? Math.max(0, trapLayers.indexOf(layer)) : 0);\n },\n () => OVERLAY_Z_BASE,\n );\n\n // Layout, not passive: the rule has to exist before the first paint the attribute applies to.\n useLayoutEffect(() => {\n if (stackElevated) {\n ensureElevatedOverlayStyles();\n }\n }, [stackElevated]);\n\n // No deps: the host mounts a commit after the layer that owns it, so there is no stack\n // change left to key this on. `syncTopLayer` compares before it touches anything.\n useLayoutEffect(() => {\n syncTopLayer();\n });\n\n const ref = useCallback((node: HTMLElement | null) => {\n panelRef.current = node;\n // A panel portaled in after its layer registered takes focus here; any other, from the effect.\n if (node && layerRef.current !== null) {\n takeInitialFocus(node, initialFocusRef.current);\n }\n }, []);\n\n return { ref, isTopmost, zIndex: stackElevated ? undefined : zIndex, elevated: stackElevated };\n};\n\nexport default useOverlayBehaviour;\n"],"names":["OVERLAY_ICON_BUTTON_CLASSES","FOCUS_RING","FOCUSABLE_SELECTOR","flatParent","element","firstSummaryOf","details","child","createRenderStates","states","stateOf","cached","display","visibility","contentVisibility","parent","parentState","closedDisclosure","state","isTabStop","hidden","invisible","isGroupedRadio","skipsWithinRadioGroup","reachable","group","candidate","radio","inTabOrder","entries","tabIndexOf","index","left","right","isShadowSlot","scopeMembers","elements","into","stopsInScope","members","stops","root","own","tabStopsIn","composedPosition","from","to","ancestry","node","chain","fromChain","toChain","fromStep","toStep","step","firstTabStopIn","trapLayers","elevatedLayers","hostSources","trapTickets","stackListeners","NO_SUBSCRIPTION","promoted","aboveStack","syncTopLayer","wanted","layer","_a","host","stillWanted","leaveTopLayer","raiseToTopLayer","keepAboveOverlayStack","notifyStackChanged","listener","subscribeToStack","wrapTab","event","active","within","first","last","inside","containsComposed","stop","handleTabKeyDown","panel","trapTicket","getDeepActiveElement","popupLayerHolding","popupStops","focusables","pushFocusTrapLayer","getPanel","getHost","nextLayerTicket","coveringLayer","source","inheritedRestoreTargets","useHasOpenOverlay","useSyncExternalStore","takeInitialFocus","initialFocus","useOverlayBehaviour","open","onClose","elevated","hostRef","onYield","panelRef","useRef","useOwnedByPopover","useCallback","previousFocusRef","layerRef","initialFocusRef","onCloseRef","onYieldRef","useEffect","ensureDroppedFocusTracking","focusReturnTarget","recorded","inherited","target","above","popEscapeLayer","pushEscapeLayer","releaseScrollLock","lockBodyScroll","popFocusTrapLayer","useLayoutEffect","subscribe","onStackChange","isTopmost","stackElevated","zIndex","OVERLAY_Z_BASE","ensureElevatedOverlayStyles"],"mappings":";;;;;;;;;;AAYO,MAAMA,KAA8B,2MAA2MC,CAAU,IAInPC,KACT,sJAGEC,KAAa,CAACC,MAChBA,EAAQ,gBACRA,EAAQ,kBACPA,EAAQ,sBAAsB,aAAaA,EAAQ,WAAW,OAAO,OAIpEC,KAAiB,CAACC,MACpB,MAAM,KAAKA,EAAQ,QAAQ,EAAE,KAAK,CAACC,MAAUA,EAAM,YAAY,SAAS,GAOtEC,KAAqB,MAA2C;AAClE,QAAMC,wBAAa,IAAA,GACbC,IAAU,CAACN,MAAkC;AAC/C,UAAMO,IAASF,EAAO,IAAIL,CAAO;AACjC,QAAIO;AACA,aAAOA;AAEX,UAAM,EAAE,SAAAC,GAAS,YAAAC,GAAY,mBAAAC,EAAA,IAAsB,iBAAiBV,CAAO,GACrEW,IAASZ,GAAWC,CAAO,GAC3BY,IAAcD,IAASL,EAAQK,CAAM,IAAI,MAGzCE,IACFF,aAAkB,sBAClB,CAACA,EAAO,QACRV,GAAeU,CAAM,MAAMX,GACzBc,IAAQ;AAAA,MACV,QACId,EAAQ,aAAa,OAAO,KAC5BQ,MAAY,UACZK,KACA,GAAQD,MAAgBA,EAAY,UAAUA,EAAY;AAAA,MAC9D,WAAWH,MAAe,YAAYA,MAAe;AAAA,MACrD,cAAcC,MAAsB;AAAA,IAAA;AAExC,WAAAL,EAAO,IAAIL,GAASc,C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A,IACjF,MAAM;AAAA,EAAA,GAIJoB,IAAgBlC;AAAA,IAClB+B;AAAA,IACA,MAAM3B,MAASE,KAAYjD,EAAe,OAAO;AAAA,IACjD,MAAM;AAAA,EAAA,GAKJ8E,IAASnC;AAAA,IACX+B;AAAA,IACA,MAAM;AACF,YAAMjE,IAAQgD,EAAS;AACvB,aAAOsB,KAAkBhC,KAAQtC,IAAQ,KAAK,IAAI,GAAGV,EAAW,QAAQU,CAAK,CAAC,IAAI;AAAA,IACtF;AAAA,IACA,MAAMsE;AAAA,EAAA;AAIV,SAAAN,EAAgB,MAAM;AAClB,IAAII,KACAG,GAAA;AAAA,EAER,GAAG,CAACH,CAAa,CAAC,GAIlBJ,EAAgB,MAAM;AAClB,IAAAlE,GAAA;AAAA,EACJ,CAAC,GAUM,EAAE,KARGgD,EAAY,CAAChE,MAA6B;AAClD,IAAA6D,EAAS,UAAU7D,GAEfA,KAAQkE,EAAS,YAAY,QAC7Bb,EAAiBrD,GAAMmE,EAAgB,OAAO;AAAA,EAEtD,GAAG,CAAA,CAAE,GAES,WAAAkB,GAAW,QAAQC,IAAgB,SAAYC,GAAQ,UAAUD,EAAA;AACnF;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2041,6 +2041,8 @@ export declare interface FilterSearchFilter {
|
|
|
2041
2041
|
info?: string;
|
|
2042
2042
|
/** Right-aligned hint on the filter's row, e.g. `e.g. Attio, Ashby`. */
|
|
2043
2043
|
example?: string;
|
|
2044
|
+
/** `false` drops the filter's name from its chip, for a value that reads alone: `Configured only`. */
|
|
2045
|
+
chipLabel?: boolean;
|
|
2044
2046
|
items: FilterSearchItem[];
|
|
2045
2047
|
}
|
|
2046
2048
|
|
|
@@ -2048,6 +2050,8 @@ export declare interface FilterSearchItem {
|
|
|
2048
2050
|
value: string;
|
|
2049
2051
|
label: string;
|
|
2050
2052
|
disabled?: boolean;
|
|
2053
|
+
/** Drawn before the label in the menu and in the applied chip: a logo, a status dot. Keep it 12px. */
|
|
2054
|
+
icon?: ReactNode;
|
|
2051
2055
|
}
|
|
2052
2056
|
|
|
2053
2057
|
export declare interface FilterSearchProps {
|
|
@@ -2081,6 +2085,11 @@ export declare interface FilterSearchProps {
|
|
|
2081
2085
|
clearable?: boolean;
|
|
2082
2086
|
/** Chips past this count collapse into `+N`. */
|
|
2083
2087
|
maxVisibleChips?: number;
|
|
2088
|
+
/**
|
|
2089
|
+
* Puts a Filters button, with the applied filter count, at the bar's right end. It and the
|
|
2090
|
+
* combobox keys open the filter list: clicking the field leaves the menu shut until something is typed.
|
|
2091
|
+
*/
|
|
2092
|
+
filtersButton?: boolean;
|
|
2084
2093
|
className?: string;
|
|
2085
2094
|
style?: default_2.CSSProperties;
|
|
2086
2095
|
id?: string;
|