@zazz-ui/core 0.4.1 → 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 +331 -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 +43 -39
- 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 +145 -122
- 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 +88 -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 +297 -186
- 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
1
|
/**
|
|
2
|
-
* otp.css: OTP (ui-otp wrapping
|
|
2
|
+
* otp.css: OTP (ui-otp wrapping :where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="input"] on one real <input>)
|
|
3
3
|
*
|
|
4
4
|
* @layer variables, components
|
|
5
|
-
* @requires
|
|
5
|
+
* @requires _layers.css, _variables.css, fields.css, input.css
|
|
6
6
|
* @uses Invisible-overlay input: the real input stretches over the
|
|
7
7
|
* stamped cell rail with transparent text/caret so autofill,
|
|
8
8
|
* paste, and focus stay native; never display:none
|
|
@@ -13,45 +13,43 @@
|
|
|
13
13
|
|
|
14
14
|
@layer variables {
|
|
15
15
|
:root {
|
|
16
|
-
--ui-otp-
|
|
17
|
-
--ui-otp-
|
|
18
|
-
--ui-otp-
|
|
19
|
-
--ui-otp-
|
|
20
|
-
--ui-otp-
|
|
21
|
-
--ui-otp-
|
|
22
|
-
--ui-otp-
|
|
23
|
-
--ui-otp-
|
|
24
|
-
--ui-otp-gap: var(--
|
|
25
|
-
--ui-otp-separator-
|
|
26
|
-
--ui-otp-caret-color: var(--ui-field-border-color--focus);
|
|
16
|
+
--ui-otp-cell-w: var(--ui-field-h);
|
|
17
|
+
--ui-otp-cell-h: var(--ui-field-h);
|
|
18
|
+
--ui-otp-cell-bg: var(--ui-field-bg);
|
|
19
|
+
--ui-otp-cell-border-width: var(--ui-field-border-width);
|
|
20
|
+
--ui-otp-cell-border-style: var(--ui-field-border-style);
|
|
21
|
+
--ui-otp-cell-border-color: var(--ui-field-border-color);
|
|
22
|
+
--ui-otp-cell-rounded: var(--ui-field-rounded);
|
|
23
|
+
--ui-otp-cell-font-size: var(--font-size-md);
|
|
24
|
+
--ui-otp-gap: calc(var(--spacing) * 1.5);
|
|
25
|
+
--ui-otp-separator-text: var(--color-muted-foreground);
|
|
26
|
+
--ui-otp-caret-color: var(--ui-field-border-color--focus-within);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
@layer
|
|
30
|
+
@layer ui.components {
|
|
31
31
|
/* ===========================================================================
|
|
32
32
|
OTP: one real input, presentational cells
|
|
33
|
-
- Before enhancement (
|
|
33
|
+
- Before enhancement (:where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="input"] alone): a centered code field.
|
|
34
34
|
- After ([data-otp-ready]): the rail is the visual and the input becomes an
|
|
35
35
|
invisible overlay (focusable, autofillable, never display:none).
|
|
36
36
|
=========================================================================== */
|
|
37
37
|
|
|
38
|
-
:where(ui-otp) {
|
|
38
|
+
:where(ui-otp, [data-ui~="otp"]) {
|
|
39
39
|
position: relative;
|
|
40
40
|
display: inline-grid;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
.ui-otp-input {
|
|
43
|
+
:where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="input"] {
|
|
45
44
|
text-align: center;
|
|
46
45
|
letter-spacing: 0.5ch;
|
|
47
46
|
font-family: var(--font-family-mono);
|
|
48
|
-
font-size: var(--ui-otp-
|
|
47
|
+
font-size: var(--ui-otp-cell-font-size);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
/*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
:where(ui-otp[data-otp-ready]) .ui-otp-input {
|
|
50
|
+
/* Opacity stays just above zero and the input keeps its size so taps, focus,
|
|
51
|
+
and autofill UI still target a real control. */
|
|
52
|
+
:where(ui-otp[data-otp-ready], [data-ui~="otp"][data-otp-ready]) [data-otp-slot~="input"] {
|
|
55
53
|
position: absolute;
|
|
56
54
|
inset: 0;
|
|
57
55
|
inline-size: 100%;
|
|
@@ -64,46 +62,46 @@
|
|
|
64
62
|
border: none;
|
|
65
63
|
box-shadow: none;
|
|
66
64
|
outline: none;
|
|
67
|
-
/*
|
|
65
|
+
/* prevents iOS focus zoom */
|
|
68
66
|
font-size: max(16px, 1em);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
[data-
|
|
69
|
+
:where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="rail"] {
|
|
72
70
|
display: flex;
|
|
73
71
|
align-items: center;
|
|
74
72
|
gap: var(--ui-otp-gap);
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
[data-
|
|
75
|
+
:where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="cell"] {
|
|
78
76
|
display: grid;
|
|
79
77
|
place-items: center;
|
|
80
|
-
inline-size: var(--ui-otp-
|
|
81
|
-
block-size: var(--ui-otp-
|
|
78
|
+
inline-size: var(--ui-otp-cell-w);
|
|
79
|
+
block-size: var(--ui-otp-cell-h);
|
|
82
80
|
|
|
83
81
|
font-family: var(--font-family-mono);
|
|
84
|
-
font-size: var(--ui-otp-
|
|
85
|
-
color: var(--ui-field-
|
|
82
|
+
font-size: var(--ui-otp-cell-font-size);
|
|
83
|
+
color: var(--ui-field-text);
|
|
86
84
|
|
|
87
|
-
background-color: var(--ui-otp-
|
|
88
|
-
border: var(--ui-otp-
|
|
89
|
-
var(--ui-otp-
|
|
90
|
-
border-radius: var(--ui-otp-
|
|
85
|
+
background-color: var(--ui-otp-cell-bg);
|
|
86
|
+
border: var(--ui-otp-cell-border-width) var(--ui-otp-cell-border-style)
|
|
87
|
+
var(--ui-otp-cell-border-color);
|
|
88
|
+
border-radius: var(--ui-otp-cell-rounded);
|
|
91
89
|
|
|
92
90
|
transition: var(--default-transition);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
border-color: var(--ui-field-border-color--focus);
|
|
98
|
-
background-color: var(--ui-field-
|
|
93
|
+
:where(ui-otp:focus-within, [data-ui~="otp"]:focus-within)
|
|
94
|
+
[data-otp-slot~="cell"][data-otp-state~="active"] {
|
|
95
|
+
border-color: var(--ui-field-border-color--focus-within);
|
|
96
|
+
background-color: var(--ui-field-bg--focus-within);
|
|
99
97
|
box-shadow:
|
|
100
|
-
0 0 0 var(--ring-offset-width) var(--ring-offset-color),
|
|
98
|
+
0 0 0 var(--ring-offset-width) var(--ring-offset-shadow-color),
|
|
101
99
|
0 0 0 calc(var(--ring-offset-width) + var(--ring-width))
|
|
102
100
|
color-mix(in oklch, var(--ui-field-ring-color) var(--ring-opacity), transparent);
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
:where(ui-otp:focus-within, [data-ui~="otp"]:focus-within)
|
|
104
|
+
[data-otp-slot~="cell"][data-otp-state~="active"]:empty::after {
|
|
107
105
|
content: "";
|
|
108
106
|
inline-size: 1px;
|
|
109
107
|
block-size: 1.2em;
|
|
@@ -111,7 +109,8 @@
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
@media (prefers-reduced-motion: no-preference) {
|
|
114
|
-
:where(ui-otp:focus-within
|
|
112
|
+
:where(ui-otp:focus-within, [data-ui~="otp"]:focus-within)
|
|
113
|
+
[data-otp-slot~="cell"][data-otp-state~="active"]:empty::after {
|
|
115
114
|
animation: ui-otp-caret-blink 1.1s steps(2, start) infinite;
|
|
116
115
|
}
|
|
117
116
|
}
|
|
@@ -122,8 +121,8 @@
|
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
[data-
|
|
126
|
-
color: var(--ui-otp-separator-
|
|
124
|
+
:where(ui-otp, [data-ui~="otp"]) [data-otp-slot~="separator"] {
|
|
125
|
+
color: var(--ui-otp-separator-text);
|
|
127
126
|
user-select: none;
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview `<ui-otp>`: a one-time password field with character slots.
|
|
3
3
|
* @description Light-DOM custom element that augments a single
|
|
4
|
-
* `<input
|
|
4
|
+
* `<input data-ui="input" data-otp-slot="input">` (the standard OTP shape with
|
|
5
5
|
* `autocomplete="one-time-code"`, `inputmode`, `pattern`, and `maxlength`)
|
|
6
6
|
* with a presentational slot rail. The input stays the source of truth:
|
|
7
7
|
* autofill, paste, IME, undo, form submission, and `:user-invalid` are all
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* character and the caret position. Without JavaScript the markup is a plain,
|
|
11
11
|
* fully functional OTP input.
|
|
12
12
|
*
|
|
13
|
-
* The code length comes from the input `maxlength`.
|
|
14
|
-
* `data-otp-length`.
|
|
13
|
+
* The code length comes from the input `maxlength`.
|
|
15
14
|
*
|
|
16
15
|
* Attributes on `<ui-otp>`:
|
|
17
16
|
* - `data-otp-groups`: separator layout, e.g. `"3-3"` or `"2-2-2"`. The
|
|
@@ -23,8 +22,8 @@
|
|
|
23
22
|
* - `data-otp-auto-submit`: request the owning form submission once when
|
|
24
23
|
* the code is complete.
|
|
25
24
|
*
|
|
26
|
-
* Stamped state: cells are `[data-
|
|
27
|
-
* `
|
|
25
|
+
* Stamped state: cells are `[data-otp-slot~="cell"]` with a `data-otp-state`
|
|
26
|
+
* token list (`filled`, `active`); separators are `[data-otp-slot~="separator"]`; the root
|
|
28
27
|
* gains `data-otp-ready` when enhanced and `data-otp-complete` when full.
|
|
29
28
|
*/
|
|
30
29
|
import { ZazzElement } from "../../base/zazz-element.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["otp.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"otp.d.ts","sourceRoot":"","sources":["otp.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAG5E,sDAAsD;AACtD,KAAK,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,CAAC;AAE7D,4DAA4D;AAC5D,UAAU,SAAS;IACjB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAQjE;AAED;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBvE;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,YAAY,CACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,GACZ,SAAS,EAAE,CAUb;AAED;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,cAAM,KAAM,SAAQ,WAAW;;IAI7B,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAqFzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAKzB;CAoCF;AAID,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AACrE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
<form
|
|
2
|
-
<label data-slot="
|
|
1
|
+
<form data-ui="field" style="--max-w: max-content">
|
|
2
|
+
<label data-field-slot="label" for="f-otp">Verification code</label>
|
|
3
3
|
<ui-otp data-otp-groups="3-3">
|
|
4
4
|
<input
|
|
5
|
-
|
|
5
|
+
data-ui="input"
|
|
6
|
+
data-otp-slot="input"
|
|
6
7
|
id="f-otp"
|
|
7
8
|
name="otp"
|
|
8
9
|
type="text"
|
|
@@ -15,8 +16,8 @@
|
|
|
15
16
|
autocapitalize="off"
|
|
16
17
|
/>
|
|
17
18
|
</ui-otp>
|
|
18
|
-
<div data-slot="
|
|
19
|
-
<span data-slot="
|
|
20
|
-
<span data-slot="
|
|
19
|
+
<div data-field-slot="description">
|
|
20
|
+
<span data-field-slot="hint">Enter the 6-digit code we sent you.</span>
|
|
21
|
+
<span data-field-slot="error">Enter all 6 digits.</span>
|
|
21
22
|
</div>
|
|
22
23
|
</form>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @fileoverview `<ui-otp>`: a one-time password field with character slots.
|
|
4
4
|
* @description Light-DOM custom element that augments a single
|
|
5
|
-
* `<input
|
|
5
|
+
* `<input data-ui="input" data-otp-slot="input">` (the standard OTP shape with
|
|
6
6
|
* `autocomplete="one-time-code"`, `inputmode`, `pattern`, and `maxlength`)
|
|
7
7
|
* with a presentational slot rail. The input stays the source of truth:
|
|
8
8
|
* autofill, paste, IME, undo, form submission, and `:user-invalid` are all
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
* character and the caret position. Without JavaScript the markup is a plain,
|
|
12
12
|
* fully functional OTP input.
|
|
13
13
|
*
|
|
14
|
-
* The code length comes from the input `maxlength`.
|
|
15
|
-
* `data-otp-length`.
|
|
14
|
+
* The code length comes from the input `maxlength`.
|
|
16
15
|
*
|
|
17
16
|
* Attributes on `<ui-otp>`:
|
|
18
17
|
* - `data-otp-groups`: separator layout, e.g. `"3-3"` or `"2-2-2"`. The
|
|
@@ -24,13 +23,12 @@
|
|
|
24
23
|
* - `data-otp-auto-submit`: request the owning form submission once when
|
|
25
24
|
* the code is complete.
|
|
26
25
|
*
|
|
27
|
-
* Stamped state: cells are `[data-
|
|
28
|
-
* `
|
|
26
|
+
* Stamped state: cells are `[data-otp-slot~="cell"]` with a `data-otp-state`
|
|
27
|
+
* token list (`filled`, `active`); separators are `[data-otp-slot~="separator"]`; the root
|
|
29
28
|
* gains `data-otp-ready` when enhanced and `data-otp-complete` when full.
|
|
30
29
|
*/
|
|
31
30
|
import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
|
|
32
31
|
import { effect, state } from "../../base/signals.js";
|
|
33
|
-
// --- Pure derivations (exported for unit tests only) ---
|
|
34
32
|
/**
|
|
35
33
|
* @description Parses `data-otp-groups` ("3-3") into group sizes. Groups that
|
|
36
34
|
* don't sum to the code length fall back to one ungrouped run.
|
|
@@ -109,7 +107,6 @@ function resolveSlots(value, length, caret, focused, mask) {
|
|
|
109
107
|
function isComplete(value, length) {
|
|
110
108
|
return length > 0 && value.length === length;
|
|
111
109
|
}
|
|
112
|
-
// --- Element ---
|
|
113
110
|
class UiOtp extends ZazzElement {
|
|
114
111
|
#rail = null;
|
|
115
112
|
#lastSubmitted = "";
|
|
@@ -141,7 +138,6 @@ class UiOtp extends ZazzElement {
|
|
|
141
138
|
}, { signal });
|
|
142
139
|
input.addEventListener("focus", () => focused.set(true), { signal });
|
|
143
140
|
input.addEventListener("blur", () => focused.set(false), { signal });
|
|
144
|
-
// Clicking a cell moves the caret to it
|
|
145
141
|
rail.addEventListener("pointerdown", (event) => {
|
|
146
142
|
const cell = event.target instanceof Element ? event.target.closest("[data-otp-index]") : null;
|
|
147
143
|
event.preventDefault();
|
|
@@ -160,14 +156,13 @@ class UiOtp extends ZazzElement {
|
|
|
160
156
|
if (!(cell instanceof HTMLElement))
|
|
161
157
|
return;
|
|
162
158
|
cell.textContent = slot.char;
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
const state = [slot.filled && "filled", slot.active && "active"]
|
|
160
|
+
.filter(Boolean)
|
|
161
|
+
.join(" ");
|
|
162
|
+
if (state)
|
|
163
|
+
cell.setAttribute("data-otp-state", state);
|
|
165
164
|
else
|
|
166
|
-
cell.removeAttribute("data-
|
|
167
|
-
if (slot.active)
|
|
168
|
-
cell.setAttribute("data-active", "");
|
|
169
|
-
else
|
|
170
|
-
cell.removeAttribute("data-active");
|
|
165
|
+
cell.removeAttribute("data-otp-state");
|
|
171
166
|
});
|
|
172
167
|
const complete = isComplete(value.get(), length);
|
|
173
168
|
if (complete)
|
|
@@ -199,20 +194,20 @@ class UiOtp extends ZazzElement {
|
|
|
199
194
|
*/
|
|
200
195
|
#stampRail(groups) {
|
|
201
196
|
const rail = document.createElement("div");
|
|
202
|
-
rail.setAttribute("data-slot", "
|
|
197
|
+
rail.setAttribute("data-otp-slot", "rail");
|
|
203
198
|
rail.setAttribute("aria-hidden", "true");
|
|
204
199
|
let index = 0;
|
|
205
200
|
groups.forEach((size, groupIndex) => {
|
|
206
201
|
if (groupIndex > 0) {
|
|
207
202
|
const separator = document.createElement("span");
|
|
208
|
-
separator.setAttribute("data-slot", "
|
|
203
|
+
separator.setAttribute("data-otp-slot", "separator");
|
|
209
204
|
separator.setAttribute("aria-role", "presentation");
|
|
210
205
|
separator.textContent = "–";
|
|
211
206
|
rail.append(separator);
|
|
212
207
|
}
|
|
213
208
|
for (let i = 0; i < size; i++) {
|
|
214
209
|
const cell = document.createElement("span");
|
|
215
|
-
cell.setAttribute("data-slot", "
|
|
210
|
+
cell.setAttribute("data-otp-slot", "cell");
|
|
216
211
|
cell.setAttribute("data-otp-index", String(index++));
|
|
217
212
|
rail.append(cell);
|
|
218
213
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @fileoverview `<ui-otp>`: a one-time password field with character slots.
|
|
5
5
|
* @description Light-DOM custom element that augments a single
|
|
6
|
-
* `<input
|
|
6
|
+
* `<input data-ui="input" data-otp-slot="input">` (the standard OTP shape with
|
|
7
7
|
* `autocomplete="one-time-code"`, `inputmode`, `pattern`, and `maxlength`)
|
|
8
8
|
* with a presentational slot rail. The input stays the source of truth:
|
|
9
9
|
* autofill, paste, IME, undo, form submission, and `:user-invalid` are all
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
* character and the caret position. Without JavaScript the markup is a plain,
|
|
13
13
|
* fully functional OTP input.
|
|
14
14
|
*
|
|
15
|
-
* The code length comes from the input `maxlength`.
|
|
16
|
-
* `data-otp-length`.
|
|
15
|
+
* The code length comes from the input `maxlength`.
|
|
17
16
|
*
|
|
18
17
|
* Attributes on `<ui-otp>`:
|
|
19
18
|
* - `data-otp-groups`: separator layout, e.g. `"3-3"` or `"2-2-2"`. The
|
|
@@ -25,16 +24,14 @@
|
|
|
25
24
|
* - `data-otp-auto-submit`: request the owning form submission once when
|
|
26
25
|
* the code is complete.
|
|
27
26
|
*
|
|
28
|
-
* Stamped state: cells are `[data-
|
|
29
|
-
* `
|
|
27
|
+
* Stamped state: cells are `[data-otp-slot~="cell"]` with a `data-otp-state`
|
|
28
|
+
* token list (`filled`, `active`); separators are `[data-otp-slot~="separator"]`; the root
|
|
30
29
|
* gains `data-otp-ready` when enhanced and `data-otp-complete` when full.
|
|
31
30
|
*/
|
|
32
31
|
|
|
33
32
|
import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
|
|
34
33
|
import { effect, state } from "../../base/signals.ts";
|
|
35
34
|
|
|
36
|
-
// --- Types ---
|
|
37
|
-
|
|
38
35
|
/** Sanitization charset for typed and pasted text. */
|
|
39
36
|
type OtpType = "numeric" | "alpha" | "alphanumeric" | "none";
|
|
40
37
|
|
|
@@ -48,8 +45,6 @@ interface SlotState {
|
|
|
48
45
|
active: boolean;
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
// --- Pure derivations (exported for unit tests only) ---
|
|
52
|
-
|
|
53
48
|
/**
|
|
54
49
|
* @description Parses `data-otp-groups` ("3-3") into group sizes. Groups that
|
|
55
50
|
* don't sum to the code length fall back to one ungrouped run.
|
|
@@ -137,8 +132,6 @@ function isComplete(value: string, length: number): boolean {
|
|
|
137
132
|
return length > 0 && value.length === length;
|
|
138
133
|
}
|
|
139
134
|
|
|
140
|
-
// --- Element ---
|
|
141
|
-
|
|
142
135
|
class UiOtp extends ZazzElement {
|
|
143
136
|
#rail: HTMLElement | null = null;
|
|
144
137
|
#lastSubmitted = "";
|
|
@@ -183,7 +176,6 @@ class UiOtp extends ZazzElement {
|
|
|
183
176
|
input.addEventListener("focus", () => focused.set(true), { signal });
|
|
184
177
|
input.addEventListener("blur", () => focused.set(false), { signal });
|
|
185
178
|
|
|
186
|
-
// Clicking a cell moves the caret to it
|
|
187
179
|
rail.addEventListener(
|
|
188
180
|
"pointerdown",
|
|
189
181
|
(event) => {
|
|
@@ -208,10 +200,11 @@ class UiOtp extends ZazzElement {
|
|
|
208
200
|
const cell = cells[index];
|
|
209
201
|
if (!(cell instanceof HTMLElement)) return;
|
|
210
202
|
cell.textContent = slot.char;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
203
|
+
const state = [slot.filled && "filled", slot.active && "active"]
|
|
204
|
+
.filter(Boolean)
|
|
205
|
+
.join(" ");
|
|
206
|
+
if (state) cell.setAttribute("data-otp-state", state);
|
|
207
|
+
else cell.removeAttribute("data-otp-state");
|
|
215
208
|
});
|
|
216
209
|
|
|
217
210
|
const complete = isComplete(value.get(), length);
|
|
@@ -247,21 +240,21 @@ class UiOtp extends ZazzElement {
|
|
|
247
240
|
*/
|
|
248
241
|
#stampRail(groups: number[]): HTMLElement {
|
|
249
242
|
const rail = document.createElement("div");
|
|
250
|
-
rail.setAttribute("data-slot", "
|
|
243
|
+
rail.setAttribute("data-otp-slot", "rail");
|
|
251
244
|
rail.setAttribute("aria-hidden", "true");
|
|
252
245
|
|
|
253
246
|
let index = 0;
|
|
254
247
|
groups.forEach((size, groupIndex) => {
|
|
255
248
|
if (groupIndex > 0) {
|
|
256
249
|
const separator = document.createElement("span");
|
|
257
|
-
separator.setAttribute("data-slot", "
|
|
250
|
+
separator.setAttribute("data-otp-slot", "separator");
|
|
258
251
|
separator.setAttribute("aria-role", "presentation");
|
|
259
252
|
separator.textContent = "–";
|
|
260
253
|
rail.append(separator);
|
|
261
254
|
}
|
|
262
255
|
for (let i = 0; i < size; i++) {
|
|
263
256
|
const cell = document.createElement("span");
|
|
264
|
-
cell.setAttribute("data-slot", "
|
|
257
|
+
cell.setAttribute("data-otp-slot", "cell");
|
|
265
258
|
cell.setAttribute("data-otp-index", String(index++));
|
|
266
259
|
rail.append(cell);
|
|
267
260
|
}
|