@humanonlyweb/ui 0.2.2 → 0.3.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.
@@ -0,0 +1,143 @@
1
+ import { useTranslations } from "../../config.js";
2
+ import { useCommandPalette } from "../../composables/use-command-palette.js";
3
+ import _sfc_main$1 from "../dialog/Dialog.js";
4
+ import _sfc_main$2 from "../kbd/Kbd.js";
5
+ import _sfc_main$3 from "../visually-hidden/VisuallyHidden.js";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, isRef, mergeModels, openBlock, renderList, renderSlot, toDisplayString, unref, useId, useModel, useTemplateRef, vModelText, withCtx, withDirectives, withModifiers } from "vue";
7
+ //#region src/components/command-palette/CommandPalette.vue
8
+ const _hoisted_1 = { "data-part": "command-palette" };
9
+ const _hoisted_2 = [
10
+ "aria-activedescendant",
11
+ "aria-label",
12
+ "placeholder"
13
+ ];
14
+ const _hoisted_3 = ["aria-label"];
15
+ const _hoisted_4 = ["aria-labelledby"];
16
+ const _hoisted_5 = ["id"];
17
+ const _hoisted_6 = [
18
+ "id",
19
+ "aria-selected",
20
+ "aria-disabled",
21
+ "data-command-active",
22
+ "onClick",
23
+ "onPointermove"
24
+ ];
25
+ const _hoisted_7 = { "data-part": "command-palette-option-label" };
26
+ const _hoisted_8 = {
27
+ key: 0,
28
+ "data-part": "command-palette-empty"
29
+ };
30
+ const _sfc_main = /*@__PURE__*/ defineComponent({
31
+ __name: "CommandPalette",
32
+ props: /*@__PURE__*/ mergeModels({
33
+ items: { default: () => [] },
34
+ label: {},
35
+ placeholder: {},
36
+ shortcut: {}
37
+ }, {
38
+ "open": {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ "openModifiers": {}
43
+ }),
44
+ emits: /*@__PURE__*/ mergeModels(["select"], ["update:open"]),
45
+ setup(__props, { emit: __emit }) {
46
+ const emit = __emit;
47
+ /** Whether the palette is open. */
48
+ const open = useModel(__props, "open");
49
+ const translations = useTranslations();
50
+ const id = useId();
51
+ const listboxId = `${id}-listbox`;
52
+ const listboxRef = useTemplateRef("listbox");
53
+ const name = computed(() => __props.label ?? translations.value.commandPalette);
54
+ const { query, sections, results, activeIndex, activeId, optionId, headingId, activate, setActive, onKeydown } = useCommandPalette({
55
+ items: () => __props.items,
56
+ open,
57
+ shortcut: () => __props.shortcut,
58
+ baseId: () => id,
59
+ listbox: listboxRef,
60
+ onSelect: (value) => emit("select", value)
61
+ });
62
+ const status = computed(() => {
63
+ if (!query.value.trim()) return "";
64
+ return results.value.length ? translations.value.resultCount(results.value.length) : translations.value.noResults;
65
+ });
66
+ return (_ctx, _cache) => {
67
+ return openBlock(), createBlock(_sfc_main$1, {
68
+ open: open.value,
69
+ "onUpdate:open": _cache[3] || (_cache[3] = ($event) => open.value = $event),
70
+ label: name.value,
71
+ size: "lg",
72
+ flush: "",
73
+ "show-close-button": false
74
+ }, {
75
+ default: withCtx(() => [createElementVNode("div", _hoisted_1, [
76
+ withDirectives(createElementVNode("input", {
77
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(query) ? query.value = $event : null),
78
+ type: "text",
79
+ role: "combobox",
80
+ autocomplete: "off",
81
+ spellcheck: "false",
82
+ autofocus: "",
83
+ "aria-autocomplete": "list",
84
+ "aria-expanded": "true",
85
+ "data-part": "command-palette-input",
86
+ "aria-controls": listboxId,
87
+ "aria-activedescendant": unref(activeId),
88
+ "aria-label": name.value,
89
+ placeholder: __props.placeholder ?? unref(translations).searchCommands,
90
+ onKeydown: _cache[1] || (_cache[1] = (...args) => unref(onKeydown) && unref(onKeydown)(...args))
91
+ }, null, 40, _hoisted_2), [[vModelText, unref(query)]]),
92
+ createElementVNode("div", {
93
+ id: listboxId,
94
+ ref: "listbox",
95
+ role: "listbox",
96
+ "data-part": "command-palette-list",
97
+ "aria-label": name.value,
98
+ onPointerdown: _cache[2] || (_cache[2] = withModifiers(() => {}, ["prevent"]))
99
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(sections), (section) => {
100
+ return openBlock(), createElementBlock("div", {
101
+ key: section.id,
102
+ role: "group",
103
+ "data-part": "command-palette-group",
104
+ "aria-labelledby": section.heading ? unref(headingId)(section.id) : void 0
105
+ }, [section.heading ? (openBlock(), createElementBlock("div", {
106
+ key: 0,
107
+ id: unref(headingId)(section.id),
108
+ role: "presentation",
109
+ "data-part": "command-palette-heading"
110
+ }, toDisplayString(section.heading), 9, _hoisted_5)) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(section.items, ({ item, index }) => {
111
+ return openBlock(), createElementBlock("div", {
112
+ id: unref(optionId)(index),
113
+ key: item.value,
114
+ role: "option",
115
+ "data-part": "command-palette-option",
116
+ "aria-selected": index === unref(activeIndex),
117
+ "aria-disabled": item.disabled || void 0,
118
+ "data-command-active": index === unref(activeIndex) || void 0,
119
+ onClick: ($event) => unref(activate)(index),
120
+ onPointermove: ($event) => !item.disabled && index !== unref(activeIndex) && unref(setActive)(index)
121
+ }, [renderSlot(_ctx.$slots, "item", {
122
+ item,
123
+ active: index === unref(activeIndex)
124
+ }, () => [createElementVNode("span", _hoisted_7, toDisplayString(item.label), 1), item.shortcut ? (openBlock(), createBlock(_sfc_main$2, {
125
+ key: 0,
126
+ keys: item.shortcut,
127
+ size: "small"
128
+ }, null, 8, ["keys"])) : createCommentVNode("v-if", true)])], 40, _hoisted_6);
129
+ }), 128))], 8, _hoisted_4);
130
+ }), 128))], 40, _hoisted_3),
131
+ !unref(results).length ? (openBlock(), createElementBlock("p", _hoisted_8, [renderSlot(_ctx.$slots, "empty", { query: unref(query) }, () => [createTextVNode(toDisplayString(unref(translations).noResults), 1)])])) : createCommentVNode("v-if", true),
132
+ createVNode(_sfc_main$3, { role: "status" }, {
133
+ default: withCtx(() => [createTextVNode(toDisplayString(status.value), 1)]),
134
+ _: 1
135
+ })
136
+ ])]),
137
+ _: 3
138
+ }, 8, ["open", "label"]);
139
+ };
140
+ }
141
+ });
142
+ //#endregion
143
+ export { _sfc_main as default };
@@ -0,0 +1,42 @@
1
+ import { CommandItem, SelectValue } from "../../types.js";
2
+ //#region src/components/command-palette/CommandPalette.vue.d.ts
3
+ declare const __VLS_export: <T extends SelectValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<({
5
+ /** Commands to search, in order. Those sharing a `group` are listed together under its heading. */
6
+ items?: CommandItem<T>[];
7
+ /** Accessible name for the dialog and its list. Defaults to the `commandPalette` translation. */
8
+ label?: string;
9
+ /** Search field placeholder. Defaults to the `searchCommands` translation. */
10
+ placeholder?: string;
11
+ /** Chord that opens and closes the palette from anywhere on the page, e.g. "mod+k". */
12
+ shortcut?: string;
13
+ } & {
14
+ /** Whether the palette is open. */
15
+ open?: boolean;
16
+ }) & {
17
+ onSelect?: ((value: T) => any) | undefined;
18
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
19
+ }> & (typeof globalThis extends {
20
+ __VLS_PROPS_FALLBACK: infer P;
21
+ } ? P : {});
22
+ expose: (exposed: {}) => void;
23
+ attrs: any;
24
+ slots: {
25
+ /** Command content, replacing the label and shortcut. */
26
+ item?(props: {
27
+ item: CommandItem<T>;
28
+ active: boolean;
29
+ }): unknown;
30
+ /** Shown when nothing matches. */
31
+ empty?(props: {
32
+ query: string;
33
+ }): unknown;
34
+ };
35
+ emit: ((evt: "select", value: T) => void) & ((event: "update:open", value: boolean) => void);
36
+ }>) => import("vue").VNode & {
37
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
38
+ };
39
+ declare const _default: typeof __VLS_export;
40
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
41
+ //#endregion
42
+ export { _default as default };
@@ -12,8 +12,8 @@ declare const __VLS_export: <T extends string | number>(__VLS_props: NonNullable
12
12
  /** Whether the menu is open. */
13
13
  open?: boolean;
14
14
  }) & {
15
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
15
  onSelect?: ((value: T) => any) | undefined;
16
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
17
  }> & (typeof globalThis extends {
18
18
  __VLS_PROPS_FALLBACK: infer P;
19
19
  } ? P : {});
