@sdxc/ui 0.0.0-pre.1

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 (399) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +812 -0
  3. package/dist/animations/index.d.ts +12 -0
  4. package/dist/animations/index.js +12 -0
  5. package/dist/animations/keyframes.d.ts +162 -0
  6. package/dist/animations/keyframes.js +297 -0
  7. package/dist/animations/scroll.d.ts +154 -0
  8. package/dist/animations/scroll.js +228 -0
  9. package/dist/animations/tokens.d.ts +47 -0
  10. package/dist/animations/tokens.js +47 -0
  11. package/dist/animations/transitions.d.ts +143 -0
  12. package/dist/animations/transitions.js +147 -0
  13. package/dist/behaviors/announcer.d.ts +90 -0
  14. package/dist/behaviors/announcer.js +93 -0
  15. package/dist/behaviors/calendar-model.d.ts +218 -0
  16. package/dist/behaviors/calendar-model.js +376 -0
  17. package/dist/behaviors/drag-session.d.ts +119 -0
  18. package/dist/behaviors/drag-session.js +110 -0
  19. package/dist/behaviors/filter-model.d.ts +117 -0
  20. package/dist/behaviors/filter-model.js +185 -0
  21. package/dist/behaviors/index.d.ts +16 -0
  22. package/dist/behaviors/index.js +16 -0
  23. package/dist/behaviors/resize-session.d.ts +115 -0
  24. package/dist/behaviors/resize-session.js +157 -0
  25. package/dist/behaviors/scroll-follow-model.d.ts +180 -0
  26. package/dist/behaviors/scroll-follow-model.js +197 -0
  27. package/dist/behaviors/selection-model.d.ts +129 -0
  28. package/dist/behaviors/selection-model.js +259 -0
  29. package/dist/behaviors/toaster.d.ts +144 -0
  30. package/dist/behaviors/toaster.js +228 -0
  31. package/dist/components/accordion.d.ts +93 -0
  32. package/dist/components/accordion.js +165 -0
  33. package/dist/components/alert-dialog.d.ts +110 -0
  34. package/dist/components/alert-dialog.js +169 -0
  35. package/dist/components/alert.d.ts +109 -0
  36. package/dist/components/alert.js +160 -0
  37. package/dist/components/aspect-ratio.d.ts +44 -0
  38. package/dist/components/aspect-ratio.js +35 -0
  39. package/dist/components/attachment.d.ts +146 -0
  40. package/dist/components/attachment.js +320 -0
  41. package/dist/components/avatar.d.ts +118 -0
  42. package/dist/components/avatar.js +89 -0
  43. package/dist/components/badge.d.ts +66 -0
  44. package/dist/components/badge.js +129 -0
  45. package/dist/components/breadcrumbs.d.ts +67 -0
  46. package/dist/components/breadcrumbs.js +121 -0
  47. package/dist/components/bubble.d.ts +91 -0
  48. package/dist/components/bubble.js +216 -0
  49. package/dist/components/button.d.ts +78 -0
  50. package/dist/components/button.js +207 -0
  51. package/dist/components/calendar.d.ts +166 -0
  52. package/dist/components/calendar.js +320 -0
  53. package/dist/components/card.d.ts +82 -0
  54. package/dist/components/card.js +126 -0
  55. package/dist/components/carousel.d.ts +96 -0
  56. package/dist/components/carousel.js +214 -0
  57. package/dist/components/chart.d.ts +485 -0
  58. package/dist/components/chart.js +563 -0
  59. package/dist/components/checkbox-group.d.ts +58 -0
  60. package/dist/components/checkbox-group.js +53 -0
  61. package/dist/components/checkbox.d.ts +61 -0
  62. package/dist/components/checkbox.js +81 -0
  63. package/dist/components/color-area.d.ts +83 -0
  64. package/dist/components/color-area.js +251 -0
  65. package/dist/components/color-field.d.ts +128 -0
  66. package/dist/components/color-field.js +73 -0
  67. package/dist/components/color-picker.d.ts +132 -0
  68. package/dist/components/color-picker.js +183 -0
  69. package/dist/components/color-slider.d.ts +103 -0
  70. package/dist/components/color-slider.js +198 -0
  71. package/dist/components/color-swatch-picker.d.ts +106 -0
  72. package/dist/components/color-swatch-picker.js +75 -0
  73. package/dist/components/color-swatch.d.ts +57 -0
  74. package/dist/components/color-swatch.js +82 -0
  75. package/dist/components/color-wheel.d.ts +58 -0
  76. package/dist/components/color-wheel.js +160 -0
  77. package/dist/components/combobox.d.ts +73 -0
  78. package/dist/components/combobox.js +108 -0
  79. package/dist/components/command.d.ts +80 -0
  80. package/dist/components/command.js +151 -0
  81. package/dist/components/confirm.d.ts +124 -0
  82. package/dist/components/confirm.js +56 -0
  83. package/dist/components/context-menu.d.ts +108 -0
  84. package/dist/components/context-menu.js +200 -0
  85. package/dist/components/date-field.d.ts +110 -0
  86. package/dist/components/date-field.js +49 -0
  87. package/dist/components/date-picker.d.ts +136 -0
  88. package/dist/components/date-picker.js +155 -0
  89. package/dist/components/date-range-picker.d.ts +152 -0
  90. package/dist/components/date-range-picker.js +106 -0
  91. package/dist/components/description.d.ts +36 -0
  92. package/dist/components/description.js +21 -0
  93. package/dist/components/dialog.d.ts +97 -0
  94. package/dist/components/dialog.js +203 -0
  95. package/dist/components/disclosure.d.ts +85 -0
  96. package/dist/components/disclosure.js +180 -0
  97. package/dist/components/drawer.d.ts +82 -0
  98. package/dist/components/drawer.js +162 -0
  99. package/dist/components/drop-indicator.d.ts +43 -0
  100. package/dist/components/drop-indicator.js +47 -0
  101. package/dist/components/drop-zone.d.ts +73 -0
  102. package/dist/components/drop-zone.js +54 -0
  103. package/dist/components/empty.d.ts +89 -0
  104. package/dist/components/empty.js +129 -0
  105. package/dist/components/field-error.d.ts +41 -0
  106. package/dist/components/field-error.js +36 -0
  107. package/dist/components/file-trigger.d.ts +84 -0
  108. package/dist/components/file-trigger.js +169 -0
  109. package/dist/components/form.d.ts +118 -0
  110. package/dist/components/form.js +113 -0
  111. package/dist/components/grid-list.d.ts +112 -0
  112. package/dist/components/grid-list.js +220 -0
  113. package/dist/components/group.d.ts +45 -0
  114. package/dist/components/group.js +44 -0
  115. package/dist/components/header.d.ts +33 -0
  116. package/dist/components/header.js +29 -0
  117. package/dist/components/heading-scope.d.ts +83 -0
  118. package/dist/components/heading-scope.js +82 -0
  119. package/dist/components/heading.d.ts +50 -0
  120. package/dist/components/heading.js +31 -0
  121. package/dist/components/hover-card.d.ts +77 -0
  122. package/dist/components/hover-card.js +151 -0
  123. package/dist/components/image-placeholder.d.ts +105 -0
  124. package/dist/components/image-placeholder.js +212 -0
  125. package/dist/components/index.d.ts +109 -0
  126. package/dist/components/index.js +109 -0
  127. package/dist/components/input.d.ts +53 -0
  128. package/dist/components/input.js +76 -0
  129. package/dist/components/item.d.ts +97 -0
  130. package/dist/components/item.js +185 -0
  131. package/dist/components/keyboard.d.ts +33 -0
  132. package/dist/components/keyboard.js +20 -0
  133. package/dist/components/label.d.ts +38 -0
  134. package/dist/components/label.js +24 -0
  135. package/dist/components/link-button.d.ts +59 -0
  136. package/dist/components/link-button.js +174 -0
  137. package/dist/components/link.d.ts +43 -0
  138. package/dist/components/link.js +85 -0
  139. package/dist/components/listbox.d.ts +119 -0
  140. package/dist/components/listbox.js +114 -0
  141. package/dist/components/logo.d.ts +117 -0
  142. package/dist/components/logo.js +89 -0
  143. package/dist/components/marker.d.ts +82 -0
  144. package/dist/components/marker.js +163 -0
  145. package/dist/components/menu.d.ts +90 -0
  146. package/dist/components/menu.js +146 -0
  147. package/dist/components/menubar.d.ts +54 -0
  148. package/dist/components/menubar.js +118 -0
  149. package/dist/components/message-scroller.d.ts +109 -0
  150. package/dist/components/message-scroller.js +180 -0
  151. package/dist/components/message.d.ts +104 -0
  152. package/dist/components/message.js +200 -0
  153. package/dist/components/meter.d.ts +60 -0
  154. package/dist/components/meter.js +110 -0
  155. package/dist/components/modal.d.ts +71 -0
  156. package/dist/components/modal.js +120 -0
  157. package/dist/components/nav-link.d.ts +53 -0
  158. package/dist/components/nav-link.js +83 -0
  159. package/dist/components/navigation-menu.d.ts +150 -0
  160. package/dist/components/navigation-menu.js +381 -0
  161. package/dist/components/number-field.d.ts +76 -0
  162. package/dist/components/number-field.js +190 -0
  163. package/dist/components/otp-field.d.ts +68 -0
  164. package/dist/components/otp-field.js +46 -0
  165. package/dist/components/overlay-arrow.d.ts +51 -0
  166. package/dist/components/overlay-arrow.js +77 -0
  167. package/dist/components/pagination.d.ts +67 -0
  168. package/dist/components/pagination.js +164 -0
  169. package/dist/components/popover.d.ts +69 -0
  170. package/dist/components/popover.js +68 -0
  171. package/dist/components/progress-bar.d.ts +53 -0
  172. package/dist/components/progress-bar.js +90 -0
  173. package/dist/components/radio-group.d.ts +102 -0
  174. package/dist/components/radio-group.js +114 -0
  175. package/dist/components/range-calendar.d.ts +169 -0
  176. package/dist/components/range-calendar.js +216 -0
  177. package/dist/components/resizable.d.ts +98 -0
  178. package/dist/components/resizable.js +151 -0
  179. package/dist/components/scroll-area.d.ts +54 -0
  180. package/dist/components/scroll-area.js +89 -0
  181. package/dist/components/search-field.d.ts +55 -0
  182. package/dist/components/search-field.js +49 -0
  183. package/dist/components/section.d.ts +37 -0
  184. package/dist/components/section.js +22 -0
  185. package/dist/components/select.d.ts +96 -0
  186. package/dist/components/select.js +285 -0
  187. package/dist/components/selection-indicator.d.ts +47 -0
  188. package/dist/components/selection-indicator.js +50 -0
  189. package/dist/components/sentinel-row.d.ts +22 -0
  190. package/dist/components/sentinel-row.js +29 -0
  191. package/dist/components/separator.d.ts +35 -0
  192. package/dist/components/separator.js +48 -0
  193. package/dist/components/shared-element.d.ts +45 -0
  194. package/dist/components/shared-element.js +48 -0
  195. package/dist/components/sheet.d.ts +78 -0
  196. package/dist/components/sheet.js +167 -0
  197. package/dist/components/sidebar.d.ts +288 -0
  198. package/dist/components/sidebar.js +1068 -0
  199. package/dist/components/skeleton.d.ts +36 -0
  200. package/dist/components/skeleton.js +38 -0
  201. package/dist/components/slider.d.ts +102 -0
  202. package/dist/components/slider.js +179 -0
  203. package/dist/components/spinner.d.ts +55 -0
  204. package/dist/components/spinner.js +51 -0
  205. package/dist/components/switch.d.ts +47 -0
  206. package/dist/components/switch.js +82 -0
  207. package/dist/components/table.d.ts +139 -0
  208. package/dist/components/table.js +216 -0
  209. package/dist/components/tabs.d.ts +124 -0
  210. package/dist/components/tabs.js +246 -0
  211. package/dist/components/tag-group.d.ts +83 -0
  212. package/dist/components/tag-group.js +157 -0
  213. package/dist/components/text-field.d.ts +119 -0
  214. package/dist/components/text-field.js +51 -0
  215. package/dist/components/text.d.ts +34 -0
  216. package/dist/components/text.js +19 -0
  217. package/dist/components/textarea.d.ts +52 -0
  218. package/dist/components/textarea.js +82 -0
  219. package/dist/components/time-field.d.ts +110 -0
  220. package/dist/components/time-field.js +48 -0
  221. package/dist/components/toast.d.ts +149 -0
  222. package/dist/components/toast.js +365 -0
  223. package/dist/components/toggle-button.d.ts +115 -0
  224. package/dist/components/toggle-button.js +237 -0
  225. package/dist/components/toolbar.d.ts +47 -0
  226. package/dist/components/toolbar.js +54 -0
  227. package/dist/components/tooltip.d.ts +52 -0
  228. package/dist/components/tooltip.js +92 -0
  229. package/dist/components/tree.d.ts +123 -0
  230. package/dist/components/tree.js +239 -0
  231. package/dist/components/typeset.d.ts +53 -0
  232. package/dist/components/typeset.js +271 -0
  233. package/dist/index.d.ts +8 -0
  234. package/dist/index.js +8 -0
  235. package/dist/mixins/aria-checked.d.ts +42 -0
  236. package/dist/mixins/aria-checked.js +127 -0
  237. package/dist/mixins/attachment-trigger.d.ts +64 -0
  238. package/dist/mixins/attachment-trigger.js +190 -0
  239. package/dist/mixins/calendar-keys.d.ts +27 -0
  240. package/dist/mixins/calendar-keys.js +113 -0
  241. package/dist/mixins/carousel-controls.d.ts +30 -0
  242. package/dist/mixins/carousel-controls.js +222 -0
  243. package/dist/mixins/chart-tooltip.d.ts +118 -0
  244. package/dist/mixins/chart-tooltip.js +323 -0
  245. package/dist/mixins/clear-field.d.ts +60 -0
  246. package/dist/mixins/clear-field.js +100 -0
  247. package/dist/mixins/color-area-drag.d.ts +58 -0
  248. package/dist/mixins/color-area-drag.js +162 -0
  249. package/dist/mixins/color-channel-sync.d.ts +73 -0
  250. package/dist/mixins/color-channel-sync.js +169 -0
  251. package/dist/mixins/color-preview.d.ts +28 -0
  252. package/dist/mixins/color-preview.js +77 -0
  253. package/dist/mixins/color-wheel-drag.d.ts +58 -0
  254. package/dist/mixins/color-wheel-drag.js +139 -0
  255. package/dist/mixins/combobox-filter.d.ts +59 -0
  256. package/dist/mixins/combobox-filter.js +81 -0
  257. package/dist/mixins/command-filter.d.ts +55 -0
  258. package/dist/mixins/command-filter.js +121 -0
  259. package/dist/mixins/command-keys.d.ts +31 -0
  260. package/dist/mixins/command-keys.js +116 -0
  261. package/dist/mixins/context-menu.d.ts +24 -0
  262. package/dist/mixins/context-menu.js +64 -0
  263. package/dist/mixins/copy-to-clipboard.d.ts +64 -0
  264. package/dist/mixins/copy-to-clipboard.js +109 -0
  265. package/dist/mixins/dismiss.d.ts +77 -0
  266. package/dist/mixins/dismiss.js +151 -0
  267. package/dist/mixins/drag-reorder.d.ts +88 -0
  268. package/dist/mixins/drag-reorder.js +214 -0
  269. package/dist/mixins/drop-zone.d.ts +52 -0
  270. package/dist/mixins/drop-zone.js +132 -0
  271. package/dist/mixins/dual-range.d.ts +60 -0
  272. package/dist/mixins/dual-range.js +100 -0
  273. package/dist/mixins/grid-list-keys.d.ts +34 -0
  274. package/dist/mixins/grid-list-keys.js +260 -0
  275. package/dist/mixins/heading-level-fallback.d.ts +81 -0
  276. package/dist/mixins/heading-level-fallback.js +112 -0
  277. package/dist/mixins/hotkey.d.ts +26 -0
  278. package/dist/mixins/hotkey.js +132 -0
  279. package/dist/mixins/image-fallback.d.ts +57 -0
  280. package/dist/mixins/image-fallback.js +86 -0
  281. package/dist/mixins/index.d.ts +48 -0
  282. package/dist/mixins/index.js +48 -0
  283. package/dist/mixins/listbox-keys.d.ts +52 -0
  284. package/dist/mixins/listbox-keys.js +63 -0
  285. package/dist/mixins/long-press.d.ts +76 -0
  286. package/dist/mixins/long-press.js +130 -0
  287. package/dist/mixins/menu-keys.d.ts +40 -0
  288. package/dist/mixins/menu-keys.js +117 -0
  289. package/dist/mixins/menubar-keys.d.ts +59 -0
  290. package/dist/mixins/menubar-keys.js +230 -0
  291. package/dist/mixins/message-follow.d.ts +56 -0
  292. package/dist/mixins/message-follow.js +368 -0
  293. package/dist/mixins/otp-slots.d.ts +53 -0
  294. package/dist/mixins/otp-slots.js +175 -0
  295. package/dist/mixins/persist.d.ts +36 -0
  296. package/dist/mixins/persist.js +78 -0
  297. package/dist/mixins/press-toggle.d.ts +43 -0
  298. package/dist/mixins/press-toggle.js +61 -0
  299. package/dist/mixins/range-preview.d.ts +26 -0
  300. package/dist/mixins/range-preview.js +120 -0
  301. package/dist/mixins/resize-handle.d.ts +101 -0
  302. package/dist/mixins/resize-handle.js +288 -0
  303. package/dist/mixins/stepper.d.ts +81 -0
  304. package/dist/mixins/stepper.js +194 -0
  305. package/dist/mixins/tab-keys.d.ts +30 -0
  306. package/dist/mixins/tab-keys.js +63 -0
  307. package/dist/mixins/theme-toggle.d.ts +82 -0
  308. package/dist/mixins/theme-toggle.js +158 -0
  309. package/dist/mixins/track-host-node.d.ts +34 -0
  310. package/dist/mixins/track-host-node.js +42 -0
  311. package/dist/mixins/treeKeys.d.ts +57 -0
  312. package/dist/mixins/treeKeys.js +266 -0
  313. package/dist/mixins/validate.d.ts +65 -0
  314. package/dist/mixins/validate.js +139 -0
  315. package/dist/mixins/view-transition.d.ts +56 -0
  316. package/dist/mixins/view-transition.js +111 -0
  317. package/dist/styles/chart-palette.d.ts +34 -0
  318. package/dist/styles/chart-palette.js +27 -0
  319. package/dist/styles/field-stack-layout.d.ts +27 -0
  320. package/dist/styles/field-stack-layout.js +16 -0
  321. package/dist/styles/floating-surface.d.ts +32 -0
  322. package/dist/styles/floating-surface.js +30 -0
  323. package/dist/styles/graphic-host.d.ts +25 -0
  324. package/dist/styles/graphic-host.js +18 -0
  325. package/dist/styles/index.d.ts +20 -0
  326. package/dist/styles/index.js +20 -0
  327. package/dist/styles/interactive-transition.d.ts +32 -0
  328. package/dist/styles/interactive-transition.js +32 -0
  329. package/dist/styles/legend-toggle.d.ts +29 -0
  330. package/dist/styles/legend-toggle.js +24 -0
  331. package/dist/styles/output-caption-text.d.ts +22 -0
  332. package/dist/styles/output-caption-text.js +15 -0
  333. package/dist/styles/panel-chrome.d.ts +34 -0
  334. package/dist/styles/panel-chrome.js +26 -0
  335. package/dist/styles/range-thumb-appearance.d.ts +36 -0
  336. package/dist/styles/range-thumb-appearance.js +76 -0
  337. package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
  338. package/dist/styles/rtl-aware-gradient-direction.js +28 -0
  339. package/dist/styles/semantic-color-panel.d.ts +35 -0
  340. package/dist/styles/semantic-color-panel.js +41 -0
  341. package/dist/utils/chart-marker-indices.d.ts +22 -0
  342. package/dist/utils/chart-marker-indices.js +45 -0
  343. package/dist/utils/chart-path.d.ts +86 -0
  344. package/dist/utils/chart-path.js +122 -0
  345. package/dist/utils/chart-scale.d.ts +182 -0
  346. package/dist/utils/chart-scale.js +221 -0
  347. package/dist/utils/color-math.d.ts +252 -0
  348. package/dist/utils/color-math.js +480 -0
  349. package/dist/utils/command-event.d.ts +24 -0
  350. package/dist/utils/command-event.js +26 -0
  351. package/dist/utils/css-styles.d.ts +21 -0
  352. package/dist/utils/css-styles.js +11 -0
  353. package/dist/utils/decorative-icon.d.ts +15 -0
  354. package/dist/utils/decorative-icon.js +15 -0
  355. package/dist/utils/disabled-selector.d.ts +22 -0
  356. package/dist/utils/disabled-selector.js +22 -0
  357. package/dist/utils/dispatch-change.d.ts +17 -0
  358. package/dist/utils/dispatch-change.js +19 -0
  359. package/dist/utils/field-parts.d.ts +26 -0
  360. package/dist/utils/field-parts.js +12 -0
  361. package/dist/utils/full-turn-radians.d.ts +16 -0
  362. package/dist/utils/full-turn-radians.js +16 -0
  363. package/dist/utils/geometry.d.ts +14 -0
  364. package/dist/utils/geometry.js +9 -0
  365. package/dist/utils/has-accessible-text.d.ts +19 -0
  366. package/dist/utils/has-accessible-text.js +30 -0
  367. package/dist/utils/hue-spectrum.d.ts +19 -0
  368. package/dist/utils/hue-spectrum.js +19 -0
  369. package/dist/utils/index.d.ts +35 -0
  370. package/dist/utils/index.js +35 -0
  371. package/dist/utils/is-new-primary-press.d.ts +29 -0
  372. package/dist/utils/is-new-primary-press.js +31 -0
  373. package/dist/utils/keyboard-nav.d.ts +64 -0
  374. package/dist/utils/keyboard-nav.js +79 -0
  375. package/dist/utils/merge-style.d.ts +33 -0
  376. package/dist/utils/merge-style.js +30 -0
  377. package/dist/utils/paired-range-inputs.d.ts +26 -0
  378. package/dist/utils/paired-range-inputs.js +29 -0
  379. package/dist/utils/placement.d.ts +18 -0
  380. package/dist/utils/placement.js +12 -0
  381. package/dist/utils/prefers-reduced-motion.d.ts +17 -0
  382. package/dist/utils/prefers-reduced-motion.js +19 -0
  383. package/dist/utils/resolve-field-wiring.d.ts +83 -0
  384. package/dist/utils/resolve-field-wiring.js +53 -0
  385. package/dist/utils/resolve-fill-percent.d.ts +28 -0
  386. package/dist/utils/resolve-fill-percent.js +34 -0
  387. package/dist/utils/round-precision.d.ts +22 -0
  388. package/dist/utils/round-precision.js +25 -0
  389. package/dist/utils/semantic-color-panel.d.ts +35 -0
  390. package/dist/utils/semantic-color-panel.js +28 -0
  391. package/dist/utils/semantic-color.d.ts +17 -0
  392. package/dist/utils/semantic-color.js +11 -0
  393. package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
  394. package/dist/utils/warn-if-no-accessible-name.js +55 -0
  395. package/dist/utils/write-cookie.d.ts +35 -0
  396. package/dist/utils/write-cookie.js +37 -0
  397. package/package.json +32 -0
  398. package/src/reset.css +223 -0
  399. package/src/theme.css +146 -0
