@refraction-ui/astro 0.4.2 → 0.4.4

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 (334) hide show
  1. package/dist/accordion/index.ts +1 -0
  2. package/dist/ai/ai-manager.ts +121 -0
  3. package/dist/ai/index.ts +23 -0
  4. package/dist/ai/mock-providers.ts +68 -0
  5. package/dist/ai/sanitizer.ts +174 -0
  6. package/dist/ai/tts-manager.ts +80 -0
  7. package/dist/ai/types.ts +72 -0
  8. package/dist/animated-text/animated-text.styles.ts +28 -0
  9. package/dist/animated-text/animated-text.ts +83 -0
  10. package/dist/animated-text/index.ts +15 -0
  11. package/dist/app-shell/app-shell.ts +252 -0
  12. package/dist/app-shell/auth-shell.ts +84 -0
  13. package/dist/app-shell/index.ts +22 -0
  14. package/dist/app-shell/page-shell.ts +125 -0
  15. package/dist/astro-accordion/Button.astro +1 -1
  16. package/dist/astro-ai/index.ts +1 -1
  17. package/dist/astro-animated-text/AnimatedText.astro +1 -1
  18. package/dist/astro-animated-text/TypewriterText.astro +1 -1
  19. package/dist/astro-app-shell/AppShell.astro +1 -1
  20. package/dist/astro-app-shell/AuthShell.astro +1 -1
  21. package/dist/astro-app-shell/AuthShellCard.astro +1 -1
  22. package/dist/astro-app-shell/PageShell.astro +1 -1
  23. package/dist/astro-app-shell/PageShellSection.astro +1 -1
  24. package/dist/astro-app-shell/index.ts +1 -1
  25. package/dist/astro-auth/index.ts +2 -2
  26. package/dist/astro-avatar/Avatar.astro +1 -1
  27. package/dist/astro-avatar/AvatarFallback.astro +1 -1
  28. package/dist/astro-avatar/AvatarImage.astro +1 -1
  29. package/dist/astro-avatar-group/AvatarGroup.astro +1 -1
  30. package/dist/astro-badge/Badge.astro +1 -1
  31. package/dist/astro-bottom-nav/BottomNav.astro +1 -1
  32. package/dist/astro-breadcrumbs/Breadcrumbs.astro +1 -1
  33. package/dist/astro-button/Button.astro +1 -1
  34. package/dist/astro-calendar/Calendar.astro +1 -1
  35. package/dist/astro-card/Card.astro +1 -1
  36. package/dist/astro-card/CardContent.astro +1 -1
  37. package/dist/astro-card/CardDescription.astro +1 -1
  38. package/dist/astro-card/CardFooter.astro +1 -1
  39. package/dist/astro-card/CardHeader.astro +1 -1
  40. package/dist/astro-card/CardTitle.astro +1 -1
  41. package/dist/astro-card-grid/CardGrid.astro +1 -1
  42. package/dist/astro-carousel/Button.astro +1 -1
  43. package/dist/astro-charts/Bars.astro +1 -1
  44. package/dist/astro-charts/Chart.astro +1 -1
  45. package/dist/astro-charts/Circles.astro +1 -1
  46. package/dist/astro-charts/Histogram.astro +1 -1
  47. package/dist/astro-charts/Line.astro +1 -1
  48. package/dist/astro-charts/PieChart.astro +1 -1
  49. package/dist/astro-charts/ScatterPlot.astro +1 -1
  50. package/dist/astro-charts/index.ts +1 -1
  51. package/dist/astro-checkbox/Checkbox.astro +1 -1
  52. package/dist/astro-code-editor/CodeEditor.astro +1 -1
  53. package/dist/astro-collapsible/Collapsible.astro +1 -1
  54. package/dist/astro-collapsible/CollapsibleContent.astro +1 -1
  55. package/dist/astro-command/Command.astro +1 -1
  56. package/dist/astro-command/CommandGroup.astro +1 -1
  57. package/dist/astro-command/CommandInput.astro +1 -1
  58. package/dist/astro-command/CommandItem.astro +1 -1
  59. package/dist/astro-command-input/CommandInput.astro +1 -1
  60. package/dist/astro-content-protection/ContentProtection.astro +1 -1
  61. package/dist/astro-data-table/DataTable.astro +1 -1
  62. package/dist/astro-date-picker/DatePicker.astro +1 -1
  63. package/dist/astro-device-frame/DeviceFrame.astro +1 -1
  64. package/dist/astro-dialog/DialogContent.astro +1 -1
  65. package/dist/astro-dialog/DialogOverlay.astro +1 -1
  66. package/dist/astro-diff-viewer/DiffViewer.astro +1 -1
  67. package/dist/astro-dropdown-menu/DropdownMenuContent.astro +1 -1
  68. package/dist/astro-dropdown-menu/DropdownMenuItem.astro +1 -1
  69. package/dist/astro-emoji-picker/EmojiPicker.astro +1 -1
  70. package/dist/astro-feedback-dialog/FeedbackDialog.astro +1 -1
  71. package/dist/astro-file-upload/FileUpload.astro +1 -1
  72. package/dist/astro-footer/Footer.astro +1 -1
  73. package/dist/astro-inline-editor/InlineEditor.astro +1 -1
  74. package/dist/astro-input/Input.astro +1 -1
  75. package/dist/astro-input-group/InputGroup.astro +1 -1
  76. package/dist/astro-input-group/InputGroupAddon.astro +1 -1
  77. package/dist/astro-input-group/InputGroupButton.astro +1 -1
  78. package/dist/astro-install-prompt/InstallPrompt.astro +1 -1
  79. package/dist/astro-keyboard-shortcut/ShortcutBadge.astro +1 -1
  80. package/dist/astro-language-selector/LanguageSelector.astro +1 -1
  81. package/dist/astro-link-card/LinkCard.astro +1 -1
  82. package/dist/astro-markdown-renderer/MarkdownRenderer.astro +1 -1
  83. package/dist/astro-mobile-nav/MobileNav.astro +1 -1
  84. package/dist/astro-mobile-nav/MobileNavLink.astro +1 -1
  85. package/dist/astro-mobile-nav/MobileNavTrigger.astro +1 -1
  86. package/dist/astro-navbar/Navbar.astro +1 -1
  87. package/dist/astro-otp-input/OtpInput.astro +1 -1
  88. package/dist/astro-payment/Payment.astro +1 -1
  89. package/dist/astro-popover/PopoverContent.astro +1 -1
  90. package/dist/astro-presence-indicator/PresenceIndicator.astro +1 -1
  91. package/dist/astro-progress-display/BadgeDisplay.astro +1 -1
  92. package/dist/astro-progress-display/ProgressBar.astro +1 -1
  93. package/dist/astro-progress-display/StatsGrid.astro +1 -1
  94. package/dist/astro-radio/RadioGroup.astro +1 -1
  95. package/dist/astro-radio/RadioItem.astro +1 -1
  96. package/dist/astro-reaction-bar/ReactionBar.astro +1 -1
  97. package/dist/astro-resizable-layout/ResizableDivider.astro +1 -1
  98. package/dist/astro-resizable-layout/ResizableLayout.astro +1 -1
  99. package/dist/astro-resizable-layout/ResizablePane.astro +1 -1
  100. package/dist/astro-resizable-layout/index.ts +1 -1
  101. package/dist/astro-rich-editor/index.ts +2 -2
  102. package/dist/astro-search-bar/SearchBar.astro +1 -1
  103. package/dist/astro-search-bar/SearchResults.astro +1 -1
  104. package/dist/astro-select/Select.astro +1 -1
  105. package/dist/astro-select/SelectContent.astro +1 -1
  106. package/dist/astro-select/SelectItem.astro +1 -1
  107. package/dist/astro-select/SelectTrigger.astro +1 -1
  108. package/dist/astro-sidebar/Sidebar.astro +1 -1
  109. package/dist/astro-skeleton/Skeleton.astro +1 -1
  110. package/dist/astro-slide-viewer/SlideViewer.astro +1 -1
  111. package/dist/astro-status-indicator/StatusIndicator.astro +1 -1
  112. package/dist/astro-switch/Switch.astro +1 -1
  113. package/dist/astro-table-of-contents/TableOfContents.astro +1 -1
  114. package/dist/astro-tabs/Tabs.astro +1 -1
  115. package/dist/astro-tabs/TabsList.astro +1 -1
  116. package/dist/astro-tabs/TabsTrigger.astro +1 -1
  117. package/dist/astro-textarea/Textarea.astro +1 -1
  118. package/dist/astro-theme/ThemeScript.astro +1 -1
  119. package/dist/astro-thread-view/ThreadView.astro +1 -1
  120. package/dist/astro-toast/Toast.astro +1 -1
  121. package/dist/astro-tooltip/TooltipContent.astro +1 -1
  122. package/dist/astro-version-selector/VersionSelector.astro +1 -1
  123. package/dist/astro-video-player/VideoPlayer.astro +1 -1
  124. package/dist/auth/adapters/mock.ts +74 -0
  125. package/dist/auth/auth-machine.ts +120 -0
  126. package/dist/auth/index.ts +22 -0
  127. package/dist/auth/rbac.ts +44 -0
  128. package/dist/auth/types.ts +44 -0
  129. package/dist/avatar/avatar.styles.ts +47 -0
  130. package/dist/avatar/avatar.ts +73 -0
  131. package/dist/avatar/index.ts +15 -0
  132. package/dist/avatar-group/avatar-group.styles.ts +63 -0
  133. package/dist/avatar-group/avatar-group.ts +106 -0
  134. package/dist/avatar-group/index.ts +18 -0
  135. package/dist/badge/badge.styles.ts +24 -0
  136. package/dist/badge/badge.ts +48 -0
  137. package/dist/badge/index.ts +10 -0
  138. package/dist/bottom-nav/bottom-nav.styles.ts +18 -0
  139. package/dist/bottom-nav/bottom-nav.ts +33 -0
  140. package/dist/bottom-nav/index.ts +2 -0
  141. package/dist/breadcrumbs/breadcrumbs.styles.ts +20 -0
  142. package/dist/breadcrumbs/breadcrumbs.ts +72 -0
  143. package/dist/breadcrumbs/index.ts +8 -0
  144. package/dist/button/button.styles.ts +38 -0
  145. package/dist/button/button.ts +64 -0
  146. package/dist/button/index.ts +10 -0
  147. package/dist/calendar/calendar.styles.ts +21 -0
  148. package/dist/calendar/calendar.ts +202 -0
  149. package/dist/calendar/index.ts +9 -0
  150. package/dist/callout/callout.ts +1 -0
  151. package/dist/callout/index.ts +1 -0
  152. package/dist/card/card.styles.ts +55 -0
  153. package/dist/card/card.ts +45 -0
  154. package/dist/card/index.ts +20 -0
  155. package/dist/card-grid/card-grid.ts +9 -0
  156. package/dist/card-grid/index.ts +1 -0
  157. package/dist/carousel/index.ts +1 -0
  158. package/dist/charts/axis.ts +50 -0
  159. package/dist/charts/chart.ts +73 -0
  160. package/dist/charts/colorblind.ts +100 -0
  161. package/dist/charts/data.ts +72 -0
  162. package/dist/charts/geometry.ts +54 -0
  163. package/dist/charts/index.ts +61 -0
  164. package/dist/charts/scales.ts +151 -0
  165. package/dist/checkbox/checkbox.styles.ts +33 -0
  166. package/dist/checkbox/checkbox.ts +73 -0
  167. package/dist/checkbox/index.ts +10 -0
  168. package/dist/code-block/code-block.ts +1 -0
  169. package/dist/code-block/index.ts +1 -0
  170. package/dist/code-editor/code-editor.styles.ts +32 -0
  171. package/dist/code-editor/code-editor.ts +140 -0
  172. package/dist/code-editor/index.ts +9 -0
  173. package/dist/collapsible/collapsible.styles.ts +14 -0
  174. package/dist/collapsible/collapsible.ts +93 -0
  175. package/dist/collapsible/index.ts +7 -0
  176. package/dist/command/command.styles.ts +27 -0
  177. package/dist/command/command.ts +179 -0
  178. package/dist/command/index.ts +14 -0
  179. package/dist/command-input/command-input.ts +176 -0
  180. package/dist/command-input/index.ts +1 -0
  181. package/dist/content-protection/content-protection.styles.ts +9 -0
  182. package/dist/content-protection/content-protection.ts +68 -0
  183. package/dist/content-protection/index.ts +8 -0
  184. package/dist/data-table/data-table.styles.ts +55 -0
  185. package/dist/data-table/data-table.ts +183 -0
  186. package/dist/data-table/index.ts +15 -0
  187. package/dist/date-picker/date-picker.styles.ts +31 -0
  188. package/dist/date-picker/date-picker.ts +333 -0
  189. package/dist/date-picker/index.ts +18 -0
  190. package/dist/device-frame/device-frame.styles.ts +21 -0
  191. package/dist/device-frame/device-frame.ts +112 -0
  192. package/dist/device-frame/index.ts +10 -0
  193. package/dist/dialog/dialog.styles.ts +8 -0
  194. package/dist/dialog/dialog.ts +133 -0
  195. package/dist/dialog/index.ts +8 -0
  196. package/dist/diff-viewer/diff-viewer.styles.ts +124 -0
  197. package/dist/diff-viewer/diff-viewer.ts +255 -0
  198. package/dist/diff-viewer/index.ts +20 -0
  199. package/dist/dropdown-menu/dropdown-menu.styles.ts +9 -0
  200. package/dist/dropdown-menu/dropdown-menu.ts +139 -0
  201. package/dist/dropdown-menu/index.ts +9 -0
  202. package/dist/emoji-picker/emoji-data.ts +282 -0
  203. package/dist/emoji-picker/emoji-picker.styles.ts +32 -0
  204. package/dist/emoji-picker/emoji-picker.ts +165 -0
  205. package/dist/emoji-picker/index.ts +25 -0
  206. package/dist/feedback-dialog/feedback-dialog.styles.ts +15 -0
  207. package/dist/feedback-dialog/feedback-dialog.ts +147 -0
  208. package/dist/feedback-dialog/index.ts +11 -0
  209. package/dist/file-upload/file-upload.styles.ts +30 -0
  210. package/dist/file-upload/file-upload.ts +260 -0
  211. package/dist/file-upload/index.ts +19 -0
  212. package/dist/footer/footer.styles.ts +5 -0
  213. package/dist/footer/footer.ts +32 -0
  214. package/dist/footer/index.ts +9 -0
  215. package/dist/index.ts +1 -1
  216. package/dist/inline-editor/index.ts +13 -0
  217. package/dist/inline-editor/inline-editor.styles.ts +42 -0
  218. package/dist/inline-editor/inline-editor.ts +96 -0
  219. package/dist/input/index.ts +9 -0
  220. package/dist/input/input.styles.ts +15 -0
  221. package/dist/input/input.ts +84 -0
  222. package/dist/input-group/index.ts +13 -0
  223. package/dist/input-group/input-group.styles.ts +50 -0
  224. package/dist/input-group/input-group.ts +44 -0
  225. package/dist/install-prompt/index.ts +9 -0
  226. package/dist/install-prompt/install-prompt.styles.ts +5 -0
  227. package/dist/install-prompt/install-prompt.ts +68 -0
  228. package/dist/keyboard-shortcut/index.ts +12 -0
  229. package/dist/keyboard-shortcut/keyboard-shortcut.styles.ts +8 -0
  230. package/dist/keyboard-shortcut/keyboard-shortcut.ts +153 -0
  231. package/dist/language-selector/index.ts +8 -0
  232. package/dist/language-selector/language-selector.styles.ts +28 -0
  233. package/dist/language-selector/language-selector.ts +149 -0
  234. package/dist/link-card/index.ts +1 -0
  235. package/dist/link-card/link-card.ts +9 -0
  236. package/dist/markdown-renderer/index.ts +8 -0
  237. package/dist/markdown-renderer/markdown-renderer.styles.ts +31 -0
  238. package/dist/markdown-renderer/markdown-renderer.ts +251 -0
  239. package/dist/mobile-nav/index.ts +14 -0
  240. package/dist/mobile-nav/mobile-nav.styles.ts +39 -0
  241. package/dist/mobile-nav/mobile-nav.ts +74 -0
  242. package/dist/navbar/index.ts +9 -0
  243. package/dist/navbar/navbar.styles.ts +29 -0
  244. package/dist/navbar/navbar.ts +39 -0
  245. package/dist/otp-input/index.ts +13 -0
  246. package/dist/otp-input/otp-input.styles.ts +51 -0
  247. package/dist/otp-input/otp-input.ts +198 -0
  248. package/dist/pagination/index.ts +1 -0
  249. package/dist/payment/index.ts +1 -0
  250. package/dist/payment/payment.ts +16 -0
  251. package/dist/popover/index.ts +7 -0
  252. package/dist/popover/popover.styles.ts +16 -0
  253. package/dist/popover/popover.ts +89 -0
  254. package/dist/presence-indicator/index.ts +14 -0
  255. package/dist/presence-indicator/presence-indicator.styles.ts +29 -0
  256. package/dist/presence-indicator/presence-indicator.ts +63 -0
  257. package/dist/progress-display/index.ts +15 -0
  258. package/dist/progress-display/progress-display.styles.ts +72 -0
  259. package/dist/progress-display/progress-display.ts +60 -0
  260. package/dist/radio/index.ts +8 -0
  261. package/dist/radio/radio.styles.ts +34 -0
  262. package/dist/radio/radio.ts +70 -0
  263. package/dist/reaction-bar/index.ts +14 -0
  264. package/dist/reaction-bar/reaction-bar.styles.ts +23 -0
  265. package/dist/reaction-bar/reaction-bar.ts +87 -0
  266. package/dist/resizable-layout/index.ts +12 -0
  267. package/dist/resizable-layout/resizable-layout.styles.ts +50 -0
  268. package/dist/resizable-layout/resizable-layout.ts +139 -0
  269. package/dist/rich-editor/editor.ts +342 -0
  270. package/dist/rich-editor/emoji.ts +175 -0
  271. package/dist/rich-editor/history.ts +79 -0
  272. package/dist/rich-editor/index.ts +106 -0
  273. package/dist/rich-editor/markdown-shortcuts.ts +248 -0
  274. package/dist/rich-editor/mentions.ts +162 -0
  275. package/dist/rich-editor/model.ts +206 -0
  276. package/dist/rich-editor/operations.ts +772 -0
  277. package/dist/rich-editor/selection.ts +157 -0
  278. package/dist/rich-editor/serialization.ts +711 -0
  279. package/dist/rich-editor/slash-commands.ts +212 -0
  280. package/dist/search-bar/index.ts +7 -0
  281. package/dist/search-bar/search-bar.styles.ts +29 -0
  282. package/dist/search-bar/search-bar.ts +130 -0
  283. package/dist/select/index.ts +13 -0
  284. package/dist/select/select.styles.ts +52 -0
  285. package/dist/select/select.ts +152 -0
  286. package/dist/sidebar/index.ts +9 -0
  287. package/dist/sidebar/sidebar.styles.ts +27 -0
  288. package/dist/sidebar/sidebar.ts +59 -0
  289. package/dist/skeleton/index.ts +8 -0
  290. package/dist/skeleton/skeleton.styles.ts +16 -0
  291. package/dist/skeleton/skeleton.ts +39 -0
  292. package/dist/skip-to-content/index.ts +1 -0
  293. package/dist/skip-to-content/skip-to-content.ts +1 -0
  294. package/dist/slide-viewer/index.ts +16 -0
  295. package/dist/slide-viewer/slide-viewer.styles.ts +57 -0
  296. package/dist/slide-viewer/slide-viewer.ts +152 -0
  297. package/dist/slider/index.ts +1 -0
  298. package/dist/slider/slider.ts +2 -0
  299. package/dist/status-indicator/index.ts +15 -0
  300. package/dist/status-indicator/status-indicator.styles.ts +41 -0
  301. package/dist/status-indicator/status-indicator.ts +66 -0
  302. package/dist/steps/index.ts +1 -0
  303. package/dist/steps/steps.ts +1 -0
  304. package/dist/switch/index.ts +7 -0
  305. package/dist/switch/switch.styles.ts +55 -0
  306. package/dist/switch/switch.ts +63 -0
  307. package/dist/table-of-contents/index.ts +1 -0
  308. package/dist/table-of-contents/table-of-contents.ts +37 -0
  309. package/dist/tabs/index.ts +8 -0
  310. package/dist/tabs/tabs.styles.ts +9 -0
  311. package/dist/tabs/tabs.ts +133 -0
  312. package/dist/textarea/index.ts +7 -0
  313. package/dist/textarea/textarea.styles.ts +15 -0
  314. package/dist/textarea/textarea.ts +59 -0
  315. package/dist/theme/dom-adapters.ts +60 -0
  316. package/dist/theme/index.ts +18 -0
  317. package/dist/theme/theme-machine.ts +130 -0
  318. package/dist/theme/theme-script.ts +18 -0
  319. package/dist/thread-view/index.ts +26 -0
  320. package/dist/thread-view/thread-view.styles.ts +35 -0
  321. package/dist/thread-view/thread-view.ts +176 -0
  322. package/dist/toast/index.ts +13 -0
  323. package/dist/toast/toast.styles.ts +19 -0
  324. package/dist/toast/toast.ts +203 -0
  325. package/dist/tooltip/index.ts +7 -0
  326. package/dist/tooltip/tooltip.styles.ts +16 -0
  327. package/dist/tooltip/tooltip.ts +109 -0
  328. package/dist/version-selector/index.ts +12 -0
  329. package/dist/version-selector/version-selector.styles.ts +41 -0
  330. package/dist/version-selector/version-selector.ts +136 -0
  331. package/dist/video-player/index.ts +12 -0
  332. package/dist/video-player/video-player.styles.ts +42 -0
  333. package/dist/video-player/video-player.ts +100 -0
  334. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ export interface Point {
2
+ x: number
3
+ y: number
4
+ }
5
+
6
+ export function linePath(points: Point[]): string {
7
+ if (points.length === 0) return ''
8
+ let d = `M${points[0].x},${points[0].y}`
9
+ for (let i = 1; i < points.length; i++) {
10
+ d += `L${points[i].x},${points[i].y}`
11
+ }
12
+ return d
13
+ }
14
+
15
+ export function areaPath(points: Point[], baseline: number): string {
16
+ if (points.length === 0) return ''
17
+ // Forward path along points
18
+ let d = `M${points[0].x},${points[0].y}`
19
+ for (let i = 1; i < points.length; i++) {
20
+ d += `L${points[i].x},${points[i].y}`
21
+ }
22
+ // Drop down to baseline, go back to start, close
23
+ const last = points[points.length - 1]
24
+ const first = points[0]
25
+ d += `L${last.x},${baseline}`
26
+ d += `L${first.x},${baseline}`
27
+ d += 'Z'
28
+ return d
29
+ }
30
+
31
+ export function arcPath(
32
+ cx: number,
33
+ cy: number,
34
+ radius: number,
35
+ startAngle: number,
36
+ endAngle: number,
37
+ ): string {
38
+ const x1 = cx + radius * Math.cos(startAngle)
39
+ const y1 = cy + radius * Math.sin(startAngle)
40
+ const x2 = cx + radius * Math.cos(endAngle)
41
+ const y2 = cy + radius * Math.sin(endAngle)
42
+
43
+ const largeArcFlag = endAngle - startAngle > Math.PI ? 1 : 0
44
+
45
+ // Round to avoid floating point noise in path string
46
+ const r = (n: number) => Math.round(n * 1e6) / 1e6
47
+
48
+ let d = `M${r(x1)},${r(y1)}`
49
+ d += `A${radius},${radius} 0 ${largeArcFlag} 1 ${r(x2)},${r(y2)}`
50
+ d += `L${cx},${cy}`
51
+ d += 'Z'
52
+
53
+ return d
54
+ }
@@ -0,0 +1,61 @@
1
+ // Scales
2
+ export {
3
+ createLinearScale,
4
+ createBandScale,
5
+ createTimeScale,
6
+ } from './scales.js'
7
+
8
+ export type {
9
+ LinearScale,
10
+ BandScale,
11
+ TimeScale,
12
+ } from './scales.js'
13
+
14
+ // Data utilities
15
+ export {
16
+ computeExtent,
17
+ computeMean,
18
+ computeHistogramBins,
19
+ normalizeData,
20
+ } from './data.js'
21
+
22
+ export type { HistogramBin } from './data.js'
23
+
24
+ // Geometry
25
+ export {
26
+ linePath,
27
+ areaPath,
28
+ arcPath,
29
+ } from './geometry.js'
30
+
31
+ export type { Point } from './geometry.js'
32
+
33
+ // Chart
34
+ export {
35
+ createChart,
36
+ combineDimensions,
37
+ } from './chart.js'
38
+
39
+ export type {
40
+ ChartConfig,
41
+ ChartAPI,
42
+ Dimensions,
43
+ Margin,
44
+ } from './chart.js'
45
+
46
+ // Axis
47
+ export {
48
+ generateTicks,
49
+ formatTick,
50
+ } from './axis.js'
51
+
52
+ // Colorblind-safe palette & patterns
53
+ export {
54
+ COLORBLIND_SAFE_PALETTE,
55
+ hexToHSL,
56
+ getChartColor,
57
+ getPatternDef,
58
+ PATTERNS,
59
+ } from './colorblind.js'
60
+
61
+ export type { PatternType } from './colorblind.js'
@@ -0,0 +1,151 @@
1
+ // --- Linear Scale ---
2
+
3
+ export interface LinearScale {
4
+ (value: number): number
5
+ invert: (value: number) => number
6
+ ticks: (count?: number) => number[]
7
+ type: 'linear'
8
+ domain: [number, number]
9
+ range: [number, number]
10
+ }
11
+
12
+ export function createLinearScale(
13
+ domain: [number, number],
14
+ range: [number, number],
15
+ ): LinearScale {
16
+ const [d0, d1] = domain
17
+ const [r0, r1] = range
18
+ const domainSpan = d1 - d0
19
+ const rangeSpan = r1 - r0
20
+
21
+ const scale = ((value: number): number => {
22
+ if (domainSpan === 0) return r0
23
+ return r0 + ((value - d0) / domainSpan) * rangeSpan
24
+ }) as LinearScale
25
+
26
+ scale.invert = (value: number): number => {
27
+ if (rangeSpan === 0) return d0
28
+ return d0 + ((value - r0) / rangeSpan) * domainSpan
29
+ }
30
+
31
+ scale.ticks = (count = 10): number[] => {
32
+ if (count <= 0) return []
33
+ const ticks: number[] = []
34
+ for (let i = 0; i < count; i++) {
35
+ ticks.push(d0 + (domainSpan * i) / (count - 1 || 1))
36
+ }
37
+ return ticks
38
+ }
39
+
40
+ scale.type = 'linear'
41
+ scale.domain = domain
42
+ scale.range = range
43
+
44
+ return scale
45
+ }
46
+
47
+ // --- Band Scale ---
48
+
49
+ export interface BandScale {
50
+ (value: string): number
51
+ bandwidth: () => number
52
+ type: 'band'
53
+ domain: string[]
54
+ range: [number, number]
55
+ }
56
+
57
+ export function createBandScale(
58
+ domain: string[],
59
+ range: [number, number],
60
+ padding = 0,
61
+ ): BandScale {
62
+ const [r0, r1] = range
63
+ const rangeSpan = r1 - r0
64
+ const n = domain.length
65
+
66
+ // With padding: each step = bandwidth + paddingInner
67
+ // total = n * step - paddingInner (no padding after last band)
68
+ // paddingInner = step * padding
69
+ // step * n - step * padding = rangeSpan => step * (n - padding) = rangeSpan
70
+ let step = 0
71
+ let bw = 0
72
+
73
+ if (n > 0) {
74
+ if (n === 1) {
75
+ bw = rangeSpan
76
+ step = rangeSpan
77
+ } else {
78
+ step = n > 0 ? rangeSpan / (n - padding) : 0
79
+ bw = step * (1 - padding)
80
+ }
81
+ }
82
+
83
+ const indexMap = new Map<string, number>()
84
+ domain.forEach((d, i) => indexMap.set(d, i))
85
+
86
+ const scale = ((value: string): number => {
87
+ const idx = indexMap.get(value)
88
+ if (idx === undefined) return 0
89
+ return r0 + idx * step
90
+ }) as BandScale
91
+
92
+ scale.bandwidth = (): number => {
93
+ return Math.max(0, bw)
94
+ }
95
+
96
+ scale.type = 'band'
97
+ scale.domain = domain
98
+ scale.range = range
99
+
100
+ return scale
101
+ }
102
+
103
+ // --- Time Scale ---
104
+
105
+ export interface TimeScale {
106
+ (value: Date): number
107
+ invert: (value: number) => Date
108
+ ticks: (count?: number) => Date[]
109
+ type: 'time'
110
+ domain: [Date, Date]
111
+ range: [number, number]
112
+ }
113
+
114
+ export function createTimeScale(
115
+ domain: [Date, Date],
116
+ range: [number, number],
117
+ ): TimeScale {
118
+ const [d0, d1] = domain
119
+ const [r0, r1] = range
120
+ const t0 = d0.getTime()
121
+ const t1 = d1.getTime()
122
+ const domainSpan = t1 - t0
123
+ const rangeSpan = r1 - r0
124
+
125
+ const scale = ((value: Date): number => {
126
+ if (domainSpan === 0) return r0
127
+ return r0 + ((value.getTime() - t0) / domainSpan) * rangeSpan
128
+ }) as TimeScale
129
+
130
+ scale.invert = (value: number): Date => {
131
+ if (rangeSpan === 0) return new Date(t0)
132
+ const t = t0 + ((value - r0) / rangeSpan) * domainSpan
133
+ return new Date(t)
134
+ }
135
+
136
+ scale.ticks = (count = 10): Date[] => {
137
+ if (count <= 0) return []
138
+ const ticks: Date[] = []
139
+ for (let i = 0; i < count; i++) {
140
+ const t = t0 + (domainSpan * i) / (count - 1 || 1)
141
+ ticks.push(new Date(t))
142
+ }
143
+ return ticks
144
+ }
145
+
146
+ scale.type = 'time'
147
+ scale.domain = domain
148
+ scale.range = range
149
+
150
+ return scale
151
+ }
@@ -0,0 +1,33 @@
1
+ import { cva } from '../shared/index.ts'
2
+ import type { TokenContract } from '../shared/index.ts'
3
+
4
+ export const checkboxTokens: TokenContract = {
5
+ name: 'checkbox',
6
+ tokens: {
7
+ bg: { variable: '--rfr-checkbox-bg', fallback: 'hsl(var(--background))' },
8
+ 'bg-checked': { variable: '--rfr-checkbox-bg-checked', fallback: 'hsl(var(--primary))' },
9
+ fg: { variable: '--rfr-checkbox-fg', fallback: 'hsl(var(--primary-foreground))' },
10
+ border: { variable: '--rfr-checkbox-border', fallback: 'hsl(var(--primary))' },
11
+ ring: { variable: '--rfr-checkbox-ring', fallback: 'hsl(var(--ring))' },
12
+ },
13
+ }
14
+
15
+ export const checkboxVariants = cva({
16
+ base: 'peer shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
17
+ variants: {
18
+ checked: {
19
+ true: 'bg-primary text-primary-foreground',
20
+ false: 'bg-background',
21
+ indeterminate: 'bg-primary text-primary-foreground',
22
+ },
23
+ size: {
24
+ sm: 'h-3.5 w-3.5',
25
+ default: 'h-4 w-4',
26
+ lg: 'h-5 w-5',
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ checked: 'false',
31
+ size: 'default',
32
+ },
33
+ })
@@ -0,0 +1,73 @@
1
+ import type { AccessibilityProps, KeyboardHandlerMap } from '../shared/index.ts'
2
+ import { Keys } from '../shared/index.ts'
3
+
4
+ export type CheckedState = boolean | 'indeterminate'
5
+
6
+ export interface CheckboxProps {
7
+ checked?: CheckedState
8
+ disabled?: boolean
9
+ required?: boolean
10
+ name?: string
11
+ value?: string
12
+ }
13
+
14
+ export interface CheckboxAPI {
15
+ /** ARIA attributes to spread on the element */
16
+ ariaProps: Partial<AccessibilityProps>
17
+ /** Keyboard handlers to attach */
18
+ keyboardHandlers: KeyboardHandlerMap
19
+ /** Whether interaction should be blocked */
20
+ isInteractive: boolean
21
+ /** Data attributes for CSS styling hooks */
22
+ dataAttributes: Record<string, string>
23
+ /** Current state */
24
+ state: {
25
+ checked: CheckedState
26
+ disabled: boolean
27
+ }
28
+ }
29
+
30
+ export function createCheckbox(props: CheckboxProps = {}): CheckboxAPI {
31
+ const { checked = false, disabled = false } = props
32
+ const isInteractive = !disabled
33
+
34
+ const ariaProps: Partial<AccessibilityProps> = {
35
+ role: 'checkbox',
36
+ 'aria-checked': checked === 'indeterminate' ? 'mixed' : checked,
37
+ }
38
+
39
+ if (disabled) {
40
+ ariaProps['aria-disabled'] = true
41
+ }
42
+
43
+ const dataAttributes: Record<string, string> = {}
44
+ if (checked === 'indeterminate') {
45
+ dataAttributes['data-state'] = 'indeterminate'
46
+ } else if (checked) {
47
+ dataAttributes['data-state'] = 'checked'
48
+ } else {
49
+ dataAttributes['data-state'] = 'unchecked'
50
+ }
51
+ if (disabled) {
52
+ dataAttributes['data-disabled'] = ''
53
+ }
54
+
55
+ const keyboardHandlers: KeyboardHandlerMap = {}
56
+ if (!isInteractive) {
57
+ keyboardHandlers[Keys.Space] = (e) => e.preventDefault()
58
+ }
59
+
60
+ return {
61
+ ariaProps,
62
+ keyboardHandlers,
63
+ isInteractive,
64
+ dataAttributes,
65
+ state: { checked, disabled },
66
+ }
67
+ }
68
+
69
+ /** SVG path data for the check icon */
70
+ export const checkIconPath = 'M20 6L9 17l-5-5'
71
+
72
+ /** SVG path data for the indeterminate/minus icon */
73
+ export const indeterminateIconPath = 'M5 12h14'
@@ -0,0 +1,10 @@
1
+ export {
2
+ createCheckbox,
3
+ checkIconPath,
4
+ indeterminateIconPath,
5
+ type CheckboxProps,
6
+ type CheckboxAPI,
7
+ type CheckedState,
8
+ } from './checkbox.js'
9
+
10
+ export { checkboxVariants, checkboxTokens } from './checkbox.styles.js'
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './code-block';
@@ -0,0 +1,32 @@
1
+ import { cva } from '../shared/index.ts'
2
+ import type { TokenContract } from '../shared/index.ts'
3
+
4
+ export const codeEditorTokens: TokenContract = {
5
+ name: 'code-editor',
6
+ tokens: {
7
+ bg: { variable: '--rfr-code-editor-bg', fallback: 'hsl(var(--background))' },
8
+ fg: { variable: '--rfr-code-editor-fg', fallback: 'hsl(var(--foreground))' },
9
+ headerBg: { variable: '--rfr-code-editor-header-bg', fallback: 'hsl(var(--muted))' },
10
+ border: { variable: '--rfr-code-editor-border', fallback: 'hsl(var(--border))' },
11
+ lineNumberFg: { variable: '--rfr-code-editor-line-number', fallback: 'hsl(var(--muted-foreground))' },
12
+ },
13
+ }
14
+
15
+ export const codeEditorVariants = cva({
16
+ base: 'flex flex-col rounded-lg border overflow-hidden font-mono text-sm',
17
+ variants: {
18
+ theme: {
19
+ light: 'bg-white text-gray-900 border-gray-200',
20
+ dark: 'bg-gray-900 text-gray-100 border-gray-700',
21
+ },
22
+ size: {
23
+ sm: 'text-xs',
24
+ default: 'text-sm',
25
+ lg: 'text-base',
26
+ },
27
+ },
28
+ defaultVariants: {
29
+ theme: 'light',
30
+ size: 'default',
31
+ },
32
+ })
@@ -0,0 +1,140 @@
1
+ import type { AccessibilityProps } from '../shared/index.ts'
2
+
3
+ export type CodeEditorTheme = 'light' | 'dark'
4
+
5
+ export interface CodeEditorProps {
6
+ value?: string
7
+ onChange?: (value: string) => void
8
+ language?: string
9
+ readOnly?: boolean
10
+ theme?: CodeEditorTheme
11
+ }
12
+
13
+ export interface CodeEditorState {
14
+ value: string
15
+ language: string
16
+ theme: CodeEditorTheme
17
+ }
18
+
19
+ export interface CodeEditorAPI {
20
+ /** Current editor state */
21
+ state: CodeEditorState
22
+ /** ARIA attributes for the editor element */
23
+ ariaProps: Partial<AccessibilityProps> & { 'aria-multiline'?: boolean }
24
+ /** Data attributes for CSS styling hooks */
25
+ dataAttributes: Record<string, string>
26
+ /** Update the editor value */
27
+ setValue: (value: string) => void
28
+ /** Get a human-readable label for the current language */
29
+ getLanguageLabel: () => string
30
+ }
31
+
32
+ /** Map of language identifiers to human-readable labels */
33
+ const languageLabels: Record<string, string> = {
34
+ js: 'JavaScript',
35
+ javascript: 'JavaScript',
36
+ ts: 'TypeScript',
37
+ typescript: 'TypeScript',
38
+ jsx: 'JSX',
39
+ tsx: 'TSX',
40
+ py: 'Python',
41
+ python: 'Python',
42
+ rb: 'Ruby',
43
+ ruby: 'Ruby',
44
+ go: 'Go',
45
+ rust: 'Rust',
46
+ rs: 'Rust',
47
+ java: 'Java',
48
+ cpp: 'C++',
49
+ c: 'C',
50
+ cs: 'C#',
51
+ csharp: 'C#',
52
+ html: 'HTML',
53
+ css: 'CSS',
54
+ json: 'JSON',
55
+ yaml: 'YAML',
56
+ yml: 'YAML',
57
+ md: 'Markdown',
58
+ markdown: 'Markdown',
59
+ sql: 'SQL',
60
+ sh: 'Shell',
61
+ bash: 'Bash',
62
+ zsh: 'Zsh',
63
+ xml: 'XML',
64
+ toml: 'TOML',
65
+ swift: 'Swift',
66
+ kotlin: 'Kotlin',
67
+ dart: 'Dart',
68
+ php: 'PHP',
69
+ lua: 'Lua',
70
+ r: 'R',
71
+ scala: 'Scala',
72
+ }
73
+
74
+ /**
75
+ * Create a headless code editor API.
76
+ *
77
+ * This provides the headless interface for a code editor — state management,
78
+ * ARIA props, and data attributes. Actual rendering (Monaco, CodeMirror, or
79
+ * a simple textarea) is handled by framework-specific wrappers.
80
+ */
81
+ export function createCodeEditor(props: CodeEditorProps = {}): CodeEditorAPI {
82
+ const {
83
+ value = '',
84
+ onChange,
85
+ language = 'plaintext',
86
+ readOnly = false,
87
+ theme = 'light',
88
+ } = props
89
+
90
+ let currentValue = value
91
+
92
+ const state: CodeEditorState = {
93
+ value: currentValue,
94
+ language,
95
+ theme,
96
+ }
97
+
98
+ const ariaProps: Partial<AccessibilityProps> & { 'aria-multiline'?: boolean; 'aria-readonly'?: boolean } = {
99
+ role: 'textbox',
100
+ 'aria-multiline': true,
101
+ 'aria-label': `Code editor - ${getLabel(language)}`,
102
+ }
103
+
104
+ if (readOnly) {
105
+ ariaProps['aria-readonly'] = true
106
+ }
107
+
108
+ const dataAttributes: Record<string, string> = {
109
+ 'data-language': language,
110
+ 'data-theme': theme,
111
+ }
112
+
113
+ if (readOnly) {
114
+ dataAttributes['data-readonly'] = ''
115
+ }
116
+
117
+ function setValue(newValue: string) {
118
+ currentValue = newValue
119
+ state.value = newValue
120
+ if (onChange) {
121
+ onChange(newValue)
122
+ }
123
+ }
124
+
125
+ function getLabel(lang: string): string {
126
+ return languageLabels[lang.toLowerCase()] ?? lang.charAt(0).toUpperCase() + lang.slice(1)
127
+ }
128
+
129
+ function getLanguageLabel(): string {
130
+ return getLabel(language)
131
+ }
132
+
133
+ return {
134
+ state,
135
+ ariaProps,
136
+ dataAttributes,
137
+ setValue,
138
+ getLanguageLabel,
139
+ }
140
+ }
@@ -0,0 +1,9 @@
1
+ export {
2
+ createCodeEditor,
3
+ type CodeEditorProps,
4
+ type CodeEditorAPI,
5
+ type CodeEditorState,
6
+ type CodeEditorTheme,
7
+ } from './code-editor.js'
8
+
9
+ export { codeEditorVariants, codeEditorTokens } from './code-editor.styles.js'
@@ -0,0 +1,14 @@
1
+ import { cva } from '../shared/index.ts'
2
+
3
+ export const collapsibleContentVariants = cva({
4
+ base: 'overflow-hidden transition-all',
5
+ variants: {
6
+ state: {
7
+ open: 'animate-accordion-down',
8
+ closed: 'animate-accordion-up',
9
+ },
10
+ },
11
+ defaultVariants: {
12
+ state: 'closed',
13
+ },
14
+ })
@@ -0,0 +1,93 @@
1
+ import { generateId, Keys, createKeyboardHandler } from '../shared/index.ts'
2
+
3
+ export interface CollapsibleProps {
4
+ open?: boolean
5
+ defaultOpen?: boolean
6
+ onOpenChange?: (open: boolean) => void
7
+ disabled?: boolean
8
+ }
9
+
10
+ export interface CollapsibleAPI {
11
+ /** Current open state */
12
+ state: { open: boolean }
13
+ /** Props to spread on the trigger element */
14
+ triggerProps: {
15
+ 'aria-expanded': boolean
16
+ 'aria-controls': string
17
+ 'data-state': 'open' | 'closed'
18
+ 'data-disabled': string | undefined
19
+ }
20
+ /** Props to spread on the content element */
21
+ contentProps: {
22
+ id: string
23
+ role: 'region'
24
+ 'data-state': 'open' | 'closed'
25
+ hidden: boolean
26
+ }
27
+ /** Toggle the open state */
28
+ toggle: () => void
29
+ /** Open the collapsible */
30
+ open: () => void
31
+ /** Close the collapsible */
32
+ close: () => void
33
+ /** Keyboard event handler for Enter/Space toggle */
34
+ keyboardHandler: (event: KeyboardEvent) => void
35
+ }
36
+
37
+ export function createCollapsible(props: CollapsibleProps = {}): CollapsibleAPI {
38
+ const {
39
+ open: controlledOpen,
40
+ defaultOpen = false,
41
+ onOpenChange,
42
+ disabled = false,
43
+ } = props
44
+
45
+ const isControlled = controlledOpen !== undefined
46
+ let internalOpen = isControlled ? controlledOpen : defaultOpen
47
+ const contentId = generateId('rfr-collapsible')
48
+
49
+ const setOpen = (next: boolean) => {
50
+ if (disabled) return
51
+ if (!isControlled) {
52
+ internalOpen = next
53
+ }
54
+ onOpenChange?.(next)
55
+ }
56
+
57
+ const toggle = () => setOpen(!internalOpen)
58
+ const openFn = () => setOpen(true)
59
+ const closeFn = () => setOpen(false)
60
+
61
+ const keyboardHandler = createKeyboardHandler({
62
+ [Keys.Enter]: (event: KeyboardEvent) => {
63
+ event.preventDefault()
64
+ toggle()
65
+ },
66
+ [Keys.Space]: (event: KeyboardEvent) => {
67
+ event.preventDefault()
68
+ toggle()
69
+ },
70
+ })
71
+
72
+ const dataState = internalOpen ? 'open' : 'closed'
73
+
74
+ return {
75
+ state: { open: internalOpen },
76
+ triggerProps: {
77
+ 'aria-expanded': internalOpen,
78
+ 'aria-controls': contentId,
79
+ 'data-state': dataState,
80
+ 'data-disabled': disabled ? '' : undefined,
81
+ },
82
+ contentProps: {
83
+ id: contentId,
84
+ role: 'region',
85
+ 'data-state': dataState,
86
+ hidden: !internalOpen,
87
+ },
88
+ toggle,
89
+ open: openFn,
90
+ close: closeFn,
91
+ keyboardHandler,
92
+ }
93
+ }
@@ -0,0 +1,7 @@
1
+ export {
2
+ createCollapsible,
3
+ type CollapsibleProps,
4
+ type CollapsibleAPI,
5
+ } from './collapsible.js'
6
+
7
+ export { collapsibleContentVariants } from './collapsible.styles.js'