@@ -12,8 +12,8 @@ declare const __VLS_export: <T extends string | number>(__VLS_props: NonNullable
12
12
  /** Whether the menu is open. */
13
13
  open?: boolean;
14
14
  }) & {
15
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
15
  onSelect?: ((value: T) => any) | undefined;
16
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
17
  }> & (typeof globalThis extends {
18
18
  __VLS_PROPS_FALLBACK: infer P;
19
19
  } ? P : {});
@@ -0,0 +1,14 @@
1
+ //#region src/composables/internal/rank-match.ts
2
+ /**
3
+ * How well `text` matches a lower-cased `query`: exact, then prefix, then substring,
4
+ * so the closest matches surface first. `-1` when it doesn't match at all.
5
+ */
6
+ function rankMatch(text, query) {
7
+ const lower = text.toLowerCase();
8
+ if (lower === query) return 0;
9
+ if (lower.startsWith(query)) return 1;
10
+ if (lower.includes(query)) return 2;
11
+ return -1;
12
+ }
13
+ //#endregion
14
+ export { rankMatch };
@@ -1,13 +1,7 @@
1
1
  import { onClickOutside } from "./internal/on-click-outside.js";
2
+ import { rankMatch } from "./internal/rank-match.js";
2
3
  import { computed, nextTick, ref, watch } from "vue";
3
4
  //#region src/composables/use-combobox.ts
