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.
- package/README.md +14 -6
- package/behaviors/LinkProvider.d.ts +3 -0
- package/behaviors/LocaleProvider.d.ts +27 -0
- package/behaviors/LocaleProvider.js +16 -0
- package/behaviors/ScrollRegion.d.ts +8 -0
- package/behaviors/ScrollRegion.js +51 -0
- package/behaviors/devWarning.d.ts +9 -0
- package/behaviors/devWarning.js +16 -0
- package/behaviors/direction.css +19 -0
- package/behaviors/direction.d.ts +40 -0
- package/behaviors/direction.js +56 -0
- package/behaviors/focusable.d.ts +2 -1
- package/behaviors/locale.d.ts +47 -0
- package/behaviors/locale.js +87 -0
- package/behaviors/shortcut-keys.d.ts +49 -0
- package/behaviors/shortcut-keys.js +129 -0
- package/behaviors/shortcuts.d.ts +75 -0
- package/behaviors/shortcuts.js +160 -0
- package/behaviors/useAnchoredPosition.d.ts +124 -0
- package/behaviors/useAnchoredPosition.js +158 -0
- package/behaviors/useFocusScope.d.ts +15 -2
- package/behaviors/useFocusScope.js +7 -1
- package/behaviors/useLayer.d.ts +9 -0
- package/behaviors/useLayer.js +4 -0
- package/behaviors/useScrollLock.d.ts +4 -0
- package/bin/rift-ds.mjs +184 -25
- package/bin/templates/app/components/rift/ColorModeScript.tsx +10 -0
- package/bin/templates/app/components/rift/RiftRoot.tsx +13 -0
- package/bin/templates/app/components/rift/font.css +7 -0
- package/bin/templates/app/components/rift/font.ts +14 -0
- package/bin/templates/blocks/app/dashboard/page.module.css +90 -0
- package/bin/templates/blocks/app/dashboard/page.tsx +141 -0
- package/bin/templates/blocks/app/sign-in/page.module.css +91 -0
- package/bin/templates/blocks/app/sign-in/page.tsx +95 -0
- package/bin/templates/blocks/app/starter/page.module.css +7 -0
- package/bin/templates/blocks/app/starter/page.tsx +31 -0
- package/bin/templates/blocks/components/blocks/AppShell.module.css +160 -0
- package/bin/templates/blocks/components/blocks/AppShell.tsx +113 -0
- package/bin/templates/blocks/registry.json +39 -0
- package/chat/AssistantTurn.js +4 -2
- package/chat/ChatWidget.css +24 -24
- package/chat/ChatWidget.js +4 -2
- package/chat/suggestions.d.ts +12 -0
- package/chat/types.d.ts +8 -7
- package/chat/useChat.js +2 -2
- package/components/Accordion/Accordion.css +1 -1
- package/components/AgentPlan/AgentPlan.css +2 -2
- package/components/AgentRail/AgentRail.css +4 -4
- package/components/AgentRail/AgentRail.js +1 -1
- package/components/AgentStatus/AgentRing.d.ts +27 -0
- package/components/AgentStatus/AgentRing.js +9 -0
- package/components/AgentStatus/AgentStatus.css +638 -10
- package/components/AgentStatus/AgentStatus.d.ts +31 -3
- package/components/AgentStatus/AgentStatus.js +22 -4
- package/components/AgentStatus/AgentStatusPatterns.d.ts +1 -1
- package/components/AgentStatus/AgentStatusPatterns.js +2 -1
- package/components/AiButton/AiButton.css +214 -41
- package/components/AiButton/AiButton.d.ts +34 -0
- package/components/AiButton/AiButton.js +130 -9
- package/components/AlertDialog/AlertDialog.css +1 -1
- package/components/AnchorNav/AnchorNav.css +6 -6
- package/components/AnchorNav/AnchorNav.js +4 -2
- package/components/AnimatedNumber/AnimatedNumber.d.ts +6 -0
- package/components/AnimatedNumber/AnimatedNumber.js +12 -5
- package/components/AppLayout/AppLayout.css +3 -3
- package/components/AppSidebar/AppSidebar.css +20 -20
- package/components/AppSidebar/AppSidebar.js +6 -4
- package/components/ArtifactCard/ArtifactCard.css +1 -1
- package/components/ArtifactCard/ArtifactCard.js +2 -1
- package/components/ArtifactPanel/ArtifactPanel.js +2 -1
- package/components/Attachment/Attachment.css +4 -4
- package/components/Attachment/AttachmentDropZone.js +2 -1
- package/components/Attachment/AttachmentGroup.d.ts +2 -0
- package/components/Attachment/AttachmentGroup.js +4 -1
- package/components/Attachment/AttachmentViewer.d.ts +2 -0
- package/components/Attachment/AttachmentViewer.js +8 -13
- package/components/Attachment/fileTypes.d.ts +5 -3
- package/components/Attachment/fileTypes.js +8 -3
- package/components/Avatar/Avatar.css +55 -1
- package/components/Avatar/Avatar.d.ts +9 -1
- package/components/Avatar/Avatar.js +5 -1
- package/components/Avatar/avatarFill.d.ts +9 -0
- package/components/Avatar/avatarFill.js +13 -0
- package/components/AvatarGroup/AvatarGroup.css +1 -1
- package/components/AvatarGroup/AvatarGroup.js +13 -1
- package/components/BentoTile/BentoTile.css +15 -3
- package/components/BottomNav/BottomNav.css +8 -8
- package/components/BottomNav/BottomNav.js +3 -1
- package/components/Breadcrumb/Breadcrumb.js +2 -2
- package/components/Button/Button.css +8 -1
- package/components/Button/Button.d.ts +8 -1
- package/components/Button/Button.js +14 -3
- package/components/Card/Card.css +3 -3
- package/components/CardStack/CardStack.js +4 -2
- package/components/Carousel/Carousel.css +5 -2
- package/components/Carousel/Carousel.js +11 -7
- package/components/Chart/AreaChart.d.ts +2 -0
- package/components/Chart/AreaChart.js +15 -6
- package/components/Chart/BarChart.d.ts +2 -0
- package/components/Chart/BarChart.js +15 -5
- package/components/Chart/Chart.css +6 -6
- package/components/Chart/ComboChart.d.ts +2 -0
- package/components/Chart/ComboChart.js +16 -6
- package/components/Chart/LineChart.d.ts +2 -0
- package/components/Chart/LineChart.js +15 -6
- package/components/Chart/PieChart.d.ts +2 -0
- package/components/Chart/PieChart.js +9 -5
- package/components/Chart/RadarChart.d.ts +2 -0
- package/components/Chart/RadarChart.js +15 -6
- package/components/Chart/RadialChart.d.ts +2 -0
- package/components/Chart/RadialChart.js +9 -5
- package/components/Chart/ScatterChart.d.ts +2 -0
- package/components/Chart/ScatterChart.js +17 -7
- package/components/Chart/StackedBarChart.d.ts +2 -0
- package/components/Chart/StackedBarChart.js +15 -7
- package/components/Chart/Treemap.d.ts +2 -0
- package/components/Chart/Treemap.js +9 -5
- package/components/ChatMarker/ChatMarker.js +2 -1
- package/components/ChatMessage/ChatMessage.css +2 -2
- package/components/ChatThread/ChatThread.css +1 -1
- package/components/Checkbox/Checkbox.js +1 -1
- package/components/CircularButton/CircularButton.css +8 -7
- package/components/CircularButton/CircularButton.d.ts +2 -2
- package/components/CircularButton/CircularButton.js +2 -1
- package/components/CodeBlock/CodeBlock.d.ts +2 -0
- package/components/CodeBlock/CodeBlock.js +2 -0
- package/components/CodeDiff/CodeDiff.css +2 -2
- package/components/ColorPicker/ColorPicker.css +8 -8
- package/components/ColorPicker/ColorPicker.js +11 -0
- package/components/ColourSwatch/ColourSwatch.css +1 -1
- package/components/Combobox/Combobox.css +20 -5
- package/components/Combobox/Combobox.js +75 -55
- package/components/CommandPalette/CommandPalette.d.ts +13 -1
- package/components/CommandPalette/CommandPalette.js +12 -13
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.css +88 -0
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.d.ts +41 -0
- package/components/CommandPaletteTrigger/CommandPaletteTrigger.js +58 -0
- package/components/Composer/Composer.css +7 -7
- package/components/Composer/Composer.d.ts +2 -0
- package/components/Composer/Composer.js +6 -2
- package/components/ContactCard/ContactCard.css +1 -1
- package/components/ContactCard/ContactCard.js +4 -3
- package/components/ContextMenu/ContextMenu.css +10 -7
- package/components/ContextMenu/ContextMenu.d.ts +3 -0
- package/components/ContextMenu/ContextMenu.js +15 -9
- package/components/ContributionGraph/ContributionGraph.css +2 -2
- package/components/ContributionGraph/ContributionGraph.d.ts +7 -1
- package/components/ContributionGraph/ContributionGraph.js +6 -4
- package/components/DataTable/CellEditor.d.ts +37 -0
- package/components/DataTable/CellEditor.js +153 -0
- package/components/DataTable/DataTable.css +1181 -1
- package/components/DataTable/DataTable.d.ts +506 -29
- package/components/DataTable/DataTable.js +2374 -190
- package/components/DataTable/FilterEditor.d.ts +10 -0
- package/components/DataTable/FilterEditor.js +181 -0
- package/components/DataTable/TypedCell.d.ts +22 -0
- package/components/DataTable/TypedCell.js +80 -0
- package/components/DataTable/VirtualRows.d.ts +21 -0
- package/components/DataTable/VirtualRows.js +38 -0
- package/components/DataTable/aggregates.d.ts +29 -0
- package/components/DataTable/aggregates.js +52 -0
- package/components/DataTable/columnTypes.d.ts +49 -0
- package/components/DataTable/columnTypes.js +96 -0
- package/components/DataTable/dragGesture.d.ts +24 -0
- package/components/DataTable/dragGesture.js +62 -0
- package/components/DataTable/editorKinds.d.ts +24 -0
- package/components/DataTable/editorKinds.js +20 -0
- package/components/DataTable/filterModel.d.ts +84 -0
- package/components/DataTable/filterModel.js +159 -0
- package/components/DataTable/tableContext.d.ts +82 -0
- package/components/DataTable/tableContext.js +7 -0
- package/components/DataTable/views.d.ts +50 -0
- package/components/DataTable/views.js +39 -0
- package/components/DateInput/DateInput.css +10 -4
- package/components/DatePicker/DatePicker.d.ts +23 -7
- package/components/DatePicker/DatePicker.js +41 -34
- package/components/Dialog/Dialog.css +1 -1
- package/components/DocumentChip/DocumentChip.css +1 -1
- package/components/DocumentChip/DocumentChip.js +2 -1
- package/components/Drawer/Drawer.css +46 -12
- package/components/Drawer/Drawer.d.ts +6 -2
- package/components/Drawer/Drawer.js +3 -1
- package/components/Dropdown/ChosenMark.css +1 -1
- package/components/Dropdown/Dropdown.css +23 -7
- package/components/Dropdown/Dropdown.d.ts +6 -0
- package/components/Dropdown/Dropdown.js +41 -10
- package/components/DropdownMenu/DropdownMenu.css +38 -17
- package/components/DropdownMenu/DropdownMenu.d.ts +10 -1
- package/components/DropdownMenu/DropdownMenu.js +80 -23
- package/components/DropdownMenu/ShortcutHint.d.ts +12 -0
- package/components/DropdownMenu/ShortcutHint.js +17 -0
- package/components/EmptyState/EmptyState.js +2 -1
- package/components/EntityCard/EntityCard.js +2 -1
- package/components/EventCalendar/EventCalendar.css +1 -1
- package/components/EventCalendar/EventCalendar.d.ts +21 -6
- package/components/EventCalendar/EventCalendar.js +33 -31
- package/components/FileInput/FileInput.d.ts +2 -0
- package/components/FileInput/FileInput.js +4 -1
- package/components/FilterBar/FilterBar.css +10 -6
- package/components/FilterBar/FilterBar.js +69 -44
- package/components/FunnelChart/FunnelChart.d.ts +2 -0
- package/components/FunnelChart/FunnelChart.js +11 -7
- package/components/GanttChart/GanttChart.css +1 -0
- package/components/GanttChart/GanttChart.js +2 -1
- package/components/Gauge/Gauge.css +1 -1
- package/components/Gauge/Gauge.d.ts +2 -0
- package/components/Gauge/Gauge.js +3 -1
- package/components/Globe/Globe.css +1 -0
- package/components/HoverCard/HoverCard.css +25 -44
- package/components/HoverCard/HoverCard.d.ts +2 -2
- package/components/HoverCard/HoverCard.js +18 -2
- package/components/ImageCompare/ImageCompare.css +1 -0
- package/components/Input/Input.css +14 -8
- package/components/Input/Input.js +3 -2
- package/components/Inspector/Inspector.css +12 -11
- package/components/Inspector/InspectorSlider.d.ts +2 -0
- package/components/Inspector/InspectorSlider.js +8 -1
- package/components/Instructions/Instructions.css +1 -1
- package/components/Instructions/Instructions.js +2 -1
- package/components/InterruptCard/InterruptCard.css +9 -1
- package/components/InterruptCard/InterruptCard.d.ts +2 -0
- package/components/InterruptCard/InterruptCard.js +9 -2
- package/components/Kbd/Kbd.css +21 -0
- package/components/Kbd/Kbd.d.ts +14 -4
- package/components/Kbd/Kbd.js +10 -1
- package/components/LegendTile/LegendTile.d.ts +6 -1
- package/components/LegendTile/LegendTile.js +3 -2
- package/components/Lightbox/Lightbox.css +3 -3
- package/components/Lightbox/Lightbox.js +6 -14
- package/components/LinkList/LinkList.js +3 -2
- package/components/MapCallout/MapCallout.css +1 -0
- package/components/Mention/Mention.js +2 -1
- package/components/MessageActions/MessageActions.js +2 -1
- package/components/MessageCard/MessageCard.css +1 -1
- package/components/MessageCard/MessageCard.js +2 -1
- package/components/Meter/Meter.css +1 -1
- package/components/Meter/Meter.d.ts +2 -0
- package/components/Meter/Meter.js +3 -1
- package/components/ModelPicker/ModelPicker.css +14 -11
- package/components/ModelPicker/ModelPicker.d.ts +2 -0
- package/components/ModelPicker/ModelPicker.js +15 -1
- package/components/MotionSwatch/MotionSwatch.css +3 -3
- package/components/NavList/NavList.css +3 -3
- package/components/NotificationCenter/NotificationCenter.d.ts +2 -0
- package/components/NotificationCenter/NotificationCenter.js +7 -2
- package/components/Pagination/Pagination.css +8 -6
- package/components/Pagination/Pagination.d.ts +2 -0
- package/components/Pagination/Pagination.js +6 -2
- package/components/PinInput/PinInput.js +3 -2
- package/components/PixelAvatar/pixelInks.d.ts +6 -0
- package/components/PixelAvatar/pixelInks.js +7 -3
- package/components/Popover/Popover.css +32 -30
- package/components/Popover/Popover.d.ts +10 -2
- package/components/Popover/Popover.js +16 -2
- package/components/ProgressBar/ProgressBar.css +1 -1
- package/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/components/ProgressBar/ProgressBar.js +3 -5
- package/components/PromptSuggestions/PromptSuggestions.css +10 -3
- package/components/PromptSuggestions/PromptSuggestions.js +3 -1
- package/components/Prose/Prose.css +50 -8
- package/components/Prose/Prose.d.ts +2 -0
- package/components/Prose/Prose.js +7 -2
- package/components/QuestionCard/QuestionCard.css +1 -1
- package/components/Quote/Quote.css +4 -4
- package/components/Rating/Rating.js +4 -3
- package/components/Reasoning/Reasoning.css +8 -8
- package/components/Reasoning/Reasoning.js +1 -0
- package/components/RichDropdown/RichDropdown.css +18 -5
- package/components/RichDropdown/RichDropdown.js +13 -0
- package/components/SegmentedControl/SegmentedControl.css +9 -1
- package/components/SegmentedControl/SegmentedControl.js +5 -3
- package/components/ShaderField/useShaderField.js +13 -1
- package/components/SidebarPanel/SidebarPanel.css +7 -7
- package/components/SidebarPanel/SidebarPanel.js +2 -2
- package/components/Skeleton/Skeleton.css +2 -2
- package/components/Skeleton/Skeleton.js +1 -0
- package/components/Slider/Slider.css +16 -1
- package/components/Slider/Slider.js +1 -1
- package/components/SourceChip/SourceChip.css +6 -12
- package/components/SourceChip/SourceChip.d.ts +2 -0
- package/components/SourceChip/SourceChip.js +16 -37
- package/components/SourceTrail/SourceTrail.css +1 -1
- package/components/SpacingSwatch/SpacingSwatch.css +3 -3
- package/components/SplitButton/SplitButton.css +2 -2
- package/components/SplitButton/SplitButton.js +1 -0
- package/components/SplitPane/SplitPane.js +3 -2
- package/components/Stat/Stat.css +1 -1
- package/components/Stat/Stat.d.ts +2 -0
- package/components/Stat/Stat.js +3 -1
- package/components/Stepper/Stepper.css +5 -5
- package/components/Stepper/Stepper.d.ts +2 -0
- package/components/Stepper/Stepper.js +5 -1
- package/components/StreamingText/StreamingText.css +1 -1
- package/components/Table/Table.css +63 -21
- package/components/Table/Table.d.ts +10 -2
- package/components/Table/Table.js +34 -12
- package/components/TableToolbar/TableToolbar.css +494 -0
- package/components/TableToolbar/TableToolbar.d.ts +281 -0
- package/components/TableToolbar/TableToolbar.js +1322 -0
- package/components/Tabs/Tabs.js +3 -2
- package/components/ThemePicker/ThemePicker.css +189 -0
- package/components/ThemePicker/ThemePicker.d.ts +67 -0
- package/components/ThemePicker/ThemePicker.js +165 -0
- package/components/ThemeToggle/ThemeToggle.css +82 -0
- package/components/ThemeToggle/ThemeToggle.d.ts +42 -0
- package/components/ThemeToggle/ThemeToggle.js +98 -0
- package/components/ThemeToggle/colorMode.d.ts +42 -0
- package/components/ThemeToggle/colorMode.js +26 -0
- package/components/ThemeToggle/useColorMode.d.ts +8 -0
- package/components/ThemeToggle/useColorMode.js +44 -0
- package/components/ThreadPanel/ThreadPanel.css +19 -5
- package/components/ThreadPanel/ThreadPanel.d.ts +6 -1
- package/components/ThreadPanel/ThreadPanel.js +11 -7
- package/components/ThreadTabs/ThreadTabs.css +8 -1
- package/components/ThreadTabs/ThreadTabs.js +4 -2
- package/components/TimePicker/TimePicker.css +12 -6
- package/components/TimePicker/TimePicker.d.ts +17 -4
- package/components/TimePicker/TimePicker.js +32 -3
- package/components/Timeline/Timeline.css +8 -8
- package/components/Timeline/Timeline.d.ts +2 -0
- package/components/Timeline/Timeline.js +5 -2
- package/components/Toast/Toast.css +5 -5
- package/components/Toast/Toast.js +3 -2
- package/components/ToggleGroup/ToggleGroup.css +11 -1
- package/components/ToggleSwitch/ToggleSwitch.css +5 -5
- package/components/ToggleSwitch/ToggleSwitch.js +1 -0
- package/components/ToolCall/ToolCall.css +3 -3
- package/components/Toolbar/Toolbar.js +4 -2
- package/components/Tooltip/Tooltip.css +25 -25
- package/components/Tooltip/Tooltip.d.ts +2 -2
- package/components/Tooltip/Tooltip.js +16 -60
- package/components/TopAppBar/TopAppBar.css +7 -5
- package/components/TopAppBar/TopAppBar.js +3 -1
- package/components/TreeView/TreeView.css +1 -1
- package/components/TreeView/TreeView.js +4 -3
- package/components/UsageCard/UsageCard.d.ts +2 -0
- package/components/UsageCard/UsageCard.js +3 -0
- package/components/Widget/Widget.css +1 -1
- package/components/Widget/Widget.d.ts +2 -0
- package/components/Widget/Widget.js +3 -2
- package/components/WorldMap/WorldMap.css +1 -0
- package/components/registry.json +37 -5
- package/components/registry.json.d.ts +37 -5
- package/components/registry.json.js +1 -1
- package/fonts/material-symbols.css +13 -1
- package/fonts/presets/anton-400-latin-ext.woff2 +0 -0
- package/fonts/presets/anton-400-latin.woff2 +0 -0
- package/fonts/presets/work-sans-300-700-latin-ext.woff2 +0 -0
- package/fonts/presets/work-sans-300-700-latin.woff2 +0 -0
- package/index.d.ts +12 -0
- package/index.js +34 -2
- package/package.json +13 -1
- package/tokens/base.css +84 -0
- package/tokens/motion.d.ts +4 -0
- package/tokens/motion.js +4 -0
- package/tokens/presets/contrast.css +6 -2
- package/tokens/presets/coral.css +4 -2
- package/tokens/presets/forest.css +6 -0
- package/tokens/presets/gold.css +10 -2
- package/tokens/presets/marquee.css +299 -0
- package/tokens/presets/mono.css +4 -2
- package/tokens/presets/pink.css +10 -0
- package/tokens/presets/presets.css +1 -0
- package/tokens/presets/terminal.css +8 -2
- package/tokens/presets/violet.css +10 -0
- package/tokens/presets/warm.css +4 -0
- package/tokens/presets/zest.css +6 -0
- package/tokens/registry.d.ts +1 -1
- package/tokens/registry.json +32 -1
- package/tokens/registry.json.d.ts +32 -1
- package/tokens/registry.json.js +1 -1
- package/tokens/tokens-dark.css +53 -0
- package/tokens/tokens-forced-colors.css +31 -0
- package/tokens/tokens-light.css +66 -0
- package/tokens/tokens-primitives.css +9 -0
- package/tokens/tokens.css +1 -0
- package/cli/templates/chat/app/api/chat/feedback/route.d.ts +0 -3
- package/cli/templates/chat/app/api/chat/followups/route.d.ts +0 -3
- package/cli/templates/chat/app/api/chat/guardrails.d.ts +0 -10
- package/cli/templates/chat/app/api/chat/route.d.ts +0 -4
- package/cli/templates/chat/components/chat/ChatMount.d.ts +0 -1
- 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 -->
|
|
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
|
-
|
|
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 -->
|
|
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
|
+
};
|
package/behaviors/focusable.d.ts
CHANGED
|
@@ -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;
|