@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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Example: composing custom command actions for `<ui-command>`.
|
|
4
|
+
* @description This file is a template, not part of the kit runtime: copy it
|
|
5
|
+
* into your project and register your own actions. It is loaded only by the
|
|
6
|
+
* `command-actions` docs example.
|
|
7
|
+
*
|
|
8
|
+
* Simple actions need no script at all: a navigation item is an `<a href>`,
|
|
9
|
+
* and opening a dialog/popover is a `<button command commandfor>` invoker.
|
|
10
|
+
* Reach for a script only when an action runs real logic. Two hooks exist:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Custom invoker commands**: give the item `command="--your-action"`
|
|
13
|
+
* and `commandfor="<target id>"`, then listen for the `command` event on
|
|
14
|
+
* the target. The invokers polyfill re-dispatches commands in browsers
|
|
15
|
+
* with native support, so de-dupe per task (see below).
|
|
16
|
+
* 2. **`zazz:command-select`**: every activation bubbles this CustomEvent
|
|
17
|
+
* from the `<ui-command>` root (`detail: { item, value }`); use it for
|
|
18
|
+
* palette-wide concerns like analytics.
|
|
19
|
+
*/
|
|
20
|
+
// --- Custom invoker commands ---
|
|
21
|
+
/**
|
|
22
|
+
* @description Binds this page's custom `--command` handlers. Handlers attach
|
|
23
|
+
* to the command *target* (the `commandfor` element), per the Invoker
|
|
24
|
+
* Commands contract.
|
|
25
|
+
*/
|
|
26
|
+
function initCommandActions() {
|
|
27
|
+
const themeTarget = document.getElementById("command-actions-target");
|
|
28
|
+
if (!themeTarget)
|
|
29
|
+
return;
|
|
30
|
+
// The invokers polyfill can deliver the same command twice in one task even
|
|
31
|
+
// with native support: de-dupe like the toaster does.
|
|
32
|
+
let lastEvent = null;
|
|
33
|
+
themeTarget.addEventListener("command", (event) => {
|
|
34
|
+
if (event === lastEvent)
|
|
35
|
+
return;
|
|
36
|
+
lastEvent = event;
|
|
37
|
+
const command = event.command;
|
|
38
|
+
switch (command) {
|
|
39
|
+
case "--theme-toggle":
|
|
40
|
+
document.documentElement.classList.toggle("dark");
|
|
41
|
+
break;
|
|
42
|
+
case "--copy-link":
|
|
43
|
+
void navigator.clipboard?.writeText(window.location.href);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// --- Palette-wide hook ---
|
|
49
|
+
/**
|
|
50
|
+
* @description Logs every command activation: swap for analytics, recents
|
|
51
|
+
* tracking, or any cross-cutting concern.
|
|
52
|
+
*/
|
|
53
|
+
function initCommandSelectLogging() {
|
|
54
|
+
document.addEventListener("zazz:command-select", (event) => {
|
|
55
|
+
const detail = event.detail;
|
|
56
|
+
console.info("[command] selected:", detail.value);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// --- Auto-initialization ---
|
|
60
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
61
|
+
const init = () => {
|
|
62
|
+
initCommandActions();
|
|
63
|
+
initCommandSelectLogging();
|
|
64
|
+
};
|
|
65
|
+
if (document.readyState === "loading")
|
|
66
|
+
document.addEventListener("DOMContentLoaded", init);
|
|
67
|
+
else
|
|
68
|
+
init();
|
|
69
|
+
}
|
|
70
|
+
export { initCommandActions, initCommandSelectLogging };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Example: composing custom command actions for `<ui-command>`.
|
|
5
|
+
* @description This file is a template, not part of the kit runtime: copy it
|
|
6
|
+
* into your project and register your own actions. It is loaded only by the
|
|
7
|
+
* `command-actions` docs example.
|
|
8
|
+
*
|
|
9
|
+
* Simple actions need no script at all: a navigation item is an `<a href>`,
|
|
10
|
+
* and opening a dialog/popover is a `<button command commandfor>` invoker.
|
|
11
|
+
* Reach for a script only when an action runs real logic. Two hooks exist:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Custom invoker commands**: give the item `command="--your-action"`
|
|
14
|
+
* and `commandfor="<target id>"`, then listen for the `command` event on
|
|
15
|
+
* the target. The invokers polyfill re-dispatches commands in browsers
|
|
16
|
+
* with native support, so de-dupe per task (see below).
|
|
17
|
+
* 2. **`zazz:command-select`**: every activation bubbles this CustomEvent
|
|
18
|
+
* from the `<ui-command>` root (`detail: { item, value }`); use it for
|
|
19
|
+
* palette-wide concerns like analytics.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// --- Custom invoker commands ---
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @description Binds this page's custom `--command` handlers. Handlers attach
|
|
26
|
+
* to the command *target* (the `commandfor` element), per the Invoker
|
|
27
|
+
* Commands contract.
|
|
28
|
+
*/
|
|
29
|
+
function initCommandActions(): void {
|
|
30
|
+
const themeTarget = document.getElementById("command-actions-target");
|
|
31
|
+
if (!themeTarget) return;
|
|
32
|
+
|
|
33
|
+
// The invokers polyfill can deliver the same command twice in one task even
|
|
34
|
+
// with native support: de-dupe like the toaster does.
|
|
35
|
+
let lastEvent: Event | null = null;
|
|
36
|
+
|
|
37
|
+
themeTarget.addEventListener("command", (event) => {
|
|
38
|
+
if (event === lastEvent) return;
|
|
39
|
+
lastEvent = event;
|
|
40
|
+
|
|
41
|
+
const command = (event as CommandEvent).command;
|
|
42
|
+
switch (command) {
|
|
43
|
+
case "--theme-toggle":
|
|
44
|
+
document.documentElement.classList.toggle("dark");
|
|
45
|
+
break;
|
|
46
|
+
case "--copy-link":
|
|
47
|
+
void navigator.clipboard?.writeText(window.location.href);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- Palette-wide hook ---
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @description Logs every command activation: swap for analytics, recents
|
|
57
|
+
* tracking, or any cross-cutting concern.
|
|
58
|
+
*/
|
|
59
|
+
function initCommandSelectLogging(): void {
|
|
60
|
+
document.addEventListener("zazz:command-select", (event) => {
|
|
61
|
+
const detail = (event as CustomEvent<{ item: HTMLElement; value: string }>).detail;
|
|
62
|
+
console.info("[command] selected:", detail.value);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// --- Auto-initialization ---
|
|
67
|
+
|
|
68
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
69
|
+
const init = (): void => {
|
|
70
|
+
initCommandActions();
|
|
71
|
+
initCommandSelectLogging();
|
|
72
|
+
};
|
|
73
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
|
|
74
|
+
else init();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { initCommandActions, initCommandSelectLogging };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<ui-command data-command-hotkey="mod+shift+k" class="w-full max-w-xl">
|
|
2
|
+
<button
|
|
3
|
+
class="ui-button w-full justify-between"
|
|
4
|
+
type="button"
|
|
5
|
+
data-variant="outline"
|
|
6
|
+
command="show-modal"
|
|
7
|
+
commandfor="command-example-dialog-1"
|
|
8
|
+
data-slot="command-open"
|
|
9
|
+
>
|
|
10
|
+
<span class="text-muted-foreground">Command palette...</span>
|
|
11
|
+
<ui-kbd-group><kbd>⌘</kbd><kbd>⇧</kbd><kbd>K</kbd></ui-kbd-group>
|
|
12
|
+
</button>
|
|
13
|
+
<dialog id="command-example-dialog-1" class="ui-dialog" data-slot="command-panel" closedby="any">
|
|
14
|
+
<header data-slot="command-header">
|
|
15
|
+
<input
|
|
16
|
+
data-slot="command-input"
|
|
17
|
+
type="text"
|
|
18
|
+
placeholder="Type a command or search..."
|
|
19
|
+
role="combobox"
|
|
20
|
+
aria-expanded="false"
|
|
21
|
+
aria-autocomplete="list"
|
|
22
|
+
autocomplete="off"
|
|
23
|
+
aria-label="Search commands"
|
|
24
|
+
/>
|
|
25
|
+
</header>
|
|
26
|
+
<div role="listbox" data-slot="command-list" aria-label="Commands">
|
|
27
|
+
<div role="group" data-slot="command-group" aria-labelledby="command-example-dialog-1-nav">
|
|
28
|
+
<span
|
|
29
|
+
class="font-strong text-eyebrow text-muted-foreground"
|
|
30
|
+
data-slot="command-group-label"
|
|
31
|
+
id="command-example-dialog-1-nav"
|
|
32
|
+
>Navigation</span
|
|
33
|
+
>
|
|
34
|
+
<a
|
|
35
|
+
role="option"
|
|
36
|
+
data-slot="command-item"
|
|
37
|
+
class="ui-button justify-start"
|
|
38
|
+
data-variant="ghost"
|
|
39
|
+
href="#home"
|
|
40
|
+
tabindex="-1"
|
|
41
|
+
>
|
|
42
|
+
Go home
|
|
43
|
+
</a>
|
|
44
|
+
<a
|
|
45
|
+
role="option"
|
|
46
|
+
data-slot="command-item"
|
|
47
|
+
class="ui-button justify-start"
|
|
48
|
+
data-variant="ghost"
|
|
49
|
+
href="#projects"
|
|
50
|
+
tabindex="-1"
|
|
51
|
+
data-keywords="work portfolio"
|
|
52
|
+
>
|
|
53
|
+
Go to projects
|
|
54
|
+
</a>
|
|
55
|
+
<a
|
|
56
|
+
role="option"
|
|
57
|
+
data-slot="command-item"
|
|
58
|
+
class="ui-button justify-start"
|
|
59
|
+
data-variant="ghost"
|
|
60
|
+
href="#team"
|
|
61
|
+
tabindex="-1"
|
|
62
|
+
data-keywords="people members"
|
|
63
|
+
>
|
|
64
|
+
Go to team
|
|
65
|
+
</a>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<p data-slot="command-empty" class="text-muted-foreground">No commands found.</p>
|
|
69
|
+
<footer data-slot="command-footer">
|
|
70
|
+
<span
|
|
71
|
+
><ui-kbd-group><kbd>↑</kbd><kbd>↓</kbd></ui-kbd-group> navigate</span
|
|
72
|
+
>
|
|
73
|
+
<span><kbd>↵</kbd> select</span>
|
|
74
|
+
<span><kbd>esc</kbd> close</span>
|
|
75
|
+
</footer>
|
|
76
|
+
</dialog>
|
|
77
|
+
</ui-command>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* command.css: Command (ui-command | .ui-command, [data-slot~="command-panel"])
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, components
|
|
5
|
+
* @requires layers.css, _variables.css, popover.css, button.css, fields.css,
|
|
6
|
+
* dialog.css, menu.css, select.css (--ui-option-*), kbd.css (--ui-kbd-group-*)
|
|
7
|
+
* @uses popovertarget + [popover="auto"]: dropdown surface, native light dismiss
|
|
8
|
+
* @uses <dialog class="ui-dialog"> + command="show-modal": focused surface
|
|
9
|
+
* @uses anchor-name, anchor-scope, position-anchor: tether the popover form
|
|
10
|
+
* @uses :has(): group + empty-state visibility without JavaScript
|
|
11
|
+
* @tokens --ui-command-* (@layer variables); items alias --ui-option-*
|
|
12
|
+
* @see command.ts: ranking, hotkeys, and activation behavior
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
@layer variables {
|
|
16
|
+
:root {
|
|
17
|
+
--ui-command-min-inline-size: var(--step-96);
|
|
18
|
+
--ui-command-max-block-size: var(--step-96);
|
|
19
|
+
--ui-command-option-gap: var(--ui-field-option-gap);
|
|
20
|
+
--ui-command-input-padding: var(--step-3);
|
|
21
|
+
--ui-command-input-border: 1px solid var(--border);
|
|
22
|
+
--ui-command-group-label-padding: var(--step-2) var(--step-2) var(--step-1);
|
|
23
|
+
--ui-command-footer-padding: var(--step-2);
|
|
24
|
+
--ui-command-footer-border: 1px solid var(--border);
|
|
25
|
+
--ui-command-shadow: var(--ui-menu-shadow);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@layer zazz.components {
|
|
30
|
+
/* ===========================================================================
|
|
31
|
+
COMMAND: palette panel (popover or dialog) with the input inside
|
|
32
|
+
- The popover form rides popover.css's surface + placement; the dialog form
|
|
33
|
+
rides dialog.css. This file shapes the interior: borderless input over a
|
|
34
|
+
hairline, scrollable list, eyebrow group labels, hint footer.
|
|
35
|
+
=========================================================================== */
|
|
36
|
+
|
|
37
|
+
:where(ui-command, .ui-command) {
|
|
38
|
+
anchor-scope: --ui-command-trigger;
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:where(ui-command, .ui-command) > :where([popovertarget], [command]) {
|
|
43
|
+
anchor-name: --ui-command-trigger;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[data-slot~="command-panel"] {
|
|
47
|
+
/* flex-direction stays ungated so the close fade (display held by the
|
|
48
|
+
allow-discrete transition) keeps the column layout to the last frame */
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
min-inline-size: var(--ui-command-min-inline-size);
|
|
51
|
+
box-shadow: var(--ui-command-shadow);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Only display is gated; unconditional it would defeat the UA's
|
|
55
|
+
display: none on closed popovers and dialogs */
|
|
56
|
+
[data-slot~="command-panel"]:where(:popover-open, .\:popover-open, [open]) {
|
|
57
|
+
display: flex;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-slot~="command-panel"]:where([popover]) {
|
|
61
|
+
position-anchor: --ui-command-trigger;
|
|
62
|
+
padding: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Dialog form: the palette owns its interior, edge to edge */
|
|
66
|
+
[data-slot~="command-panel"]:where(dialog) {
|
|
67
|
+
--ui-dialog-width: min(var(--breakpoint-sm), 100% - var(--gutters) * 2);
|
|
68
|
+
padding: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Search input: borderless over a hairline; the panel is the surface */
|
|
72
|
+
[data-slot~="command-header"] {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
border-block-end: var(--ui-command-input-border);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-slot~="command-input"] {
|
|
79
|
+
flex: 1;
|
|
80
|
+
min-inline-size: 0;
|
|
81
|
+
padding: var(--ui-command-input-padding);
|
|
82
|
+
font: inherit;
|
|
83
|
+
font-size: var(--ui-field-font-size);
|
|
84
|
+
color: inherit;
|
|
85
|
+
background: none;
|
|
86
|
+
border: none;
|
|
87
|
+
outline: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[data-slot~="command-list"] {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: var(--ui-command-option-gap);
|
|
94
|
+
max-block-size: var(--ui-command-max-block-size);
|
|
95
|
+
padding: var(--ui-popover-padding);
|
|
96
|
+
margin: 0;
|
|
97
|
+
overflow: auto;
|
|
98
|
+
list-style: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[data-slot~="command-group"] {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
gap: var(--ui-command-option-gap);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[data-slot~="command-group-label"] {
|
|
108
|
+
padding: var(--ui-command-group-label-padding);
|
|
109
|
+
/* Score ranking writes order -1000..0 on sibling items; keep the label first */
|
|
110
|
+
order: -1001;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
[data-slot~="command-item"] {
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[data-slot~="command-item"][data-highlighted] {
|
|
118
|
+
--ui-button-background: var(--ui-button-background--hover);
|
|
119
|
+
--ui-button-foreground: var(--ui-button-foreground--hover);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Shortcut hint: a lone <kbd> or a <ui-kbd-group> run pushes to the end;
|
|
123
|
+
spacing between keys inside a run is the group's --ui-kbd-group-gap. */
|
|
124
|
+
[data-slot~="command-item"] > :where(kbd, ui-kbd-group, .ui-kbd-group) {
|
|
125
|
+
margin-inline-start: auto;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
[data-slot~="command-footer"] {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
gap: var(--step-2);
|
|
132
|
+
padding: var(--ui-command-footer-padding);
|
|
133
|
+
border-block-start: var(--ui-command-footer-border);
|
|
134
|
+
color: var(--muted-foreground);
|
|
135
|
+
font-size: var(--font-size-xs);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
[data-slot~="command-group"]:not(:has([data-slot~="command-item"]:not([hidden]))) {
|
|
139
|
+
display: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
[data-slot~="command-empty"] {
|
|
143
|
+
display: none;
|
|
144
|
+
padding: var(--step-2);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[data-slot~="command-panel"]:not(:has([data-slot~="command-item"]:not([hidden])))
|
|
148
|
+
[data-slot~="command-empty"] {
|
|
149
|
+
display: block;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `<ui-command>`: a command menu for search and quick actions.
|
|
3
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
4
|
+
* (`base/typeahead.ts`), architected after cmdk. The panel (a `popover="auto"`
|
|
5
|
+
* dropdown or a `<dialog class="ui-dialog">`) contains the search input;
|
|
6
|
+
* items rank by match score and the best match auto-highlights.
|
|
7
|
+
*
|
|
8
|
+
* Actions are the platform's own vocabulary: navigation items are real
|
|
9
|
+
* `<a href>` links, and action items are `<button command commandfor>` invoker
|
|
10
|
+
* buttons (including custom `--commands`). Enter activates the highlighted
|
|
11
|
+
* item exactly as a click would; every activation also dispatches a bubbling
|
|
12
|
+
* `zazz:command-select` CustomEvent (`detail: { item, value }`) from the root.
|
|
13
|
+
* Without JavaScript the trigger still opens the panel natively and every
|
|
14
|
+
* item still works: only filtering, highlight, and hotkeys are lost.
|
|
15
|
+
*
|
|
16
|
+
* Attributes:
|
|
17
|
+
* - `data-command-hotkey` (root): global toggle shortcut, e.g. `"mod+k"`.
|
|
18
|
+
* - `data-hotkey` (item): global accelerator that activates the item, active
|
|
19
|
+
* while the element is connected (even with the panel closed).
|
|
20
|
+
* - `data-stay-open` (item): keep the panel open after activation.
|
|
21
|
+
* - `data-sort="document"` (root): opt out of score ranking (default: score).
|
|
22
|
+
*
|
|
23
|
+
* Parts: `command-open` (trigger), `command-panel`, `command-header`,
|
|
24
|
+
* `command-input`, `command-list`, `command-group` / `command-group-label`,
|
|
25
|
+
* `command-item` (`data-value`, `data-keywords`), `command-kbd`,
|
|
26
|
+
* `command-footer`, `command-empty`.
|
|
27
|
+
*
|
|
28
|
+
* For complex custom actions, see the example `command-actions.ts`: listen
|
|
29
|
+
* for your `--command` on its target, or for `zazz:command-select` on the root.
|
|
30
|
+
*/
|
|
31
|
+
import { TypeaheadElement } from "../../base/typeahead.ts";
|
|
32
|
+
declare class UiCommand extends TypeaheadElement {
|
|
33
|
+
#private;
|
|
34
|
+
protected readonly slotPrefix = "command";
|
|
35
|
+
protected readonly managesPanel: boolean;
|
|
36
|
+
protected readonly autoHighlight: boolean;
|
|
37
|
+
/** Command ranks by score unless the author opts back into DOM order. */
|
|
38
|
+
protected get sortByScore(): boolean;
|
|
39
|
+
protected setup(signal: AbortSignal): void;
|
|
40
|
+
/**
|
|
41
|
+
* @description A pointer commit has already run the item's native activation
|
|
42
|
+
* (link navigation, invoker command); a keyboard commit runs it via
|
|
43
|
+
* `click()`. Both announce `zazz:command-select` and close the panel unless
|
|
44
|
+
* the item asks to stay open.
|
|
45
|
+
*
|
|
46
|
+
* @param item - The activated item.
|
|
47
|
+
* @param source - How the commit happened.
|
|
48
|
+
*/
|
|
49
|
+
protected commit(item: HTMLElement, source: "keyboard" | "pointer"): void;
|
|
50
|
+
}
|
|
51
|
+
export { UiCommand };
|
|
52
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["command.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,cAAM,SAAU,SAAQ,gBAAgB;;IACtC,SAAS,CAAC,QAAQ,CAAC,UAAU,aAAa;IAC1C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAS;IACjD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAQ;IAEjD,yEAAyE;IACzE,SAAS,KAAK,WAAW,IAAI,OAAO,CAEnC;IAED,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA2CzC;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAExE;CAiDF;AAID,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<ui-command data-command-hotkey="mod+k" class="w-full max-w-xl">
|
|
2
|
+
<button
|
|
3
|
+
class="ui-button w-full justify-between"
|
|
4
|
+
type="button"
|
|
5
|
+
data-variant="outline"
|
|
6
|
+
popovertarget="command-example-1"
|
|
7
|
+
data-slot="command-open"
|
|
8
|
+
>
|
|
9
|
+
<span class="text-muted-foreground">Search...</span>
|
|
10
|
+
<ui-kbd-group><kbd>⌘</kbd><kbd>K</kbd></ui-kbd-group>
|
|
11
|
+
</button>
|
|
12
|
+
<div
|
|
13
|
+
id="command-example-1"
|
|
14
|
+
data-slot="command-panel"
|
|
15
|
+
data-side="bottom"
|
|
16
|
+
data-align="start"
|
|
17
|
+
popover="auto"
|
|
18
|
+
>
|
|
19
|
+
<header data-slot="command-header">
|
|
20
|
+
<input
|
|
21
|
+
data-slot="command-input"
|
|
22
|
+
type="text"
|
|
23
|
+
placeholder="Type a command or search..."
|
|
24
|
+
role="combobox"
|
|
25
|
+
aria-expanded="false"
|
|
26
|
+
aria-autocomplete="list"
|
|
27
|
+
autocomplete="off"
|
|
28
|
+
aria-label="Search commands"
|
|
29
|
+
/>
|
|
30
|
+
</header>
|
|
31
|
+
<div role="listbox" data-slot="command-list" aria-label="Commands">
|
|
32
|
+
<div role="group" data-slot="command-group" aria-labelledby="command-example-1-nav">
|
|
33
|
+
<span
|
|
34
|
+
class="font-strong text-eyebrow text-muted-foreground"
|
|
35
|
+
data-slot="command-group-label"
|
|
36
|
+
id="command-example-1-nav"
|
|
37
|
+
>Navigation</span
|
|
38
|
+
>
|
|
39
|
+
<a
|
|
40
|
+
role="option"
|
|
41
|
+
data-slot="command-item"
|
|
42
|
+
class="ui-button justify-start"
|
|
43
|
+
data-variant="ghost"
|
|
44
|
+
href="#docs"
|
|
45
|
+
tabindex="-1"
|
|
46
|
+
data-keywords="documentation guides"
|
|
47
|
+
data-hotkey="mod+shift+d"
|
|
48
|
+
>
|
|
49
|
+
Go to docs
|
|
50
|
+
<ui-kbd-group><kbd>⇧</kbd><kbd>⌘</kbd><kbd>D</kbd></ui-kbd-group>
|
|
51
|
+
</a>
|
|
52
|
+
<a
|
|
53
|
+
role="option"
|
|
54
|
+
data-slot="command-item"
|
|
55
|
+
class="ui-button justify-start"
|
|
56
|
+
data-variant="ghost"
|
|
57
|
+
href="#settings"
|
|
58
|
+
tabindex="-1"
|
|
59
|
+
data-keywords="preferences options"
|
|
60
|
+
data-hotkey="mod+shift+s"
|
|
61
|
+
>
|
|
62
|
+
Go to settings
|
|
63
|
+
<ui-kbd-group><kbd>⇧</kbd><kbd>⌘</kbd><kbd>S</kbd></ui-kbd-group>
|
|
64
|
+
</a>
|
|
65
|
+
</div>
|
|
66
|
+
<div role="group" data-slot="command-group" aria-labelledby="command-example-1-actions">
|
|
67
|
+
<span
|
|
68
|
+
class="font-strong text-eyebrow text-muted-foreground"
|
|
69
|
+
data-slot="command-group-label"
|
|
70
|
+
id="command-example-1-actions"
|
|
71
|
+
>Actions</span
|
|
72
|
+
>
|
|
73
|
+
<button
|
|
74
|
+
role="option"
|
|
75
|
+
data-slot="command-item"
|
|
76
|
+
class="ui-button justify-start"
|
|
77
|
+
data-variant="ghost"
|
|
78
|
+
type="button"
|
|
79
|
+
command="show-modal"
|
|
80
|
+
commandfor="command-example-1-dialog"
|
|
81
|
+
tabindex="-1"
|
|
82
|
+
data-keywords="modal open"
|
|
83
|
+
>
|
|
84
|
+
Open example dialog
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
<p data-slot="command-empty" class="text-muted-foreground text-sm">No commands found.</p>
|
|
89
|
+
<footer data-slot="command-footer">
|
|
90
|
+
<span
|
|
91
|
+
><ui-kbd-group><kbd>↑</kbd><kbd>↓</kbd></ui-kbd-group> navigate</span
|
|
92
|
+
>
|
|
93
|
+
<span><kbd>↵</kbd> select</span>
|
|
94
|
+
<span><kbd>esc</kbd> close</span>
|
|
95
|
+
</footer>
|
|
96
|
+
</div>
|
|
97
|
+
</ui-command>
|
|
98
|
+
|
|
99
|
+
<dialog
|
|
100
|
+
id="command-example-1-dialog"
|
|
101
|
+
class="ui-dialog"
|
|
102
|
+
closedby="any"
|
|
103
|
+
data-side="bottom"
|
|
104
|
+
data-align="center"
|
|
105
|
+
>
|
|
106
|
+
<div data-slot="dialog-content">
|
|
107
|
+
<header data-slot="dialog-header">
|
|
108
|
+
<h2 class="text-lg font-heading font-strong">Opened by a command</h2>
|
|
109
|
+
</header>
|
|
110
|
+
<div data-slot="dialog-body">
|
|
111
|
+
<p>The command item is a plain invoker button (no custom wiring).</p>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<footer data-slot="dialog-footer">
|
|
115
|
+
<button class="ui-button" type="button" commandfor="command-example-1-dialog" command="close">
|
|
116
|
+
Close
|
|
117
|
+
</button>
|
|
118
|
+
</footer>
|
|
119
|
+
</dialog>
|