4
- function rank(label, query) {
5
- const text = label.toLowerCase();
6
- if (text === query) return 0;
7
- if (text.startsWith(query)) return 1;
8
- if (text.includes(query)) return 2;
9
- return -1;
10
- }
11
5
  /**
12
6
  * APG editable combobox with list autocomplete: typing filters, focus stays in the
13
7
  * input, and the active option is conveyed with `aria-activedescendant`.
@@ -35,7 +29,7 @@ function useCombobox({ options, model, query, multiple, disabled, filter, ignore
35
29
  if (custom) return options().filter((option) => custom(option, term));
36
30
  return options().map((option) => ({
37
31
  option,
38
- score: rank(option.label, term)
32
+ score: rankMatch(option.label, term)
39
33
  })).filter((entry) => entry.score >= 0).toSorted((a, b) => a.score - b.score).map((entry) => entry.option);
40
34
  });
41
35
  const optionId = (index) => `${baseId()}-opt-${index}`;
@@ -0,0 +1,41 @@
1
+ import { CommandItem, SelectValue } from "../types.js";
2
+ import { Ref } from "vue";
3
+ //#region src/composables/use-command-palette.d.ts
4
+ export interface CommandSection<T extends SelectValue> {
5
+ id: number;
6
+ /** `undefined` for items without a group. */
7
+ heading?: string;
8
+ /** `index` is the item's place in the keyboard order, across sections. */
9
+ items: {
10
+ item: CommandItem<T>;
11
+ index: number;
12
+ }[];
13
+ }
14
+ interface UseCommandPaletteOptions<T extends SelectValue> {
15
+ items: () => CommandItem<T>[];
16
+ open: Ref<boolean>;
17
+ /** Chord that toggles the palette from anywhere on the page. */
18
+ shortcut: () => string | undefined;
19
+ baseId: () => string;
20
+ listbox: Readonly<Ref<HTMLElement | null>>;
21
+ onSelect: (value: T) => void;
22
+ }
23
+ /**
24
+ * Filtering, grouping and keyboard handling for a command palette: typing filters,
25
+ * focus stays in the input, and the active command is conveyed with
26
+ * `aria-activedescendant`.
27
+ */
28
+ export declare function useCommandPalette<T extends SelectValue>({ items, open, shortcut, baseId, listbox, onSelect }: UseCommandPaletteOptions<T>): {
29
+ query: Ref<string, string>;
30
+ sections: import("vue").ComputedRef<CommandSection<T>[]>;
31
+ results: import("vue").ComputedRef<CommandItem<T>[]>;
32
+ activeIndex: Ref<number, number>;
33
+ activeId: import("vue").ComputedRef<string | undefined>;
34
+ optionId: (index: number) => string;
35
+ headingId: (section: number) => string;
36
+ activate: (index: number) => void;
37
+ setActive: (index: number) => number;
38
+ onKeydown: (event: KeyboardEvent) => void;
39
+ };
40
+ //#endregion
41
+ export {};
@@ -0,0 +1,117 @@
1
+ import { useEventListener } from "./internal/use-event-listener.js";
2
+ import { rankMatch } from "./internal/rank-match.js";
3
+ import { matchesChord, usePlatform } from "./use-platform.js";
4
+ import { computed, nextTick, ref, watch } from "vue";
5
+ //#region src/composables/use-command-palette.ts
6
+ const KEYWORD_PENALTY = 3;
7
+ function score(item, term) {
8
+ const label = rankMatch(item.label, term);
9
+ if (label >= 0) return label;
10
+ const best = (item.keywords ?? []).map((keyword) => rankMatch(keyword, term)).filter((rank) => rank >= 0).toSorted((a, b) => a - b)[0];
11
+ return best === void 0 ? -1 : best + KEYWORD_PENALTY;
12
+ }
13
+ /**
14
+ * Filtering, grouping and keyboard handling for a command palette: typing filters,
15
+ * focus stays in the input, and the active command is conveyed with
16
+ * `aria-activedescendant`.
17
+ */
18
+ function useCommandPalette({ items, open, shortcut, baseId, listbox, onSelect }) {
19
+ const query = ref("");
20
+ const activeIndex = ref(-1);
21
+ const sections = computed(() => {
22
+ const term = query.value.trim().toLowerCase();
23
+ const matches = term ? items().map((item) => ({
24
+ item,
25
+ score: score(item, term)
26
+ })).filter((entry) => entry.score >= 0).toSorted((a, b) => a.score - b.score).map((entry) => entry.item) : items();
27
+ const groups = /* @__PURE__ */ new Map();
28
+ for (const item of matches) {
29
+ const group = groups.get(item.group);
30
+ if (group) group.push(item);
31
+ else groups.set(item.group, [item]);
32
+ }
33
+ let index = 0;
34
+ return [...groups].map(([heading, entries], id) => ({
35
+ id,
36
+ heading,
37
+ items: entries.map((item) => ({
38
+ item,
39
+ index: index++
40
+ }))
41
+ }));
42
+ });
43
+ const results = computed(() => sections.value.flatMap((section) => section.items.map((entry) => entry.item)));
44
+ const optionId = (index) => `${baseId()}-opt-${index}`;
45
+ const headingId = (section) => `${baseId()}-group-${section}`;
46
+ const activeId = computed(() => open.value && results.value[activeIndex.value] ? optionId(activeIndex.value) : void 0);
47
+ function enabledFrom(start, dir) {
48
+ const list = results.value;
49
+ for (let i = start; i >= 0 && i < list.length; i += dir) if (!list[i]?.disabled) return i;
50
+ return -1;
51
+ }
52
+ function move(dir) {
53
+ const next = enabledFrom(activeIndex.value + dir, dir);
54
+ activeIndex.value = next >= 0 ? next : enabledFrom(dir === 1 ? 0 : results.value.length - 1, dir);
55
+ }
56
+ function activate(index) {
57
+ const item = results.value[index];
58
+ if (!item || item.disabled) return;
59
+ open.value = false;
60
+ onSelect(item.value);
61
+ }
62
+ function onKeydown(event) {
63
+ if (event.isComposing) return;
64
+ switch (event.key) {
65
+ case "ArrowDown":
66
+ event.preventDefault();
67
+ move(1);
68
+ break;
69
+ case "ArrowUp":
70
+ event.preventDefault();
71
+ move(-1);
72
+ break;
73
+ case "Enter": if (results.value[activeIndex.value]) {
74
+ event.preventDefault();
75
+ activate(activeIndex.value);
76
+ }
77
+ }
78
+ }
79
+ watch(open, (isOpen) => {
80
+ if (!isOpen) return;
81
+ query.value = "";
82
+ activeIndex.value = enabledFrom(0, 1);
83
+ }, { immediate: true });
84
+ watch(query, () => activeIndex.value = enabledFrom(0, 1));
85
+ watch(() => results.value.length, () => {
86
+ if (!results.value[activeIndex.value]) activeIndex.value = enabledFrom(0, 1);
87
+ });
88
+ watch(activeIndex, async (index) => {
89
+ if (index < 0) return;
90
+ await nextTick();
91
+ const list = listbox.value;
92
+ if (!list) return;
93
+ if (index === 0) list.scrollTop = 0;
94
+ else list.querySelector(`#${CSS.escape(optionId(index))}`)?.scrollIntoView({ block: "nearest" });
95
+ });
96
+ const platform = usePlatform();
97
+ useEventListener(() => shortcut() ? document : null, "keydown", (event) => {
98
+ const chord = shortcut();
99
+ if (!chord || !matchesChord(event, chord, platform.value)) return;
100
+ event.preventDefault();
101
+ open.value = !open.value;
102
+ });
103
+ return {
104
+ query,
105
+ sections,
106
+ results,
107
+ activeIndex,
108
+ activeId,
109
+ optionId,
110
+ headingId,
111
+ activate,
112
+ setActive: (index) => activeIndex.value = index,
113
+ onKeydown
114
+ };
115
+ }
116
+ //#endregion
117
+ export { useCommandPalette };
@@ -43,7 +43,7 @@ function fieldNameOf(event) {
43
43
  if ((target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLButtonElement) && target.name) return target.name;
44
44
  return target.closest("[data-field-name]")?.dataset.fieldName || void 0;
45
45
  }
