@charcuterie/ui 4.28.4 → 4.30.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/dist/CatalogPicker/CatalogPicker.d.ts +110 -0
- package/dist/CatalogPicker/CatalogPicker.d.ts.map +1 -0
- package/dist/CatalogPicker/CatalogPicker.js +155 -0
- package/dist/CatalogPicker/CatalogPicker.js.map +1 -0
- package/dist/CatalogPicker/CatalogPickerMark.d.ts +29 -0
- package/dist/CatalogPicker/CatalogPickerMark.d.ts.map +1 -0
- package/dist/CatalogPicker/CatalogPickerMark.js +35 -0
- package/dist/CatalogPicker/CatalogPickerMark.js.map +1 -0
- package/dist/CatalogPicker/CatalogPickerOption.d.ts +40 -0
- package/dist/CatalogPicker/CatalogPickerOption.d.ts.map +1 -0
- package/dist/CatalogPicker/CatalogPickerOption.js +43 -0
- package/dist/CatalogPicker/CatalogPickerOption.js.map +1 -0
- package/dist/CatalogPicker/CatalogPickerPanel.d.ts +60 -0
- package/dist/CatalogPicker/CatalogPickerPanel.d.ts.map +1 -0
- package/dist/CatalogPicker/CatalogPickerPanel.js +409 -0
- package/dist/CatalogPicker/CatalogPickerPanel.js.map +1 -0
- package/dist/CatalogPicker/CatalogPickerRail.d.ts +50 -0
- package/dist/CatalogPicker/CatalogPickerRail.d.ts.map +1 -0
- package/dist/CatalogPicker/CatalogPickerRail.js +114 -0
- package/dist/CatalogPicker/CatalogPickerRail.js.map +1 -0
- package/dist/CatalogPicker/catalogPickerDrawings.d.ts +10 -0
- package/dist/CatalogPicker/catalogPickerDrawings.d.ts.map +1 -0
- package/dist/CatalogPicker/catalogPickerDrawings.js +29 -0
- package/dist/CatalogPicker/catalogPickerDrawings.js.map +1 -0
- package/dist/CatalogPicker/catalogPickerView.d.ts +185 -0
- package/dist/CatalogPicker/catalogPickerView.d.ts.map +1 -0
- package/dist/CatalogPicker/catalogPickerView.js +245 -0
- package/dist/CatalogPicker/catalogPickerView.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/CatalogPicker/CatalogPicker.mdx +192 -0
- package/src/CatalogPicker/CatalogPicker.stories.tsx +218 -0
- package/src/CatalogPicker/CatalogPicker.test.tsx +1592 -0
- package/src/CatalogPicker/CatalogPicker.tsx +387 -0
- package/src/CatalogPicker/CatalogPickerMark.tsx +89 -0
- package/src/CatalogPicker/CatalogPickerOption.tsx +151 -0
- package/src/CatalogPicker/CatalogPickerPanel.tsx +780 -0
- package/src/CatalogPicker/CatalogPickerRail.tsx +214 -0
- package/src/CatalogPicker/catalogPicker.storyHelpers.tsx +276 -0
- package/src/CatalogPicker/catalogPickerDrawings.tsx +51 -0
- package/src/CatalogPicker/catalogPickerView.test.ts +365 -0
- package/src/CatalogPicker/catalogPickerView.ts +476 -0
- package/src/Dialog/Dialog.test.tsx +20 -289
- package/src/Field/Field.test.tsx +11 -405
- package/src/index.ts +6 -0
- package/src/sourceRules.test.ts +5 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useUniqueId } from "@charcuterie/logic";
|
|
3
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { SearchInput } from "../SearchInput/SearchInput.js";
|
|
5
|
+
import { toClassName } from "../toClassName.js";
|
|
6
|
+
import { CatalogPickerOption } from "./CatalogPickerOption.js";
|
|
7
|
+
import { CatalogPickerRail } from "./CatalogPickerRail.js";
|
|
8
|
+
import { buildCatalogSections, buildCatalogTabs, pickInitialTabKey, toQueryWords, } from "./catalogPickerView.js";
|
|
9
|
+
const SEARCH_SIZE = {
|
|
10
|
+
lg: "lg",
|
|
11
|
+
md: "md",
|
|
12
|
+
sm: "md",
|
|
13
|
+
};
|
|
14
|
+
const GROUP_HEADING_INSET_CLASS = {
|
|
15
|
+
lg: "px-(--control-padding-inline-lg)",
|
|
16
|
+
md: "px-(--control-padding-inline-md)",
|
|
17
|
+
sm: "px-(--control-padding-inline-sm)",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* How many frames the panel waits for its height cap before it gives
|
|
21
|
+
* up on centring the chosen row. `useAnchoredOverlay` writes the cap
|
|
22
|
+
* onto the element inside floating-ui's `size` middleware, a frame or
|
|
23
|
+
* two after mount, and until then the list has nothing to scroll.
|
|
24
|
+
*/
|
|
25
|
+
const SCROLL_ATTEMPTS = 5;
|
|
26
|
+
const nextEnabledIndex = (rows, from, step) => {
|
|
27
|
+
for (let index = from + step; index >= 0 && index < rows.length; index += step) {
|
|
28
|
+
if (rows[index]?.item.isDisabled !== true) {
|
|
29
|
+
return index;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return from;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The panel's contents: the rail, the search field, and the grouped
|
|
36
|
+
* listbox. `CatalogPicker` renders it inside its anchored overlay, and
|
|
37
|
+
* it mounts fresh on every open, so the tab, the query and the
|
|
38
|
+
* highlight all start from the chosen value each time.
|
|
39
|
+
*
|
|
40
|
+
* ### The ARIA shape
|
|
41
|
+
*
|
|
42
|
+
* - The **search field** is the `role="combobox"` and keeps focus,
|
|
43
|
+
* exactly as in `Combobox`: arrows move `aria-activedescendant`
|
|
44
|
+
* through the options, Enter chooses, Escape clears a query and then
|
|
45
|
+
* closes.
|
|
46
|
+
* - The **list** is one `role="listbox"`. Search results sit in
|
|
47
|
+
* labelled `role="group"`s, one per group, the APG grouped-listbox
|
|
48
|
+
* shape `CommandPalette` uses.
|
|
49
|
+
* - The **rail** is a vertical `role="toolbar"` of toggle buttons
|
|
50
|
+
* (`aria-pressed`). See `CatalogPickerRail` for why it is not a
|
|
51
|
+
* `tablist`.
|
|
52
|
+
*
|
|
53
|
+
* Tab and Shift+Tab cycle through the search field, its clear button
|
|
54
|
+
* while it shows, and the rail, and nowhere else: the panel is two tab
|
|
55
|
+
* stops (three with a query and a clear button) however long the rail
|
|
56
|
+
* is.
|
|
57
|
+
*
|
|
58
|
+
* ### The highlight follows a value, not a position
|
|
59
|
+
*
|
|
60
|
+
* The active row is remembered by its `value`, so a catalog that
|
|
61
|
+
* refreshes while the panel is open — rows reordered, rows added — keeps
|
|
62
|
+
* the same row highlighted, and Enter chooses what the person saw. Only
|
|
63
|
+
* when that row leaves the view, or becomes disabled, is the highlight
|
|
64
|
+
* reseeded: to the chosen row if the view shows it, else the first
|
|
65
|
+
* enabled row.
|
|
66
|
+
*/
|
|
67
|
+
export const CatalogPickerPanel = ({ clearIcon, defaultQuery = "", emptyLabel, favorites, favoritesLabel, groups, inputRef: externalInputRef, itemSize, items, label, onDismiss, onSelect, searchPlaceholder, value, }) => {
|
|
68
|
+
const listId = useUniqueId();
|
|
69
|
+
const ownInputRef = useRef(null);
|
|
70
|
+
const inputRef = externalInputRef ?? ownInputRef;
|
|
71
|
+
const listRef = useRef(null);
|
|
72
|
+
const railRef = useRef(null);
|
|
73
|
+
const tabs = useMemo(() => buildCatalogTabs({
|
|
74
|
+
favorites,
|
|
75
|
+
favoritesLabel,
|
|
76
|
+
groups,
|
|
77
|
+
items,
|
|
78
|
+
}), [favorites, favoritesLabel, groups, items]);
|
|
79
|
+
const [tabKey, setTabKey] = useState(() => pickInitialTabKey({ favorites, items, tabs, value }));
|
|
80
|
+
const [query, setQuery] = useState(defaultQuery);
|
|
81
|
+
const isSearching = toQueryWords(query).length > 0;
|
|
82
|
+
// A tab that has since left the rail (its last row went away) falls
|
|
83
|
+
// back to the first one rather than browsing nothing.
|
|
84
|
+
const currentTab = tabs.find((tab) => tab.key === tabKey) ?? tabs[0];
|
|
85
|
+
const sections = useMemo(() => buildCatalogSections({
|
|
86
|
+
favorites,
|
|
87
|
+
groups,
|
|
88
|
+
items,
|
|
89
|
+
query,
|
|
90
|
+
tab: currentTab,
|
|
91
|
+
}), [currentTab, favorites, groups, items, query]);
|
|
92
|
+
const groupById = useMemo(() => new Map(groups.map((group) => [group.id, group])), [groups]);
|
|
93
|
+
const favoriteValues = useMemo(() => new Set(favorites), [favorites]);
|
|
94
|
+
const indexedSections = useMemo(() => {
|
|
95
|
+
let index = 0;
|
|
96
|
+
return sections.map((section, sectionIndex) => ({
|
|
97
|
+
...section,
|
|
98
|
+
// By position, never from the group's `id`: an `id` with a space
|
|
99
|
+
// in it would split the `aria-labelledby` reference in two.
|
|
100
|
+
headingId: `${listId}-heading-${sectionIndex}`,
|
|
101
|
+
rows: section.items.map((item) => ({
|
|
102
|
+
id: `${listId}-option-${index}`,
|
|
103
|
+
index: index++,
|
|
104
|
+
item,
|
|
105
|
+
})),
|
|
106
|
+
}));
|
|
107
|
+
}, [listId, sections]);
|
|
108
|
+
const rows = indexedSections.flatMap((section) => section.rows);
|
|
109
|
+
/**
|
|
110
|
+
* Where the highlight lands for a fresh view: the chosen row when the
|
|
111
|
+
* view shows it, else the first enabled row. A live query always
|
|
112
|
+
* takes the top match — the 2026-08-25 `Combobox` rule, a filter
|
|
113
|
+
* owns the highlight.
|
|
114
|
+
*/
|
|
115
|
+
const toSeedValue = (viewRows, isQueryLive) => {
|
|
116
|
+
if (!isQueryLive && value !== undefined) {
|
|
117
|
+
const chosenRow = viewRows.find((row) => row.item.value === value &&
|
|
118
|
+
row.item.isDisabled !== true);
|
|
119
|
+
if (chosenRow !== undefined) {
|
|
120
|
+
return chosenRow.item.value;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return viewRows[nextEnabledIndex(viewRows, -1, 1)]?.item
|
|
124
|
+
.value;
|
|
125
|
+
};
|
|
126
|
+
const [activeValue, setActiveValue] = useState(() => toSeedValue(rows, isSearching));
|
|
127
|
+
/**
|
|
128
|
+
* The scroll a fresh view still owes: centre the chosen row, or go
|
|
129
|
+
* back to the top. A new object per view change, so asking twice for
|
|
130
|
+
* the same row is never a no-op.
|
|
131
|
+
*/
|
|
132
|
+
const [pendingScroll, setPendingScroll] = useState({ attempt: 0, isCentred: !isSearching });
|
|
133
|
+
const resolvedActiveIndex = rows.findIndex((row) => row.item.value === activeValue &&
|
|
134
|
+
row.item.isDisabled !== true);
|
|
135
|
+
// The highlighted row left the view, or was disabled, under a
|
|
136
|
+
// catalog refresh: reseed it now, during this render, rather than let
|
|
137
|
+
// Enter fall on nothing or on whatever row took its place.
|
|
138
|
+
// A refresh is not a new query, so the chosen row comes first even
|
|
139
|
+
// while a search runs.
|
|
140
|
+
if (resolvedActiveIndex < 0) {
|
|
141
|
+
const seedValue = toSeedValue(rows, false);
|
|
142
|
+
if (seedValue !== activeValue) {
|
|
143
|
+
setActiveValue(seedValue);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const activeRow = resolvedActiveIndex < 0
|
|
147
|
+
? undefined
|
|
148
|
+
: rows[resolvedActiveIndex];
|
|
149
|
+
const moveActive = (index) => {
|
|
150
|
+
const row = rows[index];
|
|
151
|
+
if (row !== undefined) {
|
|
152
|
+
setActiveValue(row.item.value);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const reseed = (nextRows, isQueryLive) => {
|
|
156
|
+
setActiveValue(toSeedValue(nextRows, isQueryLive));
|
|
157
|
+
setPendingScroll({
|
|
158
|
+
attempt: 0,
|
|
159
|
+
isCentred: !isQueryLive,
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const toRows = (nextQuery, nextTabKey) => buildCatalogSections({
|
|
163
|
+
favorites,
|
|
164
|
+
groups,
|
|
165
|
+
items,
|
|
166
|
+
query: nextQuery,
|
|
167
|
+
tab: tabs.find((tab) => tab.key === nextTabKey) ??
|
|
168
|
+
tabs[0],
|
|
169
|
+
}).flatMap((section) => section.items.map((item) => ({ item })));
|
|
170
|
+
const changeQuery = (nextQuery) => {
|
|
171
|
+
setQuery(nextQuery);
|
|
172
|
+
reseed(toRows(nextQuery, tabKey), toQueryWords(nextQuery).length > 0);
|
|
173
|
+
};
|
|
174
|
+
const showTab = (nextTabKey) => {
|
|
175
|
+
setTabKey(nextTabKey);
|
|
176
|
+
// A tab is a request to see that group, so a search in progress
|
|
177
|
+
// gives way to it rather than leaving the click with no effect.
|
|
178
|
+
setQuery("");
|
|
179
|
+
reseed(toRows("", nextTabKey), false);
|
|
180
|
+
};
|
|
181
|
+
// The scroll lives in an effect because the list has to exist, and
|
|
182
|
+
// be capped, before it can move. Writing `scrollTop` on the list
|
|
183
|
+
// itself (rather than `scrollIntoView`) keeps the page behind the
|
|
184
|
+
// panel from scrolling along with it.
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (pendingScroll === null) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const list = listRef.current;
|
|
190
|
+
if (list === null) {
|
|
191
|
+
setPendingScroll(null);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!pendingScroll.isCentred) {
|
|
195
|
+
list.scrollTop = 0;
|
|
196
|
+
setPendingScroll(null);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const row = activeRow === undefined
|
|
200
|
+
? null
|
|
201
|
+
: document.getElementById(activeRow.id);
|
|
202
|
+
if (row === null) {
|
|
203
|
+
list.scrollTop = 0;
|
|
204
|
+
setPendingScroll(null);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (pendingScroll.attempt < SCROLL_ATTEMPTS &&
|
|
208
|
+
(pendingScroll.attempt === 0 ||
|
|
209
|
+
list.scrollHeight <= list.clientHeight)) {
|
|
210
|
+
const frame = requestAnimationFrame(() => {
|
|
211
|
+
setPendingScroll({
|
|
212
|
+
attempt: pendingScroll.attempt + 1,
|
|
213
|
+
isCentred: true,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
return () => {
|
|
217
|
+
cancelAnimationFrame(frame);
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const listBox = list.getBoundingClientRect();
|
|
221
|
+
const rowBox = row.getBoundingClientRect();
|
|
222
|
+
list.scrollTop +=
|
|
223
|
+
rowBox.top -
|
|
224
|
+
listBox.top -
|
|
225
|
+
(list.clientHeight - rowBox.height) / 2;
|
|
226
|
+
setPendingScroll(null);
|
|
227
|
+
}, [activeRow, pendingScroll]);
|
|
228
|
+
// Keep the highlight in view as the arrows move it, by the least
|
|
229
|
+
// scroll that shows it.
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
if (pendingScroll !== null || activeRow === undefined) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const list = listRef.current;
|
|
235
|
+
const row = document.getElementById(activeRow.id);
|
|
236
|
+
if (list === null || row === null) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const listBox = list.getBoundingClientRect();
|
|
240
|
+
const rowBox = row.getBoundingClientRect();
|
|
241
|
+
if (rowBox.top < listBox.top) {
|
|
242
|
+
list.scrollTop -= listBox.top - rowBox.top;
|
|
243
|
+
}
|
|
244
|
+
else if (rowBox.bottom > listBox.bottom) {
|
|
245
|
+
list.scrollTop += rowBox.bottom - listBox.bottom;
|
|
246
|
+
}
|
|
247
|
+
}, [activeRow, pendingScroll]);
|
|
248
|
+
const searchBoxRef = useRef(null);
|
|
249
|
+
/** The search field's clear button, while it shows. */
|
|
250
|
+
const findClearButton = () => searchBoxRef.current?.querySelector("button") ?? null;
|
|
251
|
+
const focusRail = () => {
|
|
252
|
+
const rail = railRef.current;
|
|
253
|
+
if (rail === null) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
const target = rail.querySelector('[tabindex="0"]');
|
|
257
|
+
target?.focus();
|
|
258
|
+
return target !== null;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* The element inside the panel that last took focus, and whether it
|
|
262
|
+
* was on the rail. A catalog refresh can take that element away — a
|
|
263
|
+
* rail button whose group lost its last row — and the browser then
|
|
264
|
+
* drops focus on `<body>`, outside the panel. The layout effect below
|
|
265
|
+
* puts it back, before anything is painted.
|
|
266
|
+
*/
|
|
267
|
+
const lastFocusRef = useRef(null);
|
|
268
|
+
useLayoutEffect(() => {
|
|
269
|
+
const lastFocus = lastFocusRef.current;
|
|
270
|
+
if (lastFocus === null ||
|
|
271
|
+
lastFocus.element.isConnected ||
|
|
272
|
+
(document.activeElement !== null &&
|
|
273
|
+
document.activeElement !== document.body)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
lastFocusRef.current = null;
|
|
277
|
+
if (!(lastFocus.isOnRail && focusRail())) {
|
|
278
|
+
inputRef.current?.focus();
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
const handleEscape = (keyboardEvent) => {
|
|
282
|
+
keyboardEvent.preventDefault();
|
|
283
|
+
// Handled here, so it goes no further: an enclosing `Dialog` or
|
|
284
|
+
// `Modal` listens for Escape on the document, and would close
|
|
285
|
+
// under the picker on the same key press.
|
|
286
|
+
keyboardEvent.stopPropagation();
|
|
287
|
+
if (query.length > 0) {
|
|
288
|
+
changeQuery("");
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
onDismiss();
|
|
292
|
+
};
|
|
293
|
+
const handleSearchKeyDown = (keyboardEvent) => {
|
|
294
|
+
// An input method editor is mid-word: its Enter commits the word,
|
|
295
|
+
// its Escape cancels it, and its arrows move its own candidates.
|
|
296
|
+
// None of them is the picker's. (`keyCode` 229 is the "IME busy"
|
|
297
|
+
// code browsers report on the keydown that ends a composition.)
|
|
298
|
+
if (keyboardEvent.nativeEvent.isComposing ||
|
|
299
|
+
keyboardEvent.keyCode === 229) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
switch (keyboardEvent.key) {
|
|
303
|
+
case "ArrowDown": {
|
|
304
|
+
keyboardEvent.preventDefault();
|
|
305
|
+
moveActive(nextEnabledIndex(rows, resolvedActiveIndex, 1));
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
case "ArrowUp": {
|
|
309
|
+
keyboardEvent.preventDefault();
|
|
310
|
+
moveActive(resolvedActiveIndex < 0
|
|
311
|
+
? nextEnabledIndex(rows, rows.length, -1)
|
|
312
|
+
: nextEnabledIndex(rows, resolvedActiveIndex, -1));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// Home and End are not here: they move the caret, as in any text
|
|
316
|
+
// field and in `Combobox` (the APG editable-combobox contract).
|
|
317
|
+
case "Enter": {
|
|
318
|
+
if (activeRow === undefined) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
keyboardEvent.preventDefault();
|
|
322
|
+
onSelect(activeRow.item.value);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
case "Escape": {
|
|
326
|
+
handleEscape(keyboardEvent);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
case "Tab": {
|
|
330
|
+
// Forward, a showing clear button is next in the page's own
|
|
331
|
+
// order, so the browser takes it there.
|
|
332
|
+
if (!keyboardEvent.shiftKey &&
|
|
333
|
+
findClearButton() !== null) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
// The cycle stays inside the panel: with no rail, Shift+Tab
|
|
337
|
+
// goes back round to a showing clear button, and a field
|
|
338
|
+
// alone keeps focus.
|
|
339
|
+
keyboardEvent.preventDefault();
|
|
340
|
+
if (!focusRail() && keyboardEvent.shiftKey) {
|
|
341
|
+
findClearButton()?.focus();
|
|
342
|
+
}
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
default:
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Keys on the clear button, which `SearchInput` draws: Tab goes on to
|
|
350
|
+
* the rail (Shift+Tab goes back to the field by itself), and Escape
|
|
351
|
+
* does what it does in the field.
|
|
352
|
+
*/
|
|
353
|
+
const handleSearchBoxKeyDown = (keyboardEvent) => {
|
|
354
|
+
const clearButton = findClearButton();
|
|
355
|
+
if (clearButton === null ||
|
|
356
|
+
keyboardEvent.target !== clearButton) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (keyboardEvent.key === "Escape") {
|
|
360
|
+
// The clear button leaves with the query: move off it first.
|
|
361
|
+
inputRef.current?.focus();
|
|
362
|
+
handleEscape(keyboardEvent);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (keyboardEvent.key === "Tab" &&
|
|
366
|
+
!keyboardEvent.shiftKey) {
|
|
367
|
+
// On to the rail, or round to the field when there is none.
|
|
368
|
+
keyboardEvent.preventDefault();
|
|
369
|
+
if (!focusRail()) {
|
|
370
|
+
inputRef.current?.focus();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const hasRows = rows.length > 0;
|
|
375
|
+
return (_jsxs("div", { className: "flex min-h-0 min-w-0 flex-1", onFocus: (focusEvent) => {
|
|
376
|
+
lastFocusRef.current = {
|
|
377
|
+
element: focusEvent.target,
|
|
378
|
+
isOnRail: railRef.current?.contains(focusEvent.target) ??
|
|
379
|
+
false,
|
|
380
|
+
};
|
|
381
|
+
}, children: [tabs.length > 0 ? (_jsx(CatalogPickerRail, { currentTabKey: isSearching ? undefined : currentTab?.key, itemSize: itemSize, label: `${label} groups`, onEscape: handleEscape, onLeave: (isBackward) => {
|
|
382
|
+
// Backward from the rail is the clear button while it
|
|
383
|
+
// shows, the field otherwise; forward is the field.
|
|
384
|
+
const clearButton = isBackward
|
|
385
|
+
? findClearButton()
|
|
386
|
+
: null;
|
|
387
|
+
if (clearButton === null) {
|
|
388
|
+
inputRef.current?.focus();
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
clearButton.focus();
|
|
392
|
+
}
|
|
393
|
+
}, onShowTab: showTab, ref: railRef, tabs: tabs })) : null, _jsxs("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [_jsx("div", { className: "shrink-0 border-border-subtle border-b p-1.5", onKeyDown: handleSearchBoxKeyDown, ref: searchBoxRef, children: _jsx(SearchInput, { "aria-activedescendant": activeRow?.id, "aria-autocomplete": "list", "aria-controls": hasRows ? listId : undefined, "aria-expanded": hasRows, "aria-label": label, autoCapitalize: "off", autoComplete: "off", autoCorrect: "off", clearIcon: clearIcon ?? null, isClearVisible: clearIcon !== undefined && query.length > 0, onChange: (changeEvent) => {
|
|
394
|
+
changeQuery(changeEvent.currentTarget.value);
|
|
395
|
+
}, onClear: () => {
|
|
396
|
+
changeQuery("");
|
|
397
|
+
}, onKeyDown: handleSearchKeyDown, placeholder: searchPlaceholder, ref: inputRef, role: "combobox", size: SEARCH_SIZE[itemSize], spellCheck: false, value: query }) }), hasRows ? (_jsx("div", { "aria-label": label, className: "charcuterie-scrollbar min-h-0 flex-1 overflow-y-auto overscroll-contain p-1", id: listId, ref: listRef, role: "listbox", children: indexedSections.map((section) => {
|
|
398
|
+
const options = section.rows.map((row) => (_jsx(CatalogPickerOption, { group: row.item.groupId === null
|
|
399
|
+
? undefined
|
|
400
|
+
: groupById.get(row.item.groupId), id: row.id, isActive: row.index === resolvedActiveIndex, isFavorite: favoriteValues.has(row.item.value), isSelected: row.item.value === value, item: row.item, itemSize: itemSize, onChoose: onSelect, onPoint: () => {
|
|
401
|
+
if (row.index !== resolvedActiveIndex &&
|
|
402
|
+
row.item.isDisabled !== true) {
|
|
403
|
+
setActiveValue(row.item.value);
|
|
404
|
+
}
|
|
405
|
+
} }, row.item.value)));
|
|
406
|
+
return section.heading === undefined ? (_jsx("div", { className: "not-first:mt-1", role: "presentation", children: options }, section.key)) : (_jsxs("div", { "aria-labelledby": section.headingId, className: "not-first:mt-1", role: "group", children: [_jsx("div", { className: toClassName(GROUP_HEADING_INSET_CLASS[itemSize], "pt-1.5 pb-0.5 font-medium text-content-secondary text-xs"), id: section.headingId, children: section.heading }), options] }, section.key));
|
|
407
|
+
}) })) : (_jsx("p", { className: "m-0 px-4 py-6 text-center text-content-muted text-sm", children: emptyLabel }))] })] }));
|
|
408
|
+
};
|
|
409
|
+
//# sourceMappingURL=CatalogPickerPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatalogPickerPanel.js","sourceRo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AAC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ControlSize } from "@charcuterie/tokens";
|
|
2
|
+
import type { KeyboardEvent as ReactKeyboardEvent, ReactNode, Ref } from "react";
|
|
3
|
+
import type { CatalogPickerTab } from "./catalogPickerView.ts";
|
|
4
|
+
export type CatalogPickerRailProps = {
|
|
5
|
+
/** The tab whose rows the list shows, or `undefined` while a search shows every group. */
|
|
6
|
+
currentTabKey: string | undefined;
|
|
7
|
+
itemSize: ControlSize;
|
|
8
|
+
label: string;
|
|
9
|
+
/** Escape on a rail button: the same clear-then-close the search field does. */
|
|
10
|
+
onEscape: (keyboardEvent: ReactKeyboardEvent<HTMLElement>) => void;
|
|
11
|
+
/** Tab out of the rail (`isBackward` for Shift+Tab), back to the search field or its clear button. */
|
|
12
|
+
onLeave: (isBackward: boolean) => void;
|
|
13
|
+
onShowTab: (tabKey: string) => void;
|
|
14
|
+
ref?: Ref<HTMLDivElement>;
|
|
15
|
+
tabs: readonly CatalogPickerTab[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The vertical rail: Favorites, then one button per group.
|
|
19
|
+
*
|
|
20
|
+
* ### A toolbar of toggle buttons, not a `tablist`
|
|
21
|
+
*
|
|
22
|
+
* It looks like tabs, and the first build was going to be one. Two
|
|
23
|
+
* things the picker has to do are things a tablist cannot say:
|
|
24
|
+
*
|
|
25
|
+
* - **While a search runs, no tab is current.** The list shows matches
|
|
26
|
+
* from every group, so claiming one tab is selected would be false,
|
|
27
|
+
* and an APG tablist always has a selected tab.
|
|
28
|
+
* - **There is no tab panel.** What the tab changes is the contents of
|
|
29
|
+
* a listbox that the search field also drives; the listbox is not
|
|
30
|
+
* the tab's panel and cannot be `role="tabpanel"` as well.
|
|
31
|
+
*
|
|
32
|
+
* A `role="toolbar"` of `aria-pressed` buttons says exactly what is
|
|
33
|
+
* true: a set of switches, at most one pressed, that change what the
|
|
34
|
+
* list shows. The APG toolbar pattern also gives the keyboard contract
|
|
35
|
+
* for free — one tab stop, arrows move focus (vertically here), Home
|
|
36
|
+
* and End jump, Enter and Space press.
|
|
37
|
+
*
|
|
38
|
+
* ### The pointer keeps focus in the search field
|
|
39
|
+
*
|
|
40
|
+
* A mouse press on a rail button is prevented from taking focus, the
|
|
41
|
+
* way an option's is, so a click changes the list and the caret stays
|
|
42
|
+
* where the person can keep typing or arrowing. A keyboard user who
|
|
43
|
+
* tabbed onto the rail keeps focus on it.
|
|
44
|
+
*
|
|
45
|
+
* Each button's accessible name is the group's label, and the same
|
|
46
|
+
* text is its `Tooltip`, because the mark alone is an icon or two
|
|
47
|
+
* letters.
|
|
48
|
+
*/
|
|
49
|
+
export declare const CatalogPickerRail: ({ currentTabKey, itemSize, label, onEscape, onLeave, onShowTab, ref, tabs, }: CatalogPickerRailProps) => ReactNode;
|
|
50
|
+
//# sourceMappingURL=CatalogPickerRail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatalogPickerRail.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPickerRail.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EACV,aAAa,IAAI,kBAAkB,EACnC,SAAS,EACT,GAAG,EACJ,MAAM,OAAO,CAAA;AAQd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,MAAM,MAAM,sBAAsB,GAAG;IACnC,0FAA0F;IAC1F,aAAa,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,QAAQ,EAAE,WAAW,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,QAAQ,EAAE,CACR,aAAa,EAAE,kBAAkB,CAAC,WAAW,CAAC,KAC3C,IAAI,CAAA;IACT,sGAAsG;IACtG,OAAO,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;IACzB,IAAI,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAClC,CAAA;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,iBAAiB,GAAI,8EAS/B,sBAAsB,KAAG,SAsI3B,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { FOCUS_RING_CLASS } from "../intentStyles.js";
|
|
4
|
+
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
5
|
+
import { toClassName } from "../toClassName.js";
|
|
6
|
+
import { CatalogPickerMark } from "./CatalogPickerMark.js";
|
|
7
|
+
import { RAIL_FAVORITE_STAR } from "./catalogPickerDrawings.js";
|
|
8
|
+
const RAIL_BUTTON_SIZE_CLASS = {
|
|
9
|
+
lg: "size-(--control-height-lg)",
|
|
10
|
+
md: "size-(--control-height-md)",
|
|
11
|
+
sm: "size-(--control-height-sm)",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The vertical rail: Favorites, then one button per group.
|
|
15
|
+
*
|
|
16
|
+
* ### A toolbar of toggle buttons, not a `tablist`
|
|
17
|
+
*
|
|
18
|
+
* It looks like tabs, and the first build was going to be one. Two
|
|
19
|
+
* things the picker has to do are things a tablist cannot say:
|
|
20
|
+
*
|
|
21
|
+
* - **While a search runs, no tab is current.** The list shows matches
|
|
22
|
+
* from every group, so claiming one tab is selected would be false,
|
|
23
|
+
* and an APG tablist always has a selected tab.
|
|
24
|
+
* - **There is no tab panel.** What the tab changes is the contents of
|
|
25
|
+
* a listbox that the search field also drives; the listbox is not
|
|
26
|
+
* the tab's panel and cannot be `role="tabpanel"` as well.
|
|
27
|
+
*
|
|
28
|
+
* A `role="toolbar"` of `aria-pressed` buttons says exactly what is
|
|
29
|
+
* true: a set of switches, at most one pressed, that change what the
|
|
30
|
+
* list shows. The APG toolbar pattern also gives the keyboard contract
|
|
31
|
+
* for free — one tab stop, arrows move focus (vertically here), Home
|
|
32
|
+
* and End jump, Enter and Space press.
|
|
33
|
+
*
|
|
34
|
+
* ### The pointer keeps focus in the search field
|
|
35
|
+
*
|
|
36
|
+
* A mouse press on a rail button is prevented from taking focus, the
|
|
37
|
+
* way an option's is, so a click changes the list and the caret stays
|
|
38
|
+
* where the person can keep typing or arrowing. A keyboard user who
|
|
39
|
+
* tabbed onto the rail keeps focus on it.
|
|
40
|
+
*
|
|
41
|
+
* Each button's accessible name is the group's label, and the same
|
|
42
|
+
* text is its `Tooltip`, because the mark alone is an icon or two
|
|
43
|
+
* letters.
|
|
44
|
+
*/
|
|
45
|
+
export const CatalogPickerRail = ({ currentTabKey, itemSize, label, onEscape, onLeave, onShowTab, ref, tabs, }) => {
|
|
46
|
+
// The roving tab stop: the current tab while browsing, and whichever
|
|
47
|
+
// button the arrows last reached otherwise.
|
|
48
|
+
const [focusKey, setFocusKey] = useState(currentTabKey);
|
|
49
|
+
const tabStopKey = tabs.find((tab) => tab.key === focusKey)?.key ??
|
|
50
|
+
tabs.find((tab) => tab.key === currentTabKey)?.key ??
|
|
51
|
+
tabs[0]?.key;
|
|
52
|
+
// Wraps at both ends, as the APG toolbar allows. The buttons are
|
|
53
|
+
// found from the one that has focus, so two open pickers could never
|
|
54
|
+
// reach into each other's rail.
|
|
55
|
+
const moveFocus = (from, index) => {
|
|
56
|
+
const wrappedIndex = (index + tabs.length) % tabs.length;
|
|
57
|
+
const tab = tabs[wrappedIndex];
|
|
58
|
+
if (tab === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setFocusKey(tab.key);
|
|
62
|
+
from
|
|
63
|
+
.closest('[role="toolbar"]')
|
|
64
|
+
?.querySelectorAll("button")[wrappedIndex]?.focus();
|
|
65
|
+
};
|
|
66
|
+
const handleKeyDown = (keyboardEvent, index) => {
|
|
67
|
+
switch (keyboardEvent.key) {
|
|
68
|
+
case "ArrowDown": {
|
|
69
|
+
keyboardEvent.preventDefault();
|
|
70
|
+
moveFocus(keyboardEvent.currentTarget, index + 1);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
case "ArrowUp": {
|
|
74
|
+
keyboardEvent.preventDefault();
|
|
75
|
+
moveFocus(keyboardEvent.currentTarget, index - 1);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
case "Home": {
|
|
79
|
+
keyboardEvent.preventDefault();
|
|
80
|
+
moveFocus(keyboardEvent.currentTarget, 0);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
case "End": {
|
|
84
|
+
keyboardEvent.preventDefault();
|
|
85
|
+
moveFocus(keyboardEvent.currentTarget, tabs.length - 1);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
case "Escape": {
|
|
89
|
+
onEscape(keyboardEvent);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
case "Tab": {
|
|
93
|
+
keyboardEvent.preventDefault();
|
|
94
|
+
onLeave(keyboardEvent.shiftKey);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return (_jsx("div", { "aria-label": label, "aria-orientation": "vertical", className: "charcuterie-scrollbar flex shrink-0 flex-col gap-1 overflow-y-auto overscroll-contain border-border-subtle border-e p-1.5", ref: ref, role: "toolbar", children: tabs.map((tab, index) => {
|
|
101
|
+
const isCurrent = tab.key === currentTabKey;
|
|
102
|
+
return (_jsx(Tooltip, { label: tab.label, placement: "right", children: _jsx("button", { "aria-label": tab.label, "aria-pressed": isCurrent, className: toClassName("flex shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors duration-(--duration-fast) ease-standard", RAIL_BUTTON_SIZE_CLASS[itemSize], isCurrent
|
|
103
|
+
? "bg-intent-accent-surface text-intent-accent-content"
|
|
104
|
+
: "text-content-secondary hover:bg-intent-neutral-surface-hover hover:text-content-primary", FOCUS_RING_CLASS), onClick: () => {
|
|
105
|
+
setFocusKey(tab.key);
|
|
106
|
+
onShowTab(tab.key);
|
|
107
|
+
}, onKeyDown: (keyboardEvent) => {
|
|
108
|
+
handleKeyDown(keyboardEvent, index);
|
|
109
|
+
}, onMouseDown: (mouseEvent) => {
|
|
110
|
+
mouseEvent.preventDefault();
|
|
111
|
+
}, tabIndex: tab.key === tabStopKey ? 0 : -1, type: "button", children: tab.kind === "favorites" ? (RAIL_FAVORITE_STAR) : (_jsx(CatalogPickerMark, { accentColor: tab.group.accentColor, icon: tab.group.icon, initialsOf: tab.group.label, size: itemSize })) }) }, tab.key));
|
|
112
|
+
}) }));
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=CatalogPickerRail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatalogPickerRail.js","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPickerRail.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAwB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA6B,CAAA;AAmBhE,MAAM,sBAAsB,GAC1B;IACE,EAAE,EAAE,4BAA4B;IAChC,EAAE,EAAE,4BAA4B;IAChC,EAAE,EAAE,4BAA4B;CACjC,CAAA;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,aAAa,EACb,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO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AAC,QAAQ,CAAC,EAChC,SAAS;wBACP,CAAC,CAAC,qDAAqD;wBACvD,CAAC,CAAC,yFAAyF,EAC7F,gBAAgB,CACjB,EACD,OAAO,EAAE,GAAG,EAAE;wBACZ,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;wBACpB,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;oBACpB,CAAC,EACD,SAAS,EAAE,CAAC,aAAa,EAAE,EAAE;wBAC3B,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;oBACrC,CAAC,EACD,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;wBAC1B,UAAU,CAAC,cAAc,EAAE,CAAA;oBAC7B,CAAC,EACD,QAAQ,EAAE,GAAG,CAAC,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACzC,IAAI,EAAC,QAAQ,YAEZ,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,CAC1B,kBAAkB,CACnB,CAAC,CAAC,CAAC,CACF,KAAC,iBAAiB,IAChB,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,EAClC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EACpB,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,EAC3B,IAAI,EAAE,QAAQ,GACd,CACH,GACM,IAtCJ,GAAG,CAAC,GAAG,CAuCJ,CACX,CAAA;QACH,CAAC,CAAC,GACE,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The small filled star on a favorite's row. */
|
|
2
|
+
export declare const ROW_FAVORITE_STAR: import("react").JSX.Element;
|
|
3
|
+
/** The favorites tab's mark on the rail. Takes the tab's text color. */
|
|
4
|
+
export declare const RAIL_FAVORITE_STAR: import("react").JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* The chosen row's check: the bottom and end edges of a narrow box,
|
|
7
|
+
* turned 45 degrees. `currentColor`, so it takes the row's accent.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CHOSEN_CHECK: import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=catalogPickerDrawings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogPickerDrawings.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/catalogPickerDrawings.tsx"],"names":[],"mappings":"AAuBA,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,6BAM7B,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,6BAM9B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,6BAKxB,CAAA"}
|