@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,143 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
border-radius: var(--st-radius-full);
|
|
7
|
+
font-family: var(--st-font-family);
|
|
8
|
+
font-weight: var(--st-font-weight-medium);
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
user-select: none;
|
|
11
|
+
outline: none;
|
|
12
|
+
transition:
|
|
13
|
+
background-color 0.15s ease,
|
|
14
|
+
border-color 0.15s ease,
|
|
15
|
+
box-shadow 0.15s ease;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Sizes ─── */
|
|
19
|
+
|
|
20
|
+
.md {
|
|
21
|
+
height: 32px;
|
|
22
|
+
padding: 0 var(--st-space-3);
|
|
23
|
+
gap: var(--st-space-2);
|
|
24
|
+
font-size: var(--st-font-size-sm);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sm {
|
|
28
|
+
height: 24px;
|
|
29
|
+
padding: 0 var(--st-space-2);
|
|
30
|
+
gap: var(--st-space-1);
|
|
31
|
+
font-size: var(--st-font-size-xs);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* Reduce right padding when dismiss button is present */
|
|
35
|
+
.dismissible.md {
|
|
36
|
+
padding-right: var(--st-space-1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.dismissible.sm {
|
|
40
|
+
padding-right: 2px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ─── Filled variant ─── */
|
|
44
|
+
|
|
45
|
+
.filled {
|
|
46
|
+
background-color: var(--st-color-neutral-100);
|
|
47
|
+
border: 1px solid transparent;
|
|
48
|
+
color: var(--st-color-foreground);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.filled:hover {
|
|
52
|
+
background-color: var(--st-color-neutral-200);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ─── Light variant ─── */
|
|
56
|
+
|
|
57
|
+
.light {
|
|
58
|
+
background-color: var(--st-color-background);
|
|
59
|
+
border: 1px solid var(--st-color-border);
|
|
60
|
+
color: var(--st-color-foreground);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.light:hover {
|
|
64
|
+
border-color: var(--st-color-border-strong);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* ─── Selected (overrides both variants) ─── */
|
|
68
|
+
|
|
69
|
+
.selected {
|
|
70
|
+
background-color: var(--st-color-neutral-900);
|
|
71
|
+
border-color: var(--st-color-neutral-900);
|
|
72
|
+
color: #ffffff;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.selected:hover {
|
|
76
|
+
background-color: var(--st-color-neutral-800);
|
|
77
|
+
border-color: var(--st-color-neutral-800);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* ─── Focus ─── */
|
|
81
|
+
|
|
82
|
+
.root:focus-visible {
|
|
83
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* ─── Disabled ─── */
|
|
87
|
+
|
|
88
|
+
.disabled {
|
|
89
|
+
opacity: 0.5;
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
cursor: default;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ─── Icon ─── */
|
|
95
|
+
|
|
96
|
+
.icon {
|
|
97
|
+
display: inline-flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
flex-shrink: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* ─── Label ─── */
|
|
103
|
+
|
|
104
|
+
.label {
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ─── Dismiss button ─── */
|
|
109
|
+
|
|
110
|
+
.dismiss {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
border: none;
|
|
115
|
+
background: transparent;
|
|
116
|
+
color: currentColor;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
padding: 0;
|
|
119
|
+
border-radius: var(--st-radius-full);
|
|
120
|
+
flex-shrink: 0;
|
|
121
|
+
transition: background-color 0.15s ease;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.md .dismiss {
|
|
125
|
+
width: 22px;
|
|
126
|
+
height: 22px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.sm .dismiss {
|
|
130
|
+
width: 18px;
|
|
131
|
+
height: 18px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* Dismiss hover — light surfaces */
|
|
135
|
+
.filled:not(.selected) .dismiss:hover,
|
|
136
|
+
.light:not(.selected) .dismiss:hover {
|
|
137
|
+
background-color: var(--st-color-neutral-300);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* Dismiss hover — dark/selected surfaces */
|
|
141
|
+
.selected .dismiss:hover {
|
|
142
|
+
background-color: var(--st-color-neutral-700);
|
|
143
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import type { KeyboardEvent } from 'react';
|
|
3
|
+
import { cn } from '../../utils/cn';
|
|
4
|
+
import type { ChipProps } from './Chip.types';
|
|
5
|
+
import styles from './Chip.module.css';
|
|
6
|
+
|
|
7
|
+
function DismissIcon() {
|
|
8
|
+
return (
|
|
9
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
10
|
+
<path
|
|
11
|
+
d="M9 3L3 9M3 3l6 6"
|
|
12
|
+
stroke="currentColor"
|
|
13
|
+
strokeWidth="1.5"
|
|
14
|
+
strokeLinecap="round"
|
|
15
|
+
strokeLinejoin="round"
|
|
16
|
+
/>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Chip = forwardRef<HTMLDivElement, ChipProps>(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
variant = 'filled',
|
|
25
|
+
size = 'md',
|
|
26
|
+
selected = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
icon,
|
|
29
|
+
onDismiss,
|
|
30
|
+
onClick,
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
},
|
|
35
|
+
ref
|
|
36
|
+
) => {
|
|
37
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
38
|
+
if (disabled) return;
|
|
39
|
+
|
|
40
|
+
if ((e.key === 'Enter' || e.key === ' ') && onClick) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
onClick(e as unknown as React.MouseEvent<HTMLDivElement>);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if ((e.key === 'Delete' || e.key === 'Backspace') && onDismiss) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
onDismiss();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
rest.onKeyDown?.(e);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
ref={ref}
|
|
56
|
+
role={onClick ? 'button' : undefined}
|
|
57
|
+
tabIndex={disabled ? -1 : 0}
|
|
58
|
+
className={cn(
|
|
59
|
+
styles.root,
|
|
60
|
+
styles[variant],
|
|
61
|
+
styles[size],
|
|
62
|
+
selected && styles.selected,
|
|
63
|
+
disabled && styles.disabled,
|
|
64
|
+
onDismiss && styles.dismissible,
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
onClick={disabled ? undefined : onClick}
|
|
68
|
+
onKeyDown={handleKeyDown}
|
|
69
|
+
aria-disabled={disabled || undefined}
|
|
70
|
+
{...rest}
|
|
71
|
+
>
|
|
72
|
+
{icon && <span className={styles.icon}>{icon}</span>}
|
|
73
|
+
<span className={styles.label}>{children}</span>
|
|
74
|
+
{onDismiss && (
|
|
75
|
+
<button
|
|
76
|
+
type="button"
|
|
77
|
+
tabIndex={-1}
|
|
78
|
+
className={styles.dismiss}
|
|
79
|
+
onClick={(e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
if (!disabled) onDismiss();
|
|
82
|
+
}}
|
|
83
|
+
aria-label="Dismiss"
|
|
84
|
+
>
|
|
85
|
+
<DismissIcon />
|
|
86
|
+
</button>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
Chip.displayName = 'Chip';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ChipVariant = 'filled' | 'light';
|
|
4
|
+
export type ChipSize = 'md' | 'sm';
|
|
5
|
+
|
|
6
|
+
export interface ChipProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/** Visual variant */
|
|
8
|
+
variant?: ChipVariant;
|
|
9
|
+
/** Chip size */
|
|
10
|
+
size?: ChipSize;
|
|
11
|
+
/** Whether the chip is selected */
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
/** Whether the chip is disabled */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Left icon slot */
|
|
16
|
+
icon?: ReactNode;
|
|
17
|
+
/** Called when the dismiss button is clicked — shows X button when provided */
|
|
18
|
+
onDismiss?: () => void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { ChipGroupProps } from './ChipGroup.types';
|
|
4
|
+
import styles from './ChipGroup.module.css';
|
|
5
|
+
|
|
6
|
+
export const ChipGroup = forwardRef<HTMLDivElement, ChipGroupProps>(
|
|
7
|
+
({ className, children, ...rest }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<div ref={ref} className={cn(styles.root, className)} {...rest}>
|
|
10
|
+
{children}
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
ChipGroup.displayName = 'ChipGroup';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--st-space-2);
|
|
6
|
+
position: relative;
|
|
7
|
+
font-family: var(--st-font-family);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* ─── Label ─── */
|
|
11
|
+
.label {
|
|
12
|
+
font-size: var(--st-font-size-sm);
|
|
13
|
+
font-weight: var(--st-font-weight-semibold);
|
|
14
|
+
line-height: var(--st-line-height-tight);
|
|
15
|
+
color: var(--st-color-foreground);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* ─── Range layout ─── */
|
|
19
|
+
.rangeFields {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: row;
|
|
22
|
+
gap: var(--st-space-4);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.fieldWrapper {
|
|
26
|
+
flex: 1;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: var(--st-space-2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* ─── Input box ─── */
|
|
33
|
+
.inputBox {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: var(--st-space-2);
|
|
37
|
+
border: 1px solid var(--st-color-border);
|
|
38
|
+
border-radius: var(--st-radius-lg);
|
|
39
|
+
background: var(--st-color-surface);
|
|
40
|
+
padding: 0 var(--st-space-3);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
transition: border-color var(--st-transition-fast),
|
|
43
|
+
box-shadow var(--st-transition-fast);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.inputBox.lg {
|
|
47
|
+
height: 48px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.inputBox.md {
|
|
51
|
+
height: 40px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.inputBox:hover:not(.disabled):not(.error):not(.open) {
|
|
55
|
+
border-color: var(--st-color-border-strong);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.inputBox.open,
|
|
59
|
+
.inputBox:focus-within:not(.disabled):not(.error) {
|
|
60
|
+
border-color: var(--st-color-success);
|
|
61
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.inputBox.error {
|
|
65
|
+
border-color: var(--st-color-error);
|
|
66
|
+
box-shadow: 0 0 0 2px var(--st-color-error);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.inputBox.disabled {
|
|
70
|
+
opacity: 0.5;
|
|
71
|
+
pointer-events: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ─── Input text ─── */
|
|
75
|
+
.inputText {
|
|
76
|
+
flex: 1;
|
|
77
|
+
font-size: var(--st-font-size-sm);
|
|
78
|
+
line-height: var(--st-line-height-normal);
|
|
79
|
+
color: var(--st-color-foreground);
|
|
80
|
+
white-space: nowrap;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.inputText.placeholder {
|
|
86
|
+
color: var(--st-color-muted);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ─── Calendar icon button ─── */
|
|
90
|
+
.iconBtn {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
width: 28px;
|
|
95
|
+
height: 28px;
|
|
96
|
+
border: none;
|
|
97
|
+
background: transparent;
|
|
98
|
+
border-radius: var(--st-radius-md);
|
|
99
|
+
color: var(--st-color-muted);
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
padding: 0;
|
|
102
|
+
flex-shrink: 0;
|
|
103
|
+
transition: background var(--st-transition-fast);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.iconBtn:hover {
|
|
107
|
+
background: var(--st-color-neutral-100);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ─── Helper text ─── */
|
|
111
|
+
.helperText {
|
|
112
|
+
font-size: var(--st-font-size-xs);
|
|
113
|
+
line-height: var(--st-line-height-normal);
|
|
114
|
+
color: var(--st-color-muted);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ─── Error ─── */
|
|
118
|
+
.errorText {
|
|
119
|
+
display: inline-flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
gap: var(--st-space-1);
|
|
122
|
+
font-size: var(--st-font-size-xs);
|
|
123
|
+
line-height: var(--st-line-height-normal);
|
|
124
|
+
color: var(--st-color-error);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* ─── Popover ─── */
|
|
128
|
+
.popover {
|
|
129
|
+
position: absolute;
|
|
130
|
+
top: calc(100% + var(--st-space-2));
|
|
131
|
+
left: 0;
|
|
132
|
+
z-index: var(--st-z-dropdown);
|
|
133
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { CalendarDialog } from '../Calendar/CalendarDialog';
|
|
4
|
+
import type { DateRange } from '../Calendar/CalendarDialog.types';
|
|
5
|
+
import type { DatepickerProps } from './Datepicker.types';
|
|
6
|
+
import styles from './Datepicker.module.css';
|
|
7
|
+
|
|
8
|
+
function formatDate(date: Date): string {
|
|
9
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
10
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
11
|
+
const y = date.getFullYear();
|
|
12
|
+
return `${d}/${m}/${y}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function CalendarIcon() {
|
|
16
|
+
return (
|
|
17
|
+
<svg
|
|
18
|
+
width="16"
|
|
19
|
+
height="16"
|
|
20
|
+
viewBox="0 0 16 16"
|
|
21
|
+
fill="none"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
>
|
|
24
|
+
<rect
|
|
25
|
+
x="2"
|
|
26
|
+
y="3"
|
|
27
|
+
width="12"
|
|
28
|
+
height="11"
|
|
29
|
+
rx="1.5"
|
|
30
|
+
stroke="currentColor"
|
|
31
|
+
strokeWidth="1.2"
|
|
32
|
+
/>
|
|
33
|
+
<path d="M2 6.5h12" stroke="currentColor" strokeWidth="1.2" />
|
|
34
|
+
<path
|
|
35
|
+
d="M5.5 1.5v3M10.5 1.5v3"
|
|
36
|
+
stroke="currentColor"
|
|
37
|
+
strokeWidth="1.2"
|
|
38
|
+
strokeLinecap="round"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ErrorDot() {
|
|
45
|
+
return (
|
|
46
|
+
<svg
|
|
47
|
+
width="8"
|
|
48
|
+
height="8"
|
|
49
|
+
viewBox="0 0 8 8"
|
|
50
|
+
fill="none"
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
>
|
|
53
|
+
<circle cx="4" cy="4" r="4" fill="currentColor" />
|
|
54
|
+
</svg>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Datepicker = forwardRef<HTMLDivElement, DatepickerProps>(
|
|
59
|
+
(
|
|
60
|
+
{
|
|
61
|
+
range = false,
|
|
62
|
+
size = 'lg',
|
|
63
|
+
label,
|
|
64
|
+
helperText,
|
|
65
|
+
error,
|
|
66
|
+
disabled = false,
|
|
67
|
+
value,
|
|
68
|
+
onChange,
|
|
69
|
+
rangeValue,
|
|
70
|
+
onRangeChange,
|
|
71
|
+
placeholder = 'DD/MM/YYYY',
|
|
72
|
+
minDate,
|
|
73
|
+
maxDate,
|
|
74
|
+
events,
|
|
75
|
+
className,
|
|
76
|
+
...rest
|
|
77
|
+
},
|
|
78
|
+
ref,
|
|
79
|
+
) => {
|
|
80
|
+
const [open, setOpen] = useState(false);
|
|
81
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
82
|
+
|
|
83
|
+
// Merge forwarded ref with internal ref
|
|
84
|
+
const setRefs = useCallback(
|
|
85
|
+
(node: HTMLDivElement | null) => {
|
|
86
|
+
(rootRef as React.MutableRefObject<HTMLDivElement | null>).current =
|
|
87
|
+
node;
|
|
88
|
+
if (typeof ref === 'function') ref(node);
|
|
89
|
+
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
|
90
|
+
},
|
|
91
|
+
[ref],
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// Close on click-outside
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!open) return;
|
|
97
|
+
function handleClick(e: MouseEvent) {
|
|
98
|
+
if (
|
|
99
|
+
rootRef.current &&
|
|
100
|
+
!rootRef.current.contains(e.target as Node)
|
|
101
|
+
) {
|
|
102
|
+
setOpen(false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
document.addEventListener('mousedown', handleClick);
|
|
106
|
+
return () => document.removeEventListener('mousedown', handleClick);
|
|
107
|
+
}, [open]);
|
|
108
|
+
|
|
109
|
+
// Close on Escape
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (!open) return;
|
|
112
|
+
function handleKey(e: KeyboardEvent) {
|
|
113
|
+
if (e.key === 'Escape') setOpen(false);
|
|
114
|
+
}
|
|
115
|
+
document.addEventListener('keydown', handleKey);
|
|
116
|
+
return () => document.removeEventListener('keydown', handleKey);
|
|
117
|
+
}, [open]);
|
|
118
|
+
|
|
119
|
+
const handleDone = useCallback(
|
|
120
|
+
(val: Date | DateRange | null) => {
|
|
121
|
+
if (range) {
|
|
122
|
+
onRangeChange?.(val && !(val instanceof Date) ? val : null);
|
|
123
|
+
} else {
|
|
124
|
+
onChange?.(val instanceof Date ? val : null);
|
|
125
|
+
}
|
|
126
|
+
setOpen(false);
|
|
127
|
+
},
|
|
128
|
+
[range, onChange, onRangeChange],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const handleCancel = useCallback(() => {
|
|
132
|
+
setOpen(false);
|
|
133
|
+
}, []);
|
|
134
|
+
|
|
135
|
+
const toggleOpen = useCallback(() => {
|
|
136
|
+
if (!disabled) setOpen((prev) => !prev);
|
|
137
|
+
}, [disabled]);
|
|
138
|
+
|
|
139
|
+
const inputBoxCls = cn(
|
|
140
|
+
styles.inputBox,
|
|
141
|
+
styles[size],
|
|
142
|
+
open && styles.open,
|
|
143
|
+
error && styles.error,
|
|
144
|
+
disabled && styles.disabled,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const renderInputBox = (
|
|
148
|
+
displayValue: string | undefined,
|
|
149
|
+
sublabel?: string,
|
|
150
|
+
) => (
|
|
151
|
+
<div className={sublabel ? styles.fieldWrapper : undefined}>
|
|
152
|
+
{sublabel && <span className={styles.label}>{sublabel}</span>}
|
|
153
|
+
<div
|
|
154
|
+
className={inputBoxCls}
|
|
155
|
+
role="button"
|
|
156
|
+
tabIndex={disabled ? -1 : 0}
|
|
157
|
+
onClick={toggleOpen}
|
|
158
|
+
onKeyDown={(e) => {
|
|
159
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
toggleOpen();
|
|
162
|
+
}
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
<span
|
|
166
|
+
className={cn(
|
|
167
|
+
styles.inputText,
|
|
168
|
+
!displayValue && styles.placeholder,
|
|
169
|
+
)}
|
|
170
|
+
>
|
|
171
|
+
{displayValue || placeholder}
|
|
172
|
+
</span>
|
|
173
|
+
<span className={styles.iconBtn} aria-hidden="true">
|
|
174
|
+
<CalendarIcon />
|
|
175
|
+
</span>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<div
|
|
182
|
+
ref={setRefs}
|
|
183
|
+
className={cn(styles.root, className)}
|
|
184
|
+
{...rest}
|
|
185
|
+
>
|
|
186
|
+
{/* Label (single mode only) */}
|
|
187
|
+
{!range && label && <span className={styles.label}>{label}</span>}
|
|
188
|
+
|
|
189
|
+
{/* Inputs */}
|
|
190
|
+
{range ? (
|
|
191
|
+
<div className={styles.rangeFields}>
|
|
192
|
+
{renderInputBox(
|
|
193
|
+
rangeValue?.start ? formatDate(rangeValue.start) : undefined,
|
|
194
|
+
'From',
|
|
195
|
+
)}
|
|
196
|
+
{renderInputBox(
|
|
197
|
+
rangeValue?.end ? formatDate(rangeValue.end) : undefined,
|
|
198
|
+
'To',
|
|
199
|
+
)}
|
|
200
|
+
</div>
|
|
201
|
+
) : (
|
|
202
|
+
renderInputBox(value ? formatDate(value) : undefined)
|
|
203
|
+
)}
|
|
204
|
+
|
|
205
|
+
{/* Helper / Error text */}
|
|
206
|
+
{error ? (
|
|
207
|
+
<span className={styles.errorText}>
|
|
208
|
+
<ErrorDot />
|
|
209
|
+
{error}
|
|
210
|
+
</span>
|
|
211
|
+
) : (
|
|
212
|
+
helperText && <span className={styles.helperText}>{helperText}</span>
|
|
213
|
+
)}
|
|
214
|
+
|
|
215
|
+
{/* Calendar popover */}
|
|
216
|
+
{open && (
|
|
217
|
+
<div className={styles.popover}>
|
|
218
|
+
<CalendarDialog
|
|
219
|
+
mode={range ? 'range' : 'basic'}
|
|
220
|
+
defaultValue={!range ? (value ?? undefined) : undefined}
|
|
221
|
+
defaultRange={range ? (rangeValue ?? undefined) : undefined}
|
|
222
|
+
headerAlign="center"
|
|
223
|
+
events={events}
|
|
224
|
+
minDate={minDate}
|
|
225
|
+
maxDate={maxDate}
|
|
226
|
+
onCancel={handleCancel}
|
|
227
|
+
onDone={handleDone}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
Datepicker.displayName = 'Datepicker';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import type { DateRange } from '../Calendar/CalendarDialog.types';
|
|
3
|
+
|
|
4
|
+
export type DatepickerSize = 'lg' | 'md';
|
|
5
|
+
|
|
6
|
+
export interface DatepickerProps
|
|
7
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
8
|
+
/** Dual From/To inputs + range calendar. */
|
|
9
|
+
range?: boolean;
|
|
10
|
+
/** Input height: lg=48px, md=40px. */
|
|
11
|
+
size?: DatepickerSize;
|
|
12
|
+
/** Field label (single mode only). */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** Helper text below input. Hidden when error is present. */
|
|
15
|
+
helperText?: string;
|
|
16
|
+
/** Error message. Shows red border + error dot. */
|
|
17
|
+
error?: string;
|
|
18
|
+
/** Disables the field. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Selected date (single mode). */
|
|
21
|
+
value?: Date | null;
|
|
22
|
+
/** Called when date is selected (single mode). */
|
|
23
|
+
onChange?: (date: Date | null) => void;
|
|
24
|
+
/** Selected range (range mode). */
|
|
25
|
+
rangeValue?: DateRange | null;
|
|
26
|
+
/** Called when range is selected (range mode). */
|
|
27
|
+
onRangeChange?: (range: DateRange | null) => void;
|
|
28
|
+
/** Placeholder text for empty input. */
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/** Minimum selectable date. Passed to CalendarDialog. */
|
|
31
|
+
minDate?: Date;
|
|
32
|
+
/** Maximum selectable date. Passed to CalendarDialog. */
|
|
33
|
+
maxDate?: Date;
|
|
34
|
+
/** Event indicator dates. Passed to CalendarDialog. */
|
|
35
|
+
events?: Date[];
|
|
36
|
+
}
|