@mitcsutt/kiln-ui 0.6.0 → 0.7.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/components/actions/CopyButton/CopyButton.d.ts +58 -0
- package/dist/components/actions/CopyButton/CopyButton.js +63 -0
- package/dist/components/actions/CopyButton/CopyButton.js.map +1 -0
- package/dist/components/actions/CopyButton/CopyButton.module.js +9 -0
- package/dist/components/actions/CopyButton/CopyButton.module.js.map +1 -0
- package/dist/components/actions/CopyButton/index.d.ts +4 -0
- package/dist/components/actions/CopyButton/useClipboard.d.ts +35 -0
- package/dist/components/actions/CopyButton/useClipboard.js +62 -0
- package/dist/components/actions/CopyButton/useClipboard.js.map +1 -0
- package/dist/components/actions/ToggleChip/ToggleChip.d.ts +6 -0
- package/dist/components/actions/ToggleChip/ToggleChip.js +26 -24
- package/dist/components/actions/ToggleChip/ToggleChip.js.map +1 -1
- package/dist/components/display/Badge/Badge.d.ts +6 -0
- package/dist/components/display/Badge/Badge.js +16 -15
- package/dist/components/display/Badge/Badge.js.map +1 -1
- package/dist/components/display/CodeBlock/CodeBlock.js +45 -58
- package/dist/components/display/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/display/Swatch/Swatch.d.ts +52 -0
- package/dist/components/display/Swatch/Swatch.js +27 -0
- package/dist/components/display/Swatch/Swatch.js.map +1 -0
- package/dist/components/display/Swatch/Swatch.module.js +6 -0
- package/dist/components/display/Swatch/Swatch.module.js.map +1 -0
- package/dist/components/display/Swatch/index.d.ts +2 -0
- package/dist/components/display/Tag/Tag.d.ts +7 -0
- package/dist/components/display/Tag/Tag.js +31 -26
- package/dist/components/display/Tag/Tag.js.map +1 -1
- package/dist/components/feedback/Indicator/Indicator.d.ts +74 -0
- package/dist/components/feedback/Indicator/Indicator.js +50 -0
- package/dist/components/feedback/Indicator/Indicator.js.map +1 -0
- package/dist/components/feedback/Indicator/Indicator.module.js +12 -0
- package/dist/components/feedback/Indicator/Indicator.module.js.map +1 -0
- package/dist/components/feedback/Indicator/index.d.ts +2 -0
- package/dist/components/feedback/Toaster/Toaster.d.ts +71 -0
- package/dist/components/feedback/Toaster/Toaster.js +121 -0
- package/dist/components/feedback/Toaster/Toaster.js.map +1 -0
- package/dist/components/feedback/Toaster/Toaster.module.js +20 -0
- package/dist/components/feedback/Toaster/Toaster.module.js.map +1 -0
- package/dist/components/feedback/Toaster/index.d.ts +4 -0
- package/dist/components/feedback/Toaster/toast.d.ts +96 -0
- package/dist/components/feedback/Toaster/toast.js +131 -0
- package/dist/components/feedback/Toaster/toast.js.map +1 -0
- package/dist/components/inputs/Calendar/Calendar.d.ts +87 -0
- package/dist/components/inputs/Calendar/Calendar.js +217 -0
- package/dist/components/inputs/Calendar/Calendar.js.map +1 -0
- package/dist/components/inputs/Calendar/Calendar.module.js +18 -0
- package/dist/components/inputs/Calendar/Calendar.module.js.map +1 -0
- package/dist/components/inputs/Calendar/index.d.ts +2 -0
- package/dist/components/inputs/Combobox/Combobox.js +36 -44
- package/dist/components/inputs/Combobox/Combobox.js.map +1 -1
- package/dist/components/inputs/DateField/DateField.d.ts +17 -0
- package/dist/components/inputs/DateField/DateField.js +26 -0
- package/dist/components/inputs/DateField/DateField.js.map +1 -0
- package/dist/components/inputs/DateField/index.d.ts +2 -0
- package/dist/components/inputs/DateInput/DateInput.d.ts +75 -0
- package/dist/components/inputs/DateInput/DateInput.js +139 -0
- package/dist/components/inputs/DateInput/DateInput.js.map +1 -0
- package/dist/components/inputs/DateInput/index.d.ts +3 -0
- package/dist/components/inputs/DateRangeField/DateRangeField.d.ts +18 -3
- package/dist/components/inputs/DateRangeField/DateRangeField.js.map +1 -1
- package/dist/components/inputs/DateRangeField/DateRangeField.module.js +8 -3
- package/dist/components/inputs/DateRangeField/DateRangeField.module.js.map +1 -1
- package/dist/components/inputs/DateRangeField/DateRangePickerField.d.ts +48 -0
- package/dist/components/inputs/DateRangeField/DateRangePickerField.js +246 -0
- package/dist/components/inputs/DateRangeField/DateRangePickerField.js.map +1 -0
- package/dist/components/inputs/DateRangeField/index.d.ts +2 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.d.ts +17 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.js +26 -0
- package/dist/components/inputs/DateTimeField/DateTimeField.js.map +1 -0
- package/dist/components/inputs/DateTimeField/index.d.ts +2 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.d.ts +83 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.js +216 -0
- package/dist/components/inputs/DateTimeInput/DateTimeInput.js.map +1 -0
- package/dist/components/inputs/DateTimeInput/index.d.ts +2 -0
- package/dist/components/inputs/JsonField/JsonField.d.ts +23 -0
- package/dist/components/inputs/JsonField/JsonField.js +33 -0
- package/dist/components/inputs/JsonField/JsonField.js.map +1 -0
- package/dist/components/inputs/JsonField/index.d.ts +2 -0
- package/dist/components/inputs/JsonInput/JsonInput.d.ts +119 -0
- package/dist/components/inputs/JsonInput/JsonInput.js +282 -0
- package/dist/components/inputs/JsonInput/JsonInput.js.map +1 -0
- package/dist/components/inputs/JsonInput/JsonInput.module.js +16 -0
- package/dist/components/inputs/JsonInput/JsonInput.module.js.map +1 -0
- package/dist/components/inputs/JsonInput/index.d.ts +4 -0
- package/dist/components/inputs/JsonInput/json.d.ts +59 -0
- package/dist/components/inputs/JsonInput/json.js +231 -0
- package/dist/components/inputs/JsonInput/json.js.map +1 -0
- package/dist/components/inputs/TagsInput/TagsInput.js +5 -5
- package/dist/components/inputs/TimeField/TimeField.d.ts +17 -0
- package/dist/components/inputs/TimeField/TimeField.js +26 -0
- package/dist/components/inputs/TimeField/TimeField.js.map +1 -0
- package/dist/components/inputs/TimeField/index.d.ts +2 -0
- package/dist/components/inputs/TimeInput/TimeInput.d.ts +54 -0
- package/dist/components/inputs/TimeInput/TimeInput.js +107 -0
- package/dist/components/inputs/TimeInput/TimeInput.js.map +1 -0
- package/dist/components/inputs/TimeInput/index.d.ts +2 -0
- package/dist/components/inputs/internal/DateSegments.d.ts +80 -0
- package/dist/components/inputs/internal/DateSegments.js +345 -0
- package/dist/components/inputs/internal/DateSegments.js.map +1 -0
- package/dist/components/inputs/internal/dates.d.ts +101 -0
- package/dist/components/inputs/internal/dates.js +262 -0
- package/dist/components/inputs/internal/dates.js.map +1 -0
- package/dist/components/inputs/internal/filterOptions.d.ts +22 -1
- package/dist/components/inputs/internal/filterOptions.js +32 -1
- package/dist/components/inputs/internal/filterOptions.js.map +1 -1
- package/dist/components/inputs/internal/picker.d.ts +31 -0
- package/dist/components/inputs/internal/picker.js +29 -0
- package/dist/components/inputs/internal/picker.js.map +1 -0
- package/dist/components/inputs/internal/picker.module.js +15 -0
- package/dist/components/inputs/internal/picker.module.js.map +1 -0
- package/dist/components/inputs/internal/segments.module.js +10 -0
- package/dist/components/inputs/internal/segments.module.js.map +1 -0
- package/dist/components/layout/Collapse/Collapse.d.ts +39 -0
- package/dist/components/layout/Collapse/Collapse.js +24 -0
- package/dist/components/layout/Collapse/Collapse.js.map +1 -0
- package/dist/components/layout/Collapse/Collapse.module.js +6 -0
- package/dist/components/layout/Collapse/Collapse.module.js.map +1 -0
- package/dist/components/layout/Collapse/index.d.ts +2 -0
- package/dist/components/layout/Collapse/useHeightMotion.d.ts +16 -0
- package/dist/components/layout/Collapse/useHeightMotion.js +60 -0
- package/dist/components/layout/Collapse/useHeightMotion.js.map +1 -0
- package/dist/components/layout/ShowMore/ShowMore.d.ts +59 -0
- package/dist/components/layout/ShowMore/ShowMore.js +114 -0
- package/dist/components/layout/ShowMore/ShowMore.js.map +1 -0
- package/dist/components/layout/ShowMore/ShowMore.module.js +12 -0
- package/dist/components/layout/ShowMore/ShowMore.module.js.map +1 -0
- package/dist/components/layout/ShowMore/index.d.ts +2 -0
- package/dist/components/layout/Transition/Transition.d.ts +63 -0
- package/dist/components/layout/Transition/Transition.js +63 -0
- package/dist/components/layout/Transition/Transition.js.map +1 -0
- package/dist/components/layout/Transition/Transition.module.js +17 -0
- package/dist/components/layout/Transition/Transition.module.js.map +1 -0
- package/dist/components/layout/Transition/index.d.ts +2 -0
- package/dist/components/navigation/Collapsible/Collapsible.d.ts +49 -0
- package/dist/components/navigation/Collapsible/Collapsible.js +83 -0
- package/dist/components/navigation/Collapsible/Collapsible.js.map +1 -0
- package/dist/components/navigation/Collapsible/Collapsible.module.js +11 -0
- package/dist/components/navigation/Collapsible/Collapsible.module.js.map +1 -0
- package/dist/components/navigation/Collapsible/index.d.ts +2 -0
- package/dist/components/navigation/NavLinks/NavLinks.d.ts +32 -4
- package/dist/components/navigation/NavLinks/NavLinks.js +69 -39
- package/dist/components/navigation/NavLinks/NavLinks.js.map +1 -1
- package/dist/components/navigation/NavLinks/NavLinks.module.js +13 -3
- package/dist/components/navigation/NavLinks/NavLinks.module.js.map +1 -1
- package/dist/components/navigation/NavLinks/NavLinksGroup.d.ts +49 -0
- package/dist/components/navigation/NavLinks/NavLinksGroup.js +185 -0
- package/dist/components/navigation/NavLinks/NavLinksGroup.js.map +1 -0
- package/dist/components/navigation/NavLinks/context.d.ts +28 -0
- package/dist/components/navigation/NavLinks/context.js +13 -0
- package/dist/components/navigation/NavLinks/context.js.map +1 -0
- package/dist/components/navigation/NavLinks/index.d.ts +2 -0
- package/dist/components/navigation/NavLinks/treeKeys.d.ts +8 -0
- package/dist/components/navigation/NavLinks/treeKeys.js +57 -0
- package/dist/components/navigation/NavLinks/treeKeys.js.map +1 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.d.ts +120 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.js +386 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.module.js +31 -0
- package/dist/components/overlays/CommandPalette/CommandPalette.module.js.map +1 -0
- package/dist/components/overlays/CommandPalette/index.d.ts +2 -0
- package/dist/components/overlays/CommandPalette/shortcut.d.ts +28 -0
- package/dist/components/overlays/CommandPalette/shortcut.js +104 -0
- package/dist/components/overlays/CommandPalette/shortcut.js.map +1 -0
- package/dist/index.d.ts +40 -4
- package/dist/index.js +123 -100
- package/dist/styles.css +1 -1
- package/dist/themes/fiesta.css +1 -1
- package/dist/themes/flightdeck.css +1 -1
- package/dist/themes/ledger.css +1 -1
- package/dist/themes/monograph.css +1 -1
- package/dist/themes/riso.css +1 -1
- package/package.json +1 -1
- package/skills/custom-theme/SKILL.md +32 -0
- package/skills/custom-theme/references/colour.md +20 -0
- package/skills/custom-theme/references/motion.md +9 -0
- package/skills/custom-theme/references/tokens.md +35 -0
- package/skills/design-rules/SKILL.md +5 -2
- package/skills/setup-and-theming/SKILL.md +1 -1
- package/skills/setup-and-theming/references/paper.md +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Children as e, createContext as t, isValidElement as n } from "react";
|
|
2
|
+
//#region src/components/navigation/NavLinks/context.ts
|
|
3
|
+
var r = t({
|
|
4
|
+
orientation: "horizontal",
|
|
5
|
+
size: "md"
|
|
6
|
+
}), i = t(null);
|
|
7
|
+
function a(t) {
|
|
8
|
+
return e.toArray(t).some((e) => n(e) ? e.props.active === !0 || a(e.props.children) : !1);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { r as NavLinksContext, i as NavLinksGroupContext, a as holdsActive };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["NavLinksContext","createContext","NavLinksGroupContext","holdsActive","Children","children","isValidElement","child"],"sources":["../../../../src/components/navigation/NavLinks/context.ts"],"sourcesContent":["import { Children, createContext, isValidElement, type KeyboardEvent, type ReactNode } from 'react'\n\nexport type NavLinksOrientation = 'horizontal' | 'vertical'\nexport type NavLinksSize = 'sm' | 'md'\n\n/** The tree-style arrow keys of a vertical nav with groups. */\nexport type TreeKeyDown = (event: KeyboardEvent<HTMLElement>) => void\n\nexport interface NavLinksContextValue {\n orientation: NavLinksOrientation\n size: NavLinksSize\n /**\n * Where a group puts the arrow-key handler for the nav it's in. Groups bring it, so a nav\n * without them doesn't carry it.\n */\n treeKeysRef?: { current: TreeKeyDown | null }\n}\n\nexport const NavLinksContext = createContext<NavLinksContextValue>({\n orientation: 'horizontal',\n size: 'md',\n})\n\n/** How an item or a nested group tells the groups around it that it's the current page. */\nexport interface NavLinksGroupContextValue {\n report: (id: string, active: boolean) => void\n}\n\nexport const NavLinksGroupContext = createContext<NavLinksGroupContextValue | null>(null)\n\n/**\n * Whether any element under `children` is marked `active`, read from the elements themselves, so\n * the server render already knows which groups hold the current page. Items wrapped in your own\n * components are caught on the client, when they report in.\n */\nexport function holdsActive(children: ReactNode): boolean {\n return Children.toArray(children).some((child) => {\n if (!isValidElement<{ active?: unknown; children?: ReactNode }>(child)) return false\n return child.props.active === true || holdsActive(child.props.children)\n })\n}\n"],"mappings":";;AAkBA,IAAaA,IAAkBC,EAAoC;CACjE,aAAa;CACb,MAAM;AACR,CAAC,GAOYC,IAAuBD,EAAgD,IAAI;AAOxF,SAAgBE,EAAY,GAA8B;CACxD,OAAOC,EAAS,QAAQC,CAAQ,CAAC,CAAC,MAAM,MACjCC,EAA2DC,CAAK,IAC9DA,EAAM,MAAM,WAAW,MAAQJ,EAAYI,EAAM,MAAM,QAAQ,IADS,EAEhF;AACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { KeyboardEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Arrow keys for a vertical nav with groups, like a tree: Up and Down move between the links you
|
|
4
|
+
* can see, Right opens a group (or steps into an open one), Left closes it (or steps out to its
|
|
5
|
+
* parent), Home and End jump, and a letter jumps to the next link starting with it. Tab still
|
|
6
|
+
* moves through every link, so nothing is lost for anyone who doesn't use them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function onTreeKeyDown(event: KeyboardEvent<HTMLElement>): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/components/navigation/NavLinks/treeKeys.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Array.from(e.querySelectorAll("a[href], button")).filter((e) => !e.closest("[data-navlinks-panel][data-state=\"closed\"]") && !e.disabled && (!("checkVisibility" in e) || e.checkVisibility()));
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
return e?.querySelector(":scope > [data-navlinks-row], :scope > [aria-expanded]") ?? null;
|
|
7
|
+
}
|
|
8
|
+
function n(e) {
|
|
9
|
+
let n = t(e);
|
|
10
|
+
return n?.hasAttribute("aria-expanded") ? n : n?.querySelector("[aria-expanded]") ?? null;
|
|
11
|
+
}
|
|
12
|
+
function r(r) {
|
|
13
|
+
let i = r.currentTarget;
|
|
14
|
+
if (!i.querySelector("[data-navlinks-group]")) return;
|
|
15
|
+
let a = e(i), o = r.target, s = a.indexOf(o);
|
|
16
|
+
if (s < 0 || r.altKey || r.ctrlKey || r.metaKey) return;
|
|
17
|
+
let c = (e) => {
|
|
18
|
+
e && (r.preventDefault(), e.focus());
|
|
19
|
+
}, l = o.closest("[data-navlinks-group]"), u = t(l), d = u?.contains(o) === !0, f = d ? n(l) : null;
|
|
20
|
+
switch (r.key) {
|
|
21
|
+
case "ArrowDown":
|
|
22
|
+
c(a[s + 1]);
|
|
23
|
+
return;
|
|
24
|
+
case "ArrowUp":
|
|
25
|
+
c(a[s - 1]);
|
|
26
|
+
return;
|
|
27
|
+
case "Home":
|
|
28
|
+
c(a[0]);
|
|
29
|
+
return;
|
|
30
|
+
case "End":
|
|
31
|
+
c(a.at(-1));
|
|
32
|
+
return;
|
|
33
|
+
case "ArrowRight":
|
|
34
|
+
if (!f) return;
|
|
35
|
+
r.preventDefault(), f.getAttribute("aria-expanded") === "false" ? f.click() : c(a.find((e, t) => t > s && l?.contains(e) && !u?.contains(e)));
|
|
36
|
+
return;
|
|
37
|
+
case "ArrowLeft": {
|
|
38
|
+
if (f?.getAttribute("aria-expanded") === "true") {
|
|
39
|
+
r.preventDefault(), f.click();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let e = t(d ? l?.parentElement?.closest("[data-navlinks-group]") : l);
|
|
43
|
+
c(e?.querySelector("a[href]") ?? e);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
if (r.key.length !== 1 || r.key === " ") return;
|
|
48
|
+
{
|
|
49
|
+
let e = r.key.toLowerCase();
|
|
50
|
+
c([...a.slice(s + 1), ...a.slice(0, s + 1)].find((t) => t.textContent.trim().toLowerCase().startsWith(e)));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { r as onTreeKeyDown };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=treeKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeKeys.js","names":["reachable","nav","element","rowOf","group","toggleOf","row","onTreeKeyDown","event","items","current","index","focus","inRow","toggle","at","item","ownerRow","key"],"sources":["../../../../src/components/navigation/NavLinks/treeKeys.ts"],"sourcesContent":["import type { KeyboardEvent } from 'react'\n\n/** The links and group buttons a reader can reach now: shown, and not inside a closed group. */\nfunction reachable(nav: HTMLElement): HTMLElement[] {\n return Array.from(nav.querySelectorAll<HTMLElement>('a[href], button')).filter(\n (element) =>\n !element.closest('[data-navlinks-panel][data-state=\"closed\"]') &&\n !(element as HTMLButtonElement).disabled &&\n (!('checkVisibility' in element) || element.checkVisibility()),\n )\n}\n\n/** A group's own row: the button, or the link and its toggle. */\nfunction rowOf(group: Element | null | undefined): HTMLElement | null {\n return (\n group?.querySelector<HTMLElement>(':scope > [data-navlinks-row], :scope > [aria-expanded]') ??\n null\n )\n}\n\n/** The element in a group's row that opens and closes it. */\nfunction toggleOf(group: Element | null | undefined): HTMLElement | null {\n const row = rowOf(group)\n return row?.hasAttribute('aria-expanded')\n ? row\n : (row?.querySelector<HTMLElement>('[aria-expanded]') ?? null)\n}\n\n/**\n * Arrow keys for a vertical nav with groups, like a tree: Up and Down move between the links you\n * can see, Right opens a group (or steps into an open one), Left closes it (or steps out to its\n * parent), Home and End jump, and a letter jumps to the next link starting with it. Tab still\n * moves through every link, so nothing is lost for anyone who doesn't use them.\n */\nexport function onTreeKeyDown(event: KeyboardEvent<HTMLElement>) {\n const nav = event.currentTarget\n if (!nav.querySelector('[data-navlinks-group]')) return\n const items = reachable(nav)\n const current = event.target as HTMLElement\n const index = items.indexOf(current)\n if (index < 0 || event.altKey || event.ctrlKey || event.metaKey) return\n\n const focus = (element: HTMLElement | null | undefined) => {\n if (!element) return\n event.preventDefault()\n element.focus()\n }\n const group = current.closest('[data-navlinks-group]')\n const row = rowOf(group)\n const inRow = row?.contains(current) === true\n const toggle = inRow ? toggleOf(group) : null\n\n switch (event.key) {\n case 'ArrowDown':\n focus(items[index + 1])\n return\n case 'ArrowUp':\n focus(items[index - 1])\n return\n case 'Home':\n focus(items[0])\n return\n case 'End':\n focus(items.at(-1))\n return\n case 'ArrowRight':\n if (!toggle) return\n event.preventDefault()\n if (toggle.getAttribute('aria-expanded') === 'false') toggle.click()\n else\n focus(items.find((item, at) => at > index && group?.contains(item) && !row?.contains(item)))\n return\n case 'ArrowLeft': {\n if (toggle?.getAttribute('aria-expanded') === 'true') {\n event.preventDefault()\n toggle.click()\n return\n }\n const owner = inRow ? group?.parentElement?.closest('[data-navlinks-group]') : group\n const ownerRow = rowOf(owner)\n focus(ownerRow?.querySelector<HTMLElement>('a[href]') ?? ownerRow)\n return\n }\n default:\n if (event.key.length !== 1 || event.key === ' ') return\n {\n const key = event.key.toLowerCase()\n const ordered = [...items.slice(index + 1), ...items.slice(0, index + 1)]\n focus(ordered.find((item) => item.textContent.trim().toLowerCase().startsWith(key)))\n }\n }\n}\n"],"mappings":";AAGA,SAASA,EAAU,GAAiC;CAClD,OAAO,MAAM,KAAKC,EAAI,iBAA8B,iBAAiB,CAAC,CAAC,CAAC,QACrE,MACC,CAACC,EAAQ,QAAQ,8CAA4C,KAC7D,CAAEA,EAA8B,aAC/B,EAAE,qBAAqBA,MAAYA,EAAQ,gBAAgB,EAChE;AACF;AAGA,SAASC,EAAM,GAAuD;CACpE,OACEC,GAAO,cAA2B,wDAAwD,KAC1F;AAEJ;AAGA,SAASC,EAAS,GAAuD;CACvE,IAAMC,IAAMH,EAAMC,CAAK;CACvB,OAAOE,GAAK,aAAa,eAAe,IACpCA,IACCA,GAAK,cAA2B,iBAAiB,KAAK;AAC7D;AAQA,SAAgBC,EAAc,GAAmC;CAC/D,IAAMN,IAAMO,EAAM;CAClB,IAAI,CAACP,EAAI,cAAc,uBAAuB,GAAG;CACjD,IAAMQ,IAAQT,EAAUC,CAAG,GACrBS,IAAUF,EAAM,QAChBG,IAAQF,EAAM,QAAQC,CAAO;CACnC,IAAIC,IAAQ,KAAKH,EAAM,UAAUA,EAAM,WAAWA,EAAM,SAAS;CAEjE,IAAMI,KAAS,MAA4C;EACzD,AAAKV,MACLM,EAAM,eAAe,GACrBN,EAAQ,MAAM;CAChB,GACME,IAAQM,EAAQ,QAAQ,uBAAuB,GAC/CJ,IAAMH,EAAMC,CAAK,GACjBS,IAAQP,GAAK,SAASI,CAAO,MAAM,IACnCI,IAASD,IAAQR,EAASD,CAAK,IAAI;CAEzC,QAAQI,EAAM,KAAd;EACE,KAAK;GACH,EAAMC,EAAME,IAAQ,EAAE;GACtB;EACF,KAAK;GACH,EAAMF,EAAME,IAAQ,EAAE;GACtB;EACF,KAAK;GACH,EAAMF,EAAM,EAAE;GACd;EACF,KAAK;GACH,EAAMA,EAAM,GAAG,EAAE,CAAC;GAClB;EACF,KAAK;GACH,IAAI,CAACK,GAAQ;GAEb,AADAN,EAAM,eAAe,GACjBM,EAAO,aAAa,eAAe,MAAM,UAASA,EAAO,MAAM,IAEjEF,EAAMH,EAAM,MAAM,GAAM,MAAOM,IAAKJ,KAASP,GAAO,SAASY,CAAI,KAAK,CAACV,GAAK,SAASU,CAAI,CAAC,CAAC;GAC7F;EACF,KAAK,aAAa;GAChB,IAAIF,GAAQ,aAAa,eAAe,MAAM,QAAQ;IAEpD,AADAN,EAAM,eAAe,GACrBM,EAAO,MAAM;IACb;GACF;GAEA,IAAMG,IAAWd,EADHU,IAAQT,GAAO,eAAe,QAAQ,uBAAuB,IAAIA,CACnD;GAC5B,EAAMa,GAAU,cAA2B,SAAS,KAAKA,CAAQ;GACjE;EACF;EACA;GACE,IAAIT,EAAM,IAAI,WAAW,KAAKA,EAAM,QAAQ,KAAK;GACjD;IACE,IAAMU,IAAMV,EAAM,IAAI,YAAY;IAElC,EAAM,CADW,GAAGC,EAAM,MAAME,IAAQ,CAAC,GAAG,GAAGF,EAAM,MAAM,GAAGE,IAAQ,CAAC,CACjE,CAAA,CAAQ,MAAM,MAASK,EAAK,YAAY,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,WAAWE,CAAG,CAAC,CAAC;GACrF;CACJ;AACF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { Dialog as DialogPrimitive } from 'radix-ui';
|
|
3
|
+
import type { ComboboxOption } from '../../inputs/Combobox/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* One entry in the palette: a page to go to or a command to run. It's a `Combobox` option with
|
|
6
|
+
* an `id` in place of `value`, so `label`, `description`, `keywords`, `group` and `disabled`
|
|
7
|
+
* search and group the same way in both.
|
|
8
|
+
*/
|
|
9
|
+
export interface CommandAction extends Omit<ComboboxOption, 'value'> {
|
|
10
|
+
/** Unique across the palette, nested actions included. `recent` refers to actions by it. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** A glyph before the label, such as one of the built-in icons. */
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The action's own keyboard shortcut, shown beside it, written like `mod+shift+l` (`mod` is
|
|
16
|
+
* Command on a Mac and Control elsewhere). Display only: bind the shortcut yourself.
|
|
17
|
+
*/
|
|
18
|
+
shortcut?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Runs when the action is picked, once the palette has closed and given focus back, so the
|
|
21
|
+
* action can move focus itself (to a field, or another dialog) and keep it there.
|
|
22
|
+
*/
|
|
23
|
+
onSelect?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Makes this action open a page of its own: picking it lists these instead of running
|
|
26
|
+
* `onSelect`. Backspace in an empty search box, Escape or the back button returns.
|
|
27
|
+
*/
|
|
28
|
+
actions?: readonly CommandAction[];
|
|
29
|
+
/** The search box placeholder while this action's page is open. */
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CommandPaletteProps extends Omit<ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, 'title' | 'children' | 'asChild' | 'forceMount'> {
|
|
33
|
+
/** Everything the palette can find, in the order to list it when the search is empty. */
|
|
34
|
+
actions: readonly CommandAction[];
|
|
35
|
+
open?: boolean;
|
|
36
|
+
defaultOpen?: boolean;
|
|
37
|
+
onOpenChange?: (open: boolean) => void;
|
|
38
|
+
/** A button that opens the palette. Its theme scope themes the palette. */
|
|
39
|
+
trigger?: ReactElement;
|
|
40
|
+
/**
|
|
41
|
+
* A keyboard shortcut anywhere on the page that opens and closes the palette, written like
|
|
42
|
+
* `mod+k` (Command-K on a Mac, Control-K elsewhere). Off when omitted.
|
|
43
|
+
*/
|
|
44
|
+
shortcut?: string;
|
|
45
|
+
/** Accessible name of the palette and its search box. */
|
|
46
|
+
label?: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
/** The search text. Controlled. */
|
|
49
|
+
query?: string;
|
|
50
|
+
defaultQuery?: string;
|
|
51
|
+
onQueryChange?: (query: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* `auto` (default) filters and ranks the actions by the search, like `Combobox`. `none` lists
|
|
54
|
+
* them as given, for results your own search has already chosen.
|
|
55
|
+
*/
|
|
56
|
+
filter?: 'auto' | 'none';
|
|
57
|
+
/** Actions are being fetched: a spinner in the search box, and `loadingMessage` when empty. */
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
loadingMessage?: ReactNode;
|
|
60
|
+
/** Shown when nothing matches. */
|
|
61
|
+
emptyMessage?: ReactNode;
|
|
62
|
+
/** The most actions to list at once, after ranking. */
|
|
63
|
+
limit?: number;
|
|
64
|
+
/** Ids of recently used actions, most recent first, listed above the rest while the search is empty. */
|
|
65
|
+
recent?: readonly string[];
|
|
66
|
+
/** Heading of the recent actions. */
|
|
67
|
+
recentLabel?: string;
|
|
68
|
+
/** Fires after any action runs (not when one opens a page): a place to record recent actions. */
|
|
69
|
+
onAction?: (action: CommandAction) => void;
|
|
70
|
+
/** Accessible name of the back button on a nested page. */
|
|
71
|
+
backLabel?: string;
|
|
72
|
+
/** Portal target. Defaults to `document.body`; its theme scope is also used. */
|
|
73
|
+
container?: HTMLElement | null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A keyboard-first launcher: search every page and action in an app, then run one with Enter.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* `CommandPalette` is a modal search over a list of actions. Each one is a page to go to or a
|
|
80
|
+
* command to run, grouped under headings and ranked as you type, with the matched part of each
|
|
81
|
+
* label marked. Open it with a `shortcut` (usually `mod+k`), a `trigger` button, or `open`.
|
|
82
|
+
*
|
|
83
|
+
* The arrow keys, Home and End move through the results and Enter runs the highlighted one; the
|
|
84
|
+
* first result is highlighted as you type, so Enter alone runs the best match. An action with
|
|
85
|
+
* its own `actions` opens them as a page, such as a list of projects to switch to: Backspace in
|
|
86
|
+
* an empty search box, Escape or the back button returns. Escape at the top closes the palette.
|
|
87
|
+
*
|
|
88
|
+
* ## Search and grouping
|
|
89
|
+
*
|
|
90
|
+
* Actions search and group exactly like {@link Combobox | Combobox} options: by `label`, then
|
|
91
|
+
* `keywords` and `description`, ignoring case and accents, with an exact match first, then a
|
|
92
|
+
* match at the start of a word, then anywhere. Groups appear in the order of their best result.
|
|
93
|
+
*
|
|
94
|
+
* ## Results from a server
|
|
95
|
+
*
|
|
96
|
+
* For results your own search chooses, such as records, pass `filter="none"`, set `loading` while
|
|
97
|
+
* you fetch, and pass the results as `actions`. Control the search text with `query` and
|
|
98
|
+
* `onQueryChange`.
|
|
99
|
+
*
|
|
100
|
+
* ## Recent actions
|
|
101
|
+
*
|
|
102
|
+
* `recent` takes the ids of actions to list first while the search is empty. The palette doesn't
|
|
103
|
+
* remember anything itself: record each one in `onAction`, and keep the list wherever suits your
|
|
104
|
+
* app.
|
|
105
|
+
*
|
|
106
|
+
* ## Accessibility
|
|
107
|
+
*
|
|
108
|
+
* It's a modal dialog, so focus is trapped inside and returns to whatever opened it. The search
|
|
109
|
+
* box is an ARIA combobox that keeps focus while the arrow keys move a highlight through the
|
|
110
|
+
* listbox, and a polite live region announces how many results there are. Each action's shortcut
|
|
111
|
+
* is read as its description.
|
|
112
|
+
*
|
|
113
|
+
* @privateRemarks
|
|
114
|
+
* Radix Dialog for focus (the same primitive and portal theming as Dialog and Sheet) around an
|
|
115
|
+
* ARIA 1.2 combobox whose listbox is always shown. Options share Combobox's shape and its
|
|
116
|
+
* `filterOptions`/`groupOptions`, so the two rank and group identically.
|
|
117
|
+
*
|
|
118
|
+
* <CommandPalette shortcut="mod+k" actions={actions} onAction={remember} recent={recentIds} />
|
|
119
|
+
*/
|
|
120
|
+
export declare const CommandPalette: import("react").ForwardRefExoticComponent<CommandPaletteProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { cx as e } from "../../../utils/cx.js";
|
|
2
|
+
import { ArrowLeftIcon as t, ChevronRightIcon as n, SearchIcon as r } from "../../../icons/icons.js";
|
|
3
|
+
import { VisuallyHidden as i } from "../../layout/VisuallyHidden/VisuallyHidden.js";
|
|
4
|
+
import { useLatest as a } from "../../inputs/internal/useLatest.js";
|
|
5
|
+
import { Kbd as ee } from "../../typography/Kbd/Kbd.js";
|
|
6
|
+
import { Spinner as o } from "../../feedback/Spinner/Spinner.js";
|
|
7
|
+
import { PortalAnchorContext as s, composeRefs as c, usePortalAnchor as l, usePortalAnchorRef as te, usePortalTheme as u } from "../usePortalTheme.js";
|
|
8
|
+
import { useControllableState as d } from "../../inputs/Combobox/useControllableState.js";
|
|
9
|
+
import { filterOptions as ne, groupOptions as re, matchRange as f } from "../../inputs/internal/filterOptions.js";
|
|
10
|
+
import { describeShortcut as p, isApplePlatform as ie, matchesShortcut as m, parseShortcut as h } from "./shortcut.js";
|
|
11
|
+
import g from "./CommandPalette.module.js";
|
|
12
|
+
import { forwardRef as _, useCallback as v, useEffect as y, useId as ae, useMemo as b, useRef as x, useState as S } from "react";
|
|
13
|
+
import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
14
|
+
import { Dialog as E } from "radix-ui";
|
|
15
|
+
//#region src/components/overlays/CommandPalette/CommandPalette.tsx
|
|
16
|
+
function D(e, t) {
|
|
17
|
+
for (let n of e) {
|
|
18
|
+
if (n.id === t) return n;
|
|
19
|
+
let e = n.actions ? D(n.actions, t) : void 0;
|
|
20
|
+
if (e) return e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function O(e) {
|
|
24
|
+
return `${String(e)} ${e === 1 ? "result" : "results"}`;
|
|
25
|
+
}
|
|
26
|
+
function k({ label: e, query: t }) {
|
|
27
|
+
let n = f(e, t);
|
|
28
|
+
if (!n) return /* @__PURE__ */ w(C, { children: e });
|
|
29
|
+
let [r, i] = n;
|
|
30
|
+
return /* @__PURE__ */ T(C, { children: [
|
|
31
|
+
e.slice(0, r),
|
|
32
|
+
/* @__PURE__ */ w("mark", {
|
|
33
|
+
className: g.match,
|
|
34
|
+
children: e.slice(r, i)
|
|
35
|
+
}),
|
|
36
|
+
e.slice(i)
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
var oe = _(function({ container: e }, t) {
|
|
40
|
+
let n = u(e);
|
|
41
|
+
return /* @__PURE__ */ w(E.Overlay, {
|
|
42
|
+
ref: t,
|
|
43
|
+
className: g.overlay,
|
|
44
|
+
...n
|
|
45
|
+
});
|
|
46
|
+
}), A = _(function({ children: e }, t) {
|
|
47
|
+
let n = l();
|
|
48
|
+
return /* @__PURE__ */ w(E.Trigger, {
|
|
49
|
+
ref: c(t, n),
|
|
50
|
+
asChild: !0,
|
|
51
|
+
children: e
|
|
52
|
+
});
|
|
53
|
+
}), j = _(function({ actions: s, label: c = "Command palette", placeholder: te = "Search", query: d, setQuery: f, path: m, setPath: h, open: _, hasTrigger: C, close: oe, filter: A = "auto", loading: j = !1, loadingMessage: M = "Loading…", emptyMessage: N = "No matches", limit: P, recent: F, recentLabel: se = "Recent", onAction: ce, backLabel: le = "Back", container: ue, className: de, onOpenAutoFocus: fe, onCloseAutoFocus: pe, onEscapeKeyDown: me, ...he }, ge) {
|
|
54
|
+
let _e = u(ue), I = ae(), ve = `${I}-listbox`, L = x(null), ye = b(() => ie(), []), R = x(null), be = l(), z = x(null), xe = a(ce), Se = a(_), B = v(() => {
|
|
55
|
+
let e = z.current;
|
|
56
|
+
e && (z.current = null, e.onSelect?.(), xe.current?.(e));
|
|
57
|
+
}, [xe]), Ce = m.map((e) => D(s, e)), V = Ce.every((e) => e?.actions) ? m : [], H = V.length > 0 ? Ce[Ce.length - 1] : void 0, U = H?.actions ?? s, W = H?.label ?? c, { sections: we, rows: G } = b(() => {
|
|
58
|
+
let e = [], t = 0, n = (e, n) => ({
|
|
59
|
+
key: e,
|
|
60
|
+
action: n,
|
|
61
|
+
index: t++
|
|
62
|
+
});
|
|
63
|
+
if (d.trim() === "" && !H && F && F.length > 0) {
|
|
64
|
+
let t = F.flatMap((e) => {
|
|
65
|
+
let t = D(s, e);
|
|
66
|
+
return t ? [n(`recent:${e}`, t)] : [];
|
|
67
|
+
});
|
|
68
|
+
t.length > 0 && e.push({
|
|
69
|
+
key: "recent",
|
|
70
|
+
label: se,
|
|
71
|
+
rows: t
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
let r = A === "auto" ? ne(U, d) : [...U], i = P === void 0 ? r : r.slice(0, Math.max(0, P));
|
|
75
|
+
for (let t of re(i)) e.push({
|
|
76
|
+
key: t.key,
|
|
77
|
+
label: t.label,
|
|
78
|
+
rows: t.options.map((e) => n(e.id, e))
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
sections: e,
|
|
82
|
+
rows: e.flatMap((e) => e.rows)
|
|
83
|
+
};
|
|
84
|
+
}, [
|
|
85
|
+
s,
|
|
86
|
+
A,
|
|
87
|
+
P,
|
|
88
|
+
H,
|
|
89
|
+
U,
|
|
90
|
+
d,
|
|
91
|
+
F,
|
|
92
|
+
se
|
|
93
|
+
]), Te = G.some((e) => e.action.icon !== void 0), K = G.filter((e) => !e.action.disabled), [Ee, q] = S(null), [De, Oe] = S(_);
|
|
94
|
+
_ !== De && (Oe(_), _ && q(null)), y(() => {
|
|
95
|
+
_ && B();
|
|
96
|
+
}, [_, B]), y(() => () => {
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
setTimeout(B);
|
|
99
|
+
});
|
|
100
|
+
}, [B]);
|
|
101
|
+
let J = K.find((e) => e.key === Ee) ?? K[0], ke = (e) => `${I}-option-${String(e.index)}`, Y = J ? ke(J) : void 0;
|
|
102
|
+
y(() => {
|
|
103
|
+
Y && L.current?.ownerDocument.getElementById(Y)?.scrollIntoView({ block: "nearest" });
|
|
104
|
+
}, [Y]);
|
|
105
|
+
let [Ae, je] = S(""), X = j ? "" : G.length === 0 ? typeof N == "string" ? N : "No matches" : O(G.length), Z = X === "" ? "" : H ? `${W}: ${X}` : X;
|
|
106
|
+
y(() => {
|
|
107
|
+
if (Z === "") return;
|
|
108
|
+
let e = setTimeout(() => {
|
|
109
|
+
je(Z);
|
|
110
|
+
}, 500);
|
|
111
|
+
return () => {
|
|
112
|
+
clearTimeout(e);
|
|
113
|
+
};
|
|
114
|
+
}, [Z]);
|
|
115
|
+
let Q = () => {
|
|
116
|
+
L.current?.focus();
|
|
117
|
+
}, $ = () => {
|
|
118
|
+
h(V.slice(0, -1)), f(""), q(null);
|
|
119
|
+
}, Me = (e) => {
|
|
120
|
+
if (!e.disabled) {
|
|
121
|
+
if (e.actions) {
|
|
122
|
+
h([...V, e.id]), f(""), q(null);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
z.current = e, oe(), setTimeout(() => {
|
|
126
|
+
Se.current && z.current === e && B();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}, Ne = (e) => {
|
|
130
|
+
if (K.length === 0) return;
|
|
131
|
+
let t = J ? K.indexOf(J) : -1, n = K[(t + e + K.length) % K.length];
|
|
132
|
+
q(n?.key ?? null);
|
|
133
|
+
}, Pe = (e) => {
|
|
134
|
+
f(e.target.value), q(null);
|
|
135
|
+
}, Fe = (e) => {
|
|
136
|
+
if (!e.nativeEvent.isComposing) switch (e.key) {
|
|
137
|
+
case "ArrowDown":
|
|
138
|
+
e.preventDefault(), Ne(1);
|
|
139
|
+
return;
|
|
140
|
+
case "ArrowUp":
|
|
141
|
+
e.preventDefault(), Ne(-1);
|
|
142
|
+
return;
|
|
143
|
+
case "Home":
|
|
144
|
+
case "End": {
|
|
145
|
+
let t = e.key === "Home" ? K[0] : K[K.length - 1];
|
|
146
|
+
if (!t) return;
|
|
147
|
+
e.preventDefault(), q(t.key);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
case "Enter":
|
|
151
|
+
e.preventDefault(), J && Me(J.action);
|
|
152
|
+
return;
|
|
153
|
+
case "Backspace":
|
|
154
|
+
d === "" && H && (e.preventDefault(), $());
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}, Ie = (e) => {
|
|
158
|
+
let { action: t } = e, r = !!t.disabled, i = ke(e), a = t.shortcut ? p(t.shortcut, ye) : void 0, o = [t.description, a?.spoken].filter(Boolean).join(", ");
|
|
159
|
+
return /* @__PURE__ */ T("div", {
|
|
160
|
+
id: i,
|
|
161
|
+
role: "option",
|
|
162
|
+
"aria-selected": J?.key === e.key,
|
|
163
|
+
"aria-disabled": r || void 0,
|
|
164
|
+
"aria-label": t.label,
|
|
165
|
+
"aria-describedby": o === "" ? void 0 : `${i}-hint`,
|
|
166
|
+
"aria-keyshortcuts": a?.aria,
|
|
167
|
+
className: g.option,
|
|
168
|
+
"data-active": J?.key === e.key || void 0,
|
|
169
|
+
"data-disabled": r || void 0,
|
|
170
|
+
"data-page": t.actions ? "" : void 0,
|
|
171
|
+
onMouseDown: (e) => {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
},
|
|
174
|
+
onPointerMove: () => {
|
|
175
|
+
!r && Ee !== e.key && q(e.key);
|
|
176
|
+
},
|
|
177
|
+
onClick: () => {
|
|
178
|
+
Me(t);
|
|
179
|
+
},
|
|
180
|
+
children: [
|
|
181
|
+
t.icon !== void 0 || Te ? /* @__PURE__ */ w("span", {
|
|
182
|
+
className: g.icon,
|
|
183
|
+
"aria-hidden": "true",
|
|
184
|
+
children: t.icon
|
|
185
|
+
}) : null,
|
|
186
|
+
/* @__PURE__ */ T("span", {
|
|
187
|
+
className: g.text,
|
|
188
|
+
children: [/* @__PURE__ */ w("span", {
|
|
189
|
+
className: g.label,
|
|
190
|
+
children: /* @__PURE__ */ w(k, {
|
|
191
|
+
label: t.label,
|
|
192
|
+
query: d
|
|
193
|
+
})
|
|
194
|
+
}), t.description ? /* @__PURE__ */ w("span", {
|
|
195
|
+
className: g.description,
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
children: t.description
|
|
198
|
+
}) : null]
|
|
199
|
+
}),
|
|
200
|
+
a ? /* @__PURE__ */ w("span", {
|
|
201
|
+
className: g.shortcut,
|
|
202
|
+
"aria-hidden": "true",
|
|
203
|
+
children: a.keys.map((e, t) => /* @__PURE__ */ w(ee, {
|
|
204
|
+
size: "sm",
|
|
205
|
+
children: e
|
|
206
|
+
}, t))
|
|
207
|
+
}) : null,
|
|
208
|
+
t.actions ? /* @__PURE__ */ w(n, { className: g.chevron }) : null,
|
|
209
|
+
o === "" ? null : /* @__PURE__ */ w("span", {
|
|
210
|
+
id: `${i}-hint`,
|
|
211
|
+
hidden: !0,
|
|
212
|
+
children: o
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
}, e.key);
|
|
216
|
+
};
|
|
217
|
+
return /* @__PURE__ */ T(E.Content, {
|
|
218
|
+
ref: ge,
|
|
219
|
+
className: e(g.content, de),
|
|
220
|
+
"aria-describedby": void 0,
|
|
221
|
+
"data-page": H ? "" : void 0,
|
|
222
|
+
..._e,
|
|
223
|
+
...he,
|
|
224
|
+
onOpenAutoFocus: (e) => {
|
|
225
|
+
R.current = L.current?.ownerDocument.activeElement ?? null, fe?.(e), !e.defaultPrevented && (e.preventDefault(), Q());
|
|
226
|
+
},
|
|
227
|
+
onCloseAutoFocus: (e) => {
|
|
228
|
+
pe?.(e);
|
|
229
|
+
let t = R.current;
|
|
230
|
+
if (R.current = null, z.current) {
|
|
231
|
+
let n = e.defaultPrevented;
|
|
232
|
+
e.preventDefault();
|
|
233
|
+
let r = C ? be?.current : t;
|
|
234
|
+
!n && r instanceof HTMLElement && r.isConnected && r.focus(), B();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (e.defaultPrevented || C || !(t instanceof HTMLElement) || !t.isConnected) return;
|
|
238
|
+
let n = t.ownerDocument.activeElement, r = e.target instanceof Node ? e.target : null;
|
|
239
|
+
(!n || n === t.ownerDocument.body || r?.contains(n)) && (e.preventDefault(), t.focus());
|
|
240
|
+
},
|
|
241
|
+
onEscapeKeyDown: (e) => {
|
|
242
|
+
me?.(e), !e.defaultPrevented && H && (e.preventDefault(), $(), Q());
|
|
243
|
+
},
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ w(E.Title, {
|
|
246
|
+
asChild: !0,
|
|
247
|
+
children: /* @__PURE__ */ w(i, {
|
|
248
|
+
as: "h2",
|
|
249
|
+
children: c
|
|
250
|
+
})
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ T("div", {
|
|
253
|
+
className: g.search,
|
|
254
|
+
children: [
|
|
255
|
+
H ? /* @__PURE__ */ w("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
className: g.back,
|
|
258
|
+
"aria-label": le,
|
|
259
|
+
onMouseDown: (e) => {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
},
|
|
262
|
+
onClick: () => {
|
|
263
|
+
$(), Q();
|
|
264
|
+
},
|
|
265
|
+
children: /* @__PURE__ */ w(t, {})
|
|
266
|
+
}) : /* @__PURE__ */ w(r, { className: g.searchIcon }),
|
|
267
|
+
H ? /* @__PURE__ */ w("span", {
|
|
268
|
+
className: g.crumb,
|
|
269
|
+
"aria-hidden": "true",
|
|
270
|
+
children: H.label
|
|
271
|
+
}) : null,
|
|
272
|
+
/* @__PURE__ */ w("input", {
|
|
273
|
+
ref: L,
|
|
274
|
+
type: "text",
|
|
275
|
+
role: "combobox",
|
|
276
|
+
className: g.input,
|
|
277
|
+
value: d,
|
|
278
|
+
placeholder: H?.placeholder ?? te,
|
|
279
|
+
autoComplete: "off",
|
|
280
|
+
autoCapitalize: "off",
|
|
281
|
+
autoCorrect: "off",
|
|
282
|
+
spellCheck: !1,
|
|
283
|
+
"aria-label": W,
|
|
284
|
+
"aria-autocomplete": "list",
|
|
285
|
+
"aria-haspopup": "listbox",
|
|
286
|
+
"aria-expanded": G.length > 0,
|
|
287
|
+
"aria-controls": ve,
|
|
288
|
+
"aria-activedescendant": Y,
|
|
289
|
+
"aria-busy": j || void 0,
|
|
290
|
+
onChange: Pe,
|
|
291
|
+
onKeyDown: Fe
|
|
292
|
+
}),
|
|
293
|
+
j ? /* @__PURE__ */ w(o, {
|
|
294
|
+
size: "sm",
|
|
295
|
+
label: null,
|
|
296
|
+
className: g.spinner
|
|
297
|
+
}) : null
|
|
298
|
+
]
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ T("div", {
|
|
301
|
+
className: g.body,
|
|
302
|
+
children: [/* @__PURE__ */ w("div", {
|
|
303
|
+
id: ve,
|
|
304
|
+
role: "listbox",
|
|
305
|
+
"aria-label": W,
|
|
306
|
+
"aria-busy": j || void 0,
|
|
307
|
+
className: g.listbox,
|
|
308
|
+
children: we.map((e, t) => e.label === void 0 ? e.rows.map(Ie) : /* @__PURE__ */ T("div", {
|
|
309
|
+
role: "group",
|
|
310
|
+
"aria-labelledby": `${I}-group-${String(t)}`,
|
|
311
|
+
className: g.group,
|
|
312
|
+
children: [/* @__PURE__ */ w("div", {
|
|
313
|
+
id: `${I}-group-${String(t)}`,
|
|
314
|
+
role: "presentation",
|
|
315
|
+
className: g.groupLabel,
|
|
316
|
+
children: e.label
|
|
317
|
+
}), e.rows.map(Ie)]
|
|
318
|
+
}, e.key))
|
|
319
|
+
}), G.length === 0 ? j ? /* @__PURE__ */ T("div", {
|
|
320
|
+
className: g.message,
|
|
321
|
+
children: [/* @__PURE__ */ w(o, {
|
|
322
|
+
size: "sm",
|
|
323
|
+
label: null
|
|
324
|
+
}), /* @__PURE__ */ w("span", { children: M })]
|
|
325
|
+
}) : /* @__PURE__ */ w("div", {
|
|
326
|
+
className: g.message,
|
|
327
|
+
children: N
|
|
328
|
+
}) : null]
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ w(i, {
|
|
331
|
+
as: "div",
|
|
332
|
+
role: "status",
|
|
333
|
+
"aria-live": "polite",
|
|
334
|
+
children: Ae
|
|
335
|
+
})
|
|
336
|
+
]
|
|
337
|
+
});
|
|
338
|
+
}), M = _(function({ open: e, defaultOpen: t = !1, onOpenChange: n, trigger: r, shortcut: i, query: ee, defaultQuery: o = "", onQueryChange: c, container: l, ...u }, ne) {
|
|
339
|
+
let re = te(), [f, p] = d(e, t, n), [g, _] = d(ee, o, c), [ae, b] = S([]), C = a(g), D = v((e) => {
|
|
340
|
+
e !== C.current && _(e);
|
|
341
|
+
}, [C, _]), O = a(f), k = v((e) => {
|
|
342
|
+
e !== O.current && p(e);
|
|
343
|
+
}, [O, p]), M = x(f);
|
|
344
|
+
y(() => {
|
|
345
|
+
M.current && !f && (D(""), b((e) => e.length > 0 ? [] : e)), M.current = f;
|
|
346
|
+
}, [f, D]);
|
|
347
|
+
let N = a(() => {
|
|
348
|
+
k(!O.current);
|
|
349
|
+
});
|
|
350
|
+
return y(() => {
|
|
351
|
+
if (!i) return;
|
|
352
|
+
let e = h(i, ie()), t = (t) => {
|
|
353
|
+
t.defaultPrevented || t.isComposing || t.repeat || m(t, e) && (t.preventDefault(), N.current());
|
|
354
|
+
};
|
|
355
|
+
return document.addEventListener("keydown", t), () => {
|
|
356
|
+
document.removeEventListener("keydown", t);
|
|
357
|
+
};
|
|
358
|
+
}, [i, N]), /* @__PURE__ */ w(s.Provider, {
|
|
359
|
+
value: re,
|
|
360
|
+
children: /* @__PURE__ */ T(E.Root, {
|
|
361
|
+
open: f,
|
|
362
|
+
onOpenChange: k,
|
|
363
|
+
children: [r ? /* @__PURE__ */ w(A, { children: r }) : null, /* @__PURE__ */ T(E.Portal, {
|
|
364
|
+
container: l,
|
|
365
|
+
children: [/* @__PURE__ */ w(oe, { container: l }), /* @__PURE__ */ w(j, {
|
|
366
|
+
ref: ne,
|
|
367
|
+
container: l,
|
|
368
|
+
query: g,
|
|
369
|
+
setQuery: D,
|
|
370
|
+
path: ae,
|
|
371
|
+
setPath: b,
|
|
372
|
+
open: f,
|
|
373
|
+
hasTrigger: !!r,
|
|
374
|
+
close: () => {
|
|
375
|
+
k(!1);
|
|
376
|
+
},
|
|
377
|
+
...u
|
|
378
|
+
})]
|
|
379
|
+
})]
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
//#endregion
|
|
384
|
+
export { M as CommandPalette };
|
|
385
|
+
|
|
386
|
+
//# sourceMappingURL=CommandPalette.js.map
|