@appica/ui-react 1.0.0 → 1.1.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 (473) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +47 -5
  3. package/agent-rules.md +41 -0
  4. package/appica.css +7 -0
  5. package/dist/components/accordion/accordion.d.ts +24 -0
  6. package/dist/components/accordion/accordion.d.ts.map +1 -1
  7. package/dist/components/accordion/accordion.js +1 -1
  8. package/dist/components/accordion/accordion.js.map +1 -1
  9. package/dist/components/alert/alert.d.ts +29 -1
  10. package/dist/components/alert/alert.d.ts.map +1 -1
  11. package/dist/components/alert/alert.js +1 -1
  12. package/dist/components/alert/alert.js.map +1 -1
  13. package/dist/components/alert-dialog/alert-dialog.d.ts +12 -2
  14. package/dist/components/alert-dialog/alert-dialog.d.ts.map +1 -1
  15. package/dist/components/alert-dialog/alert-dialog.js +9 -5
  16. package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
  17. package/dist/components/autocomplete/autocomplete.d.ts +21 -1
  18. package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
  19. package/dist/components/autocomplete/autocomplete.js +2 -2
  20. package/dist/components/autocomplete/autocomplete.js.map +1 -1
  21. package/dist/components/avatar/avatar.d.ts +16 -0
  22. package/dist/components/avatar/avatar.d.ts.map +1 -1
  23. package/dist/components/avatar/avatar.js +1 -1
  24. package/dist/components/avatar/avatar.js.map +1 -1
  25. package/dist/components/background-pattern/background-pattern-interactive.js +1 -1
  26. package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -1
  27. package/dist/components/background-pattern/background-pattern-shared.js +1 -1
  28. package/dist/components/background-pattern/background-pattern-shared.js.map +1 -1
  29. package/dist/components/background-pattern/background-pattern.d.ts +13 -5
  30. package/dist/components/background-pattern/background-pattern.d.ts.map +1 -1
  31. package/dist/components/background-pattern/background-pattern.js +1 -1
  32. package/dist/components/background-pattern/background-pattern.js.map +1 -1
  33. package/dist/components/badge/badge.d.ts +11 -1
  34. package/dist/components/badge/badge.d.ts.map +1 -1
  35. package/dist/components/badge/badge.js +1 -1
  36. package/dist/components/badge/badge.js.map +1 -1
  37. package/dist/components/border-beam/border-beam.d.ts +52 -0
  38. package/dist/components/border-beam/border-beam.d.ts.map +1 -0
  39. package/dist/components/border-beam/border-beam.js +67 -0
  40. package/dist/components/border-beam/border-beam.js.map +1 -0
  41. package/dist/components/breadcrumb/breadcrumb.d.ts +8 -0
  42. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  43. package/dist/components/breadcrumb/breadcrumb.js +1 -1
  44. package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
  45. package/dist/components/button/button-variants.js +1 -1
  46. package/dist/components/button/button-variants.js.map +1 -1
  47. package/dist/components/button/button.d.ts +11 -1
  48. package/dist/components/button/button.d.ts.map +1 -1
  49. package/dist/components/button/button.js +1 -1
  50. package/dist/components/button/button.js.map +1 -1
  51. package/dist/components/button-group/button-group.d.ts +10 -0
  52. package/dist/components/button-group/button-group.d.ts.map +1 -1
  53. package/dist/components/button-group/button-group.js +1 -1
  54. package/dist/components/button-group/button-group.js.map +1 -1
  55. package/dist/components/calendar/calendar.d.ts +5 -0
  56. package/dist/components/calendar/calendar.d.ts.map +1 -1
  57. package/dist/components/calendar/calendar.js +1 -1
  58. package/dist/components/calendar/calendar.js.map +1 -1
  59. package/dist/components/card/card.d.ts +43 -0
  60. package/dist/components/card/card.d.ts.map +1 -0
  61. package/dist/components/card/card.js +103 -0
  62. package/dist/components/card/card.js.map +1 -0
  63. package/dist/components/carousel/carousel.d.ts +105 -5
  64. package/dist/components/carousel/carousel.d.ts.map +1 -1
  65. package/dist/components/carousel/carousel.js +157 -5
  66. package/dist/components/carousel/carousel.js.map +1 -1
  67. package/dist/components/checkbox/checkbox.js +1 -1
  68. package/dist/components/checkbox/checkbox.js.map +1 -1
  69. package/dist/components/checkbox-group/checkbox-group.d.ts +4 -0
  70. package/dist/components/checkbox-group/checkbox-group.d.ts.map +1 -1
  71. package/dist/components/checkbox-group/checkbox-group.js +1 -1
  72. package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
  73. package/dist/components/chip/chip.d.ts +32 -0
  74. package/dist/components/chip/chip.d.ts.map +1 -1
  75. package/dist/components/chip/chip.js +1 -1
  76. package/dist/components/chip/chip.js.map +1 -1
  77. package/dist/components/collapsible/collapsible.js +1 -1
  78. package/dist/components/collapsible/collapsible.js.map +1 -1
  79. package/dist/components/color-area/color-area.d.ts +53 -0
  80. package/dist/components/color-area/color-area.d.ts.map +1 -0
  81. package/dist/components/color-area/color-area.js +245 -0
  82. package/dist/components/color-area/color-area.js.map +1 -0
  83. package/dist/components/color-picker/color-picker.d.ts +152 -0
  84. package/dist/components/color-picker/color-picker.d.ts.map +1 -0
  85. package/dist/components/color-picker/color-picker.js +327 -0
  86. package/dist/components/color-picker/color-picker.js.map +1 -0
  87. package/dist/components/color-slider/color-slider.d.ts +48 -0
  88. package/dist/components/color-slider/color-slider.d.ts.map +1 -0
  89. package/dist/components/color-slider/color-slider.js +216 -0
  90. package/dist/components/color-slider/color-slider.js.map +1 -0
  91. package/dist/components/color-swatch/color-swatch.d.ts +47 -0
  92. package/dist/components/color-swatch/color-swatch.d.ts.map +1 -0
  93. package/dist/components/color-swatch/color-swatch.js +66 -0
  94. package/dist/components/color-swatch/color-swatch.js.map +1 -0
  95. package/dist/components/color-swatch-picker/color-swatch-picker.d.ts +62 -0
  96. package/dist/components/color-swatch-picker/color-swatch-picker.d.ts.map +1 -0
  97. package/dist/components/color-swatch-picker/color-swatch-picker.js +202 -0
  98. package/dist/components/color-swatch-picker/color-swatch-picker.js.map +1 -0
  99. package/dist/components/combobox/combobox.d.ts +25 -1
  100. package/dist/components/combobox/combobox.d.ts.map +1 -1
  101. package/dist/components/combobox/combobox.js +2 -2
  102. package/dist/components/combobox/combobox.js.map +1 -1
  103. package/dist/components/context-menu/context-menu.d.ts +7 -1
  104. package/dist/components/context-menu/context-menu.d.ts.map +1 -1
  105. package/dist/components/context-menu/context-menu.js +5 -5
  106. package/dist/components/context-menu/context-menu.js.map +1 -1
  107. package/dist/components/copy-button/copy-button.d.ts +15 -0
  108. package/dist/components/copy-button/copy-button.d.ts.map +1 -1
  109. package/dist/components/copy-button/copy-button.js +1 -1
  110. package/dist/components/copy-button/copy-button.js.map +1 -1
  111. package/dist/components/countdown/countdown.d.ts +14 -0
  112. package/dist/components/countdown/countdown.d.ts.map +1 -1
  113. package/dist/components/countdown/countdown.js +1 -1
  114. package/dist/components/countdown/countdown.js.map +1 -1
  115. package/dist/components/date-field/date-field.d.ts +35 -0
  116. package/dist/components/date-field/date-field.d.ts.map +1 -1
  117. package/dist/components/date-field/date-field.js +1 -1
  118. package/dist/components/date-field/date-field.js.map +1 -1
  119. package/dist/components/date-picker/date-picker.d.ts +94 -0
  120. package/dist/components/date-picker/date-picker.d.ts.map +1 -1
  121. package/dist/components/date-picker/date-picker.js +1 -1
  122. package/dist/components/date-picker/date-picker.js.map +1 -1
  123. package/dist/components/dialog/dialog.d.ts +20 -2
  124. package/dist/components/dialog/dialog.d.ts.map +1 -1
  125. package/dist/components/dialog/dialog.js +8 -4
  126. package/dist/components/dialog/dialog.js.map +1 -1
  127. package/dist/components/drawer/drawer.d.ts +22 -2
  128. package/dist/components/drawer/drawer.d.ts.map +1 -1
  129. package/dist/components/drawer/drawer.js +13 -7
  130. package/dist/components/drawer/drawer.js.map +1 -1
  131. package/dist/components/dropdown-menu/dropdown-menu.d.ts +7 -1
  132. package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
  133. package/dist/components/dropdown-menu/dropdown-menu.js +5 -5
  134. package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
  135. package/dist/components/field/field.js +1 -1
  136. package/dist/components/field/field.js.map +1 -1
  137. package/dist/components/fieldset/fieldset.js +1 -1
  138. package/dist/components/fieldset/fieldset.js.map +1 -1
  139. package/dist/components/gradient-glow/gradient-glow.d.ts +45 -0
  140. package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -1
  141. package/dist/components/gradient-glow/gradient-glow.js +1 -1
  142. package/dist/components/gradient-glow/gradient-glow.js.map +1 -1
  143. package/dist/components/input/input-variants.js +1 -1
  144. package/dist/components/input/input-variants.js.map +1 -1
  145. package/dist/components/input/input.d.ts +21 -1
  146. package/dist/components/input/input.d.ts.map +1 -1
  147. package/dist/components/input/input.js +3 -3
  148. package/dist/components/input/input.js.map +1 -1
  149. package/dist/components/kbd/kbd.d.ts +8 -0
  150. package/dist/components/kbd/kbd.d.ts.map +1 -1
  151. package/dist/components/kbd/kbd.js +1 -1
  152. package/dist/components/kbd/kbd.js.map +1 -1
  153. package/dist/components/loader/loader.d.ts +8 -0
  154. package/dist/components/loader/loader.d.ts.map +1 -1
  155. package/dist/components/loader/loader.js +1 -1
  156. package/dist/components/loader/loader.js.map +1 -1
  157. package/dist/components/menubar/menubar.d.ts +8 -0
  158. package/dist/components/menubar/menubar.d.ts.map +1 -1
  159. package/dist/components/menubar/menubar.js +1 -1
  160. package/dist/components/menubar/menubar.js.map +1 -1
  161. package/dist/components/meter/meter.d.ts +4 -0
  162. package/dist/components/meter/meter.d.ts.map +1 -1
  163. package/dist/components/meter/meter.js +1 -1
  164. package/dist/components/meter/meter.js.map +1 -1
  165. package/dist/components/navigation/navigation-link-variants.d.ts +1 -1
  166. package/dist/components/navigation/navigation-link-variants.js +1 -1
  167. package/dist/components/navigation/navigation-link-variants.js.map +1 -1
  168. package/dist/components/navigation/navigation-link.d.ts +22 -0
  169. package/dist/components/navigation/navigation-link.d.ts.map +1 -1
  170. package/dist/components/navigation/navigation-link.js +1 -1
  171. package/dist/components/navigation/navigation-link.js.map +1 -1
  172. package/dist/components/navigation/navigation.d.ts +12 -0
  173. package/dist/components/navigation/navigation.d.ts.map +1 -1
  174. package/dist/components/navigation/navigation.js +1 -1
  175. package/dist/components/navigation/navigation.js.map +1 -1
  176. package/dist/components/navigation-menu/navigation-menu.d.ts +33 -0
  177. package/dist/components/navigation-menu/navigation-menu.d.ts.map +1 -1
  178. package/dist/components/navigation-menu/navigation-menu.js +1 -1
  179. package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
  180. package/dist/components/number-field/number-field.d.ts +14 -0
  181. package/dist/components/number-field/number-field.d.ts.map +1 -1
  182. package/dist/components/number-field/number-field.js +1 -1
  183. package/dist/components/number-field/number-field.js.map +1 -1
  184. package/dist/components/otp-field/otp-field.d.ts +9 -0
  185. package/dist/components/otp-field/otp-field.d.ts.map +1 -1
  186. package/dist/components/otp-field/otp-field.js +1 -1
  187. package/dist/components/otp-field/otp-field.js.map +1 -1
  188. package/dist/components/pagination/pagination.d.ts +16 -0
  189. package/dist/components/pagination/pagination.d.ts.map +1 -1
  190. package/dist/components/pagination/pagination.js +1 -1
  191. package/dist/components/pagination/pagination.js.map +1 -1
  192. package/dist/components/popover/popover.d.ts +5 -1
  193. package/dist/components/popover/popover.d.ts.map +1 -1
  194. package/dist/components/popover/popover.js +2 -2
  195. package/dist/components/popover/popover.js.map +1 -1
  196. package/dist/components/preview-card/preview-card.d.ts +5 -1
  197. package/dist/components/preview-card/preview-card.d.ts.map +1 -1
  198. package/dist/components/preview-card/preview-card.js +2 -2
  199. package/dist/components/preview-card/preview-card.js.map +1 -1
  200. package/dist/components/progress/progress.d.ts +17 -0
  201. package/dist/components/progress/progress.d.ts.map +1 -1
  202. package/dist/components/progress/progress.js +1 -1
  203. package/dist/components/progress/progress.js.map +1 -1
  204. package/dist/components/radio/radio.js +1 -1
  205. package/dist/components/radio/radio.js.map +1 -1
  206. package/dist/components/radio-group/radio-group.d.ts +4 -0
  207. package/dist/components/radio-group/radio-group.d.ts.map +1 -1
  208. package/dist/components/radio-group/radio-group.js +1 -1
  209. package/dist/components/radio-group/radio-group.js.map +1 -1
  210. package/dist/components/rating/rating.d.ts +79 -0
  211. package/dist/components/rating/rating.d.ts.map +1 -0
  212. package/dist/components/rating/rating.js +301 -0
  213. package/dist/components/rating/rating.js.map +1 -0
  214. package/dist/components/scroll-area/scroll-area.d.ts +13 -0
  215. package/dist/components/scroll-area/scroll-area.d.ts.map +1 -1
  216. package/dist/components/scroll-area/scroll-area.js +1 -1
  217. package/dist/components/scroll-area/scroll-area.js.map +1 -1
  218. package/dist/components/select/select.d.ts +20 -1
  219. package/dist/components/select/select.d.ts.map +1 -1
  220. package/dist/components/select/select.js +2 -2
  221. package/dist/components/select/select.js.map +1 -1
  222. package/dist/components/separator/separator.d.ts +4 -0
  223. package/dist/components/separator/separator.d.ts.map +1 -1
  224. package/dist/components/separator/separator.js +1 -1
  225. package/dist/components/separator/separator.js.map +1 -1
  226. package/dist/components/skeleton/skeleton.d.ts +4 -0
  227. package/dist/components/skeleton/skeleton.d.ts.map +1 -1
  228. package/dist/components/skeleton/skeleton.js +1 -1
  229. package/dist/components/skeleton/skeleton.js.map +1 -1
  230. package/dist/components/slider/slider.d.ts +5 -0
  231. package/dist/components/slider/slider.d.ts.map +1 -1
  232. package/dist/components/slider/slider.js +1 -1
  233. package/dist/components/slider/slider.js.map +1 -1
  234. package/dist/components/sparkline/sparkline.d.ts +44 -0
  235. package/dist/components/sparkline/sparkline.d.ts.map +1 -1
  236. package/dist/components/sparkline/sparkline.js +1 -1
  237. package/dist/components/sparkline/sparkline.js.map +1 -1
  238. package/dist/components/spinner/spinner.d.ts +8 -0
  239. package/dist/components/spinner/spinner.d.ts.map +1 -1
  240. package/dist/components/spinner/spinner.js +1 -1
  241. package/dist/components/spinner/spinner.js.map +1 -1
  242. package/dist/components/switch/switch.d.ts +4 -0
  243. package/dist/components/switch/switch.d.ts.map +1 -1
  244. package/dist/components/switch/switch.js +1 -1
  245. package/dist/components/switch/switch.js.map +1 -1
  246. package/dist/components/table/table.d.ts +28 -0
  247. package/dist/components/table/table.d.ts.map +1 -1
  248. package/dist/components/table/table.js +1 -1
  249. package/dist/components/table/table.js.map +1 -1
  250. package/dist/components/tabs/tabs.d.ts +31 -1
  251. package/dist/components/tabs/tabs.d.ts.map +1 -1
  252. package/dist/components/tabs/tabs.js +1 -1
  253. package/dist/components/tabs/tabs.js.map +1 -1
  254. package/dist/components/text-animate/text-animate.d.ts +31 -0
  255. package/dist/components/text-animate/text-animate.d.ts.map +1 -1
  256. package/dist/components/text-animate/text-animate.js +26 -9
  257. package/dist/components/text-animate/text-animate.js.map +1 -1
  258. package/dist/components/textarea/textarea.d.ts +15 -0
  259. package/dist/components/textarea/textarea.d.ts.map +1 -1
  260. package/dist/components/textarea/textarea.js +1 -1
  261. package/dist/components/textarea/textarea.js.map +1 -1
  262. package/dist/components/thumbnail/thumbnail.d.ts +20 -0
  263. package/dist/components/thumbnail/thumbnail.d.ts.map +1 -1
  264. package/dist/components/thumbnail/thumbnail.js +1 -1
  265. package/dist/components/thumbnail/thumbnail.js.map +1 -1
  266. package/dist/components/time-field/time-field.d.ts +35 -0
  267. package/dist/components/time-field/time-field.d.ts.map +1 -1
  268. package/dist/components/time-field/time-field.js +1 -1
  269. package/dist/components/time-field/time-field.js.map +1 -1
  270. package/dist/components/toast/toast.d.ts +18 -0
  271. package/dist/components/toast/toast.d.ts.map +1 -1
  272. package/dist/components/toast/toast.js +1 -1
  273. package/dist/components/toast/toast.js.map +1 -1
  274. package/dist/components/toc/toc.d.ts +10 -0
  275. package/dist/components/toc/toc.d.ts.map +1 -1
  276. package/dist/components/toc/toc.js +1 -1
  277. package/dist/components/toc/toc.js.map +1 -1
  278. package/dist/components/toggle-group/toggle-group.js +1 -1
  279. package/dist/components/toggle-group/toggle-group.js.map +1 -1
  280. package/dist/components/toolbar/toolbar.js +1 -1
  281. package/dist/components/toolbar/toolbar.js.map +1 -1
  282. package/dist/components/tooltip/tooltip.d.ts +5 -1
  283. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  284. package/dist/components/tooltip/tooltip.js +2 -2
  285. package/dist/components/tooltip/tooltip.js.map +1 -1
  286. package/dist/hooks/use-dismissible.d.ts +4 -0
  287. package/dist/hooks/use-dismissible.d.ts.map +1 -1
  288. package/dist/hooks/use-dismissible.js.map +1 -1
  289. package/dist/hooks/use-local-storage.js.map +1 -1
  290. package/dist/hooks/use-reduced-motion.d.ts +1 -1
  291. package/dist/hooks/use-reduced-motion.js.map +1 -1
  292. package/dist/hooks/use-theme.d.ts +1 -1
  293. package/dist/hooks/use-theme.js.map +1 -1
  294. package/dist/index.d.ts +9 -0
  295. package/dist/index.d.ts.map +1 -1
  296. package/dist/index.js +10 -1
  297. package/dist/index.js.map +1 -1
  298. package/dist/internal/color-control.d.ts +75 -0
  299. package/dist/internal/color-control.d.ts.map +1 -0
  300. package/dist/internal/color-control.js +78 -0
  301. package/dist/internal/color-control.js.map +1 -0
  302. package/dist/internal/color-math.d.ts +9 -0
  303. package/dist/internal/color-math.d.ts.map +1 -0
  304. package/dist/internal/color-math.js +34 -0
  305. package/dist/internal/color-math.js.map +1 -0
  306. package/dist/internal/color-picker-context.d.ts +34 -0
  307. package/dist/internal/color-picker-context.d.ts.map +1 -0
  308. package/dist/internal/color-picker-context.js +41 -0
  309. package/dist/internal/color-picker-context.js.map +1 -0
  310. package/dist/{floating.d.ts → internal/floating.d.ts} +1 -1
  311. package/dist/internal/floating.d.ts.map +1 -0
  312. package/dist/internal/floating.js.map +1 -0
  313. package/dist/{modal.d.ts → internal/modal.d.ts} +1 -1
  314. package/dist/internal/modal.d.ts.map +1 -0
  315. package/dist/internal/modal.js.map +1 -0
  316. package/dist/internal/utils.d.ts.map +1 -0
  317. package/dist/internal/utils.js.map +1 -0
  318. package/dist/lib/color.d.ts +95 -0
  319. package/dist/lib/color.d.ts.map +1 -0
  320. package/dist/lib/color.js +328 -0
  321. package/dist/lib/color.js.map +1 -0
  322. package/dist/providers/direction-provider.d.ts +4 -4
  323. package/dist/providers/direction-provider.d.ts.map +1 -1
  324. package/dist/providers/direction-provider.js.map +1 -1
  325. package/dist/providers/reduced-motion-provider.d.ts +4 -8
  326. package/dist/providers/reduced-motion-provider.d.ts.map +1 -1
  327. package/dist/providers/reduced-motion-provider.js.map +1 -1
  328. package/dist/providers/theme-provider/theme-provider.d.ts +28 -12
  329. package/dist/providers/theme-provider/theme-provider.d.ts.map +1 -1
  330. package/dist/providers/theme-provider/theme-provider.js.map +1 -1
  331. package/dist/providers/theme-provider/theme-script.js.map +1 -1
  332. package/package.json +75 -17
  333. package/src/components/accordion/accordion.tsx +25 -1
  334. package/src/components/alert/alert.tsx +30 -2
  335. package/src/components/alert-dialog/alert-dialog.test.tsx +34 -2
  336. package/src/components/alert-dialog/alert-dialog.tsx +21 -5
  337. package/src/components/autocomplete/autocomplete.test.tsx +1 -1
  338. package/src/components/autocomplete/autocomplete.tsx +22 -2
  339. package/src/components/avatar/avatar.test.tsx +2 -2
  340. package/src/components/avatar/avatar.tsx +17 -1
  341. package/src/components/background-pattern/background-pattern-interactive.tsx +1 -1
  342. package/src/components/background-pattern/background-pattern-shared.tsx +1 -1
  343. package/src/components/background-pattern/background-pattern.test.tsx +1 -1
  344. package/src/components/background-pattern/background-pattern.tsx +14 -6
  345. package/src/components/badge/badge.tsx +14 -2
  346. package/src/components/border-beam/border-beam.test.tsx +91 -0
  347. package/src/components/border-beam/border-beam.tsx +131 -0
  348. package/src/components/breadcrumb/breadcrumb.tsx +9 -1
  349. package/src/components/button/button-variants.ts +1 -1
  350. package/src/components/button/button.tsx +13 -2
  351. package/src/components/button-group/button-group.tsx +11 -1
  352. package/src/components/calendar/calendar.tsx +6 -1
  353. package/src/components/card/card.test.tsx +98 -0
  354. package/src/components/card/card.tsx +154 -0
  355. package/src/components/carousel/carousel.test.tsx +155 -0
  356. package/src/components/carousel/carousel.tsx +305 -5
  357. package/src/components/checkbox/checkbox.test.tsx +2 -2
  358. package/src/components/checkbox/checkbox.tsx +1 -1
  359. package/src/components/checkbox-group/checkbox-group.tsx +5 -1
  360. package/src/components/chip/chip.tsx +33 -1
  361. package/src/components/collapsible/collapsible.tsx +1 -1
  362. package/src/components/color-area/color-area.test.tsx +242 -0
  363. package/src/components/color-area/color-area.tsx +356 -0
  364. package/src/components/color-picker/color-picker.test.tsx +286 -0
  365. package/src/components/color-picker/color-picker.tsx +546 -0
  366. package/src/components/color-slider/color-slider.test.tsx +222 -0
  367. package/src/components/color-slider/color-slider.tsx +330 -0
  368. package/src/components/color-swatch/color-swatch.test.tsx +117 -0
  369. package/src/components/color-swatch/color-swatch.tsx +119 -0
  370. package/src/components/color-swatch-picker/color-swatch-picker.test.tsx +287 -0
  371. package/src/components/color-swatch-picker/color-swatch-picker.tsx +327 -0
  372. package/src/components/combobox/combobox.test.tsx +1 -1
  373. package/src/components/combobox/combobox.tsx +26 -2
  374. package/src/components/context-menu/context-menu.tsx +11 -5
  375. package/src/components/copy-button/copy-button.test.tsx +1 -1
  376. package/src/components/copy-button/copy-button.tsx +16 -1
  377. package/src/components/countdown/countdown.tsx +15 -1
  378. package/src/components/date-field/date-field.tsx +36 -1
  379. package/src/components/date-picker/date-picker.test.tsx +1 -1
  380. package/src/components/date-picker/date-picker.tsx +95 -1
  381. package/src/components/dialog/dialog.test.tsx +30 -1
  382. package/src/components/dialog/dialog.tsx +28 -6
  383. package/src/components/drawer/drawer.test.tsx +32 -1
  384. package/src/components/drawer/drawer.tsx +37 -7
  385. package/src/components/dropdown-menu/dropdown-menu.tsx +11 -5
  386. package/src/components/field/field.tsx +1 -1
  387. package/src/components/fieldset/fieldset.tsx +1 -1
  388. package/src/components/gradient-glow/gradient-glow.test.tsx +1 -1
  389. package/src/components/gradient-glow/gradient-glow.tsx +46 -1
  390. package/src/components/input/input-variants.ts +1 -1
  391. package/src/components/input/input.tsx +24 -4
  392. package/src/components/kbd/kbd.tsx +9 -1
  393. package/src/components/loader/loader.tsx +9 -1
  394. package/src/components/menubar/menubar.tsx +9 -1
  395. package/src/components/meter/meter.tsx +5 -1
  396. package/src/components/navigation/navigation-link-variants.ts +1 -1
  397. package/src/components/navigation/navigation-link.tsx +23 -1
  398. package/src/components/navigation/navigation.tsx +23 -3
  399. package/src/components/navigation-menu/navigation-menu.tsx +34 -1
  400. package/src/components/number-field/number-field.tsx +15 -1
  401. package/src/components/otp-field/otp-field.tsx +10 -1
  402. package/src/components/pagination/pagination.tsx +17 -1
  403. package/src/components/popover/popover.test.tsx +1 -1
  404. package/src/components/popover/popover.tsx +6 -2
  405. package/src/components/preview-card/preview-card.tsx +6 -2
  406. package/src/components/progress/progress.tsx +18 -1
  407. package/src/components/radio/radio.test.tsx +1 -1
  408. package/src/components/radio/radio.tsx +1 -1
  409. package/src/components/radio-group/radio-group.test.tsx +1 -1
  410. package/src/components/radio-group/radio-group.tsx +5 -1
  411. package/src/components/rating/rating.test.tsx +246 -0
  412. package/src/components/rating/rating.tsx +457 -0
  413. package/src/components/scroll-area/scroll-area.test.tsx +1 -1
  414. package/src/components/scroll-area/scroll-area.tsx +14 -1
  415. package/src/components/select/select.tsx +21 -2
  416. package/src/components/separator/separator.tsx +5 -1
  417. package/src/components/skeleton/skeleton.tsx +5 -1
  418. package/src/components/slider/slider.test.tsx +1 -1
  419. package/src/components/slider/slider.tsx +6 -1
  420. package/src/components/sparkline/sparkline.test.tsx +1 -1
  421. package/src/components/sparkline/sparkline.tsx +45 -1
  422. package/src/components/spinner/spinner.tsx +9 -1
  423. package/src/components/switch/switch.test.tsx +1 -1
  424. package/src/components/switch/switch.tsx +5 -1
  425. package/src/components/table/table.tsx +29 -1
  426. package/src/components/tabs/tabs.test.tsx +1 -1
  427. package/src/components/tabs/tabs.tsx +33 -2
  428. package/src/components/text-animate/text-animate.test.tsx +62 -0
  429. package/src/components/text-animate/text-animate.tsx +77 -9
  430. package/src/components/textarea/textarea.tsx +16 -1
  431. package/src/components/thumbnail/thumbnail.test.tsx +1 -1
  432. package/src/components/thumbnail/thumbnail.tsx +21 -1
  433. package/src/components/time-field/time-field.tsx +36 -1
  434. package/src/components/toast/toast.test.tsx +1 -1
  435. package/src/components/toast/toast.tsx +19 -1
  436. package/src/components/toc/toc.tsx +11 -1
  437. package/src/components/toggle/toggle.test.tsx +1 -1
  438. package/src/components/toggle-group/toggle-group.tsx +1 -1
  439. package/src/components/toolbar/toolbar.tsx +1 -1
  440. package/src/components/tooltip/tooltip.test.tsx +1 -1
  441. package/src/components/tooltip/tooltip.tsx +6 -2
  442. package/src/hooks/use-dismissible.ts +4 -0
  443. package/src/hooks/use-local-storage.ts +3 -3
  444. package/src/hooks/use-reduced-motion.ts +1 -1
  445. package/src/hooks/use-theme.ts +1 -1
  446. package/src/index.ts +11 -2
  447. package/src/internal/color-control.ts +178 -0
  448. package/src/internal/color-math.ts +44 -0
  449. package/src/internal/color-picker-context.ts +80 -0
  450. package/src/{floating.ts → internal/floating.ts} +3 -3
  451. package/src/{modal.ts → internal/modal.ts} +3 -3
  452. package/src/lib/color.test.ts +178 -0
  453. package/src/lib/color.ts +471 -0
  454. package/src/providers/direction-provider.tsx +4 -4
  455. package/src/providers/reduced-motion-provider.tsx +4 -8
  456. package/src/providers/theme-provider/theme-provider.tsx +28 -12
  457. package/src/providers/theme-provider/theme-script.tsx +2 -2
  458. package/src/test/setup.ts +1 -1
  459. package/styles.css +28 -4
  460. package/dist/floating.d.ts.map +0 -1
  461. package/dist/floating.js.map +0 -1
  462. package/dist/modal.d.ts.map +0 -1
  463. package/dist/modal.js.map +0 -1
  464. package/dist/utils.d.ts.map +0 -1
  465. package/dist/utils.js.map +0 -1
  466. /package/dist/{floating.js → internal/floating.js} +0 -0
  467. /package/dist/{modal.js → internal/modal.js} +0 -0
  468. /package/dist/{utils.d.ts → internal/utils.d.ts} +0 -0
  469. /package/dist/{utils.js → internal/utils.js} +0 -0
  470. /package/src/{floating.test.ts → internal/floating.test.ts} +0 -0
  471. /package/src/{modal.test.ts → internal/modal.test.ts} +0 -0
  472. /package/src/{utils.test.tsx → internal/utils.test.tsx} +0 -0
  473. /package/src/{utils.ts → internal/utils.ts} +0 -0
