@justanarthur/modo-ui 0.6.0-canary.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (619) hide show
  1. package/README.md +197 -643
  2. package/blocks/sidebar-app/examples.mdx +2 -2
  3. package/blocks/sidebar-app/index.tsx +20 -7
  4. package/blocks/sidebar-app/inset-topbar.tsx +3 -8
  5. package/blocks/sidebar-app/menu-grid.ts +8 -18
  6. package/blocks/sidebar-app/nav-data.ts +1 -1
  7. package/blocks/sidebar-app/search-field.tsx +8 -15
  8. package/blocks/sidebar-app/thread-page.tsx +58 -0
  9. package/blocks/sidebar-app/user-footer.tsx +8 -15
  10. package/blocks/sidebar-app/workspace-header.tsx +9 -28
  11. package/components/AI/input-message/examples.mdx +37 -33
  12. package/components/AI/input-message/file-preview-tile.tsx +59 -0
  13. package/components/AI/input-message/file-thumbnail.tsx +26 -53
  14. package/components/AI/input-message/index.tsx +362 -1122
  15. package/components/AI/input-message/input-message.css +25 -0
  16. package/components/AI/input-message/queued-row.tsx +102 -0
  17. package/components/AI/input-message/shared.ts +38 -0
  18. package/components/AI/input-message/suggestion-row.tsx +64 -0
  19. package/components/AI/input-message/use-composer-files.ts +142 -0
  20. package/components/AI/input-message/use-history-nav.ts +60 -0
  21. package/components/AI/input-message/use-message-queue.ts +108 -0
  22. package/components/AI/input-message/use-region-height.ts +34 -0
  23. package/components/AI/thinking-indicator/index.tsx +9 -31
  24. package/components/accordion/accordion-content.tsx +217 -0
  25. package/components/accordion/accordion-context.tsx +118 -0
  26. package/components/accordion/accordion-group.tsx +215 -0
  27. package/components/accordion/examples.mdx +64 -132
  28. package/components/accordion/index.tsx +127 -891
  29. package/components/avatar/examples.mdx +2 -2
  30. package/components/avatar/index.tsx +40 -34
  31. package/components/badge/change-demo.tsx +2 -0
  32. package/components/badge/examples.mdx +16 -34
  33. package/components/badge/index.tsx +31 -69
  34. package/components/badge/variants.ts +5 -30
  35. package/components/button/examples.mdx +79 -94
  36. package/components/button/index.tsx +97 -188
  37. package/components/button/loading-demo.tsx +2 -0
  38. package/components/button/variants.ts +12 -117
  39. package/components/card/card-group.tsx +184 -0
  40. package/components/card/card-media.tsx +207 -0
  41. package/components/card/card-parts.tsx +179 -0
  42. package/components/card/examples.mdx +91 -143
  43. package/components/card/index.tsx +190 -881
  44. package/components/copy/examples.mdx +29 -67
  45. package/components/copy/index.tsx +58 -285
  46. package/components/inputs/checkbox/examples.mdx +22 -39
  47. package/components/inputs/checkbox/index.tsx +103 -255
  48. package/components/inputs/checkbox/select-all-demo.tsx +8 -6
  49. package/components/inputs/color-picker/channel-sliders.tsx +70 -0
  50. package/components/inputs/color-picker/color-input.tsx +387 -0
  51. package/components/inputs/color-picker/{variants.ts → color-math.ts} +22 -57
  52. package/components/inputs/color-picker/context.ts +11 -0
  53. package/components/inputs/color-picker/examples.mdx +20 -59
  54. package/components/inputs/color-picker/format-menu.tsx +212 -0
  55. package/components/inputs/color-picker/index.tsx +190 -1776
  56. package/components/inputs/color-picker/inputs-row.tsx +196 -0
  57. package/components/inputs/color-picker/popover.tsx +161 -0
  58. package/components/inputs/color-picker/saturation-square.tsx +167 -0
  59. package/components/inputs/color-picker/swatches.tsx +178 -0
  60. package/components/inputs/combobox/context.ts +90 -0
  61. package/components/inputs/combobox/examples.mdx +103 -206
  62. package/components/inputs/combobox/fields.tsx +328 -0
  63. package/components/inputs/combobox/index.tsx +155 -1310
  64. package/components/inputs/combobox/list.tsx +415 -0
  65. package/components/inputs/combobox/remote-demo.tsx +70 -74
  66. package/components/inputs/date-time/calendar/examples.mdx +0 -11
  67. package/components/inputs/date-time/calendar/index.tsx +32 -59
  68. package/components/inputs/date-time/calendar/use-month-window.ts +35 -32
  69. package/components/inputs/date-time/date-picker/examples.mdx +59 -155
  70. package/components/inputs/date-time/date-picker/index.tsx +186 -370
  71. package/components/inputs/date-time/date-picker/masked-date-input.tsx +105 -247
  72. package/components/inputs/date-time/date-range-picker/examples.mdx +6 -62
  73. package/components/inputs/date-time/date-range-picker/index.tsx +105 -404
  74. package/components/inputs/date-time/date-value.ts +37 -0
  75. package/components/inputs/date-time/day-rules.ts +22 -0
  76. package/components/inputs/date-time/duration-picker/examples.mdx +0 -24
  77. package/components/inputs/date-time/duration-picker/index.tsx +50 -140
  78. package/components/inputs/date-time/month-picker/examples.mdx +0 -29
  79. package/components/inputs/date-time/month-picker/index.tsx +48 -132
  80. package/components/inputs/date-time/picker-shell.tsx +226 -347
  81. package/components/inputs/date-time/time-columns.tsx +11 -15
  82. package/components/inputs/date-time/time-picker/examples.mdx +0 -31
  83. package/components/inputs/date-time/time-picker/index.tsx +37 -118
  84. package/components/inputs/field/examples.mdx +81 -39
  85. package/components/inputs/field/index.tsx +113 -103
  86. package/components/inputs/file-dropzone/examples.mdx +23 -24
  87. package/components/inputs/file-dropzone/file-row.tsx +20 -21
  88. package/components/inputs/file-dropzone/index.tsx +130 -129
  89. package/components/inputs/file-dropzone/upload-demo.tsx +22 -18
  90. package/components/inputs/file-dropzone/variants.ts +3 -1
  91. package/components/inputs/input/examples.mdx +19 -74
  92. package/components/inputs/input/index.tsx +86 -149
  93. package/components/inputs/input/password-demo.tsx +5 -5
  94. package/components/inputs/label/examples.mdx +19 -26
  95. package/components/inputs/label/index.tsx +21 -34
  96. package/components/inputs/number-input/examples.mdx +63 -36
  97. package/components/inputs/number-input/index.tsx +62 -57
  98. package/components/inputs/radio/examples.mdx +24 -39
  99. package/components/inputs/radio/index.tsx +125 -328
  100. package/components/inputs/search/examples.mdx +3 -3
  101. package/components/inputs/search/index.tsx +46 -39
  102. package/components/inputs/select/examples.mdx +76 -167
  103. package/components/inputs/select/index.tsx +252 -776
  104. package/components/inputs/slider/comfortable.tsx +524 -0
  105. package/components/inputs/slider/compact.tsx +690 -0
  106. package/components/inputs/slider/examples.mdx +9 -35
  107. package/components/inputs/slider/geometry.ts +88 -0
  108. package/components/inputs/slider/index.tsx +65 -1796
  109. package/components/inputs/slider/value-display.tsx +184 -0
  110. package/components/inputs/switch/examples.mdx +31 -33
  111. package/components/inputs/switch/index.tsx +55 -107
  112. package/components/inputs/textarea/examples.mdx +23 -61
  113. package/components/inputs/textarea/index.tsx +21 -99
  114. package/components/navigation/navigation-menu/content.tsx +76 -0
  115. package/components/navigation/navigation-menu/context.ts +34 -0
  116. package/components/navigation/navigation-menu/examples.mdx +21 -84
  117. package/components/navigation/navigation-menu/index.tsx +139 -639
  118. package/components/navigation/navigation-menu/item.tsx +47 -0
  119. package/components/navigation/navigation-menu/link.tsx +104 -0
  120. package/components/navigation/navigation-menu/list.tsx +86 -0
  121. package/components/navigation/navigation-menu/trigger.tsx +78 -0
  122. package/components/navigation/navigation-menu/use-dom-rows.ts +56 -0
  123. package/components/navigation/pagination/examples.mdx +25 -34
  124. package/components/navigation/pagination/index.tsx +75 -153
  125. package/components/navigation/sidebar/examples.mdx +17 -23
  126. package/components/navigation/sidebar/index.tsx +59 -119
  127. package/components/navigation/sidebar/menu-scope.tsx +439 -0
  128. package/components/navigation/sidebar/row-label.tsx +61 -0
  129. package/components/navigation/sidebar/sidebar-context.tsx +71 -0
  130. package/components/navigation/sidebar/sidebar-group.tsx +299 -0
  131. package/components/navigation/sidebar/sidebar-menu-actions.tsx +209 -0
  132. package/components/navigation/sidebar/sidebar-menu-button.tsx +214 -0
  133. package/components/navigation/sidebar/sidebar-menu-item.tsx +207 -0
  134. package/components/navigation/sidebar/sidebar-menu-sub.tsx +180 -0
  135. package/components/navigation/sidebar/sidebar-parts.tsx +94 -0
  136. package/components/navigation/sidebar/sidebar-provider.tsx +248 -0
  137. package/components/navigation/sidebar/sidebar-rail.tsx +206 -0
  138. package/components/navigation/sidebar/sidebar-shell.tsx +180 -0
  139. package/components/navigation/sidebar/sidebar-shortcut.tsx +101 -0
  140. package/components/navigation/sidebar/sidebar.css +7 -11
  141. package/components/navigation/sidebar/use-measured-collapse.ts +62 -0
  142. package/components/navigation/tabs/context.ts +45 -0
  143. package/components/navigation/tabs/examples.mdx +63 -17
  144. package/components/navigation/tabs/index.tsx +82 -434
  145. package/components/navigation/tabs/item.tsx +161 -0
  146. package/components/navigation/tabs/list.tsx +143 -0
  147. package/components/overlays/alert-dialog/examples.mdx +2 -36
  148. package/components/overlays/alert-dialog/index.tsx +76 -90
  149. package/components/overlays/alert-dialog/pending-demo.tsx +3 -1
  150. package/components/overlays/command/index.tsx +28 -59
  151. package/components/overlays/context-menu/examples.mdx +58 -4
  152. package/components/overlays/context-menu/index.tsx +77 -221
  153. package/components/overlays/dialog/examples.mdx +8 -31
  154. package/components/overlays/dialog/index.tsx +81 -261
  155. package/components/overlays/dropdown/dropdown-search.tsx +33 -98
  156. package/components/overlays/dropdown/examples.mdx +77 -363
  157. package/components/overlays/dropdown/index.tsx +114 -1010
  158. package/components/overlays/dropdown/menu-item.tsx +98 -382
  159. package/components/overlays/dropdown/menu-popup.tsx +294 -0
  160. package/components/overlays/dropdown/panel-state.ts +176 -0
  161. package/components/overlays/dropdown/submenu.tsx +170 -0
  162. package/components/overlays/popover/anchored-demo.tsx +22 -13
  163. package/components/overlays/popover/examples.mdx +16 -65
  164. package/components/overlays/popover/index.tsx +93 -137
  165. package/components/overlays/preview-card/examples.mdx +4 -4
  166. package/components/overlays/preview-card/index.tsx +48 -103
  167. package/components/overlays/sheet/examples.mdx +0 -12
  168. package/components/overlays/sheet/index.tsx +44 -129
  169. package/components/overlays/toast/examples.mdx +33 -25
  170. package/components/overlays/toast/index.tsx +56 -203
  171. package/components/overlays/toast/manager.ts +63 -119
  172. package/components/overlays/tooltip/examples.mdx +6 -12
  173. package/components/overlays/tooltip/index.tsx +124 -264
  174. package/components/progress/index.tsx +24 -30
  175. package/components/progress/progress.css +6 -28
  176. package/components/progress/step-demo.tsx +2 -0
  177. package/components/table/context.ts +49 -0
  178. package/components/table/examples.mdx +40 -72
  179. package/components/table/head.tsx +105 -0
  180. package/components/table/index.tsx +73 -458
  181. package/components/table/parts.tsx +188 -0
  182. package/components/table/sort-demo.tsx +21 -30
  183. package/dist/base.css +141 -122
  184. package/dist/blocks/sidebar-app/index.d.ts +10 -2
  185. package/dist/blocks/sidebar-app/index.js +49 -40
  186. package/dist/components/AI/input-message/index.d.ts +22 -19
  187. package/dist/components/AI/input-message/index.js +30 -23
  188. package/dist/components/AI/thinking-indicator/index.d.ts +2 -0
  189. package/dist/components/AI/thinking-indicator/index.js +10 -9
  190. package/dist/components/accordion/index.d.ts +52 -85
  191. package/dist/components/accordion/index.js +25 -19
  192. package/dist/components/avatar/index.d.ts +10 -10
  193. package/dist/components/avatar/index.js +9 -8
  194. package/dist/components/badge/index.d.ts +11 -18
  195. package/dist/components/badge/index.js +9 -9
  196. package/dist/components/badge/variants.d.ts +2 -9
  197. package/dist/components/badge/variants.js +3 -5
  198. package/dist/components/button/index.d.ts +36 -60
  199. package/dist/components/button/index.js +12 -9
  200. package/dist/components/button/variants.d.ts +3 -34
  201. package/dist/components/button/variants.js +2 -4
  202. package/dist/components/card/index.d.ts +163 -108
  203. package/dist/components/card/index.js +30 -21
  204. package/dist/components/copy/index.d.ts +10 -41
  205. package/dist/components/copy/index.js +18 -15
  206. package/dist/components/inputs/checkbox/index.d.ts +25 -25
  207. package/dist/components/inputs/checkbox/index.js +22 -18
  208. package/dist/components/inputs/color-picker/index.d.ts +65 -53
  209. package/dist/components/inputs/color-picker/index.js +35 -29
  210. package/dist/components/inputs/combobox/index.d.ts +147 -152
  211. package/dist/components/inputs/combobox/index.js +31 -29
  212. package/dist/components/inputs/date-time/calendar/index.d.ts +18 -24
  213. package/dist/components/inputs/date-time/calendar/index.js +17 -15
  214. package/dist/components/inputs/date-time/date-picker/index.d.ts +52 -96
  215. package/dist/components/inputs/date-time/date-picker/index.js +42 -35
  216. package/dist/components/inputs/date-time/date-range-picker/index.d.ts +48 -108
  217. package/dist/components/inputs/date-time/date-range-picker/index.js +40 -35
  218. package/dist/components/inputs/date-time/duration-picker/index.d.ts +21 -67
  219. package/dist/components/inputs/date-time/duration-picker/index.js +39 -33
  220. package/dist/components/inputs/date-time/month-picker/index.d.ts +18 -61
  221. package/dist/components/inputs/date-time/month-picker/index.js +38 -32
  222. package/dist/components/inputs/date-time/time-picker/index.d.ts +18 -59
  223. package/dist/components/inputs/date-time/time-picker/index.js +39 -33
  224. package/dist/components/inputs/field/index.d.ts +37 -41
  225. package/dist/components/inputs/field/index.js +13 -14
  226. package/dist/components/inputs/file-dropzone/index.d.ts +32 -25
  227. package/dist/components/inputs/file-dropzone/index.js +18 -15
  228. package/dist/components/inputs/file-dropzone/variants.js +1 -1
  229. package/dist/components/inputs/input/index.d.ts +48 -50
  230. package/dist/components/inputs/input/index.js +14 -12
  231. package/dist/components/inputs/label/index.d.ts +12 -10
  232. package/dist/components/inputs/label/index.js +5 -4
  233. package/dist/components/inputs/number-input/index.d.ts +31 -23
  234. package/dist/components/inputs/number-input/index.js +16 -14
  235. package/dist/components/inputs/radio/index.d.ts +20 -16
  236. package/dist/components/inputs/radio/index.js +20 -16
  237. package/dist/components/inputs/search/index.d.ts +12 -5
  238. package/dist/components/inputs/search/index.js +33 -26
  239. package/dist/components/inputs/select/index.d.ts +88 -99
  240. package/dist/components/inputs/select/index.js +32 -29
  241. package/dist/components/inputs/slider/index.d.ts +26 -48
  242. package/dist/components/inputs/slider/index.js +9 -10
  243. package/dist/components/inputs/switch/index.d.ts +12 -6
  244. package/dist/components/inputs/switch/index.js +17 -15
  245. package/dist/components/inputs/textarea/index.d.ts +12 -22
  246. package/dist/components/inputs/textarea/index.js +12 -9
  247. package/dist/components/navigation/navigation-menu/index.d.ts +112 -83
  248. package/dist/components/navigation/navigation-menu/index.js +31 -27
  249. package/dist/components/navigation/pagination/index.d.ts +25 -38
  250. package/dist/components/navigation/pagination/index.js +27 -34
  251. package/dist/components/navigation/sidebar/index.d.ts +236 -230
  252. package/dist/components/navigation/sidebar/index.js +59 -55
  253. package/dist/components/navigation/tabs/index.d.ts +62 -45
  254. package/dist/components/navigation/tabs/index.js +23 -17
  255. package/dist/components/overlays/alert-dialog/index.d.ts +71 -106
  256. package/dist/components/overlays/alert-dialog/index.js +24 -19
  257. package/dist/components/overlays/command/index.d.ts +40 -31
  258. package/dist/components/overlays/command/index.js +31 -25
  259. package/dist/components/overlays/context-menu/index.d.ts +70 -84
  260. package/dist/components/overlays/context-menu/index.js +35 -31
  261. package/dist/components/overlays/dialog/index.d.ts +82 -98
  262. package/dist/components/overlays/dialog/index.js +23 -20
  263. package/dist/components/overlays/dropdown/index.d.ts +191 -357
  264. package/dist/components/overlays/dropdown/index.js +35 -41
  265. package/dist/components/overlays/popover/index.d.ts +81 -52
  266. package/dist/components/overlays/popover/index.js +17 -13
  267. package/dist/components/overlays/preview-card/index.d.ts +52 -26
  268. package/dist/components/overlays/preview-card/index.js +16 -12
  269. package/dist/components/overlays/sheet/index.d.ts +41 -45
  270. package/dist/components/overlays/sheet/index.js +24 -19
  271. package/dist/components/overlays/toast/index.d.ts +73 -183
  272. package/dist/components/overlays/toast/index.js +20 -21
  273. package/dist/components/overlays/tooltip/index.d.ts +80 -118
  274. package/dist/components/overlays/tooltip/index.js +14 -12
  275. package/dist/components/progress/index.d.ts +10 -11
  276. package/dist/components/progress/index.js +7 -6
  277. package/dist/components/table/index.d.ts +72 -71
  278. package/dist/components/table/index.js +18 -16
  279. package/dist/index.d.ts +2575 -3149
  280. package/dist/index.js +186 -202
  281. package/dist/lib/date-locale.d.ts +6 -13
  282. package/dist/lib/date-locale.js +5 -11
  283. package/dist/lib/date-mask.d.ts +41 -0
  284. package/dist/lib/date-mask.js +20 -0
  285. package/dist/lib/field-box.d.ts +114 -0
  286. package/dist/lib/field-box.js +18 -0
  287. package/dist/lib/field-classes.d.ts +15 -119
  288. package/dist/lib/field-classes.js +4 -21
  289. package/dist/lib/fluid-hover-highlight.d.ts +3 -25
  290. package/dist/lib/fluid-hover-highlight.js +8 -13
  291. package/dist/lib/focus-ring.d.ts +16 -10
  292. package/dist/lib/focus-ring.js +6 -6
  293. package/dist/lib/goo-indicator.js +6 -5
  294. package/dist/lib/icon-context.d.ts +2 -8
  295. package/dist/lib/icon-context.js +2 -6
  296. package/dist/lib/merge-refs.d.ts +10 -0
  297. package/dist/lib/merge-refs.js +8 -0
  298. package/dist/lib/morph-layers.d.ts +12 -6
  299. package/dist/lib/morph-layers.js +7 -6
  300. package/dist/lib/morph-part.js +3 -3
  301. package/dist/lib/overlay.d.ts +113 -0
  302. package/dist/lib/overlay.js +21 -0
  303. package/dist/lib/popup-rows.d.ts +101 -0
  304. package/dist/lib/popup-rows.js +25 -0
  305. package/dist/lib/popup-surface.d.ts +92 -0
  306. package/dist/lib/popup-surface.js +17 -0
  307. package/dist/lib/popup.d.ts +17 -1
  308. package/dist/lib/popup.js +4 -1
  309. package/dist/lib/rect.d.ts +16 -0
  310. package/dist/lib/rect.js +12 -0
  311. package/dist/lib/reduced-motion.js +1 -1
  312. package/dist/lib/row-group.d.ts +100 -0
  313. package/dist/lib/row-group.js +12 -0
  314. package/dist/lib/row-index.d.ts +12 -7
  315. package/dist/lib/row-index.js +4 -2
  316. package/dist/lib/scroll-column.d.ts +1 -5
  317. package/dist/lib/scroll-column.js +13 -12
  318. package/dist/lib/shape-classes.d.ts +16 -0
  319. package/dist/lib/shape-classes.js +6 -0
  320. package/dist/lib/shape-context.d.ts +2 -9
  321. package/dist/lib/shape-context.js +3 -7
  322. package/dist/lib/size-context.d.ts +1 -2
  323. package/dist/lib/size-context.js +2 -7
  324. package/dist/lib/size-scale.js +1 -1
  325. package/dist/lib/slot.d.ts +31 -26
  326. package/dist/lib/slot.js +9 -9
  327. package/dist/lib/spinner-glyph.d.ts +7 -0
  328. package/dist/lib/spinner-glyph.js +7 -0
  329. package/dist/lib/springs.d.ts +5 -1
  330. package/dist/lib/springs.js +4 -2
  331. package/dist/lib/surface-classes.js +1 -1
  332. package/dist/lib/surface-context.d.ts +3 -1
  333. package/dist/lib/surface-context.js +3 -1
  334. package/dist/lib/use-autosize-textarea.d.ts +16 -0
  335. package/dist/lib/use-autosize-textarea.js +7 -0
  336. package/dist/lib/use-controllable-state.d.ts +15 -1
  337. package/dist/lib/use-controllable-state.js +1 -1
  338. package/dist/lib/use-fluid-hover.d.ts +1 -49
  339. package/dist/lib/use-fluid-hover.js +1 -7
  340. package/dist/lib/use-is-mobile.js +1 -1
  341. package/dist/lib/use-iso-layout-effect.d.ts +7 -0
  342. package/dist/lib/use-iso-layout-effect.js +6 -0
  343. package/dist/lib/use-keyboard-nav-gate.js +3 -2
  344. package/dist/lib/use-merge-split.js +7 -6
  345. package/dist/lib/use-morph.d.ts +13 -7
  346. package/dist/lib/use-morph.js +4 -3
  347. package/dist/lib/use-touch-primary.js +1 -1
  348. package/dist/lib/utils.js +1 -1
  349. package/dist/lib/weight-label.d.ts +26 -0
  350. package/dist/lib/weight-label.js +7 -0
  351. package/dist/preset.d.ts +4 -8
  352. package/dist/preset.js +8 -8
  353. package/dist/primitives/code/index.js +8 -8
  354. package/dist/primitives/craft/index.d.ts +1 -1
  355. package/dist/primitives/craft/index.js +13 -12
  356. package/dist/primitives/fluid-hover/index.d.ts +13 -14
  357. package/dist/primitives/fluid-hover/index.js +13 -10
  358. package/dist/primitives/morph/index.d.ts +1 -1
  359. package/dist/primitives/morph/index.js +20 -16
  360. package/dist/primitives/motion/index.d.ts +2 -0
  361. package/dist/primitives/motion/index.js +14 -11
  362. package/dist/primitives/scroll-area/index.d.ts +5 -4
  363. package/dist/primitives/scroll-area/index.js +5 -5
  364. package/dist/primitives/separator/index.d.ts +12 -11
  365. package/dist/primitives/separator/index.js +2 -2
  366. package/dist/primitives/sizes/index.d.ts +17 -4
  367. package/dist/primitives/sizes/index.js +7 -4
  368. package/dist/primitives/skeleton/index.d.ts +8 -8
  369. package/dist/primitives/skeleton/index.js +7 -6
  370. package/dist/primitives/surface/index.d.ts +12 -25
  371. package/dist/primitives/surface/index.js +8 -6
  372. package/dist/shared/{components-yxmxn2jp.js → components-07g2gbjy.js} +30 -75
  373. package/dist/shared/components-099sdasz.js +552 -0
  374. package/dist/shared/{components-bsqynhaj.js → components-0h3f5jae.js} +49 -51
  375. package/dist/shared/{components-wbbckbw8.js → components-0mrhj88d.js} +13 -12
  376. package/dist/shared/{components-0h78g3b5.js → components-0p2na0cp.js} +19 -47
  377. package/dist/shared/components-1a7cr7vh.js +40 -0
  378. package/dist/shared/components-1axxc3tk.js +334 -0
  379. package/dist/shared/components-1hc3xv0y.js +381 -0
  380. package/dist/shared/{components-gyt7my41.js → components-1jxw899c.js} +94 -84
  381. package/dist/shared/{components-jqpefjsn.js → components-1nv9q3s8.js} +24 -44
  382. package/dist/shared/components-1p3k62x2.js +137 -0
  383. package/dist/shared/{components-kz5q11pp.js → components-2xmke84n.js} +12 -4
  384. package/dist/shared/{components-c7rwx0ap.js → components-346ged8v.js} +24 -3
  385. package/dist/shared/{components-4j3t39dd.js → components-34brwmgp.js} +12 -11
  386. package/dist/shared/components-38wa9nx5.js +19 -0
  387. package/dist/shared/components-3hgk57s0.js +27 -0
  388. package/dist/shared/{components-px2zm7dc.js → components-3js2vgds.js} +13 -6
  389. package/dist/shared/{components-ctqmge8t.js → components-3m4rqrqm.js} +10 -3
  390. package/dist/shared/{components-3ey0hzpb.js → components-45r18egt.js} +11 -1
  391. package/dist/shared/components-50rh4ggz.js +54 -0
  392. package/dist/shared/components-5atrr490.js +99 -0
  393. package/dist/shared/components-5f3tq4qb.js +70 -0
  394. package/dist/shared/{components-dc5q749x.js → components-5vyaexsj.js} +16 -17
  395. package/dist/shared/{components-pwayrkw9.js → components-5ynncdpn.js} +5 -4
  396. package/dist/shared/{components-1e64t8aj.js → components-62mg6pab.js} +232 -93
  397. package/dist/shared/{components-drxrtnp2.js → components-6f5pyzb2.js} +8 -0
  398. package/dist/shared/{components-868v7scv.js → components-6xfhc5qm.js} +104 -169
  399. package/dist/shared/{components-yhgq0qxx.js → components-7c4a0egq.js} +20 -12
  400. package/dist/shared/components-7fqnqbh0.js +79 -0
  401. package/dist/shared/components-7fsy0jxg.js +443 -0
  402. package/dist/shared/{components-p0fm0bab.js → components-7t3pz7v7.js} +496 -526
  403. package/dist/shared/components-85epgxwf.js +620 -0
  404. package/dist/shared/{components-wknae3m4.js → components-86vvx0c8.js} +75 -121
  405. package/dist/shared/{components-wgtjt2af.js → components-88ktjdg0.js} +30 -27
  406. package/dist/shared/{components-ft3zdc79.js → components-88r046aa.js} +6 -6
  407. package/dist/shared/{components-xd3emmy4.js → components-8hfrd2fk.js} +1462 -1464
  408. package/dist/shared/components-8sazy704.js +146 -0
  409. package/dist/shared/{components-rrbpmfx4.js → components-8wp8d8q1.js} +8 -0
  410. package/dist/shared/{components-rtadhd9j.js → components-9ybenn5v.js} +16 -16
  411. package/dist/shared/components-amsc86fb.js +293 -0
  412. package/dist/shared/{components-9as3rf68.js → components-az04rmng.js} +12 -6
  413. package/dist/shared/components-bdkm2jzy.js +34 -0
  414. package/dist/shared/{components-xjkdvnbg.js → components-be3wggg1.js} +54 -48
  415. package/dist/shared/components-bkwjvvkh.js +18 -0
  416. package/dist/shared/{components-vf45j12c.js → components-ceyn28cf.js} +7 -0
  417. package/dist/shared/{components-3h92d94m.js → components-cy5z8zxy.js} +1 -2
  418. package/dist/shared/components-dm86y7b3.js +105 -0
  419. package/dist/shared/{components-c9yr4ed1.js → components-ejn6tvbw.js} +8 -6
  420. package/dist/shared/{components-34txk9rj.js → components-ew4wq7mj.js} +7 -0
  421. package/dist/shared/{components-svkt577j.js → components-f75y4gn8.js} +53 -70
  422. package/dist/shared/components-f9adtfq8.js +34 -0
  423. package/dist/shared/{components-2a7hcand.js → components-gbsdhmrv.js} +48 -83
  424. package/dist/shared/{components-9sttq78t.js → components-gc5zky2w.js} +54 -59
  425. package/dist/shared/{components-bae8sbjx.js → components-gkdx1787.js} +12 -6
  426. package/dist/shared/{components-124epb7f.js → components-grxgqa75.js} +3 -7
  427. package/dist/shared/components-gw0wd7gd.js +986 -0
  428. package/dist/shared/components-j4z3rtw2.js +179 -0
  429. package/dist/shared/{components-t5pk5nmc.js → components-j8tcbm8y.js} +927 -953
  430. package/dist/shared/components-jm91mjm1.js +297 -0
  431. package/dist/shared/{components-b94t6qtj.js → components-jtfptckj.js} +44 -39
  432. package/dist/shared/components-jx9qb4z8.js +63 -0
  433. package/dist/shared/components-k785rge6.js +336 -0
  434. package/dist/shared/{components-r8eqs7gz.js → components-k81x1aea.js} +10 -6
  435. package/dist/shared/{components-qx27excf.js → components-kn5c7652.js} +11 -13
  436. package/dist/shared/components-mse06t0x.js +31 -0
  437. package/dist/shared/{components-cet3jpa0.js → components-n7e31ct4.js} +71 -49
  438. package/dist/shared/components-nskr4hwg.js +1008 -0
  439. package/dist/shared/components-nv5m3gcv.js +37 -0
  440. package/dist/shared/components-nwa2a9tq.js +27 -0
  441. package/dist/shared/{components-f7h57m6t.js → components-p0x8ren6.js} +3 -1
  442. package/dist/shared/{components-2krsc300.js → components-p0z99d5b.js} +67 -92
  443. package/dist/shared/{components-b1e239g3.js → components-pa43g2r2.js} +15 -4
  444. package/dist/shared/{components-m06yq8wk.js → components-pedbt2dc.js} +35 -49
  445. package/dist/shared/components-pva1wj1r.js +27 -0
  446. package/dist/shared/components-q4wyd06h.js +382 -0
  447. package/dist/shared/{components-71nbt03m.js → components-qrpdtvxa.js} +12 -45
  448. package/dist/shared/components-r33dxr5j.js +91 -0
  449. package/dist/shared/{components-005jt2nz.js → components-re8p99fj.js} +53 -179
  450. package/dist/shared/components-s217vq1n.js +35 -0
  451. package/dist/shared/{components-vc864c51.js → components-sesrjvcc.js} +7 -6
  452. package/dist/shared/{components-qh1cvj6p.js → components-skn189mp.js} +29 -36
  453. package/dist/shared/{components-tz4gaf1v.js → components-tcyz2tdn.js} +9 -1
  454. package/dist/shared/components-tjxy84s9.js +53 -0
  455. package/dist/shared/components-tnj6mkhg.js +89 -0
  456. package/dist/shared/{components-de99ykt7.js → components-tz0axc0f.js} +1 -0
  457. package/dist/shared/components-v2j3jx89.js +7 -0
  458. package/dist/shared/components-vcte8p75.js +71 -0
  459. package/dist/shared/{components-c74gf16d.js → components-vgzerqt0.js} +34 -47
  460. package/dist/shared/components-vp6vzsee.js +30 -0
  461. package/dist/shared/components-vpkh6j83.js +42 -0
  462. package/dist/shared/{components-4nck8acq.js → components-wgd1nebp.js} +21 -14
  463. package/dist/shared/{components-pt5ftm4p.js → components-wrbw67f6.js} +10 -3
  464. package/dist/shared/{components-tz1fv35x.js → components-wwd093xg.js} +1 -0
  465. package/dist/shared/components-wyfmhtw9.js +61 -0
  466. package/dist/shared/{components-d3shbwqq.js → components-xpw8dzb0.js} +16 -23
  467. package/dist/shared/{components-mattt5jp.js → components-xzcgr3gy.js} +62 -60
  468. package/dist/shared/{components-jcnjay5g.js → components-ycx2kxeq.js} +9 -1
  469. package/dist/shared/components-zbzx62pg.js +1771 -0
  470. package/dist/shared/{components-dtca4s6b.js → components-zf0nnvvg.js} +67 -147
  471. package/dist/shared/{components-h83az0bz.js → components-znspksk0.js} +9 -1
  472. package/dist/shared/components-zpatc9x3.js +78 -0
  473. package/dist/styles.css +218 -235
  474. package/dist/tailwind.css +20 -8
  475. package/dist/tokens.css +53 -68
  476. package/index.ts +16 -2
  477. package/lib/date-locale.ts +12 -149
  478. package/lib/date-mask.ts +146 -0
  479. package/lib/field-box.ts +117 -0
  480. package/lib/field-classes.ts +85 -100
  481. package/lib/fluid-hover-highlight.tsx +12 -57
  482. package/lib/focus-ring.tsx +25 -22
  483. package/lib/goo-indicator.tsx +2 -0
  484. package/lib/icon-context.tsx +23 -75
  485. package/lib/merge-refs.ts +29 -0
  486. package/lib/morph-layers.tsx +3 -1
  487. package/lib/morph-part.tsx +5 -3
  488. package/lib/overlay.tsx +118 -0
  489. package/lib/popup-rows.tsx +149 -0
  490. package/lib/popup-surface.tsx +52 -0
  491. package/lib/popup.ts +10 -9
  492. package/lib/rect.ts +48 -0
  493. package/lib/reduced-motion.ts +2 -0
  494. package/lib/row-group.tsx +113 -0
  495. package/lib/row-index.tsx +27 -10
  496. package/lib/scroll-column.tsx +26 -53
  497. package/lib/shape-classes.ts +56 -0
  498. package/lib/shape-context.tsx +10 -79
  499. package/lib/size-context.tsx +8 -21
  500. package/lib/size-scale.ts +3 -9
  501. package/lib/slot.tsx +124 -0
  502. package/lib/spinner-glyph.tsx +27 -0
  503. package/lib/springs.ts +8 -9
  504. package/lib/surface-classes.ts +3 -8
  505. package/lib/surface-context.tsx +10 -5
  506. package/lib/use-autosize-textarea.ts +64 -0
  507. package/lib/use-controllable-state.ts +30 -15
  508. package/lib/use-fluid-hover.ts +9 -11
  509. package/lib/use-is-mobile.ts +5 -5
  510. package/lib/use-iso-layout-effect.ts +14 -0
  511. package/lib/use-keyboard-nav-gate.ts +5 -6
  512. package/lib/use-merge-split.tsx +5 -15
  513. package/lib/use-morph.ts +34 -76
  514. package/lib/use-touch-primary.tsx +5 -5
  515. package/lib/utils.ts +4 -11
  516. package/lib/weight-label.tsx +69 -0
  517. package/package.json +57 -194
  518. package/primitives/code/index.tsx +4 -2
  519. package/primitives/craft/demos.tsx +4 -2
  520. package/primitives/craft/examples.mdx +32 -34
  521. package/primitives/craft/index.tsx +3 -0
  522. package/primitives/fluid-hover/examples.mdx +1 -1
  523. package/primitives/fluid-hover/index.tsx +33 -68
  524. package/primitives/morph/examples.mdx +16 -19
  525. package/primitives/morph/index.tsx +5 -3
  526. package/primitives/motion/examples.mdx +3 -3
  527. package/primitives/motion/index.tsx +6 -22
  528. package/primitives/scroll-area/examples.mdx +4 -4
  529. package/primitives/scroll-area/index.tsx +16 -41
  530. package/primitives/separator/examples.mdx +2 -2
  531. package/primitives/separator/index.tsx +15 -14
  532. package/primitives/sizes/examples.mdx +1 -1
  533. package/primitives/sizes/index.tsx +28 -42
  534. package/primitives/skeleton/examples.mdx +6 -6
  535. package/primitives/skeleton/index.tsx +24 -10
  536. package/primitives/skeleton/skeleton.css +8 -3
  537. package/primitives/surface/examples.mdx +11 -11
  538. package/primitives/surface/index.tsx +15 -40
  539. package/primitives/surface/surface.css +1 -1
  540. package/DESIGN.md +0 -623
  541. package/components/inputs/select/variants.ts +0 -32
  542. package/components/navigation/sidebar/sidebar-core.tsx +0 -1408
  543. package/components/navigation/sidebar/sidebar-menu.tsx +0 -1495
  544. package/components/navigation/sidebar/variants.ts +0 -55
  545. package/components/navigation/tabs-subtle/examples.mdx +0 -49
  546. package/components/navigation/tabs-subtle/index.tsx +0 -512
  547. package/components/overlays/dropdown/menu-parts.tsx +0 -725
  548. package/components/overlays/toast/global-demo.tsx +0 -72
  549. package/dist/components/inputs/color-picker/variants.d.ts +0 -61
  550. package/dist/components/inputs/color-picker/variants.js +0 -28
  551. package/dist/components/inputs/select/variants.d.ts +0 -5
  552. package/dist/components/inputs/select/variants.js +0 -6
  553. package/dist/components/navigation/sidebar/variants.d.ts +0 -25
  554. package/dist/components/navigation/sidebar/variants.js +0 -28
  555. package/dist/components/navigation/tabs-subtle/index.d.ts +0 -73
  556. package/dist/components/navigation/tabs-subtle/index.js +0 -24
  557. package/dist/docs/index.d.ts +0 -83
  558. package/dist/docs/index.js +0 -288
  559. package/dist/docs/vite.d.ts +0 -31
  560. package/dist/docs/vite.js +0 -45
  561. package/dist/lib/field-variants.d.ts +0 -47
  562. package/dist/lib/field-variants.js +0 -26
  563. package/dist/lib/inert.d.ts +0 -9
  564. package/dist/lib/inert.js +0 -8
  565. package/dist/lib/row-order.d.ts +0 -28
  566. package/dist/lib/row-order.js +0 -10
  567. package/dist/lib/shape-radius.d.ts +0 -19
  568. package/dist/lib/shape-radius.js +0 -6
  569. package/dist/shared/components-01w9qcfa.js +0 -277
  570. package/dist/shared/components-26snnbs9.js +0 -322
  571. package/dist/shared/components-2qbqqpgq.js +0 -1545
  572. package/dist/shared/components-303jf96s.js +0 -1478
  573. package/dist/shared/components-4vfm04wq.js +0 -82
  574. package/dist/shared/components-54nq988h.js +0 -123
  575. package/dist/shared/components-7qx17na9.js +0 -300
  576. package/dist/shared/components-7s7pykk5.js +0 -281
  577. package/dist/shared/components-8jrk5eye.js +0 -448
  578. package/dist/shared/components-91zw3d9f.js +0 -136
  579. package/dist/shared/components-9jmjnkqd.js +0 -503
  580. package/dist/shared/components-adkarj8n.js +0 -35
  581. package/dist/shared/components-c5w5zk0s.js +0 -218
  582. package/dist/shared/components-cnead5qm.js +0 -185
  583. package/dist/shared/components-czdvj1a8.js +0 -266
  584. package/dist/shared/components-dcc02hs2.js +0 -31
  585. package/dist/shared/components-dhgk6mbt.js +0 -16
  586. package/dist/shared/components-g3eafs70.js +0 -337
  587. package/dist/shared/components-gx4h5rbb.js +0 -40
  588. package/dist/shared/components-h6p86be3.js +0 -19
  589. package/dist/shared/components-hdzrqqpx.js +0 -55
  590. package/dist/shared/components-hgv6tygd.js +0 -986
  591. package/dist/shared/components-krtx3m5b.js +0 -84
  592. package/dist/shared/components-kswxnm3h.js +0 -24
  593. package/dist/shared/components-mhza2wdn.js +0 -482
  594. package/dist/shared/components-mrbaxt8q.js +0 -62
  595. package/dist/shared/components-pv1dyrtn.js +0 -678
  596. package/dist/shared/components-s8yqk2dc.js +0 -124
  597. package/dist/shared/components-syynwm1r.js +0 -114
  598. package/dist/shared/components-tv7b8tet.js +0 -271
  599. package/dist/shared/components-w2jqa6hx.js +0 -404
  600. package/dist/shared/components-xdqmt6ed.js +0 -20
  601. package/dist/shared/components-y0kfy2g4.js +0 -578
  602. package/dist/shared/components-z3v0n0de.js +0 -11
  603. package/dist/shared/components-z8fedth5.js +0 -305
  604. package/dist/shared/components-zkk3fmw8.js +0 -150
  605. package/dist/tokens/colors.css +0 -230
  606. package/dist/tokens/motion.css +0 -40
  607. package/dist/tokens/radius.css +0 -10
  608. package/dist/tokens/spacing.css +0 -9
  609. package/dist/tokens/typography.css +0 -119
  610. package/docs/chrome.css +0 -120
  611. package/docs/chrome.tsx +0 -283
  612. package/docs/index.ts +0 -9
  613. package/docs/vite.ts +0 -85
  614. package/lib/field-variants.ts +0 -117
  615. package/lib/inert.ts +0 -22
  616. package/lib/row-order.tsx +0 -126
  617. package/lib/shape-radius.ts +0 -67
  618. package/lib/slot.ts +0 -115
  619. package/preset.ts +0 -199
