@eylulg/ui 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +328 -2
- package/dist/chrome/Anchor.d.ts +3 -0
- package/dist/chrome/Anchor.js +14 -0
- package/dist/chrome/Anchor.js.map +1 -0
- package/dist/chrome/AppShell.d.ts +28 -0
- package/dist/chrome/AppShell.js +57 -0
- package/dist/chrome/AppShell.js.map +1 -0
- package/dist/chrome/BrandLogo.d.ts +13 -0
- package/dist/chrome/BrandLogo.js +33 -0
- package/dist/chrome/BrandLogo.js.map +1 -0
- package/dist/chrome/BrandMark.d.ts +12 -0
- package/dist/chrome/BrandMark.js +40 -0
- package/dist/chrome/BrandMark.js.map +1 -0
- package/dist/chrome/LinkRouter.d.ts +19 -0
- package/dist/chrome/LinkRouter.js +28 -0
- package/dist/chrome/LinkRouter.js.map +1 -0
- package/dist/chrome/MobileMenu.d.ts +19 -0
- package/dist/chrome/MobileMenu.js +52 -0
- package/dist/chrome/MobileMenu.js.map +1 -0
- package/dist/chrome/ProjectSwitcher.d.ts +30 -0
- package/dist/chrome/ProjectSwitcher.js +64 -0
- package/dist/chrome/ProjectSwitcher.js.map +1 -0
- package/dist/chrome/ProjectSwitcherMenu.d.ts +13 -0
- package/dist/chrome/ProjectSwitcherMenu.js +50 -0
- package/dist/chrome/ProjectSwitcherMenu.js.map +1 -0
- package/dist/chrome/SidebarNav.d.ts +34 -0
- package/dist/chrome/SidebarNav.js +106 -0
- package/dist/chrome/SidebarNav.js.map +1 -0
- package/dist/chrome/SiteFooter.d.ts +37 -0
- package/dist/chrome/SiteFooter.js +105 -0
- package/dist/chrome/SiteFooter.js.map +1 -0
- package/dist/chrome/TextSizeToggle.d.ts +11 -0
- package/dist/chrome/TextSizeToggle.js +38 -0
- package/dist/chrome/TextSizeToggle.js.map +1 -0
- package/dist/chrome/ThemeToggle.d.ts +26 -0
- package/dist/chrome/ThemeToggle.js +100 -0
- package/dist/chrome/ThemeToggle.js.map +1 -0
- package/dist/chrome/ThemeToggleMenu.d.ts +16 -0
- package/dist/chrome/ThemeToggleMenu.js +42 -0
- package/dist/chrome/ThemeToggleMenu.js.map +1 -0
- package/dist/chrome/TopNav.d.ts +42 -0
- package/dist/chrome/TopNav.js +117 -0
- package/dist/chrome/TopNav.js.map +1 -0
- package/dist/chrome/brandLogoPath.d.ts +2 -0
- package/dist/chrome/brandLogoPath.js +7 -0
- package/dist/chrome/brandLogoPath.js.map +1 -0
- package/dist/chrome/index.d.ts +28 -0
- package/dist/chrome/index.js +15 -0
- package/dist/chrome/projects.d.ts +28 -0
- package/dist/chrome/projects.js +105 -0
- package/dist/chrome/projects.js.map +1 -0
- package/dist/chrome/themeChoices.d.ts +6 -0
- package/dist/chrome/themeChoices.js +18 -0
- package/dist/chrome/themeChoices.js.map +1 -0
- package/dist/chrome/themeScript.d.ts +16 -0
- package/dist/chrome/themeScript.js +20 -0
- package/dist/chrome/themeScript.js.map +1 -0
- package/dist/chrome/types.d.ts +17 -0
- package/dist/chrome/useTextSize.d.ts +16 -0
- package/dist/chrome/useTextSize.js +64 -0
- package/dist/chrome/useTextSize.js.map +1 -0
- package/dist/chrome/useTheme.d.ts +19 -0
- package/dist/chrome/useTheme.js +86 -0
- package/dist/chrome/useTheme.js.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +39 -0
- package/dist/components/Avatar/Avatar.js +122 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +19 -0
- package/dist/components/Badge/Badge.js +77 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +18 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +40 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -0
- package/dist/components/Breadcrumbs/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/index.js +2 -0
- package/dist/components/Button/Button.d.ts +39 -0
- package/dist/components/Button/Button.js +73 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/buttonStyles.d.ts +21 -0
- package/dist/components/Button/buttonStyles.js +32 -0
- package/dist/components/Button/buttonStyles.js.map +1 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Button/index.js +4 -0
- package/dist/components/Card/Card.d.ts +47 -0
- package/dist/components/Card/Card.js +119 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Card/index.js +2 -0
- package/dist/components/Chart/BarChart.d.ts +24 -0
- package/dist/components/Chart/BarChart.js +327 -0
- package/dist/components/Chart/BarChart.js.map +1 -0
- package/dist/components/Chart/ChartFrame.d.ts +27 -0
- package/dist/components/Chart/ChartFrame.js +80 -0
- package/dist/components/Chart/ChartFrame.js.map +1 -0
- package/dist/components/Chart/ChartLegend.d.ts +28 -0
- package/dist/components/Chart/ChartLegend.js +53 -0
- package/dist/components/Chart/ChartLegend.js.map +1 -0
- package/dist/components/Chart/ChartTable.d.ts +11 -0
- package/dist/components/Chart/ChartTable.js +48 -0
- package/dist/components/Chart/ChartTable.js.map +1 -0
- package/dist/components/Chart/ChartTooltip.d.ts +33 -0
- package/dist/components/Chart/ChartTooltip.js +56 -0
- package/dist/components/Chart/ChartTooltip.js.map +1 -0
- package/dist/components/Chart/HeatGrid.d.ts +50 -0
- package/dist/components/Chart/HeatGrid.js +256 -0
- package/dist/components/Chart/HeatGrid.js.map +1 -0
- package/dist/components/Chart/LineChart.d.ts +23 -0
- package/dist/components/Chart/LineChart.js +248 -0
- package/dist/components/Chart/LineChart.js.map +1 -0
- package/dist/components/Chart/format.d.ts +24 -0
- package/dist/components/Chart/format.js +134 -0
- package/dist/components/Chart/format.js.map +1 -0
- package/dist/components/Chart/geometry.d.ts +11 -0
- package/dist/components/Chart/geometry.js +69 -0
- package/dist/components/Chart/geometry.js.map +1 -0
- package/dist/components/Chart/index.d.ts +9 -0
- package/dist/components/Chart/index.js +6 -0
- package/dist/components/Chart/interaction.d.ts +43 -0
- package/dist/components/Chart/interaction.js +106 -0
- package/dist/components/Chart/interaction.js.map +1 -0
- package/dist/components/Chart/labels.d.ts +3 -0
- package/dist/components/Chart/labels.js +23 -0
- package/dist/components/Chart/labels.js.map +1 -0
- package/dist/components/Chart/scale.d.ts +15 -0
- package/dist/components/Chart/scale.js +54 -0
- package/dist/components/Chart/scale.js.map +1 -0
- package/dist/components/Chart/series.d.ts +14 -0
- package/dist/components/Chart/series.js +72 -0
- package/dist/components/Chart/series.js.map +1 -0
- package/dist/components/Chart/summary.d.ts +8 -0
- package/dist/components/Chart/summary.js +56 -0
- package/dist/components/Chart/summary.js.map +1 -0
- package/dist/components/Chart/types.d.ts +50 -0
- package/dist/components/Chart/useElementWidth.d.ts +6 -0
- package/dist/components/Chart/useElementWidth.js +25 -0
- package/dist/components/Chart/useElementWidth.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +9 -0
- package/dist/components/Checkbox/Checkbox.js +36 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +22 -0
- package/dist/components/CodeBlock/CodeBlock.js +56 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
- package/dist/components/CodeBlock/index.d.ts +2 -0
- package/dist/components/CodeBlock/index.js +2 -0
- package/dist/components/Combobox/Combobox.d.ts +34 -0
- package/dist/components/Combobox/Combobox.js +106 -0
- package/dist/components/Combobox/Combobox.js.map +1 -0
- package/dist/components/Combobox/index.d.ts +2 -0
- package/dist/components/Combobox/index.js +2 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +74 -0
- package/dist/components/CommandPalette/CommandPalette.js +51 -0
- package/dist/components/CommandPalette/CommandPalette.js.map +1 -0
- package/dist/components/CommandPalette/CommandPaletteOverlay.d.ts +11 -0
- package/dist/components/CommandPalette/CommandPaletteOverlay.js +180 -0
- package/dist/components/CommandPalette/CommandPaletteOverlay.js.map +1 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CommandPalette/index.js +2 -0
- package/dist/components/DatePicker/DatePicker.d.ts +25 -0
- package/dist/components/DatePicker/DatePicker.js +142 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/index.js +2 -0
- package/dist/components/Dialog/Dialog.d.ts +37 -0
- package/dist/components/Dialog/Dialog.js +33 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Dialog/DialogOverlay.d.ts +3 -0
- package/dist/components/Dialog/DialogOverlay.js +72 -0
- package/dist/components/Dialog/DialogOverlay.js.map +1 -0
- package/dist/components/Dialog/index.d.ts +2 -0
- package/dist/components/Dialog/index.js +2 -0
- package/dist/components/Drawer/Drawer.d.ts +36 -0
- package/dist/components/Drawer/Drawer.js +33 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/DrawerOverlay.d.ts +3 -0
- package/dist/components/Drawer/DrawerOverlay.js +71 -0
- package/dist/components/Drawer/DrawerOverlay.js.map +1 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Drawer/index.js +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +49 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +52 -0
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuParts.d.ts +6 -0
- package/dist/components/DropdownMenu/DropdownMenuParts.js +76 -0
- package/dist/components/DropdownMenu/DropdownMenuParts.js.map +1 -0
- package/dist/components/DropdownMenu/index.d.ts +2 -0
- package/dist/components/DropdownMenu/index.js +2 -0
- package/dist/components/EmptyState/EmptyState.d.ts +19 -0
- package/dist/components/EmptyState/EmptyState.js +51 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/EmptyState/index.js +2 -0
- package/dist/components/FileDropZone/FileDropZone.d.ts +41 -0
- package/dist/components/FileDropZone/FileDropZone.js +94 -0
- package/dist/components/FileDropZone/FileDropZone.js.map +1 -0
- package/dist/components/FileDropZone/index.d.ts +2 -0
- package/dist/components/FileDropZone/index.js +2 -0
- package/dist/components/IconButton/IconButton.d.ts +17 -0
- package/dist/components/IconButton/IconButton.js +37 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/IconButton/index.js +2 -0
- package/dist/components/Input/Input.d.ts +21 -0
- package/dist/components/Input/Input.js +43 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Kbd/Kbd.d.ts +16 -0
- package/dist/components/Kbd/Kbd.js +35 -0
- package/dist/components/Kbd/Kbd.js.map +1 -0
- package/dist/components/Kbd/index.d.ts +2 -0
- package/dist/components/Kbd/index.js +2 -0
- package/dist/components/PageHeader/PageHeader.d.ts +18 -0
- package/dist/components/PageHeader/PageHeader.js +45 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +2 -0
- package/dist/components/PageHeader/index.js +2 -0
- package/dist/components/Pagination/Pagination.d.ts +32 -0
- package/dist/components/Pagination/Pagination.js +124 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +2 -0
- package/dist/components/Pagination/index.js +2 -0
- package/dist/components/Popover/Popover.d.ts +27 -0
- package/dist/components/Popover/Popover.js +33 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/PopoverOverlay.d.ts +3 -0
- package/dist/components/Popover/PopoverOverlay.js +39 -0
- package/dist/components/Popover/PopoverOverlay.js.map +1 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +19 -0
- package/dist/components/ProgressBar/ProgressBar.js +52 -0
- package/dist/components/ProgressBar/ProgressBar.js.map +1 -0
- package/dist/components/ProgressBar/index.d.ts +2 -0
- package/dist/components/ProgressBar/index.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +14 -0
- package/dist/components/RadioGroup/RadioGroup.js +46 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/RadioGroup/index.js +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +32 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +55 -0
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SegmentedControl/index.js +2 -0
- package/dist/components/Select/Select.d.ts +28 -0
- package/dist/components/Select/Select.js +64 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +13 -0
- package/dist/components/Skeleton/Skeleton.js +33 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton/index.js +2 -0
- package/dist/components/Spinner/Spinner.d.ts +12 -0
- package/dist/components/Spinner/Spinner.js +29 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/Spinner/index.d.ts +2 -0
- package/dist/components/Spinner/index.js +2 -0
- package/dist/components/Stat/Stat.d.ts +49 -0
- package/dist/components/Stat/Stat.js +125 -0
- package/dist/components/Stat/Stat.js.map +1 -0
- package/dist/components/Stat/index.d.ts +2 -0
- package/dist/components/Stat/index.js +2 -0
- package/dist/components/Switch/Switch.d.ts +11 -0
- package/dist/components/Switch/Switch.js +39 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Table/Table.d.ts +41 -0
- package/dist/components/Table/Table.js +121 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Tabs/Tabs.d.ts +10 -0
- package/dist/components/Tabs/Tabs.js +58 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tag/Tag.d.ts +16 -0
- package/dist/components/Tag/Tag.js +48 -0
- package/dist/components/Tag/Tag.js.map +1 -0
- package/dist/components/Tag/index.d.ts +2 -0
- package/dist/components/Tag/index.js +2 -0
- package/dist/components/Textarea/Textarea.d.ts +28 -0
- package/dist/components/Textarea/Textarea.js +30 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/Toast/Toast.d.ts +52 -0
- package/dist/components/Toast/Toast.js +77 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/ToastItem.d.ts +6 -0
- package/dist/components/Toast/ToastItem.js +127 -0
- package/dist/components/Toast/ToastItem.js.map +1 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip/Tooltip.js +38 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Tooltip/TooltipOverlay.d.ts +5 -0
- package/dist/components/Tooltip/TooltipOverlay.js +27 -0
- package/dist/components/Tooltip/TooltipOverlay.js.map +1 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/index.js +2 -0
- package/dist/fonts.css +21 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +43 -0
- package/dist/internal/Field.d.ts +13 -0
- package/dist/internal/Field.js +29 -0
- package/dist/internal/Field.js.map +1 -0
- package/dist/internal/LazyDialogTrigger.d.ts +8 -0
- package/dist/internal/LazyDialogTrigger.js +15 -0
- package/dist/internal/LazyDialogTrigger.js.map +1 -0
- package/dist/internal/PreloadOnIntent.d.ts +15 -0
- package/dist/internal/PreloadOnIntent.js +26 -0
- package/dist/internal/PreloadOnIntent.js.map +1 -0
- package/dist/internal/Spinner.d.ts +3 -0
- package/dist/internal/Spinner.js +14 -0
- package/dist/internal/Spinner.js.map +1 -0
- package/dist/internal/focusRing.d.ts +2 -0
- package/dist/internal/focusRing.js +7 -0
- package/dist/internal/focusRing.js.map +1 -0
- package/dist/internal/lazyModule.d.ts +15 -0
- package/dist/internal/lazyModule.js +54 -0
- package/dist/internal/lazyModule.js.map +1 -0
- package/dist/internal/surfaces.d.ts +8 -0
- package/dist/internal/surfaces.js +13 -0
- package/dist/internal/surfaces.js.map +1 -0
- package/dist/internal/types.d.ts +5 -0
- package/dist/internal/useLazyMenuTrigger.d.ts +23 -0
- package/dist/internal/useLazyMenuTrigger.js +47 -0
- package/dist/internal/useLazyMenuTrigger.js.map +1 -0
- package/dist/reset.css +52 -0
- package/dist/styles/themes/scales.d.ts +2 -0
- package/dist/styles/themes/scales.js +132 -0
- package/dist/styles/themes/scales.js.map +1 -0
- package/dist/styles/themes/variants.d.ts +41 -0
- package/dist/styles/themes/variants.js +180 -0
- package/dist/styles/themes/variants.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/theme.css +557 -0
- package/dist/themes/all.css +158 -0
- package/dist/themes/assistant.css +25 -0
- package/dist/themes/control-room.css +25 -0
- package/dist/themes/plain-language.css +25 -0
- package/dist/themes/portfolio.css +25 -0
- package/dist/themes/review.css +25 -0
- package/dist/themes/sudoku.css +25 -0
- package/dist/themes/tokens.css +25 -0
- package/dist/themes/watchlist.css +25 -0
- package/dist/themes/workspace.css +25 -0
- package/dist/tokens.css +351 -0
- package/dist/utils/cx.d.ts +23 -0
- package/dist/utils/cx.js +25 -0
- package/dist/utils/cx.js.map +1 -0
- package/dist/utils/cxLite.d.ts +12 -0
- package/dist/utils/cxLite.js +23 -0
- package/dist/utils/cxLite.js.map +1 -0
- package/package.json +304 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Key, type ToggleButtonGroupProps, type ToggleButtonProps } from 'react-aria-components';
|
|
3
|
+
import type { IconComponent } from '../../internal/types';
|
|
4
|
+
export type SegmentedControlSize = 'sm' | 'md';
|
|
5
|
+
export interface SegmentedControlProps extends Omit<ToggleButtonGroupProps, 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'children'> {
|
|
6
|
+
/** Accessible name of the group, such as "View". Required unless `aria-labelledby` is set. */
|
|
7
|
+
'aria-label'?: string;
|
|
8
|
+
/** The chosen segment, for a controlled control. */
|
|
9
|
+
selectedKey?: Key;
|
|
10
|
+
/** The segment chosen at first, for an uncontrolled control. */
|
|
11
|
+
defaultSelectedKey?: Key;
|
|
12
|
+
/** Called with the id of the segment the user chose. One segment is always chosen. */
|
|
13
|
+
onSelectionChange?: (key: Key) => void;
|
|
14
|
+
size?: SegmentedControlSize;
|
|
15
|
+
/** SegmentedControlItem elements. */
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export interface SegmentedControlItemProps extends Omit<ToggleButtonProps, 'children' | 'id'> {
|
|
19
|
+
id: Key;
|
|
20
|
+
/** Leading icon component, for example from lucide-react. */
|
|
21
|
+
icon?: IconComponent;
|
|
22
|
+
/** Text of the segment. Without it, pass `aria-label`. */
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A switch between a few views of the same content, such as list or board and
|
|
27
|
+
* write or preview. One segment is always chosen. Tab enters the group, the
|
|
28
|
+
* arrow keys move focus between segments, and Space or Enter chooses the
|
|
29
|
+
* focused one. Use Tabs instead when each choice shows its own panel of content.
|
|
30
|
+
*/
|
|
31
|
+
export declare function SegmentedControl({ selectedKey, defaultSelectedKey, onSelectionChange, size, className, children, ...props }: SegmentedControlProps): import("react").JSX.Element;
|
|
32
|
+
export declare function SegmentedControlItem({ icon: Icon, children, className, ...props }: SegmentedControlItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { focusRing } from "../../internal/focusRing.js";
|
|
3
|
+
import { cx } from "../../utils/cx.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { ToggleButton, ToggleButtonGroup, composeRenderProps } from "react-aria-components";
|
|
7
|
+
// src/components/SegmentedControl/SegmentedControl.tsx
|
|
8
|
+
var group = "group/segmented inline-flex items-center gap-0.5 rounded-md border border-default bg-secondary p-0.5";
|
|
9
|
+
var segment = [
|
|
10
|
+
"h-control-sm px-3 text-sm group-data-[size=sm]/segmented:h-control-xs group-data-[size=sm]/segmented:px-2.5 group-data-[size=sm]/segmented:text-xs",
|
|
11
|
+
"inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-sm font-medium whitespace-nowrap text-secondary transition-colors",
|
|
12
|
+
"data-hovered:bg-hover data-hovered:text-primary",
|
|
13
|
+
"data-selected:bg-primary data-selected:text-primary data-selected:shadow-xs",
|
|
14
|
+
"data-disabled:cursor-not-allowed data-disabled:text-disabled",
|
|
15
|
+
focusRing
|
|
16
|
+
].join(" ");
|
|
17
|
+
/**
|
|
18
|
+
* A switch between a few views of the same content, such as list or board and
|
|
19
|
+
* write or preview. One segment is always chosen. Tab enters the group, the
|
|
20
|
+
* arrow keys move focus between segments, and Space or Enter chooses the
|
|
21
|
+
* focused one. Use Tabs instead when each choice shows its own panel of content.
|
|
22
|
+
*/
|
|
23
|
+
function SegmentedControl({ selectedKey, defaultSelectedKey, onSelectionChange, size = "md", className, children, ...props }) {
|
|
24
|
+
const [uncontrolledKey, setUncontrolledKey] = useState(defaultSelectedKey);
|
|
25
|
+
const current = selectedKey ?? uncontrolledKey;
|
|
26
|
+
function handleSelectionChange(keys) {
|
|
27
|
+
const [next] = keys;
|
|
28
|
+
if (next === void 0 || next === current) return;
|
|
29
|
+
setUncontrolledKey(next);
|
|
30
|
+
onSelectionChange?.(next);
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ jsx(ToggleButtonGroup, {
|
|
33
|
+
...props,
|
|
34
|
+
"data-size": size,
|
|
35
|
+
selectionMode: "single",
|
|
36
|
+
disallowEmptySelection: true,
|
|
37
|
+
selectedKeys: current === void 0 ? [] : [current],
|
|
38
|
+
onSelectionChange: handleSelectionChange,
|
|
39
|
+
className: composeRenderProps(className, (consumer) => cx(group, consumer)),
|
|
40
|
+
children
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function SegmentedControlItem({ icon: Icon, children, className, ...props }) {
|
|
44
|
+
return /* @__PURE__ */ jsxs(ToggleButton, {
|
|
45
|
+
...props,
|
|
46
|
+
className: composeRenderProps(className, (consumer) => cx(segment, consumer)),
|
|
47
|
+
children: [Icon && /* @__PURE__ */ jsx(Icon, {
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
className: "size-4 shrink-0"
|
|
50
|
+
}), children]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { SegmentedControl, SegmentedControlItem };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { useState, type ReactNode } from 'react';\nimport {\n ToggleButton,\n ToggleButtonGroup,\n composeRenderProps,\n type Key,\n type ToggleButtonGroupProps,\n type ToggleButtonProps,\n} from 'react-aria-components';\nimport { focusRing } from '../../internal/focusRing';\nimport type { IconComponent } from '../../internal/types';\nimport { cx } from '../../utils/cx';\n\nexport type SegmentedControlSize = 'sm' | 'md';\n\nexport interface SegmentedControlProps extends Omit<\n ToggleButtonGroupProps,\n 'selectionMode' | 'selectedKeys' | 'defaultSelectedKeys' | 'onSelectionChange' | 'children'\n> {\n /** Accessible name of the group, such as \"View\". Required unless `aria-labelledby` is set. */\n 'aria-label'?: string;\n /** The chosen segment, for a controlled control. */\n selectedKey?: Key;\n /** The segment chosen at first, for an uncontrolled control. */\n defaultSelectedKey?: Key;\n /** Called with the id of the segment the user chose. One segment is always chosen. */\n onSelectionChange?: (key: Key) => void;\n size?: SegmentedControlSize;\n /** SegmentedControlItem elements. */\n children: ReactNode;\n}\n\nexport interface SegmentedControlItemProps extends Omit<ToggleButtonProps, 'children' | 'id'> {\n id: Key;\n /** Leading icon component, for example from lucide-react. */\n icon?: IconComponent;\n /** Text of the segment. Without it, pass `aria-label`. */\n children?: ReactNode;\n}\n\nconst group =\n 'group/segmented inline-flex items-center gap-0.5 rounded-md border border-default bg-secondary p-0.5';\nconst segment = [\n 'h-control-sm px-3 text-sm group-data-[size=sm]/segmented:h-control-xs group-data-[size=sm]/segmented:px-2.5 group-data-[size=sm]/segmented:text-xs',\n 'inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-sm font-medium whitespace-nowrap text-secondary transition-colors',\n 'data-hovered:bg-hover data-hovered:text-primary',\n 'data-selected:bg-primary data-selected:text-primary data-selected:shadow-xs',\n 'data-disabled:cursor-not-allowed data-disabled:text-disabled',\n focusRing,\n].join(' ');\n\n/**\n * A switch between a few views of the same content, such as list or board and\n * write or preview. One segment is always chosen. Tab enters the group, the\n * arrow keys move focus between segments, and Space or Enter chooses the\n * focused one. Use Tabs instead when each choice shows its own panel of content.\n */\nexport function SegmentedControl({\n selectedKey,\n defaultSelectedKey,\n onSelectionChange,\n size = 'md',\n className,\n children,\n ...props\n}: SegmentedControlProps) {\n const [uncontrolledKey, setUncontrolledKey] = useState(defaultSelectedKey);\n const current = selectedKey ?? uncontrolledKey;\n\n function handleSelectionChange(keys: Set<Key>) {\n const [next] = keys;\n if (next === undefined || next === current) return;\n setUncontrolledKey(next);\n onSelectionChange?.(next);\n }\n\n return (\n <ToggleButtonGroup\n {...props}\n data-size={size}\n selectionMode='single'\n disallowEmptySelection\n selectedKeys={current === undefined ? [] : [current]}\n onSelectionChange={handleSelectionChange}\n className={composeRenderProps(className, (consumer) => cx(group, consumer))}\n >\n {children}\n </ToggleButtonGroup>\n );\n}\n\nexport function SegmentedControlItem({\n icon: Icon,\n children,\n className,\n ...props\n}: SegmentedControlItemProps) {\n return (\n <ToggleButton\n {...props}\n className={composeRenderProps(className, (consumer) => cx(segment, consumer))}\n >\n {Icon && <Icon aria-hidden='true' className='size-4 shrink-0' />}\n {children}\n </ToggleButton>\n );\n}\n"],"mappings":";;;;;;;AAwCA,IAAM,QACJ;AACF,IAAM,UAAU;CACd;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAAG;;;;;;;AAQV,SAAgB,iBAAiB,EAC/B,aACA,oBACA,mBACA,OAAO,MACP,WACA,UACA,GAAG,SACqB;CACxB,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,kBAAkB;CACzE,MAAM,UAAU,eAAe;CAE/B,SAAS,sBAAsB,MAAgB;EAC7C,MAAM,CAAC,QAAQ;EACf,IAAI,SAAS,KAAA,KAAa,SAAS,SAAS;EAC5C,mBAAmB,IAAI;EACvB,oBAAoB,IAAI;CAC1B;CAEA,OACE,oBAAC,mBAAD;EACE,GAAI;EACJ,aAAW;EACX,eAAc;EACd,wBAAA;EACA,cAAc,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC,OAAO;EACnD,mBAAmB;EACnB,WAAW,mBAAmB,YAAY,aAAa,GAAG,OAAO,QAAQ,CAAC;EAEzE;CACgB,CAAA;AAEvB;AAEA,SAAgB,qBAAqB,EACnC,MAAM,MACN,UACA,WACA,GAAG,SACyB;CAC5B,OACE,qBAAC,cAAD;EACE,GAAI;EACJ,WAAW,mBAAmB,YAAY,aAAa,GAAG,SAAS,QAAQ,CAAC;EAF9E,UAAA,CAIG,QAAQ,oBAAC,MAAD;GAAM,eAAY;GAAO,WAAU;EAAmB,CAAA,GAC9D,QACW;;AAElB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import { type ButtonProps as AriaButtonProps, type ListBoxItemProps, type SelectProps as AriaSelectProps } from 'react-aria-components';
|
|
3
|
+
export interface SelectProps<T extends object> extends Omit<AriaSelectProps<T, 'single'>, 'children' | 'selectionMode'> {
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
hint?: ReactNode;
|
|
6
|
+
errorMessage?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Items for dynamic collections. Pair with a render function as children. */
|
|
9
|
+
items?: Iterable<T>;
|
|
10
|
+
children: ReactNode | ((item: T) => ReactNode);
|
|
11
|
+
/** Ref to the trigger button, for example to move focus to the select. */
|
|
12
|
+
ref?: Ref<HTMLButtonElement>;
|
|
13
|
+
/**
|
|
14
|
+
* Key presses on the trigger while the list is closed, for example Escape to
|
|
15
|
+
* cancel a form. React Aria stops propagation after calling it; call
|
|
16
|
+
* `event.continuePropagation()` to let the key reach parent handlers too.
|
|
17
|
+
*/
|
|
18
|
+
onKeyDown?: AriaButtonProps['onKeyDown'];
|
|
19
|
+
}
|
|
20
|
+
export declare function Select<T extends object>({ label, hint, errorMessage, placeholder, items, children, ref, onKeyDown, className, isInvalid, ...props }: SelectProps<T>): import("react").JSX.Element;
|
|
21
|
+
export interface SelectItemProps extends ListBoxItemProps {
|
|
22
|
+
/**
|
|
23
|
+
* Supporting text under the label. It joins the option's accessible name
|
|
24
|
+
* after the label, and is left out of the trigger once the option is chosen.
|
|
25
|
+
*/
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
}
|
|
28
|
+
export declare function SelectItem({ className, children, description, ...props }: SelectItemProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FieldErrorMessage, FieldHint, FieldLabel } from "../../internal/Field.js";
|
|
3
|
+
import { focusRing } from "../../internal/focusRing.js";
|
|
4
|
+
import { cx } from "../../utils/cx.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
7
|
+
import { Button, ListBox, ListBoxItem, Popover, Select, SelectValue, composeRenderProps } from "react-aria-components";
|
|
8
|
+
// src/components/Select/Select.tsx
|
|
9
|
+
function Select$1({ label, hint, errorMessage, placeholder = "Select an option", items, children, ref, onKeyDown, className, isInvalid, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsxs(Select, {
|
|
11
|
+
...props,
|
|
12
|
+
placeholder,
|
|
13
|
+
isInvalid: isInvalid ?? Boolean(errorMessage),
|
|
14
|
+
className: composeRenderProps(className, (consumer) => cx("group flex flex-col gap-1.5", consumer)),
|
|
15
|
+
children: [
|
|
16
|
+
label && /* @__PURE__ */ jsx(FieldLabel, { children: label }),
|
|
17
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
18
|
+
ref,
|
|
19
|
+
onKeyDown,
|
|
20
|
+
className: cx("flex h-control-md w-full cursor-pointer items-center gap-2 rounded-md border border-control bg-primary px-3 text-left text-md text-primary shadow-xs", "data-disabled:cursor-not-allowed data-disabled:border-disabled data-disabled:bg-disabled data-disabled:text-disabled", "group-data-invalid:border-error", focusRing),
|
|
21
|
+
children: [/* @__PURE__ */ jsx(SelectValue, { className: "flex-1 truncate data-placeholder:text-placeholder [&_[data-item-description]]:hidden" }), /* @__PURE__ */ jsx(ChevronDown, {
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
className: "size-4 shrink-0 text-fg-tertiary"
|
|
24
|
+
})]
|
|
25
|
+
}),
|
|
26
|
+
hint && !errorMessage && /* @__PURE__ */ jsx(FieldHint, { children: hint }),
|
|
27
|
+
/* @__PURE__ */ jsx(FieldErrorMessage, { children: errorMessage }),
|
|
28
|
+
/* @__PURE__ */ jsx(Popover, {
|
|
29
|
+
offset: 4,
|
|
30
|
+
className: "w-(--trigger-width) overflow-auto rounded-md border border-subtle bg-elevated p-1 shadow-lg outline-none",
|
|
31
|
+
children: /* @__PURE__ */ jsx(ListBox, {
|
|
32
|
+
items,
|
|
33
|
+
className: "max-h-72 outline-none",
|
|
34
|
+
children
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function SelectItem({ className, children, description, ...props }) {
|
|
41
|
+
const textValue = props.textValue ?? (typeof children === "string" ? children : void 0);
|
|
42
|
+
return /* @__PURE__ */ jsx(ListBoxItem, {
|
|
43
|
+
...props,
|
|
44
|
+
textValue,
|
|
45
|
+
className: composeRenderProps(className, (consumer) => cx("flex cursor-pointer items-center gap-2 rounded-sm px-item-x py-item-y text-md text-primary outline-none", "data-disabled:cursor-not-allowed data-disabled:text-disabled data-focus-visible:outline-2 data-focus-visible:-outline-offset-2 data-focus-visible:outline-focus data-focused:bg-hover", consumer)),
|
|
46
|
+
children: composeRenderProps(children, (content, { isSelected }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
47
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
48
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: "truncate",
|
|
50
|
+
children: content
|
|
51
|
+
}), description && /* @__PURE__ */ jsx("span", {
|
|
52
|
+
"data-item-description": "",
|
|
53
|
+
className: "truncate text-xs text-tertiary",
|
|
54
|
+
children: description
|
|
55
|
+
})]
|
|
56
|
+
}), isSelected && /* @__PURE__ */ jsx(Check, {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
className: "size-4 shrink-0 text-fg-brand"
|
|
59
|
+
})] }))
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export { Select$1 as Select, SelectItem };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","names":["Select","AriaSelect","AriaButton","_Fragment"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import { Check, ChevronDown } from 'lucide-react';\nimport type { ReactNode, Ref } from 'react';\nimport {\n Button as AriaButton,\n ListBox,\n ListBoxItem,\n Popover,\n Select as AriaSelect,\n SelectValue,\n composeRenderProps,\n type ButtonProps as AriaButtonProps,\n type ListBoxItemProps,\n type SelectProps as AriaSelectProps,\n} from 'react-aria-components';\nimport { FieldErrorMessage, FieldHint, FieldLabel } from '../../internal/Field';\nimport { focusRing } from '../../internal/focusRing';\nimport { cx } from '../../utils/cx';\n\nexport interface SelectProps<T extends object> extends Omit<\n AriaSelectProps<T, 'single'>,\n 'children' | 'selectionMode'\n> {\n label?: ReactNode;\n hint?: ReactNode;\n errorMessage?: string;\n placeholder?: string;\n /** Items for dynamic collections. Pair with a render function as children. */\n items?: Iterable<T>;\n children: ReactNode | ((item: T) => ReactNode);\n /** Ref to the trigger button, for example to move focus to the select. */\n ref?: Ref<HTMLButtonElement>;\n /**\n * Key presses on the trigger while the list is closed, for example Escape to\n * cancel a form. React Aria stops propagation after calling it; call\n * `event.continuePropagation()` to let the key reach parent handlers too.\n */\n onKeyDown?: AriaButtonProps['onKeyDown'];\n}\n\nexport function Select<T extends object>({\n label,\n hint,\n errorMessage,\n placeholder = 'Select an option',\n items,\n children,\n ref,\n onKeyDown,\n className,\n isInvalid,\n ...props\n}: SelectProps<T>) {\n return (\n <AriaSelect\n {...props}\n placeholder={placeholder}\n isInvalid={isInvalid ?? Boolean(errorMessage)}\n className={composeRenderProps(className, (consumer) =>\n cx('group flex flex-col gap-1.5', consumer),\n )}\n >\n {label && <FieldLabel>{label}</FieldLabel>}\n <AriaButton\n ref={ref}\n onKeyDown={onKeyDown}\n className={cx(\n 'flex h-control-md w-full cursor-pointer items-center gap-2 rounded-md border border-control bg-primary px-3 text-left text-md text-primary shadow-xs',\n 'data-disabled:cursor-not-allowed data-disabled:border-disabled data-disabled:bg-disabled data-disabled:text-disabled',\n 'group-data-invalid:border-error',\n focusRing,\n )}\n >\n <SelectValue className='flex-1 truncate data-placeholder:text-placeholder [&_[data-item-description]]:hidden' />\n <ChevronDown aria-hidden='true' className='size-4 shrink-0 text-fg-tertiary' />\n </AriaButton>\n {hint && !errorMessage && <FieldHint>{hint}</FieldHint>}\n <FieldErrorMessage>{errorMessage}</FieldErrorMessage>\n <Popover\n offset={4}\n className='w-(--trigger-width) overflow-auto rounded-md border border-subtle bg-elevated p-1 shadow-lg outline-none'\n >\n <ListBox items={items} className='max-h-72 outline-none'>\n {children}\n </ListBox>\n </Popover>\n </AriaSelect>\n );\n}\n\nexport interface SelectItemProps extends ListBoxItemProps {\n /**\n * Supporting text under the label. It joins the option's accessible name\n * after the label, and is left out of the trigger once the option is chosen.\n */\n description?: ReactNode;\n}\n\nexport function SelectItem({ className, children, description, ...props }: SelectItemProps) {\n const textValue = props.textValue ?? (typeof children === 'string' ? children : undefined);\n return (\n <ListBoxItem\n {...props}\n textValue={textValue}\n className={composeRenderProps(className, (consumer) =>\n cx(\n 'flex cursor-pointer items-center gap-2 rounded-sm px-item-x py-item-y text-md text-primary outline-none',\n 'data-disabled:cursor-not-allowed data-disabled:text-disabled data-focus-visible:outline-2 data-focus-visible:-outline-offset-2 data-focus-visible:outline-focus data-focused:bg-hover',\n consumer,\n ),\n )}\n >\n {composeRenderProps(children, (content, { isSelected }) => (\n <>\n <span className='flex min-w-0 flex-1 flex-col'>\n <span className='truncate'>{content}</span>\n {description && (\n <span data-item-description='' className='truncate text-xs text-tertiary'>\n {description}\n </span>\n )}\n </span>\n {isSelected && <Check aria-hidden='true' className='size-4 shrink-0 text-fg-brand' />}\n </>\n ))}\n </ListBoxItem>\n );\n}\n"],"mappings":";;;;;;;;AAuCA,SAAgBA,SAAyB,EACvC,OACA,MACA,cACA,cAAc,oBACd,OACA,UACA,KACA,WACA,WACA,WACA,GAAG,SACc;CACjB,OACE,qBAACC,QAAD;EACE,GAAI;EACS;EACb,WAAW,aAAa,QAAQ,YAAY;EAC5C,WAAW,mBAAmB,YAAY,aACxC,GAAG,+BAA+B,QAAQ,CAC5C;EANF,UAAA;GAQG,SAAS,oBAAC,YAAD,EAAA,UAAa,MAAkB,CAAA;GACzC,qBAACC,QAAD;IACO;IACM;IACX,WAAW,GACT,wJACA,wHACA,mCACA,SACF;IARF,UAAA,CAUE,oBAAC,aAAD,EAAa,WAAU,uFAAwF,CAAA,GAC/G,oBAAC,aAAD;KAAa,eAAY;KAAO,WAAU;IAAoC,CAAA,CACpE;;GACX,QAAQ,CAAC,gBAAgB,oBAAC,WAAD,EAAA,UAAY,KAAgB,CAAA;GACtD,oBAAC,mBAAD,EAAA,UAAoB,aAAgC,CAAA;GACpD,oBAAC,SAAD;IACE,QAAQ;IACR,WAAU;IAEV,UAAA,oBAAC,SAAD;KAAgB;KAAO,WAAU;KAC9B;IACM,CAAA;GACF,CAAA;EACC;;AAEhB;AAUA,SAAgB,WAAW,EAAE,WAAW,UAAU,aAAa,GAAG,SAA0B;CAC1F,MAAM,YAAY,MAAM,cAAc,OAAO,aAAa,WAAW,WAAW,KAAA;CAChF,OACE,oBAAC,aAAD;EACE,GAAI;EACO;EACX,WAAW,mBAAmB,YAAY,aACxC,GACE,2GACA,yLACA,QACF,CACF;EAEC,UAAA,mBAAmB,WAAW,SAAS,EAAE,iBACxC,qBAAAC,UAAA,EAAA,UAAA,CACE,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,oBAAC,QAAD;IAAM,WAAU;IAAY,UAAA;GAAc,CAAA,GACzC,eACC,oBAAC,QAAD;IAAM,yBAAsB;IAAG,WAAU;IACtC,UAAA;GACG,CAAA,CAEJ;EACL,CAAA,GAAA,cAAc,oBAAC,OAAD;GAAO,eAAY;GAAO,WAAU;EAAiC,CAAA,CACpF,EAAA,CAAA,CACH;CACU,CAAA;AAEjB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
export type SkeletonShape = 'text' | 'circle' | 'rect';
|
|
3
|
+
export interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
shape?: SkeletonShape;
|
|
5
|
+
/** Number of text lines. Only used with shape="text". */
|
|
6
|
+
lines?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Placeholder shown while content loads. It is hidden from assistive
|
|
10
|
+
* technology; mark the loading region with aria-busy and announce progress
|
|
11
|
+
* there instead.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Skeleton({ shape, lines, className, ...props }: SkeletonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/Skeleton/Skeleton.tsx
|
|
5
|
+
var shapes = {
|
|
6
|
+
text: "h-4 w-full rounded-xs",
|
|
7
|
+
circle: "size-10 rounded-full",
|
|
8
|
+
rect: "h-24 w-full rounded-md"
|
|
9
|
+
};
|
|
10
|
+
var block = "animate-pulse bg-tertiary motion-reduce:animate-none";
|
|
11
|
+
/**
|
|
12
|
+
* Placeholder shown while content loads. It is hidden from assistive
|
|
13
|
+
* technology; mark the loading region with aria-busy and announce progress
|
|
14
|
+
* there instead.
|
|
15
|
+
*/
|
|
16
|
+
function Skeleton({ shape = "text", lines = 1, className, ...props }) {
|
|
17
|
+
if (shape === "text" && lines > 1) return /* @__PURE__ */ jsx("div", {
|
|
18
|
+
...props,
|
|
19
|
+
"aria-hidden": "true",
|
|
20
|
+
"data-shape": shape,
|
|
21
|
+
className: cx("flex flex-col gap-2", className),
|
|
22
|
+
children: Array.from({ length: lines }, (_, index) => /* @__PURE__ */ jsx("div", { className: cx(block, shapes.text, index === lines - 1 && "w-3/5") }, index))
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx("div", {
|
|
25
|
+
...props,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
"data-shape": shape,
|
|
28
|
+
className: cx(block, shapes[shape], className)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { Skeleton };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=Skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.js","names":[],"sources":["../../../src/components/Skeleton/Skeleton.tsx"],"sourcesContent":["import type { HTMLAttributes } from 'react';\nimport { cx } from '../../utils/cx';\n\nexport type SkeletonShape = 'text' | 'circle' | 'rect';\n\nexport interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {\n shape?: SkeletonShape;\n /** Number of text lines. Only used with shape=\"text\". */\n lines?: number;\n}\n\nconst shapes: Record<SkeletonShape, string> = {\n text: 'h-4 w-full rounded-xs',\n circle: 'size-10 rounded-full',\n rect: 'h-24 w-full rounded-md',\n};\n\nconst block = 'animate-pulse bg-tertiary motion-reduce:animate-none';\n\n/**\n * Placeholder shown while content loads. It is hidden from assistive\n * technology; mark the loading region with aria-busy and announce progress\n * there instead.\n */\nexport function Skeleton({ shape = 'text', lines = 1, className, ...props }: SkeletonProps) {\n if (shape === 'text' && lines > 1) {\n return (\n <div\n {...props}\n aria-hidden='true'\n data-shape={shape}\n className={cx('flex flex-col gap-2', className)}\n >\n {Array.from({ length: lines }, (_, index) => (\n <div key={index} className={cx(block, shapes.text, index === lines - 1 && 'w-3/5')} />\n ))}\n </div>\n );\n }\n return (\n <div\n {...props}\n aria-hidden='true'\n data-shape={shape}\n className={cx(block, shapes[shape], className)}\n />\n );\n}\n"],"mappings":";;;;AAWA,IAAM,SAAwC;CAC5C,MAAM;CACN,QAAQ;CACR,MAAM;AACR;AAEA,IAAM,QAAQ;;;;;;AAOd,SAAgB,SAAS,EAAE,QAAQ,QAAQ,QAAQ,GAAG,WAAW,GAAG,SAAwB;CAC1F,IAAI,UAAU,UAAU,QAAQ,GAC9B,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,eAAY;EACZ,cAAY;EACZ,WAAW,GAAG,uBAAuB,SAAS;EAE7C,UAAA,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UACjC,oBAAC,OAAD,EAAiB,WAAW,GAAG,OAAO,OAAO,MAAM,UAAU,QAAQ,KAAK,OAAO,EAAI,GAA3E,KAA2E,CACtF;CACE,CAAA;CAGT,OACE,oBAAC,OAAD;EACE,GAAI;EACJ,eAAY;EACZ,cAAY;EACZ,WAAW,GAAG,OAAO,OAAO,QAAQ,SAAS;CAC9C,CAAA;AAEL"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SpinnerSize = 'sm' | 'md' | 'lg';
|
|
2
|
+
export interface SpinnerProps {
|
|
3
|
+
/**
|
|
4
|
+
* Announced text, such as "Loading issues". With a label the spinner is a
|
|
5
|
+
* polite status region; without one it is decorative and hidden from
|
|
6
|
+
* assistive technology, so the surrounding UI must convey the state.
|
|
7
|
+
*/
|
|
8
|
+
label?: string;
|
|
9
|
+
size?: SpinnerSize;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function Spinner({ label, size, className }: SpinnerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { LoaderCircle } from "lucide-react";
|
|
5
|
+
// src/components/Spinner/Spinner.tsx
|
|
6
|
+
var sizes = {
|
|
7
|
+
sm: "size-4",
|
|
8
|
+
md: "size-5",
|
|
9
|
+
lg: "size-8"
|
|
10
|
+
};
|
|
11
|
+
var spin = "shrink-0 animate-spin text-fg-brand motion-reduce:[animation-duration:3s]";
|
|
12
|
+
function Spinner({ label, size = "md", className }) {
|
|
13
|
+
const icon = /* @__PURE__ */ jsx(LoaderCircle, {
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
className: cx(spin, sizes[size], !label && className)
|
|
16
|
+
});
|
|
17
|
+
if (!label) return icon;
|
|
18
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
19
|
+
role: "status",
|
|
20
|
+
className: cx("inline-flex", className),
|
|
21
|
+
children: [icon, /* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "sr-only",
|
|
23
|
+
children: label
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { Spinner };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.js","names":[],"sources":["../../../src/components/Spinner/Spinner.tsx"],"sourcesContent":["import { LoaderCircle } from 'lucide-react';\nimport { cx } from '../../utils/cx';\n\nexport type SpinnerSize = 'sm' | 'md' | 'lg';\n\nexport interface SpinnerProps {\n /**\n * Announced text, such as \"Loading issues\". With a label the spinner is a\n * polite status region; without one it is decorative and hidden from\n * assistive technology, so the surrounding UI must convey the state.\n */\n label?: string;\n size?: SpinnerSize;\n className?: string;\n}\n\nconst sizes: Record<SpinnerSize, string> = {\n sm: 'size-4',\n md: 'size-5',\n lg: 'size-8',\n};\n\n/* Reduced motion slows the spin rather than stopping it, so progress stays visible. */\nconst spin = 'shrink-0 animate-spin text-fg-brand motion-reduce:[animation-duration:3s]';\n\nexport function Spinner({ label, size = 'md', className }: SpinnerProps) {\n const icon = (\n <LoaderCircle aria-hidden='true' className={cx(spin, sizes[size], !label && className)} />\n );\n if (!label) return icon;\n return (\n <span role='status' className={cx('inline-flex', className)}>\n {icon}\n <span className='sr-only'>{label}</span>\n </span>\n );\n}\n"],"mappings":";;;;;AAgBA,IAAM,QAAqC;CACzC,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAGA,IAAM,OAAO;AAEb,SAAgB,QAAQ,EAAE,OAAO,OAAO,MAAM,aAA2B;CACvE,MAAM,OACJ,oBAAC,cAAD;EAAc,eAAY;EAAO,WAAW,GAAG,MAAM,MAAM,OAAO,CAAC,SAAS,SAAS;CAAI,CAAA;CAE3F,IAAI,CAAC,OAAO,OAAO;CACnB,OACE,qBAAC,QAAD;EAAM,MAAK;EAAS,WAAW,GAAG,eAAe,SAAS;EAA1D,UAAA,CACG,MACD,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA;EAAY,CAAA,CACnC;;AAEV"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type StatTrend = 'up' | 'down' | 'neutral';
|
|
3
|
+
export interface StatDelta {
|
|
4
|
+
/** The change, as shown, for example "12%" or "+3". */
|
|
5
|
+
value: ReactNode;
|
|
6
|
+
trend: StatTrend;
|
|
7
|
+
/** Context after the change, for example "vs last week". */
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the trend is good news. Defaults to up being positive; set it for
|
|
11
|
+
* metrics where a fall is good, such as error rate or latency.
|
|
12
|
+
*/
|
|
13
|
+
isPositive?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type StatSize = 'sm' | 'md';
|
|
16
|
+
export interface StatProps extends HTMLAttributes<HTMLDListElement> {
|
|
17
|
+
label: ReactNode;
|
|
18
|
+
value: ReactNode;
|
|
19
|
+
/** `sm` fits a compact summary bar; `md` is the dashboard size. */
|
|
20
|
+
size?: StatSize;
|
|
21
|
+
/** A line of context under the value, such as "of 200 reviewed". */
|
|
22
|
+
detail?: ReactNode;
|
|
23
|
+
delta?: StatDelta;
|
|
24
|
+
/** Inline chart slot, usually a Sparkline. */
|
|
25
|
+
sparkline?: ReactNode;
|
|
26
|
+
/** Draws the stat on a bordered card surface. */
|
|
27
|
+
isCard?: boolean;
|
|
28
|
+
/** Words announced before the delta value, so the trend never relies on colour or the icon. */
|
|
29
|
+
trendLabels?: Record<StatTrend, string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A single metric: label, value, an optional detail line, an optional change
|
|
33
|
+
* and an optional sparkline. It is a description list, so a screen reader
|
|
34
|
+
* announces the label as the term and the value as its description. Put
|
|
35
|
+
* several Stats in a grid or flex container, not inside another list.
|
|
36
|
+
*/
|
|
37
|
+
export declare function Stat({ label, value, size, detail, delta, sparkline, isCard, trendLabels, className, ...props }: StatProps): import("react").JSX.Element;
|
|
38
|
+
export interface SparklineProps {
|
|
39
|
+
values: number[];
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
/** Gives the chart role="img" with this name. Without it the chart is decorative. */
|
|
43
|
+
'aria-label'?: string;
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Builds the SVG points for a line through `values`, scaled to the box with a 1px inset. */
|
|
47
|
+
export declare function sparklinePoints(values: number[], width: number, height: number): string;
|
|
48
|
+
/** A tiny line chart in the current text colour. */
|
|
49
|
+
export declare function Sparkline({ values, width, height, 'aria-label': ariaLabel, className, }: SparklineProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { ArrowDownRight, ArrowUpRight, Minus } from "lucide-react";
|
|
5
|
+
// src/components/Stat/Stat.tsx
|
|
6
|
+
var defaultTrendLabels = {
|
|
7
|
+
up: "Up",
|
|
8
|
+
down: "Down",
|
|
9
|
+
neutral: "No change"
|
|
10
|
+
};
|
|
11
|
+
var trendIcons = {
|
|
12
|
+
up: ArrowUpRight,
|
|
13
|
+
down: ArrowDownRight,
|
|
14
|
+
neutral: Minus
|
|
15
|
+
};
|
|
16
|
+
var tone = {
|
|
17
|
+
positive: "text-success",
|
|
18
|
+
negative: "text-error",
|
|
19
|
+
neutral: "text-tertiary"
|
|
20
|
+
};
|
|
21
|
+
var card = "rounded-xl border border-subtle bg-elevated p-card shadow-xs";
|
|
22
|
+
var sizes = {
|
|
23
|
+
sm: {
|
|
24
|
+
root: "gap-1",
|
|
25
|
+
label: "text-xs",
|
|
26
|
+
value: "text-xl"
|
|
27
|
+
},
|
|
28
|
+
md: {
|
|
29
|
+
root: "gap-2",
|
|
30
|
+
label: "text-sm",
|
|
31
|
+
value: "text-3xl"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function toneFor({ trend, isPositive }) {
|
|
35
|
+
if (trend === "neutral") return "neutral";
|
|
36
|
+
return isPositive ?? trend === "up" ? "positive" : "negative";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A single metric: label, value, an optional detail line, an optional change
|
|
40
|
+
* and an optional sparkline. It is a description list, so a screen reader
|
|
41
|
+
* announces the label as the term and the value as its description. Put
|
|
42
|
+
* several Stats in a grid or flex container, not inside another list.
|
|
43
|
+
*/
|
|
44
|
+
function Stat({ label, value, size = "md", detail, delta, sparkline, isCard = false, trendLabels = defaultTrendLabels, className, ...props }) {
|
|
45
|
+
const TrendIcon = delta ? trendIcons[delta.trend] : null;
|
|
46
|
+
return /* @__PURE__ */ jsxs("dl", {
|
|
47
|
+
...props,
|
|
48
|
+
className: cx("flex flex-col", sizes[size].root, isCard && card, className),
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx("dt", {
|
|
51
|
+
className: cx("font-medium text-tertiary", sizes[size].label),
|
|
52
|
+
children: label
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsxs("dd", {
|
|
55
|
+
className: "flex items-end justify-between gap-4",
|
|
56
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
57
|
+
className: cx("font-data font-semibold text-primary tabular-nums", sizes[size].value),
|
|
58
|
+
children: value
|
|
59
|
+
}), sparkline && /* @__PURE__ */ jsx("span", {
|
|
60
|
+
className: "shrink-0 text-fg-brand",
|
|
61
|
+
children: sparkline
|
|
62
|
+
})]
|
|
63
|
+
}),
|
|
64
|
+
detail && /* @__PURE__ */ jsx("dd", {
|
|
65
|
+
className: "text-sm text-tertiary",
|
|
66
|
+
children: detail
|
|
67
|
+
}),
|
|
68
|
+
delta && TrendIcon && /* @__PURE__ */ jsxs("dd", {
|
|
69
|
+
className: "flex flex-wrap items-center gap-1 text-sm",
|
|
70
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
71
|
+
className: cx("inline-flex items-center gap-0.5 font-medium", tone[toneFor(delta)]),
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(TrendIcon, {
|
|
74
|
+
"aria-hidden": "true",
|
|
75
|
+
className: "size-4"
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: "sr-only",
|
|
79
|
+
children: trendLabels[delta.trend]
|
|
80
|
+
}),
|
|
81
|
+
delta.value
|
|
82
|
+
]
|
|
83
|
+
}), delta.label && /* @__PURE__ */ jsx("span", {
|
|
84
|
+
className: "text-tertiary",
|
|
85
|
+
children: delta.label
|
|
86
|
+
})]
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Builds the SVG points for a line through `values`, scaled to the box with a 1px inset. */
|
|
92
|
+
function sparklinePoints(values, width, height) {
|
|
93
|
+
if (values.length === 0) return "";
|
|
94
|
+
const min = Math.min(...values);
|
|
95
|
+
const span = Math.max(...values) - min;
|
|
96
|
+
const step = values.length > 1 ? (width - 2) / (values.length - 1) : 0;
|
|
97
|
+
return values.map((value, index) => {
|
|
98
|
+
const x = 1 + index * step;
|
|
99
|
+
const y = span === 0 ? height / 2 : 1 + (1 - (value - min) / span) * (height - 2);
|
|
100
|
+
return `${Number(x.toFixed(2))},${Number(y.toFixed(2))}`;
|
|
101
|
+
}).join(" ");
|
|
102
|
+
}
|
|
103
|
+
/** A tiny line chart in the current text colour. */
|
|
104
|
+
function Sparkline({ values, width = 96, height = 32, "aria-label": ariaLabel, className }) {
|
|
105
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
106
|
+
width,
|
|
107
|
+
height,
|
|
108
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
109
|
+
role: ariaLabel ? "img" : void 0,
|
|
110
|
+
"aria-label": ariaLabel,
|
|
111
|
+
"aria-hidden": ariaLabel ? void 0 : true,
|
|
112
|
+
className,
|
|
113
|
+
children: /* @__PURE__ */ jsx("polyline", {
|
|
114
|
+
points: sparklinePoints(values, width, height),
|
|
115
|
+
fill: "none",
|
|
116
|
+
stroke: "currentColor",
|
|
117
|
+
strokeWidth: 2,
|
|
118
|
+
strokeLinecap: "round",
|
|
119
|
+
strokeLinejoin: "round"
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export { Sparkline, Stat, sparklinePoints };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=Stat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stat.js","names":[],"sources":["../../../src/components/Stat/Stat.tsx"],"sourcesContent":["import { ArrowDownRight, ArrowUpRight, Minus } from 'lucide-react';\nimport type { HTMLAttributes, ReactNode } from 'react';\nimport type { IconComponent } from '../../internal/types';\nimport { cx } from '../../utils/cx';\n\nexport type StatTrend = 'up' | 'down' | 'neutral';\n\nexport interface StatDelta {\n /** The change, as shown, for example \"12%\" or \"+3\". */\n value: ReactNode;\n trend: StatTrend;\n /** Context after the change, for example \"vs last week\". */\n label?: ReactNode;\n /**\n * Whether the trend is good news. Defaults to up being positive; set it for\n * metrics where a fall is good, such as error rate or latency.\n */\n isPositive?: boolean;\n}\n\nexport type StatSize = 'sm' | 'md';\n\nexport interface StatProps extends HTMLAttributes<HTMLDListElement> {\n label: ReactNode;\n value: ReactNode;\n /** `sm` fits a compact summary bar; `md` is the dashboard size. */\n size?: StatSize;\n /** A line of context under the value, such as \"of 200 reviewed\". */\n detail?: ReactNode;\n delta?: StatDelta;\n /** Inline chart slot, usually a Sparkline. */\n sparkline?: ReactNode;\n /** Draws the stat on a bordered card surface. */\n isCard?: boolean;\n /** Words announced before the delta value, so the trend never relies on colour or the icon. */\n trendLabels?: Record<StatTrend, string>;\n}\n\nconst defaultTrendLabels: Record<StatTrend, string> = {\n up: 'Up',\n down: 'Down',\n neutral: 'No change',\n};\n\nconst trendIcons: Record<StatTrend, IconComponent> = {\n up: ArrowUpRight,\n down: ArrowDownRight,\n neutral: Minus,\n};\n\nconst tone = {\n positive: 'text-success',\n negative: 'text-error',\n neutral: 'text-tertiary',\n} as const;\n\nconst card = 'rounded-xl border border-subtle bg-elevated p-card shadow-xs';\n\nconst sizes: Record<StatSize, { root: string; label: string; value: string }> = {\n sm: { root: 'gap-1', label: 'text-xs', value: 'text-xl' },\n md: { root: 'gap-2', label: 'text-sm', value: 'text-3xl' },\n};\n\nfunction toneFor({ trend, isPositive }: StatDelta): keyof typeof tone {\n if (trend === 'neutral') return 'neutral';\n const positive = isPositive ?? trend === 'up';\n return positive ? 'positive' : 'negative';\n}\n\n/**\n * A single metric: label, value, an optional detail line, an optional change\n * and an optional sparkline. It is a description list, so a screen reader\n * announces the label as the term and the value as its description. Put\n * several Stats in a grid or flex container, not inside another list.\n */\nexport function Stat({\n label,\n value,\n size = 'md',\n detail,\n delta,\n sparkline,\n isCard = false,\n trendLabels = defaultTrendLabels,\n className,\n ...props\n}: StatProps) {\n const TrendIcon = delta ? trendIcons[delta.trend] : null;\n\n return (\n <dl {...props} className={cx('flex flex-col', sizes[size].root, isCard && card, className)}>\n <dt className={cx('font-medium text-tertiary', sizes[size].label)}>{label}</dt>\n <dd className='flex items-end justify-between gap-4'>\n <span\n className={cx('font-data font-semibold text-primary tabular-nums', sizes[size].value)}\n >\n {value}\n </span>\n {sparkline && <span className='shrink-0 text-fg-brand'>{sparkline}</span>}\n </dd>\n {detail && <dd className='text-sm text-tertiary'>{detail}</dd>}\n {delta && TrendIcon && (\n <dd className='flex flex-wrap items-center gap-1 text-sm'>\n <span\n className={cx('inline-flex items-center gap-0.5 font-medium', tone[toneFor(delta)])}\n >\n <TrendIcon aria-hidden='true' className='size-4' />\n <span className='sr-only'>{trendLabels[delta.trend]}</span>\n {delta.value}\n </span>\n {delta.label && <span className='text-tertiary'>{delta.label}</span>}\n </dd>\n )}\n </dl>\n );\n}\n\nexport interface SparklineProps {\n values: number[];\n width?: number;\n height?: number;\n /** Gives the chart role=\"img\" with this name. Without it the chart is decorative. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/** Builds the SVG points for a line through `values`, scaled to the box with a 1px inset. */\nexport function sparklinePoints(values: number[], width: number, height: number): string {\n if (values.length === 0) return '';\n const min = Math.min(...values);\n const max = Math.max(...values);\n const span = max - min;\n const step = values.length > 1 ? (width - 2) / (values.length - 1) : 0;\n return values\n .map((value, index) => {\n const x = 1 + index * step;\n const y = span === 0 ? height / 2 : 1 + (1 - (value - min) / span) * (height - 2);\n return `${Number(x.toFixed(2))},${Number(y.toFixed(2))}`;\n })\n .join(' ');\n}\n\n/** A tiny line chart in the current text colour. */\nexport function Sparkline({\n values,\n width = 96,\n height = 32,\n 'aria-label': ariaLabel,\n className,\n}: SparklineProps) {\n return (\n <svg\n width={width}\n height={height}\n viewBox={`0 0 ${width} ${height}`}\n role={ariaLabel ? 'img' : undefined}\n aria-label={ariaLabel}\n aria-hidden={ariaLabel ? undefined : true}\n className={className}\n >\n <polyline\n points={sparklinePoints(values, width, height)}\n fill='none'\n stroke='currentColor'\n strokeWidth={2}\n strokeLinecap='round'\n strokeLinejoin='round'\n />\n </svg>\n );\n}\n"],"mappings":";;;;;AAsCA,IAAM,qBAAgD;CACpD,IAAI;CACJ,MAAM;CACN,SAAS;AACX;AAEA,IAAM,aAA+C;CACnD,IAAI;CACJ,MAAM;CACN,SAAS;AACX;AAEA,IAAM,OAAO;CACX,UAAU;CACV,UAAU;CACV,SAAS;AACX;AAEA,IAAM,OAAO;AAEb,IAAM,QAA0E;CAC9E,IAAI;EAAE,MAAM;EAAS,OAAO;EAAW,OAAO;CAAU;CACxD,IAAI;EAAE,MAAM;EAAS,OAAO;EAAW,OAAO;CAAW;AAC3D;AAEA,SAAS,QAAQ,EAAE,OAAO,cAA4C;CACpE,IAAI,UAAU,WAAW,OAAO;CAEhC,OADiB,cAAc,UAAU,OACvB,aAAa;AACjC;;;;;;;AAQA,SAAgB,KAAK,EACnB,OACA,OACA,OAAO,MACP,QACA,OACA,WACA,SAAS,OACT,cAAc,oBACd,WACA,GAAG,SACS;CACZ,MAAM,YAAY,QAAQ,WAAW,MAAM,SAAS;CAEpD,OACE,qBAAC,MAAD;EAAI,GAAI;EAAO,WAAW,GAAG,iBAAiB,MAAM,KAAK,CAAC,MAAM,UAAU,MAAM,SAAS;EAAzF,UAAA;GACE,oBAAC,MAAD;IAAI,WAAW,GAAG,6BAA6B,MAAM,KAAK,CAAC,KAAK;IAAI,UAAA;GAAU,CAAA;GAC9E,qBAAC,MAAD;IAAI,WAAU;IAAd,UAAA,CACE,oBAAC,QAAD;KACE,WAAW,GAAG,qDAAqD,MAAM,KAAK,CAAC,KAAK;KAEnF,UAAA;IACG,CAAA,GACL,aAAa,oBAAC,QAAD;KAAM,WAAU;KAA0B,UAAA;IAAgB,CAAA,CACtE;;GACH,UAAU,oBAAC,MAAD;IAAI,WAAU;IAAyB,UAAA;GAAW,CAAA;GAC5D,SAAS,aACR,qBAAC,MAAD;IAAI,WAAU;IAAd,UAAA,CACE,qBAAC,QAAD;KACE,WAAW,GAAG,gDAAgD,KAAK,QAAQ,KAAK,EAAE;KADpF,UAAA;MAGE,oBAAC,WAAD;OAAW,eAAY;OAAO,WAAU;MAAU,CAAA;MAClD,oBAAC,QAAD;OAAM,WAAU;OAAW,UAAA,YAAY,MAAM;MAAa,CAAA;MACzD,MAAM;KACH;IACL,CAAA,GAAA,MAAM,SAAS,oBAAC,QAAD;KAAM,WAAU;KAAiB,UAAA,MAAM;IAAY,CAAA,CACjE;;EAEJ;;AAER;;AAYA,SAAgB,gBAAgB,QAAkB,OAAe,QAAwB;CACvF,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,MAAM,MAAM,KAAK,IAAI,GAAG,MAAM;CAE9B,MAAM,OADM,KAAK,IAAI,GAAG,MACX,IAAM;CACnB,MAAM,OAAO,OAAO,SAAS,KAAK,QAAQ,MAAM,OAAO,SAAS,KAAK;CACrE,OAAO,OACJ,KAAK,OAAO,UAAU;EACrB,MAAM,IAAI,IAAI,QAAQ;EACtB,MAAM,IAAI,SAAS,IAAI,SAAS,IAAI,KAAK,KAAK,QAAQ,OAAO,SAAS,SAAS;EAC/E,OAAO,GAAG,OAAO,EAAE,QAAQ,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,CAAC,CAAC;CACvD,CAAC,CAAC,CACD,KAAK,GAAG;AACb;;AAGA,SAAgB,UAAU,EACxB,QACA,QAAQ,IACR,SAAS,IACT,cAAc,WACd,aACiB;CACjB,OACE,oBAAC,OAAD;EACS;EACC;EACR,SAAS,OAAO,MAAM,GAAG;EACzB,MAAM,YAAY,QAAQ,KAAA;EAC1B,cAAY;EACZ,eAAa,YAAY,KAAA,IAAY;EAC1B;EAEX,UAAA,oBAAC,YAAD;GACE,QAAQ,gBAAgB,QAAQ,OAAO,MAAM;GAC7C,MAAK;GACL,QAAO;GACP,aAAa;GACb,eAAc;GACd,gBAAe;EAChB,CAAA;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import { type SwitchProps as AriaSwitchProps } from 'react-aria-components';
|
|
3
|
+
export type SwitchSize = 'sm' | 'md';
|
|
4
|
+
export interface SwitchProps extends Omit<AriaSwitchProps, 'children'> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
hint?: ReactNode;
|
|
7
|
+
size?: SwitchSize;
|
|
8
|
+
/** Ref to the native checkbox input that holds focus. Same as `inputRef`, which still works. */
|
|
9
|
+
ref?: Ref<HTMLInputElement>;
|
|
10
|
+
}
|
|
11
|
+
export declare function Switch({ children, hint, size, ref, inputRef, className, ...props }: SwitchProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Switch, composeRenderProps } from "react-aria-components";
|
|
5
|
+
// src/components/Switch/Switch.tsx
|
|
6
|
+
var sizes = {
|
|
7
|
+
sm: {
|
|
8
|
+
track: "h-5 w-9",
|
|
9
|
+
thumb: "size-4 group-data-selected:translate-x-4"
|
|
10
|
+
},
|
|
11
|
+
md: {
|
|
12
|
+
track: "h-6 w-11",
|
|
13
|
+
thumb: "size-5 group-data-selected:translate-x-5"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function Switch$1({ children, hint, size = "md", ref, inputRef, className, ...props }) {
|
|
17
|
+
return /* @__PURE__ */ jsxs(Switch, {
|
|
18
|
+
...props,
|
|
19
|
+
inputRef: ref ?? inputRef,
|
|
20
|
+
className: composeRenderProps(className, (consumer) => cx("group flex cursor-pointer items-start gap-3 text-sm text-secondary", "data-disabled:cursor-not-allowed data-disabled:text-disabled", consumer)),
|
|
21
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
className: cx("flex shrink-0 items-center rounded-full bg-tertiary p-0.5 transition-colors", "group-data-selected:bg-brand-solid", "group-data-disabled:bg-disabled", "group-data-focus-visible:outline-2 group-data-focus-visible:outline-offset-2 group-data-focus-visible:outline-focus", "ring-1 ring-control ring-inset group-data-selected:ring-transparent", sizes[size].track),
|
|
24
|
+
children: /* @__PURE__ */ jsx("span", { className: cx("rounded-full bg-white shadow-sm transition-transform group-data-selected:bg-fg-on-solid motion-reduce:transition-none", sizes[size].thumb) })
|
|
25
|
+
}), (children || hint) && /* @__PURE__ */ jsxs("span", {
|
|
26
|
+
className: "flex flex-col",
|
|
27
|
+
children: [children && /* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "font-medium",
|
|
29
|
+
children
|
|
30
|
+
}), hint && /* @__PURE__ */ jsx("span", {
|
|
31
|
+
className: "text-tertiary",
|
|
32
|
+
children: hint
|
|
33
|
+
})]
|
|
34
|
+
})]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { Switch$1 as Switch };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","names":["Switch","AriaSwitch"],"sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport {\n Switch as AriaSwitch,\n composeRenderProps,\n type SwitchProps as AriaSwitchProps,\n} from 'react-aria-components';\nimport { cx } from '../../utils/cx';\n\nexport type SwitchSize = 'sm' | 'md';\n\nexport interface SwitchProps extends Omit<AriaSwitchProps, 'children'> {\n children?: ReactNode;\n hint?: ReactNode;\n size?: SwitchSize;\n /** Ref to the native checkbox input that holds focus. Same as `inputRef`, which still works. */\n ref?: Ref<HTMLInputElement>;\n}\n\nconst sizes: Record<SwitchSize, { track: string; thumb: string }> = {\n sm: { track: 'h-5 w-9', thumb: 'size-4 group-data-selected:translate-x-4' },\n md: { track: 'h-6 w-11', thumb: 'size-5 group-data-selected:translate-x-5' },\n};\n\nexport function Switch({\n children,\n hint,\n size = 'md',\n ref,\n inputRef,\n className,\n ...props\n}: SwitchProps) {\n return (\n <AriaSwitch\n {...props}\n inputRef={ref ?? inputRef}\n className={composeRenderProps(className, (consumer) =>\n cx(\n 'group flex cursor-pointer items-start gap-3 text-sm text-secondary',\n 'data-disabled:cursor-not-allowed data-disabled:text-disabled',\n consumer,\n ),\n )}\n >\n <span\n aria-hidden='true'\n className={cx(\n 'flex shrink-0 items-center rounded-full bg-tertiary p-0.5 transition-colors',\n 'group-data-selected:bg-brand-solid',\n 'group-data-disabled:bg-disabled',\n 'group-data-focus-visible:outline-2 group-data-focus-visible:outline-offset-2 group-data-focus-visible:outline-focus',\n 'ring-1 ring-control ring-inset group-data-selected:ring-transparent',\n sizes[size].track,\n )}\n >\n <span\n className={cx(\n 'rounded-full bg-white shadow-sm transition-transform group-data-selected:bg-fg-on-solid motion-reduce:transition-none',\n sizes[size].thumb,\n )}\n />\n </span>\n {(children || hint) && (\n <span className='flex flex-col'>\n {children && <span className='font-medium'>{children}</span>}\n {hint && <span className='text-tertiary'>{hint}</span>}\n </span>\n )}\n </AriaSwitch>\n );\n}\n"],"mappings":";;;;;AAkBA,IAAM,QAA8D;CAClE,IAAI;EAAE,OAAO;EAAW,OAAO;CAA2C;CAC1E,IAAI;EAAE,OAAO;EAAY,OAAO;CAA2C;AAC7E;AAEA,SAAgBA,SAAO,EACrB,UACA,MACA,OAAO,MACP,KACA,UACA,WACA,GAAG,SACW;CACd,OACE,qBAACC,QAAD;EACE,GAAI;EACJ,UAAU,OAAO;EACjB,WAAW,mBAAmB,YAAY,aACxC,GACE,sEACA,gEACA,QACF,CACF;EATF,UAAA,CAWE,oBAAC,QAAD;GACE,eAAY;GACZ,WAAW,GACT,+EACA,sCACA,mCACA,uHACA,uEACA,MAAM,KAAK,CAAC,KACd;GAEA,UAAA,oBAAC,QAAD,EACE,WAAW,GACT,yHACA,MAAM,KAAK,CAAC,KACd,EACD,CAAA;EACG,CAAA,IACJ,YAAY,SACZ,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACG,YAAY,oBAAC,QAAD;IAAM,WAAU;IAAe;GAAe,CAAA,GAC1D,QAAQ,oBAAC,QAAD;IAAM,WAAU;IAAiB,UAAA;GAAW,CAAA,CACjD;EAEE,CAAA,CAAA;;AAEhB"}
|