@@ -0,0 +1,471 @@
1
+ // Color model shared by the color components (ColorArea, ColorSlider, ColorSwatch,
2
+ // ColorSwatchPicker, ColorPicker). A Color is a plain, serializable object
3
+ // rather than a class instance, so it can cross the RSC boundary and survive
4
+ // `structuredClone` - a class would not.
5
+ //
6
+ // The matrix conversions live in ../color-math, which stays free of objects and of
7
+ // this module's clamping rules.
8
+
9
+ import { linearRgbToOklab, oklchToSrgb, srgbToLinear } from '../internal/color-math'
10
+
11
+ /** A color space a `Color` can be expressed in. */
12
+ export type ColorSpace = 'rgb' | 'hsl' | 'hsb' | 'oklch'
13
+
14
+ /** A single adjustable component of a color. */
15
+ export type ColorChannel =
16
+ 'red' | 'green' | 'blue' | 'hue' | 'saturation' | 'lightness' | 'brightness' | 'chroma' | 'alpha'
17
+
18
+ /** A string form `formatColor` can produce and `parseColor` can read back. */
19
+ export type ColorFormat = 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsb' | 'hsba' | 'oklch' | 'oklcha'
20
+
21
+ /** sRGB color. Channels are 0-255, alpha is 0-1. */
22
+ export interface RgbColor {
23
+ space: 'rgb'
24
+ red: number
25
+ green: number
26
+ blue: number
27
+ alpha: number
28
+ }
29
+
30
+ /** HSL color. Hue is 0-360, saturation and lightness are 0-100, alpha is 0-1. */
31
+ export interface HslColor {
32
+ space: 'hsl'
33
+ hue: number
34
+ saturation: number
35
+ lightness: number
36
+ alpha: number
37
+ }
38
+
39
+ /** HSB (a.k.a. HSV) color. Hue is 0-360, saturation and brightness are 0-100, alpha is 0-1. */
40
+ export interface HsbColor {
41
+ space: 'hsb'
42
+ hue: number
43
+ saturation: number
44
+ brightness: number
45
+ alpha: number
46
+ }
47
+
48
+ /** OKLCh color. Lightness is 0-100, chroma is 0-0.4, hue is 0-360, alpha is 0-1. */
49
+ export interface OklchColor {
50
+ space: 'oklch'
51
+ lightness: number
52
+ chroma: number
53
+ hue: number
54
+ alpha: number
55
+ }
56
+
57
+ /** A color value in one of the supported color spaces. */
58
+ export type Color = RgbColor | HslColor | HsbColor | OklchColor
59
+
60
+ /** The bounds and increments of a channel within a given color space. */
61
+ export interface ColorChannelRange {
62
+ /** Lowest value the channel accepts. */
63
+ minValue: number
64
+ /** Highest value the channel accepts. */
65
+ maxValue: number
66
+ /** Increment applied by an arrow key. */
67
+ step: number
68
+ /** Increment applied by Page Up, Page Down, or a shifted arrow key. */
69
+ pageSize: number
70
+ }
71
+
72
+ /** The three channels of a color space, mapped onto the axes of a color area. */
73
+ export interface ColorAxes {
74
+ /** Channel driven by the horizontal axis. */
75
+ xChannel: ColorChannel
76
+ /** Channel driven by the vertical axis. */
77
+ yChannel: ColorChannel
78
+ /** Channel held constant, and so not represented by either axis. */
79
+ zChannel: ColorChannel
80
+ }
81
+
82
+ const CHANNELS: Record<ColorSpace, [ColorChannel, ColorChannel, ColorChannel]> = {
83
+ rgb: ['red', 'green', 'blue'],
84
+ hsl: ['hue', 'saturation', 'lightness'],
85
+ hsb: ['hue', 'saturation', 'brightness'],
86
+ oklch: ['lightness', 'chroma', 'hue'],
87
+ }
88
+
89
+ const RANGES: Record<ColorSpace, Partial<Record<ColorChannel, ColorChannelRange>>> = {
90
+ rgb: {
91
+ red: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 },
92
+ green: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 },
93
+ blue: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 },
94
+ },
95
+ hsl: {
96
+ hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 },
97
+ saturation: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
98
+ lightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
99
+ },
100
+ hsb: {
101
+ hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 },
102
+ saturation: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
103
+ brightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
104
+ },
105
+ oklch: {
106
+ lightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
107
+ chroma: { minValue: 0, maxValue: 0.4, step: 0.005, pageSize: 0.05 },
108
+ hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 },
109
+ },
110
+ }
111
+
112
+ const ALPHA_RANGE: ColorChannelRange = { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 }
113
+
114
+ /** Returns the three channels that define `space`, in canonical order. */
115
+ export function getColorChannels(space: ColorSpace): [ColorChannel, ColorChannel, ColorChannel] {
116
+ return CHANNELS[space]
117
+ }
118
+
119
+ /** Returns the bounds and increments of `channel` within `space`. */
120
+ export function getChannelRange(space: ColorSpace, channel: ColorChannel): ColorChannelRange {
121
+ if (channel === 'alpha') return ALPHA_RANGE
122
+ const range = RANGES[space][channel]
123
+ if (!range) throw new Error(`Channel "${channel}" is not part of the ${space} color space`)
124
+ return range
125
+ }
126
+
127
+ /** Reads a single channel off a color. Throws if the channel is not in the color's space. */
128
+ export function getChannelValue(color: Color, channel: ColorChannel): number {
129
+ const value = (color as unknown as Record<string, number>)[channel]
130
+ if (typeof value !== 'number') {
131
+ throw new Error(`Channel "${channel}" is not part of the ${color.space} color space`)
132
+ }
133
+ return value
134
+ }
135
+
136
+ /** Returns a copy of `color` with `channel` clamped into range and set to `value`. */
137
+ export function withChannelValue(color: Color, channel: ColorChannel, value: number): Color {
138
+ const { minValue, maxValue } = getChannelRange(color.space, channel)
139
+ return { ...color, [channel]: clamp(value, minValue, maxValue) } as Color
140
+ }
141
+
142
+ /**
143
+ * Resolves the x, y and z channels of a color area. Unspecified axes fall back to
144
+ * the first channels of `space` that are still free.
145
+ */
146
+ export function getColorSpaceAxes(space: ColorSpace, axes: Partial<Omit<ColorAxes, 'zChannel'>> = {}): ColorAxes {
147
+ const channels = CHANNELS[space]
148
+ const xChannel = axes.xChannel ?? channels.find((c) => c !== axes.yChannel)!
149
+ const yChannel = axes.yChannel ?? channels.find((c) => c !== xChannel)!
150
+ const zChannel = channels.find((c) => c !== xChannel && c !== yChannel)!
151
+ return { xChannel, yChannel, zChannel }
152
+ }
153
+
154
+ function clamp(value: number, min: number, max: number) {
155
+ return Math.min(Math.max(value, min), max)
156
+ }
157
+
158
+ // Guarded so an in-range hue comes back bit for bit - the modulo round trip adds
159
+ // float error that would surface in parsed values. 360 is inside the range too: it is
160
+ // the hue channel's documented maximum, so a slider that reaches it has to be able to
161
+ // write it out and read it back, even though it paints the same color as 0.
162
+ function mod360(hue: number) {
163
+ if (hue >= 0 && hue <= 360) return hue
164
+ return ((hue % 360) + 360) % 360
165
+ }
166
+
167
+ function rgbToHsb(color: RgbColor): HsbColor {
168
+ const r = color.red / 255
169
+ const g = color.green / 255
170
+ const b = color.blue / 255
171
+ const max = Math.max(r, g, b)
172
+ const min = Math.min(r, g, b)
173
+ const delta = max - min
174
+
175
+ let hue = 0
176
+ if (delta !== 0) {
177
+ if (max === r) hue = ((g - b) / delta) % 6
178
+ else if (max === g) hue = (b - r) / delta + 2
179
+ else hue = (r - g) / delta + 4
180
+ }
181
+
182
+ return {
183
+ space: 'hsb',
184
+ hue: mod360(hue * 60),
185
+ saturation: max === 0 ? 0 : (delta / max) * 100,
186
+ brightness: max * 100,
187
+ alpha: color.alpha,
188
+ }
189
+ }
190
+
191
+ function hsbToRgb(color: HsbColor): RgbColor {
192
+ const s = color.saturation / 100
193
+ const v = color.brightness / 100
194
+ const c = v * s
195
+ const h = color.hue / 60
196
+ const x = c * (1 - Math.abs((h % 2) - 1))
197
+ const m = v - c
198
+ const [r, g, b] = sector(h, c, x)
199
+ return { space: 'rgb', red: (r + m) * 255, green: (g + m) * 255, blue: (b + m) * 255, alpha: color.alpha }
200
+ }
201
+
202
+ function rgbToHsl(color: RgbColor): HslColor {
203
+ const hsb = rgbToHsb(color)
204
+ const v = hsb.brightness / 100
205
+ const s = hsb.saturation / 100
206
+ const l = v * (1 - s / 2)
207
+ return {
208
+ space: 'hsl',
209
+ hue: hsb.hue,
210
+ saturation: l === 0 || l === 1 ? 0 : ((v - l) / Math.min(l, 1 - l)) * 100,
211
+ lightness: l * 100,
212
+ alpha: color.alpha,
213
+ }
214
+ }
215
+
216
+ function hslToRgb(color: HslColor): RgbColor {
217
+ const s = color.saturation / 100
218
+ const l = color.lightness / 100
219
+ const c = (1 - Math.abs(2 * l - 1)) * s
220
+ const h = color.hue / 60
221
+ const x = c * (1 - Math.abs((h % 2) - 1))
222
+ const m = l - c / 2
223
+ const [r, g, b] = sector(h, c, x)
224
+ return { space: 'rgb', red: (r + m) * 255, green: (g + m) * 255, blue: (b + m) * 255, alpha: color.alpha }
225
+ }
226
+
227
+ function sector(h: number, c: number, x: number): [number, number, number] {
228
+ if (h < 1) return [c, x, 0]
229
+ if (h < 2) return [x, c, 0]
230
+ if (h < 3) return [0, c, x]
231
+ if (h < 4) return [0, x, c]
232
+ if (h < 5) return [x, 0, c]
233
+ return [c, 0, x]
234
+ }
235
+
236
+ function rgbToOklch(color: RgbColor): OklchColor {
237
+ const [L, a, b] = linearRgbToOklab(
238
+ srgbToLinear(color.red / 255),
239
+ srgbToLinear(color.green / 255),
240
+ srgbToLinear(color.blue / 255),
241
+ )
242
+ const chroma = Math.sqrt(a * a + b * b)
243
+ return {
244
+ space: 'oklch',
245
+ lightness: L * 100,
246
+ chroma,
247
+ // Hue is meaningless at zero chroma and float noise there swings wildly, so pin
248
+ // it to keep round trips through gray stable.
249
+ hue: chroma < 1e-6 ? 0 : mod360((Math.atan2(b, a) * 180) / Math.PI),
250
+ alpha: color.alpha,
251
+ }
252
+ }
253
+
254
+ function oklchToRgb(color: OklchColor): RgbColor {
255
+ const [r, g, b] = oklchToSrgb(color.lightness / 100, color.chroma, color.hue)
256
+ return {
257
+ space: 'rgb',
258
+ red: clamp(r, 0, 1) * 255,
259
+ green: clamp(g, 0, 1) * 255,
260
+ blue: clamp(b, 0, 1) * 255,
261
+ alpha: color.alpha,
262
+ }
263
+ }
264
+
265
+ function toRgb(color: Color): RgbColor {
266
+ switch (color.space) {
267
+ case 'rgb':
268
+ return color
269
+ case 'hsl':
270
+ return hslToRgb(color)
271
+ case 'hsb':
272
+ return hsbToRgb(color)
273
+ case 'oklch':
274
+ return oklchToRgb(color)
275
+ }
276
+ }
277
+
278
+ /** Converts `color` into `space`. Returns the same object when it is already there. */
279
+ export function convertColor<S extends ColorSpace>(color: Color, space: S): Extract<Color, { space: S }> {
280
+ if (color.space === space) return color as Extract<Color, { space: S }>
281
+ const rgb = toRgb(color)
282
+ switch (space) {
283
+ case 'rgb':
284
+ return rgb as Extract<Color, { space: S }>
285
+ case 'hsl':
286
+ return rgbToHsl(rgb) as Extract<Color, { space: S }>
287
+ case 'hsb':
288
+ return rgbToHsb(rgb) as Extract<Color, { space: S }>
289
+ default:
290
+ return rgbToOklch(rgb) as Extract<Color, { space: S }>
291
+ }
292
+ }
293
+
294
+ const CHANNEL_NAMES: Record<ColorChannel, string> = {
295
+ red: 'Red',
296
+ green: 'Green',
297
+ blue: 'Blue',
298
+ hue: 'Hue',
299
+ saturation: 'Saturation',
300
+ lightness: 'Lightness',
301
+ brightness: 'Brightness',
302
+ chroma: 'Chroma',
303
+ alpha: 'Alpha',
304
+ }
305
+
306
+ /** Returns the English display name of `channel`, for labels and value text. */
307
+ export function getChannelName(channel: ColorChannel): string {
308
+ return CHANNEL_NAMES[channel]
309
+ }
310
+
311
+ /** Formats a channel value for display, with the unit the channel is measured in. */
312
+ export function formatChannelValue(color: Color, channel: ColorChannel): string {
313
+ const value = getChannelValue(color, channel)
314
+ if (channel === 'hue') return `${Math.round(value)}°`
315
+ if (channel === 'chroma') return value.toFixed(3)
316
+ if (channel === 'alpha') return `${Math.round(value * 100)}%`
317
+ if (color.space === 'rgb') return `${Math.round(value)}`
318
+ return `${Math.round(value)}%`
319
+ }
320
+
321
+ const HEX_RE = /^#([0-9a-f]{3,8})$/i
322
+ const FUNC_RE = /^(rgba?|hsla?|hsba?|hsva?|oklch)\(([^)]*)\)$/i
323
+
324
+ function parseComponent(raw: string, scale: number, max: number): number {
325
+ const percent = raw.endsWith('%')
326
+ const value = Number.parseFloat(percent ? raw.slice(0, -1) : raw)
327
+ if (Number.isNaN(value)) throw new Error(`Invalid color component "${raw}"`)
328
+ return clamp(percent ? (value / 100) * scale : value, 0, max)
329
+ }
330
+
331
+ function parseAlpha(raw: string | undefined): number {
332
+ if (raw == null || raw === '' || raw === 'none') return 1
333
+ return parseComponent(raw, 1, 1)
334
+ }
335
+
336
+ /**
337
+ * Parses a CSS color string into a `Color`. Accepts hex (3, 4, 6 or 8 digits),
338
+ * `rgb()`, `hsl()`, `oklch()` in both comma and space separated forms, plus the
339
+ * non-CSS `hsb()` used by design tools. Throws on anything else.
340
+ */
341
+ export function parseColor(value: string): Color {
342
+ const input = value.trim()
343
+
344
+ const hex = HEX_RE.exec(input)
345
+ if (hex) {
346
+ const digits = hex[1] ?? ''
347
+ if (digits.length !== 3 && digits.length !== 4 && digits.length !== 6 && digits.length !== 8) {
348
+ throw new Error(`Invalid hex color "${value}"`)
349
+ }
350
+ const expand = digits.length <= 4
351
+ const size = expand ? 1 : 2
352
+ const channel = (i: number) => {
353
+ const slice = digits.slice(i * size, i * size + size)
354
+ return Number.parseInt(expand ? slice + slice : slice, 16)
355
+ }
356
+ return {
357
+ space: 'rgb',
358
+ red: channel(0),
359
+ green: channel(1),
360
+ blue: channel(2),
361
+ alpha: digits.length === 4 || digits.length === 8 ? channel(3) / 255 : 1,
362
+ }
363
+ }
364
+
365
+ const func = FUNC_RE.exec(input)
366
+ if (func) {
367
+ const name = (func[1] ?? '').toLowerCase()
368
+ const parts = (func[2] ?? '')
369
+ .replace('/', ' ')
370
+ .split(/[\s,]+/)
371
+ .filter(Boolean)
372
+ const [first, second, third, fourth] = parts
373
+ if (first == null || second == null || third == null) throw new Error(`Invalid color "${value}"`)
374
+ const alpha = parseAlpha(fourth)
375
+
376
+ if (name === 'rgb' || name === 'rgba') {
377
+ return {
378
+ space: 'rgb',
379
+ red: parseComponent(first, 255, 255),
380
+ green: parseComponent(second, 255, 255),
381
+ blue: parseComponent(third, 255, 255),
382
+ alpha,
383
+ }
384
+ }
385
+ if (name === 'hsl' || name === 'hsla') {
386
+ return {
387
+ space: 'hsl',
388
+ hue: mod360(Number.parseFloat(first)),
389
+ saturation: parseComponent(second, 100, 100),
390
+ lightness: parseComponent(third, 100, 100),
391
+ alpha,
392
+ }
393
+ }
394
+ if (name === 'oklch') {
395
+ return {
396
+ space: 'oklch',
397
+ lightness: parseComponent(first, 100, 100),
398
+ chroma: parseComponent(second, 0.4, Number.POSITIVE_INFINITY),
399
+ hue: mod360(Number.parseFloat(third)),
400
+ alpha,
401
+ }
402
+ }
403
+ return {
404
+ space: 'hsb',
405
+ hue: mod360(Number.parseFloat(first)),
406
+ saturation: parseComponent(second, 100, 100),
407
+ brightness: parseComponent(third, 100, 100),
408
+ alpha,
409
+ }
410
+ }
411
+
412
+ throw new Error(`Invalid color "${value}"`)
413
+ }
414
+
415
+ /** Parses `value` into a `Color`, returning `undefined` instead of throwing on bad input. */
416
+ export function safeParseColor(value: string): Color | undefined {
417
+ try {
418
+ return parseColor(value)
419
+ } catch {
420
+ return undefined
421
+ }
422
+ }
423
+
424
+ function round(value: number, precision = 0) {
425
+ const factor = 10 ** precision
426
+ return Math.round(value * factor) / factor
427
+ }
428
+
429
+ function hexPair(value: number) {
430
+ return clamp(Math.round(value), 0, 255).toString(16).padStart(2, '0')
431
+ }
432
+
433
+ /**
434
+ * Serializes `color` to a CSS string. `'css'` picks the shortest form the browser
435
+ * understands for the color's own space, which is what you want for a `background`.
436
+ */
437
+ export function formatColor(color: Color, format: ColorFormat | 'css' = 'css'): string {
438
+ if (format === 'css') {
439
+ const space = color.space === 'hsb' ? 'hsl' : color.space
440
+ return formatColor(color, (color.alpha < 1 ? `${space}a` : space) as ColorFormat)
441
+ }
442
+
443
+ if (format === 'hex' || format === 'hexa') {
444
+ const rgb = convertColor(color, 'rgb')
445
+ const base = `#${hexPair(rgb.red)}${hexPair(rgb.green)}${hexPair(rgb.blue)}`
446
+ return format === 'hexa' ? `${base}${hexPair(rgb.alpha * 255)}` : base
447
+ }
448
+
449
+ const withAlpha = format.endsWith('a')
450
+ const alpha = round(color.alpha, 2)
451
+
452
+ if (format === 'rgb' || format === 'rgba') {
453
+ const { red, green, blue } = convertColor(color, 'rgb')
454
+ const channels = `${round(red)}, ${round(green)}, ${round(blue)}`
455
+ return withAlpha ? `rgba(${channels}, ${alpha})` : `rgb(${channels})`
456
+ }
457
+ if (format === 'hsl' || format === 'hsla') {
458
+ const { hue, saturation, lightness } = convertColor(color, 'hsl')
459
+ const channels = `${round(hue, 2)}, ${round(saturation, 2)}%, ${round(lightness, 2)}%`
460
+ return withAlpha ? `hsla(${channels}, ${alpha})` : `hsl(${channels})`
461
+ }
462
+ if (format === 'hsb' || format === 'hsba') {
463
+ const { hue, saturation, brightness } = convertColor(color, 'hsb')
464
+ const channels = `${round(hue, 2)}, ${round(saturation, 2)}%, ${round(brightness, 2)}%`
465
+ return withAlpha ? `hsba(${channels}, ${alpha})` : `hsb(${channels})`
466
+ }
467
+
468
+ const { lightness, chroma, hue } = convertColor(color, 'oklch')
469
+ const channels = `${round(lightness, 2)}% ${round(chroma, 4)} ${round(hue, 2)}`
470
+ return withAlpha ? `oklch(${channels} / ${alpha})` : `oklch(${channels})`
471
+ }
@@ -4,11 +4,11 @@ import { DirectionProvider as BaseDirectionProvider } from '@base-ui/react/direc
4
4
  export type Direction = 'ltr' | 'rtl'
