@seekalfred/primitives 0.5.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +682 -19
  2. package/dist/accordion/accordion.js +10 -4
  3. package/dist/accordion/accordion.js.map +1 -1
  4. package/dist/action-button/action-button.d.ts +50 -0
  5. package/dist/action-button/action-button.js +159 -0
  6. package/dist/action-button/action-button.js.map +1 -0
  7. package/dist/action-button/index.d.ts +2 -0
  8. package/dist/action-button/index.js +2 -0
  9. package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
  10. package/dist/activity-heatmap/activity-heatmap.js +699 -0
  11. package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
  12. package/dist/activity-heatmap/index.d.ts +2 -0
  13. package/dist/activity-heatmap/index.js +2 -0
  14. package/dist/alert/alert.d.ts +19 -1
  15. package/dist/alert/alert.js +180 -23
  16. package/dist/alert/alert.js.map +1 -1
  17. package/dist/alert-dialog/alert-dialog.d.ts +45 -18
  18. package/dist/alert-dialog/alert-dialog.js +128 -9
  19. package/dist/alert-dialog/alert-dialog.js.map +1 -1
  20. package/dist/alert-dialog/index.d.ts +2 -2
  21. package/dist/alert-dialog/index.js +2 -2
  22. package/dist/animated-counter/animated-counter.d.ts +38 -0
  23. package/dist/animated-counter/animated-counter.js +230 -0
  24. package/dist/animated-counter/animated-counter.js.map +1 -0
  25. package/dist/animated-counter/index.d.ts +2 -0
  26. package/dist/animated-counter/index.js +2 -0
  27. package/dist/announcement-bar/announcement-bar.d.ts +67 -0
  28. package/dist/announcement-bar/announcement-bar.js +364 -0
  29. package/dist/announcement-bar/announcement-bar.js.map +1 -0
  30. package/dist/announcement-bar/index.d.ts +2 -0
  31. package/dist/announcement-bar/index.js +2 -0
  32. package/dist/avatar/avatar.d.ts +6 -0
  33. package/dist/avatar/avatar.js +47 -16
  34. package/dist/avatar/avatar.js.map +1 -1
  35. package/dist/badge/badge.d.ts +10 -3
  36. package/dist/badge/badge.js +35 -5
  37. package/dist/badge/badge.js.map +1 -1
  38. package/dist/bar-chart/bar-chart.d.ts +51 -0
  39. package/dist/bar-chart/bar-chart.js +565 -0
  40. package/dist/bar-chart/bar-chart.js.map +1 -0
  41. package/dist/bar-chart/index.d.ts +2 -0
  42. package/dist/bar-chart/index.js +2 -0
  43. package/dist/breadcrumb/breadcrumb.d.ts +2 -29
  44. package/dist/breadcrumb/breadcrumb.js +32 -9
  45. package/dist/breadcrumb/breadcrumb.js.map +1 -1
  46. package/dist/brush-chart/brush-chart.d.ts +64 -0
  47. package/dist/brush-chart/brush-chart.js +1056 -0
  48. package/dist/brush-chart/brush-chart.js.map +1 -0
  49. package/dist/brush-chart/index.d.ts +2 -0
  50. package/dist/brush-chart/index.js +2 -0
  51. package/dist/button/button.d.ts +36 -23
  52. package/dist/button/button.js +198 -45
  53. package/dist/button/button.js.map +1 -1
  54. package/dist/button-group/button-group.d.ts +76 -0
  55. package/dist/button-group/button-group.js +402 -0
  56. package/dist/button-group/button-group.js.map +1 -0
  57. package/dist/button-group/index.d.ts +2 -0
  58. package/dist/button-group/index.js +2 -0
  59. package/dist/calendar/calendar.d.ts +1 -1
  60. package/dist/calendar/calendar.js +257 -30
  61. package/dist/calendar/calendar.js.map +1 -1
  62. package/dist/card/card.d.ts +9 -2
  63. package/dist/card/card.js +16 -5
  64. package/dist/card/card.js.map +1 -1
  65. package/dist/card-stack/card-stack.d.ts +54 -0
  66. package/dist/card-stack/card-stack.js +492 -0
  67. package/dist/card-stack/card-stack.js.map +1 -0
  68. package/dist/card-stack/index.d.ts +2 -0
  69. package/dist/card-stack/index.js +2 -0
  70. package/dist/carousel/carousel.d.ts +56 -0
  71. package/dist/carousel/carousel.js +389 -0
  72. package/dist/carousel/carousel.js.map +1 -0
  73. package/dist/carousel/index.d.ts +2 -0
  74. package/dist/carousel/index.js +2 -0
  75. package/dist/checkbox/checkbox.d.ts +0 -7
  76. package/dist/checkbox/checkbox.js +26 -29
  77. package/dist/checkbox/checkbox.js.map +1 -1
  78. package/dist/chip-group/chip-group.d.ts +37 -0
  79. package/dist/chip-group/chip-group.js +148 -0
  80. package/dist/chip-group/chip-group.js.map +1 -0
  81. package/dist/chip-group/index.d.ts +2 -0
  82. package/dist/chip-group/index.js +2 -0
  83. package/dist/confirm-morph/confirm-morph.d.ts +85 -0
  84. package/dist/confirm-morph/confirm-morph.js +652 -0
  85. package/dist/confirm-morph/confirm-morph.js.map +1 -0
  86. package/dist/confirm-morph/index.d.ts +2 -0
  87. package/dist/confirm-morph/index.js +2 -0
  88. package/dist/copy-button/copy-button.d.ts +32 -0
  89. package/dist/copy-button/copy-button.js +134 -0
  90. package/dist/copy-button/copy-button.js.map +1 -0
  91. package/dist/copy-button/index.d.ts +2 -0
  92. package/dist/copy-button/index.js +2 -0
  93. package/dist/countdown/countdown.d.ts +45 -0
  94. package/dist/countdown/countdown.js +298 -0
  95. package/dist/countdown/countdown.js.map +1 -0
  96. package/dist/countdown/index.d.ts +2 -0
  97. package/dist/countdown/index.js +2 -0
  98. package/dist/date-picker/date-picker.d.ts +51 -0
  99. package/dist/date-picker/date-picker.js +241 -0
  100. package/dist/date-picker/date-picker.js.map +1 -0
  101. package/dist/date-picker/date-range-picker.d.ts +78 -0
  102. package/dist/date-picker/date-range-picker.js +1015 -0
  103. package/dist/date-picker/date-range-picker.js.map +1 -0
  104. package/dist/date-picker/index.d.ts +4 -0
  105. package/dist/date-picker/index.js +4 -0
  106. package/dist/date-picker/picker-parts.d.ts +46 -0
  107. package/dist/date-picker/picker-parts.js +135 -0
  108. package/dist/date-picker/picker-parts.js.map +1 -0
  109. package/dist/dialog/dialog.d.ts +10 -14
  110. package/dist/dialog/dialog.js +40 -12
  111. package/dist/dialog/dialog.js.map +1 -1
  112. package/dist/donut-chart/donut-chart.d.ts +64 -0
  113. package/dist/donut-chart/donut-chart.js +576 -0
  114. package/dist/donut-chart/donut-chart.js.map +1 -0
  115. package/dist/donut-chart/index.d.ts +2 -0
  116. package/dist/donut-chart/index.js +2 -0
  117. package/dist/empty-state/empty-state.d.ts +55 -0
  118. package/dist/empty-state/empty-state.js +89 -0
  119. package/dist/empty-state/empty-state.js.map +1 -0
  120. package/dist/empty-state/index.d.ts +2 -0
  121. package/dist/empty-state/index.js +2 -0
  122. package/dist/expanding-button-group/expanding-button-group.d.ts +54 -0
  123. package/dist/expanding-button-group/expanding-button-group.js +350 -0
  124. package/dist/expanding-button-group/expanding-button-group.js.map +1 -0
  125. package/dist/expanding-button-group/index.d.ts +2 -0
  126. package/dist/expanding-button-group/index.js +2 -0
  127. package/dist/file-drop-zone/file-drop-zone.d.ts +71 -0
  128. package/dist/file-drop-zone/file-drop-zone.js +116 -0
  129. package/dist/file-drop-zone/file-drop-zone.js.map +1 -0
  130. package/dist/file-drop-zone/index.d.ts +2 -0
  131. package/dist/file-drop-zone/index.js +2 -0
  132. package/dist/filter-bar/filter-bar.d.ts +142 -0
  133. package/dist/filter-bar/filter-bar.js +416 -0
  134. package/dist/filter-bar/filter-bar.js.map +1 -0
  135. package/dist/filter-bar/index.d.ts +2 -0
  136. package/dist/filter-bar/index.js +2 -0
  137. package/dist/floating-button-group/floating-button-group.d.ts +61 -0
  138. package/dist/floating-button-group/floating-button-group.js +340 -0
  139. package/dist/floating-button-group/floating-button-group.js.map +1 -0
  140. package/dist/floating-button-group/index.d.ts +2 -0
  141. package/dist/floating-button-group/index.js +2 -0
  142. package/dist/gauge/gauge.d.ts +45 -0
  143. package/dist/gauge/gauge.js +219 -0
  144. package/dist/gauge/gauge.js.map +1 -0
  145. package/dist/gauge/index.d.ts +2 -0
  146. package/dist/gauge/index.js +2 -0
  147. package/dist/icon-morph/icon-morph.d.ts +55 -0
  148. package/dist/icon-morph/icon-morph.js +331 -0
  149. package/dist/icon-morph/icon-morph.js.map +1 -0
  150. package/dist/icon-morph/index.d.ts +2 -0
  151. package/dist/icon-morph/index.js +2 -0
  152. package/dist/in-view-title/in-view-title.d.ts +33 -0
  153. package/dist/in-view-title/in-view-title.js +119 -0
  154. package/dist/in-view-title/in-view-title.js.map +1 -0
  155. package/dist/in-view-title/index.d.ts +2 -0
  156. package/dist/in-view-title/index.js +2 -0
  157. package/dist/index.d.ts +71 -6
  158. package/dist/index.js +73 -11
  159. package/dist/input/input.d.ts +22 -0
  160. package/dist/input/input.js +36 -12
  161. package/dist/input/input.js.map +1 -1
  162. package/dist/lib/cn.js +11 -1
  163. package/dist/lib/cn.js.map +1 -1
  164. package/dist/lib/count-to.js +113 -0
  165. package/dist/lib/count-to.js.map +1 -0
  166. package/dist/lib/eye-morph.js +62 -0
  167. package/dist/lib/eye-morph.js.map +1 -0
  168. package/dist/lib/field-message.js +354 -0
  169. package/dist/lib/field-message.js.map +1 -0
  170. package/dist/lib/field-shell.js +81 -0
  171. package/dist/lib/field-shell.js.map +1 -0
  172. package/dist/lib/field-surface.js +11 -8
  173. package/dist/lib/field-surface.js.map +1 -1
  174. package/dist/lib/flag-emoji.js +50 -0
  175. package/dist/lib/flag-emoji.js.map +1 -0
  176. package/dist/lib/flip.js +88 -0
  177. package/dist/lib/flip.js.map +1 -0
  178. package/dist/lib/height-follow.js +59 -0
  179. package/dist/lib/height-follow.js.map +1 -0
  180. package/dist/lib/icon-swap.js +47 -0
  181. package/dist/lib/icon-swap.js.map +1 -0
  182. package/dist/lib/leaving-list.js +57 -0
  183. package/dist/lib/leaving-list.js.map +1 -0
  184. package/dist/lib/menu-highlight.js +64 -0
  185. package/dist/lib/menu-highlight.js.map +1 -0
  186. package/dist/lib/merge-refs.js +3 -3
  187. package/dist/lib/merge-refs.js.map +1 -1
  188. package/dist/lib/morph-text.js +128 -0
  189. package/dist/lib/morph-text.js.map +1 -0
  190. package/dist/lib/motion.js +169 -0
  191. package/dist/lib/motion.js.map +1 -0
  192. package/dist/lib/pausable-timeout.js +67 -0
  193. package/dist/lib/pausable-timeout.js.map +1 -0
  194. package/dist/lib/rolling-value.js +31 -0
  195. package/dist/lib/rolling-value.js.map +1 -0
  196. package/dist/lib/spring-progress.js +114 -0
  197. package/dist/lib/spring-progress.js.map +1 -0
  198. package/dist/lib/spring-tween.js +500 -0
  199. package/dist/lib/spring-tween.js.map +1 -0
  200. package/dist/lib/svg-id.js +10 -0
  201. package/dist/lib/svg-id.js.map +1 -0
  202. package/dist/lib/swap-text.js +79 -0
  203. package/dist/lib/swap-text.js.map +1 -0
  204. package/dist/lib/use-copy-feedback.js +36 -0
  205. package/dist/lib/use-copy-feedback.js.map +1 -0
  206. package/dist/line-chart/index.d.ts +2 -0
  207. package/dist/line-chart/index.js +2 -0
  208. package/dist/line-chart/line-chart.d.ts +76 -0
  209. package/dist/line-chart/line-chart.js +611 -0
  210. package/dist/line-chart/line-chart.js.map +1 -0
  211. package/dist/mention-input/index.d.ts +2 -0
  212. package/dist/mention-input/index.js +2 -0
  213. package/dist/mention-input/mention-input.d.ts +98 -0
  214. package/dist/mention-input/mention-input.js +576 -0
  215. package/dist/mention-input/mention-input.js.map +1 -0
  216. package/dist/menu/menu.d.ts +2 -0
  217. package/dist/menu/menu.js +23 -12
  218. package/dist/menu/menu.js.map +1 -1
  219. package/dist/money-input/index.d.ts +2 -0
  220. package/dist/money-input/index.js +2 -0
  221. package/dist/money-input/money-input.d.ts +65 -0
  222. package/dist/money-input/money-input.js +607 -0
  223. package/dist/money-input/money-input.js.map +1 -0
  224. package/dist/morph-select/index.d.ts +2 -0
  225. package/dist/morph-select/index.js +2 -0
  226. package/dist/morph-select/morph-select.d.ts +71 -0
  227. package/dist/morph-select/morph-select.js +693 -0
  228. package/dist/morph-select/morph-select.js.map +1 -0
  229. package/dist/multi-select/index.d.ts +2 -0
  230. package/dist/multi-select/index.js +2 -0
  231. package/dist/multi-select/multi-select.d.ts +36 -0
  232. package/dist/multi-select/multi-select.js +152 -0
  233. package/dist/multi-select/multi-select.js.map +1 -0
  234. package/dist/number-field/index.d.ts +2 -0
  235. package/dist/number-field/index.js +2 -0
  236. package/dist/number-field/number-field.d.ts +42 -0
  237. package/dist/number-field/number-field.js +199 -0
  238. package/dist/number-field/number-field.js.map +1 -0
  239. package/dist/onboarding-checklist/index.d.ts +2 -0
  240. package/dist/onboarding-checklist/index.js +2 -0
  241. package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
  242. package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
  243. package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
  244. package/dist/page-header/index.d.ts +2 -0
  245. package/dist/page-header/index.js +2 -0
  246. package/dist/page-header/page-header.d.ts +75 -0
  247. package/dist/page-header/page-header.js +83 -0
  248. package/dist/page-header/page-header.js.map +1 -0
  249. package/dist/password-field/index.d.ts +2 -0
  250. package/dist/password-field/index.js +2 -0
  251. package/dist/password-field/password-field.d.ts +37 -0
  252. package/dist/password-field/password-field.js +101 -0
  253. package/dist/password-field/password-field.js.map +1 -0
  254. package/dist/password-strength/index.d.ts +2 -0
  255. package/dist/password-strength/index.js +2 -0
  256. package/dist/password-strength/password-strength.d.ts +127 -0
  257. package/dist/password-strength/password-strength.js +455 -0
  258. package/dist/password-strength/password-strength.js.map +1 -0
  259. package/dist/phone-input/index.d.ts +3 -0
  260. package/dist/phone-input/index.js +3 -0
  261. package/dist/phone-input/phone-countries.d.ts +29 -0
  262. package/dist/phone-input/phone-countries.js +170 -0
  263. package/dist/phone-input/phone-countries.js.map +1 -0
  264. package/dist/phone-input/phone-input.d.ts +66 -0
  265. package/dist/phone-input/phone-input.js +440 -0
  266. package/dist/phone-input/phone-input.js.map +1 -0
  267. package/dist/popover/popover.d.ts +20 -0
  268. package/dist/popover/popover.js +33 -9
  269. package/dist/popover/popover.js.map +1 -1
  270. package/dist/progress/progress.js +46 -5
  271. package/dist/progress/progress.js.map +1 -1
  272. package/dist/radio-group/radio-group.js +8 -7
  273. package/dist/radio-group/radio-group.js.map +1 -1
  274. package/dist/reactions/index.d.ts +2 -0
  275. package/dist/reactions/index.js +2 -0
  276. package/dist/reactions/reactions.d.ts +50 -0
  277. package/dist/reactions/reactions.js +315 -0
  278. package/dist/reactions/reactions.js.map +1 -0
  279. package/dist/rich-text-editor/index.d.ts +3 -0
  280. package/dist/rich-text-editor/index.js +2 -0
  281. package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
  282. package/dist/rich-text-editor/rich-text-editor.js +909 -0
  283. package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
  284. package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
  285. package/dist/rich-text-editor/rich-text-engine.js +366 -0
  286. package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
  287. package/dist/rich-text-editor/rich-text-html.js +174 -0
  288. package/dist/rich-text-editor/rich-text-html.js.map +1 -0
  289. package/dist/rich-text-editor/rich-text-icons.js +43 -0
  290. package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
  291. package/dist/ridgeline/index.d.ts +2 -0
  292. package/dist/ridgeline/index.js +2 -0
  293. package/dist/ridgeline/ridgeline.d.ts +55 -0
  294. package/dist/ridgeline/ridgeline.js +701 -0
  295. package/dist/ridgeline/ridgeline.js.map +1 -0
  296. package/dist/scroll-area/index.d.ts +2 -2
  297. package/dist/scroll-area/index.js +2 -2
  298. package/dist/scroll-area/scroll-area.d.ts +75 -28
  299. package/dist/scroll-area/scroll-area.js +212 -41
  300. package/dist/scroll-area/scroll-area.js.map +1 -1
  301. package/dist/scrub-input/evaluate.d.ts +14 -0
  302. package/dist/scrub-input/evaluate.js +72 -0
  303. package/dist/scrub-input/evaluate.js.map +1 -0
  304. package/dist/scrub-input/index.d.ts +3 -0
  305. package/dist/scrub-input/index.js +3 -0
  306. package/dist/scrub-input/scrub-input.d.ts +74 -0
  307. package/dist/scrub-input/scrub-input.js +486 -0
  308. package/dist/scrub-input/scrub-input.js.map +1 -0
  309. package/dist/search-field/index.d.ts +2 -0
  310. package/dist/search-field/index.js +2 -0
  311. package/dist/search-field/search-field.d.ts +27 -0
  312. package/dist/search-field/search-field.js +155 -0
  313. package/dist/search-field/search-field.js.map +1 -0
  314. package/dist/select/select.d.ts +3 -1
  315. package/dist/select/select.js +95 -25
  316. package/dist/select/select.js.map +1 -1
  317. package/dist/separator/separator.d.ts +1 -1
  318. package/dist/sheet/sheet.js +4 -2
  319. package/dist/sheet/sheet.js.map +1 -1
  320. package/dist/shortcut-recorder/index.d.ts +3 -0
  321. package/dist/shortcut-recorder/index.js +3 -0
  322. package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
  323. package/dist/shortcut-recorder/shortcut-model.js +206 -0
  324. package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
  325. package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
  326. package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
  327. package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
  328. package/dist/side-nav/index.d.ts +2 -0
  329. package/dist/side-nav/index.js +2 -0
  330. package/dist/side-nav/side-nav.d.ts +72 -0
  331. package/dist/side-nav/side-nav.js +142 -0
  332. package/dist/side-nav/side-nav.js.map +1 -0
  333. package/dist/skeleton/skeleton.d.ts +8 -2
  334. package/dist/skeleton/skeleton.js +6 -2
  335. package/dist/skeleton/skeleton.js.map +1 -1
  336. package/dist/slider/index.d.ts +2 -2
  337. package/dist/slider/slider.d.ts +46 -14
  338. package/dist/slider/slider.js +188 -50
  339. package/dist/slider/slider.js.map +1 -1
  340. package/dist/slope-chart/index.d.ts +2 -0
  341. package/dist/slope-chart/index.js +2 -0
  342. package/dist/slope-chart/slope-chart.d.ts +54 -0
  343. package/dist/slope-chart/slope-chart.js +568 -0
  344. package/dist/slope-chart/slope-chart.js.map +1 -0
  345. package/dist/sparkline/index.d.ts +2 -0
  346. package/dist/sparkline/index.js +2 -0
  347. package/dist/sparkline/sparkline.d.ts +46 -0
  348. package/dist/sparkline/sparkline.js +390 -0
  349. package/dist/sparkline/sparkline.js.map +1 -0
  350. package/dist/split-bar/index.d.ts +2 -0
  351. package/dist/split-bar/index.js +2 -0
  352. package/dist/split-bar/split-bar.d.ts +62 -0
  353. package/dist/split-bar/split-bar.js +513 -0
  354. package/dist/split-bar/split-bar.js.map +1 -0
  355. package/dist/split-button/index.d.ts +2 -0
  356. package/dist/split-button/index.js +2 -0
  357. package/dist/split-button/split-button.d.ts +46 -0
  358. package/dist/split-button/split-button.js +123 -0
  359. package/dist/split-button/split-button.js.map +1 -0
  360. package/dist/stat-card/index.d.ts +2 -0
  361. package/dist/stat-card/index.js +2 -0
  362. package/dist/stat-card/stat-card.d.ts +101 -0
  363. package/dist/stat-card/stat-card.js +249 -0
  364. package/dist/stat-card/stat-card.js.map +1 -0
  365. package/dist/stepper/index.d.ts +2 -0
  366. package/dist/stepper/index.js +2 -0
  367. package/dist/stepper/stepper.d.ts +51 -0
  368. package/dist/stepper/stepper.js +215 -0
  369. package/dist/stepper/stepper.js.map +1 -0
  370. package/dist/streamgraph/index.d.ts +2 -0
  371. package/dist/streamgraph/index.js +2 -0
  372. package/dist/streamgraph/streamgraph.d.ts +70 -0
  373. package/dist/streamgraph/streamgraph.js +613 -0
  374. package/dist/streamgraph/streamgraph.js.map +1 -0
  375. package/dist/styles.css +1 -1
  376. package/dist/swipe-actions/index.d.ts +2 -0
  377. package/dist/swipe-actions/index.js +2 -0
  378. package/dist/swipe-actions/swipe-actions.d.ts +67 -0
  379. package/dist/swipe-actions/swipe-actions.js +552 -0
  380. package/dist/swipe-actions/swipe-actions.js.map +1 -0
  381. package/dist/switch/switch.js +10 -9
  382. package/dist/switch/switch.js.map +1 -1
  383. package/dist/table/index.d.ts +2 -2
  384. package/dist/table/index.js +2 -2
  385. package/dist/table/table.d.ts +87 -4
  386. package/dist/table/table.js +441 -165
  387. package/dist/table/table.js.map +1 -1
  388. package/dist/tabs/tabs.js +143 -7
  389. package/dist/tabs/tabs.js.map +1 -1
  390. package/dist/tag-input/index.d.ts +2 -0
  391. package/dist/tag-input/index.js +2 -0
  392. package/dist/tag-input/tag-input.d.ts +40 -0
  393. package/dist/tag-input/tag-input.js +269 -0
  394. package/dist/tag-input/tag-input.js.map +1 -0
  395. package/dist/text-morph/index.d.ts +2 -0
  396. package/dist/text-morph/index.js +2 -0
  397. package/dist/text-morph/text-morph.d.ts +23 -0
  398. package/dist/text-morph/text-morph.js +21 -0
  399. package/dist/text-morph/text-morph.js.map +1 -0
  400. package/dist/text-reveal/index.d.ts +2 -0
  401. package/dist/text-reveal/index.js +2 -0
  402. package/dist/text-reveal/text-reveal.d.ts +27 -0
  403. package/dist/text-reveal/text-reveal.js +51 -0
  404. package/dist/text-reveal/text-reveal.js.map +1 -0
  405. package/dist/text-shimmer/index.d.ts +2 -0
  406. package/dist/text-shimmer/index.js +2 -0
  407. package/dist/text-shimmer/text-shimmer.d.ts +29 -0
  408. package/dist/text-shimmer/text-shimmer.js +29 -0
  409. package/dist/text-shimmer/text-shimmer.js.map +1 -0
  410. package/dist/textarea/textarea.d.ts +23 -0
  411. package/dist/textarea/textarea.js +24 -2
  412. package/dist/textarea/textarea.js.map +1 -1
  413. package/dist/theme-switch/index.d.ts +2 -0
  414. package/dist/theme-switch/index.js +2 -0
  415. package/dist/theme-switch/theme-switch.d.ts +37 -0
  416. package/dist/theme-switch/theme-switch.js +123 -0
  417. package/dist/theme-switch/theme-switch.js.map +1 -0
  418. package/dist/time-picker/index.d.ts +2 -0
  419. package/dist/time-picker/index.js +2 -0
  420. package/dist/time-picker/time-picker.d.ts +54 -0
  421. package/dist/time-picker/time-picker.js +201 -0
  422. package/dist/time-picker/time-picker.js.map +1 -0
  423. package/dist/toast/index.d.ts +2 -2
  424. package/dist/toast/index.js +2 -2
  425. package/dist/toast/toast.d.ts +6 -0
  426. package/dist/toast/toast.js +98 -36
  427. package/dist/toast/toast.js.map +1 -1
  428. package/dist/tooltip/tooltip.d.ts +10 -3
  429. package/dist/tooltip/tooltip.js +67 -18
  430. package/dist/tooltip/tooltip.js.map +1 -1
  431. package/dist/treemap/index.d.ts +2 -0
  432. package/dist/treemap/index.js +2 -0
  433. package/dist/treemap/treemap.d.ts +53 -0
  434. package/dist/treemap/treemap.js +699 -0
  435. package/dist/treemap/treemap.js.map +1 -0
  436. package/dist/usage-meter/index.d.ts +2 -0
  437. package/dist/usage-meter/index.js +2 -0
  438. package/dist/usage-meter/usage-meter.d.ts +50 -0
  439. package/dist/usage-meter/usage-meter.js +440 -0
  440. package/dist/usage-meter/usage-meter.js.map +1 -0
  441. package/dist/waffle-chart/index.d.ts +2 -0
  442. package/dist/waffle-chart/index.js +2 -0
  443. package/dist/waffle-chart/waffle-chart.d.ts +57 -0
  444. package/dist/waffle-chart/waffle-chart.js +426 -0
  445. package/dist/waffle-chart/waffle-chart.js.map +1 -0
  446. package/package.json +245 -3
