@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.
Files changed (331) hide show
  1. package/AUTHORING.md +158 -0
  2. package/CHANGELOG.md +331 -0
  3. package/README.md +55 -23
  4. package/dist/scroll-state-C8mA5gq6.js +1 -0
  5. package/dist/sri.json +124 -72
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +116794 -0
  9. package/editor/zazz.html-data.json +1683 -0
  10. package/editor/zazz.language-data.json +5001 -0
  11. package/editor/zazz.lint-data.json +152 -0
  12. package/package.json +12 -5
  13. package/src/base/_breakpoints.css +12 -0
  14. package/src/base/_layers.css +8 -9
  15. package/src/base/_properties-2xl.css +171 -0
  16. package/src/base/_properties-active.css +107 -0
  17. package/src/base/_properties-checked.css +107 -0
  18. package/src/base/_properties-current.css +107 -0
  19. package/src/base/_properties-disabled.css +107 -0
  20. package/src/base/_properties-focus-visible.css +107 -0
  21. package/src/base/_properties-focus-within.css +107 -0
  22. package/src/base/_properties-hover.css +107 -0
  23. package/src/base/_properties-lg.css +171 -0
  24. package/src/base/_properties-md.css +171 -0
  25. package/src/base/_properties-open.css +107 -0
  26. package/src/base/_properties-sm.css +171 -0
  27. package/src/base/_properties-starting.css +55 -0
  28. package/src/base/_properties-stuck.css +55 -0
  29. package/src/base/_properties-xl.css +171 -0
  30. package/src/base/_properties.css +555 -0
  31. package/src/base/_reset.css +67 -75
  32. package/src/base/_switches.css +145 -0
  33. package/src/base/_typography.css +437 -370
  34. package/src/base/_utilities-box.css +142 -0
  35. package/src/base/_utilities-color.css +290 -0
  36. package/src/base/_utilities-effects.css +235 -0
  37. package/src/base/_utilities-flow.css +312 -0
  38. package/src/base/_utilities-grid.css +143 -0
  39. package/src/base/_utilities-margin.css +376 -0
  40. package/src/base/_utilities-pseudo.css +426 -0
  41. package/src/base/_utilities-sizing.css +259 -0
  42. package/src/base/_utilities-spacing.css +190 -0
  43. package/src/base/_utilities-tier-2xl.css +93 -0
  44. package/src/base/_utilities-tier-active.css +61 -0
  45. package/src/base/_utilities-tier-checked.css +61 -0
  46. package/src/base/_utilities-tier-current.css +61 -0
  47. package/src/base/_utilities-tier-disabled.css +61 -0
  48. package/src/base/_utilities-tier-focus-visible.css +61 -0
  49. package/src/base/_utilities-tier-focus-within.css +61 -0
  50. package/src/base/_utilities-tier-hover.css +63 -0
  51. package/src/base/_utilities-tier-lg.css +93 -0
  52. package/src/base/_utilities-tier-md.css +93 -0
  53. package/src/base/_utilities-tier-open.css +61 -0
  54. package/src/base/_utilities-tier-sm.css +93 -0
  55. package/src/base/_utilities-tier-starting.css +35 -0
  56. package/src/base/_utilities-tier-stuck.css +114 -0
  57. package/src/base/_utilities-tier-xl.css +93 -0
  58. package/src/base/_utilities-typography.css +141 -0
  59. package/src/base/_variables.css +323 -372
  60. package/src/base/_view-transitions.css +10 -12
  61. package/src/base/command-score.d.ts.map +1 -1
  62. package/src/base/command-score.js +1 -2
  63. package/src/base/command-score.ts +1 -2
  64. package/src/base/dialog-lifecycle.js +1 -1
  65. package/src/base/dialog-lifecycle.ts +1 -1
  66. package/src/base/embla.d.ts +6 -7
  67. package/src/base/embla.d.ts.map +1 -1
  68. package/src/base/embla.js +89 -55
  69. package/src/base/embla.ts +89 -55
  70. package/src/base/hotkeys.d.ts +0 -5
  71. package/src/base/hotkeys.d.ts.map +1 -1
  72. package/src/base/hotkeys.ts +0 -5
  73. package/src/base/navigation.d.ts +12 -1
  74. package/src/base/navigation.d.ts.map +1 -1
  75. package/src/base/navigation.js +229 -86
  76. package/src/base/navigation.ts +224 -92
  77. package/src/base/reveal.js +14 -14
  78. package/src/base/reveal.ts +14 -14
  79. package/src/base/scroll-state.d.ts +21 -0
  80. package/src/base/scroll-state.d.ts.map +1 -0
  81. package/src/base/scroll-state.js +177 -0
  82. package/src/base/scroll-state.ts +188 -0
  83. package/src/base/signals.d.ts +1 -2
  84. package/src/base/signals.d.ts.map +1 -1
  85. package/src/base/signals.js +4 -6
  86. package/src/base/signals.ts +4 -6
  87. package/src/base/style-format.d.ts +33 -0
  88. package/src/base/style-format.d.ts.map +1 -0
  89. package/src/base/style-format.js +160 -0
  90. package/src/base/style-format.ts +180 -0
  91. package/src/base/typeahead.d.ts +19 -4
  92. package/src/base/typeahead.d.ts.map +1 -1
  93. package/src/base/typeahead.js +68 -21
  94. package/src/base/typeahead.ts +73 -23
  95. package/src/base/utilities.d.ts +188 -0
  96. package/src/base/utilities.d.ts.map +1 -0
  97. package/src/base/utilities.js +750 -0
  98. package/src/base/utilities.ts +865 -0
  99. package/src/base/utils.d.ts +3 -7
  100. package/src/base/utils.d.ts.map +1 -1
  101. package/src/base/utils.js +4 -8
  102. package/src/base/utils.ts +4 -8
  103. package/src/base/zazz-element.d.ts +14 -8
  104. package/src/base/zazz-element.d.ts.map +1 -1
  105. package/src/base/zazz-element.js +14 -8
  106. package/src/base/zazz-element.ts +15 -8
  107. package/src/globals.d.ts +1 -1
  108. package/src/head.d.ts +50 -4
  109. package/src/head.d.ts.map +1 -1
  110. package/src/head.js +119 -38
  111. package/src/head.ts +172 -41
  112. package/src/index.css +57 -14
  113. package/src/index.js +5 -0
  114. package/src/index.ts +6 -0
  115. package/src/manifest.d.ts +36 -5
  116. package/src/manifest.d.ts.map +1 -1
  117. package/src/manifest.js +150 -6
  118. package/src/manifest.ts +167 -9
  119. package/src/primitives/accordion/accordion.css +18 -17
  120. package/src/primitives/accordion/accordion.html +42 -9
  121. package/src/primitives/alert-dialog/alert-dialog.css +13 -13
  122. package/src/primitives/alert-dialog/alert-dialog.html +26 -12
  123. package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
  124. package/src/primitives/autocomplete/autocomplete.css +43 -39
  125. package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
  126. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
  127. package/src/primitives/autocomplete/autocomplete.html +38 -26
  128. package/src/primitives/autocomplete/autocomplete.js +6 -5
  129. package/src/primitives/autocomplete/autocomplete.ts +6 -5
  130. package/src/primitives/avatar/avatar.html +110 -15
  131. package/src/primitives/badge/badge-icon.html +22 -8
  132. package/src/primitives/badge/badge.css +401 -128
  133. package/src/primitives/badge/badge.html +12 -6
  134. package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
  135. package/src/primitives/button/button-icon-only.html +17 -11
  136. package/src/primitives/button/button-icon.html +9 -3
  137. package/src/primitives/button/button.css +408 -164
  138. package/src/primitives/button/button.html +14 -7
  139. package/src/primitives/button-group/button-group-vertical.html +5 -5
  140. package/src/primitives/button-group/button-group.css +53 -25
  141. package/src/primitives/button-group/button-group.html +18 -12
  142. package/src/primitives/callout/callout.css +114 -0
  143. package/src/primitives/callout/callout.html +188 -0
  144. package/src/primitives/card/card-subgrid.html +249 -34
  145. package/src/primitives/card/card.css +125 -0
  146. package/src/primitives/card/card.html +141 -20
  147. package/src/primitives/carousel/carousel.css +30 -20
  148. package/src/primitives/carousel/carousel.d.ts +7 -10
  149. package/src/primitives/carousel/carousel.d.ts.map +1 -1
  150. package/src/primitives/carousel/carousel.html +420 -84
  151. package/src/primitives/carousel/carousel.js +1 -1
  152. package/src/primitives/carousel/carousel.ts +8 -11
  153. package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
  154. package/src/primitives/checkbox/checkbox.css +98 -40
  155. package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
  156. package/src/primitives/checkbox/checkbox.html +13 -8
  157. package/src/primitives/checkbox/checkbox.js +7 -9
  158. package/src/primitives/checkbox/checkbox.ts +7 -15
  159. package/src/primitives/combobox/combobox-multiselect.html +53 -33
  160. package/src/primitives/combobox/combobox.css +145 -122
  161. package/src/primitives/combobox/combobox.d.ts +12 -11
  162. package/src/primitives/combobox/combobox.d.ts.map +1 -1
  163. package/src/primitives/combobox/combobox.html +48 -28
  164. package/src/primitives/combobox/combobox.js +46 -51
  165. package/src/primitives/combobox/combobox.ts +48 -55
  166. package/src/primitives/command/command-actions.d.ts +2 -3
  167. package/src/primitives/command/command-actions.d.ts.map +1 -1
  168. package/src/primitives/command/command-actions.html +48 -33
  169. package/src/primitives/command/command-actions.js +12 -10
  170. package/src/primitives/command/command-actions.ts +12 -13
  171. package/src/primitives/command/command-dialog.html +49 -25
  172. package/src/primitives/command/command.css +52 -42
  173. package/src/primitives/command/command.d.ts +10 -7
  174. package/src/primitives/command/command.d.ts.map +1 -1
  175. package/src/primitives/command/command.html +95 -46
  176. package/src/primitives/command/command.js +30 -13
  177. package/src/primitives/command/command.ts +30 -12
  178. package/src/primitives/debug/audit-core.d.ts +64 -0
  179. package/src/primitives/debug/audit-core.d.ts.map +1 -0
  180. package/src/primitives/debug/audit-core.js +356 -0
  181. package/src/primitives/debug/audit-core.ts +535 -0
  182. package/src/primitives/debug/debug.d.ts +50 -0
  183. package/src/primitives/debug/debug.d.ts.map +1 -0
  184. package/src/primitives/debug/debug.js +168 -0
  185. package/src/primitives/debug/debug.ts +211 -0
  186. package/src/primitives/dialog/dialog-with-form.html +67 -45
  187. package/src/primitives/dialog/dialog.css +87 -61
  188. package/src/primitives/dialog/dialog.html +25 -17
  189. package/src/primitives/fields/fields.css +108 -134
  190. package/src/primitives/fields/fields.html +39 -0
  191. package/src/primitives/input/input-icon-leading.html +3 -3
  192. package/src/primitives/input/input-icon-trailing.html +3 -3
  193. package/src/primitives/input/input.css +87 -49
  194. package/src/primitives/input/input.html +15 -15
  195. package/src/primitives/input-group/input-group-password-group.html +15 -15
  196. package/src/primitives/input-group/input-group.css +118 -75
  197. package/src/primitives/input-group/input-group.html +42 -30
  198. package/src/primitives/kbd/kbd-group.html +15 -2
  199. package/src/primitives/kbd/kbd.css +44 -31
  200. package/src/primitives/kbd/kbd.html +7 -1
  201. package/src/primitives/layout/layout.css +159 -0
  202. package/src/primitives/layout/layout.html +35 -0
  203. package/src/primitives/lightbox/lightbox.css +178 -105
  204. package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
  205. package/src/primitives/lightbox/lightbox.html +138 -166
  206. package/src/primitives/lightbox/lightbox.js +10 -13
  207. package/src/primitives/lightbox/lightbox.ts +12 -13
  208. package/src/primitives/menu/menu-interest.html +60 -18
  209. package/src/primitives/menu/menu.css +22 -17
  210. package/src/primitives/menu/menu.d.ts +5 -5
  211. package/src/primitives/menu/menu.html +195 -40
  212. package/src/primitives/menu/menu.js +8 -8
  213. package/src/primitives/menu/menu.ts +8 -8
  214. package/src/primitives/menubar/menubar-help-search.html +78 -32
  215. package/src/primitives/menubar/menubar.html +166 -38
  216. package/src/primitives/meter/meter.css +41 -38
  217. package/src/primitives/meter/meter.html +44 -9
  218. package/src/primitives/mobile-menu/mobile-menu.css +47 -40
  219. package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
  220. package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
  221. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
  222. package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
  223. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
  224. package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
  225. package/src/primitives/navigation-menu/navigation-menu.css +104 -106
  226. package/src/primitives/navigation-menu/navigation-menu.html +554 -158
  227. package/src/primitives/otp/otp.css +43 -44
  228. package/src/primitives/otp/otp.d.ts +4 -5
  229. package/src/primitives/otp/otp.d.ts.map +1 -1
  230. package/src/primitives/otp/otp.html +7 -6
  231. package/src/primitives/otp/otp.js +13 -18
  232. package/src/primitives/otp/otp.ts +12 -19
  233. package/src/primitives/password-group/password-group.css +132 -107
  234. package/src/primitives/password-group/password-group.d.ts.map +1 -1
  235. package/src/primitives/password-group/password-group.html +23 -16
  236. package/src/primitives/password-group/password-group.js +11 -12
  237. package/src/primitives/password-group/password-group.ts +11 -12
  238. package/src/primitives/popover/popover.css +88 -95
  239. package/src/primitives/popover/popover.html +18 -0
  240. package/src/primitives/progress/progress-indeterminate.html +1 -1
  241. package/src/primitives/progress/progress.css +34 -35
  242. package/src/primitives/progress/progress.html +18 -4
  243. package/src/primitives/prose/prose.html +19 -12
  244. package/src/primitives/radio/radio.css +83 -46
  245. package/src/primitives/radio/radio.html +16 -11
  246. package/src/primitives/reveal/reveal.css +37 -46
  247. package/src/primitives/reveal/reveal.html +15 -0
  248. package/src/primitives/scroll-fade/scroll-fade.css +115 -0
  249. package/src/primitives/scroll-fade/scroll-fade.html +69 -0
  250. package/src/primitives/select/multiselect.d.ts +8 -10
  251. package/src/primitives/select/multiselect.d.ts.map +1 -1
  252. package/src/primitives/select/multiselect.js +23 -27
  253. package/src/primitives/select/multiselect.ts +23 -29
  254. package/src/primitives/select/select-align.html +79 -16
  255. package/src/primitives/select/select-multiple.html +8 -4
  256. package/src/primitives/select/select-sides.html +104 -21
  257. package/src/primitives/select/select.css +297 -186
  258. package/src/primitives/select/select.html +24 -5
  259. package/src/primitives/separator/separator.css +15 -18
  260. package/src/primitives/separator/separator.html +37 -10
  261. package/src/primitives/slider/slider.css +48 -38
  262. package/src/primitives/slider/slider.html +9 -1
  263. package/src/primitives/style-guard/style-guard.d.ts +19 -0
  264. package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
  265. package/src/primitives/style-guard/style-guard.js +125 -0
  266. package/src/primitives/style-guard/style-guard.ts +153 -0
  267. package/src/primitives/switch/switch.css +42 -33
  268. package/src/primitives/switch/switch.html +11 -6
  269. package/src/primitives/table/table-alternating.html +1 -1
  270. package/src/primitives/table/table-grid.html +5 -5
  271. package/src/primitives/table/table-size-sm.html +1 -1
  272. package/src/primitives/table/table.css +64 -61
  273. package/src/primitives/table/table.html +7 -7
  274. package/src/primitives/tabs/tabs.css +167 -166
  275. package/src/primitives/tabs/tabs.d.ts +10 -11
  276. package/src/primitives/tabs/tabs.d.ts.map +1 -1
  277. package/src/primitives/tabs/tabs.html +192 -36
  278. package/src/primitives/tabs/tabs.js +14 -15
  279. package/src/primitives/tabs/tabs.ts +14 -15
  280. package/src/primitives/textarea/textarea.css +69 -44
  281. package/src/primitives/textarea/textarea.html +3 -3
  282. package/src/primitives/toaster/toaster.css +90 -92
  283. package/src/primitives/toaster/toaster.d.ts +0 -6
  284. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  285. package/src/primitives/toaster/toaster.html +22 -18
  286. package/src/primitives/toaster/toaster.js +64 -72
  287. package/src/primitives/toaster/toaster.ts +71 -87
  288. package/src/primitives/toggle/toggle.css +368 -153
  289. package/src/primitives/toggle/toggle.html +27 -9
  290. package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
  291. package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
  292. package/src/primitives/toggle-group/toggle-group.css +71 -23
  293. package/src/primitives/toggle-group/toggle-group.html +3 -3
  294. package/src/primitives/toolbar/toolbar.html +35 -13
  295. package/src/primitives/tooltip/tooltip-disabled.html +3 -3
  296. package/src/primitives/tooltip/tooltip-sides.html +36 -14
  297. package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
  298. package/src/primitives/tooltip/tooltip.css +111 -80
  299. package/src/primitives/tooltip/tooltip.html +3 -3
  300. package/src/primitives/utilities/aspect-ratio.html +51 -7
  301. package/src/primitives/utilities/basis.html +64 -11
  302. package/src/primitives/utilities/col-span.html +65 -9
  303. package/src/primitives/utilities/compose.html +48 -10
  304. package/src/primitives/utilities/flex-align.html +89 -19
  305. package/src/primitives/utilities/flex-direction.html +111 -13
  306. package/src/primitives/utilities/flex-grow.html +41 -7
  307. package/src/primitives/utilities/gap.html +158 -19
  308. package/src/primitives/utilities/grid-cols.html +75 -7
  309. package/src/primitives/utilities/grid-responsive.html +111 -12
  310. package/src/primitives/utilities/margin-auto.html +38 -7
  311. package/src/primitives/utilities/object-fit.html +75 -13
  312. package/src/primitives/utilities/order.html +40 -4
  313. package/src/primitives/utilities/overflow.html +74 -20
  314. package/src/primitives/utilities/padding-compose.html +67 -10
  315. package/src/primitives/utilities/padding.html +84 -13
  316. package/src/primitives/utilities/pile.html +29 -0
  317. package/src/primitives/utilities/position.html +65 -8
  318. package/src/primitives/utilities/responsive-flex.html +54 -7
  319. package/src/primitives/utilities/responsive-grid.html +115 -12
  320. package/src/primitives/utilities/size.html +120 -16
  321. package/src/primitives/utilities/width.html +123 -16
  322. package/examples/about.html +0 -583
  323. package/examples/components.html +0 -1028
  324. package/examples/forms.html +0 -504
  325. package/examples/index.html +0 -261
  326. package/examples/layout.html +0 -313
  327. package/examples/products.html +0 -839
  328. package/examples/responsive.html +0 -332
  329. package/src/base/_layout.css +0 -571
  330. package/src/base/_utilities.css +0 -6758
  331. package/src/primitives/utilities/grid-pile.html +0 -5
