@soadtech/cli 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/dist/index.js +272 -0
- package/package.json +24 -0
- package/registry/base/cn.ts +5 -0
- package/registry/base/css-modules.d.ts +4 -0
- package/registry/base/theme/reset.css +43 -0
- package/registry/base/theme/tokens.css +154 -0
- package/registry/components/Accordion/Accordion.module.css +3 -0
- package/registry/components/Accordion/Accordion.tsx +54 -0
- package/registry/components/Accordion/Accordion.types.ts +17 -0
- package/registry/components/Accordion/AccordionContext.ts +18 -0
- package/registry/components/Accordion/AccordionItem.module.css +124 -0
- package/registry/components/Accordion/AccordionItem.tsx +148 -0
- package/registry/components/Accordion/AccordionItem.types.ts +14 -0
- package/registry/components/Accordion/index.ts +8 -0
- package/registry/components/ActionBar/ActionBar.module.css +18 -0
- package/registry/components/ActionBar/ActionBar.tsx +21 -0
- package/registry/components/ActionBar/ActionBar.types.ts +8 -0
- package/registry/components/ActionBar/ActionBarLink.module.css +31 -0
- package/registry/components/ActionBar/ActionBarLink.tsx +55 -0
- package/registry/components/ActionBar/ActionBarLink.types.ts +7 -0
- package/registry/components/ActionBar/index.ts +4 -0
- package/registry/components/Alert/Alert.module.css +172 -0
- package/registry/components/Alert/Alert.tsx +146 -0
- package/registry/components/Alert/Alert.types.ts +25 -0
- package/registry/components/Alert/index.ts +7 -0
- package/registry/components/Avatar/Avatar.module.css +100 -0
- package/registry/components/Avatar/Avatar.tsx +54 -0
- package/registry/components/Avatar/Avatar.types.ts +18 -0
- package/registry/components/Avatar/AvatarGroup.module.css +64 -0
- package/registry/components/Avatar/AvatarGroup.tsx +65 -0
- package/registry/components/Avatar/AvatarGroup.types.ts +13 -0
- package/registry/components/Avatar/index.ts +8 -0
- package/registry/components/Badge/Badge.module.css +92 -0
- package/registry/components/Badge/Badge.tsx +89 -0
- package/registry/components/Badge/Badge.types.ts +20 -0
- package/registry/components/Badge/TrendBadge.module.css +47 -0
- package/registry/components/Badge/TrendBadge.tsx +65 -0
- package/registry/components/Badge/TrendBadge.types.ts +15 -0
- package/registry/components/Badge/index.ts +14 -0
- package/registry/components/Breadcrumbs/BreadcrumbItem.tsx +41 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.module.css +81 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.tsx +71 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.types.ts +22 -0
- package/registry/components/Breadcrumbs/index.ts +7 -0
- package/registry/components/Button/Button.module.css +169 -0
- package/registry/components/Button/Button.tsx +43 -0
- package/registry/components/Button/Button.types.ts +18 -0
- package/registry/components/Button/index.ts +7 -0
- package/registry/components/ButtonLink/ButtonLink.module.css +85 -0
- package/registry/components/ButtonLink/ButtonLink.tsx +42 -0
- package/registry/components/ButtonLink/ButtonLink.types.ts +18 -0
- package/registry/components/ButtonLink/index.ts +6 -0
- package/registry/components/Calendar/Calendar.module.css +213 -0
- package/registry/components/Calendar/Calendar.tsx +370 -0
- package/registry/components/Calendar/Calendar.types.ts +28 -0
- package/registry/components/Calendar/CalendarDialog.module.css +29 -0
- package/registry/components/Calendar/CalendarDialog.tsx +173 -0
- package/registry/components/Calendar/CalendarDialog.types.ts +30 -0
- package/registry/components/Calendar/index.ts +9 -0
- package/registry/components/Card/Card.module.css +35 -0
- package/registry/components/Card/Card.tsx +36 -0
- package/registry/components/Card/Card.types.ts +37 -0
- package/registry/components/Card/CardContent.module.css +3 -0
- package/registry/components/Card/CardContent.tsx +16 -0
- package/registry/components/Card/CardFooter.module.css +31 -0
- package/registry/components/Card/CardFooter.tsx +34 -0
- package/registry/components/Card/CardHeader.module.css +61 -0
- package/registry/components/Card/CardHeader.tsx +46 -0
- package/registry/components/Card/InsightCard.module.css +106 -0
- package/registry/components/Card/InsightCard.tsx +68 -0
- package/registry/components/Card/InsightCard.types.ts +24 -0
- package/registry/components/Card/KPICard.module.css +31 -0
- package/registry/components/Card/KPICard.tsx +29 -0
- package/registry/components/Card/KPICard.types.ts +13 -0
- package/registry/components/Card/ListItemCard.module.css +59 -0
- package/registry/components/Card/ListItemCard.tsx +37 -0
- package/registry/components/Card/ListItemCard.types.ts +18 -0
- package/registry/components/Card/PlanCard.module.css +125 -0
- package/registry/components/Card/PlanCard.tsx +108 -0
- package/registry/components/Card/PlanCard.types.ts +30 -0
- package/registry/components/Card/ProductCard.module.css +118 -0
- package/registry/components/Card/ProductCard.tsx +56 -0
- package/registry/components/Card/ProductCard.types.ts +24 -0
- package/registry/components/Card/StatCard.module.css +20 -0
- package/registry/components/Card/StatCard.tsx +26 -0
- package/registry/components/Card/StatCard.types.ts +12 -0
- package/registry/components/Card/UserGroupCard.module.css +50 -0
- package/registry/components/Card/UserGroupCard.tsx +59 -0
- package/registry/components/Card/UserGroupCard.types.ts +23 -0
- package/registry/components/Card/index.ts +38 -0
- package/registry/components/Chart/BarChart.module.css +54 -0
- package/registry/components/Chart/BarChart.tsx +196 -0
- package/registry/components/Chart/BarChart.types.ts +20 -0
- package/registry/components/Chart/ChartAction.module.css +43 -0
- package/registry/components/Chart/ChartAction.tsx +35 -0
- package/registry/components/Chart/ChartAction.types.ts +17 -0
- package/registry/components/Chart/ChartAxis.module.css +47 -0
- package/registry/components/Chart/ChartAxis.tsx +79 -0
- package/registry/components/Chart/ChartAxis.types.ts +14 -0
- package/registry/components/Chart/ChartLegend.module.css +31 -0
- package/registry/components/Chart/ChartLegend.tsx +49 -0
- package/registry/components/Chart/ChartLegend.types.ts +18 -0
- package/registry/components/Chart/ChartTooltip.module.css +54 -0
- package/registry/components/Chart/ChartTooltip.tsx +44 -0
- package/registry/components/Chart/ChartTooltip.types.ts +19 -0
- package/registry/components/Chart/DonutChart.module.css +32 -0
- package/registry/components/Chart/DonutChart.tsx +107 -0
- package/registry/components/Chart/DonutChart.types.ts +20 -0
- package/registry/components/Chart/GridChart.module.css +26 -0
- package/registry/components/Chart/GridChart.tsx +61 -0
- package/registry/components/Chart/GridChart.types.ts +14 -0
- package/registry/components/Chart/HoverTooltip.module.css +16 -0
- package/registry/components/Chart/HoverTooltip.tsx +22 -0
- package/registry/components/Chart/KPIIndicator.module.css +48 -0
- package/registry/components/Chart/KPIIndicator.tsx +28 -0
- package/registry/components/Chart/KPIIndicator.types.ts +16 -0
- package/registry/components/Chart/LineChart.module.css +54 -0
- package/registry/components/Chart/LineChart.tsx +282 -0
- package/registry/components/Chart/LineChart.types.ts +22 -0
- package/registry/components/Chart/ProgressChart.module.css +54 -0
- package/registry/components/Chart/ProgressChart.tsx +64 -0
- package/registry/components/Chart/ProgressChart.types.ts +18 -0
- package/registry/components/Chart/TrendLineChart.module.css +5 -0
- package/registry/components/Chart/TrendLineChart.tsx +131 -0
- package/registry/components/Chart/TrendLineChart.types.ts +19 -0
- package/registry/components/Chart/chart.utils.ts +131 -0
- package/registry/components/Chart/index.ts +47 -0
- package/registry/components/Chart/useChartHover.ts +24 -0
- package/registry/components/Checkbox/Checkbox.module.css +101 -0
- package/registry/components/Checkbox/Checkbox.tsx +100 -0
- package/registry/components/Checkbox/Checkbox.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxField.module.css +69 -0
- package/registry/components/Checkbox/CheckboxField.tsx +54 -0
- package/registry/components/Checkbox/CheckboxField.types.ts +9 -0
- package/registry/components/Checkbox/CheckboxGroup.module.css +41 -0
- package/registry/components/Checkbox/CheckboxGroup.tsx +60 -0
- package/registry/components/Checkbox/CheckboxGroup.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxGroupContext.ts +13 -0
- package/registry/components/Checkbox/index.ts +11 -0
- package/registry/components/Chip/Chip.module.css +143 -0
- package/registry/components/Chip/Chip.tsx +93 -0
- package/registry/components/Chip/Chip.types.ts +19 -0
- package/registry/components/Chip/ChipGroup.module.css +5 -0
- package/registry/components/Chip/ChipGroup.tsx +16 -0
- package/registry/components/Chip/ChipGroup.types.ts +3 -0
- package/registry/components/Chip/index.ts +9 -0
- package/registry/components/Datepicker/Datepicker.module.css +133 -0
- package/registry/components/Datepicker/Datepicker.tsx +236 -0
- package/registry/components/Datepicker/Datepicker.types.ts +36 -0
- package/registry/components/Datepicker/index.ts +2 -0
- package/registry/components/Dialog/Dialog.module.css +18 -0
- package/registry/components/Dialog/Dialog.tsx +69 -0
- package/registry/components/Dialog/Dialog.types.ts +45 -0
- package/registry/components/Dialog/DialogBody.module.css +3 -0
- package/registry/components/Dialog/DialogBody.tsx +16 -0
- package/registry/components/Dialog/DialogContext.ts +11 -0
- package/registry/components/Dialog/DialogFooter.module.css +38 -0
- package/registry/components/Dialog/DialogFooter.tsx +30 -0
- package/registry/components/Dialog/DialogHeader.module.css +70 -0
- package/registry/components/Dialog/DialogHeader.tsx +72 -0
- package/registry/components/Dialog/DialogIcon.module.css +31 -0
- package/registry/components/Dialog/DialogIcon.tsx +89 -0
- package/registry/components/Dialog/index.ts +14 -0
- package/registry/components/Divider/Divider.module.css +19 -0
- package/registry/components/Divider/Divider.tsx +20 -0
- package/registry/components/Divider/Divider.types.ts +9 -0
- package/registry/components/Divider/index.ts +2 -0
- package/registry/components/DropdownMenu/DropdownMenu.module.css +9 -0
- package/registry/components/DropdownMenu/DropdownMenu.tsx +21 -0
- package/registry/components/DropdownMenu/DropdownMenu.types.ts +22 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.module.css +5 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.tsx +20 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.module.css +7 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.tsx +17 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.module.css +78 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.tsx +40 -0
- package/registry/components/DropdownMenu/index.ts +10 -0
- package/registry/components/FileUpload/FileUpload.module.css +122 -0
- package/registry/components/FileUpload/FileUpload.tsx +354 -0
- package/registry/components/FileUpload/FileUpload.types.ts +89 -0
- package/registry/components/FileUpload/FileUploadIcon.module.css +61 -0
- package/registry/components/FileUpload/FileUploadIcon.tsx +84 -0
- package/registry/components/FileUpload/FileUploadInput.module.css +140 -0
- package/registry/components/FileUpload/FileUploadInput.tsx +113 -0
- package/registry/components/FileUpload/FileUploadItem.module.css +41 -0
- package/registry/components/FileUpload/FileUploadItem.tsx +39 -0
- package/registry/components/FileUpload/index.ts +12 -0
- package/registry/components/InputCounter/InputCounter.module.css +146 -0
- package/registry/components/InputCounter/InputCounter.tsx +232 -0
- package/registry/components/InputCounter/InputCounter.types.ts +37 -0
- package/registry/components/InputCounter/index.ts +7 -0
- package/registry/components/InputMessage/InputMessage.module.css +148 -0
- package/registry/components/InputMessage/InputMessage.tsx +294 -0
- package/registry/components/InputMessage/InputMessage.types.ts +30 -0
- package/registry/components/InputMessage/index.ts +2 -0
- package/registry/components/InputSearch/InputSearch.module.css +168 -0
- package/registry/components/InputSearch/InputSearch.tsx +251 -0
- package/registry/components/InputSearch/InputSearch.types.ts +35 -0
- package/registry/components/InputSearch/index.ts +6 -0
- package/registry/components/InputText/InputText.module.css +183 -0
- package/registry/components/InputText/InputText.tsx +244 -0
- package/registry/components/InputText/InputText.types.ts +32 -0
- package/registry/components/InputText/index.ts +7 -0
- package/registry/components/InputTextArea/InputTextArea.module.css +141 -0
- package/registry/components/InputTextArea/InputTextArea.tsx +170 -0
- package/registry/components/InputTextArea/InputTextArea.types.ts +18 -0
- package/registry/components/InputTextArea/index.ts +6 -0
- package/registry/components/NavbarUser/NavbarUser.module.css +265 -0
- package/registry/components/NavbarUser/NavbarUser.tsx +202 -0
- package/registry/components/NavbarUser/NavbarUser.types.ts +31 -0
- package/registry/components/NavbarUser/index.ts +2 -0
- package/registry/components/Notification/Notification.types.ts +65 -0
- package/registry/components/Notification/NotificationItem.module.css +143 -0
- package/registry/components/Notification/NotificationItem.tsx +157 -0
- package/registry/components/Notification/NotificationPanel.module.css +75 -0
- package/registry/components/Notification/NotificationPanel.tsx +68 -0
- package/registry/components/Notification/NotificationReply.module.css +56 -0
- package/registry/components/Notification/NotificationReply.tsx +52 -0
- package/registry/components/Notification/index.ts +9 -0
- package/registry/components/Pagination/Pagination.module.css +123 -0
- package/registry/components/Pagination/Pagination.tsx +212 -0
- package/registry/components/Pagination/Pagination.types.ts +24 -0
- package/registry/components/Pagination/PaginationDots.module.css +60 -0
- package/registry/components/Pagination/PaginationDots.tsx +48 -0
- package/registry/components/Pagination/PaginationDots.types.ts +17 -0
- package/registry/components/Pagination/index.ts +12 -0
- package/registry/components/Persona/MessageDropdown.module.css +76 -0
- package/registry/components/Persona/MessageDropdown.tsx +68 -0
- package/registry/components/Persona/Persona.module.css +92 -0
- package/registry/components/Persona/Persona.tsx +90 -0
- package/registry/components/Persona/Persona.types.ts +71 -0
- package/registry/components/Persona/PersonaAction.module.css +80 -0
- package/registry/components/Persona/PersonaAction.tsx +49 -0
- package/registry/components/Persona/PersonaMessage.module.css +156 -0
- package/registry/components/Persona/PersonaMessage.tsx +70 -0
- package/registry/components/Persona/index.ts +11 -0
- package/registry/components/Progress/Progress.module.css +41 -0
- package/registry/components/Progress/Progress.tsx +43 -0
- package/registry/components/Progress/Progress.types.ts +10 -0
- package/registry/components/Progress/index.ts +2 -0
- package/registry/components/RadioButton/RadioButton.module.css +103 -0
- package/registry/components/RadioButton/RadioButton.tsx +59 -0
- package/registry/components/RadioButton/RadioButton.types.ts +19 -0
- package/registry/components/RadioButton/RadioField.module.css +68 -0
- package/registry/components/RadioButton/RadioField.tsx +68 -0
- package/registry/components/RadioButton/RadioGroup.module.css +41 -0
- package/registry/components/RadioButton/RadioGroup.tsx +76 -0
- package/registry/components/RadioButton/RadioGroupContext.ts +16 -0
- package/registry/components/RadioButton/index.ts +12 -0
- package/registry/components/RangeSlider/RangeSlider.module.css +133 -0
- package/registry/components/RangeSlider/RangeSlider.tsx +251 -0
- package/registry/components/RangeSlider/RangeSlider.types.ts +25 -0
- package/registry/components/RangeSlider/index.ts +2 -0
- package/registry/components/Rating/Rating.module.css +56 -0
- package/registry/components/Rating/Rating.tsx +142 -0
- package/registry/components/Rating/Rating.types.ts +14 -0
- package/registry/components/Rating/index.ts +7 -0
- package/registry/components/SegmentedControl/SegmentedControl.module.css +56 -0
- package/registry/components/SegmentedControl/SegmentedControl.tsx +46 -0
- package/registry/components/SegmentedControl/SegmentedControl.types.ts +27 -0
- package/registry/components/SegmentedControl/SegmentedControlContext.ts +20 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.module.css +55 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.tsx +32 -0
- package/registry/components/SegmentedControl/index.ts +8 -0
- package/registry/components/SelectDropdown/SelectDropdown.module.css +214 -0
- package/registry/components/SelectDropdown/SelectDropdown.tsx +375 -0
- package/registry/components/SelectDropdown/SelectDropdown.types.ts +50 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.module.css +101 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.tsx +86 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.module.css +74 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.tsx +202 -0
- package/registry/components/SelectDropdown/index.ts +11 -0
- package/registry/components/Sidebar/Sidebar.module.css +14 -0
- package/registry/components/Sidebar/Sidebar.tsx +41 -0
- package/registry/components/Sidebar/Sidebar.types.ts +41 -0
- package/registry/components/Sidebar/SidebarContent.module.css +5 -0
- package/registry/components/Sidebar/SidebarContent.tsx +14 -0
- package/registry/components/Sidebar/SidebarContext.ts +15 -0
- package/registry/components/Sidebar/SidebarDivider.module.css +5 -0
- package/registry/components/Sidebar/SidebarDivider.tsx +17 -0
- package/registry/components/Sidebar/SidebarFooter.module.css +5 -0
- package/registry/components/Sidebar/SidebarFooter.tsx +14 -0
- package/registry/components/Sidebar/SidebarGroup.module.css +12 -0
- package/registry/components/Sidebar/SidebarGroup.tsx +22 -0
- package/registry/components/Sidebar/SidebarHeader.module.css +5 -0
- package/registry/components/Sidebar/SidebarHeader.tsx +14 -0
- package/registry/components/Sidebar/SidebarNavItem.module.css +176 -0
- package/registry/components/Sidebar/SidebarNavItem.tsx +96 -0
- package/registry/components/Sidebar/index.ts +16 -0
- package/registry/components/Stepper/Stepper.module.css +11 -0
- package/registry/components/Stepper/Stepper.tsx +47 -0
- package/registry/components/Stepper/Stepper.types.ts +26 -0
- package/registry/components/Stepper/StepperContext.ts +17 -0
- package/registry/components/Stepper/StepperStep.module.css +183 -0
- package/registry/components/Stepper/StepperStep.tsx +204 -0
- package/registry/components/Stepper/index.ts +9 -0
- package/registry/components/Switch/Switch.module.css +145 -0
- package/registry/components/Switch/Switch.tsx +96 -0
- package/registry/components/Switch/Switch.types.ts +19 -0
- package/registry/components/Switch/SwitchField.module.css +69 -0
- package/registry/components/Switch/SwitchField.tsx +49 -0
- package/registry/components/Switch/index.ts +8 -0
- package/registry/components/Tab/Tab.module.css +20 -0
- package/registry/components/Tab/Tab.tsx +35 -0
- package/registry/components/Tab/Tab.types.ts +21 -0
- package/registry/components/Tab/TabAdd.module.css +36 -0
- package/registry/components/Tab/TabAdd.tsx +41 -0
- package/registry/components/Tab/TabContext.ts +19 -0
- package/registry/components/Tab/TabItem.module.css +145 -0
- package/registry/components/Tab/TabItem.tsx +87 -0
- package/registry/components/Tab/index.ts +9 -0
- package/registry/components/Table/Table.module.css +33 -0
- package/registry/components/Table/Table.tsx +74 -0
- package/registry/components/Table/Table.types.ts +64 -0
- package/registry/components/Table/TableBody.tsx +23 -0
- package/registry/components/Table/TableCell.module.css +21 -0
- package/registry/components/Table/TableCell.tsx +20 -0
- package/registry/components/Table/TableContext.ts +22 -0
- package/registry/components/Table/TableFooter.module.css +27 -0
- package/registry/components/Table/TableFooter.tsx +20 -0
- package/registry/components/Table/TableHeader.module.css +3 -0
- package/registry/components/Table/TableHeader.tsx +17 -0
- package/registry/components/Table/TableHeaderCell.module.css +55 -0
- package/registry/components/Table/TableHeaderCell.tsx +98 -0
- package/registry/components/Table/TableRow.module.css +53 -0
- package/registry/components/Table/TableRow.tsx +31 -0
- package/registry/components/Table/TableToolbar.module.css +7 -0
- package/registry/components/Table/TableToolbar.tsx +16 -0
- package/registry/components/Table/index.ts +22 -0
- package/registry/components/Tag/Tag.module.css +46 -0
- package/registry/components/Tag/Tag.tsx +38 -0
- package/registry/components/Tag/Tag.types.ts +37 -0
- package/registry/components/Tag/TagBrand.module.css +42 -0
- package/registry/components/Tag/TagBrand.tsx +38 -0
- package/registry/components/Tag/TagStatus.module.css +43 -0
- package/registry/components/Tag/TagStatus.tsx +119 -0
- package/registry/components/Tag/index.ts +15 -0
- package/registry/components/Tooltip/Tooltip.module.css +208 -0
- package/registry/components/Tooltip/Tooltip.tsx +81 -0
- package/registry/components/Tooltip/Tooltip.types.ts +27 -0
- package/registry/components/Tooltip/index.ts +7 -0
- package/registry/components/TreeviewList/TreeviewItem.module.css +89 -0
- package/registry/components/TreeviewList/TreeviewItem.tsx +142 -0
- package/registry/components/TreeviewList/TreeviewList.module.css +3 -0
- package/registry/components/TreeviewList/TreeviewList.tsx +19 -0
- package/registry/components/TreeviewList/TreeviewList.types.ts +18 -0
- package/registry/components/TreeviewList/TreeviewListContext.ts +13 -0
- package/registry/components/TreeviewList/index.ts +6 -0
- package/registry/components/VerificationCode/VerificationCode.module.css +49 -0
- package/registry/components/VerificationCode/VerificationCode.tsx +147 -0
- package/registry/components/VerificationCode/VerificationCode.types.ts +21 -0
- package/registry/components/VerificationCode/index.ts +2 -0
- package/registry/registry.json +746 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ChartAxisProps } from './ChartAxis.types';
|
|
2
|
+
import styles from './ChartAxis.module.css';
|
|
3
|
+
|
|
4
|
+
function defaultFormatY(value: number): string {
|
|
5
|
+
if (value >= 1000) return `${(value / 1000).toFixed(value % 1000 === 0 ? 0 : 1)}k`;
|
|
6
|
+
return String(value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ChartAxis({
|
|
10
|
+
yTicks,
|
|
11
|
+
xLabels,
|
|
12
|
+
chartWidth,
|
|
13
|
+
chartHeight,
|
|
14
|
+
gridLines = true,
|
|
15
|
+
formatY = defaultFormatY,
|
|
16
|
+
}: ChartAxisProps) {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
className={styles.root}
|
|
20
|
+
style={
|
|
21
|
+
{
|
|
22
|
+
'--ca-chart-w': `${chartWidth}px`,
|
|
23
|
+
'--ca-chart-h': `${chartHeight}px`,
|
|
24
|
+
} as React.CSSProperties
|
|
25
|
+
}
|
|
26
|
+
>
|
|
27
|
+
{/* Y-axis labels */}
|
|
28
|
+
<div className={styles.yAxis}>
|
|
29
|
+
{[...yTicks].reverse().map((tick, i) => (
|
|
30
|
+
<span key={i} className={styles.yLabel}>
|
|
31
|
+
{formatY(tick)}
|
|
32
|
+
</span>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
{/* Chart area placeholder — children injected by parent */}
|
|
37
|
+
<div className={styles.chartArea}>
|
|
38
|
+
{/* Grid lines SVG */}
|
|
39
|
+
{gridLines && (
|
|
40
|
+
<svg
|
|
41
|
+
className={styles.grid}
|
|
42
|
+
width={chartWidth}
|
|
43
|
+
height={chartHeight}
|
|
44
|
+
viewBox={`0 0 ${chartWidth} ${chartHeight}`}
|
|
45
|
+
>
|
|
46
|
+
{yTicks.map((_, i) => {
|
|
47
|
+
const y =
|
|
48
|
+
chartHeight -
|
|
49
|
+
(i / (yTicks.length - 1)) * chartHeight;
|
|
50
|
+
return (
|
|
51
|
+
<line
|
|
52
|
+
key={i}
|
|
53
|
+
x1={0}
|
|
54
|
+
y1={y}
|
|
55
|
+
x2={chartWidth}
|
|
56
|
+
y2={y}
|
|
57
|
+
stroke="var(--st-color-chart-grid)"
|
|
58
|
+
strokeWidth="1"
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
})}
|
|
62
|
+
</svg>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
{/* Spacer in bottom-left corner */}
|
|
67
|
+
<div />
|
|
68
|
+
|
|
69
|
+
{/* X-axis labels */}
|
|
70
|
+
<div className={styles.xAxis}>
|
|
71
|
+
{xLabels.map((label, i) => (
|
|
72
|
+
<span key={i} className={styles.xLabel}>
|
|
73
|
+
{label}
|
|
74
|
+
</span>
|
|
75
|
+
))}
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ChartAxisProps {
|
|
2
|
+
/** Y-axis tick values (bottom to top) */
|
|
3
|
+
yTicks: number[];
|
|
4
|
+
/** X-axis labels */
|
|
5
|
+
xLabels: string[];
|
|
6
|
+
/** Chart area width in px */
|
|
7
|
+
chartWidth: number;
|
|
8
|
+
/** Chart area height in px */
|
|
9
|
+
chartHeight: number;
|
|
10
|
+
/** Show horizontal grid lines */
|
|
11
|
+
gridLines?: boolean;
|
|
12
|
+
/** Format Y-axis tick values */
|
|
13
|
+
formatY?: (value: number) => string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.group {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--st-space-4);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.label {
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: var(--st-space-2);
|
|
12
|
+
font-family: var(--st-font-family);
|
|
13
|
+
font-size: var(--st-font-size-sm);
|
|
14
|
+
color: var(--st-color-foreground);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.indicator {
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dot {
|
|
22
|
+
width: 8px;
|
|
23
|
+
height: 8px;
|
|
24
|
+
border-radius: var(--st-radius-full);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.line {
|
|
28
|
+
width: 16px;
|
|
29
|
+
height: 3px;
|
|
30
|
+
border-radius: var(--st-radius-full);
|
|
31
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { LegendLabelProps, LegendGroupProps } from './ChartLegend.types';
|
|
4
|
+
import styles from './ChartLegend.module.css';
|
|
5
|
+
|
|
6
|
+
const COLOR_INDEX_MAP: Record<number, string> = {
|
|
7
|
+
1: 'var(--st-color-chart-1)',
|
|
8
|
+
2: 'var(--st-color-chart-2)',
|
|
9
|
+
3: 'var(--st-color-chart-3)',
|
|
10
|
+
4: 'var(--st-color-chart-4)',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const LegendLabel = forwardRef<HTMLSpanElement, LegendLabelProps>(
|
|
14
|
+
(
|
|
15
|
+
{ label, colorIndex = 1, color, variant = 'dot', className, style, ...rest },
|
|
16
|
+
ref
|
|
17
|
+
) => {
|
|
18
|
+
const resolvedColor = color ?? COLOR_INDEX_MAP[colorIndex] ?? COLOR_INDEX_MAP[1];
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(styles.label, className)}
|
|
24
|
+
style={style}
|
|
25
|
+
{...rest}
|
|
26
|
+
>
|
|
27
|
+
<span
|
|
28
|
+
className={cn(styles.indicator, styles[variant])}
|
|
29
|
+
style={{ backgroundColor: resolvedColor }}
|
|
30
|
+
/>
|
|
31
|
+
{label}
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
LegendLabel.displayName = 'LegendLabel';
|
|
38
|
+
|
|
39
|
+
export const LegendGroup = forwardRef<HTMLDivElement, LegendGroupProps>(
|
|
40
|
+
({ children, className, ...rest }, ref) => {
|
|
41
|
+
return (
|
|
42
|
+
<div ref={ref} className={cn(styles.group, className)} {...rest}>
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
LegendGroup.displayName = 'LegendGroup';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type LegendLabelVariant = 'dot' | 'line';
|
|
4
|
+
|
|
5
|
+
export interface LegendLabelProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
/** Label text */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Color index (1–4) maps to --st-color-chart-N */
|
|
9
|
+
colorIndex?: number;
|
|
10
|
+
/** Custom color override */
|
|
11
|
+
color?: string;
|
|
12
|
+
/** Dot or line indicator */
|
|
13
|
+
variant?: LegendLabelVariant;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface LegendGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
background-color: var(--st-color-chart-tooltip-bg);
|
|
5
|
+
color: var(--st-color-chart-tooltip-fg);
|
|
6
|
+
border-radius: var(--st-radius-lg);
|
|
7
|
+
padding: var(--st-space-2) var(--st-space-3);
|
|
8
|
+
font-family: var(--st-font-family);
|
|
9
|
+
font-size: var(--st-font-size-sm);
|
|
10
|
+
gap: var(--st-space-1);
|
|
11
|
+
box-shadow: var(--st-shadow-lg);
|
|
12
|
+
min-width: 100px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.item {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: var(--st-space-2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.dot {
|
|
22
|
+
width: 8px;
|
|
23
|
+
height: 8px;
|
|
24
|
+
border-radius: var(--st-radius-full);
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.label {
|
|
29
|
+
flex: 1;
|
|
30
|
+
opacity: 0.8;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.value {
|
|
34
|
+
font-weight: var(--st-font-weight-semibold);
|
|
35
|
+
margin-left: var(--st-space-3);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ─── Variants ─── */
|
|
39
|
+
|
|
40
|
+
.simple .item {
|
|
41
|
+
gap: var(--st-space-2);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.detailed {
|
|
45
|
+
padding: var(--st-space-3) var(--st-space-4);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.detailed .value {
|
|
49
|
+
font-size: var(--st-font-size-md);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.multi {
|
|
53
|
+
gap: var(--st-space-2);
|
|
54
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { ChartTooltipProps } from './ChartTooltip.types';
|
|
4
|
+
import styles from './ChartTooltip.module.css';
|
|
5
|
+
|
|
6
|
+
const COLOR_INDEX_MAP: Record<number, string> = {
|
|
7
|
+
1: 'var(--st-color-chart-1)',
|
|
8
|
+
2: 'var(--st-color-chart-2)',
|
|
9
|
+
3: 'var(--st-color-chart-3)',
|
|
10
|
+
4: 'var(--st-color-chart-4)',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ChartTooltip = forwardRef<HTMLDivElement, ChartTooltipProps>(
|
|
14
|
+
({ items, variant = 'simple', visible = true, className, ...rest }, ref) => {
|
|
15
|
+
if (!visible) return null;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(styles.root, styles[variant], className)}
|
|
21
|
+
role="tooltip"
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{items.map((item, i) => (
|
|
25
|
+
<div key={i} className={styles.item}>
|
|
26
|
+
{item.colorIndex && (
|
|
27
|
+
<span
|
|
28
|
+
className={styles.dot}
|
|
29
|
+
style={{
|
|
30
|
+
backgroundColor:
|
|
31
|
+
COLOR_INDEX_MAP[item.colorIndex] ?? COLOR_INDEX_MAP[1],
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
)}
|
|
35
|
+
<span className={styles.label}>{item.label}</span>
|
|
36
|
+
{item.value && <span className={styles.value}>{item.value}</span>}
|
|
37
|
+
</div>
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
ChartTooltip.displayName = 'ChartTooltip';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ChartTooltipVariant = 'simple' | 'detailed' | 'multi';
|
|
4
|
+
|
|
5
|
+
export interface ChartTooltipItem {
|
|
6
|
+
label: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
/** Color index (1–4) for the dot indicator */
|
|
9
|
+
colorIndex?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ChartTooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
/** Tooltip items */
|
|
14
|
+
items: ChartTooltipItem[];
|
|
15
|
+
/** Tooltip variant */
|
|
16
|
+
variant?: ChartTooltipVariant;
|
|
17
|
+
/** Visibility */
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
font-family: var(--st-font-family);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.root svg {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.center {
|
|
14
|
+
position: absolute;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
text-align: center;
|
|
20
|
+
font-size: var(--st-font-size-sm);
|
|
21
|
+
color: var(--st-color-foreground);
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.dark {
|
|
26
|
+
background-color: var(--st-color-neutral-900);
|
|
27
|
+
border-radius: var(--st-radius-2xl);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dark .center {
|
|
31
|
+
color: var(--st-color-chart-tooltip-fg);
|
|
32
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { forwardRef, useMemo, useState } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { normalizeSegments, donutArc } from './chart.utils';
|
|
4
|
+
import { useChartHover } from './useChartHover';
|
|
5
|
+
import { HoverTooltip } from './HoverTooltip';
|
|
6
|
+
import type { DonutChartProps } from './DonutChart.types';
|
|
7
|
+
import styles from './DonutChart.module.css';
|
|
8
|
+
|
|
9
|
+
const SEGMENT_COLORS = [
|
|
10
|
+
'var(--st-color-chart-1)',
|
|
11
|
+
'var(--st-color-chart-2)',
|
|
12
|
+
'var(--st-color-chart-3)',
|
|
13
|
+
'var(--st-color-chart-4)',
|
|
14
|
+
'var(--st-color-chart-1-muted)',
|
|
15
|
+
'var(--st-color-chart-2-muted)',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export const DonutChart = forwardRef<HTMLDivElement, DonutChartProps>(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
segments,
|
|
22
|
+
centerLabel,
|
|
23
|
+
thickness = 24,
|
|
24
|
+
size = 160,
|
|
25
|
+
dark = false,
|
|
26
|
+
className,
|
|
27
|
+
...rest
|
|
28
|
+
},
|
|
29
|
+
ref
|
|
30
|
+
) => {
|
|
31
|
+
const fractions = useMemo(
|
|
32
|
+
() => normalizeSegments(segments.map((s) => s.value)),
|
|
33
|
+
[segments]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const half = size / 2;
|
|
37
|
+
const outerR = half - 2;
|
|
38
|
+
const innerR = outerR - thickness;
|
|
39
|
+
|
|
40
|
+
const arcs = useMemo(() => {
|
|
41
|
+
const paths: { d: string; color: string; midX: number; midY: number; index: number }[] = [];
|
|
42
|
+
let angle = -Math.PI / 2;
|
|
43
|
+
|
|
44
|
+
fractions.forEach((frac, i) => {
|
|
45
|
+
if (frac <= 0) return;
|
|
46
|
+
const sweep = frac * Math.PI * 2;
|
|
47
|
+
const d = donutArc(half, half, outerR, innerR, angle, angle + sweep);
|
|
48
|
+
if (d) {
|
|
49
|
+
const midAngle = angle + sweep / 2;
|
|
50
|
+
const midR = (outerR + innerR) / 2;
|
|
51
|
+
paths.push({
|
|
52
|
+
d,
|
|
53
|
+
color: SEGMENT_COLORS[i % SEGMENT_COLORS.length],
|
|
54
|
+
midX: half + midR * Math.cos(midAngle),
|
|
55
|
+
midY: half + midR * Math.sin(midAngle),
|
|
56
|
+
index: i,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
angle += sweep;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return paths;
|
|
63
|
+
}, [fractions, half, outerR, innerR]);
|
|
64
|
+
|
|
65
|
+
const { hover, show, hide } = useChartHover();
|
|
66
|
+
const [activeIdx, setActiveIdx] = useState<number | null>(null);
|
|
67
|
+
|
|
68
|
+
const total = segments.reduce((s, seg) => s + seg.value, 0);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn(styles.root, dark && styles.dark, className)}
|
|
74
|
+
style={{ width: size, height: size }}
|
|
75
|
+
{...rest}
|
|
76
|
+
>
|
|
77
|
+
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>
|
|
78
|
+
{arcs.map((arc) => (
|
|
79
|
+
<path
|
|
80
|
+
key={arc.index}
|
|
81
|
+
d={arc.d}
|
|
82
|
+
fill={arc.color}
|
|
83
|
+
opacity={activeIdx === null || activeIdx === arc.index ? 1 : 0.5}
|
|
84
|
+
style={{ transition: 'opacity 150ms ease' }}
|
|
85
|
+
onMouseEnter={() => {
|
|
86
|
+
setActiveIdx(arc.index);
|
|
87
|
+
const seg = segments[arc.index];
|
|
88
|
+
const pct = total > 0 ? ((seg.value / total) * 100).toFixed(1) : '0';
|
|
89
|
+
show(arc.midX, arc.midY, (
|
|
90
|
+
<div>
|
|
91
|
+
{seg.label && <div style={{ fontWeight: 600, marginBottom: 2 }}>{seg.label}</div>}
|
|
92
|
+
<div>{seg.value} ({pct}%)</div>
|
|
93
|
+
</div>
|
|
94
|
+
));
|
|
95
|
+
}}
|
|
96
|
+
onMouseLeave={() => { setActiveIdx(null); hide(); }}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
</svg>
|
|
100
|
+
{centerLabel && <div className={styles.center}>{centerLabel}</div>}
|
|
101
|
+
<HoverTooltip hover={hover} />
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
DonutChart.displayName = 'DonutChart';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface DonutChartSegment {
|
|
4
|
+
value: number;
|
|
5
|
+
label?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DonutChartProps
|
|
9
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'color'> {
|
|
10
|
+
/** Segments with values (will be normalized) */
|
|
11
|
+
segments: DonutChartSegment[];
|
|
12
|
+
/** Center label content */
|
|
13
|
+
centerLabel?: ReactNode;
|
|
14
|
+
/** Donut thickness in px */
|
|
15
|
+
thickness?: number;
|
|
16
|
+
/** Outer size in px */
|
|
17
|
+
size?: number;
|
|
18
|
+
/** Dark background variant */
|
|
19
|
+
dark?: boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-columns: repeat(var(--gc-cols), var(--gc-cell));
|
|
5
|
+
gap: var(--gc-gap);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cell {
|
|
9
|
+
width: var(--gc-cell);
|
|
10
|
+
height: var(--gc-cell);
|
|
11
|
+
border-radius: var(--st-radius-sm);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* ─── Color palettes ─── */
|
|
15
|
+
|
|
16
|
+
.primary .cell {
|
|
17
|
+
background-color: var(--st-color-chart-1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.secondary .cell {
|
|
21
|
+
background-color: var(--st-color-chart-2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.neutral .cell {
|
|
25
|
+
background-color: var(--st-color-chart-4);
|
|
26
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { useChartHover } from './useChartHover';
|
|
4
|
+
import { HoverTooltip } from './HoverTooltip';
|
|
5
|
+
import type { GridChartProps } from './GridChart.types';
|
|
6
|
+
import styles from './GridChart.module.css';
|
|
7
|
+
|
|
8
|
+
export const GridChart = forwardRef<HTMLDivElement, GridChartProps>(
|
|
9
|
+
(
|
|
10
|
+
{ data, color = 'primary', cellSize = 16, gap = 3, className, style, ...rest },
|
|
11
|
+
ref
|
|
12
|
+
) => {
|
|
13
|
+
const { flat, cols, maxVal } = useMemo(() => {
|
|
14
|
+
const f = data.flat();
|
|
15
|
+
return {
|
|
16
|
+
flat: f,
|
|
17
|
+
cols: data[0]?.length ?? 0,
|
|
18
|
+
maxVal: Math.max(...f, 1),
|
|
19
|
+
};
|
|
20
|
+
}, [data]);
|
|
21
|
+
|
|
22
|
+
const { hover, show, hide } = useChartHover();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn(styles.root, styles[color], className)}
|
|
28
|
+
style={
|
|
29
|
+
{
|
|
30
|
+
'--gc-cols': cols,
|
|
31
|
+
'--gc-cell': `${cellSize}px`,
|
|
32
|
+
'--gc-gap': `${gap}px`,
|
|
33
|
+
...style,
|
|
34
|
+
} as React.CSSProperties
|
|
35
|
+
}
|
|
36
|
+
{...rest}
|
|
37
|
+
>
|
|
38
|
+
{flat.map((val, i) => (
|
|
39
|
+
<div
|
|
40
|
+
key={i}
|
|
41
|
+
className={styles.cell}
|
|
42
|
+
style={{ opacity: Math.max(0.1, val / maxVal) }}
|
|
43
|
+
onMouseEnter={(e) => {
|
|
44
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
45
|
+
const parentRect = e.currentTarget.parentElement!.getBoundingClientRect();
|
|
46
|
+
show(
|
|
47
|
+
rect.left - parentRect.left + rect.width / 2,
|
|
48
|
+
rect.top - parentRect.top,
|
|
49
|
+
<div>{val}</div>
|
|
50
|
+
);
|
|
51
|
+
}}
|
|
52
|
+
onMouseLeave={hide}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
<HoverTooltip hover={hover} />
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
GridChart.displayName = 'GridChart';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type GridChartColor = 'primary' | 'secondary' | 'neutral';
|
|
4
|
+
|
|
5
|
+
export interface GridChartProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** 2D array of values (0–1 normalized, or raw — will auto-normalize) */
|
|
7
|
+
data: number[][];
|
|
8
|
+
/** Color palette */
|
|
9
|
+
color?: GridChartColor;
|
|
10
|
+
/** Cell size in px */
|
|
11
|
+
cellSize?: number;
|
|
12
|
+
/** Gap between cells in px */
|
|
13
|
+
gap?: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: absolute;
|
|
3
|
+
z-index: var(--st-z-tooltip);
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
transform: translate(-50%, -100%);
|
|
6
|
+
margin-top: -8px;
|
|
7
|
+
background-color: var(--st-color-chart-tooltip-bg);
|
|
8
|
+
color: var(--st-color-chart-tooltip-fg);
|
|
9
|
+
border-radius: var(--st-radius-lg);
|
|
10
|
+
padding: var(--st-space-2) var(--st-space-3);
|
|
11
|
+
font-family: var(--st-font-family);
|
|
12
|
+
font-size: var(--st-font-size-xs);
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
box-shadow: var(--st-shadow-lg);
|
|
15
|
+
line-height: var(--st-line-height-normal);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HoverState } from './useChartHover';
|
|
2
|
+
import styles from './HoverTooltip.module.css';
|
|
3
|
+
|
|
4
|
+
interface HoverTooltipProps {
|
|
5
|
+
hover: HoverState;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function HoverTooltip({ hover }: HoverTooltipProps) {
|
|
9
|
+
if (!hover.visible) return null;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
className={styles.root}
|
|
14
|
+
style={{
|
|
15
|
+
left: hover.x,
|
|
16
|
+
top: hover.y,
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
{hover.content}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
font-family: var(--st-font-family);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.label {
|
|
8
|
+
font-size: var(--st-font-size-sm);
|
|
9
|
+
font-weight: var(--st-font-weight-medium);
|
|
10
|
+
color: var(--st-color-muted);
|
|
11
|
+
margin-bottom: var(--st-space-1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.valueRow {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: var(--st-space-2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.value {
|
|
21
|
+
font-weight: var(--st-font-weight-bold);
|
|
22
|
+
color: var(--st-color-foreground);
|
|
23
|
+
line-height: var(--st-line-height-tight);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.trend {
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.description {
|
|
31
|
+
font-size: var(--st-font-size-sm);
|
|
32
|
+
color: var(--st-color-muted);
|
|
33
|
+
margin-top: var(--st-space-1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* ─── Sizes ─── */
|
|
37
|
+
|
|
38
|
+
.sm .value {
|
|
39
|
+
font-size: var(--st-font-size-xl);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.md .value {
|
|
43
|
+
font-size: var(--st-font-size-3xl);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.lg .value {
|
|
47
|
+
font-size: var(--st-font-size-4xl);
|
|
48
|
+
}
|