@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,131 @@
|
|
|
1
|
+
/** Linear interpolation */
|
|
2
|
+
export function lerp(a: number, b: number, t: number): number {
|
|
3
|
+
return a + (b - a) * t;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Compute nice axis scale — returns array of tick values */
|
|
7
|
+
export function niceScale(min: number, max: number, maxTicks = 5): number[] {
|
|
8
|
+
if (min === max) return [min];
|
|
9
|
+
const range = max - min;
|
|
10
|
+
const roughStep = range / (maxTicks - 1);
|
|
11
|
+
const magnitude = Math.pow(10, Math.floor(Math.log10(roughStep)));
|
|
12
|
+
const residual = roughStep / magnitude;
|
|
13
|
+
let niceStep: number;
|
|
14
|
+
if (residual <= 1.5) niceStep = magnitude;
|
|
15
|
+
else if (residual <= 3) niceStep = 2 * magnitude;
|
|
16
|
+
else if (residual <= 7) niceStep = 5 * magnitude;
|
|
17
|
+
else niceStep = 10 * magnitude;
|
|
18
|
+
|
|
19
|
+
const niceMin = Math.floor(min / niceStep) * niceStep;
|
|
20
|
+
const niceMax = Math.ceil(max / niceStep) * niceStep;
|
|
21
|
+
const ticks: number[] = [];
|
|
22
|
+
for (let v = niceMin; v <= niceMax + niceStep * 0.5; v += niceStep) {
|
|
23
|
+
ticks.push(Math.round(v * 1e10) / 1e10);
|
|
24
|
+
}
|
|
25
|
+
return ticks;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Convert data points to a smooth SVG path using Catmull-Rom → cubic bezier */
|
|
29
|
+
export function smoothPath(
|
|
30
|
+
points: { x: number; y: number }[],
|
|
31
|
+
tension = 0.3
|
|
32
|
+
): string {
|
|
33
|
+
if (points.length < 2) return '';
|
|
34
|
+
if (points.length === 2) {
|
|
35
|
+
return `M${points[0].x},${points[0].y}L${points[1].x},${points[1].y}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let d = `M${points[0].x},${points[0].y}`;
|
|
39
|
+
|
|
40
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
41
|
+
const p0 = points[Math.max(0, i - 1)];
|
|
42
|
+
const p1 = points[i];
|
|
43
|
+
const p2 = points[i + 1];
|
|
44
|
+
const p3 = points[Math.min(points.length - 1, i + 2)];
|
|
45
|
+
|
|
46
|
+
const cp1x = p1.x + ((p2.x - p0.x) * tension) / 3;
|
|
47
|
+
const cp1y = p1.y + ((p2.y - p0.y) * tension) / 3;
|
|
48
|
+
const cp2x = p2.x - ((p3.x - p1.x) * tension) / 3;
|
|
49
|
+
const cp2y = p2.y - ((p3.y - p1.y) * tension) / 3;
|
|
50
|
+
|
|
51
|
+
d += `C${cp1x},${cp1y},${cp2x},${cp2y},${p2.x},${p2.y}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return d;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Create area path by closing a line path to the bottom */
|
|
58
|
+
export function areaPath(
|
|
59
|
+
linePath: string,
|
|
60
|
+
bottomY: number,
|
|
61
|
+
startX: number,
|
|
62
|
+
endX: number
|
|
63
|
+
): string {
|
|
64
|
+
return `${linePath}L${endX},${bottomY}L${startX},${bottomY}Z`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Create a donut arc path segment */
|
|
68
|
+
export function donutArc(
|
|
69
|
+
cx: number,
|
|
70
|
+
cy: number,
|
|
71
|
+
outerR: number,
|
|
72
|
+
innerR: number,
|
|
73
|
+
startAngle: number,
|
|
74
|
+
endAngle: number
|
|
75
|
+
): string {
|
|
76
|
+
const gap = 0.02; // small gap between segments
|
|
77
|
+
const sa = startAngle + gap;
|
|
78
|
+
const ea = endAngle - gap;
|
|
79
|
+
if (ea <= sa) return '';
|
|
80
|
+
|
|
81
|
+
const cos = Math.cos;
|
|
82
|
+
const sin = Math.sin;
|
|
83
|
+
|
|
84
|
+
const ox1 = cx + outerR * cos(sa);
|
|
85
|
+
const oy1 = cy + outerR * sin(sa);
|
|
86
|
+
const ox2 = cx + outerR * cos(ea);
|
|
87
|
+
const oy2 = cy + outerR * sin(ea);
|
|
88
|
+
const ix1 = cx + innerR * cos(ea);
|
|
89
|
+
const iy1 = cy + innerR * sin(ea);
|
|
90
|
+
const ix2 = cx + innerR * cos(sa);
|
|
91
|
+
const iy2 = cy + innerR * sin(sa);
|
|
92
|
+
|
|
93
|
+
const largeArc = ea - sa > Math.PI ? 1 : 0;
|
|
94
|
+
|
|
95
|
+
return [
|
|
96
|
+
`M${ox1},${oy1}`,
|
|
97
|
+
`A${outerR},${outerR},0,${largeArc},1,${ox2},${oy2}`,
|
|
98
|
+
`L${ix1},${iy1}`,
|
|
99
|
+
`A${innerR},${innerR},0,${largeArc},0,${ix2},${iy2}`,
|
|
100
|
+
'Z',
|
|
101
|
+
].join('');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Normalize segment values to fractions summing to 1 */
|
|
105
|
+
export function normalizeSegments(values: number[]): number[] {
|
|
106
|
+
const total = values.reduce((s, v) => s + v, 0);
|
|
107
|
+
if (total === 0) return values.map(() => 0);
|
|
108
|
+
return values.map((v) => v / total);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Create a bar path with only top corners rounded */
|
|
112
|
+
export function roundedBarPath(
|
|
113
|
+
x: number,
|
|
114
|
+
y: number,
|
|
115
|
+
width: number,
|
|
116
|
+
height: number,
|
|
117
|
+
radius: number
|
|
118
|
+
): string {
|
|
119
|
+
if (height <= 0) return '';
|
|
120
|
+
const r = Math.min(radius, width / 2, height);
|
|
121
|
+
const bottom = y + height;
|
|
122
|
+
return [
|
|
123
|
+
`M${x},${bottom}`,
|
|
124
|
+
`L${x},${y + r}`,
|
|
125
|
+
`A${r},${r},0,0,1,${x + r},${y}`,
|
|
126
|
+
`L${x + width - r},${y}`,
|
|
127
|
+
`A${r},${r},0,0,1,${x + width},${y + r}`,
|
|
128
|
+
`L${x + width},${bottom}`,
|
|
129
|
+
'Z',
|
|
130
|
+
].join('');
|
|
131
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export { BarChart } from './BarChart';
|
|
2
|
+
export type { BarChartProps, BarChartDataPoint } from './BarChart.types';
|
|
3
|
+
|
|
4
|
+
export { LineChart } from './LineChart';
|
|
5
|
+
export type { LineChartProps, LineChartDataPoint } from './LineChart.types';
|
|
6
|
+
|
|
7
|
+
export { DonutChart } from './DonutChart';
|
|
8
|
+
export type { DonutChartProps, DonutChartSegment } from './DonutChart.types';
|
|
9
|
+
|
|
10
|
+
export { ProgressChart } from './ProgressChart';
|
|
11
|
+
export type {
|
|
12
|
+
ProgressChartProps,
|
|
13
|
+
ProgressChartSegment,
|
|
14
|
+
ProgressChartColor,
|
|
15
|
+
} from './ProgressChart.types';
|
|
16
|
+
|
|
17
|
+
export { GridChart } from './GridChart';
|
|
18
|
+
export type { GridChartProps, GridChartColor } from './GridChart.types';
|
|
19
|
+
|
|
20
|
+
export { TrendLineChart } from './TrendLineChart';
|
|
21
|
+
export type {
|
|
22
|
+
TrendLineChartProps,
|
|
23
|
+
TrendLineChartColor,
|
|
24
|
+
} from './TrendLineChart.types';
|
|
25
|
+
|
|
26
|
+
export { KPIIndicator } from './KPIIndicator';
|
|
27
|
+
export type { KPIIndicatorProps, KPIIndicatorSize } from './KPIIndicator.types';
|
|
28
|
+
|
|
29
|
+
export { LegendLabel, LegendGroup } from './ChartLegend';
|
|
30
|
+
export type {
|
|
31
|
+
LegendLabelProps,
|
|
32
|
+
LegendLabelVariant,
|
|
33
|
+
LegendGroupProps,
|
|
34
|
+
} from './ChartLegend.types';
|
|
35
|
+
|
|
36
|
+
export { ChartAction } from './ChartAction';
|
|
37
|
+
export type {
|
|
38
|
+
ChartActionProps,
|
|
39
|
+
ChartActionTab,
|
|
40
|
+
} from './ChartAction.types';
|
|
41
|
+
|
|
42
|
+
export { ChartTooltip } from './ChartTooltip';
|
|
43
|
+
export type {
|
|
44
|
+
ChartTooltipProps,
|
|
45
|
+
ChartTooltipItem,
|
|
46
|
+
ChartTooltipVariant,
|
|
47
|
+
} from './ChartTooltip.types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useState, useCallback, type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface HoverState {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
content: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const INITIAL: HoverState = { visible: false, x: 0, y: 0, content: null };
|
|
11
|
+
|
|
12
|
+
export function useChartHover() {
|
|
13
|
+
const [hover, setHover] = useState<HoverState>(INITIAL);
|
|
14
|
+
|
|
15
|
+
const show = useCallback(
|
|
16
|
+
(x: number, y: number, content: ReactNode) =>
|
|
17
|
+
setHover({ visible: true, x, y, content }),
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const hide = useCallback(() => setHover(INITIAL), []);
|
|
22
|
+
|
|
23
|
+
return { hover, show, hide } as const;
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* ─── Sizes ─── */
|
|
11
|
+
.md {
|
|
12
|
+
width: 20px;
|
|
13
|
+
height: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.sm {
|
|
17
|
+
width: 16px;
|
|
18
|
+
height: 16px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* ─── Hidden native input ─── */
|
|
22
|
+
.input {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
margin: 0;
|
|
28
|
+
padding: 0;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
z-index: 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* ─── Visual box ─── */
|
|
35
|
+
.box {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
border: 1.5px solid var(--st-color-neutral-300);
|
|
42
|
+
border-radius: var(--st-radius-sm);
|
|
43
|
+
background-color: var(--st-color-background);
|
|
44
|
+
color: var(--st-color-success-foreground);
|
|
45
|
+
transition:
|
|
46
|
+
background-color var(--st-transition-fast),
|
|
47
|
+
border-color var(--st-transition-fast),
|
|
48
|
+
box-shadow var(--st-transition-fast);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* ─── Check / indeterminate icon ─── */
|
|
52
|
+
.icon {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
transition: opacity var(--st-transition-fast);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* ─── Checked state ─── */
|
|
61
|
+
.root:has(.input:checked) .box,
|
|
62
|
+
.root:has(.input:indeterminate) .box {
|
|
63
|
+
background-color: var(--st-color-success);
|
|
64
|
+
border-color: var(--st-color-success);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.root:has(.input:checked) .icon,
|
|
68
|
+
.root:has(.input:indeterminate) .icon {
|
|
69
|
+
opacity: 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ─── Hover ─── */
|
|
73
|
+
.root:not(.disabled):not(.readOnly):has(.input:hover) .box {
|
|
74
|
+
border-color: var(--st-color-neutral-400);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.root:not(.disabled):not(.readOnly):has(.input:checked:hover) .box,
|
|
78
|
+
.root:not(.disabled):not(.readOnly):has(.input:indeterminate:hover) .box {
|
|
79
|
+
background-color: var(--st-color-success-hover);
|
|
80
|
+
border-color: var(--st-color-success-hover);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ─── Focus ─── */
|
|
84
|
+
.root:has(.input:focus-visible) .box {
|
|
85
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* ─── Disabled ─── */
|
|
89
|
+
.disabled {
|
|
90
|
+
opacity: 0.5;
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ─── Read-only ─── */
|
|
95
|
+
.readOnly .input {
|
|
96
|
+
cursor: default;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.readOnly .box {
|
|
100
|
+
border-color: var(--st-color-neutral-200);
|
|
101
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { CheckboxProps } from './Checkbox.types';
|
|
4
|
+
import styles from './Checkbox.module.css';
|
|
5
|
+
|
|
6
|
+
function CheckIcon() {
|
|
7
|
+
return (
|
|
8
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
9
|
+
<path
|
|
10
|
+
d="M2.5 6L5 8.5L9.5 3.5"
|
|
11
|
+
stroke="currentColor"
|
|
12
|
+
strokeWidth="2"
|
|
13
|
+
strokeLinecap="round"
|
|
14
|
+
strokeLinejoin="round"
|
|
15
|
+
/>
|
|
16
|
+
</svg>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function IndeterminateIcon() {
|
|
21
|
+
return (
|
|
22
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
23
|
+
<path
|
|
24
|
+
d="M2.5 6H9.5"
|
|
25
|
+
stroke="currentColor"
|
|
26
|
+
strokeWidth="2"
|
|
27
|
+
strokeLinecap="round"
|
|
28
|
+
/>
|
|
29
|
+
</svg>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
indeterminate = false,
|
|
37
|
+
readOnly = false,
|
|
38
|
+
size = 'md',
|
|
39
|
+
disabled = false,
|
|
40
|
+
checked,
|
|
41
|
+
defaultChecked,
|
|
42
|
+
onCheckedChange,
|
|
43
|
+
onChange,
|
|
44
|
+
className,
|
|
45
|
+
...rest
|
|
46
|
+
},
|
|
47
|
+
ref,
|
|
48
|
+
) => {
|
|
49
|
+
const internalRef = useRef<HTMLInputElement>(null);
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const el =
|
|
53
|
+
(ref as React.RefObject<HTMLInputElement | null>)?.current ??
|
|
54
|
+
internalRef.current;
|
|
55
|
+
if (el) {
|
|
56
|
+
el.indeterminate = indeterminate;
|
|
57
|
+
}
|
|
58
|
+
}, [indeterminate, ref]);
|
|
59
|
+
|
|
60
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
61
|
+
if (readOnly) {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
onChange?.(e);
|
|
66
|
+
onCheckedChange?.(e.target.checked);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<span
|
|
71
|
+
className={cn(
|
|
72
|
+
styles.root,
|
|
73
|
+
styles[size],
|
|
74
|
+
disabled && styles.disabled,
|
|
75
|
+
readOnly && styles.readOnly,
|
|
76
|
+
className,
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
<input
|
|
80
|
+
ref={ref ?? internalRef}
|
|
81
|
+
type="checkbox"
|
|
82
|
+
className={styles.input}
|
|
83
|
+
checked={checked}
|
|
84
|
+
defaultChecked={defaultChecked}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
readOnly={readOnly}
|
|
87
|
+
onChange={handleChange}
|
|
88
|
+
{...rest}
|
|
89
|
+
/>
|
|
90
|
+
<span className={styles.box}>
|
|
91
|
+
<span className={styles.icon}>
|
|
92
|
+
{indeterminate ? <IndeterminateIcon /> : <CheckIcon />}
|
|
93
|
+
</span>
|
|
94
|
+
</span>
|
|
95
|
+
</span>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
Checkbox.displayName = 'Checkbox';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type CheckboxSize = 'md' | 'sm';
|
|
4
|
+
|
|
5
|
+
export interface CheckboxProps
|
|
6
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {
|
|
7
|
+
indeterminate?: boolean;
|
|
8
|
+
readOnly?: boolean;
|
|
9
|
+
size?: CheckboxSize;
|
|
10
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
gap: var(--st-space-2);
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
user-select: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* ─── Content ─── */
|
|
11
|
+
.content {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: var(--st-space-0);
|
|
15
|
+
padding-top: 1px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Label ─── */
|
|
19
|
+
.label {
|
|
20
|
+
font-family: var(--st-font-family);
|
|
21
|
+
font-size: var(--st-font-size-sm);
|
|
22
|
+
font-weight: var(--st-font-weight-medium);
|
|
23
|
+
line-height: var(--st-line-height-tight);
|
|
24
|
+
color: var(--st-color-foreground);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* ─── Description ─── */
|
|
28
|
+
.description {
|
|
29
|
+
font-family: var(--st-font-family);
|
|
30
|
+
font-size: var(--st-font-size-xs);
|
|
31
|
+
line-height: var(--st-line-height-normal);
|
|
32
|
+
color: var(--st-color-muted);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* ─── Card variant ─── */
|
|
36
|
+
.card {
|
|
37
|
+
border: 1px solid var(--st-color-border);
|
|
38
|
+
border-radius: var(--st-radius-xl);
|
|
39
|
+
padding: var(--st-space-3) var(--st-space-4);
|
|
40
|
+
transition:
|
|
41
|
+
border-color var(--st-transition-fast),
|
|
42
|
+
background-color var(--st-transition-fast);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.card:hover:not(.disabled):not(.readOnly) {
|
|
46
|
+
border-color: var(--st-color-border-strong);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.card:has(input:checked),
|
|
50
|
+
.card:has(input:indeterminate) {
|
|
51
|
+
border-color: var(--st-color-success);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.card:has(input:focus-visible) {
|
|
55
|
+
border-color: var(--st-color-success);
|
|
56
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ─── Disabled ─── */
|
|
60
|
+
.disabled {
|
|
61
|
+
opacity: 0.5;
|
|
62
|
+
cursor: default;
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ─── Read-only ─── */
|
|
67
|
+
.readOnly {
|
|
68
|
+
cursor: default;
|
|
69
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { Checkbox } from './Checkbox';
|
|
4
|
+
import { useCheckboxGroup } from './CheckboxGroupContext';
|
|
5
|
+
import type { CheckboxFieldProps } from './CheckboxField.types';
|
|
6
|
+
import styles from './CheckboxField.module.css';
|
|
7
|
+
|
|
8
|
+
export const CheckboxField = forwardRef<HTMLInputElement, CheckboxFieldProps>(
|
|
9
|
+
(
|
|
10
|
+
{
|
|
11
|
+
label,
|
|
12
|
+
description,
|
|
13
|
+
variant = 'default',
|
|
14
|
+
disabled = false,
|
|
15
|
+
readOnly = false,
|
|
16
|
+
size,
|
|
17
|
+
className,
|
|
18
|
+
...rest
|
|
19
|
+
},
|
|
20
|
+
ref,
|
|
21
|
+
) => {
|
|
22
|
+
const group = useCheckboxGroup();
|
|
23
|
+
const isDisabled = disabled || group?.disabled || false;
|
|
24
|
+
const isReadOnly = readOnly || group?.readOnly || false;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<label
|
|
28
|
+
className={cn(
|
|
29
|
+
styles.root,
|
|
30
|
+
styles[variant],
|
|
31
|
+
isDisabled && styles.disabled,
|
|
32
|
+
isReadOnly && styles.readOnly,
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
>
|
|
36
|
+
<Checkbox
|
|
37
|
+
ref={ref}
|
|
38
|
+
disabled={isDisabled}
|
|
39
|
+
readOnly={isReadOnly}
|
|
40
|
+
size={size}
|
|
41
|
+
{...rest}
|
|
42
|
+
/>
|
|
43
|
+
<span className={styles.content}>
|
|
44
|
+
<span className={styles.label}>{label}</span>
|
|
45
|
+
{description && (
|
|
46
|
+
<span className={styles.description}>{description}</span>
|
|
47
|
+
)}
|
|
48
|
+
</span>
|
|
49
|
+
</label>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
CheckboxField.displayName = 'CheckboxField';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--st-space-3);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* ─── Group label ─── */
|
|
9
|
+
.label {
|
|
10
|
+
font-family: var(--st-font-family);
|
|
11
|
+
font-size: var(--st-font-size-sm);
|
|
12
|
+
font-weight: var(--st-font-weight-semibold);
|
|
13
|
+
line-height: var(--st-line-height-tight);
|
|
14
|
+
color: var(--st-color-foreground);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ─── Items container ─── */
|
|
18
|
+
.items {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: var(--st-space-3);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* ─── Helper text ─── */
|
|
25
|
+
.helperText {
|
|
26
|
+
font-family: var(--st-font-family);
|
|
27
|
+
font-size: var(--st-font-size-xs);
|
|
28
|
+
line-height: var(--st-line-height-normal);
|
|
29
|
+
color: var(--st-color-muted);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* ─── Error ─── */
|
|
33
|
+
.error {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--st-space-1);
|
|
37
|
+
font-family: var(--st-font-family);
|
|
38
|
+
font-size: var(--st-font-size-xs);
|
|
39
|
+
line-height: var(--st-line-height-normal);
|
|
40
|
+
color: var(--st-color-error);
|
|
41
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { CheckboxGroupContext } from './CheckboxGroupContext';
|
|
4
|
+
import type { CheckboxGroupProps } from './CheckboxGroup.types';
|
|
5
|
+
import styles from './CheckboxGroup.module.css';
|
|
6
|
+
|
|
7
|
+
export const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
8
|
+
(
|
|
9
|
+
{
|
|
10
|
+
label,
|
|
11
|
+
helperText,
|
|
12
|
+
error,
|
|
13
|
+
disabled = false,
|
|
14
|
+
readOnly = false,
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
...rest
|
|
18
|
+
},
|
|
19
|
+
ref,
|
|
20
|
+
) => {
|
|
21
|
+
const ctx = useMemo(
|
|
22
|
+
() => ({ disabled, readOnly }),
|
|
23
|
+
[disabled, readOnly],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<CheckboxGroupContext.Provider value={ctx}>
|
|
28
|
+
<div
|
|
29
|
+
ref={ref}
|
|
30
|
+
role="group"
|
|
31
|
+
aria-label={label}
|
|
32
|
+
className={cn(styles.root, className)}
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
{label && <span className={styles.label}>{label}</span>}
|
|
36
|
+
<div className={styles.items}>{children}</div>
|
|
37
|
+
{error && (
|
|
38
|
+
<span className={styles.error}>
|
|
39
|
+
<svg
|
|
40
|
+
width="8"
|
|
41
|
+
height="8"
|
|
42
|
+
viewBox="0 0 8 8"
|
|
43
|
+
fill="none"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
>
|
|
46
|
+
<circle cx="4" cy="4" r="4" fill="currentColor" />
|
|
47
|
+
</svg>
|
|
48
|
+
{error}
|
|
49
|
+
</span>
|
|
50
|
+
)}
|
|
51
|
+
{!error && helperText && (
|
|
52
|
+
<span className={styles.helperText}>{helperText}</span>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
</CheckboxGroupContext.Provider>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CheckboxGroupProps
|
|
4
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
5
|
+
label?: string;
|
|
6
|
+
helperText?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CheckboxGroupContextValue {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const CheckboxGroupContext =
|
|
9
|
+
createContext<CheckboxGroupContextValue | null>(null);
|
|
10
|
+
|
|
11
|
+
export function useCheckboxGroup(): CheckboxGroupContextValue | null {
|
|
12
|
+
return useContext(CheckboxGroupContext);
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Checkbox } from './Checkbox';
|
|
2
|
+
export type { CheckboxProps, CheckboxSize } from './Checkbox.types';
|
|
3
|
+
|
|
4
|
+
export { CheckboxField } from './CheckboxField';
|
|
5
|
+
export type {
|
|
6
|
+
CheckboxFieldProps,
|
|
7
|
+
CheckboxFieldVariant,
|
|
8
|
+
} from './CheckboxField.types';
|
|
9
|
+
|
|
10
|
+
export { CheckboxGroup } from './CheckboxGroup';
|
|
11
|
+
export type { CheckboxGroupProps } from './CheckboxGroup.types';
|