@@ -1,33 +1,38 @@
1
1
  "use client";
2
- import {
3
- useShape2
4
- } from "./components-71nbt03m.js";
2
+
5
3
  import {
6
4
  useSizeVariant2
7
- } from "./components-h83az0bz.js";
8
- import {
9
- spring2
10
- } from "./components-3ey0hzpb.js";
5
+ } from "./components-znspksk0.js";
11
6
  import {
12
7
  useControllableState2
13
- } from "./components-tz1fv35x.js";
8
+ } from "./components-wwd093xg.js";
9
+ import {
10
+ mergeRefs2
11
+ } from "./components-bkwjvvkh.js";
12
+ import {
13
+ useShape2
14
+ } from "./components-qrpdtvxa.js";
15
+ import {
16
+ spring2
17
+ } from "./components-45r18egt.js";
14
18
  import {
15
19
  cn2
16
- } from "./components-jcnjay5g.js";
20
+ } from "./components-ycx2kxeq.js";
17
21
 
18
22
  // components/inputs/slider/index.tsx
23
+ import { forwardRef as forwardRef3 } from "react";
24
+
25
+ // components/inputs/slider/comfortable.tsx
19
26
  import { Slider as SliderPrimitive } from "@base-ui/react/slider";
20
- import { AnimatePresence, animate, motion, useMotionValue, useTransform } from "motion/react";
21
- import {
22
- forwardRef,
23
- useCallback,
24
- useEffect,
25
- useLayoutEffect,
26
- useMemo,
27
- useRef,
28
- useState
29
- } from "react";
30
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
27
+ import { AnimatePresence, animate, motion as motion2, useMotionValue, useTransform as useTransform2 } from "motion/react";
28
+ import { forwardRef, useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
29
+
30
+ // components/inputs/slider/geometry.ts
31
+ import { useEffect, useState } from "react";
32
+ /*!
33
+ * Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
34
+ * MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
35
+ */
31
36
  var THUMB_SIZE = 20;
32
37
  var THUMB_SIZE_REST = 16;
33
38
  var TRACK_BG_HEIGHT = 18;
@@ -48,19 +53,54 @@ function nearestStepIndex(v, steps) {
48
53
  }
49
54
  return idx;
50
55
  }
