rift-ds 1.13.0 → 1.15.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 (382) hide show
  1. package/README.md +14 -6
  2. package/behaviors/LinkProvider.d.ts +3 -0
  3. package/behaviors/LocaleProvider.d.ts +27 -0
  4. package/behaviors/LocaleProvider.js +16 -0
  5. package/behaviors/ScrollRegion.d.ts +8 -0
  6. package/behaviors/ScrollRegion.js +51 -0
  7. package/behaviors/devWarning.d.ts +9 -0
  8. package/behaviors/devWarning.js +16 -0
  9. package/behaviors/direction.css +19 -0
  10. package/behaviors/direction.d.ts +40 -0
  11. package/behaviors/direction.js +56 -0
  12. package/behaviors/focusable.d.ts +2 -1
  13. package/behaviors/locale.d.ts +47 -0
  14. package/behaviors/locale.js +87 -0
  15. package/behaviors/shortcut-keys.d.ts +49 -0
  16. package/behaviors/shortcut-keys.js +129 -0
  17. package/behaviors/shortcuts.d.ts +75 -0
  18. package/behaviors/shortcuts.js +160 -0
  19. package/behaviors/useAnchoredPosition.d.ts +124 -0
  20. package/behaviors/useAnchoredPosition.js +158 -0
  21. package/behaviors/useFocusScope.d.ts +15 -2
  22. package/behaviors/useFocusScope.js +7 -1
  23. package/behaviors/useLayer.d.ts +9 -0
  24. package/behaviors/useLayer.js +4 -0
  25. package/behaviors/useScrollLock.d.ts +4 -0
  26. package/bin/rift-ds.mjs +184 -25
  27. package/bin/templates/app/components/rift/ColorModeScript.tsx +10 -0
  28. package/bin/templates/app/components/rift/RiftRoot.tsx +13 -0
  29. package/bin/templates/app/components/rift/font.css +7 -0
  30. package/bin/templates/app/components/rift/font.ts +14 -0
  31. package/bin/templates/blocks/app/dashboard/page.module.css +90 -0
  32. package/bin/templates/blocks/app/dashboard/page.tsx +141 -0
  33. package/bin/templates/blocks/app/sign-in/page.module.css +91 -0
  34. package/bin/templates/blocks/app/sign-in/page.tsx +95 -0
  35. package/bin/templates/blocks/app/starter/page.module.css +7 -0
  36. package/bin/templates/blocks/app/starter/page.tsx +31 -0
  37. package/bin/templates/blocks/components/blocks/AppShell.module.css +160 -0
  38. package/bin/templates/blocks/components/blocks/AppShell.tsx +113 -0
  39. package/bin/templates/blocks/registry.json +39 -0
  40. package/chat/AssistantTurn.js +4 -2
  41. package/chat/ChatWidget.css +24 -24
  42. package/chat/ChatWidget.js +4 -2
  43. package/chat/suggestions.d.ts +12 -0
  44. package/chat/types.d.ts +8 -7
  45. package/chat/useChat.js +2 -2
  46. package/components/Accordion/Accordion.css +1 -1
  47. package/components/AgentPlan/AgentPlan.css +2 -2
  48. package/components/AgentRail/AgentRail.css +4 -4
  49. package/components/AgentRail/AgentRail.js +1 -1
  50. package/components/AgentStatus/AgentRing.d.ts +27 -0
  51. package/components/AgentStatus/AgentRing.js +9 -0
  52. package/components/AgentStatus/AgentStatus.css +638 -10
  53. package/components/AgentStatus/AgentStatus.d.ts +31 -3
  54. package/components/AgentStatus/AgentStatus.js +22 -4
  55. package/components/AgentStatus/AgentStatusPatterns.d.ts +1 -1
  56. package/components/AgentStatus/AgentStatusPatterns.js +2 -1
  57. package/components/AiButton/AiButton.css +214 -41
  58. package/components/AiButton/AiButton.d.ts +34 -0
  59. package/components/AiButton/AiButton.js +130 -9
  60. package/components/AlertDialog/AlertDialog.css +1 -1
  61. package/components/AnchorNav/AnchorNav.css +6 -6
  62. package/components/AnchorNav/AnchorNav.js +4 -2
  63. package/components/AnimatedNumber/AnimatedNumber.d.ts +6 -0
  64. package/components/AnimatedNumber/AnimatedNumber.js +12 -5
  65. package/components/AppLayout/AppLayout.css +3 -3
  66. package/components/AppSidebar/AppSidebar.css +20 -20
  67. package/components/AppSidebar/AppSidebar.js +6 -4
  68. package/components/ArtifactCard/ArtifactCard.css +1 -1
  69. package/components/ArtifactCard/ArtifactCard.js +2 -1
  70. package/components/ArtifactPanel/ArtifactPanel.js +2 -1
  71. package/components/Attachment/Attachment.css +4 -4
  72. package/components/Attachment/AttachmentDropZone.js +2 -1
  73. package/components/Attachment/AttachmentGroup.d.ts +2 -0
  74. package/components/Attachment/AttachmentGroup.js +4 -1
  75. package/components/Attachment/AttachmentViewer.d.ts +2 -0
  76. package/components/Attachment/AttachmentViewer.js +8 -13
  77. package/components/Attachment/fileTypes.d.ts +5 -3
  78. package/components/Attachment/fileTypes.js +8 -3
  79. package/components/Avatar/Avatar.css +55 -1
  80. package/components/Avatar/Avatar.d.ts +9 -1
  81. package/components/Avatar/Avatar.js +5 -1
  82. package/components/Avatar/avatarFill.d.ts +9 -0
  83. package/components/Avatar/avatarFill.js +13 -0
  84. package/components/AvatarGroup/AvatarGroup.css +1 -1
  85. package/components/AvatarGroup/AvatarGroup.js +13 -1
  86. package/components/BentoTile/BentoTile.css +15 -3
  87. package/components/BottomNav/BottomNav.css +8 -8
  88. package/components/BottomNav/BottomNav.js +3 -1
  89. package/components/Breadcrumb/Breadcrumb.js +2 -2
  90. package/components/Button/Button.css +8 -1
  91. package/components/Button/Button.d.ts +8 -1
  92. package/components/Button/Button.js +14 -3
  93. package/components/Card/Card.css +3 -3
  94. package/components/CardStack/CardStack.js +4 -2
  95. package/components/Carousel/Carousel.css +5 -2
  96. package/components/Carousel/Carousel.js +11 -7
  97. package/components/Chart/AreaChart.d.ts +2 -0
  98. package/components/Chart/AreaChart.js +15 -6
  99. package/components/Chart/BarChart.d.ts +2 -0
  100. package/components/Chart/BarChart.js +15 -5
  101. package/components/Chart/Chart.css +6 -6
  102. package/components/Chart/ComboChart.d.ts +2 -0
  103. package/components/Chart/ComboChart.js +16 -6
  104. package/components/Chart/LineChart.d.ts +2 -0
  105. package/components/Chart/LineChart.js +15 -6
  106. package/components/Chart/PieChart.d.ts +2 -0
  107. package/components/Chart/PieChart.js +9 -5
  108. package/components/Chart/RadarChart.d.ts +2 -0
  109. package/components/Chart/RadarChart.js +15 -6
  110. package/components/Chart/RadialChart.d.ts +2 -0
  111. package/components/Chart/RadialChart.js +9 -5
  112. package/components/Chart/ScatterChart.d.ts +2 -0
  113. package/components/Chart/ScatterChart.js +17 -7
  114. package/components/Chart/StackedBarChart.d.ts +2 -0
  115. package/components/Chart/StackedBarChart.js +15 -7
  116. package/components/Chart/Treemap.d.ts +2 -0
  117. package/components/Chart/Treemap.js +9 -5
  118. package/components/ChatMarker/ChatMarker.js +2 -1
  119. package/components/ChatMessage/ChatMessage.css +2 -2
  120. package/components/ChatThread/ChatThread.css +1 -1
  121. package/components/Checkbox/Checkbox.js +1 -1
  122. package/components/CircularButton/CircularButton.css +8 -7
  123. package/components/CircularButton/CircularButton.d.ts +2 -2
  124. package/components/CircularButton/CircularButton.js +2 -1
  125. package/components/CodeBlock/CodeBlock.d.ts +2 -0
  126. package/components/CodeBlock/CodeBlock.js +2 -0
  127. package/components/CodeDiff/CodeDiff.css +2 -2
  128. package/components/ColorPicker/ColorPicker.css +8 -8
  129. package/components/ColorPicker/ColorPicker.js +11 -0
  130. package/components/ColourSwatch/ColourSwatch.css +1 -1
  131. package/components/Combobox/Combobox.css +20 -5
  132. package/components/Combobox/Combobox.js +75 -55
  133. package/components/CommandPalette/CommandPalette.d.ts +13 -1
  134. package/components/CommandPalette/CommandPalette.js +12 -13
  135. package/components/CommandPaletteTrigger/CommandPaletteTrigger.css +88 -0
  136. package/components/CommandPaletteTrigger/CommandPaletteTrigger.d.ts +41 -0
  137. package/components/CommandPaletteTrigger/CommandPaletteTrigger.js +58 -0
  138. package/components/Composer/Composer.css +7 -7
  139. package/components/Composer/Composer.d.ts +2 -0
  140. package/components/Composer/Composer.js +6 -2
  141. package/components/ContactCard/ContactCard.css +1 -1
  142. package/components/ContactCard/ContactCard.js +4 -3
  143. package/components/ContextMenu/ContextMenu.css +10 -7
  144. package/components/ContextMenu/ContextMenu.d.ts +3 -0
  145. package/components/ContextMenu/ContextMenu.js +15 -9
  146. package/components/ContributionGraph/ContributionGraph.css +2 -2
  147. package/components/ContributionGraph/ContributionGraph.d.ts +7 -1
  148. package/components/ContributionGraph/ContributionGraph.js +6 -4
  149. package/components/DataTable/CellEditor.d.ts +37 -0
  150. package/components/DataTable/CellEditor.js +153 -0
  151. package/components/DataTable/DataTable.css +1181 -1
  152. package/components/DataTable/DataTable.d.ts +506 -29
  153. package/components/DataTable/DataTable.js +2374 -190
  154. package/components/DataTable/FilterEditor.d.ts +10 -0
  155. package/components/DataTable/FilterEditor.js +181 -0
  156. package/components/DataTable/TypedCell.d.ts +22 -0
  157. package/components/DataTable/TypedCell.js +80 -0
  158. package/components/DataTable/VirtualRows.d.ts +21 -0
  159. package/components/DataTable/VirtualRows.js +38 -0
  160. package/components/DataTable/aggregates.d.ts +29 -0
  161. package/components/DataTable/aggregates.js +52 -0
  162. package/components/DataTable/columnTypes.d.ts +49 -0
  163. package/components/DataTable/columnTypes.js +96 -0
  164. package/components/DataTable/dragGesture.d.ts +24 -0
  165. package/components/DataTable/dragGesture.js +62 -0
  166. package/components/DataTable/editorKinds.d.ts +24 -0
  167. package/components/DataTable/editorKinds.js +20 -0
  168. package/components/DataTable/filterModel.d.ts +84 -0
  169. package/components/DataTable/filterModel.js +159 -0
  170. package/components/DataTable/tableContext.d.ts +82 -0
  171. package/components/DataTable/tableContext.js +7 -0
  172. package/components/DataTable/views.d.ts +50 -0
  173. package/components/DataTable/views.js +39 -0
  174. package/components/DateInput/DateInput.css +10 -4
  175. package/components/DatePicker/DatePicker.d.ts +23 -7
  176. package/components/DatePicker/DatePicker.js +41 -34
  177. package/components/Dialog/Dialog.css +1 -1
  178. package/components/DocumentChip/DocumentChip.css +1 -1
  179. package/components/DocumentChip/DocumentChip.js +2 -1
  180. package/components/Drawer/Drawer.css +46 -12
  181. package/components/Drawer/Drawer.d.ts +6 -2
  182. package/components/Drawer/Drawer.js +3 -1
  183. package/components/Dropdown/ChosenMark.css +1 -1
  184. package/components/Dropdown/Dropdown.css +23 -7
  185. package/components/Dropdown/Dropdown.d.ts +6 -0
  186. package/components/Dropdown/Dropdown.js +41 -10
  187. package/components/DropdownMenu/DropdownMenu.css +38 -17
  188. package/components/DropdownMenu/DropdownMenu.d.ts +10 -1
  189. package/components/DropdownMenu/DropdownMenu.js +80 -23
  190. package/components/DropdownMenu/ShortcutHint.d.ts +12 -0
  191. package/components/DropdownMenu/ShortcutHint.js +17 -0
  192. package/components/EmptyState/EmptyState.js +2 -1
  193. package/components/EntityCard/EntityCard.js +2 -1
  194. package/components/EventCalendar/EventCalendar.css +1 -1
  195. package/components/EventCalendar/EventCalendar.d.ts +21 -6
  196. package/components/EventCalendar/EventCalendar.js +33 -31
  197. package/components/FileInput/FileInput.d.ts +2 -0
  198. package/components/FileInput/FileInput.js +4 -1
  199. package/components/FilterBar/FilterBar.css +10 -6
  200. package/components/FilterBar/FilterBar.js +69 -44
  201. package/components/FunnelChart/FunnelChart.d.ts +2 -0
  202. package/components/FunnelChart/FunnelChart.js +11 -7
  203. package/components/GanttChart/GanttChart.css +1 -0
  204. package/components/GanttChart/GanttChart.js +2 -1
  205. package/components/Gauge/Gauge.css +1 -1
  206. package/components/Gauge/Gauge.d.ts +2 -0
  207. package/components/Gauge/Gauge.js +3 -1
  208. package/components/Globe/Globe.css +1 -0
  209. package/components/HoverCard/HoverCard.css +25 -44
  210. package/components/HoverCard/HoverCard.d.ts +2 -2
  211. package/components/HoverCard/HoverCard.js +18 -2
  212. package/components/ImageCompare/ImageCompare.css +1 -0
  213. package/components/Input/Input.css +14 -8
  214. package/components/Input/Input.js +3 -2
  215. package/components/Inspector/Inspector.css +12 -11
  216. package/components/Inspector/InspectorSlider.d.ts +2 -0
  217. package/components/Inspector/InspectorSlider.js +8 -1
  218. package/components/Instructions/Instructions.css +1 -1
  219. package/components/Instructions/Instructions.js +2 -1
  220. package/components/InterruptCard/InterruptCard.css +9 -1
  221. package/components/InterruptCard/InterruptCard.d.ts +2 -0
  222. package/components/InterruptCard/InterruptCard.js +9 -2
  223. package/components/Kbd/Kbd.css +21 -0
  224. package/components/Kbd/Kbd.d.ts +14 -4
  225. package/components/Kbd/Kbd.js +10 -1
  226. package/components/LegendTile/LegendTile.d.ts +6 -1
  227. package/components/LegendTile/LegendTile.js +3 -2
  228. package/components/Lightbox/Lightbox.css +3 -3
  229. package/components/Lightbox/Lightbox.js +6 -14
  230. package/components/LinkList/LinkList.js +3 -2
  231. package/components/MapCallout/MapCallout.css +1 -0
  232. package/components/Mention/Mention.js +2 -1
  233. package/components/MessageActions/MessageActions.js +2 -1
  234. package/components/MessageCard/MessageCard.css +1 -1
  235. package/components/MessageCard/MessageCard.js +2 -1
  236. package/components/Meter/Meter.css +1 -1
  237. package/components/Meter/Meter.d.ts +2 -0
  238. package/components/Meter/Meter.js +3 -1
  239. package/components/ModelPicker/ModelPicker.css +14 -11
  240. package/components/ModelPicker/ModelPicker.d.ts +2 -0
  241. package/components/ModelPicker/ModelPicker.js +15 -1
  242. package/components/MotionSwatch/MotionSwatch.css +3 -3
  243. package/components/NavList/NavList.css +3 -3
  244. package/components/NotificationCenter/NotificationCenter.d.ts +2 -0
  245. package/components/NotificationCenter/NotificationCenter.js +7 -2
  246. package/components/Pagination/Pagination.css +8 -6
  247. package/components/Pagination/Pagination.d.ts +2 -0
  248. package/components/Pagination/Pagination.js +6 -2
  249. package/components/PinInput/PinInput.js +3 -2
  250. package/components/PixelAvatar/pixelInks.d.ts +6 -0
  251. package/components/PixelAvatar/pixelInks.js +7 -3
  252. package/components/Popover/Popover.css +32 -30
  253. package/components/Popover/Popover.d.ts +10 -2
  254. package/components/Popover/Popover.js +16 -2
  255. package/components/ProgressBar/ProgressBar.css +1 -1
  256. package/components/ProgressBar/ProgressBar.d.ts +2 -0
  257. package/components/ProgressBar/ProgressBar.js +3 -5
  258. package/components/PromptSuggestions/PromptSuggestions.css +10 -3
  259. package/components/PromptSuggestions/PromptSuggestions.js +3 -1
  260. package/components/Prose/Prose.css +50 -8
  261. package/components/Prose/Prose.d.ts +2 -0
  262. package/components/Prose/Prose.js +7 -2
  263. package/components/QuestionCard/QuestionCard.css +1 -1
  264. package/components/Quote/Quote.css +4 -4
  265. package/components/Rating/Rating.js +4 -3
  266. package/components/Reasoning/Reasoning.css +8 -8
  267. package/components/Reasoning/Reasoning.js +1 -0
  268. package/components/RichDropdown/RichDropdown.css +18 -5
  269. package/components/RichDropdown/RichDropdown.js +13 -0
  270. package/components/SegmentedControl/SegmentedControl.css +9 -1
  271. package/components/SegmentedControl/SegmentedControl.js +5 -3
  272. package/components/ShaderField/useShaderField.js +13 -1
  273. package/components/SidebarPanel/SidebarPanel.css +7 -7
  274. package/components/SidebarPanel/SidebarPanel.js +2 -2
  275. package/components/Skeleton/Skeleton.css +2 -2
  276. package/components/Skeleton/Skeleton.js +1 -0
  277. package/components/Slider/Slider.css +16 -1
  278. package/components/Slider/Slider.js +1 -1
  279. package/components/SourceChip/SourceChip.css +6 -12
  280. package/components/SourceChip/SourceChip.d.ts +2 -0
  281. package/components/SourceChip/SourceChip.js +16 -37
  282. package/components/SourceTrail/SourceTrail.css +1 -1
  283. package/components/SpacingSwatch/SpacingSwatch.css +3 -3
  284. package/components/SplitButton/SplitButton.css +2 -2
  285. package/components/SplitButton/SplitButton.js +1 -0
  286. package/components/SplitPane/SplitPane.js +3 -2
  287. package/components/Stat/Stat.css +1 -1
  288. package/components/Stat/Stat.d.ts +2 -0
  289. package/components/Stat/Stat.js +3 -1
  290. package/components/Stepper/Stepper.css +5 -5
  291. package/components/Stepper/Stepper.d.ts +2 -0
  292. package/components/Stepper/Stepper.js +5 -1
  293. package/components/StreamingText/StreamingText.css +1 -1
  294. package/components/Table/Table.css +63 -21
  295. package/components/Table/Table.d.ts +10 -2
  296. package/components/Table/Table.js +34 -12
  297. package/components/TableToolbar/TableToolbar.css +494 -0
  298. package/components/TableToolbar/TableToolbar.d.ts +281 -0
  299. package/components/TableToolbar/TableToolbar.js +1322 -0
  300. package/components/Tabs/Tabs.js +3 -2
  301. package/components/ThemePicker/ThemePicker.css +189 -0
  302. package/components/ThemePicker/ThemePicker.d.ts +67 -0
  303. package/components/ThemePicker/ThemePicker.js +165 -0
  304. package/components/ThemeToggle/ThemeToggle.css +82 -0
  305. package/components/ThemeToggle/ThemeToggle.d.ts +42 -0
  306. package/components/ThemeToggle/ThemeToggle.js +98 -0
  307. package/components/ThemeToggle/colorMode.d.ts +42 -0
  308. package/components/ThemeToggle/colorMode.js +26 -0
  309. package/components/ThemeToggle/useColorMode.d.ts +8 -0
  310. package/components/ThemeToggle/useColorMode.js +44 -0
  311. package/components/ThreadPanel/ThreadPanel.css +19 -5
  312. package/components/ThreadPanel/ThreadPanel.d.ts +6 -1
  313. package/components/ThreadPanel/ThreadPanel.js +11 -7
  314. package/components/ThreadTabs/ThreadTabs.css +8 -1
  315. package/components/ThreadTabs/ThreadTabs.js +4 -2
  316. package/components/TimePicker/TimePicker.css +12 -6
  317. package/components/TimePicker/TimePicker.d.ts +17 -4
  318. package/components/TimePicker/TimePicker.js +32 -3
  319. package/components/Timeline/Timeline.css +8 -8
  320. package/components/Timeline/Timeline.d.ts +2 -0
  321. package/components/Timeline/Timeline.js +5 -2
  322. package/components/Toast/Toast.css +5 -5
  323. package/components/Toast/Toast.js +3 -2
  324. package/components/ToggleGroup/ToggleGroup.css +11 -1
  325. package/components/ToggleSwitch/ToggleSwitch.css +5 -5
  326. package/components/ToggleSwitch/ToggleSwitch.js +1 -0
  327. package/components/ToolCall/ToolCall.css +3 -3
  328. package/components/Toolbar/Toolbar.js +4 -2
  329. package/components/Tooltip/Tooltip.css +25 -25
  330. package/components/Tooltip/Tooltip.d.ts +2 -2
  331. package/components/Tooltip/Tooltip.js +16 -60
  332. package/components/TopAppBar/TopAppBar.css +7 -5
  333. package/components/TopAppBar/TopAppBar.js +3 -1
  334. package/components/TreeView/TreeView.css +1 -1
  335. package/components/TreeView/TreeView.js +4 -3
  336. package/components/UsageCard/UsageCard.d.ts +2 -0
  337. package/components/UsageCard/UsageCard.js +3 -0
  338. package/components/Widget/Widget.css +1 -1
  339. package/components/Widget/Widget.d.ts +2 -0
  340. package/components/Widget/Widget.js +3 -2
  341. package/components/WorldMap/WorldMap.css +1 -0
  342. package/components/registry.json +37 -5
  343. package/components/registry.json.d.ts +37 -5
  344. package/components/registry.json.js +1 -1
  345. package/fonts/material-symbols.css +13 -1
  346. package/fonts/presets/anton-400-latin-ext.woff2 +0 -0
  347. package/fonts/presets/anton-400-latin.woff2 +0 -0
  348. package/fonts/presets/work-sans-300-700-latin-ext.woff2 +0 -0
  349. package/fonts/presets/work-sans-300-700-latin.woff2 +0 -0
  350. package/index.d.ts +12 -0
  351. package/index.js +34 -2
  352. package/package.json +13 -1
  353. package/tokens/base.css +84 -0
  354. package/tokens/motion.d.ts +4 -0
  355. package/tokens/motion.js +4 -0
  356. package/tokens/presets/contrast.css +6 -2
  357. package/tokens/presets/coral.css +4 -2
  358. package/tokens/presets/forest.css +6 -0
  359. package/tokens/presets/gold.css +10 -2
  360. package/tokens/presets/marquee.css +299 -0
  361. package/tokens/presets/mono.css +4 -2
  362. package/tokens/presets/pink.css +10 -0
  363. package/tokens/presets/presets.css +1 -0
  364. package/tokens/presets/terminal.css +8 -2
  365. package/tokens/presets/violet.css +10 -0
  366. package/tokens/presets/warm.css +4 -0
  367. package/tokens/presets/zest.css +6 -0
  368. package/tokens/registry.d.ts +1 -1
  369. package/tokens/registry.json +32 -1
  370. package/tokens/registry.json.d.ts +32 -1
  371. package/tokens/registry.json.js +1 -1
  372. package/tokens/tokens-dark.css +53 -0
  373. package/tokens/tokens-forced-colors.css +31 -0
  374. package/tokens/tokens-light.css +66 -0
  375. package/tokens/tokens-primitives.css +9 -0
  376. package/tokens/tokens.css +1 -0
  377. package/cli/templates/chat/app/api/chat/feedback/route.d.ts +0 -3
  378. package/cli/templates/chat/app/api/chat/followups/route.d.ts +0 -3
  379. package/cli/templates/chat/app/api/chat/guardrails.d.ts +0 -10
  380. package/cli/templates/chat/app/api/chat/route.d.ts +0 -4
  381. package/cli/templates/chat/components/chat/ChatMount.d.ts +0 -1
  382. package/cli/templates/chat/components/chat/models.d.ts +0 -11
