@amberstack/comp-lib 0.0.0-stage → 0.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 +68 -2
- package/dist/amberstack.css +2 -0
- package/dist/components/Accordion/Accordion.d.ts +18 -0
- package/dist/components/Accordion/AccordionContext.d.ts +10 -0
- package/dist/components/Accordion/AccordionItem.d.ts +11 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/ActivityItem/ActivityItem.d.ts +15 -0
- package/dist/components/ActivityItem/index.d.ts +1 -0
- package/dist/components/AreaChart/AreaChart.d.ts +4 -0
- package/dist/components/AreaChart/index.d.ts +1 -0
- package/dist/components/AssetField/AssetField.d.ts +26 -0
- package/dist/components/AssetField/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +19 -0
- package/dist/components/Avatar/AvatarContext.d.ts +3 -0
- package/dist/components/Avatar/AvatarGroup.d.ts +12 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Banner/Banner.d.ts +18 -0
- package/dist/components/Banner/index.d.ts +1 -0
- package/dist/components/BarChart/BarChart.d.ts +25 -0
- package/dist/components/BarChart/index.d.ts +1 -0
- package/dist/components/BlockHeader/BlockHeader.d.ts +22 -0
- package/dist/components/BlockHeader/index.d.ts +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +9 -0
- package/dist/components/Breadcrumb/BreadcrumbItem.d.ts +11 -0
- package/dist/components/Breadcrumb/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +16 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Calendar/Calendar.d.ts +49 -0
- package/dist/components/Calendar/CalendarDay.d.ts +25 -0
- package/dist/components/Calendar/CalendarHeader.d.ts +27 -0
- package/dist/components/Calendar/DateTriggerInternal.d.ts +30 -0
- package/dist/components/Calendar/dateUtils.d.ts +95 -0
- package/dist/components/Calendar/index.d.ts +4 -0
- package/dist/components/Calendar/useDatePopup.d.ts +22 -0
- package/dist/components/Card/Card.d.ts +10 -0
- package/dist/components/Card/CardFooter.d.ts +8 -0
- package/dist/components/Card/CardHeader.d.ts +14 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/CatalogCard/CatalogCard.d.ts +18 -0
- package/dist/components/CatalogCard/index.d.ts +1 -0
- package/dist/components/ChartCard/ChartCard.d.ts +30 -0
- package/dist/components/ChartCard/index.d.ts +1 -0
- package/dist/components/ChartCore/ChartAxes.d.ts +24 -0
- package/dist/components/ChartCore/ChartDataTable.d.ts +19 -0
- package/dist/components/ChartCore/ChartFrame.d.ts +11 -0
- package/dist/components/ChartCore/ChartHoverLayer.d.ts +21 -0
- package/dist/components/ChartCore/chartPlayHelpers.d.ts +11 -0
- package/dist/components/ChartCore/index.d.ts +10 -0
- package/dist/components/ChartCore/paths.d.ts +23 -0
- package/dist/components/ChartCore/scales.d.ts +40 -0
- package/dist/components/ChartCore/series.d.ts +4 -0
- package/dist/components/ChartCore/types.d.ts +38 -0
- package/dist/components/ChartCore/useChartHover.d.ts +25 -0
- package/dist/components/ChartCore/useChartSize.d.ts +6 -0
- package/dist/components/ChartLegend/ChartLegend.d.ts +20 -0
- package/dist/components/ChartLegend/ChartLegendItem.d.ts +19 -0
- package/dist/components/ChartLegend/index.d.ts +4 -0
- package/dist/components/ChartLegend/legendHelpers.d.ts +20 -0
- package/dist/components/ChartLegend/useLegendState.d.ts +10 -0
- package/dist/components/ChartTooltip/ChartTooltip.d.ts +20 -0
- package/dist/components/ChartTooltip/index.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/ChecklistItem/ChecklistItem.d.ts +14 -0
- package/dist/components/ChecklistItem/index.d.ts +1 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +32 -0
- package/dist/components/CommandPalette/CommandPaletteItem.d.ts +14 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +27 -0
- package/dist/components/ConfirmDialog/index.d.ts +1 -0
- package/dist/components/ContentRow/ContentRow.d.ts +20 -0
- package/dist/components/ContentRow/index.d.ts +1 -0
- package/dist/components/CredentialRow/CredentialRow.d.ts +18 -0
- package/dist/components/CredentialRow/index.d.ts +1 -0
- package/dist/components/DataTable/DataTable.d.ts +115 -0
- package/dist/components/DataTable/index.d.ts +1 -0
- package/dist/components/DataTable/useControllable.d.ts +2 -0
- package/dist/components/DateField/DateField.d.ts +4 -0
- package/dist/components/DateField/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +42 -0
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +87 -0
- package/dist/components/DateRangePicker/DateRangePresets.d.ts +24 -0
- package/dist/components/DateRangePicker/DateRangeTrigger.d.ts +10 -0
- package/dist/components/DateRangePicker/index.d.ts +3 -0
- package/dist/components/Dialog/Dialog.d.ts +23 -0
- package/dist/components/Dialog/DialogBody.d.ts +4 -0
- package/dist/components/Dialog/DialogFooter.d.ts +4 -0
- package/dist/components/Dialog/DialogHeader.d.ts +15 -0
- package/dist/components/Dialog/dialogContext.d.ts +23 -0
- package/dist/components/Dialog/index.d.ts +5 -0
- package/dist/components/Dialog/useModalBehaviour.d.ts +27 -0
- package/dist/components/Divider/Divider.d.ts +10 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/DonutChart/DonutChart.d.ts +20 -0
- package/dist/components/DonutChart/index.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +21 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +32 -0
- package/dist/components/DropdownMenu/DropdownMenuCheckboxItem.d.ts +13 -0
- package/dist/components/DropdownMenu/DropdownMenuContext.d.ts +5 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.d.ts +16 -0
- package/dist/components/DropdownMenu/DropdownMenuLabel.d.ts +4 -0
- package/dist/components/DropdownMenu/DropdownMenuSeparator.d.ts +4 -0
- package/dist/components/DropdownMenu/index.d.ts +5 -0
- package/dist/components/EmptyState/EmptyState.d.ts +14 -0
- package/dist/components/EmptyState/index.d.ts +1 -0
- package/dist/components/EnvironmentLabel/EnvironmentLabel.d.ts +10 -0
- package/dist/components/EnvironmentLabel/index.d.ts +1 -0
- package/dist/components/Field/Field.d.ts +26 -0
- package/dist/components/Field/FieldContext.d.ts +17 -0
- package/dist/components/Field/index.d.ts +2 -0
- package/dist/components/Field/useFieldControl.d.ts +34 -0
- package/dist/components/Filters/FilterBar.d.ts +9 -0
- package/dist/components/Filters/FilterChip.d.ts +18 -0
- package/dist/components/Filters/FilterMenu.d.ts +37 -0
- package/dist/components/Filters/index.d.ts +3 -0
- package/dist/components/IconButton/IconButton.d.ts +16 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +14 -0
- package/dist/components/Input/LockedTagInternal.d.ts +2 -0
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/KPI/KPI.d.ts +24 -0
- package/dist/components/KPI/index.d.ts +1 -0
- package/dist/components/KPIGraph/KPIGraph.d.ts +12 -0
- package/dist/components/KPIGraph/index.d.ts +1 -0
- package/dist/components/Kbd/Kbd.d.ts +4 -0
- package/dist/components/Kbd/index.d.ts +1 -0
- package/dist/components/Label/Label.d.ts +14 -0
- package/dist/components/Label/index.d.ts +1 -0
- package/dist/components/LineChart/LineChart.d.ts +4 -0
- package/dist/components/LineChart/SeriesChartInternal.d.ts +30 -0
- package/dist/components/LineChart/index.d.ts +2 -0
- package/dist/components/Link/Link.d.ts +20 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/MediaTile/MediaTile.d.ts +13 -0
- package/dist/components/MediaTile/index.d.ts +1 -0
- package/dist/components/Menu/Menu.d.ts +7 -0
- package/dist/components/Menu/MenuItem.d.ts +20 -0
- package/dist/components/Menu/index.d.ts +3 -0
- package/dist/components/Menu/usePopup.d.ts +46 -0
- package/dist/components/MetricCard/MetricCard.d.ts +26 -0
- package/dist/components/MetricCard/index.d.ts +1 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +42 -0
- package/dist/components/MultiSelect/index.d.ts +1 -0
- package/dist/components/NavGroup/NavGroup.d.ts +17 -0
- package/dist/components/NavGroup/index.d.ts +1 -0
- package/dist/components/NavItem/NavItem.d.ts +28 -0
- package/dist/components/NavItem/index.d.ts +1 -0
- package/dist/components/NodeGraph/GraphNode.d.ts +15 -0
- package/dist/components/NodeGraph/NodeGraph.d.ts +34 -0
- package/dist/components/NodeGraph/index.d.ts +2 -0
- package/dist/components/NodeReference/NodeReference.d.ts +12 -0
- package/dist/components/NodeReference/index.d.ts +1 -0
- package/dist/components/NumberField/NumberField.d.ts +28 -0
- package/dist/components/NumberField/index.d.ts +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +20 -0
- package/dist/components/PageHeader/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +21 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/PickerItem/PickerItem.d.ts +14 -0
- package/dist/components/PickerItem/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +24 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +16 -0
- package/dist/components/ProgressBar/index.d.ts +1 -0
- package/dist/components/ProposedNote/ProposedNote.d.ts +9 -0
- package/dist/components/ProposedNote/index.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +11 -0
- package/dist/components/Radio/RadioGroup.d.ts +22 -0
- package/dist/components/Radio/RadioGroupContext.d.ts +11 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/RangeTabs/RangeTabs.d.ts +21 -0
- package/dist/components/RangeTabs/Segment.d.ts +7 -0
- package/dist/components/RangeTabs/index.d.ts +2 -0
- package/dist/components/ResourceCard/ResourceCard.d.ts +29 -0
- package/dist/components/ResourceCard/index.d.ts +1 -0
- package/dist/components/RichTextField/RichTextField.d.ts +26 -0
- package/dist/components/RichTextField/RichTextTool.d.ts +9 -0
- package/dist/components/RichTextField/RichTextToolbar.d.ts +12 -0
- package/dist/components/RichTextField/index.d.ts +4 -0
- package/dist/components/RichTextField/richTextCommands.d.ts +18 -0
- package/dist/components/ScatterPlot/ScatterPlot.d.ts +41 -0
- package/dist/components/ScatterPlot/index.d.ts +1 -0
- package/dist/components/Search/Search.d.ts +15 -0
- package/dist/components/Search/index.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +38 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/useListbox.d.ts +38 -0
- package/dist/components/SetupStep/SetupStep.d.ts +18 -0
- package/dist/components/SetupStep/index.d.ts +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +17 -0
- package/dist/components/Sidebar/SidebarBrand.d.ts +11 -0
- package/dist/components/Sidebar/SidebarUser.d.ts +13 -0
- package/dist/components/Sidebar/index.d.ts +3 -0
- package/dist/components/Skeleton/Skeleton.d.ts +12 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/SortableRow/SortableRow.d.ts +24 -0
- package/dist/components/SortableRow/index.d.ts +1 -0
- package/dist/components/Sparkline/Sparkline.d.ts +18 -0
- package/dist/components/Sparkline/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +10 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Status/Status.d.ts +8 -0
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/StatusIcon/StatusIcon.d.ts +13 -0
- package/dist/components/StatusIcon/index.d.ts +1 -0
- package/dist/components/Stepper/Step.d.ts +19 -0
- package/dist/components/Stepper/Stepper.d.ts +28 -0
- package/dist/components/Stepper/index.d.ts +2 -0
- package/dist/components/SwitchField/SwitchField.d.ts +10 -0
- package/dist/components/SwitchField/index.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +9 -0
- package/dist/components/Table/TableCell.d.ts +10 -0
- package/dist/components/Table/TableCellActions.d.ts +11 -0
- package/dist/components/Table/TableCellCheckbox.d.ts +7 -0
- package/dist/components/Table/TableCellNumber.d.ts +11 -0
- package/dist/components/Table/TableCellStatus.d.ts +4 -0
- package/dist/components/Table/TableCellText.d.ts +7 -0
- package/dist/components/Table/TableCellTwoLine.d.ts +9 -0
- package/dist/components/Table/TableCellUser.d.ts +11 -0
- package/dist/components/Table/TableContext.d.ts +3 -0
- package/dist/components/Table/TableFooter.d.ts +9 -0
- package/dist/components/Table/TableHeaderCell.d.ts +17 -0
- package/dist/components/Table/TableHeaderRow.d.ts +4 -0
- package/dist/components/Table/TableRow.d.ts +7 -0
- package/dist/components/Table/TableToolbar.d.ts +13 -0
- package/dist/components/Table/index.d.ts +14 -0
- package/dist/components/Table/storyHelpers.d.ts +12 -0
- package/dist/components/Tabs/Tab.d.ts +9 -0
- package/dist/components/Tabs/TabList.d.ts +4 -0
- package/dist/components/Tabs/TabPanel.d.ts +7 -0
- package/dist/components/Tabs/Tabs.d.ts +11 -0
- package/dist/components/Tabs/TabsContext.d.ts +12 -0
- package/dist/components/Tabs/index.d.ts +4 -0
- package/dist/components/Textarea/Textarea.d.ts +9 -0
- package/dist/components/Textarea/index.d.ts +1 -0
- package/dist/components/Toast/Toast.d.ts +23 -0
- package/dist/components/Toast/ToastProvider.d.ts +12 -0
- package/dist/components/Toast/ToastStack.d.ts +11 -0
- package/dist/components/Toast/index.d.ts +4 -0
- package/dist/components/Toast/useToast.d.ts +25 -0
- package/dist/components/Toggle/Toggle.d.ts +14 -0
- package/dist/components/Toggle/index.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +17 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Tooltip/useAnchoredPosition.d.ts +13 -0
- package/dist/components/TopBar/ContextSwitcher.d.ts +10 -0
- package/dist/components/TopBar/TopBar.d.ts +9 -0
- package/dist/components/TopBar/TopBarSeparator.d.ts +4 -0
- package/dist/components/TopBar/index.d.ts +3 -0
- package/dist/components/UnavailableState/UnavailableState.d.ts +18 -0
- package/dist/components/UnavailableState/index.d.ts +1 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +6774 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/cx.d.ts +2 -0
- package/package.json +87 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { type IconName } from '../../icons';
|
|
3
|
+
export type ButtonVariant = 'primary' | 'inverse' | 'secondary' | 'ghost' | 'danger';
|
|
4
|
+
export type ButtonSize = 'md' | 'sm';
|
|
5
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
/** Visual emphasis. Use `primary` at most once per view. */
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
/** Control height: `md` is 34 px and `sm` is 28 px. */
|
|
9
|
+
size?: ButtonSize;
|
|
10
|
+
/** Icon before the label. */
|
|
11
|
+
leadingIcon?: IconName;
|
|
12
|
+
/** Icon after the label, for direction or a menu. */
|
|
13
|
+
trailingIcon?: IconName;
|
|
14
|
+
}
|
|
15
|
+
/** Triggers an action. For navigation, use Link instead. */
|
|
16
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Button';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
import { type DateRange, type WeekStart } from './dateUtils';
|
|
3
|
+
export interface CalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
4
|
+
/** The selected day, when controlled. Use a Date at local midnight. */
|
|
5
|
+
value?: Date | null;
|
|
6
|
+
/** The first selected day, when uncontrolled. */
|
|
7
|
+
defaultValue?: Date | null;
|
|
8
|
+
/** Called with the day, at local midnight, when a day is chosen. */
|
|
9
|
+
onChange?: (date: Date) => void;
|
|
10
|
+
/** Shows a range instead of a single day. The parent decides what a chosen day does to it. */
|
|
11
|
+
range?: DateRange;
|
|
12
|
+
/** While `range` has only a start, previews the range from the start to this day. */
|
|
13
|
+
rangePreview?: Date | null;
|
|
14
|
+
/** Called when the pointer or keyboard focus reaches a day that can be chosen. */
|
|
15
|
+
onDayPreview?: (date: Date) => void;
|
|
16
|
+
/** The first month shown, when controlled. */
|
|
17
|
+
month?: Date;
|
|
18
|
+
/** The first month shown at the start, when uncontrolled. Defaults to the selected month, or else `today`. */
|
|
19
|
+
defaultMonth?: Date;
|
|
20
|
+
/** Called with the first day of the first month shown, when it changes. */
|
|
21
|
+
onMonthChange?: (month: Date) => void;
|
|
22
|
+
/** The earliest day that can be chosen. */
|
|
23
|
+
min?: Date;
|
|
24
|
+
/** The latest day that can be chosen. */
|
|
25
|
+
max?: Date;
|
|
26
|
+
/** Returns true for a day that can't be chosen. */
|
|
27
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
28
|
+
/** BCP 47 locale for names and numbers. Leave out to use the browser's locale. */
|
|
29
|
+
locale?: string;
|
|
30
|
+
/** The first column of the grid: 0 is Sunday and 1 is Monday. */
|
|
31
|
+
weekStartsOn?: WeekStart;
|
|
32
|
+
/** How many months to show. Two months sit side by side, and stack when the container is narrow. */
|
|
33
|
+
months?: 1 | 2;
|
|
34
|
+
/** The day marked as today. Defaults to now. Pass it for repeatable tests. */
|
|
35
|
+
today?: Date;
|
|
36
|
+
/** Shows days of the months around a month. Defaults to true for one month. With two months it would repeat days. */
|
|
37
|
+
showOutsideDays?: boolean;
|
|
38
|
+
/** Moves focus to the current day when the calendar appears, as a date picker popup does. */
|
|
39
|
+
autoFocusDay?: boolean;
|
|
40
|
+
/** Accessible name of the previous month button. */
|
|
41
|
+
previousMonthLabel?: string;
|
|
42
|
+
/** Accessible name of the next month button. */
|
|
43
|
+
nextMonthLabel?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A month grid for choosing a day, following the WAI-ARIA grid pattern with a roving tabindex. Arrow keys move by day
|
|
47
|
+
* and week, Home and End to the ends of the week, PageUp and PageDown by month, and with Shift by year.
|
|
48
|
+
*/
|
|
49
|
+
export declare const Calendar: import("react").ForwardRefExoticComponent<CalendarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes } from 'react';
|
|
2
|
+
export interface CalendarDayProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'value'> {
|
|
3
|
+
/** The day this cell shows. */
|
|
4
|
+
date: Date;
|
|
5
|
+
/** BCP 47 locale for the number and the accessible name. Leave out to use the browser's locale. */
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** Marks the current day with a dot and `aria-current="date"`. */
|
|
8
|
+
today?: boolean;
|
|
9
|
+
/** Fills the day with the accent colour. */
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
/** The first day of a range. */
|
|
12
|
+
rangeStart?: boolean;
|
|
13
|
+
/** The last day of a range. */
|
|
14
|
+
rangeEnd?: boolean;
|
|
15
|
+
/** A day between the two ends of a range. */
|
|
16
|
+
inRange?: boolean;
|
|
17
|
+
/** The range state on this day is only a preview, while the end date is being chosen. It isn't selected yet. */
|
|
18
|
+
preview?: boolean;
|
|
19
|
+
/** A day from the month before or after the one shown. */
|
|
20
|
+
outsideMonth?: boolean;
|
|
21
|
+
/** The day can't be chosen. It uses `aria-disabled`, so the keyboard can still reach it and hear why. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** One day of the month grid: a grid cell holding a button. Render it inside a row of a `role="grid"` table. */
|
|
25
|
+
export declare const CalendarDay: import("react").ForwardRefExoticComponent<CalendarDayProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
export interface CalendarHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Any day in the month to name. */
|
|
4
|
+
month: Date;
|
|
5
|
+
/** BCP 47 locale for the month name. Leave out to use the browser's locale. */
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** The id of the month label, so a grid can name itself with it. */
|
|
8
|
+
labelId?: string;
|
|
9
|
+
/** Called when the previous month button is used. */
|
|
10
|
+
onPrevious?: () => void;
|
|
11
|
+
/** Called when the next month button is used. */
|
|
12
|
+
onNext?: () => void;
|
|
13
|
+
/** Stops the previous month button, at the first month allowed. */
|
|
14
|
+
previousDisabled?: boolean;
|
|
15
|
+
/** Stops the next month button, at the last month allowed. */
|
|
16
|
+
nextDisabled?: boolean;
|
|
17
|
+
/** Leaves out the previous month button, for the later months of a multi-month calendar. Its space stays. */
|
|
18
|
+
hidePrevious?: boolean;
|
|
19
|
+
/** Leaves out the next month button, for the earlier months of a multi-month calendar. Its space stays. */
|
|
20
|
+
hideNext?: boolean;
|
|
21
|
+
/** Accessible name of the previous month button. */
|
|
22
|
+
previousLabel?: string;
|
|
23
|
+
/** Accessible name of the next month button. */
|
|
24
|
+
nextLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
/** The month name with previous and next buttons, above a month grid. Month changes are announced politely. */
|
|
27
|
+
export declare const CalendarHeader: import("react").ForwardRefExoticComponent<CalendarHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type Ref } from 'react';
|
|
2
|
+
export interface DateTriggerInternalProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'children'> {
|
|
3
|
+
/** The formatted value, or null when there is none. */
|
|
4
|
+
text: string | null;
|
|
5
|
+
/** Text shown when there is no value. */
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
/** Shows the error state and sets `aria-invalid`. */
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
/** Read-only look with a "Locked" tag. */
|
|
10
|
+
locked?: boolean;
|
|
11
|
+
/** Marks the control as required. */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
/** Whether the popup is showing. */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/** Shows a clear button while there is a value. */
|
|
16
|
+
clearable?: boolean;
|
|
17
|
+
/** Called when the clear button is used. */
|
|
18
|
+
onClear?: () => void;
|
|
19
|
+
/** Accessible name of the clear button. */
|
|
20
|
+
clearLabel?: string;
|
|
21
|
+
/** The id of the popup, while it shows. */
|
|
22
|
+
popupId?: string;
|
|
23
|
+
/** Receives the outer box, which the popup lines up with. */
|
|
24
|
+
anchorRef?: Ref<HTMLDivElement>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The box of DatePicker and DateRangeTrigger. It looks like the Select control, and like Select it is a select-only
|
|
28
|
+
* combobox. The clear button can't sit inside a button, so the combobox button is stretched over the box instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DateTriggerInternal: import("react").ForwardRefExoticComponent<DateTriggerInternalProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure date maths for the calendar components.
|
|
3
|
+
*
|
|
4
|
+
* A date here is a local calendar day. Every calculation goes through the year, month and day numbers, never through
|
|
5
|
+
* a count of milliseconds, so a daylight saving change or a time zone can't move a date onto another day.
|
|
6
|
+
*/
|
|
7
|
+
/** A range of local calendar days. Either end can be empty while it is being chosen. */
|
|
8
|
+
export interface DateRange {
|
|
9
|
+
/** The first day of the range. */
|
|
10
|
+
start: Date | null;
|
|
11
|
+
/** The last day of the range. */
|
|
12
|
+
end: Date | null;
|
|
13
|
+
}
|
|
14
|
+
/** The first column of the month grid: 0 is Sunday, 1 is Monday and 6 is Saturday. */
|
|
15
|
+
export type WeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
16
|
+
/** The limits on which days can be chosen. */
|
|
17
|
+
export interface DateLimits {
|
|
18
|
+
/** The earliest day that can be chosen. */
|
|
19
|
+
min?: Date;
|
|
20
|
+
/** The latest day that can be chosen. */
|
|
21
|
+
max?: Date;
|
|
22
|
+
/** Returns true for a day that can't be chosen. */
|
|
23
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
24
|
+
}
|
|
25
|
+
/** The limits on a whole range. */
|
|
26
|
+
export interface RangeLimits extends DateLimits {
|
|
27
|
+
/** The fewest days a range can include, counting both ends. */
|
|
28
|
+
minDays?: number;
|
|
29
|
+
/** The most days a range can include, counting both ends. */
|
|
30
|
+
maxDays?: number;
|
|
31
|
+
/** Lets a range run across a disabled day. Neither end can be on one. */
|
|
32
|
+
allowDisabledInRange?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** The same calendar day at local midnight. */
|
|
35
|
+
export declare function startOfDay(date: Date): Date;
|
|
36
|
+
/** True when both are the same calendar day. Empty values are never the same. */
|
|
37
|
+
export declare function isSameDay(a: Date | null | undefined, b: Date | null | undefined): boolean;
|
|
38
|
+
/** True when both are in the same month of the same year. */
|
|
39
|
+
export declare function isSameMonth(a: Date, b: Date): boolean;
|
|
40
|
+
/** Negative when `a` is the earlier day, positive when it is the later day, and 0 when they are the same day. */
|
|
41
|
+
export declare function compareDays(a: Date, b: Date): number;
|
|
42
|
+
/** The number of days from `a` to `b`. Negative when `b` is earlier. */
|
|
43
|
+
export declare function daysBetween(a: Date, b: Date): number;
|
|
44
|
+
/** The number of days in a range, counting both ends. */
|
|
45
|
+
export declare function rangeLength(a: Date, b: Date): number;
|
|
46
|
+
/** The calendar day `amount` days away. */
|
|
47
|
+
export declare function addDays(date: Date, amount: number): Date;
|
|
48
|
+
/** The same day `amount` months away. A day the target month doesn't have becomes its last day: 31 Jan to 28 Feb. */
|
|
49
|
+
export declare function addMonths(date: Date, amount: number): Date;
|
|
50
|
+
/** The same day `amount` years away. 29 Feb becomes 28 Feb when the target year isn't a leap year. */
|
|
51
|
+
export declare function addYears(date: Date, amount: number): Date;
|
|
52
|
+
/** The first day of the month. */
|
|
53
|
+
export declare function startOfMonth(date: Date): Date;
|
|
54
|
+
/** The last day of the month. */
|
|
55
|
+
export declare function endOfMonth(date: Date): Date;
|
|
56
|
+
/** The first day of the week containing `date`. */
|
|
57
|
+
export declare function startOfWeek(date: Date, weekStartsOn?: WeekStart): Date;
|
|
58
|
+
/** The last day of the week containing `date`. */
|
|
59
|
+
export declare function endOfWeek(date: Date, weekStartsOn?: WeekStart): Date;
|
|
60
|
+
/** The month as six full weeks, so the grid keeps its height from month to month. */
|
|
61
|
+
export declare function monthWeeks(month: Date, weekStartsOn?: WeekStart): Date[][];
|
|
62
|
+
/** Seven days in column order, for naming the columns of the grid. 1 Jan 2024 was a Monday. */
|
|
63
|
+
export declare function weekdayDates(weekStartsOn?: WeekStart): Date[];
|
|
64
|
+
/** The day moved just enough to sit between `min` and `max`. */
|
|
65
|
+
export declare function clampDay(date: Date, min?: Date, max?: Date): Date;
|
|
66
|
+
/** True when a day can't be chosen, because of `min`, `max` or `isDateDisabled`. */
|
|
67
|
+
export declare function isDayDisabled(date: Date, { min, max, isDateDisabled }: DateLimits): boolean;
|
|
68
|
+
/** The range with its ends in order. Days are kept at local midnight. */
|
|
69
|
+
export declare function sortRange(a: Date, b: Date): {
|
|
70
|
+
start: Date;
|
|
71
|
+
end: Date;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Makes a test for which days can end a range that begins at `start`, once a start date is chosen. It remembers the
|
|
75
|
+
* nearest disabled day found on each side, so testing a whole month of days doesn't walk the calendar each time.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createEndDateTest(start: Date, limits: RangeLimits): (date: Date) => boolean;
|
|
78
|
+
/** True when a whole range can be used, for example a preset. */
|
|
79
|
+
export declare function isRangeAllowed(range: DateRange, limits: RangeLimits): boolean;
|
|
80
|
+
/** The day as `YYYY-MM-DD`, in local time. */
|
|
81
|
+
export declare function toISODay(date: Date): string;
|
|
82
|
+
/** Short date for the triggers: `12 Mar 2026`. */
|
|
83
|
+
export declare function formatShortDate(date: Date, locale?: string): string;
|
|
84
|
+
/** Long date for announcements: `12 March 2026`. */
|
|
85
|
+
export declare function formatLongDate(date: Date, locale?: string): string;
|
|
86
|
+
/** The full name of a day cell: `Thursday 12 March 2026`. */
|
|
87
|
+
export declare function formatFullDate(date: Date, locale?: string): string;
|
|
88
|
+
/** The month heading: `March 2026`. */
|
|
89
|
+
export declare function formatMonthLabel(date: Date, locale?: string): string;
|
|
90
|
+
/** The column heading of a weekday: `Mon`, or `Monday` when `long`. */
|
|
91
|
+
export declare function formatWeekday(date: Date, locale?: string, long?: boolean): string;
|
|
92
|
+
/** The number in a day cell, in the digits of the locale but without a suffix such as the Japanese 日. */
|
|
93
|
+
export declare function formatDayNumber(date: Date, locale?: string): string;
|
|
94
|
+
/** A range for a trigger: `12 Mar 2026 – 18 Mar 2026`. An empty end leaves the dash open. Null when there is no start. */
|
|
95
|
+
export declare function formatRangeText(range: DateRange | null | undefined, locale?: string): string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ForwardedRef, type KeyboardEvent } from 'react';
|
|
2
|
+
export interface UseDatePopupOptions {
|
|
3
|
+
/** Whether the popup is rendered. */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Sets `open` to false and drops any unfinished selection. It doesn't move focus. */
|
|
6
|
+
onDismiss: () => void;
|
|
7
|
+
/** The ref given to the picker, which receives the combobox button. */
|
|
8
|
+
forwardedRef: ForwardedRef<HTMLButtonElement>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The popup behaviour shared by DatePicker and DateRangePicker. It positions against the trigger box and dismisses on
|
|
12
|
+
* Escape or an outside press. Like the WAI-ARIA date picker dialog it keeps Tab inside, and focus returns to the trigger
|
|
13
|
+
* on the way out. A press on something else focusable still moves focus there, because the browser acts after this does.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useDatePopup({ open, onDismiss, forwardedRef }: UseDatePopupOptions): {
|
|
16
|
+
buttonRef: import("react").RefObject<HTMLButtonElement | null>;
|
|
17
|
+
triggerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
|
+
popupRef: import("react").RefObject<HTMLDivElement | null>;
|
|
19
|
+
popupStyle: import("react").CSSProperties;
|
|
20
|
+
focusTrigger: () => void | undefined;
|
|
21
|
+
onPopupKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ElementType, type HTMLAttributes } from 'react';
|
|
2
|
+
export type CardPadding = 'md' | 'lg' | 'none';
|
|
3
|
+
export interface CardProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** Inner padding: `md` is 16 px and `lg` is 24 px. Use `none` for content that touches the edges, such as a table. */
|
|
5
|
+
padding?: CardPadding;
|
|
6
|
+
/** Element to render, such as `section` or `article`. */
|
|
7
|
+
as?: ElementType;
|
|
8
|
+
}
|
|
9
|
+
/** Bordered container for a group of related content. It has no shadow. */
|
|
10
|
+
export declare const Card: import("react").ForwardRefExoticComponent<CardProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
export type CardFooterAlign = 'start' | 'end' | 'between';
|
|
3
|
+
export interface CardFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** How the content sits along the footer. */
|
|
5
|
+
align?: CardFooterAlign;
|
|
6
|
+
}
|
|
7
|
+
/** Bottom section of a Card, usually for actions. Use it as the last child of the card. */
|
|
8
|
+
export declare const CardFooter: import("react").ForwardRefExoticComponent<CardFooterProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export type CardHeadingLevel = 2 | 3 | 4 | 5 | 6;
|
|
3
|
+
export interface CardHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
4
|
+
/** Card title, rendered as a heading. */
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
/** Supporting text under the title. */
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/** Controls at the end of the header, such as an IconButton. */
|
|
9
|
+
actions?: ReactNode;
|
|
10
|
+
/** Heading level of the title, to fit the outline of the page. */
|
|
11
|
+
headingLevel?: CardHeadingLevel;
|
|
12
|
+
}
|
|
13
|
+
/** Top section of a Card, with a title and optional description and actions. Use it as the first child of the card. */
|
|
14
|
+
export declare const CardHeader: import("react").ForwardRefExoticComponent<CardHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import { type IconName } from '../../icons';
|
|
3
|
+
export interface CatalogCardProps extends Omit<HTMLAttributes<HTMLElement>, 'title'> {
|
|
4
|
+
/** Icon in the tile at the top left. */
|
|
5
|
+
icon?: IconName;
|
|
6
|
+
/** The name of the item. */
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
/** A short line below the name. */
|
|
9
|
+
subtitle?: ReactNode;
|
|
10
|
+
/** What the item does. */
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
/** A quieter action at the bottom left, such as a docs Button. */
|
|
13
|
+
secondaryAction?: ReactNode;
|
|
14
|
+
/** The main action at the bottom right, normally a Button. */
|
|
15
|
+
primaryAction?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** An item that can be added or started, in a catalog of choices. */
|
|
18
|
+
export declare const CatalogCard: import("react").ForwardRefExoticComponent<CatalogCardProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CatalogCard';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
/** One choice in the range control. */
|
|
3
|
+
export interface ChartCardRange {
|
|
4
|
+
/** Stable value reported on change. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Text on the tab. */
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChartCardProps extends Omit<HTMLAttributes<HTMLElement>, 'title' | 'onChange'> {
|
|
10
|
+
/** What the chart is about. */
|
|
11
|
+
title: ReactNode;
|
|
12
|
+
/** What the chart shows and where the data comes from. */
|
|
13
|
+
subtitle?: ReactNode;
|
|
14
|
+
/** Heading level of the title, to fit the page's outline. */
|
|
15
|
+
headingLevel?: 2 | 3 | 4 | 5;
|
|
16
|
+
/** Choices for the range control. Without them there is no control. */
|
|
17
|
+
ranges?: ChartCardRange[];
|
|
18
|
+
/** Selected range, when controlled. */
|
|
19
|
+
rangeValue?: string;
|
|
20
|
+
/** Selected range at first, when uncontrolled. */
|
|
21
|
+
defaultRangeValue?: string;
|
|
22
|
+
/** Called with the new range. */
|
|
23
|
+
onRangeChange?: (value: string) => void;
|
|
24
|
+
/** Accessible name of the range control. */
|
|
25
|
+
rangeLabel?: string;
|
|
26
|
+
/** The chart. */
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/** A titled container for any chart, with a time range control. */
|
|
30
|
+
export declare const ChartCard: import("react").ForwardRefExoticComponent<ChartCardProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChartCard';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PlotArea } from './types';
|
|
2
|
+
/** A labelled position along an axis. */
|
|
3
|
+
export interface AxisTick {
|
|
4
|
+
/** Pixel position along the axis. */
|
|
5
|
+
position: number;
|
|
6
|
+
/** Text to show. */
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ChartAxesProps {
|
|
10
|
+
/** The rectangle the marks are drawn in. */
|
|
11
|
+
plot: PlotArea;
|
|
12
|
+
/** Labels under the plot. */
|
|
13
|
+
xTicks?: AxisTick[];
|
|
14
|
+
/** Labels to the left of the plot. */
|
|
15
|
+
yTicks?: AxisTick[];
|
|
16
|
+
/** Hairlines across the plot at each y tick. Turn off when the y axis names categories. */
|
|
17
|
+
grid?: boolean;
|
|
18
|
+
/** Whether the y labels name categories. They then read in a stronger text colour. */
|
|
19
|
+
categoryY?: boolean;
|
|
20
|
+
/** Draws a hairline up the left of the plot, as the baseline of horizontal bars. */
|
|
21
|
+
leftBaseline?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** SVG axis labels and hairline gridlines. Render it inside an `svg`, before the marks. */
|
|
24
|
+
export declare function ChartAxes({ plot, xTicks, yTicks, grid, categoryY, leftBaseline }: ChartAxesProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** One row of a chart's data table. */
|
|
2
|
+
export interface ChartDataTableRow {
|
|
3
|
+
/** Stable identifier. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Text in the first cell, which names the row. */
|
|
6
|
+
header: string;
|
|
7
|
+
/** Remaining cells, in column order. */
|
|
8
|
+
cells: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface ChartDataTableProps {
|
|
11
|
+
/** Names the table. Usually the chart's accessible name. */
|
|
12
|
+
caption: string;
|
|
13
|
+
/** Column headings, including the one above the row names. */
|
|
14
|
+
columns: string[];
|
|
15
|
+
/** The values. */
|
|
16
|
+
rows: ChartDataTableRow[];
|
|
17
|
+
}
|
|
18
|
+
/** Visually hidden table of a chart's values, so that nothing depends on seeing the marks or hovering them. */
|
|
19
|
+
export declare function ChartDataTable({ caption, columns, rows }: ChartDataTableProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface ChartFrameProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Height reserved for the message when there is nothing to draw. */
|
|
4
|
+
height: number;
|
|
5
|
+
/** Shows `emptyMessage` in place of the chart and draws nothing. */
|
|
6
|
+
empty?: boolean;
|
|
7
|
+
/** Explains why there is nothing to draw. */
|
|
8
|
+
emptyMessage?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** Root of every chart. Sets the surface the marks sit on, bounds the tooltip and shows the empty message. */
|
|
11
|
+
export declare const ChartFrame: import("react").ForwardRefExoticComponent<ChartFrameProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
import type { ChartAnchor } from './types';
|
|
3
|
+
import type { ChartHover } from './useChartHover';
|
|
4
|
+
export interface ChartHoverLayerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
5
|
+
/** State and handlers from `useChartHover`. */
|
|
6
|
+
hover: ChartHover;
|
|
7
|
+
/** Accessible name of the plot. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Height of the plot in pixels. */
|
|
10
|
+
height: number;
|
|
11
|
+
/** Where the tooltip points. Leave unset when nothing is active. */
|
|
12
|
+
anchor?: ChartAnchor | null;
|
|
13
|
+
/** The tooltip for the active point. */
|
|
14
|
+
tooltip?: ReactNode;
|
|
15
|
+
/** Text read out by screen readers when the keyboard moves the active point. */
|
|
16
|
+
announcement?: string;
|
|
17
|
+
/** The chart's `svg`. */
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** The focusable plot. Takes pointer and keyboard input, and keeps the tooltip beside the active point and inside the chart. */
|
|
21
|
+
export declare const ChartHoverLayer: import("react").ForwardRefExoticComponent<ChartHoverLayerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the input for `userEvent.pointer` that moves the pointer to a spot in a plot, given as fractions of its size.
|
|
3
|
+
* Used by play functions. Not exported from the package.
|
|
4
|
+
*/
|
|
5
|
+
export declare function pointerAt(target: Element, xFraction: number, yFraction?: number): {
|
|
6
|
+
target: Element;
|
|
7
|
+
coords: {
|
|
8
|
+
clientX: number;
|
|
9
|
+
clientY: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './scales';
|
|
3
|
+
export * from './paths';
|
|
4
|
+
export * from './series';
|
|
5
|
+
export * from './useChartSize';
|
|
6
|
+
export * from './useChartHover';
|
|
7
|
+
export * from './ChartAxes';
|
|
8
|
+
export * from './ChartHoverLayer';
|
|
9
|
+
export * from './ChartDataTable';
|
|
10
|
+
export * from './ChartFrame';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A plotted position, or `null` where nothing was recorded. */
|
|
2
|
+
export type PathPoint = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
} | null;
|
|
6
|
+
/** Which way a bar grows from its baseline. Only that end is rounded. */
|
|
7
|
+
export type BarDirection = 'up' | 'down' | 'right' | 'left';
|
|
8
|
+
/** SVG path for a line. A missing value breaks the line rather than dropping it to zero. */
|
|
9
|
+
export declare function linePath(points: PathPoint[]): string;
|
|
10
|
+
/** SVG path for the wash under a line, closed along the baseline. */
|
|
11
|
+
export declare function areaPath(points: PathPoint[], baselineY: number): string;
|
|
12
|
+
/** SVG path for a bar: rounded at the data end when `radius` is set, always square at the baseline. */
|
|
13
|
+
export declare function barPath(x: number, y: number, width: number, height: number, direction: BarDirection, radius?: number): string;
|
|
14
|
+
/** A point on a circle. Angle 0 is 12 o'clock and angles run clockwise. */
|
|
15
|
+
export declare function polar(cx: number, cy: number, radius: number, angle: number): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* SVG path for a ring segment between two angles. `gap` is the width in pixels of the space between
|
|
21
|
+
* neighbouring segments: the angle is trimmed per radius so that the gap has parallel sides.
|
|
22
|
+
*/
|
|
23
|
+
export declare function arcPath(cx: number, cy: number, outer: number, inner: number, start: number, end: number, gap?: number): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ChartAnchor, ChartSegment, ChartSeries } from './types';
|
|
2
|
+
/** The most series or segments a chart colours. Past this, the rest fold into Other. */
|
|
3
|
+
export declare const MAX_SERIES = 5;
|
|
4
|
+
/** Keeps a number inside a range. */
|
|
5
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
6
|
+
/** Returns a function that maps a value from one numeric range to another. */
|
|
7
|
+
export declare function linearScale(domain: [number, number], range: [number, number]): (value: number) => number;
|
|
8
|
+
/** Round axis ticks that cover the values and leave a little headroom above the highest one. */
|
|
9
|
+
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
10
|
+
/** Formats axis ticks in one style: in full under 10,000, compact when the axis reaches it. */
|
|
11
|
+
export declare function formatTicks(ticks: number[]): string[];
|
|
12
|
+
/** Default value format for labels, tooltips and tables. */
|
|
13
|
+
export declare function formatValue(value: number): string;
|
|
14
|
+
/** Which label positions to show so that labels sit at least `minSpacing` pixels apart. */
|
|
15
|
+
export declare function thinTickIndexes(count: number, spacing: number, minSpacing?: number): number[];
|
|
16
|
+
/** Rough width of a caption-sized string, used to reserve room before the text is drawn. */
|
|
17
|
+
export declare function estimateTextWidth(text: string): number;
|
|
18
|
+
/** The position labels of a set of series, taken from the longest. */
|
|
19
|
+
export declare function seriesLabels(series: ChartSeries[]): string[];
|
|
20
|
+
/** The position of the last recorded value, or -1 when there is none. */
|
|
21
|
+
export declare function lastRecordedIndex(values: (number | null)[]): number;
|
|
22
|
+
/** Whether any series has at least one recorded value. */
|
|
23
|
+
export declare function hasSeriesData(series: ChartSeries[]): boolean;
|
|
24
|
+
/** Recorded values across a set of series. */
|
|
25
|
+
export declare function seriesValues(series: ChartSeries[]): number[];
|
|
26
|
+
/** Keeps the first four series and sums the rest into Other when there are more than five. */
|
|
27
|
+
export declare function foldSeries(series: ChartSeries[], otherName?: string): ChartSeries[];
|
|
28
|
+
/** Keeps the first four segments and sums the rest into Other when there are more than five. */
|
|
29
|
+
export declare function foldSegments(segments: ChartSegment[], otherLabel?: string): ChartSegment[];
|
|
30
|
+
/** Places a tooltip beside its anchor, flipping sides and clamping so that it stays inside the bounds. */
|
|
31
|
+
export declare function placeTooltip(anchor: ChartAnchor, tooltip: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
}, bounds: {
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
}, gap?: number): {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** One position on a series. A `null` value means nothing was recorded there: it leaves a gap and is never drawn as zero. */
|
|
2
|
+
export interface ChartPoint {
|
|
3
|
+
/** Position name, such as a month or category. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Measured value, or `null` when nothing was recorded. */
|
|
6
|
+
value: number | null;
|
|
7
|
+
}
|
|
8
|
+
/** A named run of values. Its position in the array sets its colour, so hiding another series never repaints it. */
|
|
9
|
+
export interface ChartSeries {
|
|
10
|
+
/** Stable identifier. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Name shown in the legend and tooltip. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Values in display order. */
|
|
15
|
+
points: ChartPoint[];
|
|
16
|
+
}
|
|
17
|
+
/** A slice of a whole, used by the donut chart. */
|
|
18
|
+
export interface ChartSegment {
|
|
19
|
+
/** Stable identifier. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Name shown in the legend and tooltip. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Size of this slice, in the same unit as the others. */
|
|
24
|
+
value: number;
|
|
25
|
+
}
|
|
26
|
+
/** The rectangle that the marks are drawn in, in SVG pixels. */
|
|
27
|
+
export interface PlotArea {
|
|
28
|
+
left: number;
|
|
29
|
+
right: number;
|
|
30
|
+
top: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
}
|
|
33
|
+
/** Where the tooltip points. `reach` is how far the highlighted mark extends sideways from `x`, so the tooltip clears it. */
|
|
34
|
+
export interface ChartAnchor {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
reach?: number;
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type KeyboardEvent, type PointerEvent } from 'react';
|
|
2
|
+
/** What set the active point. Only keyboard moves are announced, because a moving pointer would flood a screen reader. */
|
|
3
|
+
export type ChartHoverSource = 'pointer' | 'keyboard';
|
|
4
|
+
export interface UseChartHoverOptions {
|
|
5
|
+
/** How many points the keyboard can move through. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Finds the point for a pointer position in plot pixels, or `null` when the pointer is near none. */
|
|
8
|
+
locate: (x: number, y: number) => number | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ChartHover {
|
|
11
|
+
/** The active point, or `null`. */
|
|
12
|
+
activeIndex: number | null;
|
|
13
|
+
/** What set the active point. */
|
|
14
|
+
source: ChartHoverSource;
|
|
15
|
+
/** Handlers to spread onto the focusable plot. */
|
|
16
|
+
plotProps: {
|
|
17
|
+
onPointerMove: (event: PointerEvent<HTMLElement>) => void;
|
|
18
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
19
|
+
onPointerLeave: () => void;
|
|
20
|
+
onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
21
|
+
onBlur: () => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Tracks a chart's active point from the pointer and the keyboard: arrows, Home and End move it, and Escape clears it. */
|
|
25
|
+
export declare function useChartHover({ count, locate }: UseChartHoverOptions): ChartHover;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ForwardedRef } from 'react';
|
|
2
|
+
/** Measures an element's width with a ResizeObserver, so a chart fills its container. Width is 0 until first measured. */
|
|
3
|
+
export declare function useChartSize<T extends HTMLElement = HTMLDivElement>(forwardedRef?: ForwardedRef<T>): {
|
|
4
|
+
ref: (node: T | null) => void;
|
|
5
|
+
width: number;
|
|
6
|
+
};
|