46
- function useForm({ schema, initialValues, onSubmit, mapError, onError, formRef, validateOn = "blur" }) {
46
+ function useForm({ schema, initialValues, onSubmit, mapError, onError, formRef, validateOn = "submit" }) {
47
47
  const baseline = shallowRef(clone(initialValues));
48
48
  const form = reactive(clone(initialValues));
49
49
  const touched = reactive(/* @__PURE__ */ new Set());
@@ -9,6 +9,8 @@ export interface KeyCap {
9
9
  glyph: string;
10
10
  label: string;
11
11
  }
12
+ /** Whether a key press is exactly `chord`, with `mod` as ⌘ on Apple and Ctrl elsewhere. */
13
+ export declare function matchesChord(event: KeyboardEvent, chord: string, platform: Platform): boolean;
12
14
  /**
13
15
  * "mod+shift+k" or "shift enter" → key caps, with `mod` as ⌘ on Apple and Ctrl
14
16
  * elsewhere. `names` are the spoken key names, e.g. the app's `keys` translations.
@@ -98,6 +98,32 @@ const KEYS = {
98
98
  name: "right"
99
99
  }
100
100
  };
101
+ const EVENT_KEYS = {
102
+ esc: "escape",
103
+ space: " ",
104
+ up: "arrowup",
105
+ down: "arrowdown",
106
+ left: "arrowleft",
107
+ right: "arrowright"
108
+ };
109
+ /** Whether a key press is exactly `chord`, with `mod` as ⌘ on Apple and Ctrl elsewhere. */
110
+ function matchesChord(event, chord, platform) {
111
+ const tokens = chord.toLowerCase().split(/[+\s]+/).filter(Boolean);
112
+ const key = tokens.pop();
113
+ if (!key) return false;
114
+ const wanted = {
115
+ meta: false,
116
+ ctrl: false,
117
+ alt: false,
118
+ shift: false
119
+ };
120
+ for (const token of tokens) if (token === "mod") wanted[platform === "apple" ? "meta" : "ctrl"] = true;
121
+ else if (token === "cmd") wanted.meta = true;
122
+ else if (token === "ctrl" || token === "alt" || token === "shift") wanted[token] = true;
123
+ if (wanted.meta !== event.metaKey || wanted.ctrl !== event.ctrlKey || wanted.alt !== event.altKey || wanted.shift !== event.shiftKey) return false;
124
+ if (event.key.toLowerCase() === (EVENT_KEYS[key] ?? key)) return true;
125
+ return key.length === 1 && event.code === (/\d/.test(key) ? `Digit${key}` : `Key${key.toUpperCase()}`);
126
+ }
101
127
  /**
102
128
  * "mod+shift+k" or "shift enter" → key caps, with `mod` as ⌘ on Apple and Ctrl
103
129
  * elsewhere. `names` are the spoken key names, e.g. the app's `keys` translations.
@@ -123,4 +149,4 @@ function parseChord(chord, platform, names = defaultTranslations.keys) {
123
149
  });
124
150
  }
125
151
  //#endregion
126
- export { parseChord, platformFrom, usePlatform };
152
+ export { matchesChord, parseChord, platformFrom, usePlatform };
@@ -22,6 +22,7 @@
22
22
  - [Checkbox](./components/checkbox.md): A checkbox, alone or in a group.
23
23
  - [Checkbox Group](./components/checkbox-group.md): Several checkboxes bound to one array.
24
24
  - [Combobox](./components/combobox.md): A text input that filters a list of options as you type.
25
+ - [Command Palette](./components/command-palette.md): A searchable list of commands in a dialog, opened with a shortcut.
25
26
  - [Confirm Dialog](./components/confirm-dialog.md): Asks to confirm or cancel an action.
26
27
  - [Context Menu](./components/context-menu.md): A menu opened at the pointer by right-click or long-press.
27
28
  - [Dialog](./components/dialog.md): A modal dialog.
@@ -2,6 +2,10 @@
2
2
 
3
3
  > What changed in each release.
4
4
 
5
+ ## 0.3.0 (2026-11-12)
6
+
7
+ - Feat/command palette (#4)
8
+
5
9
  ## 0.2.2 (2026-11-04)
6
10
 
7
11
  - chore: bump version to 0.2.2 in package.json
@@ -0,0 +1,148 @@
1
+ # Command Palette
2
+
3
+ > A searchable list of commands in a dialog, opened with a shortcut.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ Commands sharing a `group` are listed together under its heading. `keywords` match the query without being shown, so “dark” finds _Toggle theme_. Set `shortcut` and the palette opens and closes from anywhere on the page: try it here.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const open = ref(false);
14
+ const toast = useToast();
15
+
16
+ const commands = [
17
+ { label: "New file", value: "new-file", group: "File", shortcut: "mod+n" },
18
+ { label: "Save", value: "save", group: "File", shortcut: "mod+s" },
19
+ { label: "Export as PDF", value: "export", group: "File", keywords: ["download", "print"] },
20
+ { label: "Toggle theme", value: "theme", group: "View", keywords: ["dark", "light"] },
21
+ { label: "Open settings", value: "settings", group: "View", shortcut: "mod+," },
22
+ { label: "Delete project", value: "delete", group: "Danger zone", disabled: true },
23
+ ];
24
+ </script>
25
+
26
+ <template>
27
+ <UiButton variant="secondary" @click="open = true">
28
+ Search commands
29
+ <UiKbd keys="mod+k" size="small" />
30
+ </UiButton>
31
+
32
+ <UiCommandPalette
33
+ v-model:open="open"
34
+ :items="commands"
35
+ shortcut="mod+k"
36
+ @select="(value) => toast.info(`Ran ${value}`)"
37
+ />
38
+ </template>
39
+ ```
40
+
41
+ ### Custom items
42
+
43
+ The `item` slot replaces a command's content, e.g. to add an icon. The `empty` slot replaces the “No results” text.
44
+
45
+ ```vue
46
+ <script setup lang="ts">
47
+ const open = ref(false);
48
+ const toast = useToast();
49
+
50
+ const commands = [
51
+ { label: "Add member", value: "add" },
52
+ { label: "Copy invite link", value: "copy" },
53
+ { label: "Open settings", value: "settings" },
54
+ { label: "Remove workspace", value: "remove" },
55
+ ];
56
+
57
+ const icons: Record<string, "plus" | "copy" | "settings" | "trash"> = {
58
+ add: "plus",
59
+ copy: "copy",
60
+ settings: "settings",
61
+ remove: "trash",
62
+ };
63
+ </script>
64
+
65
+ <template>
66
+ <UiButton variant="secondary" @click="open = true">Open palette</UiButton>
67
+
68
+ <UiCommandPalette
69
+ v-model:open="open"
70
+ :items="commands"
71
+ placeholder="What do you want to do?"
72
+ @select="(value) => toast.info(`Ran ${value}`)"
73
+ >
74
+ <template #item="{ item }">
75
+ <Icon :name="icons[item.value] ?? 'file'" :size="14" />
76
+ <span data-part="command-palette-option-label">{{ item.label }}</span>
77
+ </template>
78
+
79
+ <template #empty="{ query }">Nothing matches “{{ query }}”.</template>
80
+ </UiCommandPalette>
81
+ </template>
82
+ ```
83
+
84
+ ## API
85
+
86
+ | Prop | Type | Default | Description |
87
+ | --- | --- | --- | --- |
88
+ | `items` | `CommandItem<T>[]` | `[]` | Commands to search, in order. Those sharing a `group` are listed together under its heading. |
89
+ | `label` | `string` | — | Accessible name for the dialog and its list. Defaults to the `commandPalette` translation. |
90
+ | `placeholder` | `string` | — | Search field placeholder. Defaults to the `searchCommands` translation. |
91
+ | `shortcut` | `string` | — | Chord that opens and closes the palette from anywhere on the page, e.g. "mod+k". |
92
+ | `open` | `boolean` | `false` | Whether the palette is open. |
93
+
94
+ | Event | Payload | Description |
95
+ | --- | --- | --- |
96
+ | `select` | `[value: T]` | A command was chosen. The palette closes first. |
97
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
98
+
99
+ | Slot | Props | Description |
100
+ | --- | --- | --- |
101
+ | `item` | `{ item: CommandItem<T>; active: boolean; }` | Command content, replacing the label and shortcut. |
102
+ | `empty` | `{ query: string; }` | Shown when nothing matches. |
103
+
104
+ Types:
105
+
106
+ ```ts
107
+ export interface CommandItem<T extends SelectValue = SelectValue> extends SelectOption<T> {
108
+ /** Section heading. Items sharing one are listed together, in order of first appearance. */
109
+ group?: string;
110
+ /** Shortcut shown beside the label, written like `Kbd`'s `keys`, e.g. "mod+shift+s". */
111
+ shortcut?: string;
112
+ /** Extra words that match the query without being shown, e.g. synonyms. */
113
+ keywords?: string[];
114
+ }
115
+
116
+ export type SelectValue = string | number;
117
+
118
+ export interface SelectOption<T extends SelectValue = SelectValue> {
119
+ label: string;
120
+ value: T;
121
+ disabled?: boolean;
122
+ }
123
+ ```
124
+
125
+ ## Styling
126
+
127
+ The palette is a [Dialog](/components/dialog), so the dialog's parts are listed too. The highlighted command has `data-command-active`.
128
+
129
+ - Parts (`[data-part="…"]`): `command-palette`, `command-palette-input`, `command-palette-list`, `command-palette-group`, `command-palette-heading`, `command-palette-option`, `command-palette-option-label`, `command-palette-empty`, `dialog`, `dialog-panel`, `dialog-header`, `dialog-header-text`, `dialog-title`, `dialog-description`, `dialog-close`, `dialog-body`, `dialog-footer`, `kbd`, `key`, `kbd-label`, `visually-hidden`
130
+ - State attributes: `data-command-active`, `data-dialog-size`, `data-dialog-flush`, `data-kbd-size`
131
+
132
+ ## Keyboard
133
+
134
+ | Keys | Action |
135
+ | ---------- | ------------------------------------------------------- |
136
+ | `shortcut` | Open or close, from anywhere on the page |
137
+ | Typing | Filter the commands |
138
+ | `↓` / `↑` | Move between commands, skipping disabled ones, wrapping |
139
+ | `Enter` | Run the active command and close |
140
+ | `Escape` | Close |
141
+
142
+ ## Accessibility
143
+
144
+ - Focus stays in the search field; screen readers follow the highlighted command through `aria-activedescendant`.
145
+ - Commands sit in a `role="listbox"`, each group named by its heading.
146
+ - While typing, a hidden status announces the number of matches, or “No results”.
147
+ - It's a modal dialog: the page behind is inert, and focus returns to what had it before the palette opened.
148
+ - The palette starts empty and unfiltered each time it opens.
@@ -160,7 +160,7 @@ form.items = form.items.filter((_, i) => i !== index);
160
160
  | `mapError` | Turns a thrown error into field errors, e.g. a 422 from your API. |
161
161
  | `onError` | Called with any thrown error. Without it, non-field errors rethrow. |
162
162
  | `formRef` | The `<form>`; enables blur/input tracking and focusing the first invalid field. |
163
- | `validateOn` | When a field's error appears: `"blur"` (default), `"input"` or `"submit"`. |
163
+ | `validateOn` | When a field's error appears: `"submit"` (default), `"blur"` or `"input"`. |
164
164
 
165
165
  ## Returns
166
166
 
package/dist/index.d.ts CHANGED
@@ -1,53 +1,55 @@
1
1
  import _default from "./components/accordion/Accordion.vue.js";
2
2
  import _default$1 from "./components/accordion/AccordionItem.vue.js";
3
- import { AvatarItem, AvatarSize, BreadcrumbItem, ButtonSize, ButtonType, ButtonVariant, LinkTarget, LinkTo, MenuEntry, MenuItem, MenuSeparator, Platform, SelectOption, SelectValue, TableColumn, TableSort, Toast, ToastAction, ToastTone } from "./types.js";
3
+ import { AvatarItem, AvatarSize, BreadcrumbItem, ButtonSize, ButtonType, ButtonVariant, CommandItem, LinkTarget, LinkTo, MenuEntry, MenuItem, MenuSeparator, Platform, SelectOption, SelectValue, TableColumn, TableSort, Toast, ToastAction, ToastTone } from "./types.js";
4
4
  import _default$2 from "./components/avatar/Avatar.vue.js";
5
5
  import _default$3 from "./components/avatar/AvatarGroup.vue.js";
6
6
  import _default$4 from "./components/breadcrumbs/Breadcrumbs.vue.js";
7
7
  import _default$5 from "./components/button/Button.vue.js";
8
- import _default$13 from "./components/button/IconButton.vue.js";
8
+ import _default$14 from "./components/button/IconButton.vue.js";
9
9
  import _default$6 from "./components/checkbox/Checkbox.vue.js";
10
10
  import _default$7 from "./components/checkbox-group/CheckboxGroup.vue.js";
11
11
  import { ComboboxFilter, useCombobox } from "./composables/use-combobox.js";
12
12
  import _default$8 from "./components/combobox/Combobox.vue.js";
13
- import _default$9 from "./components/dialog/ConfirmDialog.vue.js";
14
- import _default$10 from "./components/context-menu/ContextMenu.vue.js";
15
- import _default$11 from "./components/dialog/Dialog.vue.js";
16
- import _default$12 from "./components/fieldset/Fieldset.vue.js";
17
- import _default$14 from "./components/input/Input.vue.js";
18
- import _default$15 from "./components/kbd/Kbd.vue.js";
19
- import _default$16 from "./components/menu/Menu.vue.js";
20
- import _default$17 from "./components/otp-input/OtpInput.vue.js";
21
- import _default$18 from "./components/pagination/Pagination.vue.js";
22
- import _default$19 from "./components/password-input/PasswordInput.vue.js";
23
- import _default$20 from "./components/popover/Popover.vue.js";
24
- import _default$21 from "./components/progress/Progress.vue.js";
25
- import _default$22 from "./components/radio-group/RadioGroup.vue.js";
26
- import _default$23 from "./components/segmented/Segmented.vue.js";
27
- import _default$24 from "./components/select/Select.vue.js";
28
- import _default$25 from "./components/slider/Slider.vue.js";
29
- import _default$26 from "./components/spin-button/SpinButton.vue.js";
30
- import _default$27 from "./components/split-button/SplitButton.vue.js";
31
- import _default$28 from "./components/switch/Switch.vue.js";
32
- import _default$29 from "./components/table/Table.vue.js";
33
- import _default$30 from "./components/tabs/Tabs.vue.js";
34
- import _default$31 from "./components/tag-input/TagInput.vue.js";
35
- import _default$32 from "./components/textarea/Textarea.vue.js";
36
- import _default$33 from "./components/toast/ToastItem.vue.js";
37
- import _default$34 from "./components/toast/ToastViewport.vue.js";
38
- import _default$35 from "./components/toggle/Toggle.vue.js";
39
- import _default$36 from "./components/toggle-group/ToggleGroup.vue.js";
40
- import _default$37 from "./components/toolbar/Toolbar.vue.js";
41
- import _default$38 from "./components/tooltip/Tooltip.vue.js";
42
- import _default$39 from "./components/visually-hidden/VisuallyHidden.vue.js";
13
+ import _default$9 from "./components/command-palette/CommandPalette.vue.js";
14
+ import _default$10 from "./components/dialog/ConfirmDialog.vue.js";
15
+ import _default$11 from "./components/context-menu/ContextMenu.vue.js";
16
+ import _default$12 from "./components/dialog/Dialog.vue.js";
17
+ import _default$13 from "./components/fieldset/Fieldset.vue.js";
18
+ import _default$15 from "./components/input/Input.vue.js";
19
+ import _default$16 from "./components/kbd/Kbd.vue.js";
20
+ import _default$17 from "./components/menu/Menu.vue.js";
21
+ import _default$18 from "./components/otp-input/OtpInput.vue.js";
22
+ import _default$19 from "./components/pagination/Pagination.vue.js";
23
+ import _default$20 from "./components/password-input/PasswordInput.vue.js";
24
+ import _default$21 from "./components/popover/Popover.vue.js";
25
+ import _default$22 from "./components/progress/Progress.vue.js";
26
+ import _default$23 from "./components/radio-group/RadioGroup.vue.js";
27
+ import _default$24 from "./components/segmented/Segmented.vue.js";
28
+ import _default$25 from "./components/select/Select.vue.js";
29
+ import _default$26 from "./components/slider/Slider.vue.js";
30
+ import _default$27 from "./components/spin-button/SpinButton.vue.js";
31
+ import _default$28 from "./components/split-button/SplitButton.vue.js";
32
+ import _default$29 from "./components/switch/Switch.vue.js";
33
+ import _default$30 from "./components/table/Table.vue.js";
34
+ import _default$31 from "./components/tabs/Tabs.vue.js";
35
+ import _default$32 from "./components/tag-input/TagInput.vue.js";
36
+ import _default$33 from "./components/textarea/Textarea.vue.js";
37
+ import _default$34 from "./components/toast/ToastItem.vue.js";
38
+ import _default$35 from "./components/toast/ToastViewport.vue.js";
39
+ import _default$36 from "./components/toggle/Toggle.vue.js";
40
+ import _default$37 from "./components/toggle-group/ToggleGroup.vue.js";
41
+ import _default$38 from "./components/toolbar/Toolbar.vue.js";
42
+ import _default$39 from "./components/tooltip/Tooltip.vue.js";
43
+ import _default$40 from "./components/visually-hidden/VisuallyHidden.vue.js";
43
44
  import { UiTranslations, UiTranslationsInput, defaultTranslations } from "./translations.js";
44
45
  import { UI_CONFIG_KEY, UiConfig, UiOptions, createUi, useTranslations, useUiConfig } from "./config.js";
45
46
  import { ACCORDION_KEY, AccordionContext, useAccordionItem } from "./composables/use-accordion.js";
47
+ import { CommandSection, useCommandPalette } from "./composables/use-command-palette.js";
46
48
  import { FieldSource, useField } from "./composables/use-field.js";
47
49
  import { StandardSchemaV1 } from "./composables/internal/standard-schema.js";
48
50
  import { FormErrors, FormValues, UseFormOptions, useForm } from "./composables/use-form.js";
49
51
  import { isMenuSeparator, useMenu } from "./composables/use-menu.js";
50
- import { KeyCap, parseChord, platformFrom, usePlatform } from "./composables/use-platform.js";
52
+ import { KeyCap, matchesChord, parseChord, platformFrom, usePlatform } from "./composables/use-platform.js";
51
53
  import { firstFocusable, useAnchor, usePopoverState } from "./composables/use-popover.js";
52
54
  import { useRovingSelection } from "./composables/use-roving-selection.js";
53
55
  import { useSelect } from "./composables/use-select.js";
@@ -59,4 +61,4 @@ declare module "vue" {
59
61
  function initDirectivesForSSR(): void;
60
62
  }
61
63
  //#endregion
62
- export { ACCORDION_KEY, _default as Accordion, type AccordionContext, _default$1 as AccordionItem, _default$2 as Avatar, _default$3 as AvatarGroup, type AvatarItem, type AvatarSize, type BreadcrumbItem, _default$4 as Breadcrumbs, _default$5 as Button, type ButtonSize, type ButtonType, type ButtonVariant, _default$6 as Checkbox, _default$7 as CheckboxGroup, _default$8 as Combobox, type ComboboxFilter, _default$9 as ConfirmDialog, _default$10 as ContextMenu, _default$11 as Dialog, type FieldSource, _default$12 as Fieldset, type FormErrors, type FormValues, _default$13 as IconButton, _default$14 as Input, _default$15 as Kbd, type KeyCap, type LinkTarget, type LinkTo, _default$16 as Menu, type MenuEntry, type MenuItem, type MenuSeparator, _default$17 as OtpInput, _default$18 as Pagination, _default$19 as PasswordInput, type Platform, _default$20 as Popover, _default$21 as Progress, _default$22 as RadioGroup, _default$23 as Segmented, _default$24 as Select, type SelectOption, type SelectValue, _default$25 as Slider, _default$26 as SpinButton, _default$27 as SplitButton, type StandardSchemaV1, _default$28 as Switch, TOASTER_KEY, _default$29 as Table, type TableColumn, type TableSort, _default$30 as Tabs, _default$31 as TagInput, _default$32 as Textarea, type Toast, type ToastAction, _default$33 as ToastItem, type ToastOptions, type ToastTone, _default$34 as ToastViewport, type Toaster, _default$35 as Toggle, _default$36 as ToggleGroup, _default$37 as Toolbar, _default$38 as Tooltip, UI_CONFIG_KEY, type UiConfig, type UiOptions, type UiTranslations, type UiTranslationsInput, type UseFormOptions, _default$39 as VisuallyHidden, createToaster, createUi, defaultTranslations, firstFocusable, isMenuSeparator, parseChord, platformFrom, useAccordionItem, useAnchor, useCombobox, useField, useForm, useMenu, usePlatform, usePopoverState, useRovingSelection, useSelect, useSlideIndicator, useToast, useTranslations, useUiConfig };
64
+ export { ACCORDION_KEY, _default as Accordion, type AccordionContext, _default$1 as AccordionItem, _default$2 as Avatar, _default$3 as AvatarGroup, type AvatarItem, type AvatarSize, type BreadcrumbItem, _default$4 as Breadcrumbs, _default$5 as Button, type ButtonSize, type ButtonType, type ButtonVariant, _default$6 as Checkbox, _default$7 as CheckboxGroup, _default$8 as Combobox, type ComboboxFilter, type CommandItem, _default$9 as CommandPalette, type CommandSection, _default$10 as ConfirmDialog, _default$11 as ContextMenu, _default$12 as Dialog, type FieldSource, _default$13 as Fieldset, type FormErrors, type FormValues, _default$14 as IconButton, _default$15 as Input, _default$16 as Kbd, type KeyCap, type LinkTarget, type LinkTo, _default$17 as Menu, type MenuEntry, type MenuItem, type MenuSeparator, _default$18 as OtpInput, _default$19 as Pagination, _default$20 as PasswordInput, type Platform, _default$21 as Popover, _default$22 as Progress, _default$23 as RadioGroup, _default$24 as Segmented, _default$25 as Select, type SelectOption, type SelectValue, _default$26 as Slider, _default$27 as SpinButton, _default$28 as SplitButton, type StandardSchemaV1, _default$29 as Switch, TOASTER_KEY, _default$30 as Table, type TableColumn, type TableSort, _default$31 as Tabs, _default$32 as TagInput, _default$33 as Textarea, type Toast, type ToastAction, _default$34 as ToastItem, type ToastOptions, type ToastTone, _default$35 as ToastViewport, type Toaster, _default$36 as Toggle, _default$37 as ToggleGroup, _default$38 as Toolbar, _default$39 as Tooltip, UI_CONFIG_KEY, type UiConfig, type UiOptions, type UiTranslations, type UiTranslationsInput, type UseFormOptions, _default$40 as VisuallyHidden, createToaster, createUi, defaultTranslations, firstFocusable, isMenuSeparator, matchesChord, parseChord, platformFrom, useAccordionItem, useAnchor, useCombobox, useCommandPalette, useField, useForm, useMenu, usePlatform, usePopoverState, useRovingSelection, useSelect, useSlideIndicator, useToast, useTranslations, useUiConfig };
package/dist/index.js CHANGED
@@ -8,51 +8,53 @@ import { UI_CONFIG_KEY, createUi, useTranslations, useUiConfig } from "./config.
8
8
  import _sfc_main$3 from "./components/avatar/AvatarGroup.js";
9
9
  import _sfc_main$4 from "./components/breadcrumbs/Breadcrumbs.js";
10
10
  import _sfc_main$5 from "./components/button/Button.js";
11
- import _sfc_main$13 from "./components/button/IconButton.js";
11
+ import _sfc_main$14 from "./components/button/IconButton.js";
12
12
  import { useField } from "./composables/use-field.js";
13
13
  import _sfc_main$6 from "./components/checkbox/Checkbox.js";
14
- import _sfc_main$12 from "./components/fieldset/Fieldset.js";
14
+ import _sfc_main$13 from "./components/fieldset/Fieldset.js";
15
15
  import _sfc_main$7 from "./components/checkbox-group/CheckboxGroup.js";
16
16
  import { useCombobox } from "./composables/use-combobox.js";
17
17
  import { firstFocusable, useAnchor, usePopoverState } from "./composables/use-popover.js";
18
18
  import _sfc_main$8 from "./components/combobox/Combobox.js";
19
- import _sfc_main$11 from "./components/dialog/Dialog.js";
20
- import _sfc_main$9 from "./components/dialog/ConfirmDialog.js";
19
+ import { matchesChord, parseChord, platformFrom, usePlatform } from "./composables/use-platform.js";
20
+ import { useCommandPalette } from "./composables/use-command-palette.js";
21
+ import _sfc_main$12 from "./components/dialog/Dialog.js";
22
+ import _sfc_main$16 from "./components/kbd/Kbd.js";
23
+ import _sfc_main$40 from "./components/visually-hidden/VisuallyHidden.js";
24
+ import _sfc_main$9 from "./components/command-palette/CommandPalette.js";
25
+ import _sfc_main$10 from "./components/dialog/ConfirmDialog.js";
21
26
  import { isMenuSeparator, useMenu } from "./composables/use-menu.js";
22
- import _sfc_main$10 from "./components/context-menu/ContextMenu.js";
23
- import _sfc_main$14 from "./components/input/Input.js";
24
- import { parseChord, platformFrom, usePlatform } from "./composables/use-platform.js";
25
- import _sfc_main$15 from "./components/kbd/Kbd.js";
26
- import _sfc_main$16 from "./components/menu/Menu.js";
27
- import _sfc_main$17 from "./components/otp-input/OtpInput.js";
28
- import _sfc_main$18 from "./components/pagination/Pagination.js";
29
- import _sfc_main$19 from "./components/password-input/PasswordInput.js";
30
- import _sfc_main$20 from "./components/popover/Popover.js";
31
- import _sfc_main$21 from "./components/progress/Progress.js";
27
+ import _sfc_main$11 from "./components/context-menu/ContextMenu.js";
28
+ import _sfc_main$15 from "./components/input/Input.js";
29
+ import _sfc_main$17 from "./components/menu/Menu.js";
30
+ import _sfc_main$18 from "./components/otp-input/OtpInput.js";
31
+ import _sfc_main$19 from "./components/pagination/Pagination.js";
32
+ import _sfc_main$20 from "./components/password-input/PasswordInput.js";
33
+ import _sfc_main$21 from "./components/popover/Popover.js";
34
+ import _sfc_main$22 from "./components/progress/Progress.js";
32
35
  import { useRovingSelection } from "./composables/use-roving-selection.js";
33
- import _sfc_main$22 from "./components/radio-group/RadioGroup.js";
36
+ import _sfc_main$23 from "./components/radio-group/RadioGroup.js";
34
37
  import { useSlideIndicator } from "./composables/use-slide-indicator.js";
35
- import _sfc_main$23 from "./components/segmented/Segmented.js";
38
+ import _sfc_main$24 from "./components/segmented/Segmented.js";
36
39
  import { useSelect } from "./composables/use-select.js";
37
- import _sfc_main$24 from "./components/select/Select.js";
38
- import _sfc_main$25 from "./components/slider/Slider.js";
39
- import _sfc_main$26 from "./components/spin-button/SpinButton.js";
40
- import _sfc_main$27 from "./components/split-button/SplitButton.js";
41
- import _sfc_main$28 from "./components/switch/Switch.js";
42
- import _sfc_main$29 from "./components/table/Table.js";
43
- import _sfc_main$30 from "./components/tabs/Tabs.js";
44
- import _sfc_main$31 from "./components/tag-input/TagInput.js";
45
- import _sfc_main$32 from "./components/textarea/Textarea.js";
46
- import _sfc_main$33 from "./components/toast/ToastItem.js";
47
- import _sfc_main$34 from "./components/toast/ToastViewport.js";
48
- import _sfc_main$35 from "./components/toggle/Toggle.js";
49
- import _sfc_main$36 from "./components/toggle-group/ToggleGroup.js";
50
- import _sfc_main$37 from "./components/toolbar/Toolbar.js";
51
- import _sfc_main$38 from "./components/tooltip/Tooltip.js";
52
- import _sfc_main$39 from "./components/visually-hidden/VisuallyHidden.js";
40
+ import _sfc_main$25 from "./components/select/Select.js";
41
+ import _sfc_main$26 from "./components/slider/Slider.js";
42
+ import _sfc_main$27 from "./components/spin-button/SpinButton.js";
43
+ import _sfc_main$28 from "./components/split-button/SplitButton.js";
44
+ import _sfc_main$29 from "./components/switch/Switch.js";
45
+ import _sfc_main$30 from "./components/table/Table.js";
46
+ import _sfc_main$31 from "./components/tabs/Tabs.js";
47
+ import _sfc_main$32 from "./components/tag-input/TagInput.js";
48
+ import _sfc_main$33 from "./components/textarea/Textarea.js";
49
+ import _sfc_main$34 from "./components/toast/ToastItem.js";
50
+ import _sfc_main$35 from "./components/toast/ToastViewport.js";
51
+ import _sfc_main$36 from "./components/toggle/Toggle.js";
52
+ import _sfc_main$37 from "./components/toggle-group/ToggleGroup.js";
53
+ import _sfc_main$38 from "./components/toolbar/Toolbar.js";
54
+ import _sfc_main$39 from "./components/tooltip/Tooltip.js";
53
55
  import { useForm } from "./composables/use-form.js";
54
56
  import { initDirectivesForSSR } from "vue";
55
57
  //#region src/index.ts
56
58
  initDirectivesForSSR();
57
59
  //#endregion
58
- export { ACCORDION_KEY, _sfc_main as Accordion, _sfc_main$1 as AccordionItem, _sfc_main$2 as Avatar, _sfc_main$3 as AvatarGroup, _sfc_main$4 as Breadcrumbs, _sfc_main$5 as Button, _sfc_main$6 as Checkbox, _sfc_main$7 as CheckboxGroup, _sfc_main$8 as Combobox, _sfc_main$9 as ConfirmDialog, _sfc_main$10 as ContextMenu, _sfc_main$11 as Dialog, _sfc_main$12 as Fieldset, _sfc_main$13 as IconButton, _sfc_main$14 as Input, _sfc_main$15 as Kbd, _sfc_main$16 as Menu, _sfc_main$17 as OtpInput, _sfc_main$18 as Pagination, _sfc_main$19 as PasswordInput, _sfc_main$20 as Popover, _sfc_main$21 as Progress, _sfc_main$22 as RadioGroup, _sfc_main$23 as Segmented, _sfc_main$24 as Select, _sfc_main$25 as Slider, _sfc_main$26 as SpinButton, _sfc_main$27 as SplitButton, _sfc_main$28 as Switch, TOASTER_KEY, _sfc_main$29 as Table, _sfc_main$30 as Tabs, _sfc_main$31 as TagInput, _sfc_main$32 as Textarea, _sfc_main$33 as ToastItem, _sfc_main$34 as ToastViewport, _sfc_main$35 as Toggle, _sfc_main$36 as ToggleGroup, _sfc_main$37 as Toolbar, _sfc_main$38 as Tooltip, UI_CONFIG_KEY, _sfc_main$39 as VisuallyHidden, createToaster, createUi, defaultTranslations, firstFocusable, isMenuSeparator, parseChord, platformFrom, useAccordionItem, useAnchor, useCombobox, useField, useForm, useMenu, usePlatform, usePopoverState, useRovingSelection, useSelect, useSlideIndicator, useToast, useTranslations, useUiConfig };
60
+ export { ACCORDION_KEY, _sfc_main as Accordion, _sfc_main$1 as AccordionItem, _sfc_main$2 as Avatar, _sfc_main$3 as AvatarGroup, _sfc_main$4 as Breadcrumbs, _sfc_main$5 as Button, _sfc_main$6 as Checkbox, _sfc_main$7 as CheckboxGroup, _sfc_main$8 as Combobox, _sfc_main$9 as CommandPalette, _sfc_main$10 as ConfirmDialog, _sfc_main$11 as ContextMenu, _sfc_main$12 as Dialog, _sfc_main$13 as Fieldset, _sfc_main$14 as IconButton, _sfc_main$15 as Input, _sfc_main$16 as Kbd, _sfc_main$17 as Menu, _sfc_main$18 as OtpInput, _sfc_main$19 as Pagination, _sfc_main$20 as PasswordInput, _sfc_main$21 as Popover, _sfc_main$22 as Progress, _sfc_main$23 as RadioGroup, _sfc_main$24 as Segmented, _sfc_main$25 as Select, _sfc_main$26 as Slider, _sfc_main$27 as SpinButton, _sfc_main$28 as SplitButton, _sfc_main$29 as Switch, TOASTER_KEY, _sfc_main$30 as Table, _sfc_main$31 as Tabs, _sfc_main$32 as TagInput, _sfc_main$33 as Textarea, _sfc_main$34 as ToastItem, _sfc_main$35 as ToastViewport, _sfc_main$36 as Toggle, _sfc_main$37 as ToggleGroup, _sfc_main$38 as Toolbar, _sfc_main$39 as Tooltip, UI_CONFIG_KEY, _sfc_main$40 as VisuallyHidden, createToaster, createUi, defaultTranslations, firstFocusable, isMenuSeparator, matchesChord, parseChord, platformFrom, useAccordionItem, useAnchor, useCombobox, useCommandPalette, useField, useForm, useMenu, usePlatform, usePopoverState, useRovingSelection, useSelect, useSlideIndicator, useToast, useTranslations, useUiConfig };
@@ -1,6 +1,6 @@
1
1
  //#region src/nuxt/module.d.ts
2
2
  /** Auto-registered as `<{prefix}{name}>`. A test keeps it in step with `src/index.ts`. */
3
- export declare const COMPONENTS: readonly ["Accordion", "AccordionItem", "Avatar", "AvatarGroup", "Breadcrumbs", "Button", "Checkbox", "CheckboxGroup", "Combobox", "ConfirmDialog", "ContextMenu", "Dialog", "Fieldset", "IconButton", "Input", "Kbd", "Menu", "OtpInput", "Pagination", "PasswordInput", "Popover", "Progress", "RadioGroup", "Segmented", "Select", "Slider", "SpinButton", "SplitButton", "Switch", "Table", "Tabs", "TagInput", "Textarea", "ToastItem", "ToastViewport", "Toggle", "ToggleGroup", "Toolbar", "Tooltip", "VisuallyHidden"];
3
+ export declare const COMPONENTS: readonly ["Accordion", "AccordionItem", "Avatar", "AvatarGroup", "Breadcrumbs", "Button", "Checkbox", "CheckboxGroup", "Combobox", "CommandPalette", "ConfirmDialog", "ContextMenu", "Dialog", "Fieldset", "IconButton", "Input", "Kbd", "Menu", "OtpInput", "Pagination", "PasswordInput", "Popover", "Progress", "RadioGroup", "Segmented", "Select", "Slider", "SpinButton", "SplitButton", "Switch", "Table", "Tabs", "TagInput", "Textarea", "ToastItem", "ToastViewport", "Toggle", "ToggleGroup", "Toolbar", "Tooltip", "VisuallyHidden"];
4
4
  export declare const COMPOSABLES: readonly ["useField", "useForm", "useToast"];
5
5
  export interface ModuleOptions {
6
6
  /** Auto-imported component prefix: `Ui` gives `<UiButton>`. */
@@ -13,6 +13,7 @@ const COMPONENTS = [
13
13
  "Checkbox",
14
14
  "CheckboxGroup",
15
15
  "Combobox",
16
+ "CommandPalette",
16
17
  "ConfirmDialog",
17
18
  "ContextMenu",
18
19
  "Dialog",
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.2.2";
2
+ var version = "0.3.0";
3
3
  //#endregion
4
4
  export { version };
@@ -18,6 +18,10 @@ export interface UiTranslations {
18
18
  menu: string;
19
19
  /** ContextMenu's name, when `label` isn't set. */
20
20
  contextMenu: string;
21
+ /** CommandPalette's name, when `label` isn't set. */
22
+ commandPalette: string;
23
+ /** CommandPalette's search field, when `placeholder` isn't set. */
24
+ searchCommands: string;
21
25
  /** SpinButton's step buttons. */
22
26
  decrease: string;
23
27
  increase: string;
@@ -31,11 +35,11 @@ export interface UiTranslations {
31
35
  removeItem: (label: string) => string;
32
36
  /** Combobox with `multiple`: what's picked, part of the input's description. */
33
37
  selectedItems: (labels: string[]) => string;
34
- /** Combobox with nothing matching. */
38
+ /** Combobox or CommandPalette with nothing matching. */
35
39
  noResults: string;
36
40
  /** Combobox with `creatable`, offering to add the typed text. */
37
41
  createOption: (query: string) => string;
38
- /** Combobox's spoken result count while filtering. */
42
+ /** Combobox or CommandPalette's spoken result count while filtering. */
39
43
  resultCount: (count: number) => string;
40
44
  /** Combobox while `loading`. */
41
45
  loading: string;
@@ -7,6 +7,8 @@ const defaultTranslations = {
7
7
  notifications: "Notifications",
8
8
  menu: "Menu",
9
9
  contextMenu: "Context menu",
10
+ commandPalette: "Command palette",
11
+ searchCommands: "Search commands…",
10
12
  decrease: "Decrease",
11
13
  increase: "Increase",
12
14
  optional: "(optional)",
package/dist/types.d.ts CHANGED
@@ -15,6 +15,14 @@ export interface MenuSeparator {
15
15
  separator: true;
16
16
  }
17
17
  export type MenuEntry<T extends SelectValue = SelectValue> = MenuItem<T> | MenuSeparator;
18
+ export interface CommandItem<T extends SelectValue = SelectValue> extends SelectOption<T> {
19
+ /** Section heading. Items sharing one are listed together, in order of first appearance. */
20
+ group?: string;
21
+ /** Shortcut shown beside the label, written like `Kbd`'s `keys`, e.g. "mod+shift+s". */
22
+ shortcut?: string;
23
+ /** Extra words that match the query without being shown, e.g. synonyms. */
24
+ keywords?: string[];
25
+ }
18
26
  export interface TableColumn<T> {
19
27
  key: string;
20
28
  header: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humanonlyweb/ui",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Headless, accessible, SSR-safe Vue components.",
5
5
  "keywords": [
6
6
  "a11y",