@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,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* combobox.css: Combobox (ui-combobox | .ui-combobox, [data-slot~="combobox-control"])
|
|
3
|
+
*
|
|
4
|
+
* @layer variables, components
|
|
5
|
+
* @requires layers.css, _variables.css, popover.css, button.css, fields.css,
|
|
6
|
+
* badge.css (--ui-badge-* for the default tag template .ui-badge),
|
|
7
|
+
* select.css (--ui-option-*, --ui-select-picker-icon-*)
|
|
8
|
+
* @uses [popover="manual"]: panel opened/closed by combobox.js
|
|
9
|
+
* @uses anchor-name, anchor-scope, position-anchor: tether panel to the control
|
|
10
|
+
* @uses anchor-size(width): match panel width to the control (@supports gated)
|
|
11
|
+
* @uses :has(): chevron rotation, group + empty-state visibility
|
|
12
|
+
* @uses mask: chevron and tag-remove icons; wiped in forced-colors mode,
|
|
13
|
+
* matching the rest of the kit (option checkmark, picker icon)
|
|
14
|
+
* @uses data-side / data-align: maps to --ui-popover-position-* in popover.css
|
|
15
|
+
* @uses data-variant="multiselect": tag variant; combobox.js clones a
|
|
16
|
+
* <template data-slot="combobox-tag-template"> (or its muted-badge
|
|
17
|
+
* default) per option carrying aria-selected="true". Tag rules key
|
|
18
|
+
* off the slots, so a custom template keeps this styling.
|
|
19
|
+
* @tokens --ui-combobox-* (@layer variables); control mirrors --ui-select-*,
|
|
20
|
+
* items alias --ui-option-*, tags alias --ui-badge-*
|
|
21
|
+
* @see combobox.ts: filtering, commit/revert, tags, and keyboard behavior
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
@layer variables {
|
|
25
|
+
:root {
|
|
26
|
+
/* Control mirrors the select trigger so the two pickers read as one family */
|
|
27
|
+
--ui-combobox-display: grid;
|
|
28
|
+
--ui-combobox-option-gap: var(--ui-field-option-gap);
|
|
29
|
+
--ui-combobox-inline-size: var(--ui-select-inline-size);
|
|
30
|
+
--ui-combobox-min-inline-size: var(--ui-select-min-inline-size);
|
|
31
|
+
--ui-combobox-padding-inline-start: var(--ui-select-padding-inline-start);
|
|
32
|
+
--ui-combobox-padding-inline-end: var(--ui-select-padding-inline-end);
|
|
33
|
+
--ui-combobox-border: var(--ui-select-border);
|
|
34
|
+
--ui-combobox-border-radius: var(--ui-select-border-radius);
|
|
35
|
+
--ui-combobox-icon-mask: var(--ui-select-picker-icon-mask);
|
|
36
|
+
--ui-combobox-icon-size: var(--ui-select-picker-icon-size);
|
|
37
|
+
--ui-combobox-icon-color: var(--ui-select-picker-icon-color);
|
|
38
|
+
--ui-combobox-panel-max-block-size: var(--step-72);
|
|
39
|
+
--ui-combobox-shadow: var(--ui-menu-shadow);
|
|
40
|
+
|
|
41
|
+
/* Control box: the multiselect variant swaps these to wrap into rows */
|
|
42
|
+
--ui-combobox-control-align: center;
|
|
43
|
+
--ui-combobox-control-wrap: nowrap;
|
|
44
|
+
--ui-combobox-control-gap: var(--ui-field-gap);
|
|
45
|
+
--ui-combobox-control-block-size: var(--ui-field-height);
|
|
46
|
+
--ui-combobox-control-min-block-size: auto;
|
|
47
|
+
--ui-combobox-control-padding-block: 0;
|
|
48
|
+
--ui-combobox-input-min-inline-size: 0;
|
|
49
|
+
--ui-combobox-input-min-block-size: auto;
|
|
50
|
+
|
|
51
|
+
/* Selection tags (data-variant="multiselect")
|
|
52
|
+
** Remove icon re-declared here: the identical --search-cancel-mask lives
|
|
53
|
+
** inside ::-webkit-search-cancel-button in _reset.css, out of reach.
|
|
54
|
+
** @see https://www.svgbackgrounds.com/tools/svg-to-css/
|
|
55
|
+
** Set to Legacy / URL Wrapper to update icon */
|
|
56
|
+
--ui-combobox-tag-gap: var(--step-1);
|
|
57
|
+
--ui-combobox-tag-padding-block: var(--step-1);
|
|
58
|
+
--ui-combobox-tag-max-inline-size: 100%;
|
|
59
|
+
--ui-combobox-tag-remove-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Crect width='256' height='256' fill='none'/%3E%3Cline x1='200' y1='56' x2='56' y2='200' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='16'/%3E%3Cline x1='200' y1='200' x2='56' y2='56' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='16'/%3E%3C/svg%3E");
|
|
60
|
+
--ui-combobox-tag-remove-size: var(--ui-badge-icon-size);
|
|
61
|
+
--ui-combobox-tag-remove-color: currentColor;
|
|
62
|
+
--ui-combobox-tag-remove-radius: var(--radius-sm);
|
|
63
|
+
--ui-combobox-tag-remove-opacity: 0.65;
|
|
64
|
+
--ui-combobox-tag-remove-opacity--hover: 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@layer zazz.components {
|
|
69
|
+
/* ===========================================================================
|
|
70
|
+
COMBOBOX: select-look control + anchored filterable panel
|
|
71
|
+
- The control shell carries the field surface (border, ring, chevron); the
|
|
72
|
+
inner input is bare so nothing double-borders. The panel rides
|
|
73
|
+
popover.css's surface + placement like autocomplete's.
|
|
74
|
+
=========================================================================== */
|
|
75
|
+
|
|
76
|
+
:where(ui-combobox, .ui-combobox) {
|
|
77
|
+
anchor-scope: --ui-combobox-trigger;
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: var(--step-px);
|
|
81
|
+
inline-size: var(--ui-combobox-inline-size);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[data-slot~="combobox-control"] {
|
|
85
|
+
anchor-name: --ui-combobox-trigger;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-wrap: var(--ui-combobox-control-wrap);
|
|
88
|
+
align-items: var(--ui-combobox-control-align);
|
|
89
|
+
gap: var(--ui-combobox-control-gap);
|
|
90
|
+
|
|
91
|
+
inline-size: 100%;
|
|
92
|
+
min-inline-size: var(--ui-combobox-min-inline-size);
|
|
93
|
+
block-size: var(--ui-combobox-control-block-size);
|
|
94
|
+
min-block-size: var(--ui-combobox-control-min-block-size);
|
|
95
|
+
padding-block: var(--ui-combobox-control-padding-block);
|
|
96
|
+
padding-inline: var(--ui-combobox-padding-inline-start) var(--ui-combobox-padding-inline-end);
|
|
97
|
+
|
|
98
|
+
font-size: var(--ui-field-font-size);
|
|
99
|
+
line-height: var(--ui-field-line-height);
|
|
100
|
+
color: var(--ui-field-foreground);
|
|
101
|
+
background-color: var(--ui-field-background);
|
|
102
|
+
|
|
103
|
+
border: var(--ui-combobox-border);
|
|
104
|
+
border-radius: var(--ui-combobox-border-radius);
|
|
105
|
+
|
|
106
|
+
/* Same ring recipe as .ui-select: transparent outline twin keeps focus
|
|
107
|
+
visible in forced-colors mode */
|
|
108
|
+
--_ring-offset-width: 0px;
|
|
109
|
+
--_ring-width: 0px;
|
|
110
|
+
--_ring: color-mix(in oklch, var(--ui-field-ring-color) var(--ring-opacity), transparent);
|
|
111
|
+
box-shadow:
|
|
112
|
+
0 0 0 var(--_ring-offset-width) var(--ring-offset-color),
|
|
113
|
+
0 0 0 calc(var(--_ring-offset-width) + var(--_ring-width)) var(--_ring, var(--ring));
|
|
114
|
+
outline: var(--outline-width) var(--outline-style) transparent;
|
|
115
|
+
outline-offset: var(--outline-offset);
|
|
116
|
+
|
|
117
|
+
transition: var(--default-transition);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-slot~="combobox-control"]:hover {
|
|
121
|
+
border-color: var(--ui-field-border--hover);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[data-slot~="combobox-control"]:focus-within {
|
|
125
|
+
border-color: var(--ui-field-border--focus);
|
|
126
|
+
background-color: var(--ui-field-background--focus);
|
|
127
|
+
--_ring-offset-width: var(--ring-offset-width);
|
|
128
|
+
--_ring-width: var(--ring-width);
|
|
129
|
+
outline-color: transparent;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[data-slot~="combobox-control"]:has(> [data-slot~="combobox-tag"]) {
|
|
133
|
+
padding-inline-start: var(--step-1_5);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* The inner input is bare: the shell owns the surface. It keeps a minimum
|
|
137
|
+
width so the multiselect variant wraps it onto its own row instead of
|
|
138
|
+
collapsing to nothing between the tags and the chevron. */
|
|
139
|
+
[data-slot~="combobox-control"] input {
|
|
140
|
+
flex: 1 1 var(--ui-combobox-input-min-inline-size);
|
|
141
|
+
min-inline-size: var(--ui-combobox-input-min-inline-size);
|
|
142
|
+
min-block-size: var(--ui-combobox-input-min-block-size);
|
|
143
|
+
font: inherit;
|
|
144
|
+
color: inherit;
|
|
145
|
+
background: none;
|
|
146
|
+
border: none;
|
|
147
|
+
outline: none;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[data-slot~="combobox-trigger"] {
|
|
151
|
+
display: grid;
|
|
152
|
+
place-items: center;
|
|
153
|
+
inline-size: var(--ui-combobox-icon-size);
|
|
154
|
+
block-size: var(--ui-combobox-icon-size);
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
margin-inline-start: auto;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[data-slot~="combobox-trigger"]::before {
|
|
161
|
+
content: "";
|
|
162
|
+
inline-size: var(--ui-combobox-icon-size);
|
|
163
|
+
block-size: var(--ui-combobox-icon-size);
|
|
164
|
+
background-color: var(--ui-combobox-icon-color);
|
|
165
|
+
mask: var(--ui-combobox-icon-mask) center / contain no-repeat;
|
|
166
|
+
transition: var(--default-transition);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* Panel: same shape as the autocomplete panel */
|
|
170
|
+
[data-slot~="combobox-panel"] {
|
|
171
|
+
position-anchor: --ui-combobox-trigger;
|
|
172
|
+
/* flex-direction stays ungated so the close fade keeps the column layout */
|
|
173
|
+
flex-direction: column;
|
|
174
|
+
max-block-size: var(--ui-combobox-panel-max-block-size);
|
|
175
|
+
overflow: auto;
|
|
176
|
+
box-shadow: var(--ui-combobox-shadow);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Only display is gated; see popover.css: closed popovers stay display: none */
|
|
180
|
+
[data-slot~="combobox-panel"]:where(:popover-open, .\:popover-open) {
|
|
181
|
+
display: flex;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Inline variant: no [popover]: the list renders in flow, always open,
|
|
185
|
+
without the floating surface chrome (combobox.js treats it as such) */
|
|
186
|
+
[data-slot~="combobox-panel"]:not([popover]) {
|
|
187
|
+
display: flex;
|
|
188
|
+
box-shadow: none;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@supports (inline-size: anchor-size(width)) {
|
|
192
|
+
[data-slot~="combobox-panel"] {
|
|
193
|
+
min-inline-size: anchor-size(width);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
[data-slot~="combobox-list"] {
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: var(--ui-combobox-option-gap);
|
|
201
|
+
margin: 0;
|
|
202
|
+
padding: 0;
|
|
203
|
+
list-style: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
[data-slot~="combobox-group"] {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-direction: column;
|
|
209
|
+
gap: var(--ui-combobox-option-gap);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* Score ranking writes order -1000..0 on sibling items: keep the label first */
|
|
213
|
+
[data-slot~="combobox-group-label"] {
|
|
214
|
+
order: -1001;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
[data-slot~="combobox-item"] {
|
|
218
|
+
cursor: pointer;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-slot~="combobox-item"][data-highlighted] {
|
|
222
|
+
--ui-button-background: var(--ui-button-background--hover);
|
|
223
|
+
--ui-button-foreground: var(--ui-button-foreground--hover);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* The committed item wears the shared option checkmark */
|
|
227
|
+
[data-slot~="combobox-item"][aria-selected="true"]::after {
|
|
228
|
+
content: "";
|
|
229
|
+
order: 1;
|
|
230
|
+
margin-inline-start: auto;
|
|
231
|
+
inline-size: var(--ui-option-checkmark-size);
|
|
232
|
+
block-size: var(--ui-option-checkmark-size);
|
|
233
|
+
background-color: var(--ui-option-checkmark-color);
|
|
234
|
+
mask: var(--ui-option-checkmark-mask) center / contain no-repeat;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
[data-slot~="combobox-group"]:not(:has([data-slot~="combobox-item"]:not([hidden]))) {
|
|
238
|
+
display: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
[data-slot~="combobox-empty"] {
|
|
242
|
+
display: none;
|
|
243
|
+
padding: var(--step-2);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
[data-slot~="combobox-panel"]:not(:has([data-slot~="combobox-item"]:not([hidden])))
|
|
247
|
+
[data-slot~="combobox-empty"] {
|
|
248
|
+
display: block;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* ===========================================================================
|
|
252
|
+
COMBOBOX MULTISELECT: selected values as removable tags inside the control
|
|
253
|
+
- The variant only swaps tokens: the control wraps into rows and grows from a
|
|
254
|
+
fixed height into a minimum one. combobox.js stamps the tags from the items
|
|
255
|
+
carrying aria-selected="true", dressed as .ui-badge[data-variant="muted"]
|
|
256
|
+
so a selection tag and a badge read as one thing.
|
|
257
|
+
=========================================================================== */
|
|
258
|
+
|
|
259
|
+
:where(ui-combobox, .ui-combobox)[data-variant="multiselect"] {
|
|
260
|
+
--ui-combobox-control-wrap: wrap;
|
|
261
|
+
--ui-combobox-control-gap: var(--ui-combobox-tag-gap);
|
|
262
|
+
--ui-combobox-control-block-size: auto;
|
|
263
|
+
--ui-combobox-control-min-block-size: var(--ui-field-height);
|
|
264
|
+
--ui-combobox-control-padding-block: var(--ui-combobox-tag-padding-block);
|
|
265
|
+
--ui-combobox-input-min-inline-size: var(--step-16);
|
|
266
|
+
--ui-combobox-input-min-block-size: var(--ui-badge-height);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* Overrides badge.css min-width: max-content (same layer, same
|
|
270
|
+
specificity, and combobox.css imports after badge.css) */
|
|
271
|
+
[data-slot~="combobox-tag"] {
|
|
272
|
+
min-inline-size: 0;
|
|
273
|
+
max-inline-size: var(--ui-combobox-tag-max-inline-size);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* The label wears its own box because text-overflow ignores a flex
|
|
277
|
+
container's own text, and .ui-badge is display: flex */
|
|
278
|
+
[data-slot~="combobox-tag-label"] {
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
text-overflow: ellipsis;
|
|
281
|
+
white-space: nowrap;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
[data-slot~="combobox-tag-remove"] {
|
|
285
|
+
display: grid;
|
|
286
|
+
place-items: center;
|
|
287
|
+
flex-shrink: 0;
|
|
288
|
+
inline-size: var(--ui-combobox-tag-remove-size);
|
|
289
|
+
block-size: var(--ui-combobox-tag-remove-size);
|
|
290
|
+
border-radius: var(--ui-combobox-tag-remove-radius);
|
|
291
|
+
opacity: var(--ui-combobox-tag-remove-opacity);
|
|
292
|
+
cursor: pointer;
|
|
293
|
+
transition: var(--default-transition);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
[data-slot~="combobox-tag-remove"]::before {
|
|
297
|
+
content: "";
|
|
298
|
+
inline-size: 100%;
|
|
299
|
+
block-size: 100%;
|
|
300
|
+
background-color: var(--ui-combobox-tag-remove-color);
|
|
301
|
+
mask: var(--ui-combobox-tag-remove-mask) center / contain no-repeat;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
[data-slot~="combobox-tag-remove"]:hover {
|
|
305
|
+
opacity: var(--ui-combobox-tag-remove-opacity--hover);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview `<ui-combobox>`: an input restricted to a predefined list.
|
|
3
|
+
* @description Light-DOM custom element on the shared typeahead engine
|
|
4
|
+
* (`base/typeahead.ts`). A relative of select: the panel filters as you type,
|
|
5
|
+
* but free text can never submit. The form value lives in an authored hidden
|
|
6
|
+
* input (`data-slot="combobox-value"`), synced whenever the selection changes.
|
|
7
|
+
*
|
|
8
|
+
* The visible input carries a **display value, not the filter**. Committing
|
|
9
|
+
* writes the option label into it and clears the query, so reopening shows
|
|
10
|
+
* the full list with the committed row checked, matching `.ui-select`.
|
|
11
|
+
* Opening selects that label so the first keystroke replaces it, and focus
|
|
12
|
+
* alone never opens the panel (a click, the chevron, an arrow key or typing
|
|
13
|
+
* does). On blur, stray text reverts to the committed label and cleared text
|
|
14
|
+
* clears the selection.
|
|
15
|
+
*
|
|
16
|
+
* `data-variant="multiselect"` selects a set instead: committing toggles a row
|
|
17
|
+
* and keeps the panel open, and every selected value renders as a removable
|
|
18
|
+
* tag stamped inside the control. The tag markup is HTML, not script: author
|
|
19
|
+
* a `<template data-slot="combobox-tag-template">` to control its classes and
|
|
20
|
+
* structure, and this file fills in the label, the value, and the remove
|
|
21
|
+
* button accessible name. Without one, the ui-badge default below applies.
|
|
22
|
+
* Backspace on an empty input drops the last tag. Options carrying
|
|
23
|
+
* `aria-selected="true"` are the single source of truth: the tags and the
|
|
24
|
+
* hidden inputs are both derived from them in DOM order so nothing can drift.
|
|
25
|
+
* The form submits repeated `name` pairs like `<select multiple>`: the authored
|
|
26
|
+
* hidden input carries the first value, and stamped siblings carry the rest.
|
|
27
|
+
*
|
|
28
|
+
* Where a no-JS fallback matters, prefer `.ui-select` / `<ui-multiselect>`:
|
|
29
|
+
* this control is inert without its script (the hidden input still submits a
|
|
30
|
+
* server-set value, but no tags render).
|
|
31
|
+
*
|
|
32
|
+
* Attributes on the root: `data-variant="multiselect"`, `data-sort="score"`,
|
|
33
|
+
* `data-min-length="<n>"`, `data-label-remove="Remove {label}"`.
|
|
34
|
+
* Parts: `combobox-value` (hidden input), `combobox-control` (select-look
|
|
35
|
+
* shell), `combobox-tag-template` (authored `<template>`), `combobox-tag` /
|
|
36
|
+
* `combobox-tag-label` / `combobox-tag-remove` (cloned from it),
|
|
37
|
+
* `combobox-trigger` (chevron), `combobox-panel`, `combobox-list`,
|
|
38
|
+
* `combobox-item`, `combobox-group` / `combobox-group-label`, `combobox-empty`.
|
|
39
|
+
*/
|
|
40
|
+
import { TypeaheadElement } from "../../base/typeahead.ts";
|
|
41
|
+
/** What a blur does to the input's text and to the committed selection. */
|
|
42
|
+
interface BlurOutcome {
|
|
43
|
+
/** The text the input shows once focus has left. */
|
|
44
|
+
value: string;
|
|
45
|
+
/** Whether the committed selection is dropped. */
|
|
46
|
+
clear: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @description Resolves a blur: free text never survives it. The multiselect
|
|
50
|
+
* variant always empties the filter (its selection lives in the tags), the
|
|
51
|
+
* single variant restores the committed label, and an emptied single-select
|
|
52
|
+
* input clears the selection outright.
|
|
53
|
+
*
|
|
54
|
+
* @param typed - The input's current text.
|
|
55
|
+
* @param committedLabel - The last committed label, empty for no selection.
|
|
56
|
+
* @param multiselect - Whether the multiselect variant is active.
|
|
57
|
+
* @returns The text to show and whether to clear the selection.
|
|
58
|
+
*/
|
|
59
|
+
declare function resolveBlur(typed: string, committedLabel: string, multiselect: boolean): BlurOutcome;
|
|
60
|
+
/**
|
|
61
|
+
* @description Fills the remove-button label template (`data-label-remove`).
|
|
62
|
+
*
|
|
63
|
+
* @param template - Template with a `{label}` placeholder.
|
|
64
|
+
* @param label - The tag's visible label.
|
|
65
|
+
* @returns The accessible name for that tag's remove button.
|
|
66
|
+
*/
|
|
67
|
+
declare function resolveRemoveLabel(template: string, label: string): string;
|
|
68
|
+
declare class UiCombobox extends TypeaheadElement {
|
|
69
|
+
#private;
|
|
70
|
+
protected readonly slotPrefix = "combobox";
|
|
71
|
+
/** The input holds a committed label, so focus alone must not open the list. */
|
|
72
|
+
protected readonly openOnFocus: boolean;
|
|
73
|
+
protected setup(signal: AbortSignal): void;
|
|
74
|
+
protected teardown(): void;
|
|
75
|
+
/**
|
|
76
|
+
* @description Combobox items match against what the user sees (the label)
|
|
77
|
+
* not the machine `data-value`.
|
|
78
|
+
*
|
|
79
|
+
* @param item - The item element.
|
|
80
|
+
* @returns The trimmed visible label.
|
|
81
|
+
*/
|
|
82
|
+
protected itemValue(item: HTMLElement): string;
|
|
83
|
+
/**
|
|
84
|
+
* @description Escape with the panel already closed restores the committed
|
|
85
|
+
* label (single) or drops the filter text (multiselect), avoiding a half-typed
|
|
86
|
+
* value that a later blur would read as a cleared selection.
|
|
87
|
+
*/
|
|
88
|
+
protected clearQuery(): void;
|
|
89
|
+
/**
|
|
90
|
+
* @description Committing shows the item's label, stores its `data-value` in
|
|
91
|
+
* the hidden input, and moves `aria-selected`. The multiselect variant
|
|
92
|
+
* toggles the row instead and keeps the panel open so picking can continue.
|
|
93
|
+
*
|
|
94
|
+
* @param item - The committed option.
|
|
95
|
+
*/
|
|
96
|
+
protected commit(item: HTMLElement, _source: "keyboard" | "pointer"): void;
|
|
97
|
+
}
|
|
98
|
+
export { UiCombobox, resolveBlur, resolveRemoveLabel };
|
|
99
|
+
export type { BlurOutcome };
|
|
100
|
+
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["combobox.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAoC3D,2EAA2E;AAC3E,UAAU,WAAW;IACnB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,WAAW,CAI7F;AAED;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAID,cAAM,UAAW,SAAQ,gBAAgB;;IACvC,SAAS,CAAC,QAAQ,CAAC,UAAU,cAAc;IAC3C,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAS;IAOhD,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA8HzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAOzB;IAED;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAE7C;IAED;;;;OAIG;IACH,SAAS,CAAC,UAAU,IAAI,IAAI,CAK3B;IAED;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CA+BzE;CAqOF;AAID,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<div class="ui-field max-w-xl">
|
|
2
|
+
<label data-slot="field-label" for="cb-country">Country</label>
|
|
3
|
+
<ui-combobox>
|
|
4
|
+
<input type="hidden" name="country" data-slot="combobox-value" value="" />
|
|
5
|
+
<div data-slot="combobox-control">
|
|
6
|
+
<input
|
|
7
|
+
id="cb-country"
|
|
8
|
+
type="text"
|
|
9
|
+
placeholder="Select a country..."
|
|
10
|
+
role="combobox"
|
|
11
|
+
aria-expanded="false"
|
|
12
|
+
aria-autocomplete="list"
|
|
13
|
+
autocomplete="off"
|
|
14
|
+
/>
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
data-slot="combobox-trigger"
|
|
18
|
+
tabindex="-1"
|
|
19
|
+
aria-label="Show options"
|
|
20
|
+
></button>
|
|
21
|
+
</div>
|
|
22
|
+
<div data-slot="combobox-panel" data-side="bottom" data-align="start" popover="manual">
|
|
23
|
+
<ul role="listbox" data-slot="combobox-list" aria-label="Countries">
|
|
24
|
+
<li
|
|
25
|
+
role="option"
|
|
26
|
+
data-slot="combobox-item"
|
|
27
|
+
class="ui-button justify-start"
|
|
28
|
+
data-variant="ghost"
|
|
29
|
+
data-value="au"
|
|
30
|
+
>
|
|
31
|
+
Australia
|
|
32
|
+
</li>
|
|
33
|
+
<li
|
|
34
|
+
role="option"
|
|
35
|
+
data-slot="combobox-item"
|
|
36
|
+
class="ui-button justify-start"
|
|
37
|
+
data-variant="ghost"
|
|
38
|
+
data-value="ca"
|
|
39
|
+
>
|
|
40
|
+
Canada
|
|
41
|
+
</li>
|
|
42
|
+
<li
|
|
43
|
+
role="option"
|
|
44
|
+
data-slot="combobox-item"
|
|
45
|
+
class="ui-button justify-start"
|
|
46
|
+
data-variant="ghost"
|
|
47
|
+
data-value="jp"
|
|
48
|
+
>
|
|
49
|
+
Japan
|
|
50
|
+
</li>
|
|
51
|
+
<li
|
|
52
|
+
role="option"
|
|
53
|
+
data-slot="combobox-item"
|
|
54
|
+
class="ui-button justify-start"
|
|
55
|
+
data-variant="ghost"
|
|
56
|
+
data-value="nz"
|
|
57
|
+
>
|
|
58
|
+
New Zealand
|
|
59
|
+
</li>
|
|
60
|
+
<li
|
|
61
|
+
role="option"
|
|
62
|
+
data-slot="combobox-item"
|
|
63
|
+
class="ui-button justify-start"
|
|
64
|
+
data-variant="ghost"
|
|
65
|
+
data-value="us"
|
|
66
|
+
>
|
|
67
|
+
United States
|
|
68
|
+
</li>
|
|
69
|
+
</ul>
|
|
70
|
+
<p data-slot="combobox-empty" class="text-muted-foreground text-sm">No matches.</p>
|
|
71
|
+
</div>
|
|
72
|
+
</ui-combobox>
|
|
73
|
+
</div>
|