@@ -0,0 +1,14 @@
1
+ //#region src/scrub-input/evaluate.d.ts
2
+ type Parsed = {
3
+ value: number;
4
+ unit?: string;
5
+ } | null;
6
+ /**
7
+ * Evaluates + - * / and parentheses over numbers that may carry a unit, such as
8
+ * `(100-24)/2` or `50%`. Commas read as decimal points, and `x` or the multiplication
9
+ * sign multiply. Returns `null` for anything else, or for a unit that is not in
10
+ * `units` (`deg` and the degree sign are aliases of each other).
11
+ */
12
+ export declare function evaluateScrubExpression(text: string, units: readonly string[]): Parsed;
13
+ //#endregion
14
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1,72 @@
1
+ //#region src/scrub-input/evaluate.ts
2
+ /**
3
+ * Evaluates + - * / and parentheses over numbers that may carry a unit, such as
4
+ * `(100-24)/2` or `50%`. Commas read as decimal points, and `x` or the multiplication
5
+ * sign multiply. Returns `null` for anything else, or for a unit that is not in
6
+ * `units` (`deg` and the degree sign are aliases of each other).
7
+ */
8
+ function evaluateScrubExpression(text, units) {
9
+ const source = text.trim().replace(/,/g, ".").replace(/[×x](?=\s*[\d(.])/gi, "*").replace(/÷/g, "/").replace(/−/g, "-");
10
+ if (!source) return null;
11
+ const tokens = source.match(/\d*\.?\d+(?:e[+-]?\d+)?|[a-z%°]+|[-+*/()]|\S/gi);
12
+ if (!tokens) return null;
13
+ const list = tokens;
14
+ let index = 0;
15
+ let unit;
16
+ let bad = false;
17
+ const known = units.map((entry) => entry.toLowerCase());
18
+ const peek = () => list[index];
19
+ function primary() {
20
+ const token = list[index++];
21
+ if (token === "(") {
22
+ const inner = sum();
23
+ if (list[index++] !== ")") bad = true;
24
+ return inner;
25
+ }
26
+ if (token === "-") return -primary();
27
+ if (token === "+") return primary();
28
+ if (token === void 0 || !/^\d*\.?\d+/.test(token)) {
29
+ bad = true;
30
+ return 0;
31
+ }
32
+ const number = Number(token);
33
+ const next = peek();
34
+ if (next && /^[a-z%°]+$/i.test(next)) {
35
+ index++;
36
+ const word = next.toLowerCase();
37
+ const alias = word === "°" ? "deg" : word === "deg" ? "°" : word;
38
+ const found = known.includes(word) ? known.indexOf(word) : known.indexOf(alias);
39
+ if (found < 0) bad = true;
40
+ else unit = units[found];
41
+ }
42
+ return number;
43
+ }
44
+ function product() {
45
+ let left = primary();
46
+ while (peek() === "*" || peek() === "/") {
47
+ const op = list[index++];
48
+ const right = primary();
49
+ left = op === "*" ? left * right : left / right;
50
+ }
51
+ return left;
52
+ }
53
+ function sum() {
54
+ let left = product();
55
+ while (peek() === "+" || peek() === "-") {
56
+ const op = list[index++];
57
+ const right = product();
58
+ left = op === "+" ? left + right : left - right;
59
+ }
60
+ return left;
61
+ }
62
+ const value = sum();
63
+ if (bad || index !== list.length || !Number.isFinite(value)) return null;
64
+ return {
65
+ value,
66
+ unit
67
+ };
68
+ }
69
+ //#endregion
70
+ export { evaluateScrubExpression };
71
+
72
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.js","names":[],"sources":["../../src/scrub-input/evaluate.ts"],"sourcesContent":["type Parsed = { value: number; unit?: string } | null;\n\n/**\n * Evaluates + - * / and parentheses over numbers that may carry a unit, such as\n * `(100-24)/2` or `50%`. Commas read as decimal points, and `x` or the multiplication\n * sign multiply. Returns `null` for anything else, or for a unit that is not in\n * `units` (`deg` and the degree sign are aliases of each other).\n */\nexport function evaluateScrubExpression(text: string, units: readonly string[]): Parsed {\n const source = text\n .trim()\n .replace(/,/g, \".\")\n .replace(/[×x](?=\\s*[\\d(.])/gi, \"*\")\n .replace(/÷/g, \"/\")\n .replace(/−/g, \"-\");\n if (!source) return null;\n const tokens = source.match(/\\d*\\.?\\d+(?:e[+-]?\\d+)?|[a-z%°]+|[-+*/()]|\\S/gi);\n if (!tokens) return null;\n const list = tokens;\n let index = 0;\n let unit: string | undefined;\n let bad = false;\n const known = units.map((entry) => entry.toLowerCase());\n const peek = () => list[index];\n\n function primary(): number {\n const token = list[index++];\n if (token === \"(\") {\n const inner = sum();\n if (list[index++] !== \")\") bad = true;\n return inner;\n }\n if (token === \"-\") return -primary();\n if (token === \"+\") return primary();\n if (token === undefined || !/^\\d*\\.?\\d+/.test(token)) {\n bad = true;\n return 0;\n }\n const number = Number(token);\n const next = peek();\n if (next && /^[a-z%°]+$/i.test(next)) {\n index++;\n const word = next.toLowerCase();\n const alias = word === \"°\" ? \"deg\" : word === \"deg\" ? \"°\" : word;\n const found = known.includes(word) ? known.indexOf(word) : known.indexOf(alias);\n if (found < 0) bad = true;\n else unit = units[found];\n }\n return number;\n }\n function product(): number {\n let left = primary();\n while (peek() === \"*\" || peek() === \"/\") {\n const op = list[index++];\n const right = primary();\n left = op === \"*\" ? left * right : left / right;\n }\n return left;\n }\n function sum(): number {\n let left = product();\n while (peek() === \"+\" || peek() === \"-\") {\n const op = list[index++];\n const right = product();\n left = op === \"+\" ? left + right : left - right;\n }\n return left;\n }\n\n const value = sum();\n if (bad || index !== list.length || !Number.isFinite(value)) return null;\n return { value, unit };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,wBAAwB,MAAc,OAAkC;CACtF,MAAM,SAAS,KACZ,KAAK,CAAC,CACN,QAAQ,MAAM,GAAG,CAAC,CAClB,QAAQ,uBAAuB,GAAG,CAAC,CACnC,QAAQ,MAAM,GAAG,CAAC,CAClB,QAAQ,MAAM,GAAG;CACpB,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,SAAS,OAAO,MAAM,gDAAgD;CAC5E,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,OAAO;CACb,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI,MAAM;CACV,MAAM,QAAQ,MAAM,KAAK,UAAU,MAAM,YAAY,CAAC;CACtD,MAAM,aAAa,KAAK;CAExB,SAAS,UAAkB;EACzB,MAAM,QAAQ,KAAK;EACnB,IAAI,UAAU,KAAK;GACjB,MAAM,QAAQ,IAAI;GAClB,IAAI,KAAK,aAAa,KAAK,MAAM;GACjC,OAAO;EACT;EACA,IAAI,UAAU,KAAK,OAAO,CAAC,QAAQ;EACnC,IAAI,UAAU,KAAK,OAAO,QAAQ;EAClC,IAAI,UAAU,KAAA,KAAa,CAAC,aAAa,KAAK,KAAK,GAAG;GACpD,MAAM;GACN,OAAO;EACT;EACA,MAAM,SAAS,OAAO,KAAK;EAC3B,MAAM,OAAO,KAAK;EAClB,IAAI,QAAQ,cAAc,KAAK,IAAI,GAAG;GACpC;GACA,MAAM,OAAO,KAAK,YAAY;GAC9B,MAAM,QAAQ,SAAS,MAAM,QAAQ,SAAS,QAAQ,MAAM;GAC5D,MAAM,QAAQ,MAAM,SAAS,IAAI,IAAI,MAAM,QAAQ,IAAI,IAAI,MAAM,QAAQ,KAAK;GAC9E,IAAI,QAAQ,GAAG,MAAM;QAChB,OAAO,MAAM;EACpB;EACA,OAAO;CACT;CACA,SAAS,UAAkB;EACzB,IAAI,OAAO,QAAQ;EACnB,OAAO,KAAK,MAAM,OAAO,KAAK,MAAM,KAAK;GACvC,MAAM,KAAK,KAAK;GAChB,MAAM,QAAQ,QAAQ;GACtB,OAAO,OAAO,MAAM,OAAO,QAAQ,OAAO;EAC5C;EACA,OAAO;CACT;CACA,SAAS,MAAc;EACrB,IAAI,OAAO,QAAQ;EACnB,OAAO,KAAK,MAAM,OAAO,KAAK,MAAM,KAAK;GACvC,MAAM,KAAK,KAAK;GAChB,MAAM,QAAQ,QAAQ;GACtB,OAAO,OAAO,MAAM,OAAO,QAAQ,OAAO;EAC5C;EACA,OAAO;CACT;CAEA,MAAM,QAAQ,IAAI;CAClB,IAAI,OAAO,UAAU,KAAK,UAAU,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpE,OAAO;EAAE;EAAO;CAAK;AACvB"}
@@ -0,0 +1,3 @@
1
+ import { ScrubInput, ScrubInputChangeDetails, ScrubInputProps, ScrubInputSource } from "./scrub-input.js";
2
+ import { evaluateScrubExpression } from "./evaluate.js";
3
+ export { ScrubInput, type ScrubInputChangeDetails, type ScrubInputProps, type ScrubInputSource, evaluateScrubExpression };
@@ -0,0 +1,3 @@
1
+ import { evaluateScrubExpression } from "./evaluate.js";
2
+ import { ScrubInput } from "./scrub-input.js";
3
+ export { ScrubInput, evaluateScrubExpression };
@@ -0,0 +1,74 @@
1
+ import { InputHTMLAttributes, ReactNode } from "react";
2
+ //#region src/scrub-input/scrub-input.d.ts
3
+ export type ScrubInputSource = "scrub" | "type" | "key" | "reset";
4
+ export interface ScrubInputChangeDetails {
5
+ /** What produced the value: a label drag, a typed entry, an arrow key, or a double click reset. */
6
+ source: ScrubInputSource;
7
+ /** The unit in effect after the change. */
8
+ unit: string;
9
+ }
10
+ export interface ScrubInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "type" | "size" | "min" | "max" | "step" | "prefix" | "className"> {
11
+ /** Text or a 16px icon. It is the scrub handle. An icon label needs `aria-label` so the field keeps an accessible name. */
12
+ label: ReactNode;
13
+ /** The value. Controlled when given. */
14
+ value?: number;
15
+ /** @default 0 */
16
+ defaultValue?: number;
17
+ /** Fires for every change, including each step of a scrub. */
18
+ onValueChange?: (value: number, details: ScrubInputChangeDetails) => void;
19
+ /** Fires once when a change settles: a scrub ends, Enter or blur commits typing, or a key step lands. Save on this. */
20
+ onValueCommit?: (value: number, details: ScrubInputChangeDetails) => void;
21
+ /** @default -Infinity */
22
+ min?: number;
23
+ /** @default Infinity */
24
+ max?: number;
25
+ /** One step for the arrow keys and for scrubbing. @default 1 */
26
+ step?: number;
27
+ /** The step with Alt held. @default step / 10 */
28
+ fineStep?: number;
29
+ /** The step with Shift held; coarse steps land on the coarse grid. @default step * 10 */
30
+ coarseStep?: number;
31
+ /** Decimal places kept. Defaults to the precision of `step` or `fineStep`. */
32
+ precision?: number;
33
+ /** Pointer travel in px for one step while scrubbing. @default 2 */
34
+ pixelsPerStep?: number;
35
+ /** Wraps from `max` back to `min`, as a rotation does. Needs both limits. @default false */
36
+ wrap?: boolean;
37
+ /** The unit shown after the number. Controlled when given. With more than one entry in `units` it is a button that cycles them. */
38
+ unit?: string;
39
+ defaultUnit?: string;
40
+ /** The units a typed value may carry, such as `["px", "%"]`. Defaults to the current unit. */
41
+ units?: readonly string[];
42
+ onUnitChange?: (unit: string) => void;
43
+ /** Double click the label to return here. */
44
+ resetValue?: number;
45
+ /** Shows where the value sits between `min` and `max` as a quiet fill. On by default when both limits are set. */
46
+ track?: boolean;
47
+ /** `md` is the compact control height, `sm` is 30px. @default "md" */
48
+ size?: "sm" | "md";
49
+ /** Locks the mouse pointer while it scrubs, when the browser allows it, so a long drag never runs out of screen. @default true */
50
+ pointerLock?: boolean;
51
+ /** Extra classes for the field. Merged last, so `w-40` sizes it. */
52
+ className?: string;
53
+ }
54
+ /**
55
+ * A compact number field for inspectors and property panels. Drag the label sideways to
56
+ * scrub the value (the mouse pointer is locked when the browser allows it, so a long drag
57
+ * never runs out of screen), or click in and type an exact value. A typed entry takes
58
+ * arithmetic such as `12*2` or `(100-24)/2`, and a unit from `units` such as `50%`.
59
+ *
60
+ * Keyboard: the arrow keys step (Shift ten times coarser, Alt ten times finer), Enter
61
+ * commits typing, Escape restores the last value (or cancels a scrub back to where it
62
+ * began). A double click on the label restores `resetValue`. The input is a spinbutton, and
63
+ * its value text spells out percent and degrees.
64
+ *
65
+ * At a limit the field strains: dragged past `min` or `max` it stretches against
66
+ * rubber-band resistance and springs back on release, and a refused step or an invalid
67
+ * entry kicks the number. Reduced motion removes the strain, the kick and the fill's glide.
68
+ *
69
+ * @example
70
+ * <ScrubInput label="W" value={width} onValueChange={setWidth} min={0} units={["px", "%"]} />
71
+ */
72
+ export declare const ScrubInput: import("react").ForwardRefExoticComponent<ScrubInputProps & import("react").RefAttributes<HTMLInputElement>>;
73
+ //#endregion
74
+ //# sourceMappingURL=scrub-input.d.ts.map
@@ -0,0 +1,486 @@
1
+ "use client";
2
+ import { cn, cnAll } from "../lib/cn.js";
3
+ import { prefersReducedMotion } from "../lib/motion.js";
4
+ import { SwapText } from "../lib/swap-text.js";
5
+ import { evaluateScrubExpression } from "./evaluate.js";
6
+ import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useRef, useState } from "react";
7
+ import { Button } from "react-aria-components";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { createPortal } from "react-dom";
10
+ //#region src/scrub-input/scrub-input.tsx
11
+ /** Movement before a press on the label becomes a scrub, and the most pixels the field strains past a limit. */
12
+ const SLOP = 3;
13
+ const STRAIN = 12;
14
+ /** The most overshoot kept, so reversing starts moving the value again after a short relax. */
15
+ const OVERSHOOT_CAP = 90;
16
+ /** How far a refused step or an invalid entry kicks the number (px). */
17
+ const KICK = 6;
18
+ /** The longest the spring home takes (the smooth spring, 720ms) plus a margin. */
19
+ const RELEASE_MS = 900;
20
+ /** How long an invalid entry is flagged. */
21
+ const INVALID_MS = 900;
22
+ const decimalsOf = (value) => {
23
+ const text = String(value);
24
+ if (text.includes("e-")) return Number(text.split("e-")[1]);
25
+ return (text.split(".")[1] ?? "").length;
26
+ };
27
+ const roundTo = (value, places) => {
28
+ const factor = 10 ** places;
29
+ return Math.round(value * factor) / factor;
30
+ };
31
+ /** Rubber-band resistance: each extra pixel gives less, and the strain never exceeds `limit`. */
32
+ const rubber = (distance, limit = STRAIN) => Math.sign(distance) * (1 - 1 / (Math.abs(distance) * .55 / limit + 1)) * limit;
33
+ const format = (value, places) => String(roundTo(value, places)).replace(/^-0$/, "0");
34
+ const sizeClass = {
35
+ md: "h-(--density-control-h-sm) rounded-md text-sm",
36
+ sm: "h-7.5 rounded-sm text-xs"
37
+ };
38
+ /**
39
+ * A compact number field for inspectors and property panels. Drag the label sideways to
40
+ * scrub the value (the mouse pointer is locked when the browser allows it, so a long drag
41
+ * never runs out of screen), or click in and type an exact value. A typed entry takes
42
+ * arithmetic such as `12*2` or `(100-24)/2`, and a unit from `units` such as `50%`.
43
+ *
44
+ * Keyboard: the arrow keys step (Shift ten times coarser, Alt ten times finer), Enter
45
+ * commits typing, Escape restores the last value (or cancels a scrub back to where it
46
+ * began). A double click on the label restores `resetValue`. The input is a spinbutton, and
47
+ * its value text spells out percent and degrees.
48
+ *
49
+ * At a limit the field strains: dragged past `min` or `max` it stretches against
50
+ * rubber-band resistance and springs back on release, and a refused step or an invalid
51
+ * entry kicks the number. Reduced motion removes the strain, the kick and the fill's glide.
52
+ *
53
+ * @example
54
+ * <ScrubInput label="W" value={width} onValueChange={setWidth} min={0} units={["px", "%"]} />
55
+ */
56
+ const ScrubInput = forwardRef(function ScrubInput({ label, value, defaultValue = 0, onValueChange, onValueCommit, min = -Infinity, max = Infinity, step = 1, fineStep, coarseStep, precision, pixelsPerStep = 2, wrap = false, unit: unitProp, defaultUnit, units, onUnitChange, resetValue, track, size = "md", pointerLock = true, className, disabled, id: idProp, onFocus, onBlur, onKeyDown, "aria-label": ariaLabel, ...rest }, forwarded) {
57
+ const uid = useId();
58
+ const id = idProp ?? `scrub-${uid.replace(/[^a-zA-Z0-9-]/g, "")}`;
59
+ const inputRef = useRef(null);
60
+ useImperativeHandle(forwarded, () => inputRef.current);
61
+ const shellRef = useRef(null);
62
+ const bodyRef = useRef(null);
63
+ const handleRef = useRef(null);
64
+ const cursorRef = useRef(null);
65
+ const fine = fineStep ?? step / 10;
66
+ const coarse = coarseStep ?? step * 10;
67
+ const places = precision ?? Math.max(decimalsOf(step), decimalsOf(fine));
68
+ const canWrap = wrap && Number.isFinite(min) && Number.isFinite(max) && max > min;
69
+ const showTrack = (track ?? true) && Number.isFinite(min) && Number.isFinite(max) && max > min;
70
+ const [inner, setInner] = useState(defaultValue);
71
+ const current = value ?? inner;
72
+ const [innerUnit, setInnerUnit] = useState(defaultUnit ?? unitProp ?? units?.[0] ?? "");
73
+ const unit = unitProp ?? innerUnit;
74
+ const unitList = units ?? (unit ? [unit] : []);
75
+ const [draft, setDraft] = useState(null);
76
+ const [scrubbing, setScrubbing] = useState(null);
77
+ const [modifier, setModifier] = useState(null);
78
+ const [invalid, setInvalid] = useState(false);
79
+ const [releasing, setReleasing] = useState(false);
80
+ const latest = useRef({
81
+ current,
82
+ unit
83
+ });
84
+ useEffect(() => {
85
+ latest.current = {
86
+ current,
87
+ unit
88
+ };
89
+ }, [current, unit]);
90
+ const drag = useRef(null);
91
+ const suppressClick = useRef(false);
92
+ const timers = useRef({
93
+ invalid: 0,
94
+ release: 0
95
+ });
96
+ const cursor = useRef({
97
+ x: 0,
98
+ y: 0
99
+ });
100
+ useEffect(() => {
101
+ const pending = timers.current;
102
+ return () => {
103
+ window.clearTimeout(pending.invalid);
104
+ window.clearTimeout(pending.release);
105
+ document.documentElement.style.removeProperty("cursor");
106
+ };
107
+ }, []);
108
+ const fraction = showTrack ? Math.min(1, Math.max(0, (current - min) / (max - min))) : 0;
109
+ /** The strain past a limit in px (positive past max): the shell stretches from its far edge and the number leans with it. */
110
+ function paintStrain(amount) {
111
+ const shell = shellRef.current;
112
+ const body = bodyRef.current;
113
+ if (shell) {
114
+ const width = Math.max(1, shell.offsetWidth);
115
+ shell.style.transform = amount === 0 ? "" : `scaleX(${1 + Math.abs(amount) / width})`;
116
+ shell.style.transformOrigin = amount >= 0 ? "left" : "right";
117
+ }
118
+ if (body) body.style.transform = amount === 0 ? "" : `translateX(${amount * .5}px)`;
119
+ }
120
+ /** Lets the shell and the number spring home: a transition switched on for the moment the strain is cleared. */
121
+ function springHome() {
122
+ paintStrain(0);
123
+ if (prefersReducedMotion()) return;
124
+ setReleasing(true);
125
+ window.clearTimeout(timers.current.release);
126
+ timers.current.release = window.setTimeout(() => setReleasing(false), RELEASE_MS);
127
+ }
128
+ /** A short kick of the number toward `direction`: a step refused at a limit, or an entry that was not understood. */
129
+ function kick(direction) {
130
+ const node = bodyRef.current;
131
+ if (!node || prefersReducedMotion()) return;
132
+ node.style.setProperty("--strain-x", `${direction * KICK}px`);
133
+ node.removeAttribute("data-strain");
134
+ node.offsetWidth;
135
+ node.setAttribute("data-strain", "");
136
+ }
137
+ const emit = useCallback((next, source, commit, nextUnit = latest.current.unit) => {
138
+ if (next !== latest.current.current) {
139
+ latest.current = {
140
+ current: next,
141
+ unit: nextUnit
142
+ };
143
+ if (value === void 0) setInner(next);
144
+ onValueChange?.(next, {
145
+ source,
146
+ unit: nextUnit
147
+ });
148
+ }
149
+ if (commit) onValueCommit?.(next, {
150
+ source,
151
+ unit: nextUnit
152
+ });
153
+ }, [
154
+ onValueChange,
155
+ onValueCommit,
156
+ value
157
+ ]);
158
+ const constrain = (next) => {
159
+ const rounded = roundTo(next, places);
160
+ if (canWrap) {
161
+ const span = max - min;
162
+ return roundTo(((rounded - min) % span + span) % span + min, places);
163
+ }
164
+ return Math.min(max, Math.max(min, rounded));
165
+ };
166
+ function flagInvalid() {
167
+ setInvalid(true);
168
+ window.clearTimeout(timers.current.invalid);
169
+ timers.current.invalid = window.setTimeout(() => setInvalid(false), INVALID_MS);
170
+ kick(-1);
171
+ }
172
+ function commitDraft(text = draft) {
173
+ setDraft(null);
174
+ if (text === null) return true;
175
+ if (text.trim() === format(current, places)) return true;
176
+ const parsed = evaluateScrubExpression(text, unitList);
177
+ if (!parsed) {
178
+ flagInvalid();
179
+ return false;
180
+ }
181
+ let nextUnit = latest.current.unit;
182
+ if (parsed.unit && parsed.unit !== nextUnit) {
183
+ nextUnit = parsed.unit;
184
+ if (unitProp === void 0) setInnerUnit(nextUnit);
185
+ onUnitChange?.(nextUnit);
186
+ }
187
+ if (!canWrap && (parsed.value > max || parsed.value < min)) kick(parsed.value > max ? 1 : -1);
188
+ emit(constrain(parsed.value), "type", true, nextUnit);
189
+ return true;
190
+ }
191
+ function stepBy(direction, event) {
192
+ const amount = event.shiftKey ? coarse : event.altKey ? fine : step;
193
+ const base = latest.current.current;
194
+ if (!canWrap && (direction > 0 && base >= max || direction < 0 && base <= min)) {
195
+ kick(direction);
196
+ return;
197
+ }
198
+ const snapped = event.shiftKey ? (direction > 0 ? Math.floor(base / amount + 1e-9) + 1 : Math.ceil(base / amount - 1e-9) - 1) * amount : base + direction * amount;
199
+ emit(constrain(snapped), "key", true);
200
+ }
201
+ const endScrub = useCallback((cancel) => {
202
+ const state = drag.current;
203
+ drag.current = null;
204
+ if (!state) return;
205
+ document.documentElement.style.removeProperty("cursor");
206
+ if (document.pointerLockElement === handleRef.current) document.exitPointerLock();
207
+ setScrubbing(null);
208
+ setModifier(null);
209
+ if (!state.moved) return;
210
+ suppressClick.current = true;
211
+ if (cancel) emit(state.start, "scrub", true);
212
+ else onValueCommit?.(latest.current.current, {
213
+ source: "scrub",
214
+ unit: latest.current.unit
215
+ });
216
+ springHome();
217
+ }, [emit, onValueCommit]);
218
+ useEffect(() => {
219
+ if (!scrubbing) return;
220
+ const onKey = (event) => {
221
+ if (event.key === "Escape") {
222
+ event.preventDefault();
223
+ endScrub(true);
224
+ return;
225
+ }
226
+ if (event.key === "Shift" || event.key === "Alt") setModifier(event.shiftKey ? "coarse" : event.altKey ? "fine" : null);
227
+ };
228
+ const onLock = () => {
229
+ if (drag.current?.locked && document.pointerLockElement !== handleRef.current) endScrub(false);
230
+ };
231
+ window.addEventListener("keydown", onKey);
232
+ window.addEventListener("keyup", onKey);
233
+ document.addEventListener("pointerlockchange", onLock);
234
+ return () => {
235
+ window.removeEventListener("keydown", onKey);
236
+ window.removeEventListener("keyup", onKey);
237
+ document.removeEventListener("pointerlockchange", onLock);
238
+ };
239
+ }, [endScrub, scrubbing]);
240
+ function placeCursor() {
241
+ const node = cursorRef.current;
242
+ if (node) node.style.transform = `translate3d(${cursor.current.x}px, ${cursor.current.y}px, 0)`;
243
+ }
244
+ function onHandleDown(event) {
245
+ if (disabled || drag.current || event.pointerType === "mouse" && event.button !== 0) return;
246
+ event.preventDefault();
247
+ if (draft !== null) commitDraft();
248
+ try {
249
+ event.currentTarget.setPointerCapture(event.pointerId);
250
+ } catch {}
251
+ drag.current = {
252
+ id: event.pointerId,
253
+ lastX: event.clientX,
254
+ travel: 0,
255
+ raw: latest.current.current,
256
+ start: latest.current.current,
257
+ moved: false,
258
+ locked: false,
259
+ mouse: event.pointerType === "mouse"
260
+ };
261
+ cursor.current = {
262
+ x: event.clientX,
263
+ y: event.clientY
264
+ };
265
+ }
266
+ function onHandleMove(event) {
267
+ const state = drag.current;
268
+ if (!state || event.pointerId !== state.id) return;
269
+ const locked = document.pointerLockElement === handleRef.current;
270
+ const dx = locked ? event.movementX : event.clientX - state.lastX;
271
+ state.lastX = event.clientX;
272
+ state.travel += dx;
273
+ if (!state.moved) {
274
+ if (Math.abs(state.travel) < SLOP) return;
275
+ state.moved = true;
276
+ inputRef.current?.blur();
277
+ document.documentElement.style.cursor = "ew-resize";
278
+ if (pointerLock && state.mouse && handleRef.current?.requestPointerLock) try {
279
+ const request = handleRef.current.requestPointerLock();
280
+ if (request instanceof Promise) request.catch(() => {});
281
+ } catch {}
282
+ setScrubbing({ locked: false });
283
+ }
284
+ if (locked && !state.locked) {
285
+ state.locked = true;
286
+ setScrubbing({ locked: true });
287
+ }
288
+ if (locked) {
289
+ const width = window.innerWidth;
290
+ cursor.current.x = ((cursor.current.x + dx) % width + width) % width;
291
+ } else cursor.current = {
292
+ x: event.clientX,
293
+ y: event.clientY
294
+ };
295
+ placeCursor();
296
+ const amount = event.shiftKey ? coarse : event.altKey ? fine : step;
297
+ const mode = event.shiftKey ? "coarse" : event.altKey ? "fine" : null;
298
+ if (mode !== modifier) setModifier(mode);
299
+ state.raw += dx / pixelsPerStep * amount;
300
+ if (!canWrap) {
301
+ const perPx = amount / pixelsPerStep;
302
+ const over = state.raw > max ? (state.raw - max) / perPx : state.raw < min ? (state.raw - min) / perPx : 0;
303
+ if (Math.abs(over) > OVERSHOOT_CAP) state.raw = (over > 0 ? max : min) + Math.sign(over) * OVERSHOOT_CAP * perPx;
304
+ paintStrain(prefersReducedMotion() ? 0 : rubber(Math.max(-90, Math.min(OVERSHOOT_CAP, over))));
305
+ }
306
+ const next = constrain(Math.round(state.raw / amount) * amount);
307
+ if (next !== latest.current.current) emit(next, "scrub", false);
308
+ }
309
+ function onHandleUp(event) {
310
+ const state = drag.current;
311
+ if (!state || event.pointerId !== state.id) return;
312
+ endScrub(false);
313
+ }
314
+ function onHandleClick(event) {
315
+ if (suppressClick.current) {
316
+ suppressClick.current = false;
317
+ event.preventDefault();
318
+ return;
319
+ }
320
+ if (disabled) return;
321
+ event.preventDefault();
322
+ inputRef.current?.focus();
323
+ inputRef.current?.select();
324
+ }
325
+ function onHandleDoubleClick() {
326
+ if (disabled || resetValue === void 0) return;
327
+ emit(constrain(resetValue), "reset", true);
328
+ }
329
+ function onInputKeyDown(event) {
330
+ onKeyDown?.(event);
331
+ if (event.defaultPrevented) return;
332
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
333
+ event.preventDefault();
334
+ if (draft !== null && !commitDraft()) return;
335
+ stepBy(event.key === "ArrowUp" ? 1 : -1, event);
336
+ requestAnimationFrame(() => inputRef.current?.select());
337
+ return;
338
+ }
339
+ if (event.key === "Enter") {
340
+ event.preventDefault();
341
+ commitDraft();
342
+ requestAnimationFrame(() => inputRef.current?.select());
343
+ return;
344
+ }
345
+ if (event.key === "Escape" && draft !== null) {
346
+ event.preventDefault();
347
+ event.stopPropagation();
348
+ setDraft(null);
349
+ requestAnimationFrame(() => inputRef.current?.select());
350
+ }
351
+ }
352
+ function onInputFocus(event) {
353
+ onFocus?.(event);
354
+ event.currentTarget.select();
355
+ }
356
+ function onInputBlur(event) {
357
+ onBlur?.(event);
358
+ commitDraft();
359
+ }
360
+ function cycleUnit() {
361
+ if (unitList.length < 2) return;
362
+ const next = unitList[(unitList.indexOf(unit) + 1) % unitList.length] ?? unit;
363
+ if (unitProp === void 0) setInnerUnit(next);
364
+ onUnitChange?.(next);
365
+ latest.current = {
366
+ ...latest.current,
367
+ unit: next
368
+ };
369
+ }
370
+ const text = draft ?? format(current, places);
371
+ const spokenUnit = unit === "%" ? "percent" : unit === "deg" || unit === "°" ? "degrees" : unit;
372
+ const valueText = `${format(current, places)}${unit ? ` ${spokenUnit}` : ""}`;
373
+ const multiplier = modifier === "coarse" ? `×${format(coarse / step, 2)}` : modifier === "fine" ? `×${format(fine / step, 3)}` : null;
374
+ const labelIsText = typeof label === "string" || typeof label === "number";
375
+ return /* @__PURE__ */ jsxs("div", {
376
+ "data-slot": "scrub-input",
377
+ "data-size": size,
378
+ "data-disabled": disabled ? "" : void 0,
379
+ "data-scrubbing": scrubbing ? "" : void 0,
380
+ "data-invalid": invalid ? "" : void 0,
381
+ "data-releasing": releasing ? "" : void 0,
382
+ className: cn(cnAll("group/scrub relative isolate grid w-full min-w-0 grid-cols-[auto_minmax(0,1fr)] items-stretch font-sans text-foreground", sizeClass[size], "data-[disabled]:opacity-(--opacity-disabled)"), className),
383
+ children: [
384
+ /* @__PURE__ */ jsx("div", {
385
+ ref: shellRef,
386
+ "aria-hidden": "true",
387
+ "data-slot": "scrub-input-shell",
388
+ className: cnAll("absolute inset-0 -z-10 overflow-hidden border-(length:--border-width) border-transparent bg-surface-muted will-change-transform", size === "sm" ? "rounded-sm" : "rounded-md", "motion-safe:transition-[background-color,border-color] motion-safe:duration-(--duration-quick) motion-safe:ease-settle", "group-data-[releasing]/scrub:motion-safe:transition-[transform,background-color,border-color] group-data-[releasing]/scrub:motion-safe:duration-(--duration-smooth) group-data-[releasing]/scrub:motion-safe:ease-smooth", "group-hover/scrub:border-border", "group-focus-within/scrub:border-foreground group-focus-within/scrub:bg-surface", "forced-colors:group-focus-within/scrub:outline-solid forced-colors:group-focus-within/scrub:outline-(length:--focus-ring-width) forced-colors:group-focus-within/scrub:outline-offset-(--focus-ring-offset)", "group-data-[scrubbing]/scrub:border-border-strong", "group-data-[invalid]/scrub:border-destructive-strong"),
389
+ children: showTrack ? /* @__PURE__ */ jsx("span", {
390
+ "data-slot": "scrub-input-fill",
391
+ style: { transform: `scaleX(${fraction})` },
392
+ className: "pointer-events-none absolute inset-0 origin-left bg-foreground/6 group-data-[scrubbing]/scrub:bg-foreground/10 motion-safe:transition-transform motion-safe:duration-(--duration-smooth) motion-safe:ease-smooth group-data-[scrubbing]/scrub:motion-safe:transition-none"
393
+ }) : null
394
+ }),
395
+ /* @__PURE__ */ jsx("label", {
396
+ ref: handleRef,
397
+ htmlFor: id,
398
+ "data-slot": "scrub-input-handle",
399
+ "data-text": labelIsText ? "" : void 0,
400
+ onPointerDown: onHandleDown,
401
+ onPointerMove: onHandleMove,
402
+ onPointerUp: onHandleUp,
403
+ onPointerCancel: onHandleUp,
404
+ onClick: onHandleClick,
405
+ onDoubleClick: onHandleDoubleClick,
406
+ className: "flex min-w-7.5 cursor-ew-resize touch-pan-y items-center justify-center ps-2.5 pe-1 text-text-secondary select-none motion-safe:transition-colors motion-safe:duration-(--duration-quick) data-[text]:font-medium hover:text-foreground group-data-[scrubbing]/scrub:text-foreground group-data-[disabled]/scrub:cursor-not-allowed [&_svg]:size-3.5 [&_svg]:flex-none",
407
+ children: label
408
+ }),
409
+ /* @__PURE__ */ jsxs("div", {
410
+ ref: bodyRef,
411
+ "data-slot": "scrub-input-body",
412
+ className: cnAll("flex min-w-0 items-center gap-0.5 pe-2.5 data-[strain]:motion-safe:animate-field-strain", "group-data-[releasing]/scrub:motion-safe:transition-transform group-data-[releasing]/scrub:motion-safe:duration-(--duration-smooth) group-data-[releasing]/scrub:motion-safe:ease-smooth"),
413
+ children: [/* @__PURE__ */ jsx("input", {
414
+ ...rest,
415
+ ref: inputRef,
416
+ id,
417
+ type: "text",
418
+ inputMode: "decimal",
419
+ autoComplete: "off",
420
+ spellCheck: false,
421
+ role: "spinbutton",
422
+ "aria-label": ariaLabel,
423
+ "aria-valuenow": current,
424
+ "aria-valuemin": Number.isFinite(min) ? min : void 0,
425
+ "aria-valuemax": Number.isFinite(max) ? max : void 0,
426
+ "aria-valuetext": valueText,
427
+ "aria-invalid": invalid || void 0,
428
+ disabled,
429
+ value: text,
430
+ onChange: (event) => setDraft(event.target.value),
431
+ onFocus: onInputFocus,
432
+ onBlur: onInputBlur,
433
+ onKeyDown: onInputKeyDown,
434
+ className: cnAll("m-0 h-full w-full min-w-0 flex-1 border-0 bg-transparent p-0 ps-1 font-sans text-foreground tabular-nums outline-none selection:bg-primary selection:text-primary-foreground disabled:cursor-not-allowed", size === "sm" ? "text-xs" : "text-sm")
435
+ }), unit ? unitList.length > 1 ? /* @__PURE__ */ jsx(Button, {
436
+ "data-slot": "scrub-input-unit",
437
+ isDisabled: disabled,
438
+ onPress: cycleUnit,
439
+ "aria-label": `Unit: ${unit}. Change unit`,
440
+ className: "relative inline-flex h-6 min-w-6 flex-none cursor-pointer items-center justify-center rounded-xs border-0 bg-transparent px-1 text-xs text-text-secondary outline-none motion-safe:transition-[background-color,color,scale] motion-safe:duration-(--duration-quick) motion-safe:ease-settle data-[hovered]:bg-foreground/7 data-[hovered]:text-foreground data-[pressed]:scale-95 data-[focus-visible]:outline-solid data-[focus-visible]:outline-(length:--focus-ring-width) data-[focus-visible]:outline-(--color-ring) data-[disabled]:cursor-not-allowed",
441
+ children: /* @__PURE__ */ jsx(SwapText, {
442
+ swapKey: unit,
443
+ motion: "rise",
444
+ children: unit
445
+ })
446
+ }) : /* @__PURE__ */ jsx("span", {
447
+ "aria-hidden": "true",
448
+ "data-slot": "scrub-input-unit",
449
+ className: "inline-flex h-6 min-w-4.5 flex-none items-center justify-center px-1 text-xs text-text-secondary",
450
+ children: unit
451
+ }) : null]
452
+ }),
453
+ multiplier && !scrubbing?.locked ? /* @__PURE__ */ jsx("span", {
454
+ "aria-hidden": "true",
455
+ "data-slot": "scrub-input-multiplier",
456
+ className: "pointer-events-none absolute bottom-full mb-1.5 start-1.5 z-10 rounded-pill bg-foreground px-1.75 py-0.5 text-xs leading-4 text-background tabular-nums motion-safe:animate-field-clear-in motion-reduce:animate-fade-in",
457
+ children: multiplier
458
+ }) : null,
459
+ scrubbing?.locked ? createPortal(/* @__PURE__ */ jsxs("div", {
460
+ ref: (node) => {
461
+ cursorRef.current = node;
462
+ placeCursor();
463
+ },
464
+ "aria-hidden": "true",
465
+ "data-slot": "scrub-input-cursor",
466
+ className: "pointer-events-none fixed top-0 left-0 z-50 -mt-2 -ms-3.25 flex items-center gap-1",
467
+ children: [/* @__PURE__ */ jsx("svg", {
468
+ width: "26",
469
+ height: "16",
470
+ viewBox: "0 0 26 16",
471
+ className: "block fill-foreground stroke-background drop-shadow-sm",
472
+ strokeWidth: "1.4",
473
+ strokeLinejoin: "round",
474
+ children: /* @__PURE__ */ jsx("path", { d: "M1.5 8 L7.5 2.5 V6 H18.5 V2.5 L24.5 8 L18.5 13.5 V10 H7.5 V13.5 Z" })
475
+ }), multiplier ? /* @__PURE__ */ jsx("span", {
476
+ className: "rounded-pill bg-foreground px-1.5 py-px font-sans text-xs leading-4 text-background tabular-nums motion-safe:animate-field-clear-in motion-reduce:animate-fade-in",
477
+ children: multiplier
478
+ }) : null]
479
+ }), document.body) : null
480
+ ]
481
+ });
482
+ });
483
+ //#endregion
484
+ export { ScrubInput };
485
+
486
+ //# sourceMappingURL=scrub-input.js.map