56
+ function snapValue(raw, min, max, step, stepValues = null) {
57
+ if (stepValues)
58
+ return stepValues[nearestStepIndex(raw, stepValues)];
59
+ return Math.max(min, Math.min(max, Math.round((raw - min) / step) * step + min));
60
+ }
51
61
  function pixelToValue(px, min, max, step, trackWidth, stepValues = null) {
52
62
  const usable = trackWidth - THUMB_SIZE;
53
63
  if (usable <= 0)
54
64
  return min;
55
- const raw = px / usable * (max - min) + min;
56
- if (stepValues)
57
- return stepValues[nearestStepIndex(raw, stepValues)];
58
- const snapped = Math.round((raw - min) / step) * step + min;
59
- return Math.max(min, Math.min(max, snapped));
65
+ return snapValue(px / usable * (max - min) + min, min, max, step, stepValues);
60
66
  }
61
67
  function toRadixValue(value) {
62
68
  return Array.isArray(value) ? value : [value];
63
69
  }
70
+ function layoutX(clientX, el) {
71
+ const rect = el.getBoundingClientRect();
72
+ if (el.offsetWidth <= 0 || rect.width <= 0)
73
+ return null;
74
+ return (clientX - rect.left) * (el.offsetWidth / rect.width);
75
+ }
76
+ function useDelayedFlag(flag, delay) {
77
+ const [delayed, setDelayed] = useState(false);
78
+ useEffect(() => {
79
+ if (!flag) {
80
+ setDelayed(false);
81
+ return;
82
+ }
83
+ const id = setTimeout(() => setDelayed(true), delay);
84
+ return () => clearTimeout(id);
85
+ }, [flag, delay]);
86
+ return delayed;
87
+ }
88
+
89
+ // components/inputs/slider/value-display.tsx
90
+ import { motion, useTransform } from "motion/react";
91
+ import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
92
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
93
+ /*!
94
+ * Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
95
+ * MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
96
+ */
97
+ function ValueBubble({ children }) {
98
+ const shape = useShape2();
99
+ return /* @__PURE__ */ jsx("span", {
100
+ className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
101
+ children
102
+ });
103
+ }
64
104
  function ValueDisplay({
65
105
  values,
66
106
  editingIndex,
@@ -77,9 +117,9 @@ function ValueDisplay({
77
117
  isInteracting
78
118
  }) {
79
119
  const shape = useShape2();
80
- const [inputValue, setInputValue] = useState("");
120
+ const [inputValue, setInputValue] = useState2("");
81
121
  const inputRef = useRef(null);
82
- useEffect(() => {
122
+ useEffect2(() => {
83
123
  if (editingIndex !== null) {
84
124
  setInputValue(String(values[editingIndex]));
85
125
  requestAnimationFrame(() => inputRef.current?.select());
@@ -88,9 +128,7 @@ function ValueDisplay({
88
128
  const commitEdit = useCallback((index) => {
89
129
  const parsed = parseFloat(inputValue);
90
130
  if (!isNaN(parsed)) {
91
- const clamped = Math.max(min, Math.min(max, parsed));
92
- const snapped = stepValues ? stepValues[nearestStepIndex(clamped, stepValues)] : Math.round((clamped - min) / step) * step + min;
93
- onCommitEdit(index, snapped);
131
+ onCommitEdit(index, snapValue(parsed, min, max, step, stepValues));
94
132
  } else {
95
133
  onCancelEdit();
96
134
  }
@@ -181,1067 +219,1003 @@ function ValueDisplay({
181
219
  ]
182
220
  });
183
221
  }
184
- function TooltipValue({ value, formatValue, motionX, vertical = false }) {
185
- const shape = useShape2();
222
+ function TooltipValue({ value, formatValue, motionX }) {
186
223
  const tooltipX = useTransform(motionX, (x) => x + THUMB_SIZE / 2);
187
- const tooltipY = useTransform(motionX, (x) => -x);
188
224
  return /* @__PURE__ */ jsx(motion.div, {
189
- className: cn2("absolute pointer-events-none z-20", vertical ? "translate-y-1/2" : "-translate-x-1/2"),
190
- style: vertical ? { y: tooltipY, bottom: THUMB_SIZE / 2, left: `calc(50% + ${THUMB_SIZE}px)` } : { x: tooltipX, top: -16 },
191
- initial: vertical ? { opacity: 0, x: -4 } : { opacity: 0, y: 4 },
192
- animate: vertical ? { opacity: 1, x: 0 } : { opacity: 1, y: 0 },
193
- exit: vertical ? { opacity: 0, x: -4, transition: spring2.fast.exit } : { opacity: 0, y: 4, transition: spring2.fast.exit },
225
+ className: "absolute -translate-x-1/2 pointer-events-none z-20",
226
+ style: {
227
+ x: tooltipX,
228
+ top: -16
229
+ },
230
+ initial: { opacity: 0, y: 4 },
231
+ animate: { opacity: 1, y: 0 },
232
+ exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
194
233
  transition: spring2.fast,
195
- children: /* @__PURE__ */ jsx("span", {
196
- className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
234
+ children: /* @__PURE__ */ jsx(ValueBubble, {
197
235
  children: formatValue(value)
198
236
  })
199
237
  });
200
238
  }
201
- var CompactSlider = forwardRef(({
239
+
240
+ // components/inputs/slider/comfortable.tsx
241
+ import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
242
+ /*!
243
+ * Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
244
+ * MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
245
+ */
246
+ var ComfortableSlider = forwardRef(({
202
247
  value,
203
- onChange,
204
- min: minProp = 0,
205
- max: maxProp = 100,
248
+ onValueChange,
249
+ min = 0,
250
+ max = 100,
206
251
  step = 1,
207
- steps,
208
- showSteps = false,
209
- showValue = true,
210
- valuePosition: valuePositionProp,
211
- formatValue = String,
252
+ variant = "pips",
212
253
  label,
254
+ formatValue = String,
213
255
  disabled = false,
214
- trackClassName,
215
- trackStyle,
216
- fillClassName,
217
- fillStyle,
218
- hideFill = false,
219
- thumbColor,
220
- thumbBorderColor,
221
- orientation = "horizontal",
222
- onValueCommit,
256
+ name,
223
257
  className,
224
- "aria-label": ariaLabel,
225
258
  ...props
226
259
  }, ref) => {
227
- const vertical = orientation === "vertical";
228
- const valuePosition = valuePositionProp ?? (vertical ? "top" : "left");
229
- const onValueCommitRef = useRef(onValueCommit);
230
- onValueCommitRef.current = onValueCommit;
231
- const latestValue = useRef(value);
232
- const isRange = Array.isArray(value);
233
- const values = toRadixValue(value);
260
+ const containerRef = useRef2(null);
261
+ const dragging = useRef2(false);
262
+ const handleDragging = useRef2(false);
263
+ const [isHovered, setIsHovered] = useState3(false);
264
+ const [isPressed, setIsPressed] = useState3(false);
265
+ const [isFocused, setIsFocused] = useState3(false);
266
+ const [hoverPreview, setHoverPreview] = useState3(null);
267
+ const showHoverTooltip = useDelayedFlag(isHovered, 100);
234
268
  const shape = useShape2();
235
- const stepsKey = steps ? steps.join(",") : "";
236
- const stepValues = useMemo(() => {
237
- if (!stepsKey)
238
- return null;
239
- const parsed = Array.from(new Set(stepsKey.split(",").map(Number))).sort((a, b) => a - b);
240
- return parsed.length > 1 ? parsed : null;
241
- }, [stepsKey]);
242
- const min = stepValues ? stepValues[0] : minProp;
243
- const max = stepValues ? stepValues[stepValues.length - 1] : maxProp;
244
- const trackRef = useRef(null);
245
- const trackWidthRef = useRef(0);
246
- const dragging = useRef(false);
247
- const activeDragThumb = useRef(0);
248
- const valuesRef = useRef(values);
249
- const minRef = useRef(min);
250
- const maxRef = useRef(max);
251
- valuesRef.current = values;
252
- minRef.current = min;
253
- maxRef.current = max;
254
- const [isHovered, setIsHovered] = useState(false);
255
- const [isPressed, setIsPressed] = useState(false);
256
- const [editingIndex, setEditingIndex] = useState(null);
257
- const [hoverPreview, setHoverPreview] = useState(null);
258
- const [focusedThumb, setFocusedThumb] = useState(null);
259
- const [showHoverTooltip, setShowHoverTooltip] = useState(false);
260
- const hoverDelayRef = useRef(null);
261
- useEffect(() => {
262
- if (isHovered) {
263
- hoverDelayRef.current = setTimeout(() => setShowHoverTooltip(true), 100);
269
+ const pipSteps = useMemo(() => Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => min + i * step), [min, max, step]);
270
+ const pipCount = pipSteps.length;
271
+ const fillPercent = useMotionValue(max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min))));
272
+ const zeroTarget = variant === "pips" ? 8 : 17;
273
+ const zeroOffset = useMotionValue(value === min ? zeroTarget : 0);
274
+ const fillWidthStyle = useTransform2(fillPercent, (p) => `${p * 100}%`);
275
+ const handleLeftStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 8px + ${zo}px)`);
276
+ const handleLineLeftStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 9px + ${zo}px)`);
277
+ const pipsFillWidthStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% + ${20 - 20 * p - zo * 2.5}px)`);
278
+ const pipsHandleLineLeftStyle = useTransform2(fillPercent, (p) => `calc(${p * 100}% + ${11 - 24 * p}px)`);
279
+ const pipsMaskStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => {
280
+ const offset = 20 - 20 * p - zo * 2.5;
281
+ return `linear-gradient(to right, transparent calc(${p * 100}% + ${offset}px), black calc(${p * 100}% + ${offset + 2}px))`;
282
+ });
283
+ const computeHoverPreview = useCallback2((clientX) => {
284
+ const el = containerRef.current;
285
+ if (!el)
286
+ return;
287
+ const w = el.clientWidth;
288
+ const x = layoutX(clientX, el);
289
+ if (w <= 0 || x === null)
290
+ return;
291
+ const borderLeft = (el.offsetWidth - w) / 2;
292
+ const clamped = Math.max(0, Math.min(w, x - borderLeft));
293
+ let snappedVal;
294
+ if (variant === "pips") {
295
+ if (pipCount <= 1)
296
+ return;
297
+ const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / w * (pipCount - 1))));
298
+ snappedVal = pipSteps[index];
264
299
  } else {
265
- if (hoverDelayRef.current)
266
- clearTimeout(hoverDelayRef.current);
267
- setShowHoverTooltip(false);
300
+ snappedVal = snapValue(min + clamped / w * (max - min), min, max, step);
268
301
  }
269
- return () => {
270
- if (hoverDelayRef.current)
271
- clearTimeout(hoverDelayRef.current);
272
- };
273
- }, [isHovered]);
274
- const motionX0 = useMotionValue(0);
275
- const motionX1 = useMotionValue(0);
276
- const fillLeft = useTransform(motionX0, (x) => isRange ? x + THUMB_SIZE / 2 - TRACK_INSET : 0);
277
- const fillWidthSingle = useTransform(motionX0, (x) => x + THUMB_SIZE / 2 - TRACK_INSET);
278
- const fillWidthRange = useTransform([motionX0, motionX1], ([x0, x1]) => x1 - x0);
279
- const fillWidth = isRange ? fillWidthRange : fillWidthSingle;
280
- const thumbY0 = useTransform(motionX0, (x) => -x);
281
- const thumbY1 = useTransform(motionX1, (x) => -x);
282
- const maskDir = vertical ? "to top" : "to right";
283
- const stepDotsMaskSingle = useTransform(motionX0, (x) => {
284
- const edge = x + THUMB_SIZE / 2;
285
- return `linear-gradient(${maskDir}, transparent ${edge}px, black ${edge + 2}px)`;
286
- });
287
- const stepDotsMaskRange = useTransform([motionX0, motionX1], ([x0, x1]) => {
288
- const left = x0 + THUMB_SIZE / 2;
289
- const right = x1 + THUMB_SIZE / 2;
290
- return `linear-gradient(${maskDir}, black ${left - 2}px, transparent ${left}px, transparent ${right}px, black ${right + 2}px)`;
291
- });
292
- const stepDotsMask = isRange ? stepDotsMaskRange : stepDotsMaskSingle;
293
- const measure = useCallback((clientX, clientY) => {
294
- const trackEl = trackRef.current;
295
- if (!trackEl)
296
- return null;
297
- const rect = trackEl.getBoundingClientRect();
298
- const length = vertical ? trackEl.offsetHeight : trackEl.offsetWidth;
299
- const visual = vertical ? rect.height : rect.width;
300
- if (length <= 0 || visual <= 0)
301
- return null;
302
- const scale = visual / length;
303
- return { length, pos: (vertical ? rect.bottom - clientY : clientX - rect.left) / scale };
304
- }, [vertical]);
305
- const computeHoverPreview = useCallback((cursorX, trackWidth) => {
306
- const usable = trackWidth - THUMB_SIZE;
307
- const rawPx = cursorX - THUMB_SIZE / 2;
308
- const clampedPx = Math.max(0, Math.min(usable, rawPx));
309
- const rawVal = usable > 0 ? clampedPx / usable * (max - min) + min : min;
310
- const snappedVal = stepValues ? stepValues[nearestStepIndex(rawVal, stepValues)] : Math.max(min, Math.min(max, Math.round((rawVal - min) / step) * step + min));
311
302
  const snappedPercent = max === min ? 0 : (snappedVal - min) / (max - min);
312
- const snappedX = THUMB_SIZE / 2 + snappedPercent * usable;
313
- const c0 = motionX0.get() + THUMB_SIZE / 2;
314
- const c1 = motionX1.get() + THUMB_SIZE / 2;
315
- const nearestIdx = isRange ? Math.abs(snappedX - c0) <= Math.abs(snappedX - c1) ? 0 : 1 : 0;
316
- const nearest = nearestIdx === 0 ? c0 : c1;
317
- const edgeX = snappedVal === min ? 0 : snappedVal === max ? trackWidth : snappedX;
318
- const left = Math.min(nearest, edgeX);
319
- const width = Math.abs(edgeX - nearest);
303
+ const snappedX = snappedPercent * w;
304
+ const currentPercent = fillPercent.get();
305
+ let handleX;
306
+ if (variant === "pips") {
307
+ const zo = zeroOffset.get();
308
+ handleX = currentPercent * w + (20 - 20 * currentPercent - zo * 2.5);
309
+ } else {
310
+ handleX = currentPercent * w;
311
+ }
312
+ const edgeX = snappedVal === min ? 0 : snappedVal === max ? w : snappedX;
313
+ const left = Math.min(handleX, edgeX);
314
+ const width = Math.abs(edgeX - handleX);
320
315
  setHoverPreview({ left, width, snappedValue: snappedVal, cursorX: snappedX });
321
- }, [min, max, step, stepValues, isRange, motionX0, motionX1]);
322
- const initialSyncDone = useRef(false);
323
- const [ready, setReady] = useState(false);
324
- useLayoutEffect(() => {
325
- const el = trackRef.current;
326
- if (!el || initialSyncDone.current)
316
+ }, [variant, pipSteps, pipCount, min, max, step, fillPercent, zeroOffset]);
317
+ useEffect3(() => {
318
+ if (dragging.current || handleDragging.current)
327
319
  return;
328
- const w = vertical ? el.offsetHeight : el.offsetWidth;
329
- trackWidthRef.current = w;
330
- const px0 = valueToPixel(values[0], min, max, w);
331
- motionX0.set(px0);
332
- if (isRange && values[1] !== undefined) {
333
- const px1 = valueToPixel(values[1], min, max, w);
334
- motionX1.set(px1);
320
+ const percent = max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min)));
321
+ animate(fillPercent, percent, spring2.fast);
322
+ animate(zeroOffset, value === min ? zeroTarget : 0, spring2.fast);
323
+ }, [value, min, max, variant, fillPercent, zeroOffset, zeroTarget]);
324
+ const getValueFromX = useCallback2((clientX) => {
325
+ const rect = containerRef.current?.getBoundingClientRect();
326
+ if (!rect)
327
+ return min;
328
+ const x = clientX - rect.left;
329
+ const clamped = Math.max(0, Math.min(rect.width, x));
330
+ if (variant === "pips") {
331
+ if (pipCount <= 1)
332
+ return min;
333
+ const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / rect.width * (pipCount - 1))));
334
+ return pipSteps[index];
335
335
  }
336
- initialSyncDone.current = true;
337
- setReady(true);
338
- }, []);
339
- useEffect(() => {
340
- const el = trackRef.current;
341
- if (!el)
342
- return;
343
- const ro = new ResizeObserver(([entry]) => {
344
- const w = vertical ? entry.contentRect.height : entry.contentRect.width;
345
- trackWidthRef.current = w;
346
- if (!dragging.current && initialSyncDone.current) {
347
- const v = valuesRef.current;
348
- const mn = minRef.current;
349
- const mx = maxRef.current;
350
- const px0 = valueToPixel(v[0], mn, mx, w);
351
- animate(motionX0, px0, spring2.moderate);
352
- if (isRange && v[1] !== undefined) {
353
- const px1 = valueToPixel(v[1], mn, mx, w);
354
- animate(motionX1, px1, spring2.moderate);
355
- }
356
- }
357
- });
358
- ro.observe(el);
359
- return () => ro.disconnect();
360
- }, [isRange, vertical, motionX0, motionX1]);
361
- const valuesKey = values.join(",");
362
- useEffect(() => {
363
- if (!initialSyncDone.current)
336
+ return snapValue(min + clamped / rect.width * (max - min), min, max, step);
337
+ }, [variant, pipSteps, pipCount, min, max, step]);
338
+ const handlePointerDown = useCallback2((e) => {
339
+ if (disabled)
364
340
  return;
365
- if (dragging.current)
341
+ if (e.pointerType === "mouse" && e.button !== 0)
366
342
  return;
367
- const tw = trackWidthRef.current;
368
- if (tw <= 0)
343
+ e.preventDefault();
344
+ dragging.current = true;
345
+ setIsPressed(true);
346
+ const newVal = getValueFromX(e.clientX);
347
+ onValueChange(newVal);
348
+ const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
349
+ animate(fillPercent, newPercent, spring2.fast);
350
+ animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
351
+ e.currentTarget.setPointerCapture(e.pointerId);
352
+ }, [disabled, getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
353
+ const handlePointerMove = useCallback2((e) => {
354
+ if (!dragging.current)
369
355
  return;
370
- const v = valuesRef.current;
371
- const px0 = valueToPixel(v[0], min, max, tw);
372
- animate(motionX0, px0, spring2.moderate);
373
- if (isRange && v[1] !== undefined) {
374
- const px1 = valueToPixel(v[1], min, max, tw);
375
- animate(motionX1, px1, spring2.moderate);
376
- }
377
- }, [valuesKey, min, max, isRange, motionX0, motionX1]);
378
- const clampForRange = useCallback((px, thumbIndex) => {
379
- if (!isRange)
380
- return px;
381
- if (thumbIndex === 0) {
382
- return Math.min(px, motionX1.get() - THUMB_SIZE * 0.5);
383
- }
384
- return Math.max(px, motionX0.get() + THUMB_SIZE * 0.5);
385
- }, [isRange, motionX0, motionX1]);
386
- const emitChange = useCallback((thumbIndex, newValue) => {
387
- if (isRange) {
388
- const newValues = [...values];
389
- newValues[thumbIndex] = newValue;
390
- latestValue.current = newValues;
391
- onChange(newValues);
356
+ const newVal = getValueFromX(e.clientX);
357
+ onValueChange(newVal);
358
+ const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
359
+ if (variant === "scrubber") {
360
+ fillPercent.set(newPercent);
392
361
  } else {
393
- latestValue.current = newValue;
394
- onChange(newValue);
362
+ animate(fillPercent, newPercent, spring2.fast);
395
363
  }
396
- }, [isRange, values, onChange]);
397
- const handlePointerDown = useCallback((e) => {
364
+ animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
365
+ }, [getValueFromX, onValueChange, variant, fillPercent, zeroOffset, zeroTarget, min, max]);
366
+ const handlePointerUp = useCallback2(() => {
367
+ dragging.current = false;
368
+ setIsPressed(false);
369
+ setHoverPreview(null);
370
+ }, []);
371
+ const handleResizePointerDown = useCallback2((e) => {
398
372
  if (disabled)
399
373
  return;
400
374
  if (e.pointerType === "mouse" && e.button !== 0)
401
375
  return;
402
376
  e.preventDefault();
403
377
  e.stopPropagation();
404
- const m = measure(e.clientX, e.clientY);
405
- if (!m)
406
- return;
407
- const layoutWidth = m.length;
408
- const localX = m.pos - THUMB_SIZE / 2;
409
- const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, localX));
410
- if (isRange) {
411
- const dist0 = Math.abs(clamped - motionX0.get());
412
- const dist1 = Math.abs(clamped - motionX1.get());
413
- activeDragThumb.current = dist0 <= dist1 ? 0 : 1;
414
- } else {
415
- activeDragThumb.current = 0;
416
- }
417
- dragging.current = true;
378
+ handleDragging.current = true;
418
379
  setIsPressed(true);
419
- const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
420
- const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
421
- const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
422
- const finalPx = clampForRange(snappedPx, activeDragThumb.current);
423
- animate(motionX, finalPx, spring2.moderate);
424
- const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
425
- emitChange(activeDragThumb.current, finalValue);
380
+ const newVal = getValueFromX(e.clientX);
381
+ onValueChange(newVal);
382
+ fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
383
+ animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
426
384
  e.currentTarget.setPointerCapture(e.pointerId);
427
- }, [disabled, isRange, min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange, measure]);
428
- const handlePointerMove = useCallback((e) => {
429
- if (!dragging.current)
430
- return;
431
- e.stopPropagation();
432
- const m = measure(e.clientX, e.clientY);
433
- if (!m)
434
- return;
435
- const layoutWidth = m.length;
436
- const localX = m.pos - THUMB_SIZE / 2;
437
- const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, localX));
438
- const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
439
- const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
440
- const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
441
- const finalPx = clampForRange(snappedPx, activeDragThumb.current);
442
- motionX.set(finalPx);
443
- const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
444
- emitChange(activeDragThumb.current, finalValue);
445
- }, [min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange, measure]);
446
- const handlePointerUp = useCallback(() => {
447
- if (!dragging.current)
385
+ }, [disabled, getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
386
+ const handleResizePointerMove = useCallback2((e) => {
387
+ if (!handleDragging.current)
448
388
  return;
449
- dragging.current = false;
450
- onValueCommitRef.current?.(latestValue.current);
389
+ const newVal = getValueFromX(e.clientX);
390
+ onValueChange(newVal);
391
+ fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
392
+ animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
393
+ }, [getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
394
+ const handleResizePointerUp = useCallback2(() => {
395
+ handleDragging.current = false;
451
396
  setIsPressed(false);
452
397
  setHoverPreview(null);
453
- const tw = trackWidthRef.current;
454
- const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
455
- const currentPx = motionX.get();
456
- const snapped = pixelToValue(currentPx, min, max, step, tw, stepValues);
457
- const snappedPx = valueToPixel(snapped, min, max, tw);
458
- animate(motionX, snappedPx, spring2.moderate);
459
- }, [min, max, step, stepValues, motionX0, motionX1]);
460
- const handleRadixChange = useCallback((newValues) => {
461
- if (dragging.current)
462
- return;
463
- const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
464
- if (isRange) {
465
- onChange(mapped);
466
- } else {
467
- onChange(mapped[0]);
468
- }
469
- }, [isRange, onChange, stepValues]);
470
- const handleRadixCommit = useCallback((newValues) => {
471
- const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
472
- onValueCommitRef.current?.(isRange ? mapped : mapped[0]);
473
- }, [isRange, stepValues]);
474
- const handleStartEdit = useCallback((index) => {
475
- setEditingIndex(index);
476
- }, []);
477
- const handleCommitEdit = useCallback((index, v) => {
478
- emitChange(index, v);
479
- onValueCommitRef.current?.(latestValue.current);
480
- setEditingIndex(null);
481
- }, [emitChange]);
482
- const handleCancelEdit = useCallback(() => {
483
- setEditingIndex(null);
484
398
  }, []);
485
- const stepDots = useMemo(() => showSteps ? stepValues ? stepValues.map((v) => ({
486
- value: v,
487
- percent: max === min ? 0 : (v - min) / (max - min)
488
- })) : Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => {
489
- const v = min + i * step;
490
- const percent = (v - min) / (max - min);
491
- return { value: v, percent };
492
- }) : [], [showSteps, min, max, step, stepValues]);
493
- const isInteracting = isHovered || isPressed;
494
- const thumbAriaLabel = (index) => {
495
- const name = ariaLabel || label;
496
- if (!isRange)
497
- return name;
498
- if (!name)
499
- return index === 0 ? "Minimum" : "Maximum";
500
- return index === 0 ? `${name} minimum` : `${name} maximum`;
501
- };
502
- const valueDisplay = showValue && valuePosition !== "tooltip" && /* @__PURE__ */ jsx(ValueDisplay, {
503
- values,
504
- editingIndex,
505
- onStartEdit: handleStartEdit,
506
- onCommitEdit: handleCommitEdit,
507
- onCancelEdit: handleCancelEdit,
508
- min,
509
- max,
510
- step,
511
- stepValues,
512
- formatValue,
513
- label,
514
- isRange,
515
- isInteracting
516
- });
517
- const renderVisualThumb = (index) => {
518
- const motionX = index === 0 ? motionX0 : motionX1;
519
- return /* @__PURE__ */ jsxs(motion.span, {
520
- className: "flex items-center justify-center pointer-events-none",
521
- style: vertical ? {
522
- width: THUMB_SIZE,
523
- height: THUMB_SIZE,
524
- marginLeft: -THUMB_SIZE / 2,
525
- y: index === 0 ? thumbY0 : thumbY1,
526
- position: "absolute",
527
- left: "50%",
528
- bottom: 0,
529
- zIndex: 10
530
- } : {
531
- width: THUMB_SIZE,
532
- height: THUMB_SIZE,
533
- marginTop: -THUMB_SIZE / 2,
534
- x: motionX,
535
- position: "absolute",
536
- top: "50%",
537
- left: 0,
538
- zIndex: 10
539
- },
540
- initial: false,
541
- children: [
542
- /* @__PURE__ */ jsx(motion.span, {
543
- className: cn2("block rounded-full shadow-thumb", !thumbColor && "bg-thumb"),
544
- initial: false,
545
- animate: {
546
- width: THUMB_SIZE_REST,
547
- height: THUMB_SIZE_REST
548
- },
399
+ const handleRadixChange = useCallback2((newValues) => {
400
+ onValueChange(newValues[0]);
401
+ }, [onValueChange]);
402
+ const isActive = isHovered || isFocused;
403
+ return /* @__PURE__ */ jsxs2("div", {
404
+ className: "relative w-full touch-none",
405
+ onPointerEnter: () => {
406
+ if (!disabled)
407
+ setIsHovered(true);
408
+ },
409
+ onPointerLeave: () => {
410
+ if (!disabled) {
411
+ setIsHovered(false);
412
+ setHoverPreview(null);
413
+ }
414
+ },
415
+ onMouseMove: (e) => {
416
+ if (disabled || dragging.current || handleDragging.current)
417
+ return;
418
+ computeHoverPreview(e.clientX);
419
+ },
420
+ children: [
421
+ /* @__PURE__ */ jsx2("div", {
422
+ className: "absolute cursor-ew-resize",
423
+ style: { left: -8, right: -8, top: 0, bottom: 0 },
424
+ onPointerDown: handlePointerDown,
425
+ onPointerMove: handlePointerMove,
426
+ onPointerUp: handlePointerUp,
427
+ onPointerCancel: handlePointerUp
428
+ }),
429
+ /* @__PURE__ */ jsx2(AnimatePresence, {
430
+ children: hoverPreview && showHoverTooltip && !isPressed && /* @__PURE__ */ jsx2(motion2.div, {
431
+ className: "absolute -translate-x-1/2 pointer-events-none z-20",
432
+ initial: { opacity: 0, y: 4 },
433
+ animate: { opacity: 1, y: 0 },
434
+ exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
549
435
  transition: spring2.fast,
550
436
  style: {
551
- backgroundColor: thumbColor,
552
- border: thumbBorderColor ? `1px solid ${thumbBorderColor}` : undefined
553
- }
554
- }),
555
- /* @__PURE__ */ jsx(motion.span, {
556
- className: "absolute rounded-full border border-focus-ring pointer-events-none",
557
- initial: false,
558
- animate: {
559
- opacity: focusedThumb === index ? 1 : 0,
560
- width: THUMB_SIZE + 4,
561
- height: THUMB_SIZE + 4
437
+ left: hoverPreview.cursorX,
438
+ top: -30
562
439
  },
563
- transition: spring2.fast
564
- })
565
- ]
566
- }, `visual-thumb-${index}`);
567
- };
568
- return /* @__PURE__ */ jsxs("div", {
569
- ref,
570
- className: cn2("flex gap-0 select-none touch-none overflow-visible", vertical ? "h-40 w-fit items-center" : "flex-col w-full", valuePosition === "left" || valuePosition === "right" ? vertical ? "flex-row gap-2" : "flex-row items-center gap-2 mb-2" : "flex-col", vertical && (valuePosition === "top" || valuePosition === "bottom" || valuePosition === "tooltip") && "gap-2", disabled && "opacity-50 pointer-events-none", className),
571
- ...props,
572
- children: [
573
- (valuePosition === "top" || valuePosition === "left") && valueDisplay,
574
- /* @__PURE__ */ jsxs("div", {
575
- className: cn2("relative overflow-visible", vertical ? "min-h-0 min-w-0" : "flex-1", vertical && (valuePosition === "left" || valuePosition === "right" ? "h-full" : "flex-1")),
576
- style: vertical ? { width: THUMB_SIZE + 16 } : {
577
- height: valuePosition === "left" || valuePosition === "right" ? THUMB_SIZE + 16 : THUMB_SIZE + (valuePosition === "tooltip" ? 16 : 0),
578
- paddingTop: valuePosition === "tooltip" ? 16 : 0
579
- },
580
- onPointerEnter: () => setIsHovered(true),
581
- onPointerLeave: () => {
582
- setIsHovered(false);
583
- setHoverPreview(null);
584
- },
585
- onMouseMove: (e) => {
586
- if (dragging.current)
587
- return;
588
- const m = measure(e.clientX, e.clientY);
589
- if (!m)
590
- return;
591
- computeHoverPreview(Math.max(0, Math.min(m.length, m.pos)), m.length);
440
+ children: /* @__PURE__ */ jsx2(ValueBubble, {
441
+ children: formatValue(hoverPreview.snappedValue)
442
+ })
443
+ }, "hover-tooltip")
444
+ }),
445
+ /* @__PURE__ */ jsxs2(motion2.div, {
446
+ ref: mergeRefs2(containerRef, ref),
447
+ className: cn2("relative w-full h-8 select-none touch-none border border-border overflow-hidden outline-offset-2", variant === "scrubber" ? "flex items-center gap-3 px-4 cursor-ew-resize" : "cursor-ew-resize", shape.bg, disabled && "opacity-50 pointer-events-none", className),
448
+ initial: false,
449
+ animate: {
450
+ outline: isFocused ? "1px solid var(--focus-ring)" : "1px solid transparent"
592
451
  },
452
+ transition: spring2.fast,
453
+ onPointerDown: handlePointerDown,
454
+ onPointerMove: handlePointerMove,
455
+ onPointerUp: handlePointerUp,
456
+ onPointerCancel: handlePointerUp,
457
+ ...props,
593
458
  children: [
594
- showValue && valuePosition === "tooltip" && /* @__PURE__ */ jsxs(AnimatePresence, {
595
- children: [
596
- isInteracting && /* @__PURE__ */ jsx(TooltipValue, {
597
- value: values[0],
598
- formatValue,
599
- motionX: motionX0,
600
- vertical
601
- }, "tooltip-0"),
602
- isInteracting && isRange && values[1] !== undefined && /* @__PURE__ */ jsx(TooltipValue, {
603
- value: values[1],
604
- formatValue,
605
- motionX: motionX1,
606
- vertical
607
- }, "tooltip-1")
608
- ]
609
- }),
610
- /* @__PURE__ */ jsx(SliderPrimitive.Root, {
611
- value: stepValues ? values.map((v) => nearestStepIndex(v, stepValues)) : values,
459
+ /* @__PURE__ */ jsx2(SliderPrimitive.Root, {
460
+ value: [value],
612
461
  onValueChange: (v) => handleRadixChange(v),
613
- onValueCommitted: (v) => handleRadixCommit(v),
614
- min: stepValues ? 0 : min,
615
- max: stepValues ? stepValues.length - 1 : max,
616
- step: stepValues ? 1 : step,
617
- orientation,
462
+ name,
463
+ min,
464
+ max,
465
+ step,
618
466
  disabled,
619
- className: "absolute inset-0 opacity-0 pointer-events-none",
620
- style: vertical ? { width: THUMB_SIZE } : { height: THUMB_SIZE },
621
- children: /* @__PURE__ */ jsxs(SliderPrimitive.Control, {
467
+ className: "absolute inset-0 opacity-0 pointer-events-none [&_*]:pointer-events-none",
468
+ children: /* @__PURE__ */ jsxs2(SliderPrimitive.Control, {
622
469
  className: "w-full h-full",
623
470
  children: [
624
- /* @__PURE__ */ jsx(SliderPrimitive.Track, {
471
+ /* @__PURE__ */ jsx2(SliderPrimitive.Track, {
625
472
  className: "w-full h-full",
626
- children: /* @__PURE__ */ jsx(SliderPrimitive.Indicator, {})
473
+ children: /* @__PURE__ */ jsx2(SliderPrimitive.Indicator, {})
627
474
  }),
628
- /* @__PURE__ */ jsx(SliderPrimitive.Thumb, {
475
+ /* @__PURE__ */ jsx2(SliderPrimitive.Thumb, {
629
476
  index: 0,
630
- "aria-label": thumbAriaLabel(0),
631
- getAriaValueText: stepValues ? () => formatValue(values[0]) : undefined,
632
- className: "block outline-none",
633
- style: { width: THUMB_SIZE, height: THUMB_SIZE },
634
- onFocus: (e) => {
635
- if (e.target.matches(":focus-visible"))
636
- setFocusedThumb(0);
637
- },
638
- onBlur: () => setFocusedThumb((prev) => prev === 0 ? null : prev)
639
- }),
640
- isRange && /* @__PURE__ */ jsx(SliderPrimitive.Thumb, {
641
- index: 1,
642
- "aria-label": thumbAriaLabel(1),
643
- getAriaValueText: stepValues ? () => formatValue(values[1]) : undefined,
477
+ "aria-label": label,
644
478
  className: "block outline-none",
645
- style: { width: THUMB_SIZE, height: THUMB_SIZE },
646
479
  onFocus: (e) => {
647
- if (e.target.matches(":focus-visible"))
648
- setFocusedThumb(1);
480
+ if (e.currentTarget.matches(":focus-visible"))
481
+ setIsFocused(true);
649
482
  },
650
- onBlur: () => setFocusedThumb((prev) => prev === 1 ? null : prev)
483
+ onBlur: () => setIsFocused(false)
651
484
  })
652
485
  ]
653
486
  })
654
487
  }),
655
- /* @__PURE__ */ jsxs("div", {
656
- ref: trackRef,
657
- className: cn2("relative", vertical ? "h-full cursor-ns-resize px-2" : "w-full cursor-ew-resize py-2"),
658
- style: vertical ? { width: THUMB_SIZE + 16, opacity: ready ? 1 : 0 } : { height: THUMB_SIZE + 16, opacity: ready ? 1 : 0 },
659
- onPointerDown: handlePointerDown,
660
- onPointerMove: handlePointerMove,
661
- onPointerUp: handlePointerUp,
662
- onPointerCancel: handlePointerUp,
488
+ /* @__PURE__ */ jsx2(motion2.div, {
489
+ className: "absolute inset-y-0 bg-accent/40 pointer-events-none z-[3]",
490
+ initial: false,
491
+ animate: {
492
+ opacity: hoverPreview && !isPressed ? 1 : 0
493
+ },
494
+ transition: { opacity: { duration: 0.15 } },
495
+ style: {
496
+ left: hoverPreview ? hoverPreview.left : 0,
497
+ width: hoverPreview ? hoverPreview.width : 0
498
+ }
499
+ }),
500
+ variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
501
+ className: "absolute inset-0 flex justify-between items-center px-3 pointer-events-none z-[1]",
502
+ style: { WebkitMaskImage: pipsMaskStyle, maskImage: pipsMaskStyle },
503
+ children: pipSteps.map((pipValue) => {
504
+ const isActivePip = pipValue === value;
505
+ return /* @__PURE__ */ jsx2("div", {
506
+ className: "relative flex items-center justify-center",
507
+ style: { width: PIP_SIZE, height: PIP_SIZE },
508
+ children: /* @__PURE__ */ jsx2(motion2.div, {
509
+ className: "rounded-full",
510
+ initial: false,
511
+ animate: {
512
+ backgroundColor: isActivePip ? "var(--foreground)" : "var(--muted-foreground)",
513
+ opacity: isActivePip ? 1 : 0.3
514
+ },
515
+ transition: spring2.fast,
516
+ style: { width: PIP_SIZE, height: PIP_SIZE }
517
+ })
518
+ }, pipValue);
519
+ })
520
+ }),
521
+ variant === "pips" && /* @__PURE__ */ jsxs2("div", {
522
+ className: "absolute inset-0 flex items-center px-2 z-[2] pointer-events-none",
523
+ "aria-hidden": true,
663
524
  children: [
664
- /* @__PURE__ */ jsx("div", {
665
- className: cn2("absolute", vertical ? "cursor-ns-resize" : "cursor-ew-resize"),
666
- style: vertical ? { left: 0, right: 0, top: -8, bottom: -8 } : { left: -8, right: -8, top: 0, bottom: 0 },
667
- onPointerDown: handlePointerDown,
668
- onPointerMove: handlePointerMove,
669
- onPointerUp: handlePointerUp,
670
- onPointerCancel: handlePointerUp
525
+ label && /* @__PURE__ */ jsx2("span", {
526
+ className: "text-body px-2 bg-background text-transparent select-none",
527
+ children: label
671
528
  }),
672
- /* @__PURE__ */ jsx(AnimatePresence, {
673
- children: hoverPreview && showHoverTooltip && !isPressed && valuePosition !== "tooltip" && /* @__PURE__ */ jsx(motion.div, {
674
- className: cn2("absolute pointer-events-none z-20", vertical ? "translate-y-1/2" : "-translate-x-1/2"),
675
- initial: vertical ? { opacity: 0, x: -4 } : { opacity: 0, y: 4 },
676
- animate: vertical ? { opacity: 1, x: 0 } : { opacity: 1, y: 0 },
677
- exit: vertical ? { opacity: 0, x: -4, transition: spring2.fast.exit } : { opacity: 0, y: 4, transition: spring2.fast.exit },
678
- transition: spring2.fast,
679
- style: vertical ? { bottom: hoverPreview.cursorX, left: `calc(100% + 4px)` } : { left: hoverPreview.cursorX, top: -20 },
680
- children: /* @__PURE__ */ jsx("span", {
681
- className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
682
- children: formatValue(hoverPreview.snappedValue)
683
- })
684
- }, "hover-tooltip")
529
+ /* @__PURE__ */ jsx2("span", {
530
+ className: "text-body tabular-nums ml-auto px-2 bg-background text-transparent select-none",
531
+ style: { minWidth: `${String(formatValue(max)).length}ch` },
532
+ children: formatValue(value)
533
+ })
534
+ ]
535
+ }),
536
+ variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
537
+ className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none z-[3]",
538
+ style: {
539
+ width: pipsFillWidthStyle
540
+ }
541
+ }),
542
+ variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
543
+ className: "absolute rounded-full pointer-events-none z-[3]",
544
+ initial: false,
545
+ animate: {
546
+ top: isActive ? 7 : 8,
547
+ bottom: isActive ? 7 : 8,
548
+ backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
549
+ },
550
+ transition: spring2.fast,
551
+ style: {
552
+ left: pipsHandleLineLeftStyle,
553
+ width: 2
554
+ }
555
+ }),
556
+ variant === "pips" && /* @__PURE__ */ jsxs2("div", {
557
+ className: "absolute inset-0 flex items-center px-2 z-[4] pointer-events-none",
558
+ children: [
559
+ label && /* @__PURE__ */ jsx2(motion2.span, {
560
+ className: "text-body px-2",
561
+ initial: false,
562
+ animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
563
+ transition: spring2.fast,
564
+ children: label
685
565
  }),
686
- /* @__PURE__ */ jsxs(motion.div, {
687
- className: cn2("absolute bg-transparent border border-border overflow-hidden rounded-full", trackClassName),
566
+ /* @__PURE__ */ jsx2(motion2.span, {
567
+ className: "text-body tabular-nums ml-auto px-2",
688
568
  initial: false,
689
- animate: vertical ? { width: TRACK_BG_HEIGHT, left: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2 } : { height: TRACK_BG_HEIGHT, top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2 },
569
+ animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
690
570
  transition: spring2.fast,
691
- style: {
692
- ...vertical ? { top: TRACK_INSET, bottom: TRACK_INSET } : { left: TRACK_INSET, right: TRACK_INSET },
693
- ...trackStyle
694
- },
695
- children: [
696
- !hideFill && /* @__PURE__ */ jsx(motion.div, {
697
- className: cn2("absolute bg-selected/50 dark:bg-accent/40", vertical ? "w-full" : "h-full", fillClassName),
698
- style: {
699
- ...vertical ? { bottom: fillLeft, height: fillWidth } : { left: fillLeft, width: fillWidth },
700
- ...fillStyle
701
- }
702
- }),
703
- /* @__PURE__ */ jsx(motion.div, {
704
- className: cn2("absolute bg-accent/40 pointer-events-none z-[2]", vertical ? "w-full" : "h-full"),
705
- initial: false,
706
- animate: {
707
- opacity: hoverPreview && !isPressed ? 1 : 0
708
- },
709
- transition: {
710
- opacity: { duration: 0.15 }
711
- },
712
- style: {
713
- ...vertical ? {
714
- bottom: hoverPreview ? hoverPreview.left - TRACK_INSET : 0,
715
- height: hoverPreview ? hoverPreview.width : 0
716
- } : {
717
- left: hoverPreview ? hoverPreview.left - TRACK_INSET : 0,
718
- width: hoverPreview ? hoverPreview.width : 0
719
- },
720
- borderRadius: hoverPreview && hoverPreview.cursorX > hoverPreview.left ? vertical ? "9999px 9999px 0 0" : "0 9999px 9999px 0" : vertical ? "0 0 9999px 9999px" : "9999px 0 0 9999px"
721
- }
722
- })
723
- ]
724
- }),
725
- stepDots.length > 0 && /* @__PURE__ */ jsx(motion.div, {
726
- className: cn2("absolute pointer-events-none", vertical ? "top-0 bottom-0" : "left-0 right-0"),
727
- style: {
728
- ...vertical ? { left: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2, width: TRACK_BG_HEIGHT } : { top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2, height: TRACK_BG_HEIGHT },
729
- WebkitMaskImage: stepDotsMask,
730
- maskImage: stepDotsMask
731
- },
732
- children: stepDots.map(({ value: v, percent }) => /* @__PURE__ */ jsx("div", {
733
- className: "absolute pointer-events-none flex items-center justify-center",
734
- style: {
735
- ...vertical ? {
736
- bottom: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
737
- left: "50%"
738
- } : {
739
- left: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
740
- top: "50%"
741
- },
742
- width: 0,
743
- height: 0
744
- },
745
- children: /* @__PURE__ */ jsx(motion.div, {
746
- className: "rounded-full flex-shrink-0 bg-muted-foreground opacity-30",
747
- initial: false,
748
- animate: {
749
- width: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE,
750
- height: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE
751
- },
752
- transition: spring2.moderate
753
- })
754
- }, v))
571
+ style: { minWidth: `${String(formatValue(max)).length}ch`, textAlign: "right" },
572
+ children: formatValue(value)
573
+ })
574
+ ]
575
+ }),
576
+ variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
577
+ className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none",
578
+ style: {
579
+ width: fillWidthStyle
580
+ }
581
+ }),
582
+ variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
583
+ className: "absolute rounded-full pointer-events-none z-10",
584
+ initial: false,
585
+ animate: {
586
+ top: isActive ? 7 : 8,
587
+ bottom: isActive ? 7 : 8,
588
+ backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
589
+ },
590
+ transition: spring2.fast,
591
+ style: {
592
+ left: handleLineLeftStyle,
593
+ width: 2
594
+ }
595
+ }),
596
+ variant === "scrubber" && label && /* @__PURE__ */ jsx2(motion2.span, {
597
+ className: "text-body shrink-0 z-10",
598
+ initial: false,
599
+ animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
600
+ transition: spring2.fast,
601
+ children: label
602
+ }),
603
+ variant === "scrubber" && /* @__PURE__ */ jsxs2(Fragment2, {
604
+ children: [
605
+ /* @__PURE__ */ jsx2("div", {
606
+ className: "flex-1"
755
607
  }),
756
- renderVisualThumb(0),
757
- isRange && renderVisualThumb(1)
608
+ /* @__PURE__ */ jsx2(motion2.span, {
609
+ className: "text-body shrink-0 tabular-nums text-right z-10",
610
+ initial: false,
611
+ animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
612
+ transition: spring2.fast,
613
+ style: { minWidth: `${String(formatValue(max)).length}ch` },
614
+ children: formatValue(value)
615
+ })
758
616
  ]
617
+ }),
618
+ variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
619
+ className: "absolute top-0 bottom-0 w-2 cursor-ew-resize z-20",
620
+ style: { left: handleLeftStyle },
621
+ onPointerDown: handleResizePointerDown,
622
+ onPointerMove: handleResizePointerMove,
623
+ onPointerUp: handleResizePointerUp,
624
+ onPointerCancel: handleResizePointerUp
759
625
  })
760
626
  ]
761
- }),
762
- (valuePosition === "bottom" || valuePosition === "right") && valueDisplay
627
+ })
763
628
  ]
764
629
  });
765
630
  });
766
- CompactSlider.displayName = "SliderCompact";
767
- var ComfortableSlider = forwardRef(({
631
+ ComfortableSlider.displayName = "ComfortableSlider";
632
+
633
+ // components/inputs/slider/compact.tsx
634
+ import { Slider as SliderPrimitive2 } from "@base-ui/react/slider";
635
+ import { AnimatePresence as AnimatePresence2, animate as animate2, motion as motion3, useMotionValue as useMotionValue2, useTransform as useTransform3 } from "motion/react";
636
+ import {
637
+ forwardRef as forwardRef2,
638
+ useCallback as useCallback3,
639
+ useEffect as useEffect4,
640
+ useLayoutEffect,
641
+ useMemo as useMemo2,
642
+ useRef as useRef3,
643
+ useState as useState4
644
+ } from "react";
645
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
646
+ /*!
647
+ * Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
648
+ * MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
649
+ */
650
+ var CompactSlider = forwardRef2(({
768
651
  value,
769
- onChange,
770
- min = 0,
771
- max = 100,
652
+ onValueChange,
653
+ min: minProp = 0,
654
+ max: maxProp = 100,
772
655
  step = 1,
773
- variant = "pips",
774
- label,
656
+ steps,
657
+ showSteps = false,
658
+ showValue = true,
659
+ valuePosition = "left",
775
660
  formatValue = String,
661
+ label,
776
662
  disabled = false,
777
- onValueCommit,
663
+ name,
664
+ trackClassName,
665
+ trackStyle,
666
+ fillClassName,
667
+ fillStyle,
668
+ hideFill = false,
669
+ thumbColor,
670
+ thumbBorderColor,
778
671
  className,
779
- "aria-label": ariaLabel,
780
672
  ...props
781
673
  }, ref) => {
782
- const containerRef = useRef(null);
783
- const onValueCommitRef = useRef(onValueCommit);
784
- onValueCommitRef.current = onValueCommit;
785
- const latestValue = useRef(value);
786
- const dragging = useRef(false);
787
- const handleDragging = useRef(false);
788
- const [isHovered, setIsHovered] = useState(false);
789
- const [isPressed, setIsPressed] = useState(false);
790
- const [isFocused, setIsFocused] = useState(false);
791
- const [hoverPreview, setHoverPreview] = useState(null);
792
- const [showHoverTooltip, setShowHoverTooltip] = useState(false);
793
- const hoverDelayRef = useRef(null);
794
- const shape = useShape2();
795
- useEffect(() => {
796
- if (isHovered) {
797
- hoverDelayRef.current = setTimeout(() => setShowHoverTooltip(true), 100);
798
- } else {
799
- if (hoverDelayRef.current)
800
- clearTimeout(hoverDelayRef.current);
801
- setShowHoverTooltip(false);
802
- }
803
- return () => {
804
- if (hoverDelayRef.current)
805
- clearTimeout(hoverDelayRef.current);
806
- };
807
- }, [isHovered]);
808
- const mergedRef = useCallback((el) => {
809
- containerRef.current = el;
810
- if (typeof ref === "function")
811
- ref(el);
812
- else if (ref)
813
- ref.current = el;
814
- }, [ref]);
815
- const pipSteps = useMemo(() => Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => min + i * step), [min, max, step]);
816
- const pipCount = pipSteps.length;
817
- const fillPercent = useMotionValue(max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min))));
818
- const zeroTarget = variant === "pips" ? 8 : 17;
819
- const zeroOffset = useMotionValue(value === min ? zeroTarget : 0);
820
- const fillWidthStyle = useTransform(fillPercent, (p) => `${p * 100}%`);
821
- const handleLeftStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 8px + ${zo}px)`);
822
- const handleLineLeftStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 9px + ${zo}px)`);
823
- const pipsFillWidthStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% + ${20 - 20 * p - zo * 2.5}px)`);
824
- const pipsHandleLineLeftStyle = useTransform(fillPercent, (p) => `calc(${p * 100}% + ${11 - 24 * p}px)`);
825
- const pipsMaskStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => {
826
- const offset = 20 - 20 * p - zo * 2.5;
827
- return `linear-gradient(to right, transparent calc(${p * 100}% + ${offset}px), black calc(${p * 100}% + ${offset + 2}px))`;
674
+ const isRange = Array.isArray(value);
675
+ const values = toRadixValue(value);
676
+ const stepsKey = steps ? steps.join(",") : "";
677
+ const stepValues = useMemo2(() => {
678
+ if (!stepsKey)
679
+ return null;
680
+ const parsed = Array.from(new Set(stepsKey.split(",").map(Number))).sort((a, b) => a - b);
681
+ return parsed.length > 1 ? parsed : null;
682
+ }, [stepsKey]);
683
+ const min = stepValues ? stepValues[0] : minProp;
684
+ const max = stepValues ? stepValues[stepValues.length - 1] : maxProp;
685
+ const trackRef = useRef3(null);
686
+ const trackWidthRef = useRef3(0);
687
+ const dragging = useRef3(false);
688
+ const activeDragThumb = useRef3(0);
689
+ const valuesRef = useRef3(values);
690
+ const minRef = useRef3(min);
691
+ const maxRef = useRef3(max);
692
+ valuesRef.current = values;
693
+ minRef.current = min;
694
+ maxRef.current = max;
695
+ const [isHovered, setIsHovered] = useState4(false);
696
+ const [isPressed, setIsPressed] = useState4(false);
697
+ const [editingIndex, setEditingIndex] = useState4(null);
698
+ const [hoverPreview, setHoverPreview] = useState4(null);
699
+ const [focusedThumb, setFocusedThumb] = useState4(null);
700
+ const showHoverTooltip = useDelayedFlag(isHovered, 100);
701
+ const motionX0 = useMotionValue2(0);
702
+ const motionX1 = useMotionValue2(0);
703
+ const fillLeft = useTransform3(motionX0, (x) => isRange ? x + THUMB_SIZE / 2 - TRACK_INSET : 0);
704
+ const fillWidthSingle = useTransform3(motionX0, (x) => x + THUMB_SIZE / 2 - TRACK_INSET);
705
+ const fillWidthRange = useTransform3([motionX0, motionX1], ([x0, x1]) => x1 - x0);
706
+ const fillWidth = isRange ? fillWidthRange : fillWidthSingle;
707
+ const stepDotsMaskSingle = useTransform3(motionX0, (x) => {
708
+ const edge = x + THUMB_SIZE / 2;
709
+ return `linear-gradient(to right, transparent ${edge}px, black ${edge + 2}px)`;
828
710
  });
829
- const computeHoverPreview = useCallback((clientX) => {
830
- const el = containerRef.current;
711
+ const stepDotsMaskRange = useTransform3([motionX0, motionX1], ([x0, x1]) => {
712
+ const left = x0 + THUMB_SIZE / 2;
713
+ const right = x1 + THUMB_SIZE / 2;
714
+ return `linear-gradient(to right, black ${left - 2}px, transparent ${left}px, transparent ${right}px, black ${right + 2}px)`;
715
+ });
716
+ const stepDotsMask = isRange ? stepDotsMaskRange : stepDotsMaskSingle;
717
+ const computeHoverPreview = useCallback3((cursorX, trackWidth) => {
718
+ const usable = trackWidth - THUMB_SIZE;
719
+ const rawPx = cursorX - THUMB_SIZE / 2;
720
+ const clampedPx = Math.max(0, Math.min(usable, rawPx));
721
+ const rawVal = usable > 0 ? clampedPx / usable * (max - min) + min : min;
722
+ const snappedVal = snapValue(rawVal, min, max, step, stepValues);
723
+ const snappedPercent = max === min ? 0 : (snappedVal - min) / (max - min);
724
+ const snappedX = THUMB_SIZE / 2 + snappedPercent * usable;
725
+ const c0 = motionX0.get() + THUMB_SIZE / 2;
726
+ const c1 = motionX1.get() + THUMB_SIZE / 2;
727
+ const nearestIdx = isRange ? Math.abs(snappedX - c0) <= Math.abs(snappedX - c1) ? 0 : 1 : 0;
728
+ const nearest = nearestIdx === 0 ? c0 : c1;
729
+ const edgeX = snappedVal === min ? 0 : snappedVal === max ? trackWidth : snappedX;
730
+ const left = Math.min(nearest, edgeX);
731
+ const width = Math.abs(edgeX - nearest);
732
+ setHoverPreview({ left, width, snappedValue: snappedVal, cursorX: snappedX });
733
+ }, [min, max, step, stepValues, isRange, motionX0, motionX1]);
734
+ const initialSyncDone = useRef3(false);
735
+ const [ready, setReady] = useState4(false);
736
+ useLayoutEffect(() => {
737
+ const el = trackRef.current;
738
+ if (!el || initialSyncDone.current)
739
+ return;
740
+ const w = el.offsetWidth;
741
+ trackWidthRef.current = w;
742
+ const px0 = valueToPixel(values[0], min, max, w);
743
+ motionX0.set(px0);
744
+ if (isRange && values[1] !== undefined) {
745
+ const px1 = valueToPixel(values[1], min, max, w);
746
+ motionX1.set(px1);
747
+ }
748
+ initialSyncDone.current = true;
749
+ setReady(true);
750
+ }, []);
751
+ useEffect4(() => {
752
+ const el = trackRef.current;
831
753
  if (!el)
832
754
  return;
833
- const rect = el.getBoundingClientRect();
834
- const w = el.clientWidth;
835
- if (w <= 0 || rect.width <= 0)
755
+ const ro = new ResizeObserver(([entry]) => {
756
+ const w = entry.contentRect.width;
757
+ trackWidthRef.current = w;
758
+ if (!dragging.current && initialSyncDone.current) {
759
+ const v = valuesRef.current;
760
+ const mn = minRef.current;
761
+ const mx = maxRef.current;
762
+ const px0 = valueToPixel(v[0], mn, mx, w);
763
+ animate2(motionX0, px0, spring2.moderate);
764
+ if (isRange && v[1] !== undefined) {
765
+ const px1 = valueToPixel(v[1], mn, mx, w);
766
+ animate2(motionX1, px1, spring2.moderate);
767
+ }
768
+ }
769
+ });
770
+ ro.observe(el);
771
+ return () => ro.disconnect();
772
+ }, [isRange, motionX0, motionX1]);
773
+ const valuesKey = values.join(",");
774
+ useEffect4(() => {
775
+ if (!initialSyncDone.current)
836
776
  return;
837
- const scale = rect.width / el.offsetWidth;
838
- const borderLeftLayout = (el.offsetWidth - w) / 2;
839
- const visualX = clientX - rect.left;
840
- const layoutX = visualX / scale - borderLeftLayout;
841
- const clamped = Math.max(0, Math.min(w, layoutX));
842
- let snappedVal;
843
- if (variant === "pips") {
844
- if (pipCount <= 1)
845
- return;
846
- const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / w * (pipCount - 1))));
847
- snappedVal = pipSteps[index];
848
- } else {
849
- const raw = min + clamped / w * (max - min);
850
- snappedVal = Math.max(min, Math.min(max, Math.round((raw - min) / step) * step + min));
777
+ if (dragging.current)
778
+ return;
779
+ const tw = trackWidthRef.current;
780
+ if (tw <= 0)
781
+ return;
782
+ const v = valuesRef.current;
783
+ const px0 = valueToPixel(v[0], min, max, tw);
784
+ animate2(motionX0, px0, spring2.moderate);
785
+ if (isRange && v[1] !== undefined) {
786
+ const px1 = valueToPixel(v[1], min, max, tw);
787
+ animate2(motionX1, px1, spring2.moderate);
851
788
  }
852
- const snappedPercent = max === min ? 0 : (snappedVal - min) / (max - min);
853
- const snappedX = snappedPercent * w;
854
- const currentPercent = fillPercent.get();
855
- let handleX;
856
- if (variant === "pips") {
857
- const zo = zeroOffset.get();
858
- handleX = currentPercent * w + (20 - 20 * currentPercent - zo * 2.5);
859
- } else {
860
- handleX = currentPercent * w;
789
+ }, [valuesKey, min, max, isRange, motionX0, motionX1]);
790
+ const clampForRange = useCallback3((px, thumbIndex) => {
791
+ if (!isRange)
792
+ return px;
793
+ if (thumbIndex === 0) {
794
+ return Math.min(px, motionX1.get() - THUMB_SIZE * 0.5);
861
795
  }
862
- const edgeX = snappedVal === min ? 0 : snappedVal === max ? w : snappedX;
863
- const left = Math.min(handleX, edgeX);
864
- const width = Math.abs(edgeX - handleX);
865
- setHoverPreview({ left, width, snappedValue: snappedVal, cursorX: snappedX });
866
- }, [variant, pipSteps, pipCount, min, max, step, fillPercent, zeroOffset]);
867
- useEffect(() => {
868
- if (dragging.current || handleDragging.current)
869
- return;
870
- const percent = max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min)));
871
- animate(fillPercent, percent, spring2.fast);
872
- animate(zeroOffset, value === min ? zeroTarget : 0, spring2.fast);
873
- }, [value, min, max, variant, fillPercent, zeroOffset, zeroTarget]);
874
- const getValueFromX = useCallback((clientX) => {
875
- const rect = containerRef.current?.getBoundingClientRect();
876
- if (!rect)
877
- return min;
878
- const x = clientX - rect.left;
879
- const clamped = Math.max(0, Math.min(rect.width, x));
880
- if (variant === "pips") {
881
- if (pipCount <= 1)
882
- return min;
883
- const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / rect.width * (pipCount - 1))));
884
- return pipSteps[index];
796
+ return Math.max(px, motionX0.get() + THUMB_SIZE * 0.5);
797
+ }, [isRange, motionX0, motionX1]);
798
+ const emitChange = useCallback3((thumbIndex, newValue) => {
799
+ if (isRange) {
800
+ const newValues = [...values];
801
+ newValues[thumbIndex] = newValue;
802
+ onValueChange(newValues);
803
+ } else {
804
+ onValueChange(newValue);
885
805
  }
886
- const raw = min + clamped / rect.width * (max - min);
887
- const snapped = Math.round((raw - min) / step) * step + min;
888
- return Math.max(min, Math.min(max, snapped));
889
- }, [variant, pipSteps, pipCount, min, max, step]);
890
- const handlePointerDown = useCallback((e) => {
806
+ }, [isRange, values, onValueChange]);
807
+ const handlePointerDown = useCallback3((e) => {
891
808
  if (disabled)
892
809
  return;
893
810
  if (e.pointerType === "mouse" && e.button !== 0)
894
811
  return;
895
812
  e.preventDefault();
813
+ e.stopPropagation();
814
+ const trackEl = trackRef.current;
815
+ if (!trackEl)
816
+ return;
817
+ const x = layoutX(e.clientX, trackEl);
818
+ if (x === null)
819
+ return;
820
+ const layoutWidth = trackEl.offsetWidth;
821
+ const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, x - THUMB_SIZE / 2));
822
+ if (isRange) {
823
+ const dist0 = Math.abs(clamped - motionX0.get());
824
+ const dist1 = Math.abs(clamped - motionX1.get());
825
+ activeDragThumb.current = dist0 <= dist1 ? 0 : 1;
826
+ } else {
827
+ activeDragThumb.current = 0;
828
+ }
896
829
  dragging.current = true;
897
830
  setIsPressed(true);
898
- const newVal = getValueFromX(e.clientX);
899
- latestValue.current = newVal;
900
- onChange(newVal);
901
- const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
902
- animate(fillPercent, newPercent, spring2.fast);
903
- animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
831
+ const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
832
+ const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
833
+ const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
834
+ const finalPx = clampForRange(snappedPx, activeDragThumb.current);
835
+ animate2(motionX, finalPx, spring2.moderate);
836
+ const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
837
+ emitChange(activeDragThumb.current, finalValue);
904
838
  e.currentTarget.setPointerCapture(e.pointerId);
905
- }, [disabled, getValueFromX, onChange, fillPercent, zeroOffset, zeroTarget, min, max]);
906
- const handlePointerMove = useCallback((e) => {
839
+ }, [disabled, isRange, min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange]);
840
+ const handlePointerMove = useCallback3((e) => {
907
841
  if (!dragging.current)
908
842
  return;
909
- const newVal = getValueFromX(e.clientX);
910
- latestValue.current = newVal;
911
- onChange(newVal);
912
- const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
913
- if (variant === "scrubber") {
914
- fillPercent.set(newPercent);
915
- } else {
916
- animate(fillPercent, newPercent, spring2.fast);
917
- }
918
- animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
919
- }, [getValueFromX, onChange, variant, fillPercent, zeroOffset, zeroTarget, min, max]);
920
- const handlePointerUp = useCallback(() => {
921
- if (dragging.current)
922
- onValueCommitRef.current?.(latestValue.current);
923
- dragging.current = false;
924
- setIsPressed(false);
925
- setHoverPreview(null);
926
- }, []);
927
- const handleResizePointerDown = useCallback((e) => {
928
- if (disabled)
843
+ e.stopPropagation();
844
+ const trackEl = trackRef.current;
845
+ if (!trackEl)
929
846
  return;
930
- if (e.pointerType === "mouse" && e.button !== 0)
847
+ const x = layoutX(e.clientX, trackEl);
848
+ if (x === null)
931
849
  return;
932
- e.preventDefault();
933
- e.stopPropagation();
934
- handleDragging.current = true;
935
- setIsPressed(true);
936
- const newVal = getValueFromX(e.clientX);
937
- latestValue.current = newVal;
938
- onChange(newVal);
939
- fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
940
- animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
941
- e.currentTarget.setPointerCapture(e.pointerId);
942
- }, [disabled, getValueFromX, onChange, fillPercent, zeroOffset, zeroTarget, min, max]);
943
- const handleResizePointerMove = useCallback((e) => {
944
- if (!handleDragging.current)
850
+ const layoutWidth = trackEl.offsetWidth;
851
+ const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, x - THUMB_SIZE / 2));
852
+ const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
853
+ const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
854
+ const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
855
+ const finalPx = clampForRange(snappedPx, activeDragThumb.current);
856
+ motionX.set(finalPx);
857
+ const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
858
+ emitChange(activeDragThumb.current, finalValue);
859
+ }, [min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange]);
860
+ const handlePointerUp = useCallback3(() => {
861
+ if (!dragging.current)
945
862
  return;
946
- const newVal = getValueFromX(e.clientX);
947
- latestValue.current = newVal;
948
- onChange(newVal);
949
- fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
950
- animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
951
- }, [getValueFromX, onChange, fillPercent, zeroOffset, zeroTarget, min, max]);
952
- const handleResizePointerUp = useCallback(() => {
953
- if (handleDragging.current)
954
- onValueCommitRef.current?.(latestValue.current);
955
- handleDragging.current = false;
863
+ dragging.current = false;
956
864
  setIsPressed(false);
957
865
  setHoverPreview(null);
866
+ const tw = trackWidthRef.current;
867
+ const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
868
+ const currentPx = motionX.get();
869
+ const snapped = pixelToValue(currentPx, min, max, step, tw, stepValues);
870
+ const snappedPx = valueToPixel(snapped, min, max, tw);
871
+ animate2(motionX, snappedPx, spring2.moderate);
872
+ }, [min, max, step, stepValues, motionX0, motionX1]);
873
+ const handleRadixChange = useCallback3((newValues) => {
874
+ if (dragging.current)
875
+ return;
876
+ const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
877
+ if (isRange) {
878
+ onValueChange(mapped);
879
+ } else {
880
+ onValueChange(mapped[0]);
881
+ }
882
+ }, [isRange, onValueChange, stepValues]);
883
+ const handleStartEdit = useCallback3((index) => {
884
+ setEditingIndex(index);
958
885
  }, []);
959
- const handleRadixChange = useCallback((newValues) => {
960
- onChange(newValues[0]);
961
- }, [onChange]);
962
- const isActive = isHovered || isFocused;
963
- return /* @__PURE__ */ jsxs("div", {
964
- className: "relative w-full touch-none",
965
- onPointerEnter: () => {
966
- if (!disabled)
967
- setIsHovered(true);
968
- },
969
- onPointerLeave: () => {
970
- if (!disabled) {
971
- setIsHovered(false);
972
- setHoverPreview(null);
973
- }
974
- },
975
- onMouseMove: (e) => {
976
- if (disabled || dragging.current || handleDragging.current)
977
- return;
978
- computeHoverPreview(e.clientX);
979
- },
980
- children: [
981
- /* @__PURE__ */ jsx("div", {
982
- className: "absolute cursor-ew-resize",
983
- style: { left: -8, right: -8, top: 0, bottom: 0 },
984
- onPointerDown: handlePointerDown,
985
- onPointerMove: handlePointerMove,
986
- onPointerUp: handlePointerUp,
987
- onPointerCancel: handlePointerUp
988
- }),
989
- /* @__PURE__ */ jsx(AnimatePresence, {
990
- children: hoverPreview && showHoverTooltip && !isPressed && /* @__PURE__ */ jsx(motion.div, {
991
- className: "absolute -translate-x-1/2 pointer-events-none z-20",
992
- initial: { opacity: 0, y: 4 },
993
- animate: { opacity: 1, y: 0 },
994
- exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
886
+ const handleCommitEdit = useCallback3((index, v) => {
887
+ emitChange(index, v);
888
+ setEditingIndex(null);
889
+ }, [emitChange]);
890
+ const handleCancelEdit = useCallback3(() => {
891
+ setEditingIndex(null);
892
+ }, []);
893
+ const stepDots = useMemo2(() => showSteps ? stepValues ? stepValues.map((v) => ({
894
+ value: v,
895
+ percent: max === min ? 0 : (v - min) / (max - min)
896
+ })) : Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => {
897
+ const v = min + i * step;
898
+ const percent = (v - min) / (max - min);
899
+ return { value: v, percent };
900
+ }) : [], [showSteps, min, max, step, stepValues]);
901
+ const isInteracting = isHovered || isPressed;
902
+ const thumbAriaLabel = (index) => {
903
+ if (!isRange)
904
+ return label;
905
+ if (!label)
906
+ return index === 0 ? "Minimum" : "Maximum";
907
+ return index === 0 ? `${label} minimum` : `${label} maximum`;
908
+ };
909
+ const valueDisplay = showValue && valuePosition !== "tooltip" && /* @__PURE__ */ jsx3(ValueDisplay, {
910
+ values,
911
+ editingIndex,
912
+ onStartEdit: handleStartEdit,
913
+ onCommitEdit: handleCommitEdit,
914
+ onCancelEdit: handleCancelEdit,
915
+ min,
916
+ max,
917
+ step,
918
+ stepValues,
919
+ formatValue,
920
+ label,
921
+ isRange,
922
+ isInteracting
923
+ });
924
+ const renderVisualThumb = (index) => {
925
+ const motionX = index === 0 ? motionX0 : motionX1;
926
+ return /* @__PURE__ */ jsxs3(motion3.span, {
927
+ className: "flex items-center justify-center pointer-events-none",
928
+ style: {
929
+ width: THUMB_SIZE,
930
+ height: THUMB_SIZE,
931
+ marginTop: -THUMB_SIZE / 2,
932
+ x: motionX,
933
+ position: "absolute",
934
+ top: "50%",
935
+ left: 0,
936
+ zIndex: 10
937
+ },
938
+ initial: false,
939
+ children: [
940
+ /* @__PURE__ */ jsx3(motion3.span, {
941
+ className: cn2("block rounded-full shadow-thumb", !thumbColor && "bg-thumb"),
942
+ initial: false,
943
+ animate: {
944
+ width: THUMB_SIZE_REST,
945
+ height: THUMB_SIZE_REST
946
+ },
995
947
  transition: spring2.fast,
996
948
  style: {
997
- left: hoverPreview.cursorX,
998
- top: -30
949
+ backgroundColor: thumbColor,
950
+ border: thumbBorderColor ? `1px solid ${thumbBorderColor}` : undefined
951
+ }
952
+ }),
953
+ /* @__PURE__ */ jsx3(motion3.span, {
954
+ className: "absolute rounded-full border border-focus-ring pointer-events-none",
955
+ initial: false,
956
+ animate: {
957
+ opacity: focusedThumb === index ? 1 : 0,
958
+ width: THUMB_SIZE + 4,
959
+ height: THUMB_SIZE + 4
999
960
  },
1000
- children: /* @__PURE__ */ jsx("span", {
1001
- className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
1002
- children: formatValue(hoverPreview.snappedValue)
1003
- })
1004
- }, "hover-tooltip")
1005
- }),
1006
- /* @__PURE__ */ jsxs(motion.div, {
1007
- ref: mergedRef,
1008
- className: cn2("relative w-full h-8 select-none touch-none border border-border overflow-hidden outline-offset-2", variant === "scrubber" ? "flex items-center gap-3 px-4 cursor-ew-resize" : "cursor-ew-resize", shape.bg, disabled && "opacity-50 pointer-events-none", className),
1009
- initial: false,
1010
- animate: {
1011
- outline: isFocused ? "1px solid var(--focus-ring)" : "1px solid transparent"
961
+ transition: spring2.fast
962
+ })
963
+ ]
964
+ }, `visual-thumb-${index}`);
965
+ };
966
+ return /* @__PURE__ */ jsxs3("div", {
967
+ ref,
968
+ className: cn2("flex flex-col gap-0 w-full select-none touch-none overflow-visible", valuePosition === "left" || valuePosition === "right" ? "flex-row items-center gap-2 mb-2" : "flex-col", disabled && "opacity-50 pointer-events-none", className),
969
+ ...props,
970
+ children: [
971
+ (valuePosition === "top" || valuePosition === "left") && valueDisplay,
972
+ /* @__PURE__ */ jsxs3("div", {
973
+ className: "relative flex-1 overflow-visible",
974
+ style: {
975
+ height: valuePosition === "left" || valuePosition === "right" ? THUMB_SIZE + 16 : THUMB_SIZE + (valuePosition === "tooltip" ? 16 : 0),
976
+ paddingTop: valuePosition === "tooltip" ? 16 : 0
977
+ },
978
+ onPointerEnter: () => setIsHovered(true),
979
+ onPointerLeave: () => {
980
+ setIsHovered(false);
981
+ setHoverPreview(null);
982
+ },
983
+ onMouseMove: (e) => {
984
+ if (dragging.current)
985
+ return;
986
+ const trackEl = trackRef.current;
987
+ if (!trackEl)
988
+ return;
989
+ const x = layoutX(e.clientX, trackEl);
990
+ if (x === null)
991
+ return;
992
+ computeHoverPreview(Math.max(0, Math.min(trackEl.offsetWidth, x)), trackEl.offsetWidth);
1012
993
  },
1013
- transition: spring2.fast,
1014
- onPointerDown: handlePointerDown,
1015
- onPointerMove: handlePointerMove,
1016
- onPointerUp: handlePointerUp,
1017
- onPointerCancel: handlePointerUp,
1018
- ...props,
1019
994
  children: [
1020
- /* @__PURE__ */ jsx(SliderPrimitive.Root, {
1021
- value: [value],
995
+ showValue && valuePosition === "tooltip" && /* @__PURE__ */ jsxs3(AnimatePresence2, {
996
+ children: [
997
+ isInteracting && /* @__PURE__ */ jsx3(TooltipValue, {
998
+ value: values[0],
999
+ formatValue,
1000
+ motionX: motionX0
1001
+ }, "tooltip-0"),
1002
+ isInteracting && isRange && values[1] !== undefined && /* @__PURE__ */ jsx3(TooltipValue, {
1003
+ value: values[1],
1004
+ formatValue,
1005
+ motionX: motionX1
1006
+ }, "tooltip-1")
1007
+ ]
1008
+ }),
1009
+ /* @__PURE__ */ jsx3(SliderPrimitive2.Root, {
1010
+ value: stepValues ? values.map((v) => nearestStepIndex(v, stepValues)) : values,
1022
1011
  onValueChange: (v) => handleRadixChange(v),
1023
- onValueCommitted: (v) => onValueCommitRef.current?.(v[0]),
1024
- min,
1025
- max,
1026
- step,
1012
+ name,
1013
+ min: stepValues ? 0 : min,
1014
+ max: stepValues ? stepValues.length - 1 : max,
1015
+ step: stepValues ? 1 : step,
1027
1016
  disabled,
1028
- className: "absolute inset-0 opacity-0 pointer-events-none [&_*]:pointer-events-none",
1029
- children: /* @__PURE__ */ jsxs(SliderPrimitive.Control, {
1017
+ className: "absolute inset-0 opacity-0 pointer-events-none",
1018
+ style: { height: THUMB_SIZE },
1019
+ children: /* @__PURE__ */ jsxs3(SliderPrimitive2.Control, {
1030
1020
  className: "w-full h-full",
1031
1021
  children: [
1032
- /* @__PURE__ */ jsx(SliderPrimitive.Track, {
1022
+ /* @__PURE__ */ jsx3(SliderPrimitive2.Track, {
1033
1023
  className: "w-full h-full",
1034
- children: /* @__PURE__ */ jsx(SliderPrimitive.Indicator, {})
1024
+ children: /* @__PURE__ */ jsx3(SliderPrimitive2.Indicator, {})
1035
1025
  }),
1036
- /* @__PURE__ */ jsx(SliderPrimitive.Thumb, {
1026
+ /* @__PURE__ */ jsx3(SliderPrimitive2.Thumb, {
1037
1027
  index: 0,
1038
- "aria-label": ariaLabel || label,
1028
+ "aria-label": thumbAriaLabel(0),
1029
+ getAriaValueText: stepValues ? () => formatValue(values[0]) : undefined,
1039
1030
  className: "block outline-none",
1031
+ style: { width: THUMB_SIZE, height: THUMB_SIZE },
1040
1032
  onFocus: (e) => {
1041
- if (e.target.matches(":focus-visible"))
1042
- setIsFocused(true);
1033
+ if (e.currentTarget.matches(":focus-visible"))
1034
+ setFocusedThumb(0);
1043
1035
  },
1044
- onBlur: () => setIsFocused(false)
1045
- })
1046
- ]
1047
- })
1048
- }),
1049
- /* @__PURE__ */ jsx(motion.div, {
1050
- className: "absolute inset-y-0 bg-accent/40 pointer-events-none z-[3]",
1051
- initial: false,
1052
- animate: {
1053
- opacity: hoverPreview && !isPressed ? 1 : 0
1054
- },
1055
- transition: { opacity: { duration: 0.15 } },
1056
- style: {
1057
- left: hoverPreview ? hoverPreview.left : 0,
1058
- width: hoverPreview ? hoverPreview.width : 0
1059
- }
1060
- }),
1061
- variant === "pips" && /* @__PURE__ */ jsx(motion.div, {
1062
- className: "absolute inset-0 flex justify-between items-center px-3 pointer-events-none z-[1]",
1063
- style: { WebkitMaskImage: pipsMaskStyle, maskImage: pipsMaskStyle },
1064
- children: pipSteps.map((pipValue) => {
1065
- const isActivePip = pipValue === value;
1066
- return /* @__PURE__ */ jsx("div", {
1067
- className: "relative flex items-center justify-center",
1068
- style: { width: PIP_SIZE, height: PIP_SIZE },
1069
- children: /* @__PURE__ */ jsx(motion.div, {
1070
- className: "rounded-full",
1071
- initial: false,
1072
- animate: {
1073
- backgroundColor: isActivePip ? "var(--foreground)" : "var(--muted-foreground)",
1074
- opacity: isActivePip ? 1 : 0.3
1036
+ onBlur: () => setFocusedThumb((prev) => prev === 0 ? null : prev)
1037
+ }),
1038
+ isRange && /* @__PURE__ */ jsx3(SliderPrimitive2.Thumb, {
1039
+ index: 1,
1040
+ "aria-label": thumbAriaLabel(1),
1041
+ getAriaValueText: stepValues ? () => formatValue(values[1]) : undefined,
1042
+ className: "block outline-none",
1043
+ style: { width: THUMB_SIZE, height: THUMB_SIZE },
1044
+ onFocus: (e) => {
1045
+ if (e.currentTarget.matches(":focus-visible"))
1046
+ setFocusedThumb(1);
1075
1047
  },
1076
- transition: spring2.fast,
1077
- style: { width: PIP_SIZE, height: PIP_SIZE }
1048
+ onBlur: () => setFocusedThumb((prev) => prev === 1 ? null : prev)
1078
1049
  })
1079
- }, pipValue);
1050
+ ]
1080
1051
  })
1081
1052
  }),
1082
- variant === "pips" && /* @__PURE__ */ jsxs("div", {
1083
- className: "absolute inset-0 flex items-center px-2 z-[2] pointer-events-none",
1084
- "aria-hidden": true,
1053
+ /* @__PURE__ */ jsxs3("div", {
1054
+ ref: trackRef,
1055
+ className: "relative w-full cursor-ew-resize py-2",
1056
+ style: { height: THUMB_SIZE + 16, opacity: ready ? 1 : 0 },
1057
+ onPointerDown: handlePointerDown,
1058
+ onPointerMove: handlePointerMove,
1059
+ onPointerUp: handlePointerUp,
1060
+ onPointerCancel: handlePointerUp,
1085
1061
  children: [
1086
- label && /* @__PURE__ */ jsx("span", {
1087
- className: "text-body px-2 bg-background text-transparent select-none",
1088
- children: label
1062
+ /* @__PURE__ */ jsx3("div", {
1063
+ className: "absolute cursor-ew-resize",
1064
+ style: { left: -8, right: -8, top: 0, bottom: 0 },
1065
+ onPointerDown: handlePointerDown,
1066
+ onPointerMove: handlePointerMove,
1067
+ onPointerUp: handlePointerUp,
1068
+ onPointerCancel: handlePointerUp
1089
1069
  }),
1090
- /* @__PURE__ */ jsx("span", {
1091
- className: "text-body tabular-nums ml-auto px-2 bg-background text-transparent select-none",
1092
- style: { minWidth: `${String(formatValue(max)).length}ch` },
1093
- children: formatValue(value)
1094
- })
1095
- ]
1096
- }),
1097
- variant === "pips" && /* @__PURE__ */ jsx(motion.div, {
1098
- className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none z-[3]",
1099
- style: {
1100
- width: pipsFillWidthStyle
1101
- }
1102
- }),
1103
- variant === "pips" && /* @__PURE__ */ jsx(motion.div, {
1104
- className: "absolute rounded-full pointer-events-none z-[3]",
1105
- initial: false,
1106
- animate: {
1107
- top: isActive ? 7 : 8,
1108
- bottom: isActive ? 7 : 8,
1109
- backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
1110
- },
1111
- transition: spring2.fast,
1112
- style: {
1113
- left: pipsHandleLineLeftStyle,
1114
- width: 2
1115
- }
1116
- }),
1117
- variant === "pips" && /* @__PURE__ */ jsxs("div", {
1118
- className: "absolute inset-0 flex items-center px-2 z-[4] pointer-events-none",
1119
- children: [
1120
- label && /* @__PURE__ */ jsx(motion.span, {
1121
- className: "text-body px-2",
1122
- initial: false,
1123
- animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
1124
- transition: spring2.fast,
1125
- children: label
1070
+ /* @__PURE__ */ jsx3(AnimatePresence2, {
1071
+ children: hoverPreview && showHoverTooltip && !isPressed && valuePosition !== "tooltip" && /* @__PURE__ */ jsx3(motion3.div, {
1072
+ className: "absolute -translate-x-1/2 pointer-events-none z-20",
1073
+ initial: { opacity: 0, y: 4 },
1074
+ animate: { opacity: 1, y: 0 },
1075
+ exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
1076
+ transition: spring2.fast,
1077
+ style: {
1078
+ left: hoverPreview.cursorX,
1079
+ top: -20
1080
+ },
1081
+ children: /* @__PURE__ */ jsx3(ValueBubble, {
1082
+ children: formatValue(hoverPreview.snappedValue)
1083
+ })
1084
+ }, "hover-tooltip")
1126
1085
  }),
1127
- /* @__PURE__ */ jsx(motion.span, {
1128
- className: "text-body tabular-nums ml-auto px-2",
1086
+ /* @__PURE__ */ jsxs3(motion3.div, {
1087
+ className: cn2("absolute bg-transparent border border-border overflow-hidden rounded-full", trackClassName),
1129
1088
  initial: false,
1130
- animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
1089
+ animate: {
1090
+ height: TRACK_BG_HEIGHT,
1091
+ top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2
1092
+ },
1131
1093
  transition: spring2.fast,
1132
- style: { minWidth: `${String(formatValue(max)).length}ch`, textAlign: "right" },
1133
- children: formatValue(value)
1134
- })
1135
- ]
1136
- }),
1137
- variant === "scrubber" && /* @__PURE__ */ jsx(motion.div, {
1138
- className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none",
1139
- style: {
1140
- width: fillWidthStyle
1141
- }
1142
- }),
1143
- variant === "scrubber" && /* @__PURE__ */ jsx(motion.div, {
1144
- className: "absolute rounded-full pointer-events-none z-10",
1145
- initial: false,
1146
- animate: {
1147
- top: isActive ? 7 : 8,
1148
- bottom: isActive ? 7 : 8,
1149
- backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
1150
- },
1151
- transition: spring2.fast,
1152
- style: {
1153
- left: handleLineLeftStyle,
1154
- width: 2
1155
- }
1156
- }),
1157
- variant === "scrubber" && label && /* @__PURE__ */ jsx(motion.span, {
1158
- className: "text-body shrink-0 z-10",
1159
- initial: false,
1160
- animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
1161
- transition: spring2.fast,
1162
- children: label
1163
- }),
1164
- variant === "scrubber" && /* @__PURE__ */ jsxs(Fragment, {
1165
- children: [
1166
- /* @__PURE__ */ jsx("div", {
1167
- className: "flex-1"
1094
+ style: {
1095
+ left: TRACK_INSET,
1096
+ right: TRACK_INSET,
1097
+ ...trackStyle
1098
+ },
1099
+ children: [
1100
+ !hideFill && /* @__PURE__ */ jsx3(motion3.div, {
1101
+ className: cn2("absolute h-full bg-selected/50 dark:bg-accent/40", fillClassName),
1102
+ style: {
1103
+ left: fillLeft,
1104
+ width: fillWidth,
1105
+ ...fillStyle
1106
+ }
1107
+ }),
1108
+ /* @__PURE__ */ jsx3(motion3.div, {
1109
+ className: "absolute h-full bg-accent/40 pointer-events-none z-[2]",
1110
+ initial: false,
1111
+ animate: {
1112
+ opacity: hoverPreview && !isPressed ? 1 : 0
1113
+ },
1114
+ transition: {
1115
+ opacity: { duration: 0.15 }
1116
+ },
1117
+ style: {
1118
+ left: hoverPreview ? hoverPreview.left - TRACK_INSET : 0,
1119
+ width: hoverPreview ? hoverPreview.width : 0,
1120
+ borderRadius: hoverPreview && hoverPreview.cursorX > hoverPreview.left ? "0 9999px 9999px 0" : "9999px 0 0 9999px"
1121
+ }
1122
+ })
1123
+ ]
1168
1124
  }),
1169
- /* @__PURE__ */ jsx(motion.span, {
1170
- className: "text-body shrink-0 tabular-nums text-right z-10",
1171
- initial: false,
1172
- animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
1173
- transition: spring2.fast,
1174
- style: { minWidth: `${String(formatValue(max)).length}ch` },
1175
- children: formatValue(value)
1176
- })
1125
+ stepDots.length > 0 && /* @__PURE__ */ jsx3(motion3.div, {
1126
+ className: "absolute left-0 right-0 pointer-events-none",
1127
+ style: {
1128
+ top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2,
1129
+ height: TRACK_BG_HEIGHT,
1130
+ WebkitMaskImage: stepDotsMask,
1131
+ maskImage: stepDotsMask
1132
+ },
1133
+ children: stepDots.map(({ value: v, percent }) => /* @__PURE__ */ jsx3("div", {
1134
+ className: "absolute pointer-events-none flex items-center justify-center",
1135
+ style: {
1136
+ left: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
1137
+ top: "50%",
1138
+ width: 0,
1139
+ height: 0
1140
+ },
1141
+ children: /* @__PURE__ */ jsx3(motion3.div, {
1142
+ className: "rounded-full flex-shrink-0 bg-muted-foreground opacity-30",
1143
+ initial: false,
1144
+ animate: {
1145
+ width: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE,
1146
+ height: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE
1147
+ },
1148
+ transition: spring2.moderate
1149
+ })
1150
+ }, v))
1151
+ }),
1152
+ renderVisualThumb(0),
1153
+ isRange && renderVisualThumb(1)
1177
1154
  ]
1178
- }),
1179
- variant === "scrubber" && /* @__PURE__ */ jsx(motion.div, {
1180
- className: "absolute top-0 bottom-0 w-2 cursor-ew-resize z-20",
1181
- style: { left: handleLeftStyle },
1182
- onPointerDown: handleResizePointerDown,
1183
- onPointerMove: handleResizePointerMove,
1184
- onPointerUp: handleResizePointerUp,
1185
- onPointerCancel: handleResizePointerUp
1186
1155
  })
1187
1156
  ]
1188
- })
1157
+ }),
1158
+ (valuePosition === "bottom" || valuePosition === "right") && valueDisplay
1189
1159
  ]
1190
1160
  });
1191
1161
  });
1192
- ComfortableSlider.displayName = "SliderComfortable";
1193
- var Slider2 = forwardRef(({ size, variant = "pips", value: valueProp, defaultValue, onChange: onChangeProp, ...rest }, ref) => {
1194
- const [value, onChange] = useControllableState2(valueProp, defaultValue ?? (rest.steps && rest.steps.length > 0 ? Math.min(...rest.steps) : rest.min ?? 0), onChangeProp);
1195
- const props = { ...rest, value, onChange };
1162
+ CompactSlider.displayName = "CompactSlider";
1163
+
1164
+ // components/inputs/slider/index.tsx
1165
+ import { jsx as jsx4 } from "react/jsx-runtime";
1166
+ /*!
1167
+ * Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
1168
+ * `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
1169
+ * MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
1170
+ * Local changes: see PORTING.md.
1171
+ */
1172
+ var COMPACT_ONLY = [
1173
+ "steps",
1174
+ "showSteps",
1175
+ "showValue",
1176
+ "valuePosition",
1177
+ "trackClassName",
1178
+ "trackStyle",
1179
+ "fillClassName",
1180
+ "fillStyle",
1181
+ "hideFill",
1182
+ "thumbColor",
1183
+ "thumbBorderColor"
1184
+ ];
1185
+ var Slider2 = forwardRef3(({ size, variant = "pips", value: valueProp, defaultValue, onValueChange, ...rest }, ref) => {
1186
+ const [value, setValue] = useControllableState2(valueProp, defaultValue ?? (rest.steps && rest.steps.length > 0 ? Math.min(...rest.steps) : rest.min ?? 0), onValueChange);
1196
1187
  const resolved = useSizeVariant2(size);
1197
- const needsCompactEngine = Array.isArray(props.value) || props.steps !== undefined || props.showSteps !== undefined || props.showValue !== undefined || props.valuePosition !== undefined || props.trackClassName !== undefined || props.trackStyle !== undefined || props.fillClassName !== undefined || props.fillStyle !== undefined || props.hideFill !== undefined || props.thumbColor !== undefined || props.thumbBorderColor !== undefined || props.orientation === "vertical";
1198
- if (resolved === "compact" || needsCompactEngine) {
1199
- return /* @__PURE__ */ jsx(CompactSlider, {
1188
+ if (resolved === "compact" || Array.isArray(value) || COMPACT_ONLY.some((key) => rest[key] !== undefined)) {
1189
+ return /* @__PURE__ */ jsx4(CompactSlider, {
1200
1190
  ref,
1201
- ...props
1191
+ ...rest,
1192
+ value,
1193
+ onValueChange: setValue
1202
1194
  });
1203
1195
  }
1204
1196
  const {
1205
- value: singleValue,
1206
- onChange: singleOnChange,
1207
- min,
1208
- max,
1209
- step,
1210
- label,
1211
- formatValue,
1212
- disabled,
1213
- onValueCommit,
1214
- steps: _steps,
1215
- showSteps: _showSteps,
1216
- showValue: _showValue,
1217
- valuePosition: _valuePosition,
1218
- trackClassName: _trackClassName,
1219
- trackStyle: _trackStyle,
1220
- fillClassName: _fillClassName,
1221
- fillStyle: _fillStyle,
1222
- hideFill: _hideFill,
1223
- thumbColor: _thumbColor,
1224
- thumbBorderColor: _thumbBorderColor,
1225
- orientation: _orientation,
1226
- ...html
1227
- } = props;
1228
- return /* @__PURE__ */ jsx(ComfortableSlider, {
1197
+ steps,
1198
+ showSteps,
1199
+ showValue,
1200
+ valuePosition,
1201
+ trackClassName,
1202
+ trackStyle,
1203
+ fillClassName,
1204
+ fillStyle,
1205
+ hideFill,
1206
+ thumbColor,
1207
+ thumbBorderColor,
1208
+ ...comfortable
1209
+ } = rest;
1210
+ return /* @__PURE__ */ jsx4(ComfortableSlider, {
1229
1211
  ref,
1230
- value: singleValue,
1231
- onChange: singleOnChange,
1232
- min,
1233
- max,
1234
- step,
1235
- variant,
1236
- label,
1237
- formatValue,
1238
- disabled,
1239
- onValueCommit,
1240
- ...html
1212
+ ...comfortable,
1213
+ value,
1214
+ onValueChange: setValue,
1215
+ variant
1241
1216
  });
1242
1217
  });
1243
1218
  Slider2.displayName = "Slider";
1244
- var SliderComfortable2 = ComfortableSlider;
1245
1219
  var slider_default = Slider2;
1246
1220
 
1247
- export { Slider2, SliderComfortable2, slider_default };
1221
+ export { Slider2, slider_default };