package/README.md CHANGED
@@ -13,7 +13,7 @@ An open source React design system built for AI products and coding agents: comp
13
13
 
14
14
  ## Why Rift DS
15
15
 
16
- - **<!-- component-count -->155<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
16
+ - **<!-- component-count -->159<!-- /component-count --> components.** Buttons, forms and tables through to charts, navigation and overlays, each typed and documented with live examples. Every one forwards a ref and your own attributes to its element, state you can own works controlled or uncontrolled (a modal opens when your app says so, by design), and every word a component writes has a prop you can localise. The build checks the first two on every component, and the words wherever they sit in markup. React and React DOM are the only required peer dependencies.
17
17
  - **AI patterns, the whole chat and templates, ready to use.** Composer, streaming chat thread, tool calls, reasoning and thread panel are in the box, the complete AI chat ships assembled as one widget that one command scaffolds, and the docs site has complete template screens built from them.
18
18
  - **Fully themeable.** The shipped themes are complete looks to start from, each in light and dark. One `data-brand` attribute applies a theme, and a few CSS overrides make your own.
19
19
  - **Ready for coding agents.** One command installs the agent skills, and a public MCP endpoint serves every component's props, so your agent builds with the library as it actually is. No key, no account.
@@ -25,18 +25,25 @@ Everything deep lives on the docs site: **[rift-ds.com](https://rift-ds.com/)**,
25
25
 
26
26
  ## Install
27
27
 
28
+ In a Next.js app router project (a fresh `create-next-app` included), three commands give you a themed first page:
29
+
28
30
  ```bash
29
31
  npm install rift-ds
32
+ npx rift-ds init app
33
+ npx rift-ds init block dashboard
30
34
  ```
31
35
 
32
- Import the token stylesheet once, then use components:
36
+ `init app` adds a root wrapper that routes every link through Next's `Link`, the script that applies the visitor's colour mode before first paint, and the base theme's font, then prints your root layout: make `app/layout.tsx` that, and drop the `globals.css` import `create-next-app` added. `init block dashboard` adds a dashboard inside an app shell (the sidebar, the top bar and the page header), laid out for a desktop and a phone; the other blocks are on the [blocks page](https://rift-ds.com/docs/blocks). Neither overwrites a file, and the files are yours to change.
37
+
38
+ In any other React app, import the token stylesheet and the base sheet once, then use components:
33
39
 
34
40
  ```tsx
35
41
  import 'rift-ds/tokens/tokens.css';
42
+ import 'rift-ds/tokens/base.css'; // the reset and page every component is tuned against
36
43
  import { Button, Card, Badge } from 'rift-ds';
37
44
  ```
38
45
 
39
- React 19+ is a peer dependency. The package is ESM-only and resolved via `exports` subpaths: use a bundler that handles CSS and font imports from `node_modules` (Vite, Next.js, webpack) and set TypeScript's `moduleResolution` to `"bundler"` or `"nodenext"`. The Recharts-backed charts live behind `rift-ds/charts`, so the optional `recharts` peer dependency is only needed if you use them. The chat widget's subpaths bring their own optional peers (`react-markdown` and `remark-gfm` for the panel, `@anthropic-ai/sdk` for the server handlers, `@upstash/ratelimit` and `@upstash/redis` for the guardrails), needed only if you use them. Prefer owning the source? Pull single components through the shadcn CLI (`npx shadcn@latest add https://rift-ds.com/r/button.json`, with details in the [get-started guide](https://rift-ds.com/docs/get-started)), or clone this repo and build on it directly; all of it is MIT.
46
+ React 19+ is a peer dependency. The package's own runtime dependencies, TanStack Table and TanStack Virtual (the headless engine under `DataTable` and the windowing behind its long tables), install with it. The package is ESM-only and resolved via `exports` subpaths: use a bundler that handles CSS and font imports from `node_modules` (Vite, Next.js, webpack) and set TypeScript's `moduleResolution` to `"bundler"` or `"nodenext"`. The Recharts-backed charts live behind `rift-ds/charts`, so the optional `recharts` peer dependency is only needed if you use them. The chat widget's subpaths bring their own optional peers (`react-markdown` and `remark-gfm` for the panel, `@anthropic-ai/sdk` for the server handlers, `@upstash/ratelimit` and `@upstash/redis` for the guardrails), needed only if you use them. Prefer owning the source? Pull single components through the shadcn CLI (`npx shadcn@latest add https://rift-ds.com/r/button.json`, with details in the [get-started guide](https://rift-ds.com/docs/get-started)), or clone this repo and build on it directly; all of it is MIT.
40
47
 
41
48
  ## The chat widget
42
49
 
@@ -84,7 +91,7 @@ Every component's prop contract is also plain markdown (append `.md` to its docs
84
91
 
85
92
  ## Theming
86
93
 
87
- Theming is CSS custom properties; there is no configuration API and no provider (one exception: wrap your tree in `ToastProvider` if, and only if, you use the toast queue via `useToast`). Complete looks ship as generated stylesheets: import the aggregate once and one attribute rethemes everything, light and dark, typefaces included (each preset self-hosts its faces).
94
+ Theming is CSS custom properties; there is no configuration API and no theme provider (one required exception: wrap your tree in `ToastProvider` if, and only if, you use the toast queue via `useToast`). Two providers are optional: `LinkProvider` hands every component your router's link, and `LocaleProvider` sets the locale numbers, dates and calendars are written in (`en-US` without it, never the browser's). Key bindings go through `useShortcut` from `rift-ds/behaviors/shortcuts`, the listener the components use, so a shortcut stays out of text fields and open overlays. For a right-to-left language, set `dir="rtl"` on `<html>`: every component lays itself out from it. Complete looks ship as generated stylesheets: import the aggregate once and one attribute rethemes everything, light and dark, typefaces included (each preset self-hosts its faces).
88
95
 
89
96
  ```tsx
90
97
  import 'rift-ds/tokens/presets/presets.css';
@@ -100,13 +107,13 @@ import 'rift-ds/tokens/presets/presets.css';
100
107
 
101
108
  ## Components
102
109
 
103
- <!-- component-count -->155<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
110
+ <!-- component-count -->159<!-- /component-count --> components, including a chat set for AI products (Chat thread, Composer, Tool call, Reasoning, Thread panel) and Shader field, a WebGL2 ambient background whose light sources read your colour tokens at runtime, so it re-themes with everything else. Details and live examples are on the [docs site](https://rift-ds.com/components).
104
111
 
105
112
  <details>
106
113
  <summary>The full list</summary>
107
114
 
108
115
  <!-- component-list:start -->
109
- Accordion · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Chip · Circular button · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Composer · Contact card · Context menu · Contribution graph · Data table · Date input · Date picker · Dialog · Divider · Document chip · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Event calendar · Field · Figure · File input · Filter bar · Funnel chart · Gantt chart · Gauge · Globe · Hover card · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link list · Map callout · Map legend · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Sidebar panel · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Tabs · Tag input · Textarea · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · World map
116
+ Accordion · Agent plan · Agent rail · Agent status · AI button · Alert · Alert dialog · Anchor nav · Animated number · App layout · App sidebar · Area chart · Artifact card · Artifact panel · Attachment drop zone · Attachment group · Attachment tile · Attachment viewer · Avatar · Avatar group · Badge · Banner · Bar chart · Bento tile · Bento tile art · Bottom nav · Breadcrumb · Button · Button group · Card · Card stack · Carousel · Chat header · Chat marker · Chat message · Chat thread · Checkbox · Chip · Circular button · Code block · Code diff · Colour picker · Combo chart · Combobox · Command palette · Command palette trigger · Composer · Contact card · Context menu · Contribution graph · Data table · Date input · Date picker · Dialog · Divider · Document chip · Drawer · Dropdown · Dropdown menu · Empty state · Entity card · Event calendar · Field · Figure · File input · Filter bar · Funnel chart · Gantt chart · Gauge · Globe · Hover card · Image compare · Input · Inspector colour picker · Inspector dropdown · Inspector input · Inspector section · Inspector segments · Inspector slider · Inspector toggle switch · Instructions · Interrupt card · Kbd · Legend tile · Lightbox · Line chart · Link list · Map callout · Map legend · Mention · Message actions · Message card · Meter · Model picker · Nav · Nav list · Notification centre · Number input · Pagination · Panel · Pie chart · Pin input · Pixel avatar · Popover · Progress bar · Prompt suggestions · Prose · Question card · Quote · Radar chart · Radial chart · Radio button · Rating · Reasoning · Rich dropdown · Scatter chart · Section title · Segmented control · Selection card · Shader field · Sidebar panel · Skeleton · Slider · Source chip · Source trail · Sparkline · Spinner · Split button · Split pane · Stacked bar chart · Stat · Status dot · Stepper · Streaming text · Swatch · Table · Table toolbar · Tabs · Tag input · Textarea · Theme picker · Theme toggle · Thread panel · Thread tabs · Time picker · Timeline · Toast · Toggle group · Toggle switch · Tool call · Toolbar · Tooltip · Top app bar · Tree view · Treemap · Usage card · Waveform · Widget · World map
110
117
  <!-- component-list:end -->
111
118
 
112
119
  </details>
@@ -118,6 +125,7 @@ Accordion · Agent plan · Agent rail · Agent status · AI button · Alert · A
118
125
  - **Next.js 16**: the documentation site
119
126
  - **Storybook 10**: component explorer
120
127
  - **Vitest + Playwright + axe**: every Storybook story runs as a render test in headless Chromium, with an accessibility audit on each
128
+ - **TanStack Table + TanStack Virtual**: the headless engine and the windowing under `DataTable`, the package's runtime dependencies
121
129
  - **CSS custom properties**: all theming via semantic tokens, no CSS-in-JS
122
130
 
123
131
  The [overview](https://rift-ds.com/overview) shows the generate-and-validate pipeline behind the docs.
@@ -27,6 +27,9 @@ export interface LinkProviderProps {
27
27
  * read a provider and take the prop alone (design.md's Components intro
28
28
  * names them, and scripts/validate-component-contract.mjs keeps them off
29
29
  * the provider).
30
+ *
31
+ * Published as the `./behaviors/LinkProvider` subpath because consumers
32
+ * mount it; with the scroll lock it is one of only two behaviors that are.
30
33
  */
31
34
  export declare function LinkProvider({ linkComponent, children }: LinkProviderProps): React.JSX.Element;
32
35
  /**
@@ -0,0 +1,27 @@
1
+ import { default as React } from 'react';
2
+ export interface LocaleProviderProps {
3
+ /**
4
+ * The BCP 47 locale every rift-ds component under this provider formats
5
+ * numbers, dates and calendars in, such as `de-DE`. Named like the
6
+ * instance prop it stands in for.
7
+ */
8
+ locale: string;
9
+ /** The part of the app it applies to, usually the whole app. */
10
+ children?: React.ReactNode;
11
+ }
12
+ /**
13
+ * Sets the locale for every client-rendered rift-ds component below it that
14
+ * formats a number or a date, or lays out a calendar: grouping and decimal
15
+ * marks, month and weekday names, the first day of the week, and the
16
+ * 12- or 24-hour clock. A component's own `locale` prop wins over it. The
17
+ * components that can render on the server cannot read a provider and take
18
+ * the prop alone. Words stay props of their own: the locale formats, it
19
+ * never translates.
20
+ */
21
+ export declare function LocaleProvider({ locale, children }: LocaleProviderProps): React.JSX.Element;
22
+ /**
23
+ * The locale to format in: the component's own `locale` prop, else the
24
+ * nearest LocaleProvider's, else `en-US`. Never the runtime's default, so
25
+ * the server and the browser always agree.
26
+ */
27
+ export declare function useLocale(override?: string): string;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ import { DEFAULT_LOCALE } from "./locale.js";
5
+ const LocaleContext = createContext(null);
6
+ function LocaleProvider({ locale, children }) {
7
+ return /* @__PURE__ */ jsx(LocaleContext.Provider, { value: locale, children });
8
+ }
9
+ function useLocale(override) {
10
+ const provided = useContext(LocaleContext);
11
+ return override ?? provided ?? DEFAULT_LOCALE;
12
+ }
13
+ export {
14
+ LocaleProvider,
15
+ useLocale
16
+ };
@@ -0,0 +1,8 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export declare function ScrollRegion({ className, style, children, onNode, }: {
3
+ className?: string;
4
+ style?: CSSProperties;
5
+ children: ReactNode;
6
+ /** Hands the scrolling element to its owner (a virtualised table scrolls its rows inside it). */
7
+ onNode?: (node: HTMLDivElement | null) => void;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef, useCallback, useId, useState, useEffect } from "react";
4
+ function ScrollRegion({
5
+ className,
6
+ style,
7
+ children,
8
+ onNode
9
+ }) {
10
+ const ref = useRef(null);
11
+ const setNode = useCallback(
12
+ (node) => {
13
+ ref.current = node;
14
+ onNode?.(node);
15
+ },
16
+ [onNode]
17
+ );
18
+ const captionId = useId();
19
+ const [overflows, setOverflows] = useState(false);
20
+ const [labelledBy, setLabelledBy] = useState();
21
+ useEffect(() => {
22
+ const node = ref.current;
23
+ if (!node) return;
24
+ const caption = node.querySelector("caption");
25
+ if (caption) {
26
+ if (!caption.id) caption.id = captionId;
27
+ setLabelledBy(caption.id);
28
+ }
29
+ const measure = () => setOverflows(node.scrollWidth > node.clientWidth + 1);
30
+ measure();
31
+ const observer = new ResizeObserver(measure);
32
+ observer.observe(node);
33
+ if (node.firstElementChild) observer.observe(node.firstElementChild);
34
+ return () => observer.disconnect();
35
+ }, [captionId]);
36
+ return /* @__PURE__ */ jsx(
37
+ "div",
38
+ {
39
+ ref: setNode,
40
+ className,
41
+ style,
42
+ role: overflows ? "region" : void 0,
43
+ "aria-labelledby": overflows ? labelledBy : void 0,
44
+ tabIndex: overflows ? 0 : void 0,
45
+ children
46
+ }
47
+ );
48
+ }
49
+ export {
50
+ ScrollRegion
51
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Development-only console warnings, the way React writes its own: the
3
+ * check reads `process.env.NODE_ENV`, which every bundler replaces at build
4
+ * time, so a production bundle drops the warning and a page with no
5
+ * bundler (and no `process`) stays silent rather than throwing. Each
6
+ * message prints once per page load, however many instances trip it.
7
+ */
8
+ /** Warns once, in development only. */
9
+ export declare function warnOnce(message: string): void;
@@ -0,0 +1,16 @@
1
+ const isDevelopment = (() => {
2
+ try {
3
+ return process.env.NODE_ENV !== "production";
4
+ } catch {
5
+ return false;
6
+ }
7
+ })();
8
+ const warned = /* @__PURE__ */ new Set();
9
+ function warnOnce(message) {
10
+ if (!isDevelopment || warned.has(message)) return;
11
+ warned.add(message);
12
+ console.warn(`[rift-ds] ${message}`);
13
+ }
14
+ export {
15
+ warnOnce
16
+ };
@@ -0,0 +1,19 @@
1
+ /* ============================================
2
+ READING DIRECTION SIGN
3
+ `--ds-inline-sign` is 1 in a left-to-right context and -1 in a
4
+ right-to-left one, read from the element's own direction (`:dir()`),
5
+ so a `dir` attribute anywhere up the tree sets it. A component that
6
+ moves along the inline axis (a slide-in, a thumb, a shimmer's sweep, an
7
+ optical nudge) multiplies its offset by it, always with the fallback
8
+ `var(--ds-inline-sign, 1)`, and imports this file. Logical properties
9
+ cover placement; this covers motion, which CSS has no logical form for.
10
+ design.md's "Layout follows the reading direction" owns the contract.
11
+ ============================================ */
12
+
13
+ :dir(ltr) {
14
+ --ds-inline-sign: 1;
15
+ }
16
+
17
+ :dir(rtl) {
18
+ --ds-inline-sign: -1;
19
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The reading direction, for the code that moves along the inline axis:
3
+ * arrow keys, drags and anything placed in pixels. Stylesheets read it
4
+ * through logical properties and `--ds-inline-sign` (direction.css); script
5
+ * reads it here, from the element itself at the moment it acts, so a `dir`
6
+ * attribute anywhere up the tree applies and a change to it needs no
7
+ * re-render. No React and no browser API at import time, so a server
8
+ * component can import it too. design.md's "Layout follows the reading
9
+ * direction" owns the contract.
10
+ */
11
+ /** Whether `element` lays out right to left. False on the server and for a missing element. */
12
+ export declare function isRtl(element: Element | null | undefined): boolean;
13
+ /** 1 when `element` reads left to right, -1 when it reads right to left: the sign to multiply a horizontal pointer delta by. */
14
+ export declare const inlineSign: (element: Element | null | undefined) => 1 | -1;
15
+ /**
16
+ * An arrow key along the inline axis as a step through the reading order:
17
+ * `1` for the next item (ArrowRight in English, ArrowLeft in Arabic), `-1`
18
+ * for the previous one, and 0 for any other key.
19
+ */
20
+ export declare function inlineStep(key: string, element: Element | null | undefined): -1 | 0 | 1;
21
+ /**
22
+ * The Material Symbols ligatures that point along the reading direction and
23
+ * so mirror in a right-to-left context: a "next" chevron points left in
24
+ * Arabic. A component that draws one adds the `ds-mirror-rtl` class (the
25
+ * rule lives in src/fonts/material-symbols.css, which every icon imports);
26
+ * `mirrorClass` decides it for an icon a consumer passes by name.
27
+ */
28
+ export declare const DIRECTIONAL_ICONS: Set<string>;
29
+ /** Whether the icon named `name` points along the reading direction and should mirror in a right-to-left context. */
30
+ export declare const mirrorsInRtl: (name: unknown) => boolean;
31
+ /**
32
+ * A key as it would be pressed in a left-to-right layout: ArrowLeft and
33
+ * ArrowRight swap when `element` reads right to left, and every other key
34
+ * passes through. A component that steps along the inline axis switches on
35
+ * this instead of the raw key, so "the next tab" is ArrowRight in English
36
+ * and ArrowLeft in Arabic with no second branch.
37
+ */
38
+ export declare function logicalArrowKey(key: string, element: Element | null | undefined): string;
39
+ /** `ds-mirror-rtl` when the icon named `name` mirrors in a right-to-left context, else an empty string, for a className. */
40
+ export declare const mirrorClass: (name: unknown) => string;
@@ -0,0 +1,56 @@
1
+ function isRtl(element) {
2
+ if (!element || typeof getComputedStyle === "undefined") return false;
3
+ return getComputedStyle(element).direction === "rtl";
4
+ }
5
+ const inlineSign = (element) => isRtl(element) ? -1 : 1;
6
+ const DIRECTIONAL_ICONS = /* @__PURE__ */ new Set([
7
+ "chevron_left",
8
+ "chevron_right",
9
+ "arrow_back",
10
+ "arrow_forward",
11
+ "arrow_back_ios",
12
+ "arrow_forward_ios",
13
+ "arrow_back_ios_new",
14
+ "first_page",
15
+ "last_page",
16
+ "keyboard_arrow_left",
17
+ "keyboard_arrow_right",
18
+ "keyboard_double_arrow_left",
19
+ "keyboard_double_arrow_right",
20
+ "navigate_before",
21
+ "navigate_next",
22
+ "east",
23
+ "west",
24
+ "trending_flat",
25
+ "subdirectory_arrow_right",
26
+ "subdirectory_arrow_left",
27
+ "reply",
28
+ "forward",
29
+ "undo",
30
+ "redo",
31
+ "logout",
32
+ "login",
33
+ "send",
34
+ "menu_open",
35
+ "format_indent_increase",
36
+ "format_indent_decrease",
37
+ "view_sidebar",
38
+ "left_panel_open",
39
+ "left_panel_close",
40
+ "right_panel_open",
41
+ "right_panel_close"
42
+ ]);
43
+ const mirrorsInRtl = (name) => typeof name === "string" && DIRECTIONAL_ICONS.has(name);
44
+ function logicalArrowKey(key, element) {
45
+ if (key !== "ArrowLeft" && key !== "ArrowRight" || !isRtl(element)) return key;
46
+ return key === "ArrowLeft" ? "ArrowRight" : "ArrowLeft";
47
+ }
48
+ const mirrorClass = (name) => mirrorsInRtl(name) ? "ds-mirror-rtl" : "";
49
+ export {
50
+ DIRECTIONAL_ICONS,
51
+ inlineSign,
52
+ isRtl,
53
+ logicalArrowKey,
54
+ mirrorClass,
55
+ mirrorsInRtl
56
+ };
@@ -2,7 +2,8 @@
2
2
  * Shared focusability queries for the overlay behavior layer.
3
3
  *
4
4
  * One home for the selector the modal components previously each carried a
5
- * copy of. Plain DOM utilities — no React, safe to import anywhere.
5
+ * copy of. Plain DOM utilities — no React, safe to import anywhere. It
6
+ * serves non-overlay keyboard work too: Toolbar's arrow-key model reads it.
6
7
  */
7
8
  /** Everything a focus trap must cycle through. */
8
9
  export declare const FOCUSABLE = "button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Locale data every formatting component shares. Server-safe: no React and
3
+ * no browser API, so a component that renders from a Server Component can
4
+ * import it too. The client half (the provider and the hook) is
5
+ * LocaleProvider.tsx.
6
+ *
7
+ * The rule it carries: a component never formats in the runtime's default
8
+ * locale. The server and the browser can disagree on it, which prints
9
+ * `1,234` on one and `1.234` on the other and breaks hydration, and a
10
+ * consumer could not choose it. Every number, date and calendar convention
11
+ * a component prints is resolved from a locale the consumer can set, which
12
+ * falls back to DEFAULT_LOCALE. scripts/validate-locale-formatting.mjs
13
+ * enforces it.
14
+ */
15
+ /** The locale a component formats in when neither its `locale` prop nor a LocaleProvider sets one. */
16
+ export declare const DEFAULT_LOCALE = "en-US";
17
+ /** A day of the week as `Date.getDay()` numbers it: 0 is Sunday, 6 is Saturday. */
18
+ export type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
19
+ /**
20
+ * The first day of the week in `locale`, as a `Date.getDay()` number:
21
+ * Sunday (0) in en-US, Monday (1) in de-DE, Saturday (6) in ar-EG. Read
22
+ * from the runtime's CLDR week data where it has it, else from the region.
23
+ */
24
+ export declare function weekStartOf(locale: string): Weekday;
25
+ /** A Sunday-first list of seven, reordered to start on `start`. */
26
+ export declare function rotateWeek<T>(sundayFirst: readonly T[], start: Weekday): T[];
27
+ /** How many days `day` sits after the week's first day: 0 for the first column, 6 for the last. */
28
+ export declare const weekdayOffset: (day: number, start: Weekday) => number;
29
+ /** The seven weekday names in `locale`, Sunday first, at the given width. */
30
+ export declare function weekdayNamesIn(locale: string, width: 'long' | 'short' | 'narrow'): string[];
31
+ /** Whether `locale` is written in English, the language every built-in label defaults to. */
32
+ export declare function isEnglish(locale: string): boolean;
33
+ /** Whether `locale` writes times on a 12-hour clock (en-US) rather than a 24-hour one (en-GB, de-DE). */
34
+ export declare function uses12HourClock(locale: string): boolean;
35
+ /**
36
+ * A number as `locale` writes it, grouped and with its own decimal mark:
37
+ * `1,234.5` in en-US, `1.234,5` in de-DE. Formats are cached per locale.
38
+ */
39
+ export declare function formatNumber(value: number, locale: string): string;
40
+ /**
41
+ * A number on a chart's value axis as `locale` writes it, grouped only from
42
+ * five digits up (`12,000` but `2024`), so a tick that happens to be a year
43
+ * never reads as a quantity.
44
+ */
45
+ export declare function formatAxisNumber(value: number, locale: string): string;
46
+ /** A whole percentage, given as 0 to 100, as `locale` writes it: `64%` in en-US, `٦٤٪` in ar-EG, `64 %` in de-DE. */
47
+ export declare function formatPercent(percent: number, locale: string): string;
@@ -0,0 +1,87 @@
1
+ const DEFAULT_LOCALE = "en-US";
2
+ const SUNDAY_FIRST = new Set(
3
+ "AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" ")
4
+ );
5
+ const SATURDAY_FIRST = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
6
+ const weekStartCache = /* @__PURE__ */ new Map();
7
+ function weekStartOf(locale) {
8
+ const cached = weekStartCache.get(locale);
9
+ if (cached !== void 0) return cached;
10
+ let start = 1;
11
+ try {
12
+ const intlLocale = new Intl.Locale(locale);
13
+ const info = intlLocale.getWeekInfo?.() ?? intlLocale.weekInfo;
14
+ if (info) {
15
+ start = info.firstDay % 7;
16
+ } else {
17
+ const region = intlLocale.maximize().region ?? "";
18
+ start = SUNDAY_FIRST.has(region) ? 0 : SATURDAY_FIRST.has(region) ? 6 : 1;
19
+ }
20
+ } catch {
21
+ start = 1;
22
+ }
23
+ weekStartCache.set(locale, start);
24
+ return start;
25
+ }
26
+ function rotateWeek(sundayFirst, start) {
27
+ return [...sundayFirst.slice(start), ...sundayFirst.slice(0, start)];
28
+ }
29
+ const weekdayOffset = (day, start) => (day - start + 7) % 7;
30
+ function weekdayNamesIn(locale, width) {
31
+ const format = new Intl.DateTimeFormat(locale, { weekday: width, timeZone: "UTC" });
32
+ return Array.from({ length: 7 }, (_, day) => format.format(Date.UTC(2023, 0, 1 + day)));
33
+ }
34
+ function isEnglish(locale) {
35
+ try {
36
+ return new Intl.Locale(locale).language === "en";
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+ function uses12HourClock(locale) {
42
+ const cycle = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle;
43
+ return cycle === "h11" || cycle === "h12";
44
+ }
45
+ const numberFormats = /* @__PURE__ */ new Map();
46
+ function formatNumber(value, locale) {
47
+ let format = numberFormats.get(locale);
48
+ if (!format) {
49
+ format = new Intl.NumberFormat(locale, { maximumFractionDigits: 3 });
50
+ numberFormats.set(locale, format);
51
+ }
52
+ return format.format(value);
53
+ }
54
+ const axisFormats = /* @__PURE__ */ new Map();
55
+ function formatAxisNumber(value, locale) {
56
+ let format = axisFormats.get(locale);
57
+ if (!format) {
58
+ format = new Intl.NumberFormat(locale, {
59
+ maximumFractionDigits: 3,
60
+ // 'min2' is CLDR's grouping for short numbers; the type lags the spec.
61
+ useGrouping: "min2"
62
+ });
63
+ axisFormats.set(locale, format);
64
+ }
65
+ return format.format(value);
66
+ }
67
+ const percentFormats = /* @__PURE__ */ new Map();
68
+ function formatPercent(percent, locale) {
69
+ let format = percentFormats.get(locale);
70
+ if (!format) {
71
+ format = new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 });
72
+ percentFormats.set(locale, format);
73
+ }
74
+ return format.format(percent / 100);
75
+ }
76
+ export {
77
+ DEFAULT_LOCALE,
78
+ formatAxisNumber,
79
+ formatNumber,
80
+ formatPercent,
81
+ isEnglish,
82
+ rotateWeek,
83
+ uses12HourClock,
84
+ weekStartOf,
85
+ weekdayNamesIn,
86
+ weekdayOffset
87
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The shortcut grammar and how a shortcut is drawn, with no React and no
3
+ * browser API, so a component that renders from a Server Component can
4
+ * draw or announce a shortcut too. The listener and the hooks are
5
+ * shortcuts.ts, which owns the grammar's description.
6
+ */
7
+ /** A shortcut in the grammar above, such as `mod+k`, `shift+?` or `g i`. */
8
+ export type Shortcut = string;
9
+ /** The platform a shortcut is read and drawn for: `apple` maps `mod` to ⌘, `other` to Ctrl. */
10
+ export type ShortcutPlatform = 'apple' | 'other';
11
+ /** The legends a shortcut is drawn with, by modifier or key name. Merged over the platform's defaults. */
12
+ export type ShortcutKeyLabels = Partial<Record<string, string>>;
13
+ /** One step of a shortcut: its key and the modifiers held with it. */
14
+ export type Step = {
15
+ key: string;
16
+ mod: boolean;
17
+ ctrl: boolean;
18
+ meta: boolean;
19
+ alt: boolean;
20
+ shift: boolean;
21
+ };
22
+ export declare const KEY_ALIASES: Record<string, string>;
23
+ /** A shortcut's steps, parsed once. A step written `ctrl++` would be ambiguous, so `plus` names the key. */
24
+ export declare const parseShortcut: (shortcut: Shortcut) => Step[];
25
+ /** The platform this code runs on, read from the browser. `other` on the server. */
26
+ export declare const detectPlatform: () => ShortcutPlatform;
27
+ /**
28
+ * A shortcut as keycap legends, one array per step: `mod+shift+p` is
29
+ * `[['⇧', '⌘', 'P']]` on a Mac and `[['Ctrl', 'Shift', 'P']]` elsewhere.
30
+ * `labels` replaces any legend, such as `{ ctrl: 'Strg' }` for a German
31
+ * keyboard.
32
+ */
33
+ export declare function shortcutKeys(shortcut: Shortcut, platform: ShortcutPlatform, labels?: ShortcutKeyLabels): string[][];
34
+ /**
35
+ * A shortcut as one line of text, for a menu row: `⇧⌘P` on a Mac and
36
+ * `Ctrl+Shift+P` elsewhere, the steps of a sequence spaced apart.
37
+ */
38
+ export declare function formatShortcut(shortcut: Shortcut, platform: ShortcutPlatform, labels?: ShortcutKeyLabels): string;
39
+ /**
40
+ * A single-step shortcut as an `aria-keyshortcuts` value (`Meta+K` on a Mac,
41
+ * `Control+K` elsewhere). A sequence has no ARIA form, so it gives undefined.
42
+ */
43
+ export declare function shortcutAria(shortcut: Shortcut, platform: ShortcutPlatform): string | undefined;
44
+ /**
45
+ * A shortcut as an `aria-keyshortcuts` value for both platforms at once
46
+ * (`Meta+K Control+K` for `mod+k`), for markup that renders on the server or
47
+ * before the platform is known. Undefined for a sequence.
48
+ */
49
+ export declare function shortcutAriaAnyPlatform(shortcut: Shortcut): string | undefined;