5
5
 
6
6
  export interface DirectionProviderProps {
7
+ /** The subtree that should read this direction */
7
8
  children: ReactNode
8
9
  /**
9
- * Reading direction for components with bidirectional layout (Switch, Slider,
10
- * Carousel, etc.). Matches the HTML `dir` attribute; descendants read it via
11
- * our `useDirection()` hook. Defaults to `ltr`.
10
+ * Reading direction for descendant components
11
+ * @default 'ltr'
12
12
  */
13
13
  dir?: Direction
14
14
  }
@@ -18,7 +18,7 @@ export interface DirectionProviderProps {
18
18
  * UI's direction provider so consumers depend on `@appica/ui-react` rather than
19
19
  * the underlying primitive.
20
20
  *
21
- * Optional — components default to `ltr` with no provider, so reach for this
21
+ * Optional - components default to `ltr` with no provider, so reach for this
22
22
  * only when supporting RTL.
23
23
  */
24
24
  export function DirectionProvider({ children, dir = 'ltr' }: DirectionProviderProps) {
@@ -13,15 +13,11 @@ const DEFAULT_CONTEXT: ReducedMotionContextValue = {
13
13
  const ReducedMotionContext = createContext<ReducedMotionContextValue>(DEFAULT_CONTEXT)
14
14
 
15
15
  export interface ReducedMotionProviderProps {
16
+ /** The subtree to opt out of animation */
16
17
  children: ReactNode
17
18
  /**
18
- * Force-disable all component animations regardless of OS `prefers-reduced-motion`.
19
- * Components also respect the OS preference automatically — this is the global override.
20
- *
21
- * The attribute is set on `<html>` (not on a wrapper div) so it reaches Base UI's portaled
22
- * popups, which render under `document.body` and therefore escape the React subtree. The
23
- * `motion-reduce:` / `motion-safe:` custom variants in styles.css already target
24
- * `[data-disable-animations] *`.
19
+ * Force-disable animations regardless of the OS preference
20
+ * @default false
25
21
  */
26
22
  disableAnimations?: boolean
27
23
  }
@@ -35,7 +31,7 @@ const ATTR = 'data-disable-animations'
35
31
  * written to `<html>`, so it applies page-wide while mounted and covers
36
32
  * portaled popups.
37
33
  *
38
- * Optional — components already respect the OS `prefers-reduced-motion`
34
+ * Optional - components already respect the OS `prefers-reduced-motion`
39
35
  * preference with no provider. Reach for this only to force-disable animations.
40
36
  */
41
37
  export function ReducedMotionProvider({ children, disableAnimations = false }: ReducedMotionProviderProps) {
@@ -16,12 +16,12 @@ export interface ThemeContextValue {
16
16
  /** The chosen theme, possibly `'system'`. */
17
17
  theme: string | undefined
18
18
  setTheme: (value: string | ((prev: string) => string)) => void
19
- /** The theme actually applied — `'system'` resolved to `'light'`/`'dark'`. */
19
+ /** The theme actually applied - `'system'` resolved to `'light'`/`'dark'`. */
20
20
  resolvedTheme: string | undefined
21
21
  systemTheme: 'light' | 'dark' | undefined
22
22
  themes: string[]
23
23
  forcedTheme: string | undefined
24
- /** `false` until the client has mounted — guard theme-dependent UI with this. */
24
+ /** `false` until the client has mounted - guard theme-dependent UI with this. */
25
25
  mounted: boolean
26
26
  }
27
27
 
@@ -42,26 +42,42 @@ export function useThemeContext(): ThemeContextValue {
42
42
  }
43
43
 
44
44
  export interface ThemeProviderProps {
45
+ /** The subtree the theme applies to */
45
46
  children?: React.ReactNode
46
- /** Available theme names. Default `['light', 'dark']`. */
47
+ /**
48
+ * Available theme names
49
+ * @default ['light', 'dark']
50
+ */
47
51
  themes?: string[]
48
- /** Force a theme for the whole tree (e.g. a docs page); overrides storage + system. */
52
+ /** Force a theme for the whole subtree (overrides storage + OS) */
49
53
  forcedTheme?: string
50
- /** Respect the OS `prefers-color-scheme`. Default `true`. */
54
+ /**
55
+ * Respect the OS `prefers-color-scheme`
56
+ * @default true
57
+ */
51
58
  enableSystem?: boolean
52
- /** Suppress CSS transitions during a theme change so colors don't animate. Default `false`. */
59
+ /**
60
+ * Suppress CSS transitions during a theme switch
61
+ * @default false
62
+ */
53
63
  disableTransitionOnChange?: boolean
54
- /** Set `color-scheme` on `<html>` so native UI (scrollbars, form controls) matches. Default `true`. */
64
+ /**
65
+ * Set `color-scheme` on `<html>` so native UI matches
66
+ * @default true
67
+ */
55
68
  enableColorScheme?: boolean
56
- /** Storage key for the persisted choice. Default `'theme'`. */
69
+ /**
70
+ * `localStorage` key for the persisted choice
71
+ * @default 'theme'
72
+ */
57
73
  storageKey?: string
58
- /** Theme used before a choice is stored. Default `enableSystem ? 'system' : 'light'`. */
74
+ /** Theme used before a choice is stored */
59
75
  defaultTheme?: string
60
- /** Map a theme name to a custom class applied on `<html>`. */
76
+ /** Map a theme name to a custom class applied on `<html>` */
61
77
  value?: Record<string, string>
62
- /** CSP nonce forwarded to the inline no-flash script. */
78
+ /** CSP nonce forwarded to the inline script */
63
79
  nonce?: string
64
- /** Extra props for the inline `<script>` element. */
80
+ /** Extra props for the inline `<script>` */
65
81
  scriptProps?: React.ScriptHTMLAttributes<HTMLScriptElement>
66
82
  }
67
83
 
@@ -1,5 +1,5 @@
1
1
  // Server-safe: a pure inline-script generator plus a <script> component.
2
- // No 'use client' — `getThemeScript` can be called in any environment (Vite
2
+ // No 'use client' - `getThemeScript` can be called in any environment (Vite
3
3
  // main entry, Astro `is:inline`, etc.) and `ThemeScript` can render in a
4
4
  // Server Component <head>.
5
5
 
@@ -51,7 +51,7 @@ function themeScript(
51
51
  : stored
52
52
  updateDOM(resolved)
53
53
  } catch (e) {
54
- // storage unavailable — leave the default
54
+ // storage unavailable - leave the default
55
55
  }
56
56
  }
57
57
  }
package/src/test/setup.ts CHANGED
@@ -5,7 +5,7 @@ import * as matchers from 'vitest-axe/matchers'
5
5
 
6
6
  expect.extend(matchers)
7
7
 
8
- // jsdom doesn't implement window.matchMedia — stub it so hooks that read
8
+ // jsdom doesn't implement window.matchMedia - stub it so hooks that read
9
9
  // media preferences (e.g. useReducedMotion) work in tests. Default to
10
10
  // "no match" so animations stay enabled; individual tests can override.
11
11
  if (typeof window !== 'undefined' && !window.matchMedia) {
package/styles.css CHANGED
@@ -497,13 +497,17 @@
497
497
  }
498
498
 
499
499
  @utility animate-gradient-glow {
500
- animation: gradient-glow var(--gradient-glow-duration, 4s) linear infinite;
500
+ animation-name: gradient-glow;
501
+ animation-duration: var(--gradient-glow-duration, 4s);
502
+ animation-timing-function: linear;
503
+ animation-iteration-count: infinite;
501
504
  }
502
505
 
503
506
  @utility animate-gradient-glow-aura {
504
- animation:
505
- gradient-glow var(--gradient-glow-duration, 4s) linear infinite,
506
- gradient-glow-pulse var(--gradient-glow-duration, 4s) ease-in-out infinite;
507
+ animation-name: gradient-glow, gradient-glow-pulse;
508
+ animation-duration: var(--gradient-glow-duration, 4s);
509
+ animation-timing-function: linear, ease-in-out;
510
+ animation-iteration-count: infinite;
507
511
  }
508
512
 
509
513
  @keyframes gradient-glow {
@@ -521,3 +525,23 @@
521
525
  transform: scale(1.03);
522
526
  }
523
527
  }
528
+
529
+ @property --border-beam-angle {
530
+ syntax: '<angle>';
531
+ inherits: false;
532
+ initial-value: 0deg;
533
+ }
534
+
535
+ @utility animate-border-beam {
536
+ animation-name: border-beam;
537
+ animation-duration: var(--border-beam-duration, 5s);
538
+ animation-delay: var(--border-beam-delay, 0s);
539
+ animation-timing-function: linear;
540
+ animation-iteration-count: infinite;
541
+ }
542
+
543
+ @keyframes border-beam {
544
+ to {
545
+ --border-beam-angle: 360deg;
546
+ }
547
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"floating.d.ts","sourceRoot":"","sources":["../src/floating.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,uMAa3B,CAAA;AAEV,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,uCAAwC,CAAA;AAEzE,KAAK,aAAa,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC9D,KAAK,SAAS,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,aAAa,CAAC,CAAC,GAC/G,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG;IAC/C,8FAA8F;IAC9F,eAAe,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,UAAU,CAAC,CAAA;IAC9D,0FAA0F;IAC1F,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC,CAAA;CACnD,CAAA;AAEH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAsBrF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"floating.js","sources":["../src/floating.ts"],"sourcesContent":["// Shared plumbing for floating *Content components — the ones that wrap a Base UI\n// Portal → Positioner → Popup trio (Popover, Tooltip, PreviewCard, Menu, Select,\n// Combobox, Autocomplete, …).\n//\n// Consumers of this library don't get direct access to the inner Portal/Positioner\n// elements the way a copy-paste (shadcn-style) component would. So every *Content\n// must map the Base UI surface itself. This module keeps that mapping consistent:\n//\n// 1. The common Positioner positioning props (+ the two Portal props) are\n// promoted to flat props on *Content — Radix/shadcn ergonomics.\n// 2. `positionerProps` / `portalProps` escape hatches forward the long tail\n// (e.g. `style`, `render`) without each component re-enumerating it.\n//\n// `className`/`style`/`render` are intentionally NOT promoted: *Content represents\n// the Popup, so those stay bound to it. Use the escape hatches to reach the\n// Positioner/Portal element instead.\n\n/**\n * Positioner props promoted to flat props on every floating *Content.\n * Mirrors Base UI's `UseAnchorPositioningSharedParameters` (v1.5.0).\n */\nexport const FLOATING_POSITIONER_KEYS = [\n 'side',\n 'sideOffset',\n 'align',\n 'alignOffset',\n 'anchor',\n 'positionMethod',\n 'collisionBoundary',\n 'collisionPadding',\n 'collisionAvoidance',\n 'sticky',\n 'arrowPadding',\n 'disableAnchorTracking',\n] as const\n\n/** Portal props promoted to flat props on every floating *Content. */\nexport const FLOATING_PORTAL_KEYS = ['container', 'keepMounted'] as const\n\ntype PositionerKey = (typeof FLOATING_POSITIONER_KEYS)[number]\ntype PortalKey = (typeof FLOATING_PORTAL_KEYS)[number]\n\n/**\n * Flat positioning/portal props + typed escape hatches, derived from a\n * component's own Positioner and Portal prop types so each *Content stays in\n * lockstep with Base UI. Intersect with the Popup props to build a *Content\n * prop type:\n *\n * ```ts\n * type PopoverContentProps = React.ComponentProps<typeof BasePopover.Popup> &\n * FloatingContentProps<\n * React.ComponentProps<typeof BasePopover.Positioner>,\n * React.ComponentProps<typeof BasePopover.Portal>\n * > & { arrow?: boolean }\n * ```\n */\nexport type FloatingContentProps<Positioner, Portal> = Pick<Positioner, Extract<keyof Positioner, PositionerKey>> &\n Pick<Portal, Extract<keyof Portal, PortalKey>> & {\n /** Escape hatch: extra props forwarded to the Base UI Positioner (e.g. `style`, `render`). */\n positionerProps?: Omit<Positioner, PositionerKey | 'children'>\n /** Escape hatch: extra props forwarded to the Base UI Portal (e.g. `style`, `render`). */\n portalProps?: Omit<Portal, PortalKey | 'children'>\n }\n\nexport interface SplitFloatingProps {\n positioner: Record<string, unknown>\n portal: Record<string, unknown>\n popup: Record<string, unknown>\n}\n\n/**\n * Partition a *Content component's spread props into its three Base UI targets.\n *\n * - Flat positioning/portal props win over the same keys inside\n * `positionerProps`/`portalProps` (the flat prop is the documented primary API).\n * - Anything left that isn't a known Positioner/Portal prop is treated as a Popup prop.\n *\n * Destructure `className`/`children` (and any component-specific props) out of the\n * props object before calling this — they should not reach the generic Popup spread.\n */\nexport function splitFloatingProps(props: Record<string, unknown>): SplitFloatingProps {\n const { positionerProps, portalProps, ...rest } = props as {\n positionerProps?: Record<string, unknown>\n portalProps?: Record<string, unknown>\n } & Record<string, unknown>\n\n const positioner: Record<string, unknown> = { ...positionerProps }\n const portal: Record<string, unknown> = { ...portalProps }\n const popup: Record<string, unknown> = {}\n\n for (const key of Object.keys(rest)) {\n const value = rest[key]\n if ((FLOATING_POSITIONER_KEYS as readonly string[]).includes(key)) {\n if (value !== undefined) positioner[key] = value\n } else if ((FLOATING_PORTAL_KEYS as readonly string[]).includes(key)) {\n if (value !== undefined) portal[key] = value\n } else {\n popup[key] = value\n }\n }\n\n return { positioner, portal, popup }\n}\n"],"names":[],"mappings":"AAqBO,MAAM,wBAAA,GAA2B;AAAA,EACtC,MAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF;AAGO,MAAM,oBAAA,GAAuB,CAAC,WAAA,EAAa,aAAa;AA2CxD,SAAS,mBAAmB,KAAA,EAAoD;AACrF,EAAA,MAAM,EAAE,eAAA,EAAiB,WAAA,EAAa,GAAG,MAAK,GAAI,KAAA;AAKlD,EAAA,MAAM,UAAA,GAAsC,EAAE,GAAG,eAAA,EAAgB;AACjE,EAAA,MAAM,MAAA,GAAkC,EAAE,GAAG,WAAA,EAAY;AACzD,EAAA,MAAM,QAAiC,EAAC;AAExC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG;AACnC,IAAA,MAAM,KAAA,GAAQ,KAAK,GAAG,CAAA;AACtB,IAAA,IAAK,wBAAA,CAA+C,QAAA,CAAS,GAAG,CAAA,EAAG;AACjE,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,UAAA,CAAW,GAAG,CAAA,GAAI,KAAA;AAAA,IAC7C,CAAA,MAAA,IAAY,oBAAA,CAA2C,QAAA,CAAS,GAAG,CAAA,EAAG;AACpE,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AAAA,IACzC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,GAAG,CAAA,GAAI,KAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAM;AACrC;;;;"}