@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.
Files changed (260) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +61 -0
  4. package/dist/sri.json +75 -0
  5. package/dist/zazz.css +1 -0
  6. package/dist/zazz.js +1 -0
  7. package/examples/about.html +590 -0
  8. package/examples/components.html +1040 -0
  9. package/examples/forms.html +511 -0
  10. package/examples/index.html +268 -0
  11. package/examples/layout.html +320 -0
  12. package/examples/products.html +846 -0
  13. package/examples/responsive.html +339 -0
  14. package/package.json +85 -0
  15. package/src/base/_layers.css +12 -0
  16. package/src/base/_layout.css +568 -0
  17. package/src/base/_reset.css +515 -0
  18. package/src/base/_typography.css +495 -0
  19. package/src/base/_utilities.css +6628 -0
  20. package/src/base/_variables.css +682 -0
  21. package/src/base/_view-transitions.css +103 -0
  22. package/src/base/command-score.d.ts +12 -0
  23. package/src/base/command-score.d.ts.map +1 -0
  24. package/src/base/command-score.js +151 -0
  25. package/src/base/command-score.ts +192 -0
  26. package/src/base/dialog-lifecycle.d.ts +11 -0
  27. package/src/base/dialog-lifecycle.d.ts.map +1 -0
  28. package/src/base/dialog-lifecycle.js +65 -0
  29. package/src/base/dialog-lifecycle.ts +80 -0
  30. package/src/base/embla.d.ts +90 -0
  31. package/src/base/embla.d.ts.map +1 -0
  32. package/src/base/embla.js +643 -0
  33. package/src/base/embla.ts +791 -0
  34. package/src/base/hotkeys.d.ts +82 -0
  35. package/src/base/hotkeys.d.ts.map +1 -0
  36. package/src/base/hotkeys.js +141 -0
  37. package/src/base/hotkeys.ts +195 -0
  38. package/src/base/navigation.d.ts +2 -0
  39. package/src/base/navigation.d.ts.map +1 -0
  40. package/src/base/navigation.js +136 -0
  41. package/src/base/navigation.ts +151 -0
  42. package/src/base/reveal.d.ts +80 -0
  43. package/src/base/reveal.d.ts.map +1 -0
  44. package/src/base/reveal.js +305 -0
  45. package/src/base/reveal.ts +379 -0
  46. package/src/base/signals.d.ts +89 -0
  47. package/src/base/signals.d.ts.map +1 -0
  48. package/src/base/signals.js +134 -0
  49. package/src/base/signals.ts +164 -0
  50. package/src/base/typeahead.d.ts +105 -0
  51. package/src/base/typeahead.d.ts.map +1 -0
  52. package/src/base/typeahead.js +411 -0
  53. package/src/base/typeahead.ts +500 -0
  54. package/src/base/utils.d.ts +56 -0
  55. package/src/base/utils.d.ts.map +1 -0
  56. package/src/base/utils.js +88 -0
  57. package/src/base/utils.ts +98 -0
  58. package/src/base/zazz-element.d.ts +44 -0
  59. package/src/base/zazz-element.d.ts.map +1 -0
  60. package/src/base/zazz-element.js +59 -0
  61. package/src/base/zazz-element.ts +73 -0
  62. package/src/globals.d.ts +148 -0
  63. package/src/head.d.ts +95 -0
  64. package/src/head.d.ts.map +1 -0
  65. package/src/head.js +311 -0
  66. package/src/head.ts +433 -0
  67. package/src/index.css +71 -0
  68. package/src/index.d.ts +36 -0
  69. package/src/index.d.ts.map +1 -0
  70. package/src/index.js +35 -0
  71. package/src/index.ts +36 -0
  72. package/src/manifest.d.ts +90 -0
  73. package/src/manifest.d.ts.map +1 -0
  74. package/src/manifest.js +614 -0
  75. package/src/manifest.ts +667 -0
  76. package/src/primitives/accordion/accordion.css +104 -0
  77. package/src/primitives/accordion/accordion.html +69 -0
  78. package/src/primitives/alert-dialog/alert-dialog.css +38 -0
  79. package/src/primitives/alert-dialog/alert-dialog.html +53 -0
  80. package/src/primitives/autocomplete/autocomplete-groups.html +77 -0
  81. package/src/primitives/autocomplete/autocomplete.css +114 -0
  82. package/src/primitives/autocomplete/autocomplete.d.ts +30 -0
  83. package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -0
  84. package/src/primitives/autocomplete/autocomplete.html +66 -0
  85. package/src/primitives/autocomplete/autocomplete.js +41 -0
  86. package/src/primitives/autocomplete/autocomplete.ts +46 -0
  87. package/src/primitives/avatar/avatar.html +44 -0
  88. package/src/primitives/badge/badge-icon.html +36 -0
  89. package/src/primitives/badge/badge.css +251 -0
  90. package/src/primitives/badge/badge.html +7 -0
  91. package/src/primitives/breadcrumbs/breadcrumbs.html +9 -0
  92. package/src/primitives/button/button-icon-only.html +84 -0
  93. package/src/primitives/button/button-icon.html +82 -0
  94. package/src/primitives/button/button.css +319 -0
  95. package/src/primitives/button/button.html +8 -0
  96. package/src/primitives/button-group/button-group-vertical.html +6 -0
  97. package/src/primitives/button-group/button-group.css +94 -0
  98. package/src/primitives/button-group/button-group.html +64 -0
  99. package/src/primitives/card/card-subgrid.html +118 -0
  100. package/src/primitives/card/card.html +53 -0
  101. package/src/primitives/carousel/carousel.css +61 -0
  102. package/src/primitives/carousel/carousel.d.ts +16 -0
  103. package/src/primitives/carousel/carousel.d.ts.map +1 -0
  104. package/src/primitives/carousel/carousel.html +315 -0
  105. package/src/primitives/carousel/carousel.js +73 -0
  106. package/src/primitives/carousel/carousel.ts +84 -0
  107. package/src/primitives/checkbox/checkbox-tasklist.html +71 -0
  108. package/src/primitives/checkbox/checkbox.css +82 -0
  109. package/src/primitives/checkbox/checkbox.d.ts +21 -0
  110. package/src/primitives/checkbox/checkbox.d.ts.map +1 -0
  111. package/src/primitives/checkbox/checkbox.html +17 -0
  112. package/src/primitives/checkbox/checkbox.js +190 -0
  113. package/src/primitives/checkbox/checkbox.ts +219 -0
  114. package/src/primitives/combobox/combobox-multiselect.html +91 -0
  115. package/src/primitives/combobox/combobox.css +307 -0
  116. package/src/primitives/combobox/combobox.d.ts +100 -0
  117. package/src/primitives/combobox/combobox.d.ts.map +1 -0
  118. package/src/primitives/combobox/combobox.html +73 -0
  119. package/src/primitives/combobox/combobox.js +503 -0
  120. package/src/primitives/combobox/combobox.ts +559 -0
  121. package/src/primitives/command/command-actions.d.ts +31 -0
  122. package/src/primitives/command/command-actions.d.ts.map +1 -0
  123. package/src/primitives/command/command-actions.html +89 -0
  124. package/src/primitives/command/command-actions.js +70 -0
  125. package/src/primitives/command/command-actions.ts +77 -0
  126. package/src/primitives/command/command-dialog.html +77 -0
  127. package/src/primitives/command/command.css +151 -0
  128. package/src/primitives/command/command.d.ts +52 -0
  129. package/src/primitives/command/command.d.ts.map +1 -0
  130. package/src/primitives/command/command.html +119 -0
  131. package/src/primitives/command/command.js +146 -0
  132. package/src/primitives/command/command.ts +157 -0
  133. package/src/primitives/dialog/dialog-with-form.html +200 -0
  134. package/src/primitives/dialog/dialog.css +229 -0
  135. package/src/primitives/dialog/dialog.html +90 -0
  136. package/src/primitives/fields/fields.css +278 -0
  137. package/src/primitives/input/input-icon-leading.html +19 -0
  138. package/src/primitives/input/input-icon-trailing.html +18 -0
  139. package/src/primitives/input/input.css +114 -0
  140. package/src/primitives/input/input.html +61 -0
  141. package/src/primitives/input-group/input-group-password-group.html +108 -0
  142. package/src/primitives/input-group/input-group.css +215 -0
  143. package/src/primitives/input-group/input-group.html +132 -0
  144. package/src/primitives/kbd/kbd-group.html +18 -0
  145. package/src/primitives/kbd/kbd.css +87 -0
  146. package/src/primitives/kbd/kbd.html +7 -0
  147. package/src/primitives/lightbox/lightbox.css +459 -0
  148. package/src/primitives/lightbox/lightbox.d.ts +7 -0
  149. package/src/primitives/lightbox/lightbox.d.ts.map +1 -0
  150. package/src/primitives/lightbox/lightbox.html +665 -0
  151. package/src/primitives/lightbox/lightbox.js +96 -0
  152. package/src/primitives/lightbox/lightbox.ts +113 -0
  153. package/src/primitives/menu/menu-interest.html +52 -0
  154. package/src/primitives/menu/menu.css +55 -0
  155. package/src/primitives/menu/menu.d.ts +38 -0
  156. package/src/primitives/menu/menu.d.ts.map +1 -0
  157. package/src/primitives/menu/menu.html +70 -0
  158. package/src/primitives/menu/menu.js +117 -0
  159. package/src/primitives/menu/menu.ts +131 -0
  160. package/src/primitives/menubar/menubar-help-search.html +103 -0
  161. package/src/primitives/menubar/menubar.html +166 -0
  162. package/src/primitives/meter/meter.css +178 -0
  163. package/src/primitives/meter/meter.html +38 -0
  164. package/src/primitives/mobile-menu/mobile-menu.css +145 -0
  165. package/src/primitives/mobile-menu/mobile-menu.html +614 -0
  166. package/src/primitives/navigation-menu/navigation-menu-featured.html +76 -0
  167. package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +158 -0
  168. package/src/primitives/navigation-menu/navigation-menu-interest.html +103 -0
  169. package/src/primitives/navigation-menu/navigation-menu-megamenu.html +141 -0
  170. package/src/primitives/navigation-menu/navigation-menu-simple.html +96 -0
  171. package/src/primitives/navigation-menu/navigation-menu.css +295 -0
  172. package/src/primitives/navigation-menu/navigation-menu.html +576 -0
  173. package/src/primitives/otp/otp.css +126 -0
  174. package/src/primitives/otp/otp.d.ts +89 -0
  175. package/src/primitives/otp/otp.d.ts.map +1 -0
  176. package/src/primitives/otp/otp.html +22 -0
  177. package/src/primitives/otp/otp.js +226 -0
  178. package/src/primitives/otp/otp.ts +279 -0
  179. package/src/primitives/password-group/password-group.css +238 -0
  180. package/src/primitives/password-group/password-group.d.ts +25 -0
  181. package/src/primitives/password-group/password-group.d.ts.map +1 -0
  182. package/src/primitives/password-group/password-group.html +109 -0
  183. package/src/primitives/password-group/password-group.js +76 -0
  184. package/src/primitives/password-group/password-group.ts +95 -0
  185. package/src/primitives/popover/popover.css +233 -0
  186. package/src/primitives/progress/progress-indeterminate.html +1 -0
  187. package/src/primitives/progress/progress.css +105 -0
  188. package/src/primitives/progress/progress.html +7 -0
  189. package/src/primitives/prose/prose.html +65 -0
  190. package/src/primitives/radio/radio.css +84 -0
  191. package/src/primitives/radio/radio.html +17 -0
  192. package/src/primitives/reveal/reveal.css +167 -0
  193. package/src/primitives/select/multiselect.d.ts +43 -0
  194. package/src/primitives/select/multiselect.d.ts.map +1 -0
  195. package/src/primitives/select/multiselect.js +147 -0
  196. package/src/primitives/select/multiselect.ts +188 -0
  197. package/src/primitives/select/select-align.html +49 -0
  198. package/src/primitives/select/select-multiple.html +12 -0
  199. package/src/primitives/select/select-sides.html +65 -0
  200. package/src/primitives/select/select.css +481 -0
  201. package/src/primitives/select/select.html +16 -0
  202. package/src/primitives/separator/separator.css +49 -0
  203. package/src/primitives/separator/separator.html +16 -0
  204. package/src/primitives/slider/slider.css +122 -0
  205. package/src/primitives/slider/slider.html +1 -0
  206. package/src/primitives/switch/switch.css +126 -0
  207. package/src/primitives/switch/switch.html +13 -0
  208. package/src/primitives/table/table-alternating.html +36 -0
  209. package/src/primitives/table/table-grid.html +30 -0
  210. package/src/primitives/table/table-size-sm.html +26 -0
  211. package/src/primitives/table/table.css +158 -0
  212. package/src/primitives/table/table.html +45 -0
  213. package/src/primitives/tabs/tabs.css +328 -0
  214. package/src/primitives/tabs/tabs.d.ts +35 -0
  215. package/src/primitives/tabs/tabs.d.ts.map +1 -0
  216. package/src/primitives/tabs/tabs.html +75 -0
  217. package/src/primitives/tabs/tabs.js +84 -0
  218. package/src/primitives/tabs/tabs.ts +93 -0
  219. package/src/primitives/textarea/textarea.css +78 -0
  220. package/src/primitives/textarea/textarea.html +10 -0
  221. package/src/primitives/toaster/toaster.css +309 -0
  222. package/src/primitives/toaster/toaster.d.ts +138 -0
  223. package/src/primitives/toaster/toaster.d.ts.map +1 -0
  224. package/src/primitives/toaster/toaster.html +77 -0
  225. package/src/primitives/toaster/toaster.js +736 -0
  226. package/src/primitives/toaster/toaster.ts +823 -0
  227. package/src/primitives/toggle/toggle.css +295 -0
  228. package/src/primitives/toggle/toggle.html +68 -0
  229. package/src/primitives/toggle-group/toggle-group-multiple.html +14 -0
  230. package/src/primitives/toggle-group/toggle-group-vertical.html +14 -0
  231. package/src/primitives/toggle-group/toggle-group.css +73 -0
  232. package/src/primitives/toggle-group/toggle-group.html +53 -0
  233. package/src/primitives/toolbar/toolbar.html +45 -0
  234. package/src/primitives/tooltip/tooltip-disabled.html +19 -0
  235. package/src/primitives/tooltip/tooltip-sides.html +57 -0
  236. package/src/primitives/tooltip/tooltip-with-kbd.html +31 -0
  237. package/src/primitives/tooltip/tooltip.css +235 -0
  238. package/src/primitives/tooltip/tooltip.html +12 -0
  239. package/src/primitives/utilities/aspect-ratio.html +17 -0
  240. package/src/primitives/utilities/basis.html +27 -0
  241. package/src/primitives/utilities/col-span.html +23 -0
  242. package/src/primitives/utilities/compose.html +19 -0
  243. package/src/primitives/utilities/flex-align.html +26 -0
  244. package/src/primitives/utilities/flex-direction.html +36 -0
  245. package/src/primitives/utilities/flex-grow.html +17 -0
  246. package/src/primitives/utilities/gap.html +62 -0
  247. package/src/primitives/utilities/grid-cols.html +20 -0
  248. package/src/primitives/utilities/grid-pile.html +5 -0
  249. package/src/primitives/utilities/grid-responsive.html +31 -0
  250. package/src/primitives/utilities/margin-auto.html +13 -0
  251. package/src/primitives/utilities/object-fit.html +41 -0
  252. package/src/primitives/utilities/order.html +17 -0
  253. package/src/primitives/utilities/overflow.html +26 -0
  254. package/src/primitives/utilities/padding-compose.html +23 -0
  255. package/src/primitives/utilities/padding.html +30 -0
  256. package/src/primitives/utilities/position.html +13 -0
  257. package/src/primitives/utilities/responsive-flex.html +22 -0
  258. package/src/primitives/utilities/responsive-grid.html +31 -0
  259. package/src/primitives/utilities/size.html +22 -0
  260. package/src/primitives/utilities/width.html +22 -0