@@ -1,8 +1,8 @@
1
1
  /**
2
- * otp.css: OTP (ui-otp wrapping .ui-otp-input on one real <input>)
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 layers.css, _variables.css, fields.css, input.css
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-slot-inline-size: var(--ui-field-block-size);
17
- --ui-otp-slot-block-size: var(--ui-field-block-size);
18
- --ui-otp-slot-background: var(--ui-field-background);
19
- --ui-otp-slot-border-width: var(--ui-field-border-width);
20
- --ui-otp-slot-border-style: var(--ui-field-border-style);
21
- --ui-otp-slot-border-color: var(--ui-field-border-color);
22
- --ui-otp-slot-radius: var(--ui-field-radius);
23
- --ui-otp-slot-font-size: var(--font-size-md);
24
- --ui-otp-gap: var(--step-1_5);
25
- --ui-otp-separator-color: var(--muted-foreground);
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 zazz.components {
30
+ @layer ui.components {
31
31
  /* ===========================================================================
32
32
  OTP: one real input, presentational cells
33
- - Before enhancement (.ui-otp-input alone): a centered code field.
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
- /* No-JS baseline: a plain code field in the field family */
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-slot-font-size);
47
+ font-size: var(--ui-otp-cell-font-size);
49
48
  }
50
49
 
