@eifi1/ui-kit 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -11
- package/dist/components/alert-banner.d.ts +32 -5
- package/dist/components/alert-banner.js +57 -14
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/breadcrumbs.d.ts +60 -0
- package/dist/components/breadcrumbs.js +88 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bulk-action-bar.d.ts +66 -0
- package/dist/components/bulk-action-bar.js +149 -0
- package/dist/components/bulk-action-bar.js.map +1 -0
- package/dist/components/calculator.d.ts +6 -0
- package/dist/components/chip.d.ts +58 -10
- package/dist/components/chip.js +91 -7
- package/dist/components/chip.js.map +1 -1
- package/dist/components/copy-button.d.ts +13 -4
- package/dist/components/copy-button.js +17 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +122 -91
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +89 -3
- package/dist/components/date-picker.js +163 -68
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +43 -6
- package/dist/components/description-list.js +91 -11
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +7 -0
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +68 -4
- package/dist/components/disclosure.js +33 -15
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +3 -4
- package/dist/components/file-dropzone.js +2 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.d.ts +29 -2
- package/dist/components/floating-panel.js +16 -2
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +23 -4
- package/dist/components/full-bleed-dialog.js +11 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/list.d.ts +174 -0
- package/dist/components/list.js +215 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu-item.d.ts +99 -0
- package/dist/components/menu-item.js +83 -0
- package/dist/components/menu-item.js.map +1 -0
- package/dist/components/modal.d.ts +23 -1
- package/dist/components/modal.js +36 -10
- package/dist/components/modal.js.map +1 -1
- package/dist/components/number-field.d.ts +6 -0
- package/dist/components/number-input.d.ts +6 -0
- package/dist/components/numpad-sheet.d.ts +6 -0
- package/dist/components/page-contents.js +1 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.d.ts +37 -0
- package/dist/components/page-header.js +36 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/progress-bar.d.ts +16 -2
- package/dist/components/progress-bar.js +4 -2
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +3 -0
- package/dist/components/series-chart-labels.js +2 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +16 -0
- package/dist/components/series-chart.js +137 -3
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/status-dot.d.ts +49 -0
- package/dist/components/status-dot.js +52 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/table.d.ts +39 -6
- package/dist/components/table.js +43 -4
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +63 -0
- package/dist/components/text.js +23 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/toast.d.ts +167 -0
- package/dist/components/toast.js +226 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +29 -1
- package/dist/components/toggle-group.js +52 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +38 -15
- package/dist/components/tooltip.js +85 -47
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +139 -16
- package/dist/components/ui.js +136 -26
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/{data-table-filters-CF1PXqjQ.d.ts → data-table-filters-Dh9uF_S-.d.ts} +33 -2
- package/dist/data-table.d.ts +1 -1
- package/dist/hooks/use-close-transition.d.ts +7 -1
- package/dist/hooks/use-close-transition.js +5 -2
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +84 -4
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.d.ts +6 -0
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +11 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
- package/dist/i18n/locales/de-CH.d.ts +6 -0
- package/dist/i18n/locales/de-informal.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.js +31 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.js +31 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.js +31 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.js +31 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.js +31 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +6 -0
- package/dist/i18n/locales/zh.js +31 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +9 -0
- package/dist/lib/clipping.js +14 -0
- package/dist/lib/clipping.js.map +1 -0
- package/dist/search/command-palette.d.ts +67 -2
- package/dist/search/command-palette.js +147 -33
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +166 -0
- package/dist/search/global-search.js +293 -0
- package/dist/search/global-search.js.map +1 -0
- package/dist/search/search-index.d.ts +105 -0
- package/dist/search/search-index.js +142 -0
- package/dist/search/search-index.js.map +1 -0
- package/dist/search.d.ts +3 -1
- package/dist/search.js +2 -0
- package/dist/search.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +10 -1
- package/dist/wizard/stepper-nav.js +3 -2
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +2 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +1 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-summary.js +3 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +25 -12
- package/src/components/alert-banner.tsx +117 -18
- package/src/components/breadcrumbs.tsx +168 -0
- package/src/components/bulk-action-bar.tsx +256 -0
- package/src/components/chip.tsx +164 -13
- package/src/components/copy-button.tsx +29 -7
- package/src/components/data-table.tsx +81 -5
- package/src/components/date-picker.tsx +377 -118
- package/src/components/description-list.tsx +168 -15
- package/src/components/dialog-frame.tsx +7 -0
- package/src/components/disclosure.tsx +116 -28
- package/src/components/file-dropzone.tsx +9 -10
- package/src/components/floating-panel.tsx +46 -2
- package/src/components/full-bleed-dialog.tsx +42 -5
- package/src/components/list.tsx +417 -0
- package/src/components/menu-item.tsx +214 -0
- package/src/components/modal.tsx +80 -17
- package/src/components/page-contents.tsx +4 -4
- package/src/components/page-header.tsx +68 -0
- package/src/components/progress-bar.tsx +27 -3
- package/src/components/series-chart-labels.ts +4 -0
- package/src/components/series-chart.tsx +253 -3
- package/src/components/status-dot.tsx +99 -0
- package/src/components/table.tsx +91 -6
- package/src/components/text.tsx +89 -0
- package/src/components/toast.tsx +441 -0
- package/src/components/toggle-group.tsx +82 -3
- package/src/components/tooltip.tsx +186 -100
- package/src/components/ui.tsx +321 -41
- package/src/hooks/use-close-transition.ts +14 -5
- package/src/hooks/use-copy-to-clipboard.ts +1 -1
- package/src/hooks/use-overlay-history.ts +181 -4
- package/src/i18n/defaults.ts +10 -0
- package/src/i18n/kit-labels.tsx +10 -0
- package/src/i18n/locales/de.ts +30 -0
- package/src/i18n/locales/es.ts +30 -0
- package/src/i18n/locales/fr.ts +30 -0
- package/src/i18n/locales/hu.ts +30 -0
- package/src/i18n/locales/it.ts +30 -0
- package/src/i18n/locales/zh.ts +30 -0
- package/src/index.ts +30 -0
- package/src/lib/clipping.ts +16 -0
- package/src/search/command-palette.tsx +241 -31
- package/src/search/global-search.tsx +525 -0
- package/src/search/search-index.ts +295 -0
- package/src/search.ts +2 -0
- package/src/wizard/stepper-nav.tsx +13 -2
- package/src/wizard/types.ts +2 -2
- package/src/wizard/use-wizard.ts +3 -3
- package/src/wizard/wizard-summary.tsx +14 -10
- package/tokens.css +97 -0
|
@@ -20,6 +20,18 @@ interface CommandItem {
|
|
|
20
20
|
* with a link and JavaScript cannot fake — the rejected alternative, an
|
|
21
21
|
* `onAuxClick` calling `window.open`, gets the middle click and nothing else. */
|
|
22
22
|
href?: string;
|
|
23
|
+
/** Marks this row's label and hint `data-private`, so session replay and screenshot
|
|
24
|
+
* tooling masks them — a payee, an account name, an amount. Overrides the palette's
|
|
25
|
+
* {@link CommandPaletteProps.redactLabels} either way, so `false` un-masks one
|
|
26
|
+
* harmless row ("Settings") in a palette that masks by default. */
|
|
27
|
+
redact?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* `"status"` makes the row a line of text rather than a choice — a group's
|
|
30
|
+
* "Searching…" while its source is still out, or its error. It is skipped by the
|
|
31
|
+
* arrow keys and ↵, has no hover highlight, and its `onSelect` is never called.
|
|
32
|
+
* Default `"option"`.
|
|
33
|
+
*/
|
|
34
|
+
kind?: "option" | "status";
|
|
23
35
|
}
|
|
24
36
|
interface CommandPaletteLabels {
|
|
25
37
|
placeholder: string;
|
|
@@ -41,8 +53,22 @@ interface CommandPaletteLabels {
|
|
|
41
53
|
* rejects. Optional for the same reason as `dialog`; the default always carries it.
|
|
42
54
|
*/
|
|
43
55
|
error?: string;
|
|
56
|
+
/** Names the "×" that empties the field. Optional like `dialog`. */
|
|
57
|
+
clear?: string;
|
|
58
|
+
/** Names the button that commits the typed text when `searchOn="submit"`. */
|
|
59
|
+
submit?: string;
|
|
60
|
+
/** Names the close button of the full-screen phone presentation, which has no
|
|
61
|
+
* backdrop to tap and, on a phone, no Escape key. */
|
|
62
|
+
close?: string;
|
|
44
63
|
}
|
|
45
64
|
declare const DEFAULT_COMMAND_PALETTE_LABELS: CommandPaletteLabels;
|
|
65
|
+
/**
|
|
66
|
+
* How tall the palette's rows are. `"compact"` (the default) is the desktop list the
|
|
67
|
+
* palette always drew, 36px a row; `"comfortable"` gives every row the kit's 44px touch
|
|
68
|
+
* target (`min-h-11`) and body-size text — keksdose's phone search, where a 36px row
|
|
69
|
+
* under a thumb picks its neighbour.
|
|
70
|
+
*/
|
|
71
|
+
type CommandPaletteDensity = "compact" | "comfortable";
|
|
46
72
|
interface CommandPaletteProps {
|
|
47
73
|
open: boolean;
|
|
48
74
|
onClose: () => void;
|
|
@@ -51,6 +77,14 @@ interface CommandPaletteProps {
|
|
|
51
77
|
* query is allowed — return defaults like pages/recent). Sync or async; stale
|
|
52
78
|
* async responses are ignored.
|
|
53
79
|
*
|
|
80
|
+
* A SYNCHRONOUS provider (one returning an array, not a promise) never shows the
|
|
81
|
+
* "Searching…" hint: its answer is there the moment it is asked, and the hint only
|
|
82
|
+
* flashed through the debounce before results that were never late — keksdose's
|
|
83
|
+
* transaction search filters a list already in memory. The palette tells the two
|
|
84
|
+
* apart by what the provider RETURNS, call by call, so there is no prop to keep in
|
|
85
|
+
* step with the implementation: an async provider shows the hint from the first
|
|
86
|
+
* promise on (and during the debounce of every later query), a sync one never.
|
|
87
|
+
*
|
|
54
88
|
* Its IDENTITY is not a re-run signal — it is read through a ref, so the palette
|
|
55
89
|
* never re-searches merely because the caller rebuilt the callback. That is
|
|
56
90
|
* deliberate: a provider closing over a list rendered from a query allocates a new
|
|
@@ -85,6 +119,37 @@ interface CommandPaletteProps {
|
|
|
85
119
|
/** Every edit of the field's text. Fires in both modes — uncontrolled, it only
|
|
86
120
|
* observes. */
|
|
87
121
|
onQueryChange?: (query: string) => void;
|
|
122
|
+
/**
|
|
123
|
+
* When the typed text becomes THE query — the one `search` runs on and
|
|
124
|
+
* `onQueryChange` reports.
|
|
125
|
+
*
|
|
126
|
+
* - `"input"` (default): every keystroke, debounced for the search, as before.
|
|
127
|
+
* - `"submit"`: typing edits a draft; the query is committed by ↵ or the submit
|
|
128
|
+
* button beside the field. Until then the results stay on the last committed query
|
|
129
|
+
* and `onQueryChange` stays quiet — which is what an owner binding `query` to the
|
|
130
|
+
* URL's `q` needs, or every keystroke re-filters the page behind and pushes history.
|
|
131
|
+
* ↵ with a draft that differs from the committed query COMMITS; ↵ with nothing new
|
|
132
|
+
* typed chooses the highlighted row, as in `"input"` mode. The draft follows any
|
|
133
|
+
* outside change of the committed query (Back through the URL), and an uncommitted
|
|
134
|
+
* draft is dropped when the palette is closed.
|
|
135
|
+
*
|
|
136
|
+
* The clear "×" commits the empty query in both modes: an emptied box over results
|
|
137
|
+
* (or a page) still filtered by the old text is the stuck state Keksdose #423 was.
|
|
138
|
+
*/
|
|
139
|
+
searchOn?: "input" | "submit";
|
|
140
|
+
/** Mark every row's label and hint `data-private` (see {@link CommandItem.redact},
|
|
141
|
+
* which overrides it per row). Off by default. */
|
|
142
|
+
redactLabels?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Below the phone breakpoint ({@link PHONE_QUERY}) the palette fills the screen:
|
|
145
|
+
* no inset, no rounded panel, the field pinned at the top inside the safe areas and
|
|
146
|
+
* the list scrolling under it, with a close button since there is no backdrop to tap.
|
|
147
|
+
* On by default — a top-centred card at 70vh leaves little room once the keyboard is
|
|
148
|
+
* up. `false` keeps the card on every viewport.
|
|
149
|
+
*/
|
|
150
|
+
fullScreenOnPhone?: boolean;
|
|
151
|
+
/** Row height — see {@link CommandPaletteDensity}. Default `"compact"`. */
|
|
152
|
+
density?: CommandPaletteDensity;
|
|
88
153
|
labels?: Partial<CommandPaletteLabels>;
|
|
89
154
|
}
|
|
90
155
|
/** Registers a global ⌘K / Ctrl-K shortcut that calls `onOpen`. */
|
|
@@ -95,6 +160,6 @@ declare function useCommandKey(onOpen: () => void): void;
|
|
|
95
160
|
* results via the `search` provider (pages, actions, records, …); each result
|
|
96
161
|
* carries its own `onSelect`.
|
|
97
162
|
*/
|
|
98
|
-
declare function CommandPalette({ open, onClose, search, revision, query: queryProp, onQueryChange, labels, }: CommandPaletteProps): react.ReactPortal | null;
|
|
163
|
+
declare function CommandPalette({ open, onClose, search, revision, query: queryProp, onQueryChange, searchOn, redactLabels, fullScreenOnPhone, density, labels, }: CommandPaletteProps): react.ReactPortal | null;
|
|
99
164
|
|
|
100
|
-
export { type CommandItem, CommandPalette, type CommandPaletteLabels, DEFAULT_COMMAND_PALETTE_LABELS, useCommandKey };
|
|
165
|
+
export { type CommandItem, CommandPalette, type CommandPaletteDensity, type CommandPaletteLabels, DEFAULT_COMMAND_PALETTE_LABELS, useCommandKey };
|
|
@@ -2,19 +2,40 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
import { Search } from "lucide-react";
|
|
5
|
+
import { CornerDownLeft, Search, X } from "lucide-react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { PHONE_QUERY } from "../components/ui.js";
|
|
8
|
+
import { useMediaQuery } from "../hooks/use-media-query.js";
|
|
7
9
|
import { useOverlayHistory } from "../hooks/use-overlay-history.js";
|
|
8
10
|
import { useFocusTrap } from "../hooks/use-focus-trap.js";
|
|
9
11
|
import { useBodyScrollLock } from "../hooks/use-body-scroll-lock.js";
|
|
10
12
|
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
13
|
+
function groupItems(items) {
|
|
14
|
+
const order = [];
|
|
15
|
+
const byGroup = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const item of items) {
|
|
17
|
+
if (!byGroup.has(item.group)) {
|
|
18
|
+
byGroup.set(item.group, []);
|
|
19
|
+
order.push(item.group);
|
|
20
|
+
}
|
|
21
|
+
byGroup.get(item.group).push(item);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
groups: order.map((g) => ({ group: g, items: byGroup.get(g) })),
|
|
25
|
+
flat: order.flatMap((g) => byGroup.get(g)).filter((item) => item.kind !== "status")
|
|
26
|
+
};
|
|
27
|
+
}
|
|
11
28
|
const DEFAULT_COMMAND_PALETTE_LABELS = {
|
|
12
29
|
placeholder: "Search\u2026",
|
|
13
30
|
empty: "No results",
|
|
14
31
|
loading: "Searching\u2026",
|
|
15
32
|
dialog: "Search",
|
|
16
|
-
error: "Search failed. Try again."
|
|
33
|
+
error: "Search failed. Try again.",
|
|
34
|
+
clear: "Clear search",
|
|
35
|
+
submit: "Search",
|
|
36
|
+
close: "Close"
|
|
17
37
|
};
|
|
38
|
+
const isThenable = (value) => typeof value?.then === "function";
|
|
18
39
|
const { dialog: DEFAULT_DIALOG_NAME, ...DEFAULTS_WITHOUT_DIALOG } = DEFAULT_COMMAND_PALETTE_LABELS;
|
|
19
40
|
function useCommandKey(onOpen) {
|
|
20
41
|
useEffect(() => {
|
|
@@ -35,6 +56,10 @@ function CommandPalette({
|
|
|
35
56
|
revision,
|
|
36
57
|
query: queryProp,
|
|
37
58
|
onQueryChange,
|
|
59
|
+
searchOn = "input",
|
|
60
|
+
redactLabels = false,
|
|
61
|
+
fullScreenOnPhone = true,
|
|
62
|
+
density = "compact",
|
|
38
63
|
labels
|
|
39
64
|
}) {
|
|
40
65
|
const l = useKitLabels("commandPalette", DEFAULTS_WITHOUT_DIALOG, labels);
|
|
@@ -46,6 +71,20 @@ function CommandPalette({
|
|
|
46
71
|
if (!controlled) setOwnQuery(next);
|
|
47
72
|
onQueryChange?.(next);
|
|
48
73
|
};
|
|
74
|
+
const submitMode = searchOn === "submit";
|
|
75
|
+
const [draft, setDraft] = useState(query);
|
|
76
|
+
const [draftBase, setDraftBase] = useState(query);
|
|
77
|
+
if (draftBase !== query) {
|
|
78
|
+
setDraftBase(query);
|
|
79
|
+
setDraft(query);
|
|
80
|
+
}
|
|
81
|
+
const fieldText = submitMode ? draft : query;
|
|
82
|
+
const commit = (next) => {
|
|
83
|
+
setDraft(next);
|
|
84
|
+
setQuery(next);
|
|
85
|
+
};
|
|
86
|
+
const dirty = submitMode && draft !== query;
|
|
87
|
+
const isPhone = useMediaQuery(PHONE_QUERY, false) && fullScreenOnPhone;
|
|
49
88
|
const [results, setResults] = useState([]);
|
|
50
89
|
const [loading, setLoading] = useState(false);
|
|
51
90
|
const [failed, setFailed] = useState(false);
|
|
@@ -60,28 +99,40 @@ function CommandPalette({
|
|
|
60
99
|
const searchRef = useRef(search);
|
|
61
100
|
searchRef.current = search;
|
|
62
101
|
const reqId = useRef(0);
|
|
102
|
+
const syncRef = useRef(void 0);
|
|
103
|
+
const shownQuery = useRef(null);
|
|
104
|
+
const activeIdRef = useRef(void 0);
|
|
63
105
|
useOverlayHistory(open, onClose);
|
|
64
106
|
useFocusTrap(dialogRef, { active: open, initialFocus: () => inputRef.current });
|
|
65
107
|
useBodyScrollLock(open);
|
|
66
108
|
useEffect(() => {
|
|
67
109
|
if (!open) return;
|
|
68
110
|
if (!controlled) setOwnQuery("");
|
|
111
|
+
setDraft(controlled ? query : "");
|
|
69
112
|
setActive(0);
|
|
113
|
+
shownQuery.current = null;
|
|
70
114
|
}, [open]);
|
|
71
115
|
useEffect(() => {
|
|
72
116
|
if (!open) return;
|
|
73
117
|
const id = ++reqId.current;
|
|
74
|
-
setLoading(true);
|
|
118
|
+
if (syncRef.current === false) setLoading(true);
|
|
75
119
|
const run = async () => {
|
|
76
120
|
try {
|
|
77
|
-
const
|
|
121
|
+
const answer = searchRef.current(query);
|
|
122
|
+
syncRef.current = !isThenable(answer);
|
|
123
|
+
if (!syncRef.current) setLoading(true);
|
|
124
|
+
const r = await answer;
|
|
78
125
|
if (reqId.current === id) {
|
|
126
|
+
const keep = shownQuery.current === query ? activeIdRef.current : void 0;
|
|
127
|
+
const at = keep === void 0 ? -1 : groupItems(r).flat.findIndex((item) => item.id === keep);
|
|
128
|
+
shownQuery.current = query;
|
|
79
129
|
setResults(r);
|
|
80
130
|
setFailed(false);
|
|
81
|
-
setActive(0);
|
|
131
|
+
setActive(Math.max(at, 0));
|
|
82
132
|
}
|
|
83
133
|
} catch (err) {
|
|
84
134
|
if (reqId.current === id) {
|
|
135
|
+
shownQuery.current = null;
|
|
85
136
|
setResults([]);
|
|
86
137
|
setFailed(true);
|
|
87
138
|
setActive(0);
|
|
@@ -94,21 +145,10 @@ function CommandPalette({
|
|
|
94
145
|
const t = setTimeout(run, query ? 150 : 0);
|
|
95
146
|
return () => clearTimeout(t);
|
|
96
147
|
}, [query, open, revision]);
|
|
97
|
-
const { groups, flat } = useMemo(() =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!byGroup.has(item.group)) {
|
|
102
|
-
byGroup.set(item.group, []);
|
|
103
|
-
order.push(item.group);
|
|
104
|
-
}
|
|
105
|
-
byGroup.get(item.group).push(item);
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
groups: order.map((g) => ({ group: g, items: byGroup.get(g) })),
|
|
109
|
-
flat: order.flatMap((g) => byGroup.get(g))
|
|
110
|
-
};
|
|
111
|
-
}, [results]);
|
|
148
|
+
const { groups, flat } = useMemo(() => groupItems(results), [results]);
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
activeIdRef.current = flat[active]?.id;
|
|
151
|
+
});
|
|
112
152
|
const choose = (item) => {
|
|
113
153
|
if (!item) return;
|
|
114
154
|
onClose();
|
|
@@ -123,7 +163,8 @@ function CommandPalette({
|
|
|
123
163
|
setActive((i) => Math.max(i - 1, 0));
|
|
124
164
|
} else if (e.key === "Enter") {
|
|
125
165
|
e.preventDefault();
|
|
126
|
-
|
|
166
|
+
if (dirty) commit(draft);
|
|
167
|
+
else choose(flat[active]);
|
|
127
168
|
}
|
|
128
169
|
};
|
|
129
170
|
const onDialogKeyDown = (e) => {
|
|
@@ -134,15 +175,19 @@ function CommandPalette({
|
|
|
134
175
|
};
|
|
135
176
|
useEffect(() => {
|
|
136
177
|
const el = listRef.current?.querySelector(`[data-index="${active}"]`);
|
|
137
|
-
el?.scrollIntoView({ block: "nearest" });
|
|
178
|
+
el?.scrollIntoView?.({ block: "nearest" });
|
|
138
179
|
}, [active]);
|
|
139
180
|
if (!open) return null;
|
|
181
|
+
const comfortable = density === "comfortable";
|
|
140
182
|
let flatIndex = -1;
|
|
141
183
|
return createPortal(
|
|
142
184
|
/* @__PURE__ */ jsx(
|
|
143
185
|
"div",
|
|
144
186
|
{
|
|
145
|
-
className:
|
|
187
|
+
className: cn(
|
|
188
|
+
"fixed inset-0 z-[70] flex items-start justify-center bg-black/40",
|
|
189
|
+
isPhone ? "p-0" : "p-4 pt-[10vh]"
|
|
190
|
+
),
|
|
146
191
|
onMouseDown: (e) => {
|
|
147
192
|
if (e.target === e.currentTarget) onClose();
|
|
148
193
|
},
|
|
@@ -155,9 +200,19 @@ function CommandPalette({
|
|
|
155
200
|
"aria-label": dialogName,
|
|
156
201
|
tabIndex: -1,
|
|
157
202
|
onKeyDown: onDialogKeyDown,
|
|
158
|
-
|
|
203
|
+
"data-fullscreen": isPhone || void 0,
|
|
204
|
+
className: cn(
|
|
205
|
+
"flex w-full flex-col overflow-hidden bg-[var(--bg-surface)] outline-none",
|
|
206
|
+
isPhone ? "h-full" : "max-h-[70vh] max-w-xl rounded-xl border border-[var(--border)] shadow-2xl"
|
|
207
|
+
),
|
|
208
|
+
style: isPhone ? {
|
|
209
|
+
paddingTop: "max(0px, env(safe-area-inset-top))",
|
|
210
|
+
paddingBottom: "max(0px, env(safe-area-inset-bottom))",
|
|
211
|
+
paddingLeft: "max(0px, env(safe-area-inset-left))",
|
|
212
|
+
paddingRight: "max(0px, env(safe-area-inset-right))"
|
|
213
|
+
} : void 0,
|
|
159
214
|
children: [
|
|
160
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-[var(--border)] px-3", children: [
|
|
215
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b border-[var(--border)] px-3", children: [
|
|
161
216
|
/* @__PURE__ */ jsx(Search, { className: "size-4 shrink-0 text-[var(--text-placeholder)]" }),
|
|
162
217
|
/* @__PURE__ */ jsx(
|
|
163
218
|
"input",
|
|
@@ -167,17 +222,57 @@ function CommandPalette({
|
|
|
167
222
|
"aria-expanded": true,
|
|
168
223
|
"aria-controls": listId,
|
|
169
224
|
"aria-activedescendant": flat[active] ? itemId(flat[active].id) : void 0,
|
|
170
|
-
value:
|
|
171
|
-
onChange: (e) => setQuery(e.target.value),
|
|
225
|
+
value: fieldText,
|
|
226
|
+
onChange: (e) => submitMode ? setDraft(e.target.value) : setQuery(e.target.value),
|
|
172
227
|
onKeyDown,
|
|
173
228
|
placeholder: l.placeholder,
|
|
174
|
-
|
|
229
|
+
enterKeyHint: submitMode ? "search" : void 0,
|
|
230
|
+
className: cn(
|
|
231
|
+
"w-full bg-transparent py-3 outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)]",
|
|
232
|
+
// 16px on a phone, or iOS zooms the page in on focus.
|
|
233
|
+
isPhone ? "text-base" : "text-sm"
|
|
234
|
+
)
|
|
175
235
|
}
|
|
176
236
|
),
|
|
177
|
-
loading && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-[var(--text-placeholder)]", children: l.loading })
|
|
237
|
+
loading && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-[var(--text-placeholder)]", children: l.loading }),
|
|
238
|
+
fieldText !== "" && /* @__PURE__ */ jsx(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
type: "button",
|
|
242
|
+
"aria-label": l.clear ?? DEFAULT_COMMAND_PALETTE_LABELS.clear,
|
|
243
|
+
onClick: () => {
|
|
244
|
+
commit("");
|
|
245
|
+
inputRef.current?.focus();
|
|
246
|
+
},
|
|
247
|
+
className: "shrink-0 rounded p-1 text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]",
|
|
248
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-4" })
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
dirty && /* @__PURE__ */ jsx(
|
|
252
|
+
"button",
|
|
253
|
+
{
|
|
254
|
+
type: "button",
|
|
255
|
+
"aria-label": l.submit ?? DEFAULT_COMMAND_PALETTE_LABELS.submit,
|
|
256
|
+
onClick: () => {
|
|
257
|
+
commit(draft);
|
|
258
|
+
inputRef.current?.focus();
|
|
259
|
+
},
|
|
260
|
+
className: "shrink-0 rounded p-1 text-[var(--text-secondary)] hover:text-[var(--text-primary)]",
|
|
261
|
+
children: /* @__PURE__ */ jsx(CornerDownLeft, { className: "size-4" })
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
isPhone && /* @__PURE__ */ jsx(
|
|
265
|
+
"button",
|
|
266
|
+
{
|
|
267
|
+
type: "button",
|
|
268
|
+
onClick: onClose,
|
|
269
|
+
className: "-me-1 shrink-0 rounded px-1 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]",
|
|
270
|
+
children: l.close ?? DEFAULT_COMMAND_PALETTE_LABELS.close
|
|
271
|
+
}
|
|
272
|
+
)
|
|
178
273
|
] }),
|
|
179
274
|
failed && !loading && /* @__PURE__ */ jsx("div", { role: "alert", className: "px-3 py-6 text-center text-sm text-[var(--text-muted)]", children: l.error ?? DEFAULT_COMMAND_PALETTE_LABELS.error }),
|
|
180
|
-
!failed &&
|
|
275
|
+
!failed && results.length === 0 && !loading && /* @__PURE__ */ jsx("div", { className: "px-3 py-6 text-center text-sm text-[var(--text-muted)]", children: l.empty }),
|
|
181
276
|
/* @__PURE__ */ jsx("ul", { id: listId, ref: listRef, role: "listbox", "aria-label": dialogName, className: "min-h-0 flex-1 overflow-y-auto py-1", children: groups.map(({ group, items }, groupIndex) => /* @__PURE__ */ jsxs("li", { role: "presentation", children: [
|
|
182
277
|
/* @__PURE__ */ jsx(
|
|
183
278
|
"div",
|
|
@@ -189,9 +284,27 @@ function CommandPalette({
|
|
|
189
284
|
}
|
|
190
285
|
),
|
|
191
286
|
/* @__PURE__ */ jsx("ul", { role: "group", "aria-labelledby": groupId(groupIndex), children: items.map((item) => {
|
|
287
|
+
if (item.kind === "status") {
|
|
288
|
+
return /* @__PURE__ */ jsxs(
|
|
289
|
+
"li",
|
|
290
|
+
{
|
|
291
|
+
role: "presentation",
|
|
292
|
+
className: cn(
|
|
293
|
+
"flex items-center gap-2.5 px-3 text-xs text-[var(--text-placeholder)]",
|
|
294
|
+
comfortable ? "min-h-11 py-2.5" : "py-2"
|
|
295
|
+
),
|
|
296
|
+
children: [
|
|
297
|
+
item.icon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center", children: item.icon }),
|
|
298
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label })
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
item.id
|
|
302
|
+
);
|
|
303
|
+
}
|
|
192
304
|
flatIndex += 1;
|
|
193
305
|
const idx = flatIndex;
|
|
194
306
|
const isActive = idx === active;
|
|
307
|
+
const redact = item.redact ?? redactLabels;
|
|
195
308
|
const shared = {
|
|
196
309
|
id: itemId(item.id),
|
|
197
310
|
role: "option",
|
|
@@ -199,14 +312,15 @@ function CommandPalette({
|
|
|
199
312
|
"data-index": idx,
|
|
200
313
|
onMouseMove: () => setActive(idx),
|
|
201
314
|
className: cn(
|
|
202
|
-
"flex w-full items-center gap-2.5 px-3
|
|
315
|
+
"flex w-full items-center gap-2.5 px-3 text-start",
|
|
316
|
+
comfortable ? "min-h-11 py-2.5 text-base" : "py-2 text-sm",
|
|
203
317
|
isActive ? "bg-[var(--bg-active)] text-[var(--text-primary)]" : "text-[var(--text-secondary)]"
|
|
204
318
|
)
|
|
205
319
|
};
|
|
206
320
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
207
321
|
item.icon && /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-[var(--text-placeholder)]", children: item.icon }),
|
|
208
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
209
|
-
item.hint && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-[var(--text-placeholder)]", children: item.hint })
|
|
322
|
+
/* @__PURE__ */ jsx("span", { "data-private": redact || void 0, className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
323
|
+
item.hint && /* @__PURE__ */ jsx("span", { "data-private": redact || void 0, className: "shrink-0 text-xs text-[var(--text-placeholder)]", children: item.hint })
|
|
210
324
|
] });
|
|
211
325
|
return /* @__PURE__ */ jsx("li", { role: "presentation", children: item.href ? /* @__PURE__ */ jsx(
|
|
212
326
|
"a",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/search/command-palette.tsx"],"sourcesContent":["import { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useBodyScrollLock } from \"../hooks/use-body-scroll-lock\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\nexport interface CommandItem {\n id: string;\n /** Primary text. */\n label: string;\n /** Secondary text on the right (e.g. an amount, a date, a group hint). */\n hint?: string;\n /** Heading this item is grouped under. */\n group: string;\n /** Leading icon / element. */\n icon?: ReactNode;\n /** Invoked when the item is chosen (navigate, run an action, …). */\n onSelect: () => void;\n /** Where this item leads, when it is a navigation rather than an action. Renders\n * the row as a real anchor so it can be middle-/⌘-clicked into a new tab\n * (Keksdose feedback #451); `onSelect` still runs for a plain click and for ↵, so\n * in-app navigation stays client-side. `href` only adds what the browser can do\n * with a link and JavaScript cannot fake — the rejected alternative, an\n * `onAuxClick` calling `window.open`, gets the middle click and nothing else. */\n href?: string;\n}\n\nexport interface CommandPaletteLabels {\n placeholder: string;\n empty: string;\n loading: string;\n /** Hint shown in the footer, e.g. \"↑↓ to navigate · ↵ to select · esc to close\". */\n hint?: string;\n /**\n * Accessible name of the dialog itself. It used to borrow `placeholder`, which is\n * written to sit greyed-out in an empty box (\"Search…\", \"Type a command\"), not to\n * name a window — and a reader heard the ellipsis read out as part of the name.\n *\n * Optional, unlike `placeholder`, so a translation annotated as\n * `CommandPaletteLabels` keeps compiling; the default always carries it.\n */\n dialog?: string;\n /**\n * Shown in place of the results when the `search` provider throws or its promise\n * rejects. Optional for the same reason as `dialog`; the default always carries it.\n */\n error?: string;\n}\n\nexport const DEFAULT_COMMAND_PALETTE_LABELS: CommandPaletteLabels = {\n placeholder: \"Search…\",\n empty: \"No results\",\n loading: \"Searching…\",\n dialog: \"Search\",\n error: \"Search failed. Try again.\",\n};\n\n/** The defaults minus `dialog`, so a resolved `dialog` means someone SUPPLIED one —\n * see the dialog's `aria-label` for why that distinction matters. */\nconst { dialog: DEFAULT_DIALOG_NAME, ...DEFAULTS_WITHOUT_DIALOG } = DEFAULT_COMMAND_PALETTE_LABELS;\n\ninterface CommandPaletteProps {\n open: boolean;\n onClose: () => void;\n /**\n * Returns results for a query (called debounced as the user types; an empty\n * query is allowed — return defaults like pages/recent). Sync or async; stale\n * async responses are ignored.\n *\n * Its IDENTITY is not a re-run signal — it is read through a ref, so the palette\n * never re-searches merely because the caller rebuilt the callback. That is\n * deliberate: a provider closing over a list rendered from a query allocates a new\n * function on most renders, and re-running the search on each would make typing\n * stutter. Use {@link CommandPaletteProps.revision} when the DATA behind the\n * provider changes.\n */\n search: (query: string) => CommandItem[] | Promise<CommandItem[]>;\n /**\n * Anything whose change means the current results are out of date — typically the\n * arrays the provider searches over. Compared by identity (as an effect dependency\n * would be), so pass stable references: a `data = []` default allocates a fresh\n * array on every render while a query is pending and would re-search forever.\n *\n * Without it, a provider whose data arrives AFTER the palette opened never gets\n * asked again: the user's last keystroke settles the debounce, the queries resolve a\n * moment later, and the groups they would have contributed are simply absent until\n * another keystroke. That is the ordinary first open on a cold cache.\n */\n revision?: unknown;\n /**\n * The search text, CONTROLLED. Keksdose binds it to the URL's `q`, so a search\n * survives a reload, can be shared as a link, and Back walks through it — none of\n * which state inside the palette can do.\n *\n * Leave it out and the palette keeps its own, as before, starting empty on every\n * open. Given, it is never reset on open: the owner decides what an open shows, and\n * a palette that blanked the URL's `q` each time would fight its own address bar.\n * `onQueryChange` is then how a keystroke gets anywhere, since it is the only writer.\n */\n query?: string;\n /** Every edit of the field's text. Fires in both modes — uncontrolled, it only\n * observes. */\n onQueryChange?: (query: string) => void;\n labels?: Partial<CommandPaletteLabels>;\n}\n\n/** Registers a global ⌘K / Ctrl-K shortcut that calls `onOpen`. */\nexport function useCommandKey(onOpen: () => void): void {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && (e.key === \"k\" || e.key === \"K\")) {\n e.preventDefault();\n onOpen();\n }\n };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [onOpen]);\n}\n\n/**\n * A ⌘K-style command palette: a top-centred modal with a search field and a\n * grouped, keyboard-navigable result list. Domain-free — the app supplies\n * results via the `search` provider (pages, actions, records, …); each result\n * carries its own `onSelect`.\n */\nexport function CommandPalette({\n open,\n onClose,\n search,\n revision,\n query: queryProp,\n onQueryChange,\n labels,\n}: CommandPaletteProps) {\n const l = useKitLabels(\"commandPalette\", DEFAULTS_WITHOUT_DIALOG, labels);\n // `dialog` is new, and until it existed the dialog was named by `placeholder`. An\n // app that translated `placeholder` and has not heard of `dialog` would otherwise\n // go from a German name to an English \"Search\" on update — so a translated\n // placeholder keeps doing the job until a `dialog` is supplied.\n const dialogName =\n l.dialog ??\n (l.placeholder !== DEFAULT_COMMAND_PALETTE_LABELS.placeholder ? l.placeholder : DEFAULT_DIALOG_NAME);\n const [ownQuery, setOwnQuery] = useState(\"\");\n const controlled = queryProp !== undefined;\n const query = controlled ? queryProp : ownQuery;\n const setQuery = (next: string) => {\n if (!controlled) setOwnQuery(next);\n onQueryChange?.(next);\n };\n const [results, setResults] = useState<CommandItem[]>([]);\n const [loading, setLoading] = useState(false);\n const [failed, setFailed] = useState(false);\n const [active, setActive] = useState(0);\n // Per instance: these were the literal \"command-palette-list\" / \"command-item-<id>\",\n // so two palettes on one page (an app-wide one and a scoped one) pointed each\n // other's `aria-controls` and `aria-activedescendant` at the wrong list.\n const uid = useId();\n const listId = `${uid}-list`;\n const itemId = (id: string) => `${uid}-item-${id}`;\n const groupId = (index: number) => `${uid}-group-${index}`;\n const dialogRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLUListElement>(null);\n const searchRef = useRef(search);\n searchRef.current = search;\n const reqId = useRef(0);\n\n // Back dismisses the palette (Keksdose feedback #172). Declared with the other\n // hooks, above the `if (!open) return null` below — a hook past a conditional\n // return changes the hook order between renders. Passing `open` rather than\n // mounting-while-open is what lets it sit here.\n useOverlayHistory(open, onClose);\n\n // A modal like any other: Tab stays inside, the page behind does not scroll, and\n // focus goes back to whatever opened it — the palette used to drop it on <body>.\n // Initial focus is the field, not the container: typing is the only reason to open it.\n useFocusTrap(dialogRef, { active: open, initialFocus: () => inputRef.current });\n useBodyScrollLock(open);\n\n // Reset when opened — the palette's OWN text only; a controlled query belongs to\n // its owner (see the prop).\n useEffect(() => {\n if (!open) return;\n if (!controlled) setOwnQuery(\"\");\n setActive(0);\n // `controlled` is read at the open, not watched: a caller switching modes while\n // the palette is open is not a reason to wipe what is typed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n // Debounced, race-safe search.\n useEffect(() => {\n if (!open) return;\n const id = ++reqId.current;\n setLoading(true);\n const run = async () => {\n try {\n const r = await Promise.resolve(searchRef.current(query));\n if (reqId.current === id) {\n setResults(r);\n setFailed(false);\n setActive(0);\n }\n } catch (err) {\n // There was no catch: the previous query's results stayed on screen as if they\n // answered this one, and the rejection went unhandled. Clear them and say so.\n if (reqId.current === id) {\n setResults([]);\n setFailed(true);\n setActive(0);\n }\n console.error(\"CommandPalette: search failed\", err);\n } finally {\n if (reqId.current === id) setLoading(false);\n }\n };\n const t = setTimeout(run, query ? 150 : 0);\n return () => clearTimeout(t);\n // `revision`, not `search`: see the prop's docstring. The debounce is re-armed on a\n // revision change, which is right — data arriving is not a keystroke and there is\n // nothing to feel laggy about.\n }, [query, open, revision]);\n\n // Group results, preserving first-seen group order; keep a flat list for nav.\n const { groups, flat } = useMemo(() => {\n const order: string[] = [];\n const byGroup = new Map<string, CommandItem[]>();\n for (const item of results) {\n if (!byGroup.has(item.group)) {\n byGroup.set(item.group, []);\n order.push(item.group);\n }\n byGroup.get(item.group)!.push(item);\n }\n return {\n groups: order.map((g) => ({ group: g, items: byGroup.get(g)! })),\n flat: order.flatMap((g) => byGroup.get(g)!),\n };\n }, [results]);\n\n const choose = (item: CommandItem | undefined) => {\n if (!item) return;\n onClose();\n item.onSelect();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive((i) => Math.min(i + 1, flat.length - 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive((i) => Math.max(i - 1, 0));\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n choose(flat[active]);\n }\n };\n\n // Escape on the whole dialog, not only the field: once Tab has moved focus to a row\n // (or a footer control), Escape used to do nothing at all.\n const onDialogKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n }\n };\n\n // Keep the active row scrolled into view.\n useEffect(() => {\n const el = listRef.current?.querySelector<HTMLElement>(`[data-index=\"${active}\"]`);\n el?.scrollIntoView({ block: \"nearest\" });\n }, [active]);\n\n if (!open) return null;\n\n let flatIndex = -1;\n return createPortal(\n <div\n className=\"fixed inset-0 z-[70] flex items-start justify-center bg-black/40 p-4 pt-[10vh]\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) onClose();\n }}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Escape from anywhere in the dialog */}\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={dialogName}\n // The trap's fallback target when the field is not there to take focus.\n tabIndex={-1}\n // Escape bubbling up from anything inside — a dialog is where it belongs.\n onKeyDown={onDialogKeyDown}\n className=\"flex max-h-[70vh] w-full max-w-xl flex-col overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg-surface)] shadow-2xl outline-none\"\n >\n <div className=\"flex items-center gap-2 border-b border-[var(--border)] px-3\">\n <Search className=\"size-4 shrink-0 text-[var(--text-placeholder)]\" />\n <input\n ref={inputRef}\n role=\"combobox\"\n aria-expanded\n aria-controls={listId}\n aria-activedescendant={flat[active] ? itemId(flat[active].id) : undefined}\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n onKeyDown={onKeyDown}\n placeholder={l.placeholder}\n className=\"w-full bg-transparent py-3 text-sm outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)]\"\n />\n {loading && <span className=\"shrink-0 text-[11px] text-[var(--text-placeholder)]\">{l.loading}</span>}\n </div>\n\n {/* The status lines sit outside the listbox: a listbox owns options and groups,\n and \"No results\" is neither. */}\n {failed && !loading && (\n <div role=\"alert\" className=\"px-3 py-6 text-center text-sm text-[var(--text-muted)]\">\n {l.error ?? DEFAULT_COMMAND_PALETTE_LABELS.error}\n </div>\n )}\n {!failed && flat.length === 0 && !loading && (\n <div className=\"px-3 py-6 text-center text-sm text-[var(--text-muted)]\">{l.empty}</div>\n )}\n {/* Listbox grouping: each group is a `role=\"group\"` named by its heading, and\n the list markup in between is presentational so the listbox's children are\n groups and options only — as a plain <li>/<ul> tree a reader announced\n \"list, 2 items\" between options and never tied the heading to its rows. */}\n <ul id={listId} ref={listRef} role=\"listbox\" aria-label={dialogName} className=\"min-h-0 flex-1 overflow-y-auto py-1\">\n {groups.map(({ group, items }, groupIndex) => (\n <li key={group} role=\"presentation\">\n <div\n id={groupId(groupIndex)}\n role=\"presentation\"\n className=\"px-3 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-placeholder)]\"\n >\n {group}\n </div>\n <ul role=\"group\" aria-labelledby={groupId(groupIndex)}>\n {items.map((item) => {\n flatIndex += 1;\n const idx = flatIndex;\n const isActive = idx === active;\n // Written once and worn by either tag below, so the anchor and the\n // button can never drift apart in looks or in listbox semantics.\n // `role=\"option\"` on an <a href> is fine: the browser's middle-click\n // behaviour keys off the element, not the ARIA role.\n const shared = {\n id: itemId(item.id),\n role: \"option\" as const,\n \"aria-selected\": isActive,\n \"data-index\": idx,\n onMouseMove: () => setActive(idx),\n className: cn(\n \"flex w-full items-center gap-2.5 px-3 py-2 text-start text-sm\",\n isActive\n ? \"bg-[var(--bg-active)] text-[var(--text-primary)]\"\n : \"text-[var(--text-secondary)]\",\n ),\n };\n const inner = (\n <>\n {item.icon && (\n <span className=\"flex size-4 shrink-0 items-center justify-center text-[var(--text-placeholder)]\">\n {item.icon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate\">{item.label}</span>\n {item.hint && (\n <span className=\"shrink-0 text-xs text-[var(--text-placeholder)]\">{item.hint}</span>\n )}\n </>\n );\n return (\n <li key={item.id} role=\"presentation\">\n {item.href ? (\n <a\n {...shared}\n href={item.href}\n draggable={false}\n onClick={(e) => {\n // A modified click belongs to the browser (feedback\n // #451) — and the palette deliberately stays OPEN for\n // it: ⌘-clicking three results in a row is the reason to\n // want this, and closing after the first would undo it.\n if (\n e.button !== 0 ||\n e.metaKey ||\n e.ctrlKey ||\n e.shiftKey ||\n e.altKey\n )\n return;\n e.preventDefault();\n choose(item);\n }}\n >\n {inner}\n </a>\n ) : (\n <button type=\"button\" {...shared} onClick={() => choose(item)}>\n {inner}\n </button>\n )}\n </li>\n );\n })}\n </ul>\n </li>\n ))}\n </ul>\n\n {l.hint && (\n <div className=\"border-t border-[var(--border)] px-3 py-1.5 text-[11px] text-[var(--text-placeholder)]\">\n {l.hint}\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AA6SQ,SAgEY,UA/DV,KADF;AA7SR,SAAS,WAAW,OAAO,SAAS,QAAQ,gBAAgB;AAE5D,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AA6CtB,MAAM,iCAAuD;AAAA,EAClE,aAAa;AAAA,EACb,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AACT;AAIA,MAAM,EAAE,QAAQ,qBAAqB,GAAG,wBAAwB,IAAI;AAgD7D,SAAS,cAAc,QAA0B;AACtD,YAAU,MAAM;AACd,UAAM,UAAU,CAAC,MAAqB;AACpC,WAAK,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,OAAO,EAAE,QAAQ,MAAM;AAChE,UAAE,eAAe;AACjB,eAAO;AAAA,MACT;AAAA,IACF;AACA,aAAS,iBAAiB,WAAW,OAAO;AAC5C,WAAO,MAAM,SAAS,oBAAoB,WAAW,OAAO;AAAA,EAC9D,GAAG,CAAC,MAAM,CAAC;AACb;AAQO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAA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K,OAAM;AAAA,oBACrD,KAAK,QACJ,oBAAC,UAAK,WAAU,mDAAmD,eAAK,MAAK;AAAA,qBAEjF;AAEF,yBACE,oBAAC,QAAiB,MAAK,gBACpB,eAAK,OACJ;AAAA,oBAAC;AAAA;AAAA,sBACE,GAAG;AAAA,sBACJ,MAAM,KAAK;AAAA,sBACX,WAAW;AAAA,sBACX,SAAS,CAAC,MAAM;AAKd,4BACE,EAAE,WAAW,KACb,EAAE,WACF,EAAE,WACF,EAAE,YACF,EAAE;AAEF;AACF,0BAAE,eAAe;AACjB,+BAAO,IAAI;AAAA,sBACb;AAAA,sBAEC;AAAA;AAAA,kBACH,IAEA,oBAAC,YAAO,MAAK,UAAU,GAAG,QAAQ,SAAS,MAAM,OAAO,IAAI,GACzD,iBACH,KA5BK,KAAK,EA8Bd;AAAA,gBAEJ,CAAC,GACH;AAAA,mBA7EO,KA8ET,CACD,GACH;AAAA,cAEC,EAAE,QACD,oBAAC,SAAI,WAAU,0FACZ,YAAE,MACL;AAAA;AAAA;AAAA,QAEJ;AAAA;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/search/command-palette.tsx"],"sourcesContent":["import { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { CornerDownLeft, Search, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { PHONE_QUERY } from \"../components/ui\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { useFocusTrap } from \"../hooks/use-focus-trap\";\nimport { useBodyScrollLock } from \"../hooks/use-body-scroll-lock\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\nexport interface CommandItem {\n id: string;\n /** Primary text. */\n label: string;\n /** Secondary text on the right (e.g. an amount, a date, a group hint). */\n hint?: string;\n /** Heading this item is grouped under. */\n group: string;\n /** Leading icon / element. */\n icon?: ReactNode;\n /** Invoked when the item is chosen (navigate, run an action, …). */\n onSelect: () => void;\n /** Where this item leads, when it is a navigation rather than an action. Renders\n * the row as a real anchor so it can be middle-/⌘-clicked into a new tab\n * (Keksdose feedback #451); `onSelect` still runs for a plain click and for ↵, so\n * in-app navigation stays client-side. `href` only adds what the browser can do\n * with a link and JavaScript cannot fake — the rejected alternative, an\n * `onAuxClick` calling `window.open`, gets the middle click and nothing else. */\n href?: string;\n /** Marks this row's label and hint `data-private`, so session replay and screenshot\n * tooling masks them — a payee, an account name, an amount. Overrides the palette's\n * {@link CommandPaletteProps.redactLabels} either way, so `false` un-masks one\n * harmless row (\"Settings\") in a palette that masks by default. */\n redact?: boolean;\n /**\n * `\"status\"` makes the row a line of text rather than a choice — a group's\n * \"Searching…\" while its source is still out, or its error. It is skipped by the\n * arrow keys and ↵, has no hover highlight, and its `onSelect` is never called.\n * Default `\"option\"`.\n */\n kind?: \"option\" | \"status\";\n}\n\n/** Group items preserving first-seen group order; `flat` is the navigable rows only. */\nfunction groupItems(items: CommandItem[]) {\n const order: string[] = [];\n const byGroup = new Map<string, CommandItem[]>();\n for (const item of items) {\n if (!byGroup.has(item.group)) {\n byGroup.set(item.group, []);\n order.push(item.group);\n }\n byGroup.get(item.group)!.push(item);\n }\n return {\n groups: order.map((g) => ({ group: g, items: byGroup.get(g)! })),\n flat: order.flatMap((g) => byGroup.get(g)!).filter((item) => item.kind !== \"status\"),\n };\n}\n\nexport interface CommandPaletteLabels {\n placeholder: string;\n empty: string;\n loading: string;\n /** Hint shown in the footer, e.g. \"↑↓ to navigate · ↵ to select · esc to close\". */\n hint?: string;\n /**\n * Accessible name of the dialog itself. It used to borrow `placeholder`, which is\n * written to sit greyed-out in an empty box (\"Search…\", \"Type a command\"), not to\n * name a window — and a reader heard the ellipsis read out as part of the name.\n *\n * Optional, unlike `placeholder`, so a translation annotated as\n * `CommandPaletteLabels` keeps compiling; the default always carries it.\n */\n dialog?: string;\n /**\n * Shown in place of the results when the `search` provider throws or its promise\n * rejects. Optional for the same reason as `dialog`; the default always carries it.\n */\n error?: string;\n /** Names the \"×\" that empties the field. Optional like `dialog`. */\n clear?: string;\n /** Names the button that commits the typed text when `searchOn=\"submit\"`. */\n submit?: string;\n /** Names the close button of the full-screen phone presentation, which has no\n * backdrop to tap and, on a phone, no Escape key. */\n close?: string;\n}\n\nexport const DEFAULT_COMMAND_PALETTE_LABELS: CommandPaletteLabels = {\n placeholder: \"Search…\",\n empty: \"No results\",\n loading: \"Searching…\",\n dialog: \"Search\",\n error: \"Search failed. Try again.\",\n clear: \"Clear search\",\n submit: \"Search\",\n close: \"Close\",\n};\n\n/**\n * How tall the palette's rows are. `\"compact\"` (the default) is the desktop list the\n * palette always drew, 36px a row; `\"comfortable\"` gives every row the kit's 44px touch\n * target (`min-h-11`) and body-size text — keksdose's phone search, where a 36px row\n * under a thumb picks its neighbour.\n */\nexport type CommandPaletteDensity = \"compact\" | \"comfortable\";\n\n/** A provider's answer is a promise — the only case with anything to wait for. */\nconst isThenable = (value: unknown): value is PromiseLike<unknown> =>\n typeof (value as PromiseLike<unknown> | null)?.then === \"function\";\n\n/** The defaults minus `dialog`, so a resolved `dialog` means someone SUPPLIED one —\n * see the dialog's `aria-label` for why that distinction matters. */\nconst { dialog: DEFAULT_DIALOG_NAME, ...DEFAULTS_WITHOUT_DIALOG } = DEFAULT_COMMAND_PALETTE_LABELS;\n\ninterface CommandPaletteProps {\n open: boolean;\n onClose: () => void;\n /**\n * Returns results for a query (called debounced as the user types; an empty\n * query is allowed — return defaults like pages/recent). Sync or async; stale\n * async responses are ignored.\n *\n * A SYNCHRONOUS provider (one returning an array, not a promise) never shows the\n * \"Searching…\" hint: its answer is there the moment it is asked, and the hint only\n * flashed through the debounce before results that were never late — keksdose's\n * transaction search filters a list already in memory. The palette tells the two\n * apart by what the provider RETURNS, call by call, so there is no prop to keep in\n * step with the implementation: an async provider shows the hint from the first\n * promise on (and during the debounce of every later query), a sync one never.\n *\n * Its IDENTITY is not a re-run signal — it is read through a ref, so the palette\n * never re-searches merely because the caller rebuilt the callback. That is\n * deliberate: a provider closing over a list rendered from a query allocates a new\n * function on most renders, and re-running the search on each would make typing\n * stutter. Use {@link CommandPaletteProps.revision} when the DATA behind the\n * provider changes.\n */\n search: (query: string) => CommandItem[] | Promise<CommandItem[]>;\n /**\n * Anything whose change means the current results are out of date — typically the\n * arrays the provider searches over. Compared by identity (as an effect dependency\n * would be), so pass stable references: a `data = []` default allocates a fresh\n * array on every render while a query is pending and would re-search forever.\n *\n * Without it, a provider whose data arrives AFTER the palette opened never gets\n * asked again: the user's last keystroke settles the debounce, the queries resolve a\n * moment later, and the groups they would have contributed are simply absent until\n * another keystroke. That is the ordinary first open on a cold cache.\n */\n revision?: unknown;\n /**\n * The search text, CONTROLLED. Keksdose binds it to the URL's `q`, so a search\n * survives a reload, can be shared as a link, and Back walks through it — none of\n * which state inside the palette can do.\n *\n * Leave it out and the palette keeps its own, as before, starting empty on every\n * open. Given, it is never reset on open: the owner decides what an open shows, and\n * a palette that blanked the URL's `q` each time would fight its own address bar.\n * `onQueryChange` is then how a keystroke gets anywhere, since it is the only writer.\n */\n query?: string;\n /** Every edit of the field's text. Fires in both modes — uncontrolled, it only\n * observes. */\n onQueryChange?: (query: string) => void;\n /**\n * When the typed text becomes THE query — the one `search` runs on and\n * `onQueryChange` reports.\n *\n * - `\"input\"` (default): every keystroke, debounced for the search, as before.\n * - `\"submit\"`: typing edits a draft; the query is committed by ↵ or the submit\n * button beside the field. Until then the results stay on the last committed query\n * and `onQueryChange` stays quiet — which is what an owner binding `query` to the\n * URL's `q` needs, or every keystroke re-filters the page behind and pushes history.\n * ↵ with a draft that differs from the committed query COMMITS; ↵ with nothing new\n * typed chooses the highlighted row, as in `\"input\"` mode. The draft follows any\n * outside change of the committed query (Back through the URL), and an uncommitted\n * draft is dropped when the palette is closed.\n *\n * The clear \"×\" commits the empty query in both modes: an emptied box over results\n * (or a page) still filtered by the old text is the stuck state Keksdose #423 was.\n */\n searchOn?: \"input\" | \"submit\";\n /** Mark every row's label and hint `data-private` (see {@link CommandItem.redact},\n * which overrides it per row). Off by default. */\n redactLabels?: boolean;\n /**\n * Below the phone breakpoint ({@link PHONE_QUERY}) the palette fills the screen:\n * no inset, no rounded panel, the field pinned at the top inside the safe areas and\n * the list scrolling under it, with a close button since there is no backdrop to tap.\n * On by default — a top-centred card at 70vh leaves little room once the keyboard is\n * up. `false` keeps the card on every viewport.\n */\n fullScreenOnPhone?: boolean;\n /** Row height — see {@link CommandPaletteDensity}. Default `\"compact\"`. */\n density?: CommandPaletteDensity;\n labels?: Partial<CommandPaletteLabels>;\n}\n\n/** Registers a global ⌘K / Ctrl-K shortcut that calls `onOpen`. */\nexport function useCommandKey(onOpen: () => void): void {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && (e.key === \"k\" || e.key === \"K\")) {\n e.preventDefault();\n onOpen();\n }\n };\n document.addEventListener(\"keydown\", handler);\n return () => document.removeEventListener(\"keydown\", handler);\n }, [onOpen]);\n}\n\n/**\n * A ⌘K-style command palette: a top-centred modal with a search field and a\n * grouped, keyboard-navigable result list. Domain-free — the app supplies\n * results via the `search` provider (pages, actions, records, …); each result\n * carries its own `onSelect`.\n */\nexport function CommandPalette({\n open,\n onClose,\n search,\n revision,\n query: queryProp,\n onQueryChange,\n searchOn = \"input\",\n redactLabels = false,\n fullScreenOnPhone = true,\n density = \"compact\",\n labels,\n}: CommandPaletteProps) {\n const l = useKitLabels(\"commandPalette\", DEFAULTS_WITHOUT_DIALOG, labels);\n // `dialog` is new, and until it existed the dialog was named by `placeholder`. An\n // app that translated `placeholder` and has not heard of `dialog` would otherwise\n // go from a German name to an English \"Search\" on update — so a translated\n // placeholder keeps doing the job until a `dialog` is supplied.\n const dialogName =\n l.dialog ??\n (l.placeholder !== DEFAULT_COMMAND_PALETTE_LABELS.placeholder ? l.placeholder : DEFAULT_DIALOG_NAME);\n const [ownQuery, setOwnQuery] = useState(\"\");\n const controlled = queryProp !== undefined;\n const query = controlled ? queryProp : ownQuery;\n const setQuery = (next: string) => {\n if (!controlled) setOwnQuery(next);\n onQueryChange?.(next);\n };\n const submitMode = searchOn === \"submit\";\n // The field's text in `\"submit\"` mode. It follows the committed query whenever that\n // changes — adjusted during render, React's pattern for state derived from a prop,\n // rather than in an effect that would paint the stale draft first.\n const [draft, setDraft] = useState(query);\n const [draftBase, setDraftBase] = useState(query);\n if (draftBase !== query) {\n setDraftBase(query);\n setDraft(query);\n }\n const fieldText = submitMode ? draft : query;\n const commit = (next: string) => {\n setDraft(next);\n setQuery(next);\n };\n const dirty = submitMode && draft !== query;\n const isPhone = useMediaQuery(PHONE_QUERY, false) && fullScreenOnPhone;\n const [results, setResults] = useState<CommandItem[]>([]);\n const [loading, setLoading] = useState(false);\n const [failed, setFailed] = useState(false);\n const [active, setActive] = useState(0);\n // Per instance: these were the literal \"command-palette-list\" / \"command-item-<id>\",\n // so two palettes on one page (an app-wide one and a scoped one) pointed each\n // other's `aria-controls` and `aria-activedescendant` at the wrong list.\n const uid = useId();\n const listId = `${uid}-list`;\n const itemId = (id: string) => `${uid}-item-${id}`;\n const groupId = (index: number) => `${uid}-group-${index}`;\n const dialogRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLUListElement>(null);\n const searchRef = useRef(search);\n searchRef.current = search;\n const reqId = useRef(0);\n /** What the provider's last answer was: a promise (`false`), an array (`true`), or\n * not known yet. Only a provider known to be async shows \"Searching…\" while the\n * debounce runs — see `search`. */\n const syncRef = useRef<boolean | undefined>(undefined);\n /** The query the results on screen answer, and the row highlighted in them — so a\n * re-run for the SAME query (a `revision` change: a source streaming in) keeps the\n * highlight on its row instead of throwing it back to the top mid-arrow. */\n const shownQuery = useRef<string | null>(null);\n const activeIdRef = useRef<string | undefined>(undefined);\n\n // Back dismisses the palette (Keksdose feedback #172). Declared with the other\n // hooks, above the `if (!open) return null` below — a hook past a conditional\n // return changes the hook order between renders. Passing `open` rather than\n // mounting-while-open is what lets it sit here.\n useOverlayHistory(open, onClose);\n\n // A modal like any other: Tab stays inside, the page behind does not scroll, and\n // focus goes back to whatever opened it — the palette used to drop it on <body>.\n // Initial focus is the field, not the container: typing is the only reason to open it.\n useFocusTrap(dialogRef, { active: open, initialFocus: () => inputRef.current });\n useBodyScrollLock(open);\n\n // Reset when opened — the palette's OWN text only; a controlled query belongs to\n // its owner (see the prop).\n useEffect(() => {\n if (!open) return;\n if (!controlled) setOwnQuery(\"\");\n // An uncommitted draft does not outlive the open it was typed in.\n setDraft(controlled ? query : \"\");\n setActive(0);\n shownQuery.current = null;\n // `controlled` is read at the open, not watched: a caller switching modes while\n // the palette is open is not a reason to wipe what is typed.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n // Debounced, race-safe search.\n useEffect(() => {\n if (!open) return;\n const id = ++reqId.current;\n if (syncRef.current === false) setLoading(true);\n const run = async () => {\n try {\n const answer = searchRef.current(query);\n syncRef.current = !isThenable(answer);\n if (!syncRef.current) setLoading(true);\n const r = await answer;\n if (reqId.current === id) {\n const keep = shownQuery.current === query ? activeIdRef.current : undefined;\n const at = keep === undefined ? -1 : groupItems(r).flat.findIndex((item) => item.id === keep);\n shownQuery.current = query;\n setResults(r);\n setFailed(false);\n setActive(Math.max(at, 0));\n }\n } catch (err) {\n // There was no catch: the previous query's results stayed on screen as if they\n // answered this one, and the rejection went unhandled. Clear them and say so.\n if (reqId.current === id) {\n shownQuery.current = null;\n setResults([]);\n setFailed(true);\n setActive(0);\n }\n console.error(\"CommandPalette: search failed\", err);\n } finally {\n if (reqId.current === id) setLoading(false);\n }\n };\n const t = setTimeout(run, query ? 150 : 0);\n return () => clearTimeout(t);\n // `revision`, not `search`: see the prop's docstring. The debounce is re-armed on a\n // revision change, which is right — data arriving is not a keystroke and there is\n // nothing to feel laggy about.\n }, [query, open, revision]);\n\n // Group results, preserving first-seen group order; keep a flat list for nav.\n const { groups, flat } = useMemo(() => groupItems(results), [results]);\n useEffect(() => {\n activeIdRef.current = flat[active]?.id;\n });\n\n const choose = (item: CommandItem | undefined) => {\n if (!item) return;\n onClose();\n item.onSelect();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActive((i) => Math.min(i + 1, flat.length - 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActive((i) => Math.max(i - 1, 0));\n } else if (e.key === \"Enter\") {\n e.preventDefault();\n if (dirty) commit(draft);\n else choose(flat[active]);\n }\n };\n\n // Escape on the whole dialog, not only the field: once Tab has moved focus to a row\n // (or a footer control), Escape used to do nothing at all.\n const onDialogKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n onClose();\n }\n };\n\n // Keep the active row scrolled into view.\n useEffect(() => {\n const el = listRef.current?.querySelector<HTMLElement>(`[data-index=\"${active}\"]`);\n // Optional-called, as in combobox-core: jsdom has no scrollIntoView, and every\n // consumer's tests crashed on the first highlighted row (kastlan stubbed it).\n el?.scrollIntoView?.({ block: \"nearest\" });\n }, [active]);\n\n if (!open) return null;\n\n const comfortable = density === \"comfortable\";\n let flatIndex = -1;\n return createPortal(\n <div\n className={cn(\n \"fixed inset-0 z-[70] flex items-start justify-center bg-black/40\",\n isPhone ? \"p-0\" : \"p-4 pt-[10vh]\",\n )}\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) onClose();\n }}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Escape from anywhere in the dialog */}\n <div\n ref={dialogRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={dialogName}\n // The trap's fallback target when the field is not there to take focus.\n tabIndex={-1}\n // Escape bubbling up from anything inside — a dialog is where it belongs.\n onKeyDown={onDialogKeyDown}\n data-fullscreen={isPhone || undefined}\n className={cn(\n \"flex w-full flex-col overflow-hidden bg-[var(--bg-surface)] outline-none\",\n isPhone\n ? \"h-full\"\n : \"max-h-[70vh] max-w-xl rounded-xl border border-[var(--border)] shadow-2xl\",\n )}\n // Full screen means edge to edge, so the notch, the home indicator and the\n // rounded corners are the panel's to keep clear of.\n style={\n isPhone\n ? {\n paddingTop: \"max(0px, env(safe-area-inset-top))\",\n paddingBottom: \"max(0px, env(safe-area-inset-bottom))\",\n paddingLeft: \"max(0px, env(safe-area-inset-left))\",\n paddingRight: \"max(0px, env(safe-area-inset-right))\",\n }\n : undefined\n }\n >\n <div className=\"flex shrink-0 items-center gap-2 border-b border-[var(--border)] px-3\">\n <Search className=\"size-4 shrink-0 text-[var(--text-placeholder)]\" />\n <input\n ref={inputRef}\n role=\"combobox\"\n aria-expanded\n aria-controls={listId}\n aria-activedescendant={flat[active] ? itemId(flat[active].id) : undefined}\n value={fieldText}\n onChange={(e) => (submitMode ? setDraft(e.target.value) : setQuery(e.target.value))}\n onKeyDown={onKeyDown}\n placeholder={l.placeholder}\n enterKeyHint={submitMode ? \"search\" : undefined}\n className={cn(\n \"w-full bg-transparent py-3 outline-none placeholder:text-[var(--text-placeholder)] text-[var(--text-primary)]\",\n // 16px on a phone, or iOS zooms the page in on focus.\n isPhone ? \"text-base\" : \"text-sm\",\n )}\n />\n {loading && <span className=\"shrink-0 text-[11px] text-[var(--text-placeholder)]\">{l.loading}</span>}\n {fieldText !== \"\" && (\n <button\n type=\"button\"\n aria-label={l.clear ?? DEFAULT_COMMAND_PALETTE_LABELS.clear}\n onClick={() => {\n commit(\"\");\n // Clearing starts the next query far more often than it ends this one.\n inputRef.current?.focus();\n }}\n className=\"shrink-0 rounded p-1 text-[var(--text-placeholder)] hover:text-[var(--text-secondary)]\"\n >\n <X className=\"size-4\" />\n </button>\n )}\n {dirty && (\n <button\n type=\"button\"\n aria-label={l.submit ?? DEFAULT_COMMAND_PALETTE_LABELS.submit}\n onClick={() => {\n commit(draft);\n inputRef.current?.focus();\n }}\n className=\"shrink-0 rounded p-1 text-[var(--text-secondary)] hover:text-[var(--text-primary)]\"\n >\n <CornerDownLeft className=\"size-4\" />\n </button>\n )}\n {isPhone && (\n <button\n type=\"button\"\n onClick={onClose}\n className=\"-me-1 shrink-0 rounded px-1 py-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)]\"\n >\n {l.close ?? DEFAULT_COMMAND_PALETTE_LABELS.close}\n </button>\n )}\n </div>\n\n {/* The status lines sit outside the listbox: a listbox owns options and groups,\n and \"No results\" is neither. */}\n {failed && !loading && (\n <div role=\"alert\" className=\"px-3 py-6 text-center text-sm text-[var(--text-muted)]\">\n {l.error ?? DEFAULT_COMMAND_PALETTE_LABELS.error}\n </div>\n )}\n {/* `results`, not `flat`: a group whose only row is its \"Searching…\" line is not\n an empty result. */}\n {!failed && results.length === 0 && !loading && (\n <div className=\"px-3 py-6 text-center text-sm text-[var(--text-muted)]\">{l.empty}</div>\n )}\n {/* Listbox grouping: each group is a `role=\"group\"` named by its heading, and\n the list markup in between is presentational so the listbox's children are\n groups and options only — as a plain <li>/<ul> tree a reader announced\n \"list, 2 items\" between options and never tied the heading to its rows. */}\n <ul id={listId} ref={listRef} role=\"listbox\" aria-label={dialogName} className=\"min-h-0 flex-1 overflow-y-auto py-1\">\n {groups.map(({ group, items }, groupIndex) => (\n <li key={group} role=\"presentation\">\n <div\n id={groupId(groupIndex)}\n role=\"presentation\"\n className=\"px-3 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wide text-[var(--text-placeholder)]\"\n >\n {group}\n </div>\n <ul role=\"group\" aria-labelledby={groupId(groupIndex)}>\n {items.map((item) => {\n if (item.kind === \"status\") {\n return (\n <li\n key={item.id}\n role=\"presentation\"\n className={cn(\n \"flex items-center gap-2.5 px-3 text-xs text-[var(--text-placeholder)]\",\n comfortable ? \"min-h-11 py-2.5\" : \"py-2\",\n )}\n >\n {item.icon && <span className=\"flex size-4 shrink-0 items-center justify-center\">{item.icon}</span>}\n <span className=\"min-w-0 flex-1 truncate\">{item.label}</span>\n </li>\n );\n }\n flatIndex += 1;\n const idx = flatIndex;\n const isActive = idx === active;\n const redact = item.redact ?? redactLabels;\n // Written once and worn by either tag below, so the anchor and the\n // button can never drift apart in looks or in listbox semantics.\n // `role=\"option\"` on an <a href> is fine: the browser's middle-click\n // behaviour keys off the element, not the ARIA role.\n const shared = {\n id: itemId(item.id),\n role: \"option\" as const,\n \"aria-selected\": isActive,\n \"data-index\": idx,\n onMouseMove: () => setActive(idx),\n className: cn(\n \"flex w-full items-center gap-2.5 px-3 text-start\",\n comfortable ? \"min-h-11 py-2.5 text-base\" : \"py-2 text-sm\",\n isActive\n ? \"bg-[var(--bg-active)] text-[var(--text-primary)]\"\n : \"text-[var(--text-secondary)]\",\n ),\n };\n const inner = (\n <>\n {item.icon && (\n <span className=\"flex size-4 shrink-0 items-center justify-center text-[var(--text-placeholder)]\">\n {item.icon}\n </span>\n )}\n <span data-private={redact || undefined} className=\"min-w-0 flex-1 truncate\">\n {item.label}\n </span>\n {item.hint && (\n <span data-private={redact || undefined} className=\"shrink-0 text-xs text-[var(--text-placeholder)]\">\n {item.hint}\n </span>\n )}\n </>\n );\n return (\n <li key={item.id} role=\"presentation\">\n {item.href ? (\n <a\n {...shared}\n href={item.href}\n draggable={false}\n onClick={(e) => {\n // A modified click belongs to the browser (feedback\n // #451) — and the palette deliberately stays OPEN for\n // it: ⌘-clicking three results in a row is the reason to\n // want this, and closing after the first would undo it.\n if (\n e.button !== 0 ||\n e.metaKey ||\n e.ctrlKey ||\n e.shiftKey ||\n e.altKey\n )\n return;\n e.preventDefault();\n choose(item);\n }}\n >\n {inner}\n </a>\n ) : (\n <button type=\"button\" {...shared} onClick={() => choose(item)}>\n {inner}\n </button>\n )}\n </li>\n );\n })}\n </ul>\n </li>\n ))}\n </ul>\n\n {l.hint && (\n <div className=\"border-t border-[var(--border)] px-3 py-1.5 text-[11px] text-[var(--text-placeholder)]\">\n {l.hint}\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AA+bQ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