@@ -0,0 +1,17 @@
1
+ <fieldset class="ui-radio-group">
2
+ <legend>Options</legend>
3
+ <div class="flex flex-col gap-xs">
4
+ <label class="ui-field" data-orientation="horizontal">
5
+ <input class="ui-radio" type="radio" name="radio-options-example" value="option-1" />
6
+ <span data-slot="field-label">Option 1</span>
7
+ </label>
8
+ <label class="ui-field" data-orientation="horizontal">
9
+ <input class="ui-radio" type="radio" name="radio-options-example" value="option-2" checked />
10
+ <span data-slot="field-label">Option 2</span>
11
+ </label>
12
+ <label class="ui-field" data-orientation="horizontal">
13
+ <input class="ui-radio" type="radio" name="radio-options-example" value="option-3" />
14
+ <span data-slot="field-label">Option 3</span>
15
+ </label>
16
+ </div>
17
+ </fieldset>
@@ -0,0 +1,167 @@
1
+ /**
2
+ * reveal.css — Scroll reveals ([data-reveal])
3
+ *
4
+ * @layer variables, utilities
5
+ * @requires layers.css, _variables.css
6
+ * @uses prefers-reduced-motion — native media feature
7
+ * @uses sibling-index(), sibling-count() — native stagger delays (@supports
8
+ * gated — no Firefox yet; where unsupported, reveal.js writes a
9
+ * per-child --ui-reveal-wait instead)
10
+ * @uses Behaviour requires zazz/scripts/reveal.js (IntersectionObserver)
11
+ * @tokens --ui-reveal-global-* (@layer variables);
12
+ * per-instance --ui-reveal-* set from data-* attributes by reveal.js;
13
+ * --ui-reveal-stagger-base / --ui-reveal-stagger-step written on stagger
14
+ * groups by reveal.js for the native sibling-index() path
15
+ * @version 0.1.0
16
+ * @since 0.1.0
17
+ *
18
+ * A lightweight, configurable animation system for scroll-based reveals. Focuses
19
+ * on viewport entry animations for single elements and direct children of stagger
20
+ * groups. Available animations: slide-up, slide-down, slide-left, slide-right,
21
+ * fade, grow, shrink.
22
+ *
23
+ * @example Single element
24
+ * <div data-reveal="slide-up">Content</div>
25
+ *
26
+ * @example Staggered children — animation applied to each direct child
27
+ * <div data-reveal-each="fade" data-reveal-step="100">
28
+ * <div>Item 1</div>
29
+ * <p>Item 2</p>
30
+ * </div>
31
+ *
32
+ * Data attributes (on the element with data-reveal or data-reveal-each):
33
+ * data-reveal="animation-name" single elements
34
+ * data-reveal-each="animation-name" groups; applied to children
35
+ * data-reveal-duration="300" ms
36
+ * data-reveal-wait="0" ms, base delay
37
+ * data-reveal-step="80" ms, stagger delay for groups
38
+ * data-reveal-ease="ease-in-out"
39
+ * data-reveal-distance="2rem" translation distance
40
+ * data-reveal-order="reversed" stagger order for groups
41
+ * data-reveal-margin="0px" IntersectionObserver rootMargin
42
+ * data-reveal-threshold="0.2" IntersectionObserver threshold
43
+ * data-reveal-scale="0.5" optional initial scale (requires JS mod)
44
+ */
45
+
46
+ @layer variables {
47
+ :root {
48
+ --ui-reveal-global-duration: var(--default-transition-duration);
49
+ --ui-reveal-global-ease: var(--default-transition-timing-function);
50
+ --ui-reveal-global-wait: 0ms;
51
+ --ui-reveal-global-distance: 1rem;
52
+ --ui-reveal-global-grow: 0.97;
53
+ --ui-reveal-global-shrink: 1.03;
54
+ }
55
+ }
56
+
57
+ @layer zazz.utilities {
58
+ /* --- Animation Styles --- */
59
+ @media screen and (prefers-reduced-motion: no-preference) {
60
+ /* Effective values + hidden state. Kept at :where() (0,0,0) so the
61
+ .in-viewport final state overrides opacity with minimal specificity. */
62
+ :where(
63
+ [data-reveal]:not([data-gjs-type]),
64
+ [data-reveal-each]:not([data-gjs-type]) > *:not([data-gjs-type])
65
+ ) {
66
+ --ui-reveal-effective-duration: var(--ui-reveal-duration, var(--ui-reveal-global-duration));
67
+ --ui-reveal-effective-ease: var(--ui-reveal-ease, var(--ui-reveal-global-ease));
68
+ --ui-reveal-effective-wait: var(--ui-reveal-wait, var(--ui-reveal-global-wait));
69
+ --ui-reveal-effective-distance: var(--ui-reveal-distance, var(--ui-reveal-global-distance));
70
+ will-change: opacity, transform;
71
+ opacity: 0;
72
+ }
73
+
74
+ /* Transition config — deliberately NOT wrapped in :where(), so its (0,1,0)
75
+ beats bare transition utilities (e.g. .transition is :where(.transition)
76
+ = 0,0,0) that share this layer and would otherwise reset transition-delay,
77
+ wiping out the per-child stagger. The gjs exclusion uses :not(:where())
78
+ to add no specificity, so the fade override below still wins on order. */
79
+ [data-reveal]:not(:where([data-gjs-type])),
80
+ [data-reveal-each]:not(:where([data-gjs-type])) > *:not(:where([data-gjs-type])) {
81
+ transition-timing-function: var(--ui-reveal-effective-ease);
82
+ transition-duration: var(--ui-reveal-effective-duration);
83
+ transition-delay: var(--ui-reveal-effective-wait);
84
+ transition-property: opacity, transform;
85
+ }
86
+
87
+ /* --- Stagger timing (native) --- */
88
+ /* Each stagger child derives its own delay from its DOM position:
89
+ wait = base + step × (index − 1); reversed groups count from the end.
90
+ reveal.js writes --ui-reveal-stagger-base/-step on the group (from
91
+ data-reveal-wait / data-reveal-step, config defaults applied) and skips
92
+ the per-child --ui-reveal-wait it falls back to where sibling-index() is
93
+ unsupported (Firefox). The literal 80ms mirrors the JS default step. */
94
+ @supports (top: calc(sibling-index() * 1px)) {
95
+ [data-reveal-each] > * {
96
+ --ui-reveal-wait: calc(
97
+ var(--ui-reveal-stagger-base, var(--ui-reveal-global-wait)) +
98
+ var(--ui-reveal-stagger-step, 80ms) * (sibling-index() - 1)
99
+ );
100
+ }
101
+
102
+ [data-reveal-each][data-reveal-order="reversed"] > * {
103
+ --ui-reveal-wait: calc(
104
+ var(--ui-reveal-stagger-base, var(--ui-reveal-global-wait)) +
105
+ var(--ui-reveal-stagger-step, 80ms) * (sibling-count() - sibling-index())
106
+ );
107
+ }
108
+ }
109
+
110
+ /* Slide animations */
111
+ [data-reveal="slide-up"]:not(:where(.in-viewport, [data-gjs-type])),
112
+ [data-reveal-each="slide-up"] > *:not(:where(.in-viewport, [data-gjs-type])) {
113
+ transform: translateY(var(--ui-reveal-effective-distance));
114
+ }
115
+
116
+ [data-reveal="slide-down"]:not(:where(.in-viewport, [data-gjs-type])),
117
+ [data-reveal-each="slide-down"] > *:not(:where(.in-viewport, [data-gjs-type])) {
118
+ transform: translateY(calc(-1 * var(--ui-reveal-effective-distance)));
119
+ }
120
+
121
+ [data-reveal="slide-left"]:not(:where(.in-viewport, [data-gjs-type])),
122
+ [data-reveal-each="slide-left"] > *:not(:where(.in-viewport, [data-gjs-type])) {
123
+ transform: translateX(var(--ui-reveal-effective-distance));
124
+ }
125
+
126
+ [data-reveal="slide-right"]:not(:where(.in-viewport, [data-gjs-type])),
127
+ [data-reveal-each="slide-right"] > *:not(:where(.in-viewport, [data-gjs-type])) {
128
+ transform: translateX(calc(-1 * var(--ui-reveal-effective-distance)));
129
+ }
130
+
131
+ /* Fade animation */
132
+ [data-reveal="fade"]:not(:where(.in-viewport, [data-gjs-type])),
133
+ [data-reveal-each="fade"] > *:not(:where(.in-viewport, [data-gjs-type])) {
134
+ transition-property: opacity;
135
+ transform: none;
136
+ }
137
+
138
+ /* Scale animations */
139
+ [data-reveal="grow"]:not(:where(.in-viewport, [data-gjs-type])),
140
+ [data-reveal-each="grow"] > *:not(:where(.in-viewport, [data-gjs-type])) {
141
+ transform: scale(var(--ui-reveal-scale, var(--ui-reveal-global-grow)));
142
+ }
143
+
144
+ [data-reveal="shrink"]:not(:where(.in-viewport, [data-gjs-type])),
145
+ [data-reveal-each="shrink"] > *:not(:where(.in-viewport, [data-gjs-type])) {
146
+ transform: scale(var(--ui-reveal-scale, var(--ui-reveal-global-shrink)));
147
+ }
148
+
149
+ /* Final state */
150
+ [data-reveal]:where(.in-viewport, [data-gjs-type]),
151
+ [data-reveal-each] > *:where(.in-viewport, [data-gjs-type]) {
152
+ opacity: 1;
153
+ transform: none;
154
+ }
155
+ }
156
+
157
+ /* --- Accessibility: Reduced Motion --- */
158
+ @media (prefers-reduced-motion: reduce) {
159
+ /* Immediately show elements without transition */
160
+ :where([data-reveal], [data-reveal-each] > *) {
161
+ transition: none !important;
162
+ transform: none !important;
163
+ opacity: 1 !important;
164
+ will-change: auto !important;
165
+ }
166
+ }
167
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview `<ui-multiselect>`: a multi-select styled as a dropdown.
3
+ * @description Light-DOM custom element that progressively enhances a real
4
+ * `<select multiple class="ui-select">`. `appearance: base-select` does not
5
+ * yet apply to multi-selects in any stable engine, so the script hides the
6
+ * select (which remains the form value carrier and source of truth) and
7
+ * stamps a `.ui-select`-look trigger button plus an anchored popover of
8
+ * checkbox rows projected from the options. Checkbox changes write back to
9
+ * `option.selected` and re-dispatch `change` on the select; external writes
10
+ * and form resets flow the other way. Without JavaScript the native
11
+ * multi-select listbox renders: fully functional and accessible.
12
+ *
13
+ * The trigger reads `<first selection> (+N more)`. When base-select grows
14
+ * stable multi-select support this enhancement can retire (see the CSS
15
+ * header note in select.css).
16
+ *
17
+ * Attributes on `<ui-multiselect>`:
18
+ * - `data-placeholder`: trigger text when nothing is selected.
19
+ * - `data-label-more`: overflow template, default `"(+{n} more)"`.
20
+ * - `data-side` / `data-align`: forwarded to the stamped panel (popover
21
+ * placement matrix).
22
+ *
23
+ * Stamped parts: `multiselect-trigger` (a `.ui-select`-classed button),
24
+ * `multiselect-icon` (chevron), `multiselect-panel` (`[popover]`),
25
+ * `multiselect-option` (label + checkbox per option).
26
+ */
27
+ import { ZazzElement } from "../../base/zazz-element.ts";
28
+ /**
29
+ * @description Formats the trigger label from the selected option labels.
30
+ *
31
+ * @param labels - Labels of the selected options, in DOM order.
32
+ * @param placeholder - Text for an empty selection.
33
+ * @param moreTemplate - Overflow template; `{n}` is the remaining count.
34
+ * @returns The trigger text.
35
+ */
36
+ declare function resolveTriggerLabel(labels: readonly string[], placeholder: string, moreTemplate: string): string;
37
+ declare class UiMultiselect extends ZazzElement {
38
+ #private;
39
+ protected setup(signal: AbortSignal): void;
40
+ protected teardown(): void;
41
+ }
42
+ export { UiMultiselect, resolveTriggerLabel };
43
+ //# sourceMappingURL=multiselect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiselect.d.ts","sourceRoot":"","sources":["multiselect.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAK5E;;;;;;;GAOG;AACH,iBAAS,mBAAmB,CAC1B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR;AAMD,cAAM,aAAc,SAAQ,WAAW;;IAIrC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CA0DzC;IAED,SAAS,CAAC,QAAQ,IAAI,IAAI,CAKzB;CA0DF;AAID,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview `<ui-multiselect>`: a multi-select styled as a dropdown.
4
+ * @description Light-DOM custom element that progressively enhances a real
5
+ * `<select multiple class="ui-select">`. `appearance: base-select` does not
6
+ * yet apply to multi-selects in any stable engine, so the script hides the
7
+ * select (which remains the form value carrier and source of truth) and
8
+ * stamps a `.ui-select`-look trigger button plus an anchored popover of
9
+ * checkbox rows projected from the options. Checkbox changes write back to
10
+ * `option.selected` and re-dispatch `change` on the select; external writes
11
+ * and form resets flow the other way. Without JavaScript the native
12
+ * multi-select listbox renders: fully functional and accessible.
13
+ *
14
+ * The trigger reads `<first selection> (+N more)`. When base-select grows
15
+ * stable multi-select support this enhancement can retire (see the CSS
16
+ * header note in select.css).
17
+ *
18
+ * Attributes on `<ui-multiselect>`:
19
+ * - `data-placeholder`: trigger text when nothing is selected.
20
+ * - `data-label-more`: overflow template, default `"(+{n} more)"`.
21
+ * - `data-side` / `data-align`: forwarded to the stamped panel (popover
22
+ * placement matrix).
23
+ *
24
+ * Stamped parts: `multiselect-trigger` (a `.ui-select`-classed button),
25
+ * `multiselect-icon` (chevron), `multiselect-panel` (`[popover]`),
26
+ * `multiselect-option` (label + checkbox per option).
27
+ */
28
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.js";
29
+ import { effect, state } from "../../base/signals.js";
30
+ // --- Pure derivations (exported for unit tests only) ---
31
+ /**
32
+ * @description Formats the trigger label from the selected option labels.
33
+ *
34
+ * @param labels - Labels of the selected options, in DOM order.
35
+ * @param placeholder - Text for an empty selection.
36
+ * @param moreTemplate - Overflow template; `{n}` is the remaining count.
37
+ * @returns The trigger text.
38
+ */
39
+ function resolveTriggerLabel(labels, placeholder, moreTemplate) {
40
+ if (labels.length === 0)
41
+ return placeholder;
42
+ if (labels.length === 1)
43
+ return labels[0];
44
+ return `${labels[0]} ${moreTemplate.replace("{n}", String(labels.length - 1))}`;
45
+ }
46
+ // --- Element ---
47
+ let multiselectIdCounter = 0;
48
+ class UiMultiselect extends ZazzElement {
49
+ #stamped = [];
50
+ #select = null;
51
+ setup(signal) {
52
+ const select = this.querySelector("select[multiple]");
53
+ if (!(select instanceof HTMLSelectElement))
54
+ return;
55
+ this.#select = select;
56
+ const placeholder = this.getAttribute("data-placeholder") ?? "Select…";
57
+ const moreTemplate = this.getAttribute("data-label-more") ?? "(+{n} more)";
58
+ const { trigger, label, panel, checkboxes } = this.#stamp(select);
59
+ select.setAttribute("data-multiselect-enhanced", "");
60
+ const selectedLabels = () => Array.from(select.selectedOptions).map((option) => option.label);
61
+ const selection = state(selectedLabels());
62
+ // Checkbox → option: the select stays the source of truth
63
+ checkboxes.forEach((checkbox, index) => {
64
+ checkbox.addEventListener("change", () => {
65
+ const option = select.options[index];
66
+ if (option)
67
+ option.selected = checkbox.checked;
68
+ selection.set(selectedLabels());
69
+ select.dispatchEvent(new Event("change", { bubbles: true }));
70
+ }, { signal });
71
+ });
72
+ // External writes and form resets → re-read (reset applies after the event)
73
+ select.addEventListener("change", () => selection.set(selectedLabels()), { signal });
74
+ select.form?.addEventListener("reset", () => queueMicrotask(() => selection.set(selectedLabels())), { signal });
75
+ // The popover polyfill doesn't reflect expanded state: mirror it ourselves
76
+ panel.addEventListener("toggle", (event) => {
77
+ trigger.setAttribute("aria-expanded", String(event.newState === "open"));
78
+ }, { signal });
79
+ // Output adapter: trigger label + row checked states together
80
+ effect(() => {
81
+ selection.get();
82
+ label.textContent = resolveTriggerLabel(selectedLabels(), placeholder, moreTemplate);
83
+ checkboxes.forEach((checkbox, index) => {
84
+ const option = select.options[index];
85
+ if (option && checkbox.checked !== option.selected)
86
+ checkbox.checked = option.selected;
87
+ });
88
+ }, { signal });
89
+ }
90
+ teardown() {
91
+ for (const node of this.#stamped)
92
+ node.remove();
93
+ this.#stamped = [];
94
+ this.#select?.removeAttribute("data-multiselect-enhanced");
95
+ this.#select = null;
96
+ }
97
+ /**
98
+ * @description Builds the trigger button and checkbox panel from the
99
+ * select's options and inserts them after it.
100
+ *
101
+ * @param select - The enhanced select.
102
+ * @returns The stamped parts and the checkbox list (option order).
103
+ * @private
104
+ */
105
+ #stamp(select) {
106
+ const panelId = `ui-multiselect-panel-${++multiselectIdCounter}`;
107
+ const trigger = document.createElement("button");
108
+ trigger.type = "button";
109
+ trigger.className = "ui-select";
110
+ trigger.setAttribute("data-slot", "multiselect-trigger");
111
+ trigger.setAttribute("popovertarget", panelId);
112
+ trigger.setAttribute("aria-expanded", "false");
113
+ const label = document.createElement("span");
114
+ label.setAttribute("data-slot", "multiselect-label");
115
+ const icon = document.createElement("span");
116
+ icon.setAttribute("data-slot", "multiselect-icon");
117
+ icon.setAttribute("aria-hidden", "true");
118
+ trigger.append(label, icon);
119
+ const panel = document.createElement("div");
120
+ panel.id = panelId;
121
+ panel.setAttribute("data-slot", "multiselect-panel");
122
+ panel.setAttribute("popover", "auto");
123
+ const side = this.getAttribute("data-side");
124
+ const align = this.getAttribute("data-align");
125
+ if (side)
126
+ panel.setAttribute("data-side", side);
127
+ if (align)
128
+ panel.setAttribute("data-align", align);
129
+ const checkboxes = [];
130
+ for (const option of Array.from(select.options)) {
131
+ const row = document.createElement("label");
132
+ row.setAttribute("data-slot", "multiselect-option");
133
+ const checkbox = document.createElement("input");
134
+ checkbox.type = "checkbox";
135
+ checkbox.checked = option.selected;
136
+ checkbox.disabled = option.disabled;
137
+ row.append(checkbox, document.createTextNode(option.label));
138
+ panel.append(row);
139
+ checkboxes.push(checkbox);
140
+ }
141
+ select.after(trigger, panel);
142
+ this.#stamped = [trigger, panel];
143
+ return { trigger, label, panel, checkboxes };
144
+ }
145
+ }
146
+ defineZazzElement("ui-multiselect", UiMultiselect);
147
+ export { UiMultiselect, resolveTriggerLabel };
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview `<ui-multiselect>`: a multi-select styled as a dropdown.
5
+ * @description Light-DOM custom element that progressively enhances a real
6
+ * `<select multiple class="ui-select">`. `appearance: base-select` does not
7
+ * yet apply to multi-selects in any stable engine, so the script hides the
8
+ * select (which remains the form value carrier and source of truth) and
9
+ * stamps a `.ui-select`-look trigger button plus an anchored popover of
10
+ * checkbox rows projected from the options. Checkbox changes write back to
11
+ * `option.selected` and re-dispatch `change` on the select; external writes
12
+ * and form resets flow the other way. Without JavaScript the native
13
+ * multi-select listbox renders: fully functional and accessible.
14
+ *
15
+ * The trigger reads `<first selection> (+N more)`. When base-select grows
16
+ * stable multi-select support this enhancement can retire (see the CSS
17
+ * header note in select.css).
18
+ *
19
+ * Attributes on `<ui-multiselect>`:
20
+ * - `data-placeholder`: trigger text when nothing is selected.
21
+ * - `data-label-more`: overflow template, default `"(+{n} more)"`.
22
+ * - `data-side` / `data-align`: forwarded to the stamped panel (popover
23
+ * placement matrix).
24
+ *
25
+ * Stamped parts: `multiselect-trigger` (a `.ui-select`-classed button),
26
+ * `multiselect-icon` (chevron), `multiselect-panel` (`[popover]`),
27
+ * `multiselect-option` (label + checkbox per option).
28
+ */
29
+
30
+ import { ZazzElement, defineZazzElement } from "../../base/zazz-element.ts";
31
+ import { effect, state } from "../../base/signals.ts";
32
+
33
+ // --- Pure derivations (exported for unit tests only) ---
34
+
35
+ /**
36
+ * @description Formats the trigger label from the selected option labels.
37
+ *
38
+ * @param labels - Labels of the selected options, in DOM order.
39
+ * @param placeholder - Text for an empty selection.
40
+ * @param moreTemplate - Overflow template; `{n}` is the remaining count.
41
+ * @returns The trigger text.
42
+ */
43
+ function resolveTriggerLabel(
44
+ labels: readonly string[],
45
+ placeholder: string,
46
+ moreTemplate: string,
47
+ ): string {
48
+ if (labels.length === 0) return placeholder;
49
+ if (labels.length === 1) return labels[0];
50
+ return `${labels[0]} ${moreTemplate.replace("{n}", String(labels.length - 1))}`;
51
+ }
52
+
53
+ // --- Element ---
54
+
55
+ let multiselectIdCounter = 0;
56
+
57
+ class UiMultiselect extends ZazzElement {
58
+ #stamped: HTMLElement[] = [];
59
+ #select: HTMLSelectElement | null = null;
60
+
61
+ protected setup(signal: AbortSignal): void {
62
+ const select = this.querySelector("select[multiple]");
63
+ if (!(select instanceof HTMLSelectElement)) return;
64
+ this.#select = select;
65
+
66
+ const placeholder = this.getAttribute("data-placeholder") ?? "Select…";
67
+ const moreTemplate = this.getAttribute("data-label-more") ?? "(+{n} more)";
68
+
69
+ const { trigger, label, panel, checkboxes } = this.#stamp(select);
70
+ select.setAttribute("data-multiselect-enhanced", "");
71
+
72
+ const selectedLabels = (): string[] =>
73
+ Array.from(select.selectedOptions).map((option) => option.label);
74
+ const selection = state(selectedLabels());
75
+
76
+ // Checkbox → option: the select stays the source of truth
77
+ checkboxes.forEach((checkbox, index) => {
78
+ checkbox.addEventListener(
79
+ "change",
80
+ () => {
81
+ const option = select.options[index];
82
+ if (option) option.selected = checkbox.checked;
83
+ selection.set(selectedLabels());
84
+ select.dispatchEvent(new Event("change", { bubbles: true }));
85
+ },
86
+ { signal },
87
+ );
88
+ });
89
+
90
+ // External writes and form resets → re-read (reset applies after the event)
91
+ select.addEventListener("change", () => selection.set(selectedLabels()), { signal });
92
+ select.form?.addEventListener(
93
+ "reset",
94
+ () => queueMicrotask(() => selection.set(selectedLabels())),
95
+ { signal },
96
+ );
97
+
98
+ // The popover polyfill doesn't reflect expanded state: mirror it ourselves
99
+ panel.addEventListener(
100
+ "toggle",
101
+ (event) => {
102
+ trigger.setAttribute("aria-expanded", String((event as ToggleEvent).newState === "open"));
103
+ },
104
+ { signal },
105
+ );
106
+
107
+ // Output adapter: trigger label + row checked states together
108
+ effect(
109
+ () => {
110
+ selection.get();
111
+ label.textContent = resolveTriggerLabel(selectedLabels(), placeholder, moreTemplate);
112
+ checkboxes.forEach((checkbox, index) => {
113
+ const option = select.options[index];
114
+ if (option && checkbox.checked !== option.selected) checkbox.checked = option.selected;
115
+ });
116
+ },
117
+ { signal },
118
+ );
119
+ }
120
+
121
+ protected teardown(): void {
122
+ for (const node of this.#stamped) node.remove();
123
+ this.#stamped = [];
124
+ this.#select?.removeAttribute("data-multiselect-enhanced");
125
+ this.#select = null;
126
+ }
127
+
128
+ /**
129
+ * @description Builds the trigger button and checkbox panel from the
130
+ * select's options and inserts them after it.
131
+ *
132
+ * @param select - The enhanced select.
133
+ * @returns The stamped parts and the checkbox list (option order).
134
+ * @private
135
+ */
136
+ #stamp(select: HTMLSelectElement): {
137
+ trigger: HTMLButtonElement;
138
+ label: HTMLElement;
139
+ panel: HTMLElement;
140
+ checkboxes: HTMLInputElement[];
141
+ } {
142
+ const panelId = `ui-multiselect-panel-${++multiselectIdCounter}`;
143
+
144
+ const trigger = document.createElement("button");
145
+ trigger.type = "button";
146
+ trigger.className = "ui-select";
147
+ trigger.setAttribute("data-slot", "multiselect-trigger");
148
+ trigger.setAttribute("popovertarget", panelId);
149
+ trigger.setAttribute("aria-expanded", "false");
150
+
151
+ const label = document.createElement("span");
152
+ label.setAttribute("data-slot", "multiselect-label");
153
+ const icon = document.createElement("span");
154
+ icon.setAttribute("data-slot", "multiselect-icon");
155
+ icon.setAttribute("aria-hidden", "true");
156
+ trigger.append(label, icon);
157
+
158
+ const panel = document.createElement("div");
159
+ panel.id = panelId;
160
+ panel.setAttribute("data-slot", "multiselect-panel");
161
+ panel.setAttribute("popover", "auto");
162
+ const side = this.getAttribute("data-side");
163
+ const align = this.getAttribute("data-align");
164
+ if (side) panel.setAttribute("data-side", side);
165
+ if (align) panel.setAttribute("data-align", align);
166
+
167
+ const checkboxes: HTMLInputElement[] = [];
168
+ for (const option of Array.from(select.options)) {
169
+ const row = document.createElement("label");
170
+ row.setAttribute("data-slot", "multiselect-option");
171
+ const checkbox = document.createElement("input");
172
+ checkbox.type = "checkbox";
173
+ checkbox.checked = option.selected;
174
+ checkbox.disabled = option.disabled;
175
+ row.append(checkbox, document.createTextNode(option.label));
176
+ panel.append(row);
177
+ checkboxes.push(checkbox);
178
+ }
179
+
180
+ select.after(trigger, panel);
181
+ this.#stamped = [trigger, panel];
182
+ return { trigger, label, panel, checkboxes };
183
+ }
184
+ }
185
+
186
+ defineZazzElement("ui-multiselect", UiMultiselect);
187
+
188
+ export { UiMultiselect, resolveTriggerLabel };
@@ -0,0 +1,49 @@
1
+ <div class="flex gap-sm items-start">
2
+ <div class="ui-field">
3
+ <label data-slot="field-label" for="f-align-start">Start</label>
4
+ <select class="ui-select" id="f-align-start" name="align-start" data-align="start">
5
+ <button>
6
+ <selectedcontent></selectedcontent>
7
+ </button>
8
+ <optgroup class="grid gap-px" label="Sort by">
9
+ <legend class="text-eyebrow text-muted-foreground p-xs">Sort by</legend>
10
+ <option value="recent" selected>Most recent</option>
11
+ <option value="popular">Most popular</option>
12
+ <option value="price-asc">Price: low to high</option>
13
+ <option value="price-desc">Price: high to low</option>
14
+ </optgroup>
15
+ </select>
16
+ </div>
17
+
18
+ <div class="ui-field">
19
+ <label data-slot="field-label" for="f-align-center">Center</label>
20
+ <select class="ui-select" id="f-align-center" name="align-center" data-align="center">
21
+ <button>
22
+ <selectedcontent></selectedcontent>
23
+ </button>
24
+ <optgroup class="grid gap-px" label="Sort by">
25
+ <legend class="text-eyebrow text-muted-foreground p-xs">Sort by</legend>
26
+ <option value="recent" selected>Most recent</option>
27
+ <option value="popular">Most popular</option>
28
+ <option value="price-asc">Price: low to high</option>
29
+ <option value="price-desc">Price: high to low</option>
30
+ </optgroup>
31
+ </select>
32
+ </div>
33
+
34
+ <div class="ui-field">
35
+ <label data-slot="field-label" for="f-align-end">End</label>
36
+ <select class="ui-select" id="f-align-end" name="align-end" data-align="end">
37
+ <button>
38
+ <selectedcontent></selectedcontent>
39
+ </button>
40
+ <optgroup class="grid gap-px" label="Sort by">
41
+ <legend class="text-eyebrow text-muted-foreground p-xs">Sort by</legend>
42
+ <option value="recent" selected>Most recent</option>
43
+ <option value="popular">Most popular</option>
44
+ <option value="price-asc">Price: low to high</option>
45
+ <option value="price-desc">Price: high to low</option>
46
+ </optgroup>
47
+ </select>
48
+ </div>
49
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="ui-field max-w-xl">
2
+ <label data-slot="field-label" for="f-tags">Tags</label>
3
+ <ui-multiselect data-placeholder="Select tags" data-side="bottom" data-align="start">
4
+ <select class="ui-select" id="f-tags" name="tags" multiple>
5
+ <option value="design" selected>Design</option>
6
+ <option value="engineering" selected>Engineering</option>
7
+ <option value="research">Research</option>
8
+ <option value="marketing">Marketing</option>
9
+ <option value="ops" disabled>Operations</option>
10
+ </select>
11
+ </ui-multiselect>
12
+ </div>