@zazz-ui/core 0.4.0 → 0.5.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/AUTHORING.md +158 -0
- package/CHANGELOG.md +341 -0
- package/README.md +55 -23
- package/dist/scroll-state-C8mA5gq6.js +1 -0
- package/dist/sri.json +124 -72
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +116794 -0
- package/editor/zazz.html-data.json +1683 -0
- package/editor/zazz.language-data.json +5001 -0
- package/editor/zazz.lint-data.json +152 -0
- package/package.json +12 -5
- package/src/base/_breakpoints.css +12 -0
- package/src/base/_layers.css +8 -9
- package/src/base/_properties-2xl.css +171 -0
- package/src/base/_properties-active.css +107 -0
- package/src/base/_properties-checked.css +107 -0
- package/src/base/_properties-current.css +107 -0
- package/src/base/_properties-disabled.css +107 -0
- package/src/base/_properties-focus-visible.css +107 -0
- package/src/base/_properties-focus-within.css +107 -0
- package/src/base/_properties-hover.css +107 -0
- package/src/base/_properties-lg.css +171 -0
- package/src/base/_properties-md.css +171 -0
- package/src/base/_properties-open.css +107 -0
- package/src/base/_properties-sm.css +171 -0
- package/src/base/_properties-starting.css +55 -0
- package/src/base/_properties-stuck.css +55 -0
- package/src/base/_properties-xl.css +171 -0
- package/src/base/_properties.css +555 -0
- package/src/base/_reset.css +67 -75
- package/src/base/_switches.css +145 -0
- package/src/base/_typography.css +437 -370
- package/src/base/_utilities-box.css +142 -0
- package/src/base/_utilities-color.css +290 -0
- package/src/base/_utilities-effects.css +235 -0
- package/src/base/_utilities-flow.css +312 -0
- package/src/base/_utilities-grid.css +143 -0
- package/src/base/_utilities-margin.css +376 -0
- package/src/base/_utilities-pseudo.css +426 -0
- package/src/base/_utilities-sizing.css +259 -0
- package/src/base/_utilities-spacing.css +190 -0
- package/src/base/_utilities-tier-2xl.css +93 -0
- package/src/base/_utilities-tier-active.css +61 -0
- package/src/base/_utilities-tier-checked.css +61 -0
- package/src/base/_utilities-tier-current.css +61 -0
- package/src/base/_utilities-tier-disabled.css +61 -0
- package/src/base/_utilities-tier-focus-visible.css +61 -0
- package/src/base/_utilities-tier-focus-within.css +61 -0
- package/src/base/_utilities-tier-hover.css +63 -0
- package/src/base/_utilities-tier-lg.css +93 -0
- package/src/base/_utilities-tier-md.css +93 -0
- package/src/base/_utilities-tier-open.css +61 -0
- package/src/base/_utilities-tier-sm.css +93 -0
- package/src/base/_utilities-tier-starting.css +35 -0
- package/src/base/_utilities-tier-stuck.css +114 -0
- package/src/base/_utilities-tier-xl.css +93 -0
- package/src/base/_utilities-typography.css +141 -0
- package/src/base/_variables.css +323 -372
- package/src/base/_view-transitions.css +10 -12
- package/src/base/command-score.d.ts.map +1 -1
- package/src/base/command-score.js +1 -2
- package/src/base/command-score.ts +1 -2
- package/src/base/dialog-lifecycle.js +1 -1
- package/src/base/dialog-lifecycle.ts +1 -1
- package/src/base/embla.d.ts +6 -7
- package/src/base/embla.d.ts.map +1 -1
- package/src/base/embla.js +89 -55
- package/src/base/embla.ts +89 -55
- package/src/base/hotkeys.d.ts +0 -5
- package/src/base/hotkeys.d.ts.map +1 -1
- package/src/base/hotkeys.ts +0 -5
- package/src/base/navigation.d.ts +12 -1
- package/src/base/navigation.d.ts.map +1 -1
- package/src/base/navigation.js +229 -86
- package/src/base/navigation.ts +224 -92
- package/src/base/reveal.js +14 -14
- package/src/base/reveal.ts +14 -14
- package/src/base/scroll-state.d.ts +21 -0
- package/src/base/scroll-state.d.ts.map +1 -0
- package/src/base/scroll-state.js +177 -0
- package/src/base/scroll-state.ts +188 -0
- package/src/base/signals.d.ts +1 -2
- package/src/base/signals.d.ts.map +1 -1
- package/src/base/signals.js +4 -6
- package/src/base/signals.ts +4 -6
- package/src/base/style-format.d.ts +33 -0
- package/src/base/style-format.d.ts.map +1 -0
- package/src/base/style-format.js +160 -0
- package/src/base/style-format.ts +180 -0
- package/src/base/typeahead.d.ts +19 -4
- package/src/base/typeahead.d.ts.map +1 -1
- package/src/base/typeahead.js +68 -21
- package/src/base/typeahead.ts +73 -23
- package/src/base/utilities.d.ts +188 -0
- package/src/base/utilities.d.ts.map +1 -0
- package/src/base/utilities.js +750 -0
- package/src/base/utilities.ts +865 -0
- package/src/base/utils.d.ts +3 -7
- package/src/base/utils.d.ts.map +1 -1
- package/src/base/utils.js +4 -8
- package/src/base/utils.ts +4 -8
- package/src/base/zazz-element.d.ts +14 -8
- package/src/base/zazz-element.d.ts.map +1 -1
- package/src/base/zazz-element.js +14 -8
- package/src/base/zazz-element.ts +15 -8
- package/src/globals.d.ts +1 -1
- package/src/head.d.ts +50 -4
- package/src/head.d.ts.map +1 -1
- package/src/head.js +119 -38
- package/src/head.ts +172 -41
- package/src/index.css +57 -14
- package/src/index.js +5 -0
- package/src/index.ts +6 -0
- package/src/manifest.d.ts +36 -5
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +150 -6
- package/src/manifest.ts +167 -9
- package/src/primitives/accordion/accordion.css +18 -17
- package/src/primitives/accordion/accordion.html +42 -9
- package/src/primitives/alert-dialog/alert-dialog.css +13 -13
- package/src/primitives/alert-dialog/alert-dialog.html +26 -12
- package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
- package/src/primitives/autocomplete/autocomplete.css +45 -43
- package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
- package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
- package/src/primitives/autocomplete/autocomplete.html +38 -26
- package/src/primitives/autocomplete/autocomplete.js +6 -5
- package/src/primitives/autocomplete/autocomplete.ts +6 -5
- package/src/primitives/avatar/avatar.html +110 -15
- package/src/primitives/badge/badge-icon.html +22 -8
- package/src/primitives/badge/badge.css +401 -128
- package/src/primitives/badge/badge.html +12 -6
- package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
- package/src/primitives/button/button-icon-only.html +17 -11
- package/src/primitives/button/button-icon.html +9 -3
- package/src/primitives/button/button.css +408 -164
- package/src/primitives/button/button.html +14 -7
- package/src/primitives/button-group/button-group-vertical.html +5 -5
- package/src/primitives/button-group/button-group.css +53 -25
- package/src/primitives/button-group/button-group.html +18 -12
- package/src/primitives/callout/callout.css +114 -0
- package/src/primitives/callout/callout.html +188 -0
- package/src/primitives/card/card-subgrid.html +249 -34
- package/src/primitives/card/card.css +125 -0
- package/src/primitives/card/card.html +141 -20
- package/src/primitives/carousel/carousel.css +30 -20
- package/src/primitives/carousel/carousel.d.ts +7 -10
- package/src/primitives/carousel/carousel.d.ts.map +1 -1
- package/src/primitives/carousel/carousel.html +420 -84
- package/src/primitives/carousel/carousel.js +1 -1
- package/src/primitives/carousel/carousel.ts +8 -11
- package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
- package/src/primitives/checkbox/checkbox.css +98 -40
- package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
- package/src/primitives/checkbox/checkbox.html +13 -8
- package/src/primitives/checkbox/checkbox.js +7 -9
- package/src/primitives/checkbox/checkbox.ts +7 -15
- package/src/primitives/combobox/combobox-multiselect.html +53 -33
- package/src/primitives/combobox/combobox.css +147 -126
- package/src/primitives/combobox/combobox.d.ts +12 -11
- package/src/primitives/combobox/combobox.d.ts.map +1 -1
- package/src/primitives/combobox/combobox.html +48 -28
- package/src/primitives/combobox/combobox.js +46 -51
- package/src/primitives/combobox/combobox.ts +48 -55
- package/src/primitives/command/command-actions.d.ts +2 -3
- package/src/primitives/command/command-actions.d.ts.map +1 -1
- package/src/primitives/command/command-actions.html +48 -33
- package/src/primitives/command/command-actions.js +12 -10
- package/src/primitives/command/command-actions.ts +12 -13
- package/src/primitives/command/command-dialog.html +49 -25
- package/src/primitives/command/command.css +52 -42
- package/src/primitives/command/command.d.ts +10 -7
- package/src/primitives/command/command.d.ts.map +1 -1
- package/src/primitives/command/command.html +95 -46
- package/src/primitives/command/command.js +30 -13
- package/src/primitives/command/command.ts +30 -12
- package/src/primitives/debug/audit-core.d.ts +64 -0
- package/src/primitives/debug/audit-core.d.ts.map +1 -0
- package/src/primitives/debug/audit-core.js +356 -0
- package/src/primitives/debug/audit-core.ts +535 -0
- package/src/primitives/debug/debug.d.ts +50 -0
- package/src/primitives/debug/debug.d.ts.map +1 -0
- package/src/primitives/debug/debug.js +168 -0
- package/src/primitives/debug/debug.ts +211 -0
- package/src/primitives/dialog/dialog-with-form.html +67 -45
- package/src/primitives/dialog/dialog.css +87 -61
- package/src/primitives/dialog/dialog.html +25 -17
- package/src/primitives/fields/fields.css +108 -134
- package/src/primitives/fields/fields.html +39 -0
- package/src/primitives/input/input-icon-leading.html +3 -3
- package/src/primitives/input/input-icon-trailing.html +3 -3
- package/src/primitives/input/input.css +87 -49
- package/src/primitives/input/input.html +15 -15
- package/src/primitives/input-group/input-group-password-group.html +15 -15
- package/src/primitives/input-group/input-group.css +118 -75
- package/src/primitives/input-group/input-group.html +42 -30
- package/src/primitives/kbd/kbd-group.html +15 -2
- package/src/primitives/kbd/kbd.css +44 -31
- package/src/primitives/kbd/kbd.html +7 -1
- package/src/primitives/layout/layout.css +159 -0
- package/src/primitives/layout/layout.html +35 -0
- package/src/primitives/lightbox/lightbox.css +178 -105
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
- package/src/primitives/lightbox/lightbox.html +138 -166
- package/src/primitives/lightbox/lightbox.js +10 -13
- package/src/primitives/lightbox/lightbox.ts +12 -13
- package/src/primitives/menu/menu-interest.html +60 -18
- package/src/primitives/menu/menu.css +22 -17
- package/src/primitives/menu/menu.d.ts +5 -5
- package/src/primitives/menu/menu.html +195 -40
- package/src/primitives/menu/menu.js +8 -8
- package/src/primitives/menu/menu.ts +8 -8
- package/src/primitives/menubar/menubar-help-search.html +78 -32
- package/src/primitives/menubar/menubar.html +166 -38
- package/src/primitives/meter/meter.css +41 -38
- package/src/primitives/meter/meter.html +44 -9
- package/src/primitives/mobile-menu/mobile-menu.css +47 -40
- package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
- package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
- package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
- package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
- package/src/primitives/navigation-menu/navigation-menu.css +104 -106
- package/src/primitives/navigation-menu/navigation-menu.html +554 -158
- package/src/primitives/otp/otp.css +43 -44
- package/src/primitives/otp/otp.d.ts +4 -5
- package/src/primitives/otp/otp.d.ts.map +1 -1
- package/src/primitives/otp/otp.html +7 -6
- package/src/primitives/otp/otp.js +13 -18
- package/src/primitives/otp/otp.ts +12 -19
- package/src/primitives/password-group/password-group.css +132 -107
- package/src/primitives/password-group/password-group.d.ts.map +1 -1
- package/src/primitives/password-group/password-group.html +23 -16
- package/src/primitives/password-group/password-group.js +11 -12
- package/src/primitives/password-group/password-group.ts +11 -12
- package/src/primitives/popover/popover.css +89 -95
- package/src/primitives/popover/popover.html +18 -0
- package/src/primitives/progress/progress-indeterminate.html +1 -1
- package/src/primitives/progress/progress.css +34 -35
- package/src/primitives/progress/progress.html +18 -4
- package/src/primitives/prose/prose.html +19 -12
- package/src/primitives/radio/radio.css +83 -46
- package/src/primitives/radio/radio.html +16 -11
- package/src/primitives/reveal/reveal.css +37 -46
- package/src/primitives/reveal/reveal.html +15 -0
- package/src/primitives/scroll-fade/scroll-fade.css +115 -0
- package/src/primitives/scroll-fade/scroll-fade.html +69 -0
- package/src/primitives/select/multiselect.d.ts +8 -10
- package/src/primitives/select/multiselect.d.ts.map +1 -1
- package/src/primitives/select/multiselect.js +23 -27
- package/src/primitives/select/multiselect.ts +23 -29
- package/src/primitives/select/select-align.html +79 -16
- package/src/primitives/select/select-multiple.html +8 -4
- package/src/primitives/select/select-sides.html +104 -21
- package/src/primitives/select/select.css +299 -191
- package/src/primitives/select/select.html +24 -5
- package/src/primitives/separator/separator.css +15 -18
- package/src/primitives/separator/separator.html +37 -10
- package/src/primitives/slider/slider.css +48 -38
- package/src/primitives/slider/slider.html +9 -1
- package/src/primitives/style-guard/style-guard.d.ts +19 -0
- package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
- package/src/primitives/style-guard/style-guard.js +125 -0
- package/src/primitives/style-guard/style-guard.ts +153 -0
- package/src/primitives/switch/switch.css +42 -33
- package/src/primitives/switch/switch.html +11 -6
- package/src/primitives/table/table-alternating.html +1 -1
- package/src/primitives/table/table-grid.html +5 -5
- package/src/primitives/table/table-size-sm.html +1 -1
- package/src/primitives/table/table.css +64 -61
- package/src/primitives/table/table.html +7 -7
- package/src/primitives/tabs/tabs.css +167 -166
- package/src/primitives/tabs/tabs.d.ts +10 -11
- package/src/primitives/tabs/tabs.d.ts.map +1 -1
- package/src/primitives/tabs/tabs.html +192 -36
- package/src/primitives/tabs/tabs.js +14 -15
- package/src/primitives/tabs/tabs.ts +14 -15
- package/src/primitives/textarea/textarea.css +69 -44
- package/src/primitives/textarea/textarea.html +3 -3
- package/src/primitives/toaster/toaster.css +90 -92
- package/src/primitives/toaster/toaster.d.ts +0 -6
- package/src/primitives/toaster/toaster.d.ts.map +1 -1
- package/src/primitives/toaster/toaster.html +22 -18
- package/src/primitives/toaster/toaster.js +64 -72
- package/src/primitives/toaster/toaster.ts +71 -87
- package/src/primitives/toggle/toggle.css +368 -153
- package/src/primitives/toggle/toggle.html +27 -9
- package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
- package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
- package/src/primitives/toggle-group/toggle-group.css +71 -23
- package/src/primitives/toggle-group/toggle-group.html +3 -3
- package/src/primitives/toolbar/toolbar.html +35 -13
- package/src/primitives/tooltip/tooltip-disabled.html +3 -3
- package/src/primitives/tooltip/tooltip-sides.html +36 -14
- package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
- package/src/primitives/tooltip/tooltip.css +111 -80
- package/src/primitives/tooltip/tooltip.html +3 -3
- package/src/primitives/utilities/aspect-ratio.html +51 -7
- package/src/primitives/utilities/basis.html +64 -11
- package/src/primitives/utilities/col-span.html +65 -9
- package/src/primitives/utilities/compose.html +48 -10
- package/src/primitives/utilities/flex-align.html +89 -19
- package/src/primitives/utilities/flex-direction.html +111 -13
- package/src/primitives/utilities/flex-grow.html +41 -7
- package/src/primitives/utilities/gap.html +158 -19
- package/src/primitives/utilities/grid-cols.html +75 -7
- package/src/primitives/utilities/grid-responsive.html +111 -12
- package/src/primitives/utilities/margin-auto.html +38 -7
- package/src/primitives/utilities/object-fit.html +75 -13
- package/src/primitives/utilities/order.html +40 -4
- package/src/primitives/utilities/overflow.html +74 -20
- package/src/primitives/utilities/padding-compose.html +67 -10
- package/src/primitives/utilities/padding.html +84 -13
- package/src/primitives/utilities/pile.html +29 -0
- package/src/primitives/utilities/position.html +65 -8
- package/src/primitives/utilities/responsive-flex.html +54 -7
- package/src/primitives/utilities/responsive-grid.html +115 -12
- package/src/primitives/utilities/size.html +120 -16
- package/src/primitives/utilities/width.html +123 -16
- package/examples/about.html +0 -583
- package/examples/components.html +0 -1028
- package/examples/forms.html +0 -504
- package/examples/index.html +0 -261
- package/examples/layout.html +0 -313
- package/examples/products.html +0 -839
- package/examples/responsive.html +0 -332
- package/src/base/_layout.css +0 -571
- package/src/base/_utilities.css +0 -6758
- package/src/primitives/utilities/grid-pile.html +0 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<div
|
|
2
|
-
<label data-slot="
|
|
1
|
+
<div data-ui="field" style="--max-w: 96">
|
|
2
|
+
<label data-field-slot="label" for="cb-country">Country</label>
|
|
3
3
|
<ui-combobox>
|
|
4
|
-
<input type="hidden" name="country" data-slot="
|
|
5
|
-
<div data-slot="
|
|
4
|
+
<input type="hidden" name="country" data-combobox-slot="value" value="" />
|
|
5
|
+
<div data-combobox-slot="control">
|
|
6
6
|
<input
|
|
7
7
|
id="cb-country"
|
|
8
8
|
type="text"
|
|
@@ -14,60 +14,80 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<button
|
|
16
16
|
type="button"
|
|
17
|
-
data-slot="
|
|
17
|
+
data-combobox-slot="trigger"
|
|
18
18
|
tabindex="-1"
|
|
19
19
|
aria-label="Show options"
|
|
20
20
|
></button>
|
|
21
21
|
</div>
|
|
22
|
-
<div
|
|
23
|
-
|
|
22
|
+
<div
|
|
23
|
+
data-combobox-slot="panel"
|
|
24
|
+
data-popover-side="bottom"
|
|
25
|
+
data-popover-align="start"
|
|
26
|
+
popover="manual"
|
|
27
|
+
>
|
|
28
|
+
<ul role="listbox" data-combobox-slot="list" aria-label="Countries">
|
|
24
29
|
<li
|
|
25
30
|
role="option"
|
|
26
|
-
data-slot="
|
|
27
|
-
|
|
28
|
-
data-variant="ghost"
|
|
29
|
-
data-value="au"
|
|
31
|
+
data-combobox-slot="item"
|
|
32
|
+
data-ui="button"
|
|
33
|
+
data-button-variant="ghost"
|
|
34
|
+
data-combobox-value="au"
|
|
35
|
+
style="--justify: start"
|
|
30
36
|
>
|
|
31
37
|
Australia
|
|
32
38
|
</li>
|
|
33
39
|
<li
|
|
34
40
|
role="option"
|
|
35
|
-
data-slot="
|
|
36
|
-
|
|
37
|
-
data-variant="ghost"
|
|
38
|
-
data-value="ca"
|
|
41
|
+
data-combobox-slot="item"
|
|
42
|
+
data-ui="button"
|
|
43
|
+
data-button-variant="ghost"
|
|
44
|
+
data-combobox-value="ca"
|
|
45
|
+
style="--justify: start"
|
|
39
46
|
>
|
|
40
47
|
Canada
|
|
41
48
|
</li>
|
|
42
49
|
<li
|
|
43
50
|
role="option"
|
|
44
|
-
data-slot="
|
|
45
|
-
|
|
46
|
-
data-variant="ghost"
|
|
47
|
-
data-value="jp"
|
|
51
|
+
data-combobox-slot="item"
|
|
52
|
+
data-ui="button"
|
|
53
|
+
data-button-variant="ghost"
|
|
54
|
+
data-combobox-value="jp"
|
|
55
|
+
style="--justify: start"
|
|
48
56
|
>
|
|
49
57
|
Japan
|
|
50
58
|
</li>
|
|
51
59
|
<li
|
|
52
60
|
role="option"
|
|
53
|
-
data-slot="
|
|
54
|
-
|
|
55
|
-
data-variant="ghost"
|
|
56
|
-
data-value="nz"
|
|
61
|
+
data-combobox-slot="item"
|
|
62
|
+
data-ui="button"
|
|
63
|
+
data-button-variant="ghost"
|
|
64
|
+
data-combobox-value="nz"
|
|
65
|
+
style="--justify: start"
|
|
57
66
|
>
|
|
58
67
|
New Zealand
|
|
59
68
|
</li>
|
|
60
69
|
<li
|
|
61
70
|
role="option"
|
|
62
|
-
data-slot="
|
|
63
|
-
|
|
64
|
-
data-variant="ghost"
|
|
65
|
-
data-value="us"
|
|
71
|
+
data-combobox-slot="item"
|
|
72
|
+
data-ui="button"
|
|
73
|
+
data-button-variant="ghost"
|
|
74
|
+
data-combobox-value="us"
|
|
75
|
+
style="--justify: start"
|
|
66
76
|
>
|
|
67
77
|
United States
|
|
68
78
|
</li>
|
|
69
79
|
</ul>
|
|
70
|
-
<p
|
|
80
|
+
<p
|
|
81
|
+
data-combobox-slot="empty"
|
|
82
|
+
style="
|
|
83
|
+
--font-size: var(--font-size-sm);
|
|
84
|
+
--leading: var(--leading-sm);
|
|
85
|
+
--tracking: var(--tracking-sm);
|
|
86
|
+
--text: var(--color-muted-foreground);
|
|
87
|
+
"
|
|
88
|
+
>
|
|
89
|
+
No matches.
|
|
90
|
+
</p>
|
|
71
91
|
</div>
|
|
72
92
|
</ui-combobox>
|
|
73
93
|
</div>
|
|
@@ -4,34 +4,35 @@
|
|
|
4
4
|
* @description Light-DOM custom element on the shared typeahead engine
|
|
5
5
|
* (`base/typeahead.ts`). A relative of select: the panel filters as you type,
|
|
6
6
|
* but free text can never submit. The form value lives in an authored hidden
|
|
7
|
-
* input (`data-slot="
|
|
7
|
+
* input (`data-combobox-slot="value"`), synced whenever the selection changes.
|
|
8
8
|
*
|
|
9
9
|
* The visible input carries a **display value, not the filter**. Committing
|
|
10
10
|
* writes the option label into it and clears the query, so reopening shows
|
|
11
|
-
* the full list with the committed row checked, matching
|
|
11
|
+
* the full list with the committed row checked, matching `[data-ui~="select"]`.
|
|
12
12
|
* Opening selects that label so the first keystroke replaces it, and focus
|
|
13
13
|
* alone never opens the panel (a click, the chevron, an arrow key or typing
|
|
14
14
|
* does). On blur, stray text reverts to the committed label and cleared text
|
|
15
15
|
* clears the selection.
|
|
16
16
|
*
|
|
17
|
-
* `data-variant="multiselect"` selects a set instead: committing toggles a row
|
|
17
|
+
* `data-combobox-variant="multiselect"` selects a set instead: committing toggles a row
|
|
18
18
|
* and keeps the panel open, and every selected value renders as a removable
|
|
19
19
|
* tag stamped inside the control. The tag markup is HTML, not script: author
|
|
20
|
-
* a `<template data-slot="
|
|
20
|
+
* a `<template data-combobox-slot="tag-template">` to control its classes and
|
|
21
21
|
* structure, and this file fills in the label, the value, and the remove
|
|
22
|
-
* button accessible name. Without one, the
|
|
22
|
+
* button accessible name. Without one, the badge default below applies.
|
|
23
23
|
* Backspace on an empty input drops the last tag. Options carrying
|
|
24
24
|
* `aria-selected="true"` are the single source of truth: the tags and the
|
|
25
25
|
* hidden inputs are both derived from them in DOM order so nothing can drift.
|
|
26
26
|
* The form submits repeated `name` pairs like `<select multiple>`: the authored
|
|
27
27
|
* hidden input carries the first value, and stamped siblings carry the rest.
|
|
28
28
|
*
|
|
29
|
-
* Where a no-JS fallback matters, prefer
|
|
29
|
+
* Where a no-JS fallback matters, prefer `[data-ui~="select"]` / `<ui-multiselect>`:
|
|
30
30
|
* this control is inert without its script (the hidden input still submits a
|
|
31
31
|
* server-set value, but no tags render).
|
|
32
32
|
*
|
|
33
|
-
* Attributes on the root: `data-variant="multiselect"`, `data-sort="score"`,
|
|
34
|
-
* `data-
|
|
33
|
+
* Attributes on the root: `data-combobox-variant="multiselect"`, `data-combobox-sort="score"`,
|
|
34
|
+
* `data-combobox-filter="none"` (another source filters; the engine only navigates),
|
|
35
|
+
* `data-combobox-min-length="<n>"`, `data-combobox-label-remove="Remove {label}"`.
|
|
35
36
|
* Parts: `combobox-value` (hidden input), `combobox-control` (select-look
|
|
36
37
|
* shell), `combobox-tag-template` (authored `<template>`), `combobox-tag` /
|
|
37
38
|
* `combobox-tag-label` / `combobox-tag-remove` (cloned from it),
|
|
@@ -40,17 +41,10 @@
|
|
|
40
41
|
*/
|
|
41
42
|
import { TypeaheadElement } from "../../base/typeahead.js";
|
|
42
43
|
import { defineZazzElement } from "../../base/zazz-element.js";
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* a tag (other classes, an extra icon, a different component entirely) never
|
|
48
|
-
* means editing this script. Kept as markup rather than createElement calls so
|
|
49
|
-
* the default reads the same way the override is written.
|
|
50
|
-
*/
|
|
51
|
-
const TAG_MARKUP = '<span class="ui-badge" data-slot="combobox-tag">' +
|
|
52
|
-
'<span data-slot="combobox-tag-label"></span>' +
|
|
53
|
-
'<button type="button" tabindex="-1" data-slot="combobox-tag-remove"></button>' +
|
|
44
|
+
/** Default tag markup, cloned per selected value; a `tag-template` overrides it. */
|
|
45
|
+
const TAG_MARKUP = '<span data-ui="badge" data-combobox-slot="tag">' +
|
|
46
|
+
'<span data-combobox-slot="tag-label"></span>' +
|
|
47
|
+
'<button type="button" tabindex="-1" data-combobox-slot="tag-remove"></button>' +
|
|
54
48
|
"</span>";
|
|
55
49
|
let defaultTagTemplate = null;
|
|
56
50
|
/**
|
|
@@ -85,7 +79,7 @@ function resolveBlur(typed, committedLabel, multiselect) {
|
|
|
85
79
|
return { value: committedLabel, clear: false };
|
|
86
80
|
}
|
|
87
81
|
/**
|
|
88
|
-
* @description Fills the remove-button label template (`data-label-remove`).
|
|
82
|
+
* @description Fills the remove-button label template (`data-combobox-label-remove`).
|
|
89
83
|
*
|
|
90
84
|
* @param template - Template with a `{label}` placeholder.
|
|
91
85
|
* @param label - The tag's visible label.
|
|
@@ -94,7 +88,6 @@ function resolveBlur(typed, committedLabel, multiselect) {
|
|
|
94
88
|
function resolveRemoveLabel(template, label) {
|
|
95
89
|
return template.replace("{label}", label);
|
|
96
90
|
}
|
|
97
|
-
// --- Element ---
|
|
98
91
|
class UiCombobox extends TypeaheadElement {
|
|
99
92
|
slotPrefix = "combobox";
|
|
100
93
|
/** The input holds a committed label, so focus alone must not open the list. */
|
|
@@ -111,7 +104,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
111
104
|
const multiselect = this.#multiselect();
|
|
112
105
|
this.#placeholder = input.getAttribute("placeholder") ?? "";
|
|
113
106
|
if (multiselect) {
|
|
114
|
-
this.querySelector('[data-slot~="
|
|
107
|
+
this.querySelector('[data-combobox-slot~="list"]')?.setAttribute("aria-multiselectable", "true");
|
|
115
108
|
}
|
|
116
109
|
// Adopt a server-rendered value no row claims yet, so `value` alone is
|
|
117
110
|
// enough markup to seed the selection, ensuring the sync below never
|
|
@@ -135,7 +128,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
135
128
|
this.#committedLabel = multiselect ? "" : (this.#selectedLabel() ?? "");
|
|
136
129
|
input.value = this.#committedLabel;
|
|
137
130
|
this.#syncSelection(false);
|
|
138
|
-
const control = input.closest('[data-slot~="
|
|
131
|
+
const control = input.closest('[data-combobox-slot~="control"]');
|
|
139
132
|
// A select-look control is one big hit target
|
|
140
133
|
input.addEventListener("click", () => this.#openPanel(), { signal });
|
|
141
134
|
control?.addEventListener("mousedown", (event) => {
|
|
@@ -145,7 +138,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
145
138
|
// the tag remove buttons would otherwise blur it and close the panel
|
|
146
139
|
event.preventDefault();
|
|
147
140
|
input.focus();
|
|
148
|
-
if (!event.target.closest('[data-slot~="
|
|
141
|
+
if (!event.target.closest('[data-combobox-slot~="trigger"], [data-combobox-slot~="tag"]')) {
|
|
149
142
|
this.#openPanel();
|
|
150
143
|
}
|
|
151
144
|
}, { signal });
|
|
@@ -153,17 +146,19 @@ class UiCombobox extends TypeaheadElement {
|
|
|
153
146
|
control?.addEventListener("click", (event) => {
|
|
154
147
|
if (!(event.target instanceof Element))
|
|
155
148
|
return;
|
|
156
|
-
const remove = event.target.closest('[data-slot~="
|
|
149
|
+
const remove = event.target.closest('[data-combobox-slot~="tag-remove"]');
|
|
157
150
|
if (!remove)
|
|
158
151
|
return;
|
|
159
152
|
// A template that forgets type="button" would otherwise submit the form
|
|
160
153
|
event.preventDefault();
|
|
161
|
-
const value = remove
|
|
154
|
+
const value = remove
|
|
155
|
+
.closest('[data-combobox-slot~="tag"]')
|
|
156
|
+
?.getAttribute("data-combobox-value");
|
|
162
157
|
this.#deselect(this.items().find((item) => this.#itemFormValue(item) === value));
|
|
163
158
|
input.focus();
|
|
164
159
|
}, { signal });
|
|
165
160
|
// Chevron toggles the full, unfiltered list
|
|
166
|
-
const trigger = this.querySelector('[data-slot~="
|
|
161
|
+
const trigger = this.querySelector('[data-combobox-slot~="trigger"]');
|
|
167
162
|
if (trigger instanceof HTMLElement) {
|
|
168
163
|
trigger.addEventListener("click", () => {
|
|
169
164
|
if (this.open.get())
|
|
@@ -202,7 +197,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
202
197
|
(hidden ?? input).form?.addEventListener("reset", () => queueMicrotask(() => this.#restoreDefaults()), { signal });
|
|
203
198
|
}
|
|
204
199
|
teardown() {
|
|
205
|
-
for (const node of this.querySelectorAll('[data-slot~="
|
|
200
|
+
for (const node of this.querySelectorAll('[data-combobox-slot~="tag"], [data-combobox-state~="stamped"]')) {
|
|
206
201
|
node.remove();
|
|
207
202
|
}
|
|
208
203
|
if (this.searchInput)
|
|
@@ -210,7 +205,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
210
205
|
}
|
|
211
206
|
/**
|
|
212
207
|
* @description Combobox items match against what the user sees (the label)
|
|
213
|
-
* not the machine `data-value`.
|
|
208
|
+
* not the machine `data-combobox-value`.
|
|
214
209
|
*
|
|
215
210
|
* @param item - The item element.
|
|
216
211
|
* @returns The trimmed visible label.
|
|
@@ -231,7 +226,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
231
226
|
this.query.set("");
|
|
232
227
|
}
|
|
233
228
|
/**
|
|
234
|
-
* @description Committing shows the item's label, stores its `data-value` in
|
|
229
|
+
* @description Committing shows the item's label, stores its `data-combobox-value` in
|
|
235
230
|
* the hidden input, and moves `aria-selected`. The multiselect variant
|
|
236
231
|
* toggles the row instead and keeps the panel open so picking can continue.
|
|
237
232
|
*
|
|
@@ -274,11 +269,11 @@ class UiCombobox extends TypeaheadElement {
|
|
|
274
269
|
/**
|
|
275
270
|
* @description Whether the multiselect variant is active.
|
|
276
271
|
*
|
|
277
|
-
* @returns True for `data-variant="multiselect"`.
|
|
272
|
+
* @returns True for `data-combobox-variant="multiselect"`.
|
|
278
273
|
* @private
|
|
279
274
|
*/
|
|
280
275
|
#multiselect() {
|
|
281
|
-
return this.
|
|
276
|
+
return this.config("variant") === "multiselect";
|
|
282
277
|
}
|
|
283
278
|
/**
|
|
284
279
|
* @description Opens the panel the way a select does: the full list, the
|
|
@@ -330,11 +325,11 @@ class UiCombobox extends TypeaheadElement {
|
|
|
330
325
|
* @description An item's machine value.
|
|
331
326
|
*
|
|
332
327
|
* @param item - The item element.
|
|
333
|
-
* @returns `data-value` when present, the visible label otherwise.
|
|
328
|
+
* @returns `data-combobox-value` when present, the visible label otherwise.
|
|
334
329
|
* @private
|
|
335
330
|
*/
|
|
336
331
|
#itemFormValue(item) {
|
|
337
|
-
return item.getAttribute("data-value") ?? this.itemValue(item);
|
|
332
|
+
return item.getAttribute("data-combobox-value") ?? this.itemValue(item);
|
|
338
333
|
}
|
|
339
334
|
/**
|
|
340
335
|
* @description Drops one item from the selection.
|
|
@@ -356,7 +351,7 @@ class UiCombobox extends TypeaheadElement {
|
|
|
356
351
|
* @private
|
|
357
352
|
*/
|
|
358
353
|
#valueInput() {
|
|
359
|
-
const hidden = this.querySelector('[data-slot~="
|
|
354
|
+
const hidden = this.querySelector('[data-combobox-slot~="value"]:not([data-combobox-state~="stamped"])');
|
|
360
355
|
return hidden instanceof HTMLInputElement ? hidden : null;
|
|
361
356
|
}
|
|
362
357
|
/**
|
|
@@ -382,14 +377,14 @@ class UiCombobox extends TypeaheadElement {
|
|
|
382
377
|
if (!hidden)
|
|
383
378
|
return;
|
|
384
379
|
hidden.value = values[0] ?? "";
|
|
385
|
-
for (const stale of this.querySelectorAll(
|
|
380
|
+
for (const stale of this.querySelectorAll('[data-combobox-state~="stamped"]'))
|
|
386
381
|
stale.remove();
|
|
387
382
|
let anchor = hidden;
|
|
388
383
|
for (const value of values.slice(1)) {
|
|
389
384
|
const extra = document.createElement("input");
|
|
390
385
|
extra.type = "hidden";
|
|
391
|
-
extra.setAttribute("data-slot", "
|
|
392
|
-
extra.setAttribute("data-combobox-
|
|
386
|
+
extra.setAttribute("data-combobox-slot", "value");
|
|
387
|
+
extra.setAttribute("data-combobox-state", "stamped");
|
|
393
388
|
if (hidden.name)
|
|
394
389
|
extra.name = hidden.name;
|
|
395
390
|
extra.value = value;
|
|
@@ -401,16 +396,16 @@ class UiCombobox extends TypeaheadElement {
|
|
|
401
396
|
}
|
|
402
397
|
/**
|
|
403
398
|
* @description The element cloned per selected value: the first child of an
|
|
404
|
-
* authored `<template data-slot="
|
|
405
|
-
* default
|
|
406
|
-
* fragment, so a blueprint carrying `data-slot="
|
|
399
|
+
* authored `<template data-combobox-slot="tag-template">` when present, the
|
|
400
|
+
* default badge otherwise. A template's content lives in a separate
|
|
401
|
+
* fragment, so a blueprint carrying `data-combobox-slot="tag"` is invisible to
|
|
407
402
|
* the stale-tag sweep and can never be mistaken for a rendered tag.
|
|
408
403
|
*
|
|
409
404
|
* @returns The blueprint element, or null when an authored template is empty.
|
|
410
405
|
* @private
|
|
411
406
|
*/
|
|
412
407
|
#tagBlueprint() {
|
|
413
|
-
const authored = this.querySelector('[data-slot~="
|
|
408
|
+
const authored = this.querySelector('[data-combobox-slot~="tag-template"]');
|
|
414
409
|
const template = authored instanceof HTMLTemplateElement ? authored : defaultTagBlueprint();
|
|
415
410
|
const root = template.content.firstElementChild;
|
|
416
411
|
return root instanceof HTMLElement ? root : null;
|
|
@@ -424,35 +419,35 @@ class UiCombobox extends TypeaheadElement {
|
|
|
424
419
|
* @private
|
|
425
420
|
*/
|
|
426
421
|
#renderTags(input) {
|
|
427
|
-
const control = input.closest('[data-slot~="
|
|
422
|
+
const control = input.closest('[data-combobox-slot~="control"]');
|
|
428
423
|
if (!control)
|
|
429
424
|
return;
|
|
430
|
-
for (const stale of control.querySelectorAll('[data-slot~="
|
|
425
|
+
for (const stale of control.querySelectorAll('[data-combobox-slot~="tag"]'))
|
|
431
426
|
stale.remove();
|
|
432
427
|
const blueprint = this.#tagBlueprint();
|
|
433
428
|
if (!blueprint)
|
|
434
429
|
return;
|
|
435
|
-
const removeLabel = this.
|
|
430
|
+
const removeLabel = this.config("label-remove") ?? "Remove {label}";
|
|
436
431
|
const tags = this.#selectedItems().map((item) => {
|
|
437
432
|
const label = this.itemValue(item);
|
|
438
433
|
const tag = blueprint.cloneNode(true);
|
|
439
|
-
tag.setAttribute("data-value", this.#itemFormValue(item));
|
|
434
|
+
tag.setAttribute("data-combobox-value", this.#itemFormValue(item));
|
|
440
435
|
// The slot is the contract every other moving part keys off (the CSS, the
|
|
441
436
|
// stale sweep above, and tag removal), so add the token if the template
|
|
442
437
|
// left it out rather than stamping an orphan
|
|
443
|
-
if (!tag.matches('[data-slot~="
|
|
444
|
-
const slots = tag.getAttribute("data-slot");
|
|
445
|
-
tag.setAttribute("data-slot", slots ? `${slots}
|
|
438
|
+
if (!tag.matches('[data-combobox-slot~="tag"]')) {
|
|
439
|
+
const slots = tag.getAttribute("data-combobox-slot");
|
|
440
|
+
tag.setAttribute("data-combobox-slot", slots ? `${slots} tag` : "tag");
|
|
446
441
|
}
|
|
447
442
|
// The label wants its own box: text-overflow ignores a flex container's
|
|
448
443
|
// own text, but a template without one still gets its text
|
|
449
|
-
const text = tag.querySelector('[data-slot~="
|
|
444
|
+
const text = tag.querySelector('[data-combobox-slot~="tag-label"]');
|
|
450
445
|
if (text)
|
|
451
446
|
text.textContent = label;
|
|
452
447
|
else
|
|
453
448
|
tag.prepend(document.createTextNode(label));
|
|
454
449
|
tag
|
|
455
|
-
.querySelector('[data-slot~="
|
|
450
|
+
.querySelector('[data-combobox-slot~="tag-remove"]')
|
|
456
451
|
?.setAttribute("aria-label", resolveRemoveLabel(removeLabel, label));
|
|
457
452
|
return tag;
|
|
458
453
|
});
|