@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,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* accordion.css: Accordion (ui-accordion | .ui-accordion on <details>/<summary>)
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, reset, components
|
|
5
|
+
* @requires layers.css, _variables.css
|
|
6
|
+
* @uses ::details-content: native open/close block-size transition (reset layer)
|
|
7
|
+
* @uses interpolate-size: allow-keywords (from _variables.css; required for
|
|
8
|
+
* block-size: 0 -> auto transitions)
|
|
9
|
+
* @tokens --ui-accordion-* (@layer variables)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer variables {
|
|
13
|
+
:root {
|
|
14
|
+
--ui-accordion-icon-size: var(--step-4);
|
|
15
|
+
--ui-accordion-icon-transform-open: rotate(-180deg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@layer reset {
|
|
20
|
+
/* ===========================================================================
|
|
21
|
+
DETAILS & SUMMARY: native open/close transition + summary marker reset
|
|
22
|
+
- In the reset layer so the :where(ui-accordion, .ui-accordion) component styling below wins.
|
|
23
|
+
=========================================================================== */
|
|
24
|
+
|
|
25
|
+
:where(details)::details-content {
|
|
26
|
+
--details-content-transition:
|
|
27
|
+
opacity var(--default-transition-duration) var(--default-transition-timing-function),
|
|
28
|
+
transform var(--default-transition-duration) var(--default-transition-timing-function),
|
|
29
|
+
block-size var(--default-transition-duration) var(--default-transition-timing-function),
|
|
30
|
+
content-visibility var(--default-transition-duration)
|
|
31
|
+
var(--default-transition-timing-function) allow-discrete;
|
|
32
|
+
|
|
33
|
+
block-size: 0;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
transition: var(--details-content-transition);
|
|
36
|
+
will-change: opacity, transform, block-size, content-visibility;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:where(details[open])::details-content {
|
|
40
|
+
block-size: auto;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:where(summary) {
|
|
44
|
+
display: flex;
|
|
45
|
+
text-decoration: none;
|
|
46
|
+
user-select: none;
|
|
47
|
+
list-style: none;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@layer zazz.components {
|
|
52
|
+
:where(ui-accordion, .ui-accordion) {
|
|
53
|
+
display: grid;
|
|
54
|
+
inline-size: 100%;
|
|
55
|
+
flex: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:where(ui-accordion, .ui-accordion) > details {
|
|
59
|
+
display: grid;
|
|
60
|
+
flex: 1 0 auto;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:where(ui-accordion, .ui-accordion) > details > summary {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
|
|
68
|
+
/* ring renders as box-shadow; the ring widths animate from 0 so the ring
|
|
69
|
+
grows in smoothly on focus */
|
|
70
|
+
--_ring-offset-width: 0px;
|
|
71
|
+
--_ring-width: 0px;
|
|
72
|
+
box-shadow:
|
|
73
|
+
0 0 0 var(--_ring-offset-width) var(--ring-offset-color),
|
|
74
|
+
0 0 0 calc(var(--_ring-offset-width) + var(--_ring-width)) var(--_ring, var(--ring));
|
|
75
|
+
|
|
76
|
+
/* transparent twin of the ring for forced-colors / high-contrast modes */
|
|
77
|
+
outline: var(--outline-width) var(--outline-style) transparent;
|
|
78
|
+
outline-offset: var(--outline-offset);
|
|
79
|
+
|
|
80
|
+
transition: var(--default-transition);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:where(ui-accordion, .ui-accordion) > details > summary:focus-visible {
|
|
84
|
+
--_ring-offset-width: var(--ring-offset-width);
|
|
85
|
+
--_ring-width: var(--ring-width);
|
|
86
|
+
|
|
87
|
+
outline-color: transparent;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:where(ui-accordion, .ui-accordion) summary > svg {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
inline-size: var(--ui-accordion-icon-size);
|
|
95
|
+
block-size: var(--ui-accordion-icon-size);
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
transition: transform var(--default-transition-duration)
|
|
98
|
+
var(--default-transition-timing-function);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:where(ui-accordion, .ui-accordion) > details[open] > summary > svg {
|
|
102
|
+
transform: var(--ui-accordion-icon-transform-open);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<ui-accordion>
|
|
2
|
+
<details class="border-b py-sm">
|
|
3
|
+
<summary class="font-strong hover:text-muted-foreground">
|
|
4
|
+
What is an accordion?
|
|
5
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
6
|
+
<rect width="256" height="256" fill="none" />
|
|
7
|
+
<polyline
|
|
8
|
+
points="208 96 128 176 48 96"
|
|
9
|
+
fill="none"
|
|
10
|
+
stroke="currentColor"
|
|
11
|
+
stroke-linecap="round"
|
|
12
|
+
stroke-linejoin="round"
|
|
13
|
+
stroke-width="16"
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
|
16
|
+
</summary>
|
|
17
|
+
<div class="pb-sm">
|
|
18
|
+
<p>
|
|
19
|
+
A disclosure widget built from the native <code><details></code> and
|
|
20
|
+
<code><summary></code> elements. The open/close animation uses the
|
|
21
|
+
<code>::details-content</code> pseudo-element — no JavaScript.
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
24
|
+
</details>
|
|
25
|
+
<details class="border-b py-sm">
|
|
26
|
+
<summary class="font-strong hover:text-muted-foreground">
|
|
27
|
+
How does it work?
|
|
28
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
29
|
+
<rect width="256" height="256" fill="none" />
|
|
30
|
+
<polyline
|
|
31
|
+
points="208 96 128 176 48 96"
|
|
32
|
+
fill="none"
|
|
33
|
+
stroke="currentColor"
|
|
34
|
+
stroke-linecap="round"
|
|
35
|
+
stroke-linejoin="round"
|
|
36
|
+
stroke-width="16"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
39
|
+
</summary>
|
|
40
|
+
<div class="pb-sm">
|
|
41
|
+
<p>
|
|
42
|
+
Each item is a separate <code><details></code>, so several can stay open at once.
|
|
43
|
+
Click a summary or focus it and press Enter to toggle.
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
</details>
|
|
47
|
+
<details class="border-b py-sm">
|
|
48
|
+
<summary class="font-strong hover:text-muted-foreground">
|
|
49
|
+
Why use it?
|
|
50
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
51
|
+
<rect width="256" height="256" fill="none" />
|
|
52
|
+
<polyline
|
|
53
|
+
points="208 96 128 176 48 96"
|
|
54
|
+
fill="none"
|
|
55
|
+
stroke="currentColor"
|
|
56
|
+
stroke-linecap="round"
|
|
57
|
+
stroke-linejoin="round"
|
|
58
|
+
stroke-width="16"
|
|
59
|
+
/>
|
|
60
|
+
</svg>
|
|
61
|
+
</summary>
|
|
62
|
+
<div class="pb-sm">
|
|
63
|
+
<p>
|
|
64
|
+
Keyboard support, state, and accessibility come from the platform — Zazz only styles the
|
|
65
|
+
chrome through theme tokens.
|
|
66
|
+
</p>
|
|
67
|
+
</div>
|
|
68
|
+
</details>
|
|
69
|
+
</ui-accordion>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* alert-dialog.css: Alert dialog (.ui-alert-dialog on .ui-dialog <dialog>)
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, components
|
|
5
|
+
* @requires layers.css, _variables.css, dialog.css
|
|
6
|
+
* @uses closedby="none": the alert contract: only an explicit choice closes it
|
|
7
|
+
* @uses command="show-modal" / command="close": Invoker Commands (polyfill: invokers)
|
|
8
|
+
* @tokens --ui-alert-dialog-* (@layer variables)
|
|
9
|
+
* @see dialog.css: owns the slots, motion, and backdrop this composes
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@layer variables {
|
|
13
|
+
:root {
|
|
14
|
+
/* Narrower than the base dialog: an alert is a single question, not a form */
|
|
15
|
+
--ui-alert-dialog-width: min(45ch, 100% - var(--gap-md) * 2);
|
|
16
|
+
--ui-alert-dialog-accent: var(--destructive);
|
|
17
|
+
--ui-alert-dialog-shadow: var(--ui-dialog-shadow);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@layer zazz.components {
|
|
22
|
+
/* ===========================================================================
|
|
23
|
+
ALERT DIALOG: a dialog that requires an explicit response
|
|
24
|
+
- Composes .ui-dialog (markup carries both classes) and keeps the dialog-*
|
|
25
|
+
slots; this file only retunes dialog tokens and colors the header accent.
|
|
26
|
+
- The contract lives in the markup: role="alertdialog", closedby="none",
|
|
27
|
+
no dialog-close button: Cancel/Confirm are the only ways out.
|
|
28
|
+
=========================================================================== */
|
|
29
|
+
|
|
30
|
+
.ui-alert-dialog {
|
|
31
|
+
--ui-dialog-width: var(--ui-alert-dialog-width);
|
|
32
|
+
--ui-dialog-shadow: var(--ui-alert-dialog-shadow);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ui-alert-dialog [data-slot~="dialog-header"] {
|
|
36
|
+
color: var(--ui-alert-dialog-accent);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<button
|
|
2
|
+
class="ui-button"
|
|
3
|
+
type="button"
|
|
4
|
+
data-variant="destructive"
|
|
5
|
+
command="show-modal"
|
|
6
|
+
commandfor="alert-dialog-example-1"
|
|
7
|
+
>
|
|
8
|
+
Delete account
|
|
9
|
+
</button>
|
|
10
|
+
<dialog
|
|
11
|
+
id="alert-dialog-example-1"
|
|
12
|
+
class="ui-dialog ui-alert-dialog"
|
|
13
|
+
role="alertdialog"
|
|
14
|
+
aria-labelledby="alert-dialog-example-1-title"
|
|
15
|
+
aria-describedby="alert-dialog-example-1-body"
|
|
16
|
+
closedby="none"
|
|
17
|
+
>
|
|
18
|
+
<div data-slot="dialog-content">
|
|
19
|
+
<header class="flex-row items-center gap-xs" data-slot="dialog-header">
|
|
20
|
+
<svg class="size-md" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
21
|
+
<rect width="256" height="256" fill="none" />
|
|
22
|
+
<path
|
|
23
|
+
fill="currentColor"
|
|
24
|
+
d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"
|
|
25
|
+
/>
|
|
26
|
+
</svg>
|
|
27
|
+
<h2 class="text-lg font-heading font-strong" id="alert-dialog-example-1-title">
|
|
28
|
+
Are you absolutely sure?
|
|
29
|
+
</h2>
|
|
30
|
+
</header>
|
|
31
|
+
<div class="italic" data-slot="dialog-body" id="alert-dialog-example-1-body">
|
|
32
|
+
<p>
|
|
33
|
+
Alert dialogs must be closed by clicking the Cancel or Continue buttons. Changing
|
|
34
|
+
<code>closedby="none"</code> to <code>closedby="any"</code> allows the user to close the
|
|
35
|
+
dialog by clicking outside the dialog or pressing the Escape key.
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<footer data-slot="dialog-footer">
|
|
40
|
+
<button class="ui-button" type="button" commandfor="alert-dialog-example-1" command="close">
|
|
41
|
+
Cancel
|
|
42
|
+
</button>
|
|
43
|
+
<button
|
|
44
|
+
class="ui-button"
|
|
45
|
+
data-variant="destructive"
|
|
46
|
+
type="button"
|
|
47
|
+
commandfor="alert-dialog-example-1"
|
|
48
|
+
command="close"
|
|
49
|
+
>
|
|
50
|
+
Delete account
|
|
51
|
+
</button>
|
|
52
|
+
</footer>
|
|
53
|
+
</dialog>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div class="ui-field max-w-xl">
|
|
2
|
+
<label data-slot="field-label" for="ac-produce">Produce</label>
|
|
3
|
+
<ui-autocomplete data-sort="score">
|
|
4
|
+
<input
|
|
5
|
+
class="ui-input"
|
|
6
|
+
id="ac-produce"
|
|
7
|
+
name="produce"
|
|
8
|
+
type="text"
|
|
9
|
+
placeholder="Search produce..."
|
|
10
|
+
role="combobox"
|
|
11
|
+
aria-expanded="false"
|
|
12
|
+
aria-autocomplete="list"
|
|
13
|
+
autocomplete="off"
|
|
14
|
+
/>
|
|
15
|
+
<div data-slot="autocomplete-panel" data-side="bottom" data-align="start" popover="manual">
|
|
16
|
+
<ul role="listbox" data-slot="autocomplete-list" aria-label="Produce suggestions">
|
|
17
|
+
<li role="group" data-slot="autocomplete-group" aria-labelledby="ac-group-fruit">
|
|
18
|
+
<span
|
|
19
|
+
class="font-strong text-eyebrow text-muted-foreground p-xs"
|
|
20
|
+
data-slot="autocomplete-group-label"
|
|
21
|
+
id="ac-group-fruit"
|
|
22
|
+
>Fruit</span
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
role="option"
|
|
26
|
+
data-slot="autocomplete-item"
|
|
27
|
+
class="ui-button justify-start"
|
|
28
|
+
data-variant="ghost"
|
|
29
|
+
data-value="Apple"
|
|
30
|
+
data-keywords="fruit red"
|
|
31
|
+
>
|
|
32
|
+
Apple
|
|
33
|
+
</div>
|
|
34
|
+
<div
|
|
35
|
+
role="option"
|
|
36
|
+
data-slot="autocomplete-item"
|
|
37
|
+
class="ui-button justify-start"
|
|
38
|
+
data-variant="ghost"
|
|
39
|
+
data-value="Cherry"
|
|
40
|
+
data-keywords="fruit red"
|
|
41
|
+
>
|
|
42
|
+
Cherry
|
|
43
|
+
</div>
|
|
44
|
+
</li>
|
|
45
|
+
<li role="group" data-slot="autocomplete-group" aria-labelledby="ac-group-veg">
|
|
46
|
+
<span
|
|
47
|
+
class="font-strong text-eyebrow text-muted-foreground p-xs"
|
|
48
|
+
data-slot="autocomplete-group-label"
|
|
49
|
+
id="ac-group-veg"
|
|
50
|
+
>Vegetables</span
|
|
51
|
+
>
|
|
52
|
+
<div
|
|
53
|
+
role="option"
|
|
54
|
+
data-slot="autocomplete-item"
|
|
55
|
+
class="ui-button justify-start"
|
|
56
|
+
data-variant="ghost"
|
|
57
|
+
data-value="Carrot"
|
|
58
|
+
data-keywords="vegetable orange"
|
|
59
|
+
>
|
|
60
|
+
Carrot
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
role="option"
|
|
64
|
+
data-slot="autocomplete-item"
|
|
65
|
+
class="ui-button justify-start"
|
|
66
|
+
data-variant="ghost"
|
|
67
|
+
data-value="Cauliflower"
|
|
68
|
+
data-keywords="vegetable white"
|
|
69
|
+
>
|
|
70
|
+
Cauliflower
|
|
71
|
+
</div>
|
|
72
|
+
</li>
|
|
73
|
+
</ul>
|
|
74
|
+
<p data-slot="autocomplete-empty" class="text-muted-foreground">No results.</p>
|
|
75
|
+
</div>
|
|
76
|
+
</ui-autocomplete>
|
|
77
|
+
</div>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autocomplete.css — Autocomplete (ui-autocomplete | .ui-autocomplete, [data-slot~="autocomplete-panel"])
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, components
|
|
5
|
+
* @requires layers.css, _variables.css, popover.css, button.css, fields.css,
|
|
6
|
+
* select.css (--ui-option-*), input.css
|
|
7
|
+
* @uses [popover="manual"] — panel opened/closed by autocomplete.js
|
|
8
|
+
* @uses anchor-name, anchor-scope, position-anchor — tether panel to the input
|
|
9
|
+
* @uses anchor-size(width) — match panel width to the input (@supports gated)
|
|
10
|
+
* @uses :has() — group + empty-state visibility without JavaScript
|
|
11
|
+
* @uses data-side / data-align — maps to --ui-popover-position-* in popover.css
|
|
12
|
+
* @tokens --ui-autocomplete-* (@layer variables); items alias --ui-option-*
|
|
13
|
+
* @see autocomplete.ts — filtering, ranking, and keyboard behavior
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
@layer variables {
|
|
17
|
+
:root {
|
|
18
|
+
--ui-autocomplete-panel-max-block-size: var(--step-72);
|
|
19
|
+
--ui-autocomplete-shadow: var(--ui-menu-shadow);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@layer zazz.components {
|
|
24
|
+
/* ===========================================================================
|
|
25
|
+
AUTOCOMPLETE — input + anchored suggestion panel
|
|
26
|
+
- The input is a plain .ui-input and the no-JS baseline; the panel is a
|
|
27
|
+
manual popover the script owns, riding popover.css's surface + placement.
|
|
28
|
+
- Items are ghost buttons (the --ui-option-* alias family), so a select's
|
|
29
|
+
options and an autocomplete's suggestions read identically.
|
|
30
|
+
=========================================================================== */
|
|
31
|
+
|
|
32
|
+
:where(ui-autocomplete, .ui-autocomplete) {
|
|
33
|
+
anchor-scope: --ui-autocomplete-trigger;
|
|
34
|
+
display: block;
|
|
35
|
+
inline-size: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:where(ui-autocomplete, .ui-autocomplete) input:where([role="combobox"]) {
|
|
39
|
+
anchor-name: --ui-autocomplete-trigger;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-slot~="autocomplete-panel"] {
|
|
43
|
+
position-anchor: --ui-autocomplete-trigger;
|
|
44
|
+
/* flex-direction stays ungated so the close fade keeps the column layout */
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
max-block-size: var(--ui-autocomplete-panel-max-block-size);
|
|
47
|
+
overflow: auto;
|
|
48
|
+
box-shadow: var(--ui-autocomplete-shadow);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Only display is gated — see popover.css: closed popovers stay display: none */
|
|
52
|
+
[data-slot~="autocomplete-panel"]:where(:popover-open, .\:popover-open) {
|
|
53
|
+
display: flex;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Inline variant — no [popover]: the list renders in flow, always open,
|
|
57
|
+
without the floating surface chrome (autocomplete.js treats it as such) */
|
|
58
|
+
[data-slot~="autocomplete-panel"]:not([popover]) {
|
|
59
|
+
display: flex;
|
|
60
|
+
box-shadow: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@supports (inline-size: anchor-size(width)) {
|
|
64
|
+
[data-slot~="autocomplete-panel"] {
|
|
65
|
+
min-inline-size: anchor-size(width);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[data-slot~="autocomplete-list"] {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: var(--step-px);
|
|
73
|
+
margin: 0;
|
|
74
|
+
padding: 0;
|
|
75
|
+
list-style: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-slot~="autocomplete-group"] {
|
|
79
|
+
display: flex;
|
|
80
|
+
flex-direction: column;
|
|
81
|
+
gap: var(--step-px);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Score ranking writes order -1000..0 on sibling items — keep the label first */
|
|
85
|
+
[data-slot~="autocomplete-group-label"] {
|
|
86
|
+
order: -1001;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[data-slot~="autocomplete-item"] {
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Keyboard highlight mirrors hover — variants only reassign tokens */
|
|
94
|
+
[data-slot~="autocomplete-item"][data-highlighted] {
|
|
95
|
+
--ui-button-background: var(--ui-button-background--hover);
|
|
96
|
+
--ui-button-foreground: var(--ui-button-foreground--hover);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* A group with no visible items disappears, label and all — no JS */
|
|
100
|
+
[data-slot~="autocomplete-group"]:not(:has([data-slot~="autocomplete-item"]:not([hidden]))) {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Empty state appears only when nothing matches */
|
|
105
|
+
[data-slot~="autocomplete-empty"] {
|
|
106
|
+
display: none;
|
|
107
|
+
padding: var(--step-2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[data-slot~="autocomplete-panel"]:not(:has([data-slot~="autocomplete-item"]:not([hidden])))
|
|
111
|
+
[data-slot~="autocomplete-empty"] {
|
|
112
|
+
display: block;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `<ui-autocomplete>`: an input that suggests options as you type.
|
|
3
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
4
|
+
* (`base/typeahead.ts`). The visible input is the form value (free text is
|
|
5
|
+
* allowed) and the anchored `popover="manual"` panel suggests matches ranked
|
|
6
|
+
* by the vendored cmdk scorer. Committing a suggestion (Enter or click) fills
|
|
7
|
+
* the input; without JavaScript the markup degrades to a plain `.ui-input`.
|
|
8
|
+
*
|
|
9
|
+
* Attributes on the root:
|
|
10
|
+
* - `data-sort="score"`: re-rank visually by match score (default: DOM order).
|
|
11
|
+
* - `data-min-length="<n>"`: query length before the panel opens (default 0).
|
|
12
|
+
*
|
|
13
|
+
* Parts: `autocomplete-panel` (popover="manual"), `autocomplete-list`
|
|
14
|
+
* ([role="listbox"]), `autocomplete-item` ([role="option"], `data-value`,
|
|
15
|
+
* optional `data-keywords`), `autocomplete-group` / `autocomplete-group-label`,
|
|
16
|
+
* `autocomplete-empty`.
|
|
17
|
+
*/
|
|
18
|
+
import { TypeaheadElement } from "../../base/typeahead.ts";
|
|
19
|
+
declare class UiAutocomplete extends TypeaheadElement {
|
|
20
|
+
protected readonly slotPrefix = "autocomplete";
|
|
21
|
+
/**
|
|
22
|
+
* @description Committing a suggestion fills the visible input (which is
|
|
23
|
+
* the form value), closes the panel, and returns to typing position.
|
|
24
|
+
*
|
|
25
|
+
* @param item - The committed option.
|
|
26
|
+
*/
|
|
27
|
+
protected commit(item: HTMLElement, _source: "keyboard" | "pointer"): void;
|
|
28
|
+
}
|
|
29
|
+
export { UiAutocomplete };
|
|
30
|
+
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["autocomplete.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,cAAM,cAAe,SAAQ,gBAAgB;IAC3C,SAAS,CAAC,QAAQ,CAAC,UAAU,kBAAkB;IAE/C;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAQzE;CACF;AAID,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<div class="ui-field max-w-xl">
|
|
2
|
+
<label data-slot="field-label" for="ac-fruit">Fruit</label>
|
|
3
|
+
<ui-autocomplete>
|
|
4
|
+
<input
|
|
5
|
+
class="ui-input"
|
|
6
|
+
id="ac-fruit"
|
|
7
|
+
name="fruit"
|
|
8
|
+
type="text"
|
|
9
|
+
placeholder="Search fruits..."
|
|
10
|
+
role="combobox"
|
|
11
|
+
aria-expanded="false"
|
|
12
|
+
aria-autocomplete="list"
|
|
13
|
+
autocomplete="off"
|
|
14
|
+
/>
|
|
15
|
+
<div data-slot="autocomplete-panel" data-side="bottom" data-align="start" popover="manual">
|
|
16
|
+
<ul role="listbox" data-slot="autocomplete-list" aria-label="Fruit suggestions">
|
|
17
|
+
<li
|
|
18
|
+
role="option"
|
|
19
|
+
data-slot="autocomplete-item"
|
|
20
|
+
class="ui-button justify-start"
|
|
21
|
+
data-variant="ghost"
|
|
22
|
+
data-value="Apple"
|
|
23
|
+
>
|
|
24
|
+
Apple
|
|
25
|
+
</li>
|
|
26
|
+
<li
|
|
27
|
+
role="option"
|
|
28
|
+
data-slot="autocomplete-item"
|
|
29
|
+
class="ui-button justify-start"
|
|
30
|
+
data-variant="ghost"
|
|
31
|
+
data-value="Banana"
|
|
32
|
+
>
|
|
33
|
+
Banana
|
|
34
|
+
</li>
|
|
35
|
+
<li
|
|
36
|
+
role="option"
|
|
37
|
+
data-slot="autocomplete-item"
|
|
38
|
+
class="ui-button justify-start"
|
|
39
|
+
data-variant="ghost"
|
|
40
|
+
data-value="Blueberry"
|
|
41
|
+
>
|
|
42
|
+
Blueberry
|
|
43
|
+
</li>
|
|
44
|
+
<li
|
|
45
|
+
role="option"
|
|
46
|
+
data-slot="autocomplete-item"
|
|
47
|
+
class="ui-button justify-start"
|
|
48
|
+
data-variant="ghost"
|
|
49
|
+
data-value="Cherry"
|
|
50
|
+
>
|
|
51
|
+
Cherry
|
|
52
|
+
</li>
|
|
53
|
+
<li
|
|
54
|
+
role="option"
|
|
55
|
+
data-slot="autocomplete-item"
|
|
56
|
+
class="ui-button justify-start"
|
|
57
|
+
data-variant="ghost"
|
|
58
|
+
data-value="Grape"
|
|
59
|
+
>
|
|
60
|
+
Grape
|
|
61
|
+
</li>
|
|
62
|
+
</ul>
|
|
63
|
+
<p data-slot="autocomplete-empty" class="text-muted-foreground">No results.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</ui-autocomplete>
|
|
66
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview `<ui-autocomplete>`: an input that suggests options as you type.
|
|
4
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
5
|
+
* (`base/typeahead.ts`). The visible input is the form value (free text is
|
|
6
|
+
* allowed) and the anchored `popover="manual"` panel suggests matches ranked
|
|
7
|
+
* by the vendored cmdk scorer. Committing a suggestion (Enter or click) fills
|
|
8
|
+
* the input; without JavaScript the markup degrades to a plain `.ui-input`.
|
|
9
|
+
*
|
|
10
|
+
* Attributes on the root:
|
|
11
|
+
* - `data-sort="score"`: re-rank visually by match score (default: DOM order).
|
|
12
|
+
* - `data-min-length="<n>"`: query length before the panel opens (default 0).
|
|
13
|
+
*
|
|
14
|
+
* Parts: `autocomplete-panel` (popover="manual"), `autocomplete-list`
|
|
15
|
+
* ([role="listbox"]), `autocomplete-item` ([role="option"], `data-value`,
|
|
16
|
+
* optional `data-keywords`), `autocomplete-group` / `autocomplete-group-label`,
|
|
17
|
+
* `autocomplete-empty`.
|
|
18
|
+
*/
|
|
19
|
+
import { TypeaheadElement } from "../../base/typeahead.js";
|
|
20
|
+
import { defineZazzElement } from "../../base/zazz-element.js";
|
|
21
|
+
class UiAutocomplete extends TypeaheadElement {
|
|
22
|
+
slotPrefix = "autocomplete";
|
|
23
|
+
/**
|
|
24
|
+
* @description Committing a suggestion fills the visible input (which is
|
|
25
|
+
* the form value), closes the panel, and returns to typing position.
|
|
26
|
+
*
|
|
27
|
+
* @param item - The committed option.
|
|
28
|
+
*/
|
|
29
|
+
commit(item, _source) {
|
|
30
|
+
const input = this.searchInput;
|
|
31
|
+
if (!input)
|
|
32
|
+
return;
|
|
33
|
+
input.value = this.itemValue(item);
|
|
34
|
+
this.query.set(input.value);
|
|
35
|
+
this.open.set(false);
|
|
36
|
+
input.focus();
|
|
37
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
defineZazzElement("ui-autocomplete", UiAutocomplete);
|
|
41
|
+
export { UiAutocomplete };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview `<ui-autocomplete>`: an input that suggests options as you type.
|
|
5
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
6
|
+
* (`base/typeahead.ts`). The visible input is the form value (free text is
|
|
7
|
+
* allowed) and the anchored `popover="manual"` panel suggests matches ranked
|
|
8
|
+
* by the vendored cmdk scorer. Committing a suggestion (Enter or click) fills
|
|
9
|
+
* the input; without JavaScript the markup degrades to a plain `.ui-input`.
|
|
10
|
+
*
|
|
11
|
+
* Attributes on the root:
|
|
12
|
+
* - `data-sort="score"`: re-rank visually by match score (default: DOM order).
|
|
13
|
+
* - `data-min-length="<n>"`: query length before the panel opens (default 0).
|
|
14
|
+
*
|
|
15
|
+
* Parts: `autocomplete-panel` (popover="manual"), `autocomplete-list`
|
|
16
|
+
* ([role="listbox"]), `autocomplete-item` ([role="option"], `data-value`,
|
|
17
|
+
* optional `data-keywords`), `autocomplete-group` / `autocomplete-group-label`,
|
|
18
|
+
* `autocomplete-empty`.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { TypeaheadElement } from "../../base/typeahead.ts";
|
|
22
|
+
import { defineZazzElement } from "../../base/zazz-element.ts";
|
|
23
|
+
|
|
24
|
+
class UiAutocomplete extends TypeaheadElement {
|
|
25
|
+
protected readonly slotPrefix = "autocomplete";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @description Committing a suggestion fills the visible input (which is
|
|
29
|
+
* the form value), closes the panel, and returns to typing position.
|
|
30
|
+
*
|
|
31
|
+
* @param item - The committed option.
|
|
32
|
+
*/
|
|
33
|
+
protected commit(item: HTMLElement, _source: "keyboard" | "pointer"): void {
|
|
34
|
+
const input = this.searchInput;
|
|
35
|
+
if (!input) return;
|
|
36
|
+
input.value = this.itemValue(item);
|
|
37
|
+
this.query.set(input.value);
|
|
38
|
+
this.open.set(false);
|
|
39
|
+
input.focus();
|
|
40
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
defineZazzElement("ui-autocomplete", UiAutocomplete);
|
|
45
|
+
|
|
46
|
+
export { UiAutocomplete };
|