51
- /* Enhanced: the input stretches invisibly over the rail. Opacity stays just
52
- above zero and the element keeps its size so taps, focus, and browser
53
- autofill UI keep landing on a real, visible-to-the-UA control. */
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
- /* Guards iOS focus zoom */
65
+ /* prevents iOS focus zoom */
68
66
  font-size: max(16px, 1em);
69
67
  }
70
68
 
71
- [data-slot~="otp-rail"] {
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-slot~="otp-slot"] {
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-slot-inline-size);
81
- block-size: var(--ui-otp-slot-block-size);
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-slot-font-size);
85
- color: var(--ui-field-foreground);
82
+ font-size: var(--ui-otp-cell-font-size);
83
+ color: var(--ui-field-text);
86
84
 
87
- background-color: var(--ui-otp-slot-background);
88
- border: var(--ui-otp-slot-border-width) var(--ui-otp-slot-border-style)
89
- var(--ui-otp-slot-border-color);
90
- border-radius: var(--ui-otp-slot-radius);
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
- /* Active cell: ring + focus border, only while the input has focus */
96
- :where(ui-otp:focus-within) [data-slot~="otp-slot"][data-active] {
97
- border-color: var(--ui-field-border-color--focus);
98
- background-color: var(--ui-field-background--focus);
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
- /* Fake caret in the active empty cell */
106
- :where(ui-otp:focus-within) [data-slot~="otp-slot"][data-active]:empty::after {
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) [data-slot~="otp-slot"][data-active]:empty::after {
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-slot~="otp-separator"] {
126
- color: var(--ui-otp-separator-color);
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 class="ui-input ui-otp-input">` (the standard OTP shape with
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`. There is no
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-slot~="otp-slot"]` with `data-filled` /
27
- * `data-active`; separators are `[data-slot~="otp-separator"]`; the root
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAK5E,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;AAID;;;;;;;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;AAID,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
+ {"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 class="ui-field" style="max-inline-size: max-content">
2
- <label data-slot="field-label" for="f-otp">Verification code</label>
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
- class="ui-input ui-otp-input"
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="field-description">
19
- <span data-slot="field-hint">Enter the 6-digit code we sent you.</span>
20
- <span data-slot="field-error">Enter all 6 digits.</span>
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 class="ui-input ui-otp-input">` (the standard OTP shape with
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`. There is no
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-slot~="otp-slot"]` with `data-filled` /
28
- * `data-active`; separators are `[data-slot~="otp-separator"]`; the root
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
- if (slot.filled)
164
- cell.setAttribute("data-filled", "");
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-filled");
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", "otp-rail");
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", "otp-separator");
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", "otp-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 class="ui-input ui-otp-input">` (the standard OTP shape with
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`. There is no
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-slot~="otp-slot"]` with `data-filled` /
29
- * `data-active`; separators are `[data-slot~="otp-separator"]`; the root
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
- if (slot.filled) cell.setAttribute("data-filled", "");
212
- else cell.removeAttribute("data-filled");
213
- if (slot.active) cell.setAttribute("data-active", "");
214
- else cell.removeAttribute("data-active");
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", "otp-rail");
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", "otp-separator");
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", "otp-slot");
257
+ cell.setAttribute("data-otp-slot", "cell");
265
258
  cell.setAttribute("data-otp-index", String(index++));
266
259
  rail.append(cell);
267
260
  }