@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,288 @@
1
+ /**
2
+ * Pointer-driven resize for one handle of a Resizable panel group: turns a
3
+ * pointer press into a `ResizeSession`, feeds it pointer position along the
4
+ * group's axis, and mirrors solved panel sizes back as CSS custom properties.
5
+ *
6
+ * Why JS: redistributing space between flexible panels — honoring min/max
7
+ * constraints and cascading a shrink once a neighbor bottoms out — has no
8
+ * declarative equivalent for turning a pointer gesture into solved sizes.
9
+ * No-JS baseline: every panel renders at its default size and the boundary
10
+ * between them is fixed.
11
+ *
12
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
13
+ * @copyright Sergio Xalambrí 2026
14
+ */
15
+ import { createElement, createMixin, on } from "remix/ui";
16
+ import { isNewPrimaryPress } from "../utils/is-new-primary-press.js";
17
+ import { trackHostNode } from "./track-host-node.js";
18
+ /**
19
+ * Attribute a Resizable panel group's own host element carries.
20
+ * `resizeHandle()` walks up to the nearest ancestor carrying it to find the
21
+ * group to coordinate, so a nested group's handles never reach outside it.
22
+ */
23
+ export const RESIZABLE_GROUP_ATTRIBUTE = "data-resizable-group";
24
+ /**
25
+ * Attribute every panel in a Resizable group carries as a direct child of
26
+ * the group's host element. `resizeHandle()` reads matching direct children,
27
+ * in document order, as the panel list `ResizeSession`'s `panels` indexes by.
28
+ */
29
+ export const RESIZABLE_PANEL_ATTRIBUTE = "data-resizable-panel";
30
+ /**
31
+ * Attribute every handle in a Resizable group carries as a direct child of
32
+ * the group's host element. `resizeHandle()` reads matching direct children,
33
+ * in document order, to resolve which pair of panels its host sits between.
34
+ */
35
+ export const RESIZABLE_HANDLE_ATTRIBUTE = "data-resizable-handle";
36
+ /**
37
+ * Attribute a panel optionally carries to set the smallest percentage of the
38
+ * group's main-axis size it may shrink to, as a plain number (`"20"`, not
39
+ * `"20%"`). Omitted entirely, a panel is free to shrink to 0.
40
+ */
41
+ export const RESIZABLE_PANEL_MIN_ATTRIBUTE = "data-resizable-min";
42
+ /**
43
+ * Attribute a panel optionally carries to set the largest percentage of the
44
+ * group's main-axis size it may grow to, as a plain number (`"80"`, not
45
+ * `"80%"`). Omitted entirely, a panel is free to grow to 100.
46
+ */
47
+ export const RESIZABLE_PANEL_MAX_ATTRIBUTE = "data-resizable-max";
48
+ /**
49
+ * CSS custom property `resizeHandle()` writes on every panel with its
50
+ * current resolved size as a percentage (`"42.5%"`) of the group's
51
+ * main-axis size, letting a panel's own styles read it back directly.
52
+ */
53
+ export const RESIZABLE_PANEL_SIZE_PROPERTY = "--ui-resizable-panel-size";
54
+ /** DOM event type dispatched by {@link resizeHandle} on the panel group once a drag settles a new layout. */
55
+ const RESIZABLE_LAYOUT_CHANGE_EVENT = "ui:resizable-layout-change";
56
+ /**
57
+ * Dispatched on a Resizable group's host by {@link resizeHandle} once a
58
+ * drag ends by releasing over the handle, carrying every panel's settled
59
+ * size; a cancelled drag reverts the panels instead of dispatching this.
60
+ */
61
+ export class ResizableLayoutChangeEvent extends Event {
62
+ /** Every panel's settled size, min, and max, in group order. */
63
+ panels;
64
+ /**
65
+ * @param panels Every panel's settled state at the moment the drag ended.
66
+ */
67
+ constructor(panels) {
68
+ super(RESIZABLE_LAYOUT_CHANGE_EVENT, { bubbles: true });
69
+ this.panels = panels;
70
+ }
71
+ }
72
+ /**
73
+ * Finds the nearest enclosing panel group, identified by
74
+ * {@link RESIZABLE_GROUP_ATTRIBUTE}.
75
+ *
76
+ * @param node Handle element to search upward from.
77
+ * @returns The matched group, or `undefined` when `node` sits outside one.
78
+ */
79
+ function findGroup(node) {
80
+ return node.closest(`[${RESIZABLE_GROUP_ATTRIBUTE}]`) ?? undefined;
81
+ }
82
+ /**
83
+ * Reads every direct child of `groupNode` carrying `attribute`, in document
84
+ * order — the scoping rule every query in this module uses so a nested
85
+ * group's panels and handles never leak into an ancestor's coordination.
86
+ *
87
+ * @param groupNode Panel group element to read direct children of.
88
+ * @param attribute Attribute name identifying the child elements to collect.
89
+ * @returns The matched direct children, in document order.
90
+ */
91
+ function queryGroupChildren(groupNode, attribute) {
92
+ return Array.from(groupNode.querySelectorAll(`:scope > [${attribute}]`));
93
+ }
94
+ /**
95
+ * Reads a panel's current resolved size off {@link RESIZABLE_PANEL_SIZE_PROPERTY},
96
+ * falling back to `fallback` when the property is unset or holds a
97
+ * value that doesn't resolve to a finite number.
98
+ *
99
+ * @param node Panel element to read.
100
+ * @param fallback Size to use when the property is unset or unparsable.
101
+ */
102
+ function readPanelSize(node, fallback) {
103
+ let raw = getComputedStyle(node).getPropertyValue(RESIZABLE_PANEL_SIZE_PROPERTY).trim();
104
+ if (raw === "")
105
+ return fallback;
106
+ let value = Number(raw.replace(/%$/, ""));
107
+ return Number.isFinite(value) ? value : fallback;
108
+ }
109
+ /**
110
+ * Reads a panel's numeric constraint attribute (`min` or `max`), returning
111
+ * `undefined` when the attribute is absent or doesn't hold a finite number —
112
+ * letting `ResizeSession.start()` fall back to its own default in either case.
113
+ *
114
+ * @param node Panel element to read.
115
+ * @param attribute Constraint attribute to read off it.
116
+ */
117
+ function readPanelConstraint(node, attribute) {
118
+ let raw = node.getAttribute(attribute);
119
+ if (raw === null)
120
+ return undefined;
121
+ let value = Number(raw);
122
+ return Number.isFinite(value) ? value : undefined;
123
+ }
124
+ /**
125
+ * Builds the `ResizeSession.PanelInput` snapshot `start()` needs from a
126
+ * group's panel elements: id, size, and min/max each fall back to a
127
+ * default — a positional id, an even split, and `start()`'s own limits.
128
+ *
129
+ * @param panelNodes A group's panel elements, in document order.
130
+ * @returns The matching panel snapshot, in the same order.
131
+ */
132
+ function readPanelInputs(panelNodes) {
133
+ let evenSize = panelNodes.length > 0 ? 100 / panelNodes.length : 0;
134
+ return panelNodes.map((node, index) => ({
135
+ id: node.id || `panel-${index}`,
136
+ size: readPanelSize(node, evenSize),
137
+ min: readPanelConstraint(node, RESIZABLE_PANEL_MIN_ATTRIBUTE),
138
+ max: readPanelConstraint(node, RESIZABLE_PANEL_MAX_ATTRIBUTE),
139
+ }));
140
+ }
141
+ /**
142
+ * Reads the pointer coordinate `ResizeSession.move()` solves against,
143
+ * matching whichever axis the group resizes on: `clientX` for
144
+ * `"horizontal"`, `clientY` for `"vertical"`.
145
+ *
146
+ * @param event Pointer event to read a coordinate from.
147
+ * @param axis Axis the enclosing group resizes along.
148
+ */
149
+ function axisPointerPosition(event, axis) {
150
+ return axis === "horizontal" ? event.clientX : event.clientY;
151
+ }
152
+ /**
153
+ * Measures `groupNode`'s size along `axis`, in pixels — the unit
154
+ * `ResizeSession` converts pixel pointer deltas against to solve percentage
155
+ * sizes.
156
+ *
157
+ * @param groupNode Panel group element to measure.
158
+ * @param axis Axis the group resizes along.
159
+ */
160
+ function measureGroupSize(groupNode, axis) {
161
+ let rect = groupNode.getBoundingClientRect();
162
+ return axis === "horizontal" ? rect.width : rect.height;
163
+ }
164
+ /**
165
+ * Rounds a solved percentage to two decimal places before it's written to
166
+ * {@link RESIZABLE_PANEL_SIZE_PROPERTY}, so a repeating fraction from
167
+ * `ResizeSession`'s division doesn't land as a long floating-point string.
168
+ *
169
+ * @param value Percentage to round.
170
+ */
171
+ function roundPercent(value) {
172
+ return Math.round(value * 100) / 100;
173
+ }
174
+ /**
175
+ * Adds pointer-driven resizing to one handle of a Resizable panel group,
176
+ * sharing `session` with every other handle in the group; unmounting only
177
+ * cancels a handle's own in-progress drag, leaving a sibling's drag alone.
178
+ *
179
+ * @param axis Axis the enclosing group resizes along.
180
+ * @param session Resize session shared by every handle in the same panel group.
181
+ * @example
182
+ * let session = new ResizeSession();
183
+ * <div data-resizable-group>
184
+ * <section data-resizable-panel id="sidebar">Sidebar</section>
185
+ * <div
186
+ * data-resizable-handle
187
+ * role="separator"
188
+ * aria-orientation="vertical"
189
+ * aria-label={resizeSidebarLabel}
190
+ * tabIndex={0}
191
+ * mix={resizeHandle("horizontal", session)}
192
+ * />
193
+ * <section data-resizable-panel id="content">Content</section>
194
+ * </div>
195
+ */
196
+ export const resizeHandle = createMixin((handle) => {
197
+ let getHostNode = trackHostNode(handle);
198
+ let boundSession;
199
+ let activePointerId;
200
+ /** Mirrors `session`'s resolved sizes onto their panel elements, and this handle's adjacent panel onto its own ARIA value attributes. */
201
+ function syncLayout(session) {
202
+ let hostNode = getHostNode();
203
+ if (!hostNode)
204
+ return;
205
+ let groupNode = findGroup(hostNode);
206
+ if (!groupNode)
207
+ return;
208
+ let panels = session.panels;
209
+ let panelNodes = queryGroupChildren(groupNode, RESIZABLE_PANEL_ATTRIBUTE);
210
+ for (let index = 0; index < panelNodes.length; index++) {
211
+ let panel = panels[index];
212
+ let panelNode = panelNodes[index];
213
+ if (panel && panelNode) {
214
+ panelNode.style.setProperty(RESIZABLE_PANEL_SIZE_PROPERTY, `${roundPercent(panel.size)}%`);
215
+ }
216
+ }
217
+ let handleNodes = queryGroupChildren(groupNode, RESIZABLE_HANDLE_ATTRIBUTE);
218
+ let handleIndex = handleNodes.indexOf(hostNode);
219
+ let adjacentPanel = handleIndex === -1 ? undefined : panels[handleIndex];
220
+ if (!adjacentPanel)
221
+ return;
222
+ hostNode.setAttribute("aria-valuenow", String(Math.round(adjacentPanel.size)));
223
+ hostNode.setAttribute("aria-valuemin", String(Math.round(adjacentPanel.min)));
224
+ hostNode.setAttribute("aria-valuemax", String(Math.round(adjacentPanel.max)));
225
+ }
226
+ return (axis, session) => {
227
+ if (boundSession !== session) {
228
+ boundSession = session;
229
+ session.addEventListener("change", () => syncLayout(session), { signal: handle.signal });
230
+ handle.signal.addEventListener("abort", () => {
231
+ if (activePointerId !== undefined)
232
+ session.cancel();
233
+ });
234
+ }
235
+ return createElement(handle.element, {
236
+ mix: [
237
+ on("pointerdown", (event) => {
238
+ if (!isNewPrimaryPress(event, activePointerId))
239
+ return;
240
+ let hostNode = getHostNode();
241
+ if (!hostNode || session.isActive)
242
+ return;
243
+ let groupNode = findGroup(hostNode);
244
+ if (!groupNode)
245
+ return;
246
+ let panelNodes = queryGroupChildren(groupNode, RESIZABLE_PANEL_ATTRIBUTE);
247
+ let handleNodes = queryGroupChildren(groupNode, RESIZABLE_HANDLE_ATTRIBUTE);
248
+ let handleIndex = handleNodes.indexOf(hostNode);
249
+ if (handleIndex === -1 || panelNodes.length < 2)
250
+ return;
251
+ activePointerId = event.pointerId;
252
+ hostNode.setPointerCapture(event.pointerId);
253
+ session.start({
254
+ handleIndex,
255
+ panels: readPanelInputs(panelNodes),
256
+ pointerPosition: axisPointerPosition(event, axis),
257
+ groupSize: measureGroupSize(groupNode, axis),
258
+ });
259
+ }),
260
+ on("pointermove", (event) => {
261
+ if (event.pointerId !== activePointerId || !session.isActive)
262
+ return;
263
+ session.move(axisPointerPosition(event, axis));
264
+ }),
265
+ on("pointerup", (event) => {
266
+ let hostNode = getHostNode();
267
+ if (event.pointerId !== activePointerId || !hostNode)
268
+ return;
269
+ activePointerId = undefined;
270
+ session.end();
271
+ findGroup(hostNode)?.dispatchEvent(new ResizableLayoutChangeEvent(session.panels));
272
+ }),
273
+ on("pointercancel", (event) => {
274
+ if (event.pointerId !== activePointerId)
275
+ return;
276
+ activePointerId = undefined;
277
+ session.cancel();
278
+ }),
279
+ on("keydown", (event) => {
280
+ if (event.key !== "Escape" || activePointerId === undefined)
281
+ return;
282
+ activePointerId = undefined;
283
+ session.cancel();
284
+ }),
285
+ ],
286
+ });
287
+ };
288
+ });
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Press-and-hold repeat for a NumberField group's increment/decrement
3
+ * buttons, calling the field's native `stepUp()`/`stepDown()` on an
4
+ * interval for as long as a button stays pressed. `stepUp()`/`stepDown()`
5
+ * are script-only with no native repeat semantics on `<button>`; without
6
+ * JS the input keeps its native spinner arrows and arrow-key stepping.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ /**
12
+ * Direction a single step moves a NumberField's value: `"increment"` raises
13
+ * it, `"decrement"` lowers it.
14
+ */
15
+ export type NumberFieldStepDirection = "increment" | "decrement";
16
+ /**
17
+ * Custom Invoker Command an increment button declares (`command="--step-up"`
18
+ * `commandfor` pointing at the group's number input), read back by
19
+ * `stepper()` to call `stepUp()` on the matching input.
20
+ */
21
+ export declare const NUMBER_FIELD_STEP_UP_COMMAND = "--step-up";
22
+ /**
23
+ * Custom Invoker Command a decrement button declares (`command="--step-down"`
24
+ * `commandfor` pointing at the group's number input), read back by
25
+ * `stepper()` to call `stepDown()` on the matching input.
26
+ */
27
+ export declare const NUMBER_FIELD_STEP_DOWN_COMMAND = "--step-down";
28
+ /**
29
+ * Event type `stepper()` dispatches on the number input after every
30
+ * completed step, whether triggered by a single activation or by one tick of
31
+ * hold-to-repeat.
32
+ */
33
+ export declare const NUMBER_FIELD_STEP_EVENT: "ui:number-field-step";
34
+ declare global {
35
+ interface HTMLElementEventMap {
36
+ [NUMBER_FIELD_STEP_EVENT]: NumberFieldStepEvent;
37
+ }
38
+ }
39
+ /**
40
+ * Dispatched on the number input immediately after `stepper()` applies a
41
+ * step, carrying the direction and freshly stepped value so a consumer can
42
+ * react without diffing `input`/`change` events against the prior value.
43
+ */
44
+ export declare class NumberFieldStepEvent extends Event {
45
+ /** Which direction the value just moved. */
46
+ readonly direction: NumberFieldStepDirection;
47
+ /** The input's `valueAsNumber` immediately after the step. */
48
+ readonly value: number;
49
+ /**
50
+ * @param direction Which direction the value just moved.
51
+ * @param value The input's `valueAsNumber` immediately after the step.
52
+ */
53
+ constructor(direction: NumberFieldStepDirection, value: number);
54
+ }
55
+ /**
56
+ * Options accepted by {@link stepper} to tune its hold-to-repeat timing.
57
+ */
58
+ export interface StepperOptions {
59
+ /** Milliseconds a step button must stay pressed before hold-repeat begins. Defaults to {@link DEFAULT_HOLD_DELAY_MS}. */
60
+ holdDelayMs?: number;
61
+ /** Milliseconds between repeated steps once hold-repeat has begun. Defaults to {@link DEFAULT_HOLD_INTERVAL_MS}. */
62
+ holdIntervalMs?: number;
63
+ }
64
+ /**
65
+ * Adds press-and-hold repeat to a NumberField group's Invoker-Command
66
+ * increment/decrement buttons. The trailing click after a hold-repeat
67
+ * gesture is absorbed so it doesn't add one extra step atop the repeat.
68
+ *
69
+ * @param options Hold-to-repeat timing overrides.
70
+ * @example
71
+ * <div role="group" mix={[stepper()]}>
72
+ * <button type="button" command={NUMBER_FIELD_STEP_DOWN_COMMAND} commandfor="quantity" aria-label={decrementLabel}>
73
+ * <MinusIcon />
74
+ * </button>
75
+ * <input id="quantity" type="number" min={0} max={99} defaultValue={1} />
76
+ * <button type="button" command={NUMBER_FIELD_STEP_UP_COMMAND} commandfor="quantity" aria-label={incrementLabel}>
77
+ * <PlusIcon />
78
+ * </button>
79
+ * </div>
80
+ */
81
+ export declare const stepper: import("remix/ui").MixinFactory<HTMLElement, [options?: StepperOptions | undefined], import("remix/ui").ElementProps>;
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Press-and-hold repeat for a NumberField group's increment/decrement
3
+ * buttons, calling the field's native `stepUp()`/`stepDown()` on an
4
+ * interval for as long as a button stays pressed. `stepUp()`/`stepDown()`
5
+ * are script-only with no native repeat semantics on `<button>`; without
6
+ * JS the input keeps its native spinner arrows and arrow-key stepping.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { createElement, createMixin, on } from "remix/ui";
12
+ import { asCommandEvent } from "../utils/command-event.js";
13
+ /**
14
+ * Custom Invoker Command an increment button declares (`command="--step-up"`
15
+ * `commandfor` pointing at the group's number input), read back by
16
+ * `stepper()` to call `stepUp()` on the matching input.
17
+ */
18
+ export const NUMBER_FIELD_STEP_UP_COMMAND = "--step-up";
19
+ /**
20
+ * Custom Invoker Command a decrement button declares (`command="--step-down"`
21
+ * `commandfor` pointing at the group's number input), read back by
22
+ * `stepper()` to call `stepDown()` on the matching input.
23
+ */
24
+ export const NUMBER_FIELD_STEP_DOWN_COMMAND = "--step-down";
25
+ /**
26
+ * Event type `stepper()` dispatches on the number input after every
27
+ * completed step, whether triggered by a single activation or by one tick of
28
+ * hold-to-repeat.
29
+ */
30
+ export const NUMBER_FIELD_STEP_EVENT = "ui:number-field-step";
31
+ /**
32
+ * Dispatched on the number input immediately after `stepper()` applies a
33
+ * step, carrying the direction and freshly stepped value so a consumer can
34
+ * react without diffing `input`/`change` events against the prior value.
35
+ */
36
+ export class NumberFieldStepEvent extends Event {
37
+ /** Which direction the value just moved. */
38
+ direction;
39
+ /** The input's `valueAsNumber` immediately after the step. */
40
+ value;
41
+ /**
42
+ * @param direction Which direction the value just moved.
43
+ * @param value The input's `valueAsNumber` immediately after the step.
44
+ */
45
+ constructor(direction, value) {
46
+ super(NUMBER_FIELD_STEP_EVENT, { bubbles: true });
47
+ this.direction = direction;
48
+ this.value = value;
49
+ }
50
+ }
51
+ /** Milliseconds a step button must stay pressed before hold-repeat begins. */
52
+ const DEFAULT_HOLD_DELAY_MS = 400;
53
+ /** Milliseconds between repeated steps once hold-repeat has begun. */
54
+ const DEFAULT_HOLD_INTERVAL_MS = 60;
55
+ /**
56
+ * Resolves which direction a step button's own custom command names,
57
+ * returning `undefined` for a command string that isn't one of the two
58
+ * `stepper()` recognizes, so unrelated Invoker Command buttons are ignored.
59
+ *
60
+ * @param command The `command` attribute value read off a button, or a
61
+ * dispatched `CommandEvent`'s `command` property.
62
+ */
63
+ function directionForCommand(command) {
64
+ if (command === NUMBER_FIELD_STEP_UP_COMMAND)
65
+ return "increment";
66
+ if (command === NUMBER_FIELD_STEP_DOWN_COMMAND)
67
+ return "decrement";
68
+ return undefined;
69
+ }
70
+ /**
71
+ * Finds the number input a step button's `commandfor` targets, preferring
72
+ * the live `commandForElement` reference and falling back to an `id` lookup
73
+ * for runtimes that haven't reflected the attribute onto that IDL property.
74
+ *
75
+ * @param button A step button found inside the group.
76
+ */
77
+ function resolveStepTarget(button) {
78
+ if (button.commandForElement instanceof HTMLInputElement)
79
+ return button.commandForElement;
80
+ let commandForId = button.getAttribute("commandfor");
81
+ if (!commandForId)
82
+ return undefined;
83
+ let fallbackTarget = document.getElementById(commandForId);
84
+ return fallbackTarget instanceof HTMLInputElement ? fallbackTarget : undefined;
85
+ }
86
+ /**
87
+ * Steps a number input one unit in the given direction using its native
88
+ * `stepUp()`/`stepDown()` method, then dispatches the `input`, `change`, and
89
+ * {@link NumberFieldStepEvent} events those methods don't fire on their own.
90
+ *
91
+ * @param input The number input to step.
92
+ * @param direction Which direction to step it.
93
+ * @returns Whether the value actually changed; `false` when the input is
94
+ * disabled, read-only, or already at the boundary the direction would cross.
95
+ */
96
+ function applyStep(input, direction) {
97
+ if (input.disabled || input.readOnly)
98
+ return false;
99
+ let previousValue = input.value;
100
+ try {
101
+ if (direction === "increment")
102
+ input.stepUp();
103
+ else
104
+ input.stepDown();
105
+ }
106
+ catch {
107
+ return false;
108
+ }
109
+ if (input.value === previousValue)
110
+ return false;
111
+ input.dispatchEvent(new Event("input", { bubbles: true }));
112
+ input.dispatchEvent(new Event("change", { bubbles: true }));
113
+ input.dispatchEvent(new NumberFieldStepEvent(direction, input.valueAsNumber));
114
+ return true;
115
+ }
116
+ /**
117
+ * Adds press-and-hold repeat to a NumberField group's Invoker-Command
118
+ * increment/decrement buttons. The trailing click after a hold-repeat
119
+ * gesture is absorbed so it doesn't add one extra step atop the repeat.
120
+ *
121
+ * @param options Hold-to-repeat timing overrides.
122
+ * @example
123
+ * <div role="group" mix={[stepper()]}>
124
+ * <button type="button" command={NUMBER_FIELD_STEP_DOWN_COMMAND} commandfor="quantity" aria-label={decrementLabel}>
125
+ * <MinusIcon />
126
+ * </button>
127
+ * <input id="quantity" type="number" min={0} max={99} defaultValue={1} />
128
+ * <button type="button" command={NUMBER_FIELD_STEP_UP_COMMAND} commandfor="quantity" aria-label={incrementLabel}>
129
+ * <PlusIcon />
130
+ * </button>
131
+ * </div>
132
+ */
133
+ export const stepper = createMixin((handle) => {
134
+ let holdDelayMs = DEFAULT_HOLD_DELAY_MS;
135
+ let holdIntervalMs = DEFAULT_HOLD_INTERVAL_MS;
136
+ let holdDelayTimerId = 0;
137
+ let holdRepeatTimerId = 0;
138
+ let repeatFiredForGesture = false;
139
+ /** Cancels any pending delay or in-progress repeat timer for the current press. */
140
+ function clearHoldTimers() {
141
+ window.clearTimeout(holdDelayTimerId);
142
+ window.clearInterval(holdRepeatTimerId);
143
+ holdDelayTimerId = 0;
144
+ holdRepeatTimerId = 0;
145
+ }
146
+ handle.signal.addEventListener("abort", clearHoldTimers);
147
+ return (options) => {
148
+ holdDelayMs = options?.holdDelayMs ?? DEFAULT_HOLD_DELAY_MS;
149
+ holdIntervalMs = options?.holdIntervalMs ?? DEFAULT_HOLD_INTERVAL_MS;
150
+ return createElement(handle.element, {
151
+ mix: [
152
+ on("pointerdown", (event) => {
153
+ if (!(event.target instanceof Element))
154
+ return;
155
+ let button = event.target.closest("button[command]");
156
+ if (!(button instanceof HTMLButtonElement))
157
+ return;
158
+ let direction = directionForCommand(button.getAttribute("command"));
159
+ if (!direction)
160
+ return;
161
+ let input = resolveStepTarget(button);
162
+ if (!input)
163
+ return;
164
+ clearHoldTimers();
165
+ repeatFiredForGesture = false;
166
+ holdDelayTimerId = window.setTimeout(() => {
167
+ repeatFiredForGesture = applyStep(input, direction) || repeatFiredForGesture;
168
+ holdRepeatTimerId = window.setInterval(() => {
169
+ let stepped = applyStep(input, direction);
170
+ repeatFiredForGesture = repeatFiredForGesture || stepped;
171
+ if (!stepped)
172
+ clearHoldTimers();
173
+ }, holdIntervalMs);
174
+ }, holdDelayMs);
175
+ }),
176
+ on("pointerup", clearHoldTimers),
177
+ on("pointercancel", clearHoldTimers),
178
+ on("command", (event) => {
179
+ let commandEvent = asCommandEvent(event);
180
+ let direction = directionForCommand(commandEvent.command);
181
+ if (!direction)
182
+ return;
183
+ if (repeatFiredForGesture) {
184
+ repeatFiredForGesture = false;
185
+ return;
186
+ }
187
+ if (!(commandEvent.target instanceof HTMLInputElement))
188
+ return;
189
+ applyStep(commandEvent.target, direction);
190
+ }, true),
191
+ ],
192
+ });
193
+ };
194
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Delegated arrow-key activation for a Tabs list: a single `keydown`
3
+ * listener on the tablist container reads the shared `remix/ui/tabs`
4
+ * context to move the roving tab stop, instead of binding one listener
5
+ * per tab. Needed because the WAI-ARIA tabs keyboard pattern has no
6
+ * HTML/CSS equivalent; without JS every tab stays reachable through Tab.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ /**
12
+ * Options accepted by {@link tabKeys}. Reserved for future configuration;
13
+ * the mixin needs no per-call arguments today.
14
+ */
15
+ export interface TabKeysOptions {
16
+ }
17
+ /**
18
+ * Adds delegated arrow-key activation to a Tabs list, adapting the shared
19
+ * `remix/ui/tabs` context instead of tracking tab order itself. Capturing
20
+ * and stopping handled keys pre-empts a same-key `tab()` binding per tab.
21
+ *
22
+ * @example
23
+ * <tabs.Context defaultActiveTab="overview">
24
+ * <div role="tablist" mix={tabKeys()}>
25
+ * <button mix={tabs.tab({ name: "overview" })}>Overview</button>
26
+ * <button mix={tabs.tab({ name: "activity" })}>Activity</button>
27
+ * </div>
28
+ * </tabs.Context>
29
+ */
30
+ export declare const tabKeys: import("remix/ui").MixinFactory<HTMLElement, [options?: TabKeysOptions | undefined], import("remix/ui").ElementProps>;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Delegated arrow-key activation for a Tabs list: a single `keydown`
3
+ * listener on the tablist container reads the shared `remix/ui/tabs`
4
+ * context to move the roving tab stop, instead of binding one listener
5
+ * per tab. Needed because the WAI-ARIA tabs keyboard pattern has no
6
+ * HTML/CSS equivalent; without JS every tab stays reachable through Tab.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { createElement, createMixin, on } from "remix/ui";
12
+ import * as tabs from "remix/ui/tabs/primitives";
13
+ /**
14
+ * Adds delegated arrow-key activation to a Tabs list, adapting the shared
15
+ * `remix/ui/tabs` context instead of tracking tab order itself. Capturing
16
+ * and stopping handled keys pre-empts a same-key `tab()` binding per tab.
17
+ *
18
+ * @example
19
+ * <tabs.Context defaultActiveTab="overview">
20
+ * <div role="tablist" mix={tabKeys()}>
21
+ * <button mix={tabs.tab({ name: "overview" })}>Overview</button>
22
+ * <button mix={tabs.tab({ name: "activity" })}>Activity</button>
23
+ * </div>
24
+ * </tabs.Context>
25
+ */
26
+ export const tabKeys = createMixin((handle) => {
27
+ let context = handle.context.get(tabs.Context);
28
+ return () => createElement(handle.element, {
29
+ mix: [
30
+ on("keydown", (event) => {
31
+ if (context.disabled)
32
+ return;
33
+ let activeTab = context.activeTab;
34
+ if (activeTab === null)
35
+ return;
36
+ switch (event.key) {
37
+ case "ArrowRight":
38
+ case "ArrowDown":
39
+ event.preventDefault();
40
+ event.stopPropagation();
41
+ context.activateTabInDirection(activeTab, "next");
42
+ break;
43
+ case "ArrowLeft":
44
+ case "ArrowUp":
45
+ event.preventDefault();
46
+ event.stopPropagation();
47
+ context.activateTabInDirection(activeTab, "previous");
48
+ break;
49
+ case "Home":
50
+ event.preventDefault();
51
+ event.stopPropagation();
52
+ context.activateTabInDirection(activeTab, "first");
53
+ break;
54
+ case "End":
55
+ event.preventDefault();
56
+ event.stopPropagation();
57
+ context.activateTabInDirection(activeTab, "last");
58
+ break;
59
+ }
60
+ }, true),
61
+ ],
62
+ });
63
+ });