@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,60 @@
1
+ /**
2
+ * Wires a SearchField's clear button to empty its associated input alone
3
+ * and reveals the button, shipped `hidden` in markup, the moment it mounts.
4
+ * Script is required since a form button can only submit or reset every
5
+ * field, and no built-in browser command clears a single input on its own —
6
+ * WebKit's native `type="search"` cancel affordance is the only fallback.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import type { MixinFactory } from "remix/ui";
12
+ /**
13
+ * Custom Invoker Command a SearchField's clear button declares
14
+ * (`command={SEARCH_FIELD_CLEAR_COMMAND}`, `commandfor` pointing at the
15
+ * field's input) so the pairing reads as a real invoker relationship in markup, matched by {@link clearField} through the button's own click.
16
+ */
17
+ export declare const SEARCH_FIELD_CLEAR_COMMAND: "--clear";
18
+ /** DOM event type dispatched on a SearchField's input by {@link clearField} right after it empties the field. */
19
+ declare const SEARCH_FIELD_CLEAR_EVENT: "ui:search-field-clear";
20
+ declare global {
21
+ interface HTMLElementEventMap {
22
+ [SEARCH_FIELD_CLEAR_EVENT]: SearchFieldClearEvent;
23
+ }
24
+ }
25
+ /**
26
+ * Dispatched on a SearchField's input by {@link clearField} immediately
27
+ * after its value is emptied, carrying the text it held a moment before so
28
+ * a consumer can react to the clear — canceling an in-flight request for that term, or dropping a query param — using only this event.
29
+ */
30
+ export declare class SearchFieldClearEvent extends Event {
31
+ /** The input's value immediately before this clear. */
32
+ readonly previousValue: string;
33
+ /**
34
+ * @param previousValue The input's value immediately before this clear.
35
+ */
36
+ constructor(previousValue: string);
37
+ }
38
+ /**
39
+ * Wires a SearchField's clear button to empty its own `commandfor`-resolved
40
+ * input and dispatch `input`/`change` plus {@link SearchFieldClearEvent}
41
+ * before refocusing the field, since the button can vanish once styles react to the emptied state; a disabled, read-only, or already-empty target leaves the press with no effect.
42
+ *
43
+ * @returns A mixin descriptor for a SearchField clear button's `mix` prop.
44
+ * @example
45
+ * <div>
46
+ * <input id="site-search" type="search" name="q" />
47
+ * <button
48
+ * type="button"
49
+ * hidden
50
+ * commandfor="site-search"
51
+ * command={SEARCH_FIELD_CLEAR_COMMAND}
52
+ * aria-label={t("searchField.clear")}
53
+ * mix={clearField()}
54
+ * >
55
+ * <XIcon />
56
+ * </button>
57
+ * </div>
58
+ */
59
+ export declare const clearField: MixinFactory<HTMLButtonElement>;
60
+ export {};
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Wires a SearchField's clear button to empty its associated input alone
3
+ * and reveals the button, shipped `hidden` in markup, the moment it mounts.
4
+ * Script is required since a form button can only submit or reset every
5
+ * field, and no built-in browser command clears a single input on its own —
6
+ * WebKit's native `type="search"` cancel affordance is the only fallback.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { createElement, createMixin, on } from "remix/ui";
12
+ import { DISABLED_SELECTOR } from "../utils/disabled-selector.js";
13
+ /**
14
+ * Custom Invoker Command a SearchField's clear button declares
15
+ * (`command={SEARCH_FIELD_CLEAR_COMMAND}`, `commandfor` pointing at the
16
+ * field's input) so the pairing reads as a real invoker relationship in markup, matched by {@link clearField} through the button's own click.
17
+ */
18
+ export const SEARCH_FIELD_CLEAR_COMMAND = "--clear";
19
+ /** DOM event type dispatched on a SearchField's input by {@link clearField} right after it empties the field. */
20
+ const SEARCH_FIELD_CLEAR_EVENT = "ui:search-field-clear";
21
+ /**
22
+ * Dispatched on a SearchField's input by {@link clearField} immediately
23
+ * after its value is emptied, carrying the text it held a moment before so
24
+ * a consumer can react to the clear — canceling an in-flight request for that term, or dropping a query param — using only this event.
25
+ */
26
+ export class SearchFieldClearEvent extends Event {
27
+ /** The input's value immediately before this clear. */
28
+ previousValue;
29
+ /**
30
+ * @param previousValue The input's value immediately before this clear.
31
+ */
32
+ constructor(previousValue) {
33
+ super(SEARCH_FIELD_CLEAR_EVENT, { bubbles: true });
34
+ this.previousValue = previousValue;
35
+ }
36
+ }
37
+ /**
38
+ * Finds the input a clear button's `commandfor` targets, preferring the
39
+ * live `commandForElement` reference and falling back to an `id` lookup for
40
+ * runtimes that parse `commandfor` without yet reflecting the IDL property.
41
+ *
42
+ * @param button The clear button found inside a SearchField.
43
+ */
44
+ function resolveClearTarget(button) {
45
+ if (button.commandForElement instanceof HTMLInputElement)
46
+ return button.commandForElement;
47
+ let commandForId = button.getAttribute("commandfor");
48
+ if (!commandForId)
49
+ return undefined;
50
+ let fallbackTarget = document.getElementById(commandForId);
51
+ return fallbackTarget instanceof HTMLInputElement ? fallbackTarget : undefined;
52
+ }
53
+ /**
54
+ * Wires a SearchField's clear button to empty its own `commandfor`-resolved
55
+ * input and dispatch `input`/`change` plus {@link SearchFieldClearEvent}
56
+ * before refocusing the field, since the button can vanish once styles react to the emptied state; a disabled, read-only, or already-empty target leaves the press with no effect.
57
+ *
58
+ * @returns A mixin descriptor for a SearchField clear button's `mix` prop.
59
+ * @example
60
+ * <div>
61
+ * <input id="site-search" type="search" name="q" />
62
+ * <button
63
+ * type="button"
64
+ * hidden
65
+ * commandfor="site-search"
66
+ * command={SEARCH_FIELD_CLEAR_COMMAND}
67
+ * aria-label={t("searchField.clear")}
68
+ * mix={clearField()}
69
+ * >
70
+ * <XIcon />
71
+ * </button>
72
+ * </div>
73
+ */
74
+ export const clearField = createMixin((handle) => {
75
+ handle.addEventListener("insert", (event) => {
76
+ event.node.hidden = false;
77
+ });
78
+ return () => createElement(handle.element, {
79
+ mix: [
80
+ on("click", (event) => {
81
+ let button = event.currentTarget;
82
+ if (button.matches(DISABLED_SELECTOR))
83
+ return;
84
+ let input = resolveClearTarget(button);
85
+ if (!input)
86
+ return;
87
+ if (input.disabled || input.readOnly)
88
+ return;
89
+ if (input.value === "")
90
+ return;
91
+ let previousValue = input.value;
92
+ input.value = "";
93
+ input.dispatchEvent(new Event("input", { bubbles: true }));
94
+ input.dispatchEvent(new Event("change", { bubbles: true }));
95
+ input.dispatchEvent(new SearchFieldClearEvent(previousValue));
96
+ input.focus();
97
+ }),
98
+ ],
99
+ });
100
+ });
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Drags a ColorArea root as one two-dimensional pointer gesture, mapping the
3
+ * pointer position onto paired horizontal- and vertical-axis range inputs
4
+ * and writing both together — the one update neither input's own drag
5
+ * handling can produce alone, since each tracks only its own axis.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { MixinFactory } from "remix/ui";
11
+ import type { Point } from "../utils/color-math.js";
12
+ /**
13
+ * `data-*` attribute a ColorArea's paired axis inputs carry so
14
+ * {@link colorAreaDrag} can tell the horizontal-axis input from the
15
+ * vertical-axis input.
16
+ */
17
+ export declare const COLOR_AREA_AXIS_ATTRIBUTE = "data-color-area-axis";
18
+ /** {@link COLOR_AREA_AXIS_ATTRIBUTE} value the horizontal-axis input of a pair carries. */
19
+ export declare const COLOR_AREA_AXIS_X = "x";
20
+ /** {@link COLOR_AREA_AXIS_ATTRIBUTE} value the vertical-axis input of a pair carries. */
21
+ export declare const COLOR_AREA_AXIS_Y = "y";
22
+ /** DOM event type dispatched by {@link colorAreaDrag} on its host whenever a pointer gesture settles both paired axis inputs on new values. */
23
+ declare const COLOR_AREA_CHANGE_EVENT: "ui:color-area-change";
24
+ declare global {
25
+ interface HTMLElementEventMap {
26
+ [COLOR_AREA_CHANGE_EVENT]: ColorAreaChangeEvent;
27
+ }
28
+ }
29
+ /**
30
+ * Dispatched on a ColorArea's host by {@link colorAreaDrag} whenever a
31
+ * pointer gesture settles both paired axis inputs on new values, so a
32
+ * consumer can react to the pair without reading the two `<input>` elements itself.
33
+ */
34
+ export declare class ColorAreaChangeEvent extends Event {
35
+ /** Settled value of the horizontal-axis input, after mapping the pointer position through its own `min`–`max` range. */
36
+ readonly x: number;
37
+ /** Settled value of the vertical-axis input, after mapping the pointer position through its own `min`–`max` range. */
38
+ readonly y: number;
39
+ /**
40
+ * @param init Settled horizontal- and vertical-axis values at dispatch time.
41
+ */
42
+ constructor(init: Point);
43
+ }
44
+ /**
45
+ * Adds pointer-driven, two-dimensional dragging to a ColorArea root,
46
+ * mapping each captured pointer's position onto the paired axis inputs
47
+ * found via {@link COLOR_AREA_AXIS_ATTRIBUTE} and dispatching {@link ColorAreaChangeEvent} on settled pairs.
48
+ *
49
+ * @returns A mixin descriptor for a ColorArea root's `mix` prop.
50
+ * @example
51
+ * <div mix={[colorAreaDrag(), css({ position: "relative" })]}>
52
+ * <input type="range" data-color-area-axis="x" min={0} max={100} defaultValue={50} />
53
+ * <input type="range" data-color-area-axis="y" min={0} max={100} defaultValue={50} />
54
+ * <span aria-hidden="true" mix={css({ position: "absolute" })} />
55
+ * </div>
56
+ */
57
+ export declare const colorAreaDrag: MixinFactory<HTMLElement>;
58
+ export {};
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Drags a ColorArea root as one two-dimensional pointer gesture, mapping the
3
+ * pointer position onto paired horizontal- and vertical-axis range inputs
4
+ * and writing both together — the one update neither input's own drag
5
+ * handling can produce alone, since each tracks only its own axis.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createElement, createMixin, on } from "remix/ui";
11
+ import { normalizedPointerPosition } from "../utils/color-math.js";
12
+ import { findPairedRangeInputs } from "../utils/paired-range-inputs.js";
13
+ /**
14
+ * `data-*` attribute a ColorArea's paired axis inputs carry so
15
+ * {@link colorAreaDrag} can tell the horizontal-axis input from the
16
+ * vertical-axis input.
17
+ */
18
+ export const COLOR_AREA_AXIS_ATTRIBUTE = "data-color-area-axis";
19
+ /** {@link COLOR_AREA_AXIS_ATTRIBUTE} value the horizontal-axis input of a pair carries. */
20
+ export const COLOR_AREA_AXIS_X = "x";
21
+ /** {@link COLOR_AREA_AXIS_ATTRIBUTE} value the vertical-axis input of a pair carries. */
22
+ export const COLOR_AREA_AXIS_Y = "y";
23
+ /** DOM event type dispatched by {@link colorAreaDrag} on its host whenever a pointer gesture settles both paired axis inputs on new values. */
24
+ const COLOR_AREA_CHANGE_EVENT = "ui:color-area-change";
25
+ /**
26
+ * Dispatched on a ColorArea's host by {@link colorAreaDrag} whenever a
27
+ * pointer gesture settles both paired axis inputs on new values, so a
28
+ * consumer can react to the pair without reading the two `<input>` elements itself.
29
+ */
30
+ export class ColorAreaChangeEvent extends Event {
31
+ /** Settled value of the horizontal-axis input, after mapping the pointer position through its own `min`–`max` range. */
32
+ x;
33
+ /** Settled value of the vertical-axis input, after mapping the pointer position through its own `min`–`max` range. */
34
+ y;
35
+ /**
36
+ * @param init Settled horizontal- and vertical-axis values at dispatch time.
37
+ */
38
+ constructor(init) {
39
+ super(COLOR_AREA_CHANGE_EVENT, { bubbles: true });
40
+ this.x = init.x;
41
+ this.y = init.y;
42
+ }
43
+ }
44
+ /**
45
+ * Reads one bound (`min` or `max`) off an axis input's own attribute value,
46
+ * falling back to `fallback` when the attribute is unset — mirroring the
47
+ * native `<input type="range">` defaults an author gets when omitting it.
48
+ *
49
+ * @param raw The input's own `min` or `max` property value.
50
+ * @param fallback Bound to use when `raw` is unset.
51
+ * @returns The parsed bound, or `fallback`.
52
+ */
53
+ function readAxisBound(raw, fallback) {
54
+ if (raw === "")
55
+ return fallback;
56
+ let value = Number(raw);
57
+ return Number.isFinite(value) ? value : fallback;
58
+ }
59
+ /**
60
+ * Reads an axis input's own `min`–`max` range, defaulting each bound to the
61
+ * native `<input type="range">` default (`0`–`100`) when the input omits it.
62
+ *
63
+ * @param input Axis input to read the range of.
64
+ * @returns The input's own `min` and `max`, as numbers.
65
+ */
66
+ function readAxisRange(input) {
67
+ return { min: readAxisBound(input.min, 0), max: readAxisBound(input.max, 100) };
68
+ }
69
+ /**
70
+ * Maps a normalized `[0, 1]` position onto `input`'s own `min`–`max` range.
71
+ *
72
+ * @param normalized Normalized position, `0`–`1`.
73
+ * @param input Axis input whose own range the position maps onto.
74
+ * @returns The mapped value, within `input`'s own `min`–`max` range.
75
+ */
76
+ function mapToAxisValue(normalized, input) {
77
+ let { min, max } = readAxisRange(input);
78
+ return min + normalized * (max - min);
79
+ }
80
+ /**
81
+ * Measures `point` against `host`, maps it onto `xInput`'s and `yInput`'s ranges
82
+ * — inverting the vertical axis since the surface increases upward while the
83
+ * rectangle runs top-down — then dispatches {@link ColorAreaChangeEvent}.
84
+ *
85
+ * @param host ColorArea root element the pointer position measures against.
86
+ * @param xInput Horizontal-axis input to write.
87
+ * @param yInput Vertical-axis input to write.
88
+ * @param point Pointer position, in viewport coordinates.
89
+ */
90
+ function applyPointerPosition(host, xInput, yInput, point) {
91
+ let rect = host.getBoundingClientRect();
92
+ let normalized = normalizedPointerPosition(rect, point);
93
+ let x = mapToAxisValue(normalized.x, xInput);
94
+ let y = mapToAxisValue(1 - normalized.y, yInput);
95
+ xInput.valueAsNumber = x;
96
+ yInput.valueAsNumber = y;
97
+ host.dispatchEvent(new ColorAreaChangeEvent({ x, y }));
98
+ }
99
+ /**
100
+ * Adds pointer-driven, two-dimensional dragging to a ColorArea root,
101
+ * mapping each captured pointer's position onto the paired axis inputs
102
+ * found via {@link COLOR_AREA_AXIS_ATTRIBUTE} and dispatching {@link ColorAreaChangeEvent} on settled pairs.
103
+ *
104
+ * @returns A mixin descriptor for a ColorArea root's `mix` prop.
105
+ * @example
106
+ * <div mix={[colorAreaDrag(), css({ position: "relative" })]}>
107
+ * <input type="range" data-color-area-axis="x" min={0} max={100} defaultValue={50} />
108
+ * <input type="range" data-color-area-axis="y" min={0} max={100} defaultValue={50} />
109
+ * <span aria-hidden="true" mix={css({ position: "absolute" })} />
110
+ * </div>
111
+ */
112
+ export const colorAreaDrag = createMixin((handle) => {
113
+ let hostNode;
114
+ let activePointerId;
115
+ handle.addEventListener("insert", (event) => {
116
+ hostNode = event.node;
117
+ });
118
+ handle.addEventListener("remove", () => {
119
+ hostNode = undefined;
120
+ activePointerId = undefined;
121
+ });
122
+ return () => createElement(handle.element, {
123
+ mix: [
124
+ on("pointerdown", (event) => {
125
+ if (activePointerId !== undefined || !event.isPrimary || event.button !== 0)
126
+ return;
127
+ if (!hostNode)
128
+ return;
129
+ let inputs = findPairedRangeInputs(hostNode, COLOR_AREA_AXIS_ATTRIBUTE, COLOR_AREA_AXIS_X, COLOR_AREA_AXIS_Y);
130
+ if (!inputs)
131
+ return;
132
+ activePointerId = event.pointerId;
133
+ hostNode.setPointerCapture(event.pointerId);
134
+ applyPointerPosition(hostNode, inputs.a, inputs.b, {
135
+ x: event.clientX,
136
+ y: event.clientY,
137
+ });
138
+ }),
139
+ on("pointermove", (event) => {
140
+ if (event.pointerId !== activePointerId || !hostNode)
141
+ return;
142
+ let inputs = findPairedRangeInputs(hostNode, COLOR_AREA_AXIS_ATTRIBUTE, COLOR_AREA_AXIS_X, COLOR_AREA_AXIS_Y);
143
+ if (!inputs)
144
+ return;
145
+ applyPointerPosition(hostNode, inputs.a, inputs.b, {
146
+ x: event.clientX,
147
+ y: event.clientY,
148
+ });
149
+ }),
150
+ on("pointerup", (event) => {
151
+ if (event.pointerId !== activePointerId)
152
+ return;
153
+ activePointerId = undefined;
154
+ }),
155
+ on("pointercancel", (event) => {
156
+ if (event.pointerId !== activePointerId)
157
+ return;
158
+ activePointerId = undefined;
159
+ }),
160
+ ],
161
+ });
162
+ });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Keeps every track in a group of sibling ColorSlider channels painting a
3
+ * gradient that reflects what every other channel is currently settled on,
4
+ * since none of the independent `<input type="range">` thumbs can otherwise
5
+ * notice a sibling's value changing.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { MixinFactory } from "remix/ui";
11
+ /**
12
+ * `data-*` attribute a ColorSlider channel's native range thumb carries,
13
+ * naming the channel it controls. {@link channelSync} reads it, paired
14
+ * with the thumb's own `valueAsNumber`, to tell one channel's value from the next.
15
+ */
16
+ export declare const COLOR_CHANNEL_ATTRIBUTE = "data-channel";
17
+ /**
18
+ * Builds the CSS custom property name {@link channelSync} mirrors a given
19
+ * channel's settled value onto, shared with whatever renders a group's
20
+ * initial markup so both sides agree on the name without duplicating it.
21
+ *
22
+ * @param channel Channel name, matching a {@link COLOR_CHANNEL_ATTRIBUTE} value.
23
+ * @returns The full custom property name for `channel`.
24
+ * @example
25
+ * colorChannelProperty("h"); // "--ui-color-slider-channel-h"
26
+ */
27
+ export declare function colorChannelProperty(channel: string): string;
28
+ /** DOM event type dispatched by {@link channelSync} on its host every time a settled input reports every channel's value together. */
29
+ declare const COLOR_CHANNEL_CHANGE_EVENT: "ui:color-channel-change";
30
+ declare global {
31
+ interface HTMLElementEventMap {
32
+ [COLOR_CHANNEL_CHANGE_EVENT]: ColorChannelChangeEvent;
33
+ }
34
+ }
35
+ /**
36
+ * Dispatched on a ColorSlider group's host by {@link channelSync} every
37
+ * time any channel's thumb settles on a new value, carrying every
38
+ * channel's current value together so a consumer can compose the full color without reading each channel's own `<input>` itself.
39
+ */
40
+ export declare class ColorChannelChangeEvent extends Event {
41
+ /** Name of the channel whose thumb just fired the `input` event that triggered this report. */
42
+ readonly channel: string;
43
+ /** Every channel's settled value, keyed by its own {@link COLOR_CHANNEL_ATTRIBUTE} name. */
44
+ readonly values: Readonly<Record<string, number>>;
45
+ /**
46
+ * @param init The channel that just moved, and every channel's settled value at dispatch time.
47
+ */
48
+ constructor(init: {
49
+ channel: string;
50
+ values: Record<string, number>;
51
+ });
52
+ }
53
+ /**
54
+ * Keeps a group of sibling ColorSlider channel tracks painting a gradient
55
+ * that stays current with one another as each channel's thumb settles, by
56
+ * mirroring every settled value onto the others via {@link colorChannelProperty}.
57
+ *
58
+ * @returns A mixin descriptor for a ColorSlider group's wrapping host's `mix` prop.
59
+ * @example
60
+ * <div mix={channelSync()}>
61
+ * <div data-slot="track">
62
+ * <input type="range" data-channel="r" min={0} max={255} defaultValue={120} aria-label={t("colorSlider.red")} />
63
+ * </div>
64
+ * <div data-slot="track">
65
+ * <input type="range" data-channel="g" min={0} max={255} defaultValue={45} aria-label={t("colorSlider.green")} />
66
+ * </div>
67
+ * <div data-slot="track">
68
+ * <input type="range" data-channel="b" min={0} max={255} defaultValue={200} aria-label={t("colorSlider.blue")} />
69
+ * </div>
70
+ * </div>
71
+ */
72
+ export declare const channelSync: MixinFactory<HTMLElement>;
73
+ export {};
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Keeps every track in a group of sibling ColorSlider channels painting a
3
+ * gradient that reflects what every other channel is currently settled on,
4
+ * since none of the independent `<input type="range">` thumbs can otherwise
5
+ * notice a sibling's value changing.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import { createElement, createMixin, on } from "remix/ui";
11
+ /**
12
+ * `data-*` attribute a ColorSlider channel's native range thumb carries,
13
+ * naming the channel it controls. {@link channelSync} reads it, paired
14
+ * with the thumb's own `valueAsNumber`, to tell one channel's value from the next.
15
+ */
16
+ export const COLOR_CHANNEL_ATTRIBUTE = "data-channel";
17
+ /**
18
+ * Selector matching a channel's own track — the element its gradient paints
19
+ * on — identified by carrying `data-slot="track"`. {@link channelSync}
20
+ * walks up from a thumb to the nearest ancestor matching this selector.
21
+ */
22
+ const CHANNEL_TRACK_SELECTOR = '[data-slot="track"]';
23
+ /**
24
+ * Prefix {@link colorChannelProperty} builds every channel's CSS custom
25
+ * property name from. Kept private so the naming scheme has exactly one
26
+ * source of truth, shared with whatever renders a track's initial gradient.
27
+ */
28
+ const COLOR_CHANNEL_PROPERTY_PREFIX = "--ui-color-slider-channel-";
29
+ /**
30
+ * Builds the CSS custom property name {@link channelSync} mirrors a given
31
+ * channel's settled value onto, shared with whatever renders a group's
32
+ * initial markup so both sides agree on the name without duplicating it.
33
+ *
34
+ * @param channel Channel name, matching a {@link COLOR_CHANNEL_ATTRIBUTE} value.
35
+ * @returns The full custom property name for `channel`.
36
+ * @example
37
+ * colorChannelProperty("h"); // "--ui-color-slider-channel-h"
38
+ */
39
+ export function colorChannelProperty(channel) {
40
+ return `${COLOR_CHANNEL_PROPERTY_PREFIX}${channel}`;
41
+ }
42
+ /** DOM event type dispatched by {@link channelSync} on its host every time a settled input reports every channel's value together. */
43
+ const COLOR_CHANNEL_CHANGE_EVENT = "ui:color-channel-change";
44
+ /**
45
+ * Dispatched on a ColorSlider group's host by {@link channelSync} every
46
+ * time any channel's thumb settles on a new value, carrying every
47
+ * channel's current value together so a consumer can compose the full color without reading each channel's own `<input>` itself.
48
+ */
49
+ export class ColorChannelChangeEvent extends Event {
50
+ /** Name of the channel whose thumb just fired the `input` event that triggered this report. */
51
+ channel;
52
+ /** Every channel's settled value, keyed by its own {@link COLOR_CHANNEL_ATTRIBUTE} name. */
53
+ values;
54
+ /**
55
+ * @param init The channel that just moved, and every channel's settled value at dispatch time.
56
+ */
57
+ constructor(init) {
58
+ super(COLOR_CHANNEL_CHANGE_EVENT, { bubbles: true });
59
+ this.channel = init.channel;
60
+ this.values = Object.freeze({ ...init.values });
61
+ }
62
+ }
63
+ /**
64
+ * Finds every channel thumb under `host`, keyed by its own
65
+ * {@link COLOR_CHANNEL_ATTRIBUTE} name.
66
+ *
67
+ * @param host Wrapping host the sibling ColorSlider channels render inside.
68
+ * @returns Every matched thumb, in document order, keyed by channel name.
69
+ */
70
+ function findChannelThumbs(host) {
71
+ let thumbs = new Map();
72
+ for (let thumb of host.querySelectorAll(`input[type="range"][${COLOR_CHANNEL_ATTRIBUTE}]`)) {
73
+ let channel = thumb.getAttribute(COLOR_CHANNEL_ATTRIBUTE);
74
+ if (channel)
75
+ thumbs.set(channel, thumb);
76
+ }
77
+ return thumbs;
78
+ }
79
+ /**
80
+ * Finds a channel's own track — the nearest ancestor of `thumb` matching
81
+ * {@link CHANNEL_TRACK_SELECTOR} — the element {@link channelSync} mirrors
82
+ * sibling values onto.
83
+ *
84
+ * @param thumb The channel's own native range thumb.
85
+ * @returns The matched track, or `null` when no ancestor carries the slot.
86
+ */
87
+ function findChannelTrack(thumb) {
88
+ return thumb.closest(CHANNEL_TRACK_SELECTOR);
89
+ }
90
+ /**
91
+ * Reads every channel's current settled value off its own thumb.
92
+ *
93
+ * @param thumbs Every channel thumb under a group's host, keyed by channel name.
94
+ * @returns Every channel's current value, keyed the same way.
95
+ */
96
+ function readChannelValues(thumbs) {
97
+ let values = {};
98
+ for (let [channel, thumb] of thumbs)
99
+ values[channel] = thumb.valueAsNumber;
100
+ return values;
101
+ }
102
+ /**
103
+ * Mirrors `values` onto every channel's own track, skipping `firedChannel`'s
104
+ * own track since its gradient never depends on its own value, and skipping
105
+ * each track's own channel within `values` since a gradient only reads its own siblings.
106
+ *
107
+ * @param thumbs Every channel thumb under a group's host, keyed by channel name.
108
+ * @param values Every channel's current settled value, keyed the same way.
109
+ * @param firedChannel Channel whose thumb just fired the triggering `input` event.
110
+ */
111
+ function writeOtherChannelProperties(thumbs, values, firedChannel) {
112
+ for (let [channel, thumb] of thumbs) {
113
+ if (channel === firedChannel)
114
+ continue;
115
+ let track = findChannelTrack(thumb);
116
+ if (!track)
117
+ continue;
118
+ for (let [otherChannel, value] of Object.entries(values)) {
119
+ if (otherChannel === channel)
120
+ continue;
121
+ track.style.setProperty(colorChannelProperty(otherChannel), String(value));
122
+ }
123
+ }
124
+ }
125
+ /**
126
+ * Keeps a group of sibling ColorSlider channel tracks painting a gradient
127
+ * that stays current with one another as each channel's thumb settles, by
128
+ * mirroring every settled value onto the others via {@link colorChannelProperty}.
129
+ *
130
+ * @returns A mixin descriptor for a ColorSlider group's wrapping host's `mix` prop.
131
+ * @example
132
+ * <div mix={channelSync()}>
133
+ * <div data-slot="track">
134
+ * <input type="range" data-channel="r" min={0} max={255} defaultValue={120} aria-label={t("colorSlider.red")} />
135
+ * </div>
136
+ * <div data-slot="track">
137
+ * <input type="range" data-channel="g" min={0} max={255} defaultValue={45} aria-label={t("colorSlider.green")} />
138
+ * </div>
139
+ * <div data-slot="track">
140
+ * <input type="range" data-channel="b" min={0} max={255} defaultValue={200} aria-label={t("colorSlider.blue")} />
141
+ * </div>
142
+ * </div>
143
+ */
144
+ export const channelSync = createMixin((handle) => {
145
+ let hostNode;
146
+ handle.addEventListener("insert", (event) => {
147
+ hostNode = event.node;
148
+ });
149
+ handle.addEventListener("remove", () => {
150
+ hostNode = undefined;
151
+ });
152
+ /** Mirrors every channel's settled value onto every other channel's track, then reports the full set. */
153
+ function handleChannelInput(target) {
154
+ if (!hostNode || !(target instanceof HTMLInputElement))
155
+ return;
156
+ let firedChannel = target.getAttribute(COLOR_CHANNEL_ATTRIBUTE);
157
+ if (firedChannel === null)
158
+ return;
159
+ let thumbs = findChannelThumbs(hostNode);
160
+ if (!thumbs.has(firedChannel))
161
+ return;
162
+ let values = readChannelValues(thumbs);
163
+ writeOtherChannelProperties(thumbs, values, firedChannel);
164
+ hostNode.dispatchEvent(new ColorChannelChangeEvent({ channel: firedChannel, values }));
165
+ }
166
+ return () => createElement(handle.element, {
167
+ mix: [on("input", (event) => handleChannelInput(event.target))],
168
+ });
169
+ });
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Live-updates a ColorField's paired swatch preview as the person typing
3
+ * into its text control lands on a value the chosen color notation actually
4
+ * accepts, reflecting every keystroke a script can observe that no CSS
5
+ * selector or HTML attribute can react to on its own.
6
+ *
7
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
8
+ * @copyright Sergio Xalambrí 2026
9
+ */
10
+ import type { MixinFactory } from "remix/ui";
11
+ /**
12
+ * Live-updates a ColorField's paired swatch preview as its text control's
13
+ * value changes, running each `input` event's value through `parseColor()`
14
+ * and writing successful parses onto the swatch found via {@link findSwatch}.
15
+ *
16
+ * @returns A mixin descriptor for a ColorField wrapping host's `mix` prop.
17
+ * @example
18
+ * <div mix={colorPreview()}>
19
+ * <input
20
+ * type="text"
21
+ * pattern="#[0-9a-fA-F]{6}"
22
+ * defaultValue="#3b82f6"
23
+ * aria-label={t("colorField.label")}
24
+ * />
25
+ * <ColorSwatch value="#3b82f6" />
26
+ * </div>
27
+ */
28
+ export declare const colorPreview: MixinFactory<HTMLElement>;