@@ -0,0 +1,480 @@
1
+ /**
2
+ * Pure numeric and string math behind the color-editing components: parsing
3
+ * a hex, `rgb()`, or `hsl()` string, formatting a color back out in any of
4
+ * the three notations, converting between RGB, HSL, and HSV, and the
5
+ * pointer-geometry math a picking square or hue ring turns into a value.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { FULL_TURN_RADIANS } from "./full-turn-radians.js";
11
+ import { roundChannel } from "./round-precision.js";
12
+ export { roundChannel };
13
+ /** Degrees in a full turn around the color wheel, shared by hue normalization and {@link angleToHue}/{@link hueToAngle}'s conversion. */
14
+ const FULL_TURN_DEGREES = 360;
15
+ /**
16
+ * Clamps `value` into an inclusive numeric bound — an RGB channel's
17
+ * `0`–`255`, an alpha channel's `0`–`1`, or a saturation/lightness/value
18
+ * percentage's `0`–`100`.
19
+ *
20
+ * @param value Value to clamp.
21
+ * @param min Lower bound. Defaults to `0`.
22
+ * @param max Upper bound. Defaults to `255`.
23
+ * @returns `value` held within `[min, max]`.
24
+ * @example
25
+ * clampChannel(300); // 255
26
+ * @example
27
+ * clampChannel(-0.2, 0, 1); // 0
28
+ */
29
+ export function clampChannel(value, min = 0, max = 255) {
30
+ return Math.min(max, Math.max(min, value));
31
+ }
32
+ /** Normalizes `hue` into the `[0, 360)` range a color wheel wraps around, folding a negative or over-large input back into range. */
33
+ function normalizeHue(hue) {
34
+ return ((hue % FULL_TURN_DEGREES) + FULL_TURN_DEGREES) % FULL_TURN_DEGREES;
35
+ }
36
+ /** Normalizes `angle` (radians) into the `[0, 2π)` range {@link angleFromCenter} produces, folding a negative or over-large input back into range. */
37
+ function normalizeAngle(angle) {
38
+ return ((angle % FULL_TURN_RADIANS) + FULL_TURN_RADIANS) % FULL_TURN_RADIANS;
39
+ }
40
+ /**
41
+ * Computes the hue angle, in degrees `0`–`360`, of a normalized (`0`–`1`)
42
+ * RGB triplet reduced to its `max` channel and `delta` (`max - min`) — the
43
+ * hue math shared by converting to either the HSL or HSV space.
44
+ *
45
+ * @param r Red channel, `0`–`1`.
46
+ * @param g Green channel, `0`–`1`.
47
+ * @param b Blue channel, `0`–`1`.
48
+ * @param max The largest of `r`, `g`, `b`.
49
+ * @param delta `max` minus the smallest of `r`, `g`, `b`.
50
+ * @returns The hue angle, in degrees, `0`–`360`. Resolves to `0` for a fully desaturated color, where hue has no defined value but a real number is still needed.
51
+ */
52
+ function computeHue(r, g, b, max, delta) {
53
+ if (delta === 0)
54
+ return 0;
55
+ let h;
56
+ if (max === r)
57
+ h = (g - b) / delta;
58
+ else if (max === g)
59
+ h = (b - r) / delta + 2;
60
+ else
61
+ h = (r - g) / delta + 4;
62
+ h *= 60;
63
+ return h < 0 ? h + 360 : h;
64
+ }
65
+ /**
66
+ * Maps a hue's `0`–`360` sector to the `[first, second, third]` RGB-order
67
+ * triplet built from `chroma` and `x` (the second-largest channel's share
68
+ * of it) — the sector logic shared by both HSL-to-RGB and HSV-to-RGB.
69
+ *
70
+ * @param h Hue, in degrees, already normalized to `0`–`360`.
71
+ * @param chroma The color's chroma for this hue/saturation pairing.
72
+ * @param x The second-largest channel's share of `chroma` at this hue.
73
+ * @returns The `[r, g, b]` triplet, each still needing the conversion's own offset added.
74
+ */
75
+ function hueSectorRgb(h, chroma, x) {
76
+ if (h < 60)
77
+ return [chroma, x, 0];
78
+ if (h < 120)
79
+ return [x, chroma, 0];
80
+ if (h < 180)
81
+ return [0, chroma, x];
82
+ if (h < 240)
83
+ return [0, x, chroma];
84
+ if (h < 300)
85
+ return [x, 0, chroma];
86
+ return [chroma, 0, x];
87
+ }
88
+ /**
89
+ * Converts an {@link RGBColor} to its {@link HSLColor} representation.
90
+ *
91
+ * @param color The color to convert.
92
+ * @returns The equivalent hue/saturation/lightness values.
93
+ * @example
94
+ * rgbToHsl({ r: 255, g: 0, b: 0 }); // { h: 0, s: 100, l: 50 }
95
+ * @example
96
+ * rgbToHsl({ r: 128, g: 128, b: 128 }); // { h: 0, s: 0, l: ~50.2 }
97
+ */
98
+ export function rgbToHsl(color) {
99
+ let r = clampChannel(color.r, 0, 255) / 255;
100
+ let g = clampChannel(color.g, 0, 255) / 255;
101
+ let b = clampChannel(color.b, 0, 255) / 255;
102
+ let max = Math.max(r, g, b);
103
+ let min = Math.min(r, g, b);
104
+ let delta = max - min;
105
+ let l = (max + min) / 2;
106
+ let s;
107
+ if (delta === 0)
108
+ s = 0;
109
+ else if (l > 0.5)
110
+ s = delta / (2 - max - min);
111
+ else
112
+ s = delta / (max + min);
113
+ return { h: computeHue(r, g, b, max, delta), s: s * 100, l: l * 100 };
114
+ }
115
+ /**
116
+ * Converts an {@link HSLColor} to its {@link RGBColor} representation,
117
+ * rounding each channel to a whole number.
118
+ *
119
+ * @param color The color to convert.
120
+ * @returns The equivalent red/green/blue values, each `0`–`255`.
121
+ * @example
122
+ * hslToRgb({ h: 0, s: 100, l: 50 }); // { r: 255, g: 0, b: 0 }
123
+ * @example
124
+ * hslToRgb({ h: 120, s: 100, l: 50 }); // { r: 0, g: 255, b: 0 }
125
+ */
126
+ export function hslToRgb(color) {
127
+ let h = normalizeHue(color.h);
128
+ let s = clampChannel(color.s, 0, 100) / 100;
129
+ let l = clampChannel(color.l, 0, 100) / 100;
130
+ if (s === 0) {
131
+ let gray = roundChannel(l * 255);
132
+ return { r: gray, g: gray, b: gray };
133
+ }
134
+ let chroma = (1 - Math.abs(2 * l - 1)) * s;
135
+ let x = chroma * (1 - Math.abs(((h / 60) % 2) - 1));
136
+ let m = l - chroma / 2;
137
+ let [r, g, b] = hueSectorRgb(h, chroma, x);
138
+ return {
139
+ r: roundChannel((r + m) * 255),
140
+ g: roundChannel((g + m) * 255),
141
+ b: roundChannel((b + m) * 255),
142
+ };
143
+ }
144
+ /**
145
+ * Converts an {@link RGBColor} to its {@link HSVColor} representation.
146
+ *
147
+ * @param color The color to convert.
148
+ * @returns The equivalent hue/saturation/value values.
149
+ * @example
150
+ * rgbToHsv({ r: 255, g: 0, b: 0 }); // { h: 0, s: 100, v: 100 }
151
+ * @example
152
+ * rgbToHsv({ r: 0, g: 0, b: 0 }); // { h: 0, s: 0, v: 0 }
153
+ */
154
+ export function rgbToHsv(color) {
155
+ let r = clampChannel(color.r, 0, 255) / 255;
156
+ let g = clampChannel(color.g, 0, 255) / 255;
157
+ let b = clampChannel(color.b, 0, 255) / 255;
158
+ let max = Math.max(r, g, b);
159
+ let min = Math.min(r, g, b);
160
+ let delta = max - min;
161
+ let s = max === 0 ? 0 : delta / max;
162
+ return { h: computeHue(r, g, b, max, delta), s: s * 100, v: max * 100 };
163
+ }
164
+ /**
165
+ * Converts an {@link HSVColor} to its {@link RGBColor} representation,
166
+ * rounding each channel to a whole number.
167
+ *
168
+ * @param color The color to convert.
169
+ * @returns The equivalent red/green/blue values, each `0`–`255`.
170
+ * @example
171
+ * hsvToRgb({ h: 0, s: 100, v: 100 }); // { r: 255, g: 0, b: 0 }
172
+ * @example
173
+ * hsvToRgb({ h: 0, s: 0, v: 0 }); // { r: 0, g: 0, b: 0 }
174
+ */
175
+ export function hsvToRgb(color) {
176
+ let h = normalizeHue(color.h);
177
+ let s = clampChannel(color.s, 0, 100) / 100;
178
+ let v = clampChannel(color.v, 0, 100) / 100;
179
+ if (s === 0) {
180
+ let gray = roundChannel(v * 255);
181
+ return { r: gray, g: gray, b: gray };
182
+ }
183
+ let chroma = v * s;
184
+ let x = chroma * (1 - Math.abs(((h / 60) % 2) - 1));
185
+ let m = v - chroma;
186
+ let [r, g, b] = hueSectorRgb(h, chroma, x);
187
+ return {
188
+ r: roundChannel((r + m) * 255),
189
+ g: roundChannel((g + m) * 255),
190
+ b: roundChannel((b + m) * 255),
191
+ };
192
+ }
193
+ /** Splits the parenthesized contents of an `rgb()`/`rgba()`/`hsl()`/`hsla()` call into its component tokens, accepting both the classic comma-separated form and the space-separated form with an optional `/`-prefixed alpha. */
194
+ function tokenizeComponents(content) {
195
+ return content
196
+ .replace(/[,/]/g, " ")
197
+ .trim()
198
+ .split(/\s+/)
199
+ .filter((token) => token.length > 0);
200
+ }
201
+ /** Parses one `rgb()`/`rgba()` channel token — a plain number or a percentage of `255` — to its numeric value, or `null` when `token` matches neither shape. */
202
+ function parseRgbChannelToken(token) {
203
+ if (token.endsWith("%")) {
204
+ let percent = Number(token.slice(0, -1));
205
+ return Number.isFinite(percent) ? (percent / 100) * 255 : null;
206
+ }
207
+ let value = Number(token);
208
+ return Number.isFinite(value) ? value : null;
209
+ }
210
+ /** Parses an alpha token — a plain `0`–`1` number or a percentage — to its numeric value; a missing token (no fourth component given) resolves to fully opaque (`1`). */
211
+ function parseAlphaToken(token) {
212
+ if (token === undefined)
213
+ return 1;
214
+ if (token.endsWith("%")) {
215
+ let percent = Number(token.slice(0, -1));
216
+ return Number.isFinite(percent) ? percent / 100 : null;
217
+ }
218
+ let value = Number(token);
219
+ return Number.isFinite(value) ? value : null;
220
+ }
221
+ /** Parses an `hsl()`/`hsla()` hue token — a plain number optionally suffixed with `deg` — to its numeric degree value, or `null` when `token` matches neither shape. */
222
+ function parseHueToken(token) {
223
+ let match = /^(-?\d*\.?\d+)(deg)?$/i.exec(token);
224
+ if (match === null)
225
+ return null;
226
+ let value = Number(match[1]);
227
+ return Number.isFinite(value) ? value : null;
228
+ }
229
+ /** Parses an `hsl()`/`hsla()` saturation or lightness token — a percentage — to its numeric `0`–`100` value, or `null` when `token` isn't a percentage. */
230
+ function parsePercentToken(token) {
231
+ if (!token.endsWith("%"))
232
+ return null;
233
+ let percent = Number(token.slice(0, -1));
234
+ return Number.isFinite(percent) ? percent : null;
235
+ }
236
+ /** Expands a single hex digit into its doubled two-character form (`"f"` → `"ff"`), the per-channel encoding the shorthand `#rgb`/`#rgba` notation uses. */
237
+ function expandHexDigit(digit) {
238
+ return digit + digit;
239
+ }
240
+ /** Parses the digits of a `#`-prefixed hex color (already stripped of the `#`) into an {@link RGBAColor}, or `null` when `digits` isn't 3, 4, 6, or 8 hex characters long. */
241
+ function parseHexDigits(digits) {
242
+ let channels;
243
+ switch (digits.length) {
244
+ case 3:
245
+ channels = [...Array.from(digits, expandHexDigit), "ff"];
246
+ break;
247
+ case 4:
248
+ channels = Array.from(digits, expandHexDigit);
249
+ break;
250
+ case 6:
251
+ channels = [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 6), "ff"];
252
+ break;
253
+ case 8:
254
+ channels = [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 6), digits.slice(6, 8)];
255
+ break;
256
+ default:
257
+ return null;
258
+ }
259
+ let [r, g, b, a] = channels;
260
+ if (r === undefined || g === undefined || b === undefined || a === undefined)
261
+ return null;
262
+ return {
263
+ r: Number.parseInt(r, 16),
264
+ g: Number.parseInt(g, 16),
265
+ b: Number.parseInt(b, 16),
266
+ a: roundChannel(Number.parseInt(a, 16) / 255, 2),
267
+ };
268
+ }
269
+ /** Parses the parenthesized contents of an `rgb()`/`rgba()` color into an {@link RGBAColor}, or `null` when `content` doesn't hold 3 or 4 valid components. */
270
+ function parseRgbComponents(content) {
271
+ let tokens = tokenizeComponents(content);
272
+ if (tokens.length !== 3 && tokens.length !== 4)
273
+ return null;
274
+ let [rToken, gToken, bToken, aToken] = tokens;
275
+ if (rToken === undefined || gToken === undefined || bToken === undefined)
276
+ return null;
277
+ let r = parseRgbChannelToken(rToken);
278
+ let g = parseRgbChannelToken(gToken);
279
+ let b = parseRgbChannelToken(bToken);
280
+ let a = parseAlphaToken(aToken);
281
+ if (r === null || g === null || b === null || a === null)
282
+ return null;
283
+ return {
284
+ r: roundChannel(clampChannel(r, 0, 255)),
285
+ g: roundChannel(clampChannel(g, 0, 255)),
286
+ b: roundChannel(clampChannel(b, 0, 255)),
287
+ a: clampChannel(a, 0, 1),
288
+ };
289
+ }
290
+ /** Parses the parenthesized contents of an `hsl()`/`hsla()` color into an {@link RGBAColor}, converting through {@link hslToRgb}, or `null` when `content` doesn't hold 3 or 4 valid components. */
291
+ function parseHslComponents(content) {
292
+ let tokens = tokenizeComponents(content);
293
+ if (tokens.length !== 3 && tokens.length !== 4)
294
+ return null;
295
+ let [hToken, sToken, lToken, aToken] = tokens;
296
+ if (hToken === undefined || sToken === undefined || lToken === undefined)
297
+ return null;
298
+ let h = parseHueToken(hToken);
299
+ let s = parsePercentToken(sToken);
300
+ let l = parsePercentToken(lToken);
301
+ let a = parseAlphaToken(aToken);
302
+ if (h === null || s === null || l === null || a === null)
303
+ return null;
304
+ let { r, g, b } = hslToRgb({ h, s, l });
305
+ return { r, g, b, a: clampChannel(a, 0, 1) };
306
+ }
307
+ /**
308
+ * Parses a hex (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`), `rgb()`/`rgba()`,
309
+ * or `hsl()`/`hsla()` color string into its channel values — the shared
310
+ * entry point every color-editing field and swatch reads a raw value through.
311
+ *
312
+ * @param input The color string to parse.
313
+ * @returns The parsed {@link RGBAColor}, or `null` when `input` doesn't
314
+ * match a supported notation — a named color, an unsupported notation, or
315
+ * a string merely resembling one of the three formats without fully
316
+ * matching it.
317
+ * @example
318
+ * parseColor("#ff0000"); // { r: 255, g: 0, b: 0, a: 1 }
319
+ * @example
320
+ * parseColor("rgba(0, 128, 255, 0.5)"); // { r: 0, g: 128, b: 255, a: 0.5 }
321
+ * @example
322
+ * parseColor("hsl(120deg 100% 50%)"); // { r: 0, g: 255, b: 0, a: 1 }
323
+ * @example
324
+ * parseColor("not-a-color"); // null
325
+ */
326
+ export function parseColor(input) {
327
+ let value = input.trim();
328
+ let hexMatch = /^#([0-9a-fA-F]+)$/.exec(value);
329
+ if (hexMatch !== null) {
330
+ let digits = hexMatch[1];
331
+ return digits === undefined ? null : parseHexDigits(digits);
332
+ }
333
+ let rgbMatch = /^rgba?\(([^)]*)\)$/i.exec(value);
334
+ if (rgbMatch !== null) {
335
+ let content = rgbMatch[1];
336
+ return content === undefined ? null : parseRgbComponents(content);
337
+ }
338
+ let hslMatch = /^hsla?\(([^)]*)\)$/i.exec(value);
339
+ if (hslMatch !== null) {
340
+ let content = hslMatch[1];
341
+ return content === undefined ? null : parseHslComponents(content);
342
+ }
343
+ return null;
344
+ }
345
+ /** Formats a single `0`–`255` channel as a two-character lowercase hex byte, clamping and rounding it first so an out-of-range or fractional input still produces a valid byte. */
346
+ function toHexByte(value) {
347
+ return roundChannel(clampChannel(value, 0, 255))
348
+ .toString(16)
349
+ .padStart(2, "0");
350
+ }
351
+ /**
352
+ * Formats `color` as a hex string: `#rrggbb` once fully opaque, or
353
+ * `#rrggbbaa` once alpha drops below `1`, so a fully opaque color round-trips
354
+ * through the shorter, more familiar six-character form.
355
+ *
356
+ * @param color The color to format.
357
+ * @returns The formatted hex string, always lowercase.
358
+ * @example
359
+ * formatHex({ r: 255, g: 0, b: 0, a: 1 }); // "#ff0000"
360
+ * @example
361
+ * formatHex({ r: 255, g: 0, b: 0, a: 0.5 }); // "#ff000080"
362
+ */
363
+ export function formatHex(color) {
364
+ let hex = `#${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
365
+ let alpha = clampChannel(color.a, 0, 1);
366
+ return alpha >= 1 ? hex : `${hex}${toHexByte(alpha * 255)}`;
367
+ }
368
+ /**
369
+ * Formats `color` as an `rgb()`/`rgba()` string using the classic
370
+ * comma-separated notation: `rgb(r, g, b)` once fully opaque, or
371
+ * `rgba(r, g, b, a)` once alpha drops below `1`.
372
+ *
373
+ * @param color The color to format.
374
+ * @returns The formatted `rgb()`/`rgba()` string.
375
+ * @example
376
+ * formatRgb({ r: 255, g: 0, b: 0, a: 1 }); // "rgb(255, 0, 0)"
377
+ * @example
378
+ * formatRgb({ r: 255, g: 0, b: 0, a: 0.5 }); // "rgba(255, 0, 0, 0.5)"
379
+ */
380
+ export function formatRgb(color) {
381
+ let r = roundChannel(clampChannel(color.r, 0, 255));
382
+ let g = roundChannel(clampChannel(color.g, 0, 255));
383
+ let b = roundChannel(clampChannel(color.b, 0, 255));
384
+ let a = clampChannel(color.a, 0, 1);
385
+ return a >= 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${roundChannel(a, 2)})`;
386
+ }
387
+ /**
388
+ * Formats `color` as an `hsl()`/`hsla()` string, converting through
389
+ * {@link rgbToHsl} first: `hsl(h, s%, l%)` once fully opaque, or
390
+ * `hsla(h, s%, l%, a)` once alpha drops below `1`.
391
+ *
392
+ * @param color The color to format.
393
+ * @returns The formatted `hsl()`/`hsla()` string.
394
+ * @example
395
+ * formatHsl({ r: 255, g: 0, b: 0, a: 1 }); // "hsl(0, 100%, 50%)"
396
+ * @example
397
+ * formatHsl({ r: 255, g: 0, b: 0, a: 0.5 }); // "hsla(0, 100%, 50%, 0.5)"
398
+ */
399
+ export function formatHsl(color) {
400
+ let { h, s, l } = rgbToHsl(color);
401
+ let hue = roundChannel(h);
402
+ let saturation = roundChannel(s);
403
+ let lightness = roundChannel(l);
404
+ let a = clampChannel(color.a, 0, 1);
405
+ return a >= 1
406
+ ? `hsl(${hue}, ${saturation}%, ${lightness}%)`
407
+ : `hsla(${hue}, ${saturation}%, ${lightness}%, ${roundChannel(a, 2)})`;
408
+ }
409
+ /**
410
+ * Maps a pointer position to its `[0, 1]` × `[0, 1]` position within `rect`,
411
+ * clamped to the rectangle's border for a pointer that has drifted past its
412
+ * edges — the shared math behind dragging across a picking surface.
413
+ *
414
+ * @param rect The rectangle `point` is measured against.
415
+ * @param point The pointer position to normalize.
416
+ * @returns The normalized, clamped position within `rect`. A zero-width or
417
+ * zero-height `rect` resolves every position on that axis to `0`.
418
+ * @example
419
+ * normalizedPointerPosition({ left: 0, top: 0, width: 200, height: 100 }, { x: 100, y: 25 });
420
+ * // { x: 0.5, y: 0.25 }
421
+ * @example
422
+ * normalizedPointerPosition({ left: 0, top: 0, width: 200, height: 100 }, { x: -50, y: 500 });
423
+ * // { x: 0, y: 1 }
424
+ */
425
+ export function normalizedPointerPosition(rect, point) {
426
+ let x = rect.width === 0 ? 0 : (point.x - rect.left) / rect.width;
427
+ let y = rect.height === 0 ? 0 : (point.y - rect.top) / rect.height;
428
+ return { x: clampChannel(x, 0, 1), y: clampChannel(y, 0, 1) };
429
+ }
430
+ /**
431
+ * Computes the clockwise angle, in radians from `0` (straight up, 12
432
+ * o'clock) through the full `[0, 2π)` turn, of `point` as seen from
433
+ * `center` — the shared math behind dragging around a circular control.
434
+ *
435
+ * @param center The circle's center.
436
+ * @param point The pointer position to measure the angle of.
437
+ * @returns The angle, in radians, clockwise from 12 o'clock, `0`–`2π`. A
438
+ * `point` exactly on `center` resolves to `0`.
439
+ * @example
440
+ * angleFromCenter({ x: 0, y: 0 }, { x: 0, y: -10 }); // 0 (straight up)
441
+ * @example
442
+ * angleFromCenter({ x: 0, y: 0 }, { x: 10, y: 0 }); // Math.PI / 2 (3 o'clock)
443
+ */
444
+ export function angleFromCenter(center, point) {
445
+ let dx = point.x - center.x;
446
+ let dy = point.y - center.y;
447
+ if (dx === 0 && dy === 0)
448
+ return 0;
449
+ return normalizeAngle(Math.atan2(dx, -dy));
450
+ }
451
+ /**
452
+ * Converts an {@link angleFromCenter}-style angle (radians, clockwise from
453
+ * 12 o'clock) to the hue, in degrees, it represents on a circular hue
454
+ * control — the inverse of {@link hueToAngle}.
455
+ *
456
+ * @param angle The angle, in radians, to convert.
457
+ * @returns The equivalent hue, in degrees, `0`–`360`.
458
+ * @example
459
+ * angleToHue(0); // 0
460
+ * @example
461
+ * angleToHue(Math.PI); // 180
462
+ */
463
+ export function angleToHue(angle) {
464
+ return normalizeAngle(angle) * (FULL_TURN_DEGREES / FULL_TURN_RADIANS);
465
+ }
466
+ /**
467
+ * Converts a hue, in degrees, to its {@link angleFromCenter}-style angle
468
+ * (radians, clockwise from 12 o'clock) on a circular hue control — the
469
+ * inverse of {@link angleToHue}, for placing a control's pointer.
470
+ *
471
+ * @param hue The hue, in degrees, to convert.
472
+ * @returns The equivalent angle, in radians, clockwise from 12 o'clock.
473
+ * @example
474
+ * hueToAngle(0); // 0
475
+ * @example
476
+ * hueToAngle(180); // Math.PI
477
+ */
478
+ export function hueToAngle(hue) {
479
+ return normalizeHue(hue) * (FULL_TURN_RADIANS / FULL_TURN_DEGREES);
480
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The escape-hatch cast every mixin answering an Invoker Commands `command`
3
+ * event repeats on its own: `on()` types a `"command"` handler's event as a
4
+ * plain DOM `Event`, since `CommandEvent` isn't part of the standard
5
+ * `HTMLElementEventMap` yet, so reading `command` or `source` off it needs a
6
+ * cast past that generic type first.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ /**
12
+ * Narrows an `on("command", ...)` handler's event to `CommandEvent`, so the
13
+ * `as unknown as CommandEvent` cast a command-answering mixin would
14
+ * otherwise repeat lives in one reviewable place.
15
+ *
16
+ * @param event The event received by an `on("command", ...)` handler.
17
+ * @returns The same event, narrowed to `CommandEvent`.
18
+ * @example
19
+ * on<HTMLElement, "command">("command", (event) => {
20
+ * let commandEvent = asCommandEvent(event);
21
+ * if (commandEvent.command !== TOGGLE_COMMAND) return;
22
+ * });
23
+ */
24
+ export declare function asCommandEvent(event: Event): CommandEvent;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The escape-hatch cast every mixin answering an Invoker Commands `command`
3
+ * event repeats on its own: `on()` types a `"command"` handler's event as a
4
+ * plain DOM `Event`, since `CommandEvent` isn't part of the standard
5
+ * `HTMLElementEventMap` yet, so reading `command` or `source` off it needs a
6
+ * cast past that generic type first.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ /**
12
+ * Narrows an `on("command", ...)` handler's event to `CommandEvent`, so the
13
+ * `as unknown as CommandEvent` cast a command-answering mixin would
14
+ * otherwise repeat lives in one reviewable place.
15
+ *
16
+ * @param event The event received by an `on("command", ...)` handler.
17
+ * @returns The same event, narrowed to `CommandEvent`.
18
+ * @example
19
+ * on<HTMLElement, "command">("command", (event) => {
20
+ * let commandEvent = asCommandEvent(event);
21
+ * if (commandEvent.command !== TOGGLE_COMMAND) return;
22
+ * });
23
+ */
24
+ export function asCommandEvent(event) {
25
+ return event;
26
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The style object shape `css()` accepts, aliased directly from `css()`'s own
3
+ * parameter type because `remix/ui` doesn't export that type under its own
4
+ * name. Modules that build a nested selector, at-rule, or gated block ahead
5
+ * of a `css()` call assign it into its own `CSSStyles` variable first, so
6
+ * each nested block gets checked against this exact type as it's written.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { css } from "remix/ui";
12
+ /**
13
+ * The style object shape {@link css} accepts: a plain CSS-in-JS declaration
14
+ * block, with nested selectors, at-rules (`@media`, `@supports`,
15
+ * `@starting-style`, `@keyframes`), and computed keys all valid at any depth.
16
+ *
17
+ * @example
18
+ * let hovered: CSSStyles = { opacity: 1 };
19
+ * let host: CSSStyles = { opacity: 0, "&:hover": hovered };
20
+ */
21
+ export type CSSStyles = Parameters<typeof css>[0];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The style object shape `css()` accepts, aliased directly from `css()`'s own
3
+ * parameter type because `remix/ui` doesn't export that type under its own
4
+ * name. Modules that build a nested selector, at-rule, or gated block ahead
5
+ * of a `css()` call assign it into its own `CSSStyles` variable first, so
6
+ * each nested block gets checked against this exact type as it's written.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { css } from "remix/ui";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The shared `aria-hidden` default every decorative icon slot applies
3
+ * through `attrs` — an `Icon` compound part whose meaning is already carried
4
+ * by adjacent text or the surrounding component's color, so exposing its
5
+ * glyph to assistive technology would only add noise.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ /**
11
+ * `aria-hidden="true"` applied to a decorative icon slot through `attrs`
12
+ * unless a consumer overrides it. The value stays the string `"true"` since
13
+ * a boolean prop serializes to `aria-hidden=""`, which hides nothing.
14
+ */
15
+ export declare const DEFAULT_ICON_ARIA_HIDDEN = "true";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The shared `aria-hidden` default every decorative icon slot applies
3
+ * through `attrs` — an `Icon` compound part whose meaning is already carried
4
+ * by adjacent text or the surrounding component's color, so exposing its
5
+ * glyph to assistive technology would only add noise.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ /**
11
+ * `aria-hidden="true"` applied to a decorative icon slot through `attrs`
12
+ * unless a consumer overrides it. The value stays the string `"true"` since
13
+ * a boolean prop serializes to `aria-hidden=""`, which hides nothing.
14
+ */
15
+ export const DEFAULT_ICON_ARIA_HIDDEN = "true";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The selector every mixin checks before reacting to a click or counting an
3
+ * element among its keyboard-navigation stops: an element reads as disabled
4
+ * whether that state rides the native `disabled` attribute a form control
5
+ * carries, or `aria-disabled="true"`, the attribute a non-form element (a
6
+ * `role="menuitem"` row, a `role="gridcell"` action) carries instead since it
7
+ * has no native disabled state of its own to set.
8
+ *
9
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
10
+ * @copyright Sergio Xalambrí 2026
11
+ */
12
+ /**
13
+ * Matches an element carrying the native `disabled` attribute or
14
+ * `aria-disabled="true"`, letting one guard cover both a native form
15
+ * control and an ARIA-only widget through a single `.matches()` call.
16
+ *
17
+ * @example
18
+ * button.matches(DISABLED_SELECTOR);
19
+ * @example
20
+ * candidates.filter((element) => !element.matches(DISABLED_SELECTOR));
21
+ */
22
+ export declare const DISABLED_SELECTOR = ":disabled, [aria-disabled=\"true\"]";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The selector every mixin checks before reacting to a click or counting an
3
+ * element among its keyboard-navigation stops: an element reads as disabled
4
+ * whether that state rides the native `disabled` attribute a form control
5
+ * carries, or `aria-disabled="true"`, the attribute a non-form element (a
6
+ * `role="menuitem"` row, a `role="gridcell"` action) carries instead since it
7
+ * has no native disabled state of its own to set.
8
+ *
9
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
10
+ * @copyright Sergio Xalambrí 2026
11
+ */
12
+ /**
13
+ * Matches an element carrying the native `disabled` attribute or
14
+ * `aria-disabled="true"`, letting one guard cover both a native form
15
+ * control and an ARIA-only widget through a single `.matches()` call.
16
+ *
17
+ * @example
18
+ * button.matches(DISABLED_SELECTOR);
19
+ * @example
20
+ * candidates.filter((element) => !element.matches(DISABLED_SELECTOR));
21
+ */
22
+ export const DISABLED_SELECTOR = ':disabled, [aria-disabled="true"]';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Dispatches the plain `"change"` event a behavior class fires after a
3
+ * state-mutating method runs, shared by every class under `behaviors/` that
4
+ * announces its updates this way.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /**
10
+ * Dispatches a plain `"change"` event on `target`, announcing a state update
11
+ * to any subscriber.
12
+ *
13
+ * @param target Event target the `"change"` event is dispatched on.
14
+ * @example
15
+ * dispatchChange(this);
16
+ */
17
+ export declare function dispatchChange(target: EventTarget): void;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Dispatches the plain `"change"` event a behavior class fires after a
3
+ * state-mutating method runs, shared by every class under `behaviors/` that
4
+ * announces its updates this way.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /**
10
+ * Dispatches a plain `"change"` event on `target`, announcing a state update
11
+ * to any subscriber.
12
+ *
13
+ * @param target Event target the `"change"` event is dispatched on.
14
+ * @example
15
+ * dispatchChange(this);
16
+ */
17
+ export function dispatchChange(target) {
18
+ target.dispatchEvent(new Event("change"));
19
+ }