@primecoderin/fast-ui-react 0.0.0-stage → 1.0.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/CHANGELOG.md +106 -0
- package/LICENSE +21 -0
- package/README.md +180 -3
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.js +7 -0
- package/dist/components/Avatar/Avatar.d.ts +12 -0
- package/dist/components/Avatar/Avatar.js +92 -0
- package/dist/components/Button/Button.d.ts +44 -0
- package/dist/components/Button/Button.js +221 -0
- package/dist/components/Checkbox/CheckboxBox.d.ts +33 -0
- package/dist/components/Checkbox/CheckboxBox.js +148 -0
- package/dist/components/CodeSnippet/CodeSnippet.d.ts +26 -0
- package/dist/components/CodeSnippet/CodeSnippet.js +153 -0
- package/dist/components/Collapsible/Collapsible.d.ts +20 -0
- package/dist/components/Collapsible/Collapsible.js +97 -0
- package/dist/components/Container/Container.d.ts +301 -0
- package/dist/components/Container/Container.js +20 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.d.ts +22 -0
- package/dist/components/FloatingActionButton/FloatingActionButton.js +141 -0
- package/dist/components/Grid/Grid.d.ts +311 -0
- package/dist/components/Grid/Grid.js +30 -0
- package/dist/components/IconTile/IconTile.d.ts +12 -0
- package/dist/components/IconTile/IconTile.js +70 -0
- package/dist/components/InlineError/InlineError.d.ts +9 -0
- package/dist/components/InlineError/InlineError.js +62 -0
- package/dist/components/Kbd/Kbd.d.ts +11 -0
- package/dist/components/Kbd/Kbd.js +31 -0
- package/dist/components/Link/Link.d.ts +18 -0
- package/dist/components/Link/Link.js +68 -0
- package/dist/components/Menu/ContextMenu.d.ts +18 -0
- package/dist/components/Menu/ContextMenu.js +68 -0
- package/dist/components/Menu/Menu.d.ts +86 -0
- package/dist/components/Menu/Menu.js +394 -0
- package/dist/components/OtpInput/OtpInput.d.ts +32 -0
- package/dist/components/OtpInput/OtpInput.js +177 -0
- package/dist/components/Popover/HoverPopover.d.ts +22 -0
- package/dist/components/Popover/HoverPopover.js +74 -0
- package/dist/components/Popover/Popover.d.ts +21 -0
- package/dist/components/Popover/Popover.js +64 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +17 -0
- package/dist/components/ProgressBar/ProgressBar.js +44 -0
- package/dist/components/Rating/Rating.d.ts +49 -0
- package/dist/components/Rating/Rating.js +241 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +23 -0
- package/dist/components/ScrollArea/ScrollArea.js +90 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +29 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +99 -0
- package/dist/components/Separator/Separator.d.ts +9 -0
- package/dist/components/Separator/Separator.js +34 -0
- package/dist/components/Skeleton/Skeleton.d.ts +31 -0
- package/dist/components/Skeleton/Skeleton.js +152 -0
- package/dist/components/Slider/Slider.d.ts +54 -0
- package/dist/components/Slider/Slider.js +178 -0
- package/dist/components/Spinner/Spinner.d.ts +17 -0
- package/dist/components/Spinner/Spinner.js +118 -0
- package/dist/components/Stack/Stack.d.ts +302 -0
- package/dist/components/Stack/Stack.js +14 -0
- package/dist/components/StateIcon/StateIcon.d.ts +11 -0
- package/dist/components/StateIcon/StateIcon.js +65 -0
- package/dist/components/StatusBadge/StatusBadge.d.ts +19 -0
- package/dist/components/StatusBadge/StatusBadge.js +82 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.js +109 -0
- package/dist/components/Tag/Tag.d.ts +11 -0
- package/dist/components/Tag/Tag.js +66 -0
- package/dist/components/Toast/AppToaster.d.ts +8 -0
- package/dist/components/Toast/AppToaster.js +135 -0
- package/dist/components/Toast/toast-manager.d.ts +28 -0
- package/dist/components/Toast/toast-manager.js +47 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +26 -0
- package/dist/components/ToggleButton/ToggleButton.js +106 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +32 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +79 -0
- package/dist/components/Tooltip/Tooltip.d.ts +16 -0
- package/dist/components/Tooltip/Tooltip.js +58 -0
- package/dist/components/Tooltip/TooltipGroup.d.ts +22 -0
- package/dist/components/Tooltip/TooltipGroup.js +65 -0
- package/dist/components/Typography/Typography.d.ts +17 -0
- package/dist/components/Typography/Typography.js +100 -0
- package/dist/editor-forms.d.ts +1 -0
- package/dist/editor-forms.js +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +1 -0
- package/dist/fonts/LICENSE +93 -0
- package/dist/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-greek-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/fonts.css +69 -0
- package/dist/forms.d.ts +22 -0
- package/dist/forms.js +23 -0
- package/dist/foundation.css +23 -0
- package/dist/global.css +116 -0
- package/dist/hooks/useAppToast.d.ts +12 -0
- package/dist/hooks/useAppToast.js +29 -0
- package/dist/icons/icons.d.ts +43 -0
- package/dist/icons/icons.js +44 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +101 -0
- package/dist/patterns/Accordion/Accordion.d.ts +35 -0
- package/dist/patterns/Accordion/Accordion.js +139 -0
- package/dist/patterns/Alert/Alert.d.ts +38 -0
- package/dist/patterns/Alert/Alert.js +151 -0
- package/dist/patterns/AppShell/AppShell.d.ts +39 -0
- package/dist/patterns/AppShell/AppShell.js +218 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.d.ts +21 -0
- package/dist/patterns/Breadcrumbs/Breadcrumbs.js +73 -0
- package/dist/patterns/Calendar/Calendar.d.ts +59 -0
- package/dist/patterns/Calendar/Calendar.js +283 -0
- package/dist/patterns/Calendar/DateRangePicker.d.ts +53 -0
- package/dist/patterns/Calendar/DateRangePicker.js +266 -0
- package/dist/patterns/Calendar/FormDateRangeField.d.ts +24 -0
- package/dist/patterns/Calendar/FormDateRangeField.js +138 -0
- package/dist/patterns/Card/Card.d.ts +26 -0
- package/dist/patterns/Card/Card.js +125 -0
- package/dist/patterns/Carousel/Carousel.d.ts +33 -0
- package/dist/patterns/Carousel/Carousel.js +127 -0
- package/dist/patterns/Cascader/Cascader.d.ts +53 -0
- package/dist/patterns/Cascader/Cascader.js +371 -0
- package/dist/patterns/Cascader/FormCascaderField.d.ts +21 -0
- package/dist/patterns/Cascader/FormCascaderField.js +130 -0
- package/dist/patterns/Charts/AreaChart.d.ts +13 -0
- package/dist/patterns/Charts/AreaChart.js +220 -0
- package/dist/patterns/Charts/BarChart.d.ts +11 -0
- package/dist/patterns/Charts/BarChart.js +220 -0
- package/dist/patterns/Charts/DonutChart.d.ts +37 -0
- package/dist/patterns/Charts/DonutChart.js +215 -0
- package/dist/patterns/Charts/GaugeChart.d.ts +44 -0
- package/dist/patterns/Charts/GaugeChart.js +210 -0
- package/dist/patterns/Charts/LineChart.d.ts +14 -0
- package/dist/patterns/Charts/LineChart.js +222 -0
- package/dist/patterns/Charts/Sparkline.d.ts +24 -0
- package/dist/patterns/Charts/Sparkline.js +81 -0
- package/dist/patterns/Charts/chart-parts.d.ts +139 -0
- package/dist/patterns/Charts/chart-parts.js +385 -0
- package/dist/patterns/Charts/gauge-math.d.ts +20 -0
- package/dist/patterns/Charts/gauge-math.js +21 -0
- package/dist/patterns/Charts/sparkline-path.d.ts +11 -0
- package/dist/patterns/Charts/sparkline-path.js +24 -0
- package/dist/patterns/ColorPicker/ColorPicker.d.ts +50 -0
- package/dist/patterns/ColorPicker/ColorPicker.js +590 -0
- package/dist/patterns/ColorPicker/FormColorField.d.ts +21 -0
- package/dist/patterns/ColorPicker/FormColorField.js +130 -0
- package/dist/patterns/ColorPicker/color-value.d.ts +19 -0
- package/dist/patterns/ColorPicker/color-value.js +72 -0
- package/dist/patterns/Combobox/Autocomplete.d.ts +48 -0
- package/dist/patterns/Combobox/Autocomplete.js +158 -0
- package/dist/patterns/Combobox/Combobox.d.ts +52 -0
- package/dist/patterns/Combobox/Combobox.js +195 -0
- package/dist/patterns/Combobox/ComboboxPopup.d.ts +24 -0
- package/dist/patterns/Combobox/ComboboxPopup.js +107 -0
- package/dist/patterns/Combobox/FormAutocompleteField.d.ts +17 -0
- package/dist/patterns/Combobox/FormAutocompleteField.js +119 -0
- package/dist/patterns/Combobox/FormComboboxField.d.ts +18 -0
- package/dist/patterns/Combobox/FormComboboxField.js +119 -0
- package/dist/patterns/Combobox/FormMultiSelectField.d.ts +18 -0
- package/dist/patterns/Combobox/FormMultiSelectField.js +119 -0
- package/dist/patterns/Combobox/MultiSelect.d.ts +54 -0
- package/dist/patterns/Combobox/MultiSelect.js +175 -0
- package/dist/patterns/CommandPalette/CommandPalette.d.ts +50 -0
- package/dist/patterns/CommandPalette/CommandPalette.js +193 -0
- package/dist/patterns/DataTable/DataTable.d.ts +107 -0
- package/dist/patterns/DataTable/DataTable.js +364 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.d.ts +28 -0
- package/dist/patterns/DateTimePicker/DateTimePanel.js +444 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.d.ts +75 -0
- package/dist/patterns/DateTimePicker/DateTimePicker.js +271 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.d.ts +32 -0
- package/dist/patterns/DateTimePicker/FormDateTimeField.js +148 -0
- package/dist/patterns/DateTimePicker/TimeSliders.d.ts +14 -0
- package/dist/patterns/DateTimePicker/TimeSliders.js +206 -0
- package/dist/patterns/DateTimePicker/picker-labels.d.ts +30 -0
- package/dist/patterns/DateTimePicker/picker-labels.js +23 -0
- package/dist/patterns/DateTimePicker/picker-values.d.ts +98 -0
- package/dist/patterns/DateTimePicker/picker-values.js +194 -0
- package/dist/patterns/DescriptionList/DescriptionList.d.ts +20 -0
- package/dist/patterns/DescriptionList/DescriptionList.js +57 -0
- package/dist/patterns/Dialog/Dialog.d.ts +26 -0
- package/dist/patterns/Dialog/Dialog.js +212 -0
- package/dist/patterns/Drawer/Drawer.d.ts +33 -0
- package/dist/patterns/Drawer/Drawer.js +153 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +35 -0
- package/dist/patterns/EmptyState/EmptyState.js +44 -0
- package/dist/patterns/FileUpload/FileUpload.d.ts +87 -0
- package/dist/patterns/FileUpload/FileUpload.js +417 -0
- package/dist/patterns/FileUpload/FormFileUploadField.d.ts +19 -0
- package/dist/patterns/FileUpload/FormFileUploadField.js +117 -0
- package/dist/patterns/FileUpload/add-files.d.ts +26 -0
- package/dist/patterns/FileUpload/add-files.js +35 -0
- package/dist/patterns/FileUpload/file-size.d.ts +14 -0
- package/dist/patterns/FileUpload/file-size.js +44 -0
- package/dist/patterns/FormField/CheckboxField.d.ts +26 -0
- package/dist/patterns/FormField/CheckboxField.js +97 -0
- package/dist/patterns/FormField/FieldFrame.d.ts +85 -0
- package/dist/patterns/FormField/FieldFrame.js +257 -0
- package/dist/patterns/FormField/FormCheckboxField.d.ts +17 -0
- package/dist/patterns/FormField/FormCheckboxField.js +92 -0
- package/dist/patterns/FormField/FormRadioGroupField.d.ts +16 -0
- package/dist/patterns/FormField/FormRadioGroupField.js +97 -0
- package/dist/patterns/FormField/FormRatingField.d.ts +19 -0
- package/dist/patterns/FormField/FormRatingField.js +119 -0
- package/dist/patterns/FormField/FormSelectField.d.ts +16 -0
- package/dist/patterns/FormField/FormSelectField.js +91 -0
- package/dist/patterns/FormField/FormSliderField.d.ts +22 -0
- package/dist/patterns/FormField/FormSliderField.js +128 -0
- package/dist/patterns/FormField/FormSwitchField.d.ts +19 -0
- package/dist/patterns/FormField/FormSwitchField.js +88 -0
- package/dist/patterns/FormField/FormTextAreaField.d.ts +12 -0
- package/dist/patterns/FormField/FormTextAreaField.js +91 -0
- package/dist/patterns/FormField/FormTextField.d.ts +23 -0
- package/dist/patterns/FormField/FormTextField.js +103 -0
- package/dist/patterns/FormField/RadioGroupField.d.ts +38 -0
- package/dist/patterns/FormField/RadioGroupField.js +201 -0
- package/dist/patterns/FormField/SelectField.d.ts +43 -0
- package/dist/patterns/FormField/SelectField.js +211 -0
- package/dist/patterns/FormField/SwitchField.d.ts +27 -0
- package/dist/patterns/FormField/SwitchField.js +105 -0
- package/dist/patterns/FormField/TextAreaField.d.ts +37 -0
- package/dist/patterns/FormField/TextAreaField.js +134 -0
- package/dist/patterns/FormField/TextField.d.ts +51 -0
- package/dist/patterns/FormField/TextField.js +256 -0
- package/dist/patterns/FormField/error-message.d.ts +6 -0
- package/dist/patterns/FormField/error-message.js +8 -0
- package/dist/patterns/FormField/field-styles.d.ts +44 -0
- package/dist/patterns/FormField/field-styles.js +89 -0
- package/dist/patterns/FormField/field-types.d.ts +4 -0
- package/dist/patterns/FormField/use-field-ids.d.ts +18 -0
- package/dist/patterns/FormField/use-field-ids.js +53 -0
- package/dist/patterns/List/List.d.ts +38 -0
- package/dist/patterns/List/List.js +174 -0
- package/dist/patterns/MentionsInput/FormMentionsField.d.ts +18 -0
- package/dist/patterns/MentionsInput/FormMentionsField.js +124 -0
- package/dist/patterns/MentionsInput/MentionsInput.d.ts +57 -0
- package/dist/patterns/MentionsInput/MentionsInput.js +133 -0
- package/dist/patterns/MentionsInput/mention-text.d.ts +24 -0
- package/dist/patterns/MentionsInput/mention-text.js +31 -0
- package/dist/patterns/Menubar/Menubar.d.ts +22 -0
- package/dist/patterns/Menubar/Menubar.js +79 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.d.ts +27 -0
- package/dist/patterns/NavigationMenu/NavigationMenu.js +104 -0
- package/dist/patterns/NumberField/FormNumberField.d.ts +18 -0
- package/dist/patterns/NumberField/FormNumberField.js +119 -0
- package/dist/patterns/NumberField/NumberField.d.ts +57 -0
- package/dist/patterns/NumberField/NumberField.js +242 -0
- package/dist/patterns/Pagination/Pagination.d.ts +31 -0
- package/dist/patterns/Pagination/Pagination.js +275 -0
- package/dist/patterns/Pagination/page-items.d.ts +18 -0
- package/dist/patterns/Pagination/page-items.js +40 -0
- package/dist/patterns/PhoneField/FormPhoneField.d.ts +22 -0
- package/dist/patterns/PhoneField/FormPhoneField.js +97 -0
- package/dist/patterns/PhoneField/PhoneField.d.ts +60 -0
- package/dist/patterns/PhoneField/PhoneField.js +448 -0
- package/dist/patterns/PhoneField/phone-value.d.ts +26 -0
- package/dist/patterns/PhoneField/phone-value.js +38 -0
- package/dist/patterns/QRCode/QRCode.d.ts +37 -0
- package/dist/patterns/QRCode/QRCode.js +120 -0
- package/dist/patterns/QRCode/qr-path.d.ts +7 -0
- package/dist/patterns/QRCode/qr-path.js +25 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.d.ts +34 -0
- package/dist/patterns/ResizablePanels/ResizablePanels.js +175 -0
- package/dist/patterns/ResizablePanels/panel-sizes.d.ts +31 -0
- package/dist/patterns/ResizablePanels/panel-sizes.js +54 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.d.ts +18 -0
- package/dist/patterns/RichTextEditor/FormRichTextField.js +118 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.d.ts +71 -0
- package/dist/patterns/RichTextEditor/RichTextEditor.js +453 -0
- package/dist/patterns/SearchInput/SearchInput.d.ts +26 -0
- package/dist/patterns/SearchInput/SearchInput.js +98 -0
- package/dist/patterns/SideNav/SideNav.d.ts +50 -0
- package/dist/patterns/SideNav/SideNav.js +269 -0
- package/dist/patterns/Stat/Stat.d.ts +51 -0
- package/dist/patterns/Stat/Stat.js +292 -0
- package/dist/patterns/Stepper/Stepper.d.ts +35 -0
- package/dist/patterns/Stepper/Stepper.js +110 -0
- package/dist/patterns/TagGroup/TagGroup.d.ts +44 -0
- package/dist/patterns/TagGroup/TagGroup.js +151 -0
- package/dist/patterns/TagsInput/FormTagsInputField.d.ts +18 -0
- package/dist/patterns/TagsInput/FormTagsInputField.js +124 -0
- package/dist/patterns/TagsInput/TagsInput.d.ts +51 -0
- package/dist/patterns/TagsInput/TagsInput.js +97 -0
- package/dist/patterns/Timeline/Timeline.d.ts +29 -0
- package/dist/patterns/Timeline/Timeline.js +85 -0
- package/dist/patterns/Toolbar/Toolbar.d.ts +31 -0
- package/dist/patterns/Toolbar/Toolbar.js +105 -0
- package/dist/patterns/Tour/Tour.d.ts +38 -0
- package/dist/patterns/Tour/Tour.js +333 -0
- package/dist/patterns/TransferList/FormTransferListField.d.ts +19 -0
- package/dist/patterns/TransferList/FormTransferListField.js +117 -0
- package/dist/patterns/TransferList/TransferList.d.ts +53 -0
- package/dist/patterns/TransferList/TransferList.js +441 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.d.ts +28 -0
- package/dist/patterns/TreeSelect/FormTreeSelectField.js +88 -0
- package/dist/patterns/TreeSelect/TreeSelect.d.ts +49 -0
- package/dist/patterns/TreeSelect/TreeSelect.js +375 -0
- package/dist/patterns/TreeView/TreeView.d.ts +40 -0
- package/dist/patterns/TreeView/TreeView.js +296 -0
- package/dist/provider/DesignSystemProvider.d.ts +54 -0
- package/dist/provider/DesignSystemProvider.js +270 -0
- package/dist/provider/nonce.d.ts +7 -0
- package/dist/provider/nonce.js +13 -0
- package/dist/styles.css +2 -0
- package/dist/theme/chart-palette.d.ts +51 -0
- package/dist/theme/chart-palette.js +112 -0
- package/dist/theme/create-theme.d.ts +52 -0
- package/dist/theme/create-theme.js +75 -0
- package/dist/theme/style-element.d.ts +28 -0
- package/dist/theme/style-element.js +79 -0
- package/dist/theme/tenant-branding.d.ts +48 -0
- package/dist/theme/tenant-branding.js +65 -0
- package/dist/theme/theme-switch.d.ts +25 -0
- package/dist/theme/theme-switch.js +90 -0
- package/dist/theme/token-names.d.ts +3 -0
- package/dist/theme/token-names.js +166 -0
- package/dist/theme.css +241 -0
- package/dist/tokens.css +383 -0
- package/dist/types/direction.d.ts +4 -0
- package/dist/types/tone.d.ts +7 -0
- package/dist/utils/cn.d.ts +7 -0
- package/dist/utils/cn.js +50 -0
- package/dist/utils/first-field.d.ts +8 -0
- package/dist/utils/first-field.js +10 -0
- package/dist/utils/layout.d.ts +33 -0
- package/dist/utils/layout.js +30 -0
- package/dist/utils/popup.d.ts +12 -0
- package/dist/utils/popup.js +27 -0
- package/docs/accessibility.md +61 -0
- package/docs/advanced-components.md +38 -0
- package/docs/ai-assistants.md +44 -0
- package/docs/architecture.md +65 -0
- package/docs/browser-support.md +30 -0
- package/docs/charts.md +56 -0
- package/docs/components.md +2928 -0
- package/docs/conventions.md +19 -0
- package/docs/customization.md +79 -0
- package/docs/dates-files-data.md +48 -0
- package/docs/design-principles.md +50 -0
- package/docs/faq.md +68 -0
- package/docs/forms.md +114 -0
- package/docs/getting-started.md +64 -0
- package/docs/icons.md +48 -0
- package/docs/internationalization.md +64 -0
- package/docs/layout-and-navigation.md +51 -0
- package/docs/nextjs.md +69 -0
- package/docs/releasing.md +40 -0
- package/docs/testing.md +242 -0
- package/docs/theming.md +118 -0
- package/docs/typescript.md +62 -0
- package/llms-full.txt +4573 -0
- package/llms.txt +52 -0
- package/package.json +193 -6
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Area, AreaChart as AreaChart$1, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
4
|
+
import { AXIS_LINE, AXIS_TICK, CURSOR_STROKE, ChartDataTable, ChartFrame, ChartLegend, ChartTooltip, GRID_STROKE, seriesColor, seriesDash, useChartFontVersion, usePrefersReducedMotion } from "./chart-parts.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/patterns/Charts/AreaChart.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Filled areas over a shared x axis: a volume over time, or with `stacked` how a total divides into parts. The
|
|
9
|
+
* colours are the chart tokens, and the top edge of each area after the first is dashed or dotted in its own way (the
|
|
10
|
+
* legend shows the same). The data is also given to a screen reader as a table.
|
|
11
|
+
*/
|
|
12
|
+
var AreaChart = (t0) => {
|
|
13
|
+
const $ = c(55);
|
|
14
|
+
const { data, xKey, xLabel, series, "aria-label": ariaLabel, height: t1, formatX, formatValue, hideLegend: t2, hideGrid: t3, stacked: t4, curve: t5, className } = t0;
|
|
15
|
+
const height = t1 === void 0 ? 240 : t1;
|
|
16
|
+
const hideLegend = t2 === void 0 ? false : t2;
|
|
17
|
+
const hideGrid = t3 === void 0 ? false : t3;
|
|
18
|
+
const stacked = t4 === void 0 ? false : t4;
|
|
19
|
+
const curve = t5 === void 0 ? "monotone" : t5;
|
|
20
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
21
|
+
const font = useChartFontVersion();
|
|
22
|
+
const t6 = font.probe;
|
|
23
|
+
let t7;
|
|
24
|
+
if ($[0] !== className) {
|
|
25
|
+
t7 = className ? { className } : {};
|
|
26
|
+
$[0] = className;
|
|
27
|
+
$[1] = t7;
|
|
28
|
+
} else t7 = $[1];
|
|
29
|
+
let t8;
|
|
30
|
+
if ($[2] !== hideLegend || $[3] !== series) {
|
|
31
|
+
t8 = hideLegend ? null : /* @__PURE__ */ jsx(ChartLegend, { items: series.map(_temp) });
|
|
32
|
+
$[2] = hideLegend;
|
|
33
|
+
$[3] = series;
|
|
34
|
+
$[4] = t8;
|
|
35
|
+
} else t8 = $[4];
|
|
36
|
+
let t9;
|
|
37
|
+
if ($[5] !== ariaLabel || $[6] !== data || $[7] !== formatValue || $[8] !== formatX || $[9] !== series || $[10] !== xKey || $[11] !== xLabel) {
|
|
38
|
+
t9 = /* @__PURE__ */ jsx(ChartDataTable, {
|
|
39
|
+
caption: ariaLabel,
|
|
40
|
+
data,
|
|
41
|
+
xKey,
|
|
42
|
+
xLabel,
|
|
43
|
+
series,
|
|
44
|
+
formatX,
|
|
45
|
+
formatValue
|
|
46
|
+
});
|
|
47
|
+
$[5] = ariaLabel;
|
|
48
|
+
$[6] = data;
|
|
49
|
+
$[7] = formatValue;
|
|
50
|
+
$[8] = formatX;
|
|
51
|
+
$[9] = series;
|
|
52
|
+
$[10] = xKey;
|
|
53
|
+
$[11] = xLabel;
|
|
54
|
+
$[12] = t9;
|
|
55
|
+
} else t9 = $[12];
|
|
56
|
+
const t10 = font.version;
|
|
57
|
+
let t11;
|
|
58
|
+
if ($[13] !== data) {
|
|
59
|
+
t11 = [...data];
|
|
60
|
+
$[13] = data;
|
|
61
|
+
$[14] = t11;
|
|
62
|
+
} else t11 = $[14];
|
|
63
|
+
let t12;
|
|
64
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
65
|
+
t12 = {
|
|
66
|
+
top: 8,
|
|
67
|
+
right: 8,
|
|
68
|
+
bottom: 0,
|
|
69
|
+
left: 0
|
|
70
|
+
};
|
|
71
|
+
$[15] = t12;
|
|
72
|
+
} else t12 = $[15];
|
|
73
|
+
let t13;
|
|
74
|
+
if ($[16] !== hideGrid) {
|
|
75
|
+
t13 = hideGrid ? null : /* @__PURE__ */ jsx(CartesianGrid, {
|
|
76
|
+
vertical: false,
|
|
77
|
+
stroke: GRID_STROKE
|
|
78
|
+
});
|
|
79
|
+
$[16] = hideGrid;
|
|
80
|
+
$[17] = t13;
|
|
81
|
+
} else t13 = $[17];
|
|
82
|
+
let t14;
|
|
83
|
+
if ($[18] !== formatX) {
|
|
84
|
+
t14 = formatX ? { tickFormatter: formatX } : {};
|
|
85
|
+
$[18] = formatX;
|
|
86
|
+
$[19] = t14;
|
|
87
|
+
} else t14 = $[19];
|
|
88
|
+
let t15;
|
|
89
|
+
if ($[20] !== t14 || $[21] !== xKey) {
|
|
90
|
+
t15 = /* @__PURE__ */ jsx(XAxis, {
|
|
91
|
+
dataKey: xKey,
|
|
92
|
+
tickLine: false,
|
|
93
|
+
axisLine: AXIS_LINE,
|
|
94
|
+
tick: AXIS_TICK,
|
|
95
|
+
...t14
|
|
96
|
+
});
|
|
97
|
+
$[20] = t14;
|
|
98
|
+
$[21] = xKey;
|
|
99
|
+
$[22] = t15;
|
|
100
|
+
} else t15 = $[22];
|
|
101
|
+
let t16;
|
|
102
|
+
if ($[23] !== formatValue) {
|
|
103
|
+
t16 = /* @__PURE__ */ jsx(YAxis, {
|
|
104
|
+
width: "auto",
|
|
105
|
+
tickLine: false,
|
|
106
|
+
axisLine: false,
|
|
107
|
+
tick: AXIS_TICK,
|
|
108
|
+
...formatValue ? { tickFormatter: formatValue } : {}
|
|
109
|
+
});
|
|
110
|
+
$[23] = formatValue;
|
|
111
|
+
$[24] = t16;
|
|
112
|
+
} else t16 = $[24];
|
|
113
|
+
let t17;
|
|
114
|
+
if ($[25] !== formatValue || $[26] !== formatX) {
|
|
115
|
+
t17 = /* @__PURE__ */ jsx(Tooltip, {
|
|
116
|
+
cursor: CURSOR_STROKE,
|
|
117
|
+
content: (props) => /* @__PURE__ */ jsx(ChartTooltip, {
|
|
118
|
+
...props,
|
|
119
|
+
formatLabel: formatX,
|
|
120
|
+
formatValue
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
$[25] = formatValue;
|
|
124
|
+
$[26] = formatX;
|
|
125
|
+
$[27] = t17;
|
|
126
|
+
} else t17 = $[27];
|
|
127
|
+
let t18;
|
|
128
|
+
if ($[28] !== curve || $[29] !== font.version || $[30] !== reduceMotion || $[31] !== series || $[32] !== stacked) {
|
|
129
|
+
let t19;
|
|
130
|
+
if ($[34] !== curve || $[35] !== font.version || $[36] !== reduceMotion || $[37] !== stacked) {
|
|
131
|
+
t19 = (item_0, index_0) => /* @__PURE__ */ jsx(Area, {
|
|
132
|
+
type: curve,
|
|
133
|
+
dataKey: item_0.key,
|
|
134
|
+
name: item_0.label,
|
|
135
|
+
...stacked ? { stackId: "stack" } : {},
|
|
136
|
+
stroke: seriesColor(index_0, item_0.color),
|
|
137
|
+
strokeWidth: 2,
|
|
138
|
+
...seriesDash(index_0) ? { strokeDasharray: seriesDash(index_0) } : {},
|
|
139
|
+
fill: seriesColor(index_0, item_0.color),
|
|
140
|
+
fillOpacity: .18,
|
|
141
|
+
dot: false,
|
|
142
|
+
activeDot: {
|
|
143
|
+
r: 4,
|
|
144
|
+
strokeWidth: 2,
|
|
145
|
+
stroke: "var(--fast-surface)"
|
|
146
|
+
},
|
|
147
|
+
isAnimationActive: !reduceMotion && font.version === 0,
|
|
148
|
+
animationDuration: 400
|
|
149
|
+
}, item_0.key);
|
|
150
|
+
$[34] = curve;
|
|
151
|
+
$[35] = font.version;
|
|
152
|
+
$[36] = reduceMotion;
|
|
153
|
+
$[37] = stacked;
|
|
154
|
+
$[38] = t19;
|
|
155
|
+
} else t19 = $[38];
|
|
156
|
+
t18 = series.map(t19);
|
|
157
|
+
$[28] = curve;
|
|
158
|
+
$[29] = font.version;
|
|
159
|
+
$[30] = reduceMotion;
|
|
160
|
+
$[31] = series;
|
|
161
|
+
$[32] = stacked;
|
|
162
|
+
$[33] = t18;
|
|
163
|
+
} else t18 = $[33];
|
|
164
|
+
let t19;
|
|
165
|
+
if ($[39] !== font.version || $[40] !== t11 || $[41] !== t13 || $[42] !== t15 || $[43] !== t16 || $[44] !== t17 || $[45] !== t18) {
|
|
166
|
+
t19 = /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
167
|
+
width: "100%",
|
|
168
|
+
height: "100%",
|
|
169
|
+
children: /* @__PURE__ */ jsxs(AreaChart$1, {
|
|
170
|
+
data: t11,
|
|
171
|
+
margin: t12,
|
|
172
|
+
accessibilityLayer: false,
|
|
173
|
+
children: [
|
|
174
|
+
t13,
|
|
175
|
+
t15,
|
|
176
|
+
t16,
|
|
177
|
+
t17,
|
|
178
|
+
t18
|
|
179
|
+
]
|
|
180
|
+
}, t10)
|
|
181
|
+
});
|
|
182
|
+
$[39] = font.version;
|
|
183
|
+
$[40] = t11;
|
|
184
|
+
$[41] = t13;
|
|
185
|
+
$[42] = t15;
|
|
186
|
+
$[43] = t16;
|
|
187
|
+
$[44] = t17;
|
|
188
|
+
$[45] = t18;
|
|
189
|
+
$[46] = t19;
|
|
190
|
+
} else t19 = $[46];
|
|
191
|
+
let t20;
|
|
192
|
+
if ($[47] !== ariaLabel || $[48] !== font.probe || $[49] !== height || $[50] !== t19 || $[51] !== t7 || $[52] !== t8 || $[53] !== t9) {
|
|
193
|
+
t20 = /* @__PURE__ */ jsx(ChartFrame, {
|
|
194
|
+
"aria-label": ariaLabel,
|
|
195
|
+
height,
|
|
196
|
+
fontProbe: t6,
|
|
197
|
+
...t7,
|
|
198
|
+
legend: t8,
|
|
199
|
+
table: t9,
|
|
200
|
+
children: t19
|
|
201
|
+
});
|
|
202
|
+
$[47] = ariaLabel;
|
|
203
|
+
$[48] = font.probe;
|
|
204
|
+
$[49] = height;
|
|
205
|
+
$[50] = t19;
|
|
206
|
+
$[51] = t7;
|
|
207
|
+
$[52] = t8;
|
|
208
|
+
$[53] = t9;
|
|
209
|
+
$[54] = t20;
|
|
210
|
+
} else t20 = $[54];
|
|
211
|
+
return t20;
|
|
212
|
+
};
|
|
213
|
+
function _temp(item, index) {
|
|
214
|
+
return {
|
|
215
|
+
label: item.label,
|
|
216
|
+
color: seriesColor(index, item.color),
|
|
217
|
+
line: { dash: seriesDash(index) }
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export { AreaChart };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type CartesianChartProps } from "./chart-parts.js";
|
|
2
|
+
export interface BarChartProps extends CartesianChartProps {
|
|
3
|
+
/** Stack the series into one bar for each x value, so the bar's height is their total. Otherwise they stand side by side. */
|
|
4
|
+
stacked?: boolean | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Bars for each x value: a comparison between categories, or with `stacked` how each total divides into parts. The
|
|
8
|
+
* colours are the chart tokens and the data is also given to a screen reader as a table. Unlike the lines of a
|
|
9
|
+
* LineChart, the bars of several series differ only by colour and by their place in each group.
|
|
10
|
+
*/
|
|
11
|
+
export declare const BarChart: ({ data, xKey, xLabel, series, "aria-label": ariaLabel, height, formatX, formatValue, hideLegend, hideGrid, stacked, className, }: BarChartProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Bar, BarChart as BarChart$1, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
4
|
+
import { AXIS_LINE, AXIS_TICK, ChartDataTable, ChartFrame, ChartLegend, ChartTooltip, GRID_STROKE, seriesColor, useChartFontVersion, usePrefersReducedMotion } from "./chart-parts.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/patterns/Charts/BarChart.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Bars for each x value: a comparison between categories, or with `stacked` how each total divides into parts. The
|
|
9
|
+
* colours are the chart tokens and the data is also given to a screen reader as a table. Unlike the lines of a
|
|
10
|
+
* LineChart, the bars of several series differ only by colour and by their place in each group.
|
|
11
|
+
*/
|
|
12
|
+
var BarChart = (t0) => {
|
|
13
|
+
const $ = c(54);
|
|
14
|
+
const { data, xKey, xLabel, series, "aria-label": ariaLabel, height: t1, formatX, formatValue, hideLegend: t2, hideGrid: t3, stacked: t4, className } = t0;
|
|
15
|
+
const height = t1 === void 0 ? 240 : t1;
|
|
16
|
+
const hideLegend = t2 === void 0 ? false : t2;
|
|
17
|
+
const hideGrid = t3 === void 0 ? false : t3;
|
|
18
|
+
const stacked = t4 === void 0 ? false : t4;
|
|
19
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
20
|
+
const font = useChartFontVersion();
|
|
21
|
+
const t5 = font.probe;
|
|
22
|
+
let t6;
|
|
23
|
+
if ($[0] !== className) {
|
|
24
|
+
t6 = className ? { className } : {};
|
|
25
|
+
$[0] = className;
|
|
26
|
+
$[1] = t6;
|
|
27
|
+
} else t6 = $[1];
|
|
28
|
+
let t7;
|
|
29
|
+
if ($[2] !== hideLegend || $[3] !== series) {
|
|
30
|
+
t7 = hideLegend ? null : /* @__PURE__ */ jsx(ChartLegend, { items: series.map(_temp) });
|
|
31
|
+
$[2] = hideLegend;
|
|
32
|
+
$[3] = series;
|
|
33
|
+
$[4] = t7;
|
|
34
|
+
} else t7 = $[4];
|
|
35
|
+
let t8;
|
|
36
|
+
if ($[5] !== ariaLabel || $[6] !== data || $[7] !== formatValue || $[8] !== formatX || $[9] !== series || $[10] !== xKey || $[11] !== xLabel) {
|
|
37
|
+
t8 = /* @__PURE__ */ jsx(ChartDataTable, {
|
|
38
|
+
caption: ariaLabel,
|
|
39
|
+
data,
|
|
40
|
+
xKey,
|
|
41
|
+
xLabel,
|
|
42
|
+
series,
|
|
43
|
+
formatX,
|
|
44
|
+
formatValue
|
|
45
|
+
});
|
|
46
|
+
$[5] = ariaLabel;
|
|
47
|
+
$[6] = data;
|
|
48
|
+
$[7] = formatValue;
|
|
49
|
+
$[8] = formatX;
|
|
50
|
+
$[9] = series;
|
|
51
|
+
$[10] = xKey;
|
|
52
|
+
$[11] = xLabel;
|
|
53
|
+
$[12] = t8;
|
|
54
|
+
} else t8 = $[12];
|
|
55
|
+
const t9 = font.version;
|
|
56
|
+
let t10;
|
|
57
|
+
if ($[13] !== data) {
|
|
58
|
+
t10 = [...data];
|
|
59
|
+
$[13] = data;
|
|
60
|
+
$[14] = t10;
|
|
61
|
+
} else t10 = $[14];
|
|
62
|
+
let t11;
|
|
63
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t11 = {
|
|
65
|
+
top: 8,
|
|
66
|
+
right: 8,
|
|
67
|
+
bottom: 0,
|
|
68
|
+
left: 0
|
|
69
|
+
};
|
|
70
|
+
$[15] = t11;
|
|
71
|
+
} else t11 = $[15];
|
|
72
|
+
let t12;
|
|
73
|
+
if ($[16] !== hideGrid) {
|
|
74
|
+
t12 = hideGrid ? null : /* @__PURE__ */ jsx(CartesianGrid, {
|
|
75
|
+
vertical: false,
|
|
76
|
+
stroke: GRID_STROKE
|
|
77
|
+
});
|
|
78
|
+
$[16] = hideGrid;
|
|
79
|
+
$[17] = t12;
|
|
80
|
+
} else t12 = $[17];
|
|
81
|
+
let t13;
|
|
82
|
+
if ($[18] !== formatX) {
|
|
83
|
+
t13 = formatX ? { tickFormatter: formatX } : {};
|
|
84
|
+
$[18] = formatX;
|
|
85
|
+
$[19] = t13;
|
|
86
|
+
} else t13 = $[19];
|
|
87
|
+
let t14;
|
|
88
|
+
if ($[20] !== t13 || $[21] !== xKey) {
|
|
89
|
+
t14 = /* @__PURE__ */ jsx(XAxis, {
|
|
90
|
+
dataKey: xKey,
|
|
91
|
+
tickLine: false,
|
|
92
|
+
axisLine: AXIS_LINE,
|
|
93
|
+
tick: AXIS_TICK,
|
|
94
|
+
...t13
|
|
95
|
+
});
|
|
96
|
+
$[20] = t13;
|
|
97
|
+
$[21] = xKey;
|
|
98
|
+
$[22] = t14;
|
|
99
|
+
} else t14 = $[22];
|
|
100
|
+
let t15;
|
|
101
|
+
if ($[23] !== formatValue) {
|
|
102
|
+
t15 = /* @__PURE__ */ jsx(YAxis, {
|
|
103
|
+
width: "auto",
|
|
104
|
+
tickLine: false,
|
|
105
|
+
axisLine: false,
|
|
106
|
+
tick: AXIS_TICK,
|
|
107
|
+
...formatValue ? { tickFormatter: formatValue } : {}
|
|
108
|
+
});
|
|
109
|
+
$[23] = formatValue;
|
|
110
|
+
$[24] = t15;
|
|
111
|
+
} else t15 = $[24];
|
|
112
|
+
let t16;
|
|
113
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
114
|
+
t16 = {
|
|
115
|
+
fill: "var(--fast-chart-grid)",
|
|
116
|
+
fillOpacity: .6
|
|
117
|
+
};
|
|
118
|
+
$[25] = t16;
|
|
119
|
+
} else t16 = $[25];
|
|
120
|
+
let t17;
|
|
121
|
+
if ($[26] !== formatValue || $[27] !== formatX) {
|
|
122
|
+
t17 = /* @__PURE__ */ jsx(Tooltip, {
|
|
123
|
+
cursor: t16,
|
|
124
|
+
content: (props) => /* @__PURE__ */ jsx(ChartTooltip, {
|
|
125
|
+
...props,
|
|
126
|
+
formatLabel: formatX,
|
|
127
|
+
formatValue
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
$[26] = formatValue;
|
|
131
|
+
$[27] = formatX;
|
|
132
|
+
$[28] = t17;
|
|
133
|
+
} else t17 = $[28];
|
|
134
|
+
let t18;
|
|
135
|
+
if ($[29] !== font.version || $[30] !== reduceMotion || $[31] !== series || $[32] !== stacked) {
|
|
136
|
+
let t19;
|
|
137
|
+
if ($[34] !== font.version || $[35] !== reduceMotion || $[36] !== stacked) {
|
|
138
|
+
t19 = (item_0, index_0) => /* @__PURE__ */ jsx(Bar, {
|
|
139
|
+
dataKey: item_0.key,
|
|
140
|
+
name: item_0.label,
|
|
141
|
+
...stacked ? { stackId: "stack" } : {},
|
|
142
|
+
fill: seriesColor(index_0, item_0.color),
|
|
143
|
+
maxBarSize: 40,
|
|
144
|
+
radius: stacked ? 0 : [
|
|
145
|
+
4,
|
|
146
|
+
4,
|
|
147
|
+
0,
|
|
148
|
+
0
|
|
149
|
+
],
|
|
150
|
+
isAnimationActive: !reduceMotion && font.version === 0,
|
|
151
|
+
animationDuration: 400
|
|
152
|
+
}, item_0.key);
|
|
153
|
+
$[34] = font.version;
|
|
154
|
+
$[35] = reduceMotion;
|
|
155
|
+
$[36] = stacked;
|
|
156
|
+
$[37] = t19;
|
|
157
|
+
} else t19 = $[37];
|
|
158
|
+
t18 = series.map(t19);
|
|
159
|
+
$[29] = font.version;
|
|
160
|
+
$[30] = reduceMotion;
|
|
161
|
+
$[31] = series;
|
|
162
|
+
$[32] = stacked;
|
|
163
|
+
$[33] = t18;
|
|
164
|
+
} else t18 = $[33];
|
|
165
|
+
let t19;
|
|
166
|
+
if ($[38] !== font.version || $[39] !== t10 || $[40] !== t12 || $[41] !== t14 || $[42] !== t15 || $[43] !== t17 || $[44] !== t18) {
|
|
167
|
+
t19 = /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
168
|
+
width: "100%",
|
|
169
|
+
height: "100%",
|
|
170
|
+
children: /* @__PURE__ */ jsxs(BarChart$1, {
|
|
171
|
+
data: t10,
|
|
172
|
+
margin: t11,
|
|
173
|
+
accessibilityLayer: false,
|
|
174
|
+
children: [
|
|
175
|
+
t12,
|
|
176
|
+
t14,
|
|
177
|
+
t15,
|
|
178
|
+
t17,
|
|
179
|
+
t18
|
|
180
|
+
]
|
|
181
|
+
}, t9)
|
|
182
|
+
});
|
|
183
|
+
$[38] = font.version;
|
|
184
|
+
$[39] = t10;
|
|
185
|
+
$[40] = t12;
|
|
186
|
+
$[41] = t14;
|
|
187
|
+
$[42] = t15;
|
|
188
|
+
$[43] = t17;
|
|
189
|
+
$[44] = t18;
|
|
190
|
+
$[45] = t19;
|
|
191
|
+
} else t19 = $[45];
|
|
192
|
+
let t20;
|
|
193
|
+
if ($[46] !== ariaLabel || $[47] !== font.probe || $[48] !== height || $[49] !== t19 || $[50] !== t6 || $[51] !== t7 || $[52] !== t8) {
|
|
194
|
+
t20 = /* @__PURE__ */ jsx(ChartFrame, {
|
|
195
|
+
"aria-label": ariaLabel,
|
|
196
|
+
height,
|
|
197
|
+
fontProbe: t5,
|
|
198
|
+
...t6,
|
|
199
|
+
legend: t7,
|
|
200
|
+
table: t8,
|
|
201
|
+
children: t19
|
|
202
|
+
});
|
|
203
|
+
$[46] = ariaLabel;
|
|
204
|
+
$[47] = font.probe;
|
|
205
|
+
$[48] = height;
|
|
206
|
+
$[49] = t19;
|
|
207
|
+
$[50] = t6;
|
|
208
|
+
$[51] = t7;
|
|
209
|
+
$[52] = t8;
|
|
210
|
+
$[53] = t20;
|
|
211
|
+
} else t20 = $[53];
|
|
212
|
+
return t20;
|
|
213
|
+
};
|
|
214
|
+
function _temp(item, index) {
|
|
215
|
+
return {
|
|
216
|
+
label: item.label,
|
|
217
|
+
color: seriesColor(index, item.color)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
export { BarChart };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface DonutSlice {
|
|
3
|
+
/** Identifies the slice. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** The slice's name, in the user's language. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Its size: a count or an amount. The slices are drawn in proportion to their values. */
|
|
8
|
+
value: number;
|
|
9
|
+
/** A CSS colour or variable. The chart tokens in order of use if omitted. */
|
|
10
|
+
color?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface DonutChartProps {
|
|
13
|
+
/** The slices, in the order they go round the ring. With none nothing is drawn, and the data table has no rows. */
|
|
14
|
+
slices: readonly DonutSlice[];
|
|
15
|
+
/** What the chart shows, e.g. "Orders by status". It names the chart and its data table. */
|
|
16
|
+
"aria-label": string;
|
|
17
|
+
/** The heading of the data table's column of slice names, e.g. "Status". */
|
|
18
|
+
nameLabel: string;
|
|
19
|
+
/** The heading of the data table's column of values, e.g. "Orders". */
|
|
20
|
+
valueLabel: string;
|
|
21
|
+
/** Writes a value in the legend, the tooltip and the data table. */
|
|
22
|
+
formatValue?: ((value: number) => string) | undefined;
|
|
23
|
+
/** In the hole: a total, a score. It is hidden from a screen reader, so the data table must say the same. */
|
|
24
|
+
centerLabel?: ReactNode | undefined;
|
|
25
|
+
/** The size of the ring in pixels. Default 220. */
|
|
26
|
+
size?: number | undefined;
|
|
27
|
+
/** Leave out the legend under the chart. */
|
|
28
|
+
hideLegend?: boolean | undefined;
|
|
29
|
+
/** Extra classes for the chart's box. Merged last. */
|
|
30
|
+
className?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A ring divided into slices: how a whole splits into a few parts (five or fewer read well). The legend gives each
|
|
34
|
+
* slice's name and value, and the data is also given to a screen reader as a table. The colours are the chart
|
|
35
|
+
* tokens, so it follows the theme.
|
|
36
|
+
*/
|
|
37
|
+
export declare const DonutChart: ({ slices, "aria-label": ariaLabel, nameLabel, valueLabel, formatValue, centerLabel, size, hideLegend, className, }: DonutChartProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { Cell, Pie, PieChart, ResponsiveContainer, Tooltip } from "recharts";
|
|
4
|
+
import { ChartFrame, ChartLegend, ChartTooltip, seriesColor, usePrefersReducedMotion } from "./chart-parts.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/patterns/Charts/DonutChart.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A ring divided into slices: how a whole splits into a few parts (five or fewer read well). The legend gives each
|
|
9
|
+
* slice's name and value, and the data is also given to a screen reader as a table. The colours are the chart
|
|
10
|
+
* tokens, so it follows the theme.
|
|
11
|
+
*/
|
|
12
|
+
var DonutChart = (t0) => {
|
|
13
|
+
const $ = c(54);
|
|
14
|
+
const { slices, "aria-label": ariaLabel, nameLabel, valueLabel, formatValue, centerLabel, size: t1, hideLegend: t2, className } = t0;
|
|
15
|
+
const size = t1 === void 0 ? 220 : t1;
|
|
16
|
+
const hideLegend = t2 === void 0 ? false : t2;
|
|
17
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
18
|
+
let t3;
|
|
19
|
+
if ($[0] !== formatValue) {
|
|
20
|
+
t3 = (value) => formatValue ? formatValue(value) : String(value);
|
|
21
|
+
$[0] = formatValue;
|
|
22
|
+
$[1] = t3;
|
|
23
|
+
} else t3 = $[1];
|
|
24
|
+
const write = t3;
|
|
25
|
+
let t4;
|
|
26
|
+
if ($[2] !== className) {
|
|
27
|
+
t4 = className ? { className } : {};
|
|
28
|
+
$[2] = className;
|
|
29
|
+
$[3] = t4;
|
|
30
|
+
} else t4 = $[3];
|
|
31
|
+
let t5;
|
|
32
|
+
if ($[4] !== hideLegend || $[5] !== slices || $[6] !== write) {
|
|
33
|
+
t5 = hideLegend ? null : /* @__PURE__ */ jsx(ChartLegend, { items: slices.map((slice, index) => ({
|
|
34
|
+
label: slice.label,
|
|
35
|
+
color: seriesColor(index, slice.color),
|
|
36
|
+
value: write(slice.value)
|
|
37
|
+
})) });
|
|
38
|
+
$[4] = hideLegend;
|
|
39
|
+
$[5] = slices;
|
|
40
|
+
$[6] = write;
|
|
41
|
+
$[7] = t5;
|
|
42
|
+
} else t5 = $[7];
|
|
43
|
+
let t6;
|
|
44
|
+
if ($[8] !== ariaLabel) {
|
|
45
|
+
t6 = /* @__PURE__ */ jsx("caption", { children: ariaLabel });
|
|
46
|
+
$[8] = ariaLabel;
|
|
47
|
+
$[9] = t6;
|
|
48
|
+
} else t6 = $[9];
|
|
49
|
+
let t7;
|
|
50
|
+
if ($[10] !== nameLabel) {
|
|
51
|
+
t7 = /* @__PURE__ */ jsx("th", {
|
|
52
|
+
scope: "col",
|
|
53
|
+
children: nameLabel
|
|
54
|
+
});
|
|
55
|
+
$[10] = nameLabel;
|
|
56
|
+
$[11] = t7;
|
|
57
|
+
} else t7 = $[11];
|
|
58
|
+
let t8;
|
|
59
|
+
if ($[12] !== valueLabel) {
|
|
60
|
+
t8 = /* @__PURE__ */ jsx("th", {
|
|
61
|
+
scope: "col",
|
|
62
|
+
children: valueLabel
|
|
63
|
+
});
|
|
64
|
+
$[12] = valueLabel;
|
|
65
|
+
$[13] = t8;
|
|
66
|
+
} else t8 = $[13];
|
|
67
|
+
let t9;
|
|
68
|
+
if ($[14] !== t7 || $[15] !== t8) {
|
|
69
|
+
t9 = /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [t7, t8] }) });
|
|
70
|
+
$[14] = t7;
|
|
71
|
+
$[15] = t8;
|
|
72
|
+
$[16] = t9;
|
|
73
|
+
} else t9 = $[16];
|
|
74
|
+
let t10;
|
|
75
|
+
if ($[17] !== slices || $[18] !== write) {
|
|
76
|
+
let t11;
|
|
77
|
+
if ($[20] !== write) {
|
|
78
|
+
t11 = (slice_0) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
79
|
+
scope: "row",
|
|
80
|
+
children: slice_0.label
|
|
81
|
+
}), /* @__PURE__ */ jsx("td", { children: write(slice_0.value) })] }, slice_0.id);
|
|
82
|
+
$[20] = write;
|
|
83
|
+
$[21] = t11;
|
|
84
|
+
} else t11 = $[21];
|
|
85
|
+
t10 = slices.map(t11);
|
|
86
|
+
$[17] = slices;
|
|
87
|
+
$[18] = write;
|
|
88
|
+
$[19] = t10;
|
|
89
|
+
} else t10 = $[19];
|
|
90
|
+
let t11;
|
|
91
|
+
if ($[22] !== t10) {
|
|
92
|
+
t11 = /* @__PURE__ */ jsx("tbody", { children: t10 });
|
|
93
|
+
$[22] = t10;
|
|
94
|
+
$[23] = t11;
|
|
95
|
+
} else t11 = $[23];
|
|
96
|
+
let t12;
|
|
97
|
+
if ($[24] !== t11 || $[25] !== t6 || $[26] !== t9) {
|
|
98
|
+
t12 = /* @__PURE__ */ jsxs("table", {
|
|
99
|
+
className: "sr-only",
|
|
100
|
+
children: [
|
|
101
|
+
t6,
|
|
102
|
+
t9,
|
|
103
|
+
t11
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
$[24] = t11;
|
|
107
|
+
$[25] = t6;
|
|
108
|
+
$[26] = t9;
|
|
109
|
+
$[27] = t12;
|
|
110
|
+
} else t12 = $[27];
|
|
111
|
+
let t13;
|
|
112
|
+
if ($[28] !== formatValue) {
|
|
113
|
+
t13 = /* @__PURE__ */ jsx(Tooltip, { content: (props) => /* @__PURE__ */ jsx(ChartTooltip, {
|
|
114
|
+
...props,
|
|
115
|
+
formatValue
|
|
116
|
+
}) });
|
|
117
|
+
$[28] = formatValue;
|
|
118
|
+
$[29] = t13;
|
|
119
|
+
} else t13 = $[29];
|
|
120
|
+
let t14;
|
|
121
|
+
if ($[30] !== slices) {
|
|
122
|
+
t14 = slices.map(_temp);
|
|
123
|
+
$[30] = slices;
|
|
124
|
+
$[31] = t14;
|
|
125
|
+
} else t14 = $[31];
|
|
126
|
+
const t15 = slices.length > 1 ? 2 : 0;
|
|
127
|
+
const t16 = !reduceMotion;
|
|
128
|
+
let t17;
|
|
129
|
+
if ($[32] !== slices) {
|
|
130
|
+
t17 = slices.map(_temp2);
|
|
131
|
+
$[32] = slices;
|
|
132
|
+
$[33] = t17;
|
|
133
|
+
} else t17 = $[33];
|
|
134
|
+
let t18;
|
|
135
|
+
if ($[34] !== t14 || $[35] !== t15 || $[36] !== t16 || $[37] !== t17) {
|
|
136
|
+
t18 = /* @__PURE__ */ jsx(Pie, {
|
|
137
|
+
data: t14,
|
|
138
|
+
dataKey: "value",
|
|
139
|
+
nameKey: "label",
|
|
140
|
+
rootTabIndex: -1,
|
|
141
|
+
innerRadius: "62%",
|
|
142
|
+
outerRadius: "100%",
|
|
143
|
+
paddingAngle: t15,
|
|
144
|
+
stroke: "var(--fast-surface)",
|
|
145
|
+
strokeWidth: 2,
|
|
146
|
+
isAnimationActive: t16,
|
|
147
|
+
animationDuration: 400,
|
|
148
|
+
children: t17
|
|
149
|
+
});
|
|
150
|
+
$[34] = t14;
|
|
151
|
+
$[35] = t15;
|
|
152
|
+
$[36] = t16;
|
|
153
|
+
$[37] = t17;
|
|
154
|
+
$[38] = t18;
|
|
155
|
+
} else t18 = $[38];
|
|
156
|
+
let t19;
|
|
157
|
+
if ($[39] !== t13 || $[40] !== t18) {
|
|
158
|
+
t19 = /* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
159
|
+
width: "100%",
|
|
160
|
+
height: "100%",
|
|
161
|
+
children: /* @__PURE__ */ jsxs(PieChart, {
|
|
162
|
+
accessibilityLayer: false,
|
|
163
|
+
children: [t13, t18]
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
$[39] = t13;
|
|
167
|
+
$[40] = t18;
|
|
168
|
+
$[41] = t19;
|
|
169
|
+
} else t19 = $[41];
|
|
170
|
+
let t20;
|
|
171
|
+
if ($[42] !== centerLabel) {
|
|
172
|
+
t20 = centerLabel ? /* @__PURE__ */ jsx("div", {
|
|
173
|
+
className: "pointer-events-none absolute inset-0 flex items-center justify-center text-center text-body font-semibold text-fg",
|
|
174
|
+
children: centerLabel
|
|
175
|
+
}) : null;
|
|
176
|
+
$[42] = centerLabel;
|
|
177
|
+
$[43] = t20;
|
|
178
|
+
} else t20 = $[43];
|
|
179
|
+
let t21;
|
|
180
|
+
if ($[44] !== t19 || $[45] !== t20) {
|
|
181
|
+
t21 = /* @__PURE__ */ jsxs("div", {
|
|
182
|
+
className: "relative size-full",
|
|
183
|
+
children: [t19, t20]
|
|
184
|
+
});
|
|
185
|
+
$[44] = t19;
|
|
186
|
+
$[45] = t20;
|
|
187
|
+
$[46] = t21;
|
|
188
|
+
} else t21 = $[46];
|
|
189
|
+
let t22;
|
|
190
|
+
if ($[47] !== ariaLabel || $[48] !== size || $[49] !== t12 || $[50] !== t21 || $[51] !== t4 || $[52] !== t5) {
|
|
191
|
+
t22 = /* @__PURE__ */ jsx(ChartFrame, {
|
|
192
|
+
"aria-label": ariaLabel,
|
|
193
|
+
height: size,
|
|
194
|
+
...t4,
|
|
195
|
+
legend: t5,
|
|
196
|
+
table: t12,
|
|
197
|
+
children: t21
|
|
198
|
+
});
|
|
199
|
+
$[47] = ariaLabel;
|
|
200
|
+
$[48] = size;
|
|
201
|
+
$[49] = t12;
|
|
202
|
+
$[50] = t21;
|
|
203
|
+
$[51] = t4;
|
|
204
|
+
$[52] = t5;
|
|
205
|
+
$[53] = t22;
|
|
206
|
+
} else t22 = $[53];
|
|
207
|
+
return t22;
|
|
208
|
+
};
|
|
209
|
+
function _temp(slice_1) {
|
|
210
|
+
return { ...slice_1 };
|
|
211
|
+
}
|
|
212
|
+
function _temp2(slice_2, index_0) {
|
|
213
|
+
return /* @__PURE__ */ jsx(Cell, { fill: seriesColor(index_0, slice_2.color) }, slice_2.id);
|
|
214
|
+
}
|
|
215
|
+
export { DonutChart };
|