@zazz-ui/core 0.1.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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/sri.json +75 -0
- package/dist/zazz.css +1 -0
- package/dist/zazz.js +1 -0
- package/examples/about.html +590 -0
- package/examples/components.html +1040 -0
- package/examples/forms.html +511 -0
- package/examples/index.html +268 -0
- package/examples/layout.html +320 -0
- package/examples/products.html +846 -0
- package/examples/responsive.html +339 -0
- package/package.json +85 -0
- package/src/base/_layers.css +12 -0
- package/src/base/_layout.css +568 -0
- package/src/base/_reset.css +515 -0
- package/src/base/_typography.css +495 -0
- package/src/base/_utilities.css +6628 -0
- package/src/base/_variables.css +682 -0
- package/src/base/_view-transitions.css +103 -0
- package/src/base/command-score.d.ts +12 -0
- package/src/base/command-score.d.ts.map +1 -0
- package/src/base/command-score.js +151 -0
- package/src/base/command-score.ts +192 -0
- package/src/base/dialog-lifecycle.d.ts +11 -0
- package/src/base/dialog-lifecycle.d.ts.map +1 -0
- package/src/base/dialog-lifecycle.js +65 -0
- package/src/base/dialog-lifecycle.ts +80 -0
- package/src/base/embla.d.ts +90 -0
- package/src/base/embla.d.ts.map +1 -0
- package/src/base/embla.js +643 -0
- package/src/base/embla.ts +791 -0
- package/src/base/hotkeys.d.ts +82 -0
- package/src/base/hotkeys.d.ts.map +1 -0
- package/src/base/hotkeys.js +141 -0
- package/src/base/hotkeys.ts +195 -0
- package/src/base/navigation.d.ts +2 -0
- package/src/base/navigation.d.ts.map +1 -0
- package/src/base/navigation.js +136 -0
- package/src/base/navigation.ts +151 -0
- package/src/base/reveal.d.ts +80 -0
- package/src/base/reveal.d.ts.map +1 -0
- package/src/base/reveal.js +305 -0
- package/src/base/reveal.ts +379 -0
- package/src/base/signals.d.ts +89 -0
- package/src/base/signals.d.ts.map +1 -0
- package/src/base/signals.js +134 -0
- package/src/base/signals.ts +164 -0
- package/src/base/typeahead.d.ts +105 -0
- package/src/base/typeahead.d.ts.map +1 -0
- package/src/base/typeahead.js +411 -0
- package/src/base/typeahead.ts +500 -0
- package/src/base/utils.d.ts +56 -0
- package/src/base/utils.d.ts.map +1 -0
- package/src/base/utils.js +88 -0
- package/src/base/utils.ts +98 -0
- package/src/base/zazz-element.d.ts +44 -0
- package/src/base/zazz-element.d.ts.map +1 -0
- package/src/base/zazz-element.js +59 -0
- package/src/base/zazz-element.ts +73 -0
- package/src/globals.d.ts +148 -0
- package/src/head.d.ts +95 -0
- package/src/head.d.ts.map +1 -0
- package/src/head.js +311 -0
- package/src/head.ts +433 -0
- package/src/index.css +71 -0
- package/src/index.d.ts +36 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +35 -0
- package/src/index.ts +36 -0
- package/src/manifest.d.ts +90 -0
- package/src/manifest.d.ts.map +1 -0
- package/src/manifest.js +614 -0
- package/src/manifest.ts +667 -0
- package/src/primitives/accordion/accordion.css +104 -0
- package/src/primitives/accordion/accordion.html +69 -0
- package/src/primitives/alert-dialog/alert-dialog.css +38 -0
- package/src/primitives/alert-dialog/alert-dialog.html +53 -0
- package/src/primitives/autocomplete/autocomplete-groups.html +77 -0
- package/src/primitives/autocomplete/autocomplete.css +114 -0
- package/src/primitives/autocomplete/autocomplete.d.ts +30 -0
- package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -0
- package/src/primitives/autocomplete/autocomplete.html +66 -0
- package/src/primitives/autocomplete/autocomplete.js +41 -0
- package/src/primitives/autocomplete/autocomplete.ts +46 -0
- package/src/primitives/avatar/avatar.html +44 -0
- package/src/primitives/badge/badge-icon.html +36 -0
- package/src/primitives/badge/badge.css +251 -0
- package/src/primitives/badge/badge.html +7 -0
- package/src/primitives/breadcrumbs/breadcrumbs.html +9 -0
- package/src/primitives/button/button-icon-only.html +84 -0
- package/src/primitives/button/button-icon.html +82 -0
- package/src/primitives/button/button.css +319 -0
- package/src/primitives/button/button.html +8 -0
- package/src/primitives/button-group/button-group-vertical.html +6 -0
- package/src/primitives/button-group/button-group.css +94 -0
- package/src/primitives/button-group/button-group.html +64 -0
- package/src/primitives/card/card-subgrid.html +118 -0
- package/src/primitives/card/card.html +53 -0
- package/src/primitives/carousel/carousel.css +61 -0
- package/src/primitives/carousel/carousel.d.ts +16 -0
- package/src/primitives/carousel/carousel.d.ts.map +1 -0
- package/src/primitives/carousel/carousel.html +315 -0
- package/src/primitives/carousel/carousel.js +73 -0
- package/src/primitives/carousel/carousel.ts +84 -0
- package/src/primitives/checkbox/checkbox-tasklist.html +71 -0
- package/src/primitives/checkbox/checkbox.css +82 -0
- package/src/primitives/checkbox/checkbox.d.ts +21 -0
- package/src/primitives/checkbox/checkbox.d.ts.map +1 -0
- package/src/primitives/checkbox/checkbox.html +17 -0
- package/src/primitives/checkbox/checkbox.js +190 -0
- package/src/primitives/checkbox/checkbox.ts +219 -0
- package/src/primitives/combobox/combobox-multiselect.html +91 -0
- package/src/primitives/combobox/combobox.css +307 -0
- package/src/primitives/combobox/combobox.d.ts +100 -0
- package/src/primitives/combobox/combobox.d.ts.map +1 -0
- package/src/primitives/combobox/combobox.html +73 -0
- package/src/primitives/combobox/combobox.js +503 -0
- package/src/primitives/combobox/combobox.ts +559 -0
- package/src/primitives/command/command-actions.d.ts +31 -0
- package/src/primitives/command/command-actions.d.ts.map +1 -0
- package/src/primitives/command/command-actions.html +89 -0
- package/src/primitives/command/command-actions.js +70 -0
- package/src/primitives/command/command-actions.ts +77 -0
- package/src/primitives/command/command-dialog.html +77 -0
- package/src/primitives/command/command.css +151 -0
- package/src/primitives/command/command.d.ts +52 -0
- package/src/primitives/command/command.d.ts.map +1 -0
- package/src/primitives/command/command.html +119 -0
- package/src/primitives/command/command.js +146 -0
- package/src/primitives/command/command.ts +157 -0
- package/src/primitives/dialog/dialog-with-form.html +200 -0
- package/src/primitives/dialog/dialog.css +229 -0
- package/src/primitives/dialog/dialog.html +90 -0
- package/src/primitives/fields/fields.css +278 -0
- package/src/primitives/input/input-icon-leading.html +19 -0
- package/src/primitives/input/input-icon-trailing.html +18 -0
- package/src/primitives/input/input.css +114 -0
- package/src/primitives/input/input.html +61 -0
- package/src/primitives/input-group/input-group-password-group.html +108 -0
- package/src/primitives/input-group/input-group.css +215 -0
- package/src/primitives/input-group/input-group.html +132 -0
- package/src/primitives/kbd/kbd-group.html +18 -0
- package/src/primitives/kbd/kbd.css +87 -0
- package/src/primitives/kbd/kbd.html +7 -0
- package/src/primitives/lightbox/lightbox.css +459 -0
- package/src/primitives/lightbox/lightbox.d.ts +7 -0
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -0
- package/src/primitives/lightbox/lightbox.html +665 -0
- package/src/primitives/lightbox/lightbox.js +96 -0
- package/src/primitives/lightbox/lightbox.ts +113 -0
- package/src/primitives/menu/menu-interest.html +52 -0
- package/src/primitives/menu/menu.css +55 -0
- package/src/primitives/menu/menu.d.ts +38 -0
- package/src/primitives/menu/menu.d.ts.map +1 -0
- package/src/primitives/menu/menu.html +70 -0
- package/src/primitives/menu/menu.js +117 -0
- package/src/primitives/menu/menu.ts +131 -0
- package/src/primitives/menubar/menubar-help-search.html +103 -0
- package/src/primitives/menubar/menubar.html +166 -0
- package/src/primitives/meter/meter.css +178 -0
- package/src/primitives/meter/meter.html +38 -0
- package/src/primitives/mobile-menu/mobile-menu.css +145 -0
- package/src/primitives/mobile-menu/mobile-menu.html +614 -0
- package/src/primitives/navigation-menu/navigation-menu-featured.html +76 -0
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +158 -0
- package/src/primitives/navigation-menu/navigation-menu-interest.html +103 -0
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +141 -0
- package/src/primitives/navigation-menu/navigation-menu-simple.html +96 -0
- package/src/primitives/navigation-menu/navigation-menu.css +295 -0
- package/src/primitives/navigation-menu/navigation-menu.html +576 -0
- package/src/primitives/otp/otp.css +126 -0
- package/src/primitives/otp/otp.d.ts +89 -0
- package/src/primitives/otp/otp.d.ts.map +1 -0
- package/src/primitives/otp/otp.html +22 -0
- package/src/primitives/otp/otp.js +226 -0
- package/src/primitives/otp/otp.ts +279 -0
- package/src/primitives/password-group/password-group.css +238 -0
- package/src/primitives/password-group/password-group.d.ts +25 -0
- package/src/primitives/password-group/password-group.d.ts.map +1 -0
- package/src/primitives/password-group/password-group.html +109 -0
- package/src/primitives/password-group/password-group.js +76 -0
- package/src/primitives/password-group/password-group.ts +95 -0
- package/src/primitives/popover/popover.css +233 -0
- package/src/primitives/progress/progress-indeterminate.html +1 -0
- package/src/primitives/progress/progress.css +105 -0
- package/src/primitives/progress/progress.html +7 -0
- package/src/primitives/prose/prose.html +65 -0
- package/src/primitives/radio/radio.css +84 -0
- package/src/primitives/radio/radio.html +17 -0
- package/src/primitives/reveal/reveal.css +167 -0
- package/src/primitives/select/multiselect.d.ts +43 -0
- package/src/primitives/select/multiselect.d.ts.map +1 -0
- package/src/primitives/select/multiselect.js +147 -0
- package/src/primitives/select/multiselect.ts +188 -0
- package/src/primitives/select/select-align.html +49 -0
- package/src/primitives/select/select-multiple.html +12 -0
- package/src/primitives/select/select-sides.html +65 -0
- package/src/primitives/select/select.css +481 -0
- package/src/primitives/select/select.html +16 -0
- package/src/primitives/separator/separator.css +49 -0
- package/src/primitives/separator/separator.html +16 -0
- package/src/primitives/slider/slider.css +122 -0
- package/src/primitives/slider/slider.html +1 -0
- package/src/primitives/switch/switch.css +126 -0
- package/src/primitives/switch/switch.html +13 -0
- package/src/primitives/table/table-alternating.html +36 -0
- package/src/primitives/table/table-grid.html +30 -0
- package/src/primitives/table/table-size-sm.html +26 -0
- package/src/primitives/table/table.css +158 -0
- package/src/primitives/table/table.html +45 -0
- package/src/primitives/tabs/tabs.css +328 -0
- package/src/primitives/tabs/tabs.d.ts +35 -0
- package/src/primitives/tabs/tabs.d.ts.map +1 -0
- package/src/primitives/tabs/tabs.html +75 -0
- package/src/primitives/tabs/tabs.js +84 -0
- package/src/primitives/tabs/tabs.ts +93 -0
- package/src/primitives/textarea/textarea.css +78 -0
- package/src/primitives/textarea/textarea.html +10 -0
- package/src/primitives/toaster/toaster.css +309 -0
- package/src/primitives/toaster/toaster.d.ts +138 -0
- package/src/primitives/toaster/toaster.d.ts.map +1 -0
- package/src/primitives/toaster/toaster.html +77 -0
- package/src/primitives/toaster/toaster.js +736 -0
- package/src/primitives/toaster/toaster.ts +823 -0
- package/src/primitives/toggle/toggle.css +295 -0
- package/src/primitives/toggle/toggle.html +68 -0
- package/src/primitives/toggle-group/toggle-group-multiple.html +14 -0
- package/src/primitives/toggle-group/toggle-group-vertical.html +14 -0
- package/src/primitives/toggle-group/toggle-group.css +73 -0
- package/src/primitives/toggle-group/toggle-group.html +53 -0
- package/src/primitives/toolbar/toolbar.html +45 -0
- package/src/primitives/tooltip/tooltip-disabled.html +19 -0
- package/src/primitives/tooltip/tooltip-sides.html +57 -0
- package/src/primitives/tooltip/tooltip-with-kbd.html +31 -0
- package/src/primitives/tooltip/tooltip.css +235 -0
- package/src/primitives/tooltip/tooltip.html +12 -0
- package/src/primitives/utilities/aspect-ratio.html +17 -0
- package/src/primitives/utilities/basis.html +27 -0
- package/src/primitives/utilities/col-span.html +23 -0
- package/src/primitives/utilities/compose.html +19 -0
- package/src/primitives/utilities/flex-align.html +26 -0
- package/src/primitives/utilities/flex-direction.html +36 -0
- package/src/primitives/utilities/flex-grow.html +17 -0
- package/src/primitives/utilities/gap.html +62 -0
- package/src/primitives/utilities/grid-cols.html +20 -0
- package/src/primitives/utilities/grid-pile.html +5 -0
- package/src/primitives/utilities/grid-responsive.html +31 -0
- package/src/primitives/utilities/margin-auto.html +13 -0
- package/src/primitives/utilities/object-fit.html +41 -0
- package/src/primitives/utilities/order.html +17 -0
- package/src/primitives/utilities/overflow.html +26 -0
- package/src/primitives/utilities/padding-compose.html +23 -0
- package/src/primitives/utilities/padding.html +30 -0
- package/src/primitives/utilities/position.html +13 -0
- package/src/primitives/utilities/responsive-flex.html +22 -0
- package/src/primitives/utilities/responsive-grid.html +31 -0
- package/src/primitives/utilities/size.html +22 -0
- package/src/primitives/utilities/width.html +22 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview `<ui-combobox>`: an input restricted to a predefined list.
|
|
5
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
6
|
+
* (`base/typeahead.ts`). A relative of select: the panel filters as you type,
|
|
7
|
+
* but free text can never submit. The form value lives in an authored hidden
|
|
8
|
+
* input (`data-slot="combobox-value"`), synced whenever the selection changes.
|
|
9
|
+
*
|
|
10
|
+
* The visible input carries a **display value, not the filter**. Committing
|
|
11
|
+
* writes the option label into it and clears the query, so reopening shows
|
|
12
|
+
* the full list with the committed row checked, matching `.ui-select`.
|
|
13
|
+
* Opening selects that label so the first keystroke replaces it, and focus
|
|
14
|
+
* alone never opens the panel (a click, the chevron, an arrow key or typing
|
|
15
|
+
* does). On blur, stray text reverts to the committed label and cleared text
|
|
16
|
+
* clears the selection.
|
|
17
|
+
*
|
|
18
|
+
* `data-variant="multiselect"` selects a set instead: committing toggles a row
|
|
19
|
+
* and keeps the panel open, and every selected value renders as a removable
|
|
20
|
+
* tag stamped inside the control. The tag markup is HTML, not script: author
|
|
21
|
+
* a `<template data-slot="combobox-tag-template">` to control its classes and
|
|
22
|
+
* structure, and this file fills in the label, the value, and the remove
|
|
23
|
+
* button accessible name. Without one, the ui-badge default below applies.
|
|
24
|
+
* Backspace on an empty input drops the last tag. Options carrying
|
|
25
|
+
* `aria-selected="true"` are the single source of truth: the tags and the
|
|
26
|
+
* hidden inputs are both derived from them in DOM order so nothing can drift.
|
|
27
|
+
* The form submits repeated `name` pairs like `<select multiple>`: the authored
|
|
28
|
+
* hidden input carries the first value, and stamped siblings carry the rest.
|
|
29
|
+
*
|
|
30
|
+
* Where a no-JS fallback matters, prefer `.ui-select` / `<ui-multiselect>`:
|
|
31
|
+
* this control is inert without its script (the hidden input still submits a
|
|
32
|
+
* server-set value, but no tags render).
|
|
33
|
+
*
|
|
34
|
+
* Attributes on the root: `data-variant="multiselect"`, `data-sort="score"`,
|
|
35
|
+
* `data-min-length="<n>"`, `data-label-remove="Remove {label}"`.
|
|
36
|
+
* Parts: `combobox-value` (hidden input), `combobox-control` (select-look
|
|
37
|
+
* shell), `combobox-tag-template` (authored `<template>`), `combobox-tag` /
|
|
38
|
+
* `combobox-tag-label` / `combobox-tag-remove` (cloned from it),
|
|
39
|
+
* `combobox-trigger` (chevron), `combobox-panel`, `combobox-list`,
|
|
40
|
+
* `combobox-item`, `combobox-group` / `combobox-group-label`, `combobox-empty`.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
import { TypeaheadElement } from "../../base/typeahead.ts";
|
|
44
|
+
import { defineZazzElement } from "../../base/zazz-element.ts";
|
|
45
|
+
|
|
46
|
+
// --- Tag blueprint ---
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The default tag markup, cloned once per selected value. Authors override it
|
|
50
|
+
* wholesale with a `<template data-slot="combobox-tag-template">`, so restyling
|
|
51
|
+
* a tag (other classes, an extra icon, a different component entirely) never
|
|
52
|
+
* means editing this script. Kept as markup rather than createElement calls so
|
|
53
|
+
* the default reads the same way the override is written.
|
|
54
|
+
*/
|
|
55
|
+
const TAG_MARKUP =
|
|
56
|
+
'<span class="ui-badge" data-slot="combobox-tag">' +
|
|
57
|
+
'<span data-slot="combobox-tag-label"></span>' +
|
|
58
|
+
'<button type="button" tabindex="-1" data-slot="combobox-tag-remove"></button>' +
|
|
59
|
+
"</span>";
|
|
60
|
+
|
|
61
|
+
let defaultTagTemplate: HTMLTemplateElement | null = null;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @description Parses `TAG_MARKUP` once and shares the result.
|
|
65
|
+
*
|
|
66
|
+
* @returns The fallback tag template.
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
function defaultTagBlueprint(): HTMLTemplateElement {
|
|
70
|
+
if (!defaultTagTemplate) {
|
|
71
|
+
defaultTagTemplate = document.createElement("template");
|
|
72
|
+
defaultTagTemplate.innerHTML = TAG_MARKUP;
|
|
73
|
+
}
|
|
74
|
+
return defaultTagTemplate;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// --- Pure derivations ---
|
|
78
|
+
|
|
79
|
+
/** What a blur does to the input's text and to the committed selection. */
|
|
80
|
+
interface BlurOutcome {
|
|
81
|
+
/** The text the input shows once focus has left. */
|
|
82
|
+
value: string;
|
|
83
|
+
/** Whether the committed selection is dropped. */
|
|
84
|
+
clear: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @description Resolves a blur: free text never survives it. The multiselect
|
|
89
|
+
* variant always empties the filter (its selection lives in the tags), the
|
|
90
|
+
* single variant restores the committed label, and an emptied single-select
|
|
91
|
+
* input clears the selection outright.
|
|
92
|
+
*
|
|
93
|
+
* @param typed - The input's current text.
|
|
94
|
+
* @param committedLabel - The last committed label, empty for no selection.
|
|
95
|
+
* @param multiselect - Whether the multiselect variant is active.
|
|
96
|
+
* @returns The text to show and whether to clear the selection.
|
|
97
|
+
*/
|
|
98
|
+
function resolveBlur(typed: string, committedLabel: string, multiselect: boolean): BlurOutcome {
|
|
99
|
+
if (multiselect) return { value: "", clear: false };
|
|
100
|
+
if (typed === "") return { value: "", clear: true };
|
|
101
|
+
return { value: committedLabel, clear: false };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @description Fills the remove-button label template (`data-label-remove`).
|
|
106
|
+
*
|
|
107
|
+
* @param template - Template with a `{label}` placeholder.
|
|
108
|
+
* @param label - The tag's visible label.
|
|
109
|
+
* @returns The accessible name for that tag's remove button.
|
|
110
|
+
*/
|
|
111
|
+
function resolveRemoveLabel(template: string, label: string): string {
|
|
112
|
+
return template.replace("{label}", label);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// --- Element ---
|
|
116
|
+
|
|
117
|
+
class UiCombobox extends TypeaheadElement {
|
|
118
|
+
protected readonly slotPrefix = "combobox";
|
|
119
|
+
/** The input holds a committed label, so focus alone must not open the list. */
|
|
120
|
+
protected readonly openOnFocus: boolean = false;
|
|
121
|
+
|
|
122
|
+
#committedLabel = "";
|
|
123
|
+
#placeholder = "";
|
|
124
|
+
#defaultValues: string[] = [];
|
|
125
|
+
#serialized = "";
|
|
126
|
+
|
|
127
|
+
protected setup(signal: AbortSignal): void {
|
|
128
|
+
super.setup(signal);
|
|
129
|
+
const input = this.searchInput;
|
|
130
|
+
if (!input) return;
|
|
131
|
+
const multiselect = this.#multiselect();
|
|
132
|
+
this.#placeholder = input.getAttribute("placeholder") ?? "";
|
|
133
|
+
|
|
134
|
+
if (multiselect) {
|
|
135
|
+
this.querySelector('[data-slot~="combobox-list"]')?.setAttribute(
|
|
136
|
+
"aria-multiselectable",
|
|
137
|
+
"true",
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Adopt a server-rendered value no row claims yet, so `value` alone is
|
|
142
|
+
// enough markup to seed the selection, ensuring the sync below never
|
|
143
|
+
// silently discards it
|
|
144
|
+
const hidden = this.#valueInput();
|
|
145
|
+
if (hidden !== null && hidden.value !== "" && this.#selectedItems().length === 0) {
|
|
146
|
+
const match = this.items().find((item) => this.#itemFormValue(item) === hidden.value);
|
|
147
|
+
match?.setAttribute("aria-selected", "true");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// A multi-select listbox announces every row state, not just the picked ones
|
|
151
|
+
if (multiselect) {
|
|
152
|
+
for (const item of this.items()) {
|
|
153
|
+
if (item.getAttribute("aria-selected") !== "true") {
|
|
154
|
+
item.setAttribute("aria-selected", "false");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Attribute state has no defaultValue: remember the markup selection so
|
|
160
|
+
// a form reset can restore it
|
|
161
|
+
this.#defaultValues = this.#selectedItems().map((item) => this.#itemFormValue(item));
|
|
162
|
+
this.#committedLabel = multiselect ? "" : (this.#selectedLabel() ?? "");
|
|
163
|
+
input.value = this.#committedLabel;
|
|
164
|
+
this.#syncSelection(false);
|
|
165
|
+
|
|
166
|
+
const control = input.closest<HTMLElement>('[data-slot~="combobox-control"]');
|
|
167
|
+
|
|
168
|
+
// A select-look control is one big hit target
|
|
169
|
+
input.addEventListener("click", () => this.#openPanel(), { signal });
|
|
170
|
+
|
|
171
|
+
control?.addEventListener(
|
|
172
|
+
"mousedown",
|
|
173
|
+
(event) => {
|
|
174
|
+
if (!(event.target instanceof Element) || event.target === input) return;
|
|
175
|
+
// Nothing in the shell may steal focus from the input: the chevron and
|
|
176
|
+
// the tag remove buttons would otherwise blur it and close the panel
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
input.focus();
|
|
179
|
+
if (!event.target.closest('[data-slot~="combobox-trigger"], [data-slot~="combobox-tag"]')) {
|
|
180
|
+
this.#openPanel();
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{ signal },
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// Tag removal is delegated: the tags are re-stamped on every change
|
|
187
|
+
control?.addEventListener(
|
|
188
|
+
"click",
|
|
189
|
+
(event) => {
|
|
190
|
+
if (!(event.target instanceof Element)) return;
|
|
191
|
+
const remove = event.target.closest('[data-slot~="combobox-tag-remove"]');
|
|
192
|
+
if (!remove) return;
|
|
193
|
+
// A template that forgets type="button" would otherwise submit the form
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
const value = remove.closest('[data-slot~="combobox-tag"]')?.getAttribute("data-value");
|
|
196
|
+
this.#deselect(this.items().find((item) => this.#itemFormValue(item) === value));
|
|
197
|
+
input.focus();
|
|
198
|
+
},
|
|
199
|
+
{ signal },
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
// Chevron toggles the full, unfiltered list
|
|
203
|
+
const trigger = this.querySelector('[data-slot~="combobox-trigger"]');
|
|
204
|
+
if (trigger instanceof HTMLElement) {
|
|
205
|
+
trigger.addEventListener(
|
|
206
|
+
"click",
|
|
207
|
+
() => {
|
|
208
|
+
if (this.open.get()) this.open.set(false);
|
|
209
|
+
else this.#openPanel();
|
|
210
|
+
},
|
|
211
|
+
{ signal },
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Backspace on an empty filter drops the last tag
|
|
216
|
+
if (multiselect) {
|
|
217
|
+
input.addEventListener(
|
|
218
|
+
"keydown",
|
|
219
|
+
(event) => {
|
|
220
|
+
if (event.key !== "Backspace" || input.value !== "") return;
|
|
221
|
+
const last = this.#selectedItems().at(-1);
|
|
222
|
+
if (!last) return;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
this.#deselect(last);
|
|
225
|
+
},
|
|
226
|
+
{ signal },
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// No free text: on leaving, revert stray text or clear the selection
|
|
231
|
+
this.addEventListener(
|
|
232
|
+
"focusout",
|
|
233
|
+
(event) => {
|
|
234
|
+
const next = event.relatedTarget;
|
|
235
|
+
if (next instanceof Node && this.contains(next)) return;
|
|
236
|
+
const outcome = resolveBlur(input.value, this.#committedLabel, this.#multiselect());
|
|
237
|
+
input.value = outcome.value;
|
|
238
|
+
// Safe mid-close: the gated ranking effect ignores query writes while
|
|
239
|
+
// the panel is fading out
|
|
240
|
+
this.query.set("");
|
|
241
|
+
if (outcome.clear) this.#clearSelection();
|
|
242
|
+
},
|
|
243
|
+
{ signal },
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// A form reset restores the selection the markup shipped with (reset
|
|
247
|
+
// applies after the event)
|
|
248
|
+
(hidden ?? input).form?.addEventListener(
|
|
249
|
+
"reset",
|
|
250
|
+
() => queueMicrotask(() => this.#restoreDefaults()),
|
|
251
|
+
{ signal },
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
protected teardown(): void {
|
|
256
|
+
for (const node of this.querySelectorAll(
|
|
257
|
+
'[data-slot~="combobox-tag"], [data-combobox-stamped]',
|
|
258
|
+
)) {
|
|
259
|
+
node.remove();
|
|
260
|
+
}
|
|
261
|
+
if (this.searchInput) this.searchInput.placeholder = this.#placeholder;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @description Combobox items match against what the user sees (the label)
|
|
266
|
+
* not the machine `data-value`.
|
|
267
|
+
*
|
|
268
|
+
* @param item - The item element.
|
|
269
|
+
* @returns The trimmed visible label.
|
|
270
|
+
*/
|
|
271
|
+
protected itemValue(item: HTMLElement): string {
|
|
272
|
+
return item.textContent?.trim() ?? "";
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @description Escape with the panel already closed restores the committed
|
|
277
|
+
* label (single) or drops the filter text (multiselect), avoiding a half-typed
|
|
278
|
+
* value that a later blur would read as a cleared selection.
|
|
279
|
+
*/
|
|
280
|
+
protected clearQuery(): void {
|
|
281
|
+
const input = this.searchInput;
|
|
282
|
+
if (!input) return;
|
|
283
|
+
input.value = this.#multiselect() ? "" : this.#committedLabel;
|
|
284
|
+
this.query.set("");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @description Committing shows the item's label, stores its `data-value` in
|
|
289
|
+
* the hidden input, and moves `aria-selected`. The multiselect variant
|
|
290
|
+
* toggles the row instead and keeps the panel open so picking can continue.
|
|
291
|
+
*
|
|
292
|
+
* @param item - The committed option.
|
|
293
|
+
*/
|
|
294
|
+
protected commit(item: HTMLElement, _source: "keyboard" | "pointer"): void {
|
|
295
|
+
const input = this.searchInput;
|
|
296
|
+
if (!input) return;
|
|
297
|
+
|
|
298
|
+
if (this.#multiselect()) {
|
|
299
|
+
item.setAttribute("aria-selected", String(item.getAttribute("aria-selected") !== "true"));
|
|
300
|
+
input.value = "";
|
|
301
|
+
this.query.set("");
|
|
302
|
+
// Follow the row through the re-widened list so a second Enter toggles it
|
|
303
|
+
// back: with an empty query every item is visible, and visual order is
|
|
304
|
+
// DOM order (score ranking is stable at equal scores)
|
|
305
|
+
this.activeIndex.set(this.items().indexOf(item));
|
|
306
|
+
this.#syncSelection(true);
|
|
307
|
+
input.focus();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.#committedLabel = this.itemValue(item);
|
|
312
|
+
input.value = this.#committedLabel;
|
|
313
|
+
// The label is display text, not a filter: clearing the query is what
|
|
314
|
+
// makes the reopened panel show the full list with this row checked
|
|
315
|
+
this.query.set("");
|
|
316
|
+
for (const other of this.items()) other.removeAttribute("aria-selected");
|
|
317
|
+
item.setAttribute("aria-selected", "true");
|
|
318
|
+
this.#syncSelection(true);
|
|
319
|
+
input.focus();
|
|
320
|
+
// The inline variant has no popover to close, and closing it would gate its
|
|
321
|
+
// filtering off for good. It also never reopens, so commit is where it
|
|
322
|
+
// selects the label (the popover variants do that in #openPanel()).
|
|
323
|
+
if (this.panel?.hasAttribute("popover")) this.open.set(false);
|
|
324
|
+
else input.select();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @description Whether the multiselect variant is active.
|
|
329
|
+
*
|
|
330
|
+
* @returns True for `data-variant="multiselect"`.
|
|
331
|
+
* @private
|
|
332
|
+
*/
|
|
333
|
+
#multiselect(): boolean {
|
|
334
|
+
return this.getAttribute("data-variant") === "multiselect";
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* @description Opens the panel the way a select does: the full list, the
|
|
339
|
+
* committed row highlighted, and its label selected so the first keystroke
|
|
340
|
+
* replaces it. `activeIndex` is written here rather than from an effect
|
|
341
|
+
* because effects are output adapters, and writes from inside one can be dropped
|
|
342
|
+
* until the next notification.
|
|
343
|
+
* @private
|
|
344
|
+
*/
|
|
345
|
+
#openPanel(): void {
|
|
346
|
+
const input = this.searchInput;
|
|
347
|
+
if (!input || this.open.get()) return;
|
|
348
|
+
if (this.#multiselect()) {
|
|
349
|
+
input.value = "";
|
|
350
|
+
this.activeIndex.set(-1);
|
|
351
|
+
} else {
|
|
352
|
+
input.value = this.#committedLabel;
|
|
353
|
+
const selected = this.#selectedItems()[0];
|
|
354
|
+
this.activeIndex.set(selected ? this.items().indexOf(selected) : -1);
|
|
355
|
+
if (input.value !== "") input.select();
|
|
356
|
+
}
|
|
357
|
+
this.query.set("");
|
|
358
|
+
this.open.set(true);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @description The selection: items carrying `aria-selected="true"`, in DOM
|
|
363
|
+
* order. The single source of truth for tags and form values alike.
|
|
364
|
+
*
|
|
365
|
+
* @returns The selected items.
|
|
366
|
+
* @private
|
|
367
|
+
*/
|
|
368
|
+
#selectedItems(): HTMLElement[] {
|
|
369
|
+
return this.items().filter((item) => item.getAttribute("aria-selected") === "true");
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @description The single-select committed label.
|
|
374
|
+
*
|
|
375
|
+
* @returns The selected item's label, or undefined when nothing is selected.
|
|
376
|
+
* @private
|
|
377
|
+
*/
|
|
378
|
+
#selectedLabel(): string | undefined {
|
|
379
|
+
const selected = this.#selectedItems()[0];
|
|
380
|
+
return selected ? this.itemValue(selected) : undefined;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @description An item's machine value.
|
|
385
|
+
*
|
|
386
|
+
* @param item - The item element.
|
|
387
|
+
* @returns `data-value` when present, the visible label otherwise.
|
|
388
|
+
* @private
|
|
389
|
+
*/
|
|
390
|
+
#itemFormValue(item: HTMLElement): string {
|
|
391
|
+
return item.getAttribute("data-value") ?? this.itemValue(item);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* @description Drops one item from the selection.
|
|
396
|
+
*
|
|
397
|
+
* @param item - The item to deselect; a no-op when undefined.
|
|
398
|
+
* @private
|
|
399
|
+
*/
|
|
400
|
+
#deselect(item: HTMLElement | undefined): void {
|
|
401
|
+
if (!item) return;
|
|
402
|
+
item.setAttribute("aria-selected", "false");
|
|
403
|
+
this.#syncSelection(true);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @description The authored hidden input carrying the form value (never one
|
|
408
|
+
* of the stamped siblings).
|
|
409
|
+
*
|
|
410
|
+
* @returns The hidden input, or null when the author omitted it.
|
|
411
|
+
* @private
|
|
412
|
+
*/
|
|
413
|
+
#valueInput(): HTMLInputElement | null {
|
|
414
|
+
const hidden = this.querySelector('[data-slot~="combobox-value"]:not([data-combobox-stamped])');
|
|
415
|
+
return hidden instanceof HTMLInputElement ? hidden : null;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @description Mirrors the selection into the two things derived from it: the
|
|
420
|
+
* tags and the hidden inputs. The authored input carries the first value and
|
|
421
|
+
* stamped siblings carry the rest under the same `name`, so a multiselection
|
|
422
|
+
* submits as repeated pairs exactly like `<select multiple>`. DOM
|
|
423
|
+
* construction stays imperative: the DOM is the source of truth here, not a
|
|
424
|
+
* signal.
|
|
425
|
+
*
|
|
426
|
+
* @param notify - Whether to dispatch `change` (skipped while seeding).
|
|
427
|
+
* @private
|
|
428
|
+
*/
|
|
429
|
+
#syncSelection(notify: boolean): void {
|
|
430
|
+
const input = this.searchInput;
|
|
431
|
+
const values = this.#selectedItems().map((item) => this.#itemFormValue(item));
|
|
432
|
+
const serialized = JSON.stringify(values);
|
|
433
|
+
const changed = serialized !== this.#serialized;
|
|
434
|
+
this.#serialized = serialized;
|
|
435
|
+
|
|
436
|
+
if (input && this.#multiselect()) this.#renderTags(input);
|
|
437
|
+
|
|
438
|
+
const hidden = this.#valueInput();
|
|
439
|
+
if (!hidden) return;
|
|
440
|
+
hidden.value = values[0] ?? "";
|
|
441
|
+
for (const stale of this.querySelectorAll("[data-combobox-stamped]")) stale.remove();
|
|
442
|
+
let anchor: Element = hidden;
|
|
443
|
+
for (const value of values.slice(1)) {
|
|
444
|
+
const extra = document.createElement("input");
|
|
445
|
+
extra.type = "hidden";
|
|
446
|
+
extra.setAttribute("data-slot", "combobox-value");
|
|
447
|
+
extra.setAttribute("data-combobox-stamped", "");
|
|
448
|
+
if (hidden.name) extra.name = hidden.name;
|
|
449
|
+
extra.value = value;
|
|
450
|
+
anchor.after(extra);
|
|
451
|
+
anchor = extra;
|
|
452
|
+
}
|
|
453
|
+
if (notify && changed) hidden.dispatchEvent(new Event("change", { bubbles: true }));
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @description The element cloned per selected value: the first child of an
|
|
458
|
+
* authored `<template data-slot="combobox-tag-template">` when present, the
|
|
459
|
+
* default ui-badge otherwise. A template's content lives in a separate
|
|
460
|
+
* fragment, so a blueprint carrying `data-slot="combobox-tag"` is invisible to
|
|
461
|
+
* the stale-tag sweep and can never be mistaken for a rendered tag.
|
|
462
|
+
*
|
|
463
|
+
* @returns The blueprint element, or null when an authored template is empty.
|
|
464
|
+
* @private
|
|
465
|
+
*/
|
|
466
|
+
#tagBlueprint(): HTMLElement | null {
|
|
467
|
+
const authored = this.querySelector('[data-slot~="combobox-tag-template"]');
|
|
468
|
+
const template = authored instanceof HTMLTemplateElement ? authored : defaultTagBlueprint();
|
|
469
|
+
const root = template.content.firstElementChild;
|
|
470
|
+
return root instanceof HTMLElement ? root : null;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @description Re-stamps the selection tags inside the control, in DOM order.
|
|
475
|
+
* Rebuilt wholesale rather than diffed: the tags are pure output, nothing
|
|
476
|
+
* focusable ever lands inside one, and removal is delegated from the control.
|
|
477
|
+
*
|
|
478
|
+
* @param input - The search input the tags render before.
|
|
479
|
+
* @private
|
|
480
|
+
*/
|
|
481
|
+
#renderTags(input: HTMLInputElement): void {
|
|
482
|
+
const control = input.closest('[data-slot~="combobox-control"]');
|
|
483
|
+
if (!control) return;
|
|
484
|
+
for (const stale of control.querySelectorAll('[data-slot~="combobox-tag"]')) stale.remove();
|
|
485
|
+
|
|
486
|
+
const blueprint = this.#tagBlueprint();
|
|
487
|
+
if (!blueprint) return;
|
|
488
|
+
|
|
489
|
+
const removeLabel = this.getAttribute("data-label-remove") ?? "Remove {label}";
|
|
490
|
+
const tags = this.#selectedItems().map((item) => {
|
|
491
|
+
const label = this.itemValue(item);
|
|
492
|
+
const tag = blueprint.cloneNode(true) as HTMLElement;
|
|
493
|
+
tag.setAttribute("data-value", this.#itemFormValue(item));
|
|
494
|
+
|
|
495
|
+
// The slot is the contract every other moving part keys off (the CSS, the
|
|
496
|
+
// stale sweep above, and tag removal), so add the token if the template
|
|
497
|
+
// left it out rather than stamping an orphan
|
|
498
|
+
if (!tag.matches('[data-slot~="combobox-tag"]')) {
|
|
499
|
+
const slots = tag.getAttribute("data-slot");
|
|
500
|
+
tag.setAttribute("data-slot", slots ? `${slots} combobox-tag` : "combobox-tag");
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// The label wants its own box: text-overflow ignores a flex container's
|
|
504
|
+
// own text, but a template without one still gets its text
|
|
505
|
+
const text = tag.querySelector('[data-slot~="combobox-tag-label"]');
|
|
506
|
+
if (text) text.textContent = label;
|
|
507
|
+
else tag.prepend(document.createTextNode(label));
|
|
508
|
+
|
|
509
|
+
tag
|
|
510
|
+
.querySelector('[data-slot~="combobox-tag-remove"]')
|
|
511
|
+
?.setAttribute("aria-label", resolveRemoveLabel(removeLabel, label));
|
|
512
|
+
|
|
513
|
+
return tag;
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
input.before(...tags);
|
|
517
|
+
input.placeholder = tags.length > 0 ? "" : this.#placeholder;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* @description Empties the committed state: label, hidden value, tags, and
|
|
522
|
+
* `aria-selected` all clear together.
|
|
523
|
+
* @private
|
|
524
|
+
*/
|
|
525
|
+
#clearSelection(): void {
|
|
526
|
+
this.#committedLabel = "";
|
|
527
|
+
const multiselect = this.#multiselect();
|
|
528
|
+
for (const item of this.items()) {
|
|
529
|
+
if (multiselect) item.setAttribute("aria-selected", "false");
|
|
530
|
+
else item.removeAttribute("aria-selected");
|
|
531
|
+
}
|
|
532
|
+
this.#syncSelection(true);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @description Restores the selection the markup shipped with (form reset).
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
#restoreDefaults(): void {
|
|
540
|
+
const input = this.searchInput;
|
|
541
|
+
if (!input) return;
|
|
542
|
+
const multiselect = this.#multiselect();
|
|
543
|
+
for (const item of this.items()) {
|
|
544
|
+
const selected = this.#defaultValues.includes(this.#itemFormValue(item));
|
|
545
|
+
if (multiselect) item.setAttribute("aria-selected", String(selected));
|
|
546
|
+
else if (selected) item.setAttribute("aria-selected", "true");
|
|
547
|
+
else item.removeAttribute("aria-selected");
|
|
548
|
+
}
|
|
549
|
+
this.#committedLabel = multiselect ? "" : (this.#selectedLabel() ?? "");
|
|
550
|
+
input.value = this.#committedLabel;
|
|
551
|
+
this.query.set("");
|
|
552
|
+
this.#syncSelection(true);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
defineZazzElement("ui-combobox", UiCombobox);
|
|
557
|
+
|
|
558
|
+
export { UiCombobox, resolveBlur, resolveRemoveLabel };
|
|
559
|
+
export type { BlurOutcome };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Example: composing custom command actions for `<ui-command>`.
|
|
3
|
+
* @description This file is a template, not part of the kit runtime: copy it
|
|
4
|
+
* into your project and register your own actions. It is loaded only by the
|
|
5
|
+
* `command-actions` docs example.
|
|
6
|
+
*
|
|
7
|
+
* Simple actions need no script at all: a navigation item is an `<a href>`,
|
|
8
|
+
* and opening a dialog/popover is a `<button command commandfor>` invoker.
|
|
9
|
+
* Reach for a script only when an action runs real logic. Two hooks exist:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Custom invoker commands**: give the item `command="--your-action"`
|
|
12
|
+
* and `commandfor="<target id>"`, then listen for the `command` event on
|
|
13
|
+
* the target. The invokers polyfill re-dispatches commands in browsers
|
|
14
|
+
* with native support, so de-dupe per task (see below).
|
|
15
|
+
* 2. **`zazz:command-select`**: every activation bubbles this CustomEvent
|
|
16
|
+
* from the `<ui-command>` root (`detail: { item, value }`); use it for
|
|
17
|
+
* palette-wide concerns like analytics.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @description Binds this page's custom `--command` handlers. Handlers attach
|
|
21
|
+
* to the command *target* (the `commandfor` element), per the Invoker
|
|
22
|
+
* Commands contract.
|
|
23
|
+
*/
|
|
24
|
+
declare function initCommandActions(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @description Logs every command activation: swap for analytics, recents
|
|
27
|
+
* tracking, or any cross-cutting concern.
|
|
28
|
+
*/
|
|
29
|
+
declare function initCommandSelectLogging(): void;
|
|
30
|
+
export { initCommandActions, initCommandSelectLogging };
|
|
31
|
+
//# sourceMappingURL=command-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-actions.d.ts","sourceRoot":"","sources":["command-actions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;GAIG;AACH,iBAAS,kBAAkB,IAAI,IAAI,CAsBlC;AAID;;;GAGG;AACH,iBAAS,wBAAwB,IAAI,IAAI,CAKxC;AAaD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- command-actions.js (loaded with this example) shows how to register
|
|
2
|
+
custom actions: listen for your `--command` on its `commandfor` target,
|
|
3
|
+
or for `zazz:command-select` on the root. Copy it into your project as a
|
|
4
|
+
starting point. -->
|
|
5
|
+
<ui-command data-command-hotkey="mod+j" id="command-actions-target" class="w-full max-w-xl">
|
|
6
|
+
<button
|
|
7
|
+
class="ui-button w-full justify-between"
|
|
8
|
+
type="button"
|
|
9
|
+
data-variant="outline"
|
|
10
|
+
popovertarget="command-example-actions-1"
|
|
11
|
+
data-slot="command-open"
|
|
12
|
+
>
|
|
13
|
+
<span class="text-muted-foreground">Quick actions...</span>
|
|
14
|
+
<ui-kbd-group><kbd>⌘</kbd><kbd>J</kbd></ui-kbd-group>
|
|
15
|
+
</button>
|
|
16
|
+
<div
|
|
17
|
+
id="command-example-actions-1"
|
|
18
|
+
data-slot="command-panel"
|
|
19
|
+
data-side="bottom"
|
|
20
|
+
data-align="start"
|
|
21
|
+
popover="auto"
|
|
22
|
+
>
|
|
23
|
+
<header data-slot="command-header">
|
|
24
|
+
<input
|
|
25
|
+
data-slot="command-input"
|
|
26
|
+
type="text"
|
|
27
|
+
placeholder="Type a command..."
|
|
28
|
+
role="combobox"
|
|
29
|
+
aria-expanded="false"
|
|
30
|
+
aria-autocomplete="list"
|
|
31
|
+
autocomplete="off"
|
|
32
|
+
aria-label="Search commands"
|
|
33
|
+
/>
|
|
34
|
+
</header>
|
|
35
|
+
<div role="listbox" data-slot="command-list" aria-label="Commands">
|
|
36
|
+
<button
|
|
37
|
+
role="option"
|
|
38
|
+
data-slot="command-item"
|
|
39
|
+
class="ui-button justify-start"
|
|
40
|
+
data-variant="ghost"
|
|
41
|
+
type="button"
|
|
42
|
+
command="--theme-toggle"
|
|
43
|
+
commandfor="command-actions-target"
|
|
44
|
+
tabindex="-1"
|
|
45
|
+
data-keywords="dark light mode appearance"
|
|
46
|
+
data-stay-open
|
|
47
|
+
>
|
|
48
|
+
Toggle theme
|
|
49
|
+
</button>
|
|
50
|
+
<button
|
|
51
|
+
role="option"
|
|
52
|
+
data-slot="command-item"
|
|
53
|
+
class="ui-button justify-start"
|
|
54
|
+
data-variant="ghost"
|
|
55
|
+
type="button"
|
|
56
|
+
command="--copy-link"
|
|
57
|
+
commandfor="command-actions-target"
|
|
58
|
+
tabindex="-1"
|
|
59
|
+
data-keywords="share url clipboard"
|
|
60
|
+
>
|
|
61
|
+
Copy link
|
|
62
|
+
</button>
|
|
63
|
+
<button
|
|
64
|
+
role="option"
|
|
65
|
+
data-slot="command-item"
|
|
66
|
+
class="ui-button justify-start"
|
|
67
|
+
data-variant="ghost"
|
|
68
|
+
type="button"
|
|
69
|
+
command="--toast-success"
|
|
70
|
+
commandfor="command-actions-toaster"
|
|
71
|
+
data-title="Saved"
|
|
72
|
+
data-description="Your changes are safe."
|
|
73
|
+
tabindex="-1"
|
|
74
|
+
data-keywords="notify notification"
|
|
75
|
+
>
|
|
76
|
+
Show a toast
|
|
77
|
+
</button>
|
|
78
|
+
</div>
|
|
79
|
+
<p data-slot="command-empty" class="text-muted-foreground">No commands found.</p>
|
|
80
|
+
<footer data-slot="command-footer">
|
|
81
|
+
<span
|
|
82
|
+
><ui-kbd-group><kbd>↑</kbd><kbd>↓</kbd></ui-kbd-group> navigate</span
|
|
83
|
+
>
|
|
84
|
+
<span><kbd>↵</kbd> select</span>
|
|
85
|
+
</footer>
|
|
86
|
+
</div>
|
|
87
|
+
</ui-command>
|
|
88
|
+
|
|
89
|
+
<ui-toaster id="command-actions-toaster" data-position="bottom-end"></ui-toaster>
|