@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,42 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { ButtonLinkProps } from './ButtonLink.types';
|
|
4
|
+
import styles from './ButtonLink.module.css';
|
|
5
|
+
|
|
6
|
+
export const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(
|
|
7
|
+
(
|
|
8
|
+
{
|
|
9
|
+
color = 'primary',
|
|
10
|
+
size = 'md',
|
|
11
|
+
iconLeft,
|
|
12
|
+
iconRight,
|
|
13
|
+
disabled = false,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
},
|
|
18
|
+
ref
|
|
19
|
+
) => {
|
|
20
|
+
return (
|
|
21
|
+
<a
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
styles.root,
|
|
25
|
+
styles[color],
|
|
26
|
+
styles[size],
|
|
27
|
+
disabled && styles.disabled,
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
aria-disabled={disabled || undefined}
|
|
31
|
+
tabIndex={disabled ? -1 : undefined}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{iconLeft && <span className={styles.iconSlot}>{iconLeft}</span>}
|
|
35
|
+
{children}
|
|
36
|
+
{iconRight && <span className={styles.iconSlot}>{iconRight}</span>}
|
|
37
|
+
</a>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
ButtonLink.displayName = 'ButtonLink';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type ButtonLinkColor = 'primary' | 'secondary' | 'danger';
|
|
4
|
+
export type ButtonLinkSize = 'lg' | 'md' | 'sm';
|
|
5
|
+
|
|
6
|
+
export interface ButtonLinkProps
|
|
7
|
+
extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
8
|
+
/** Color scheme */
|
|
9
|
+
color?: ButtonLinkColor;
|
|
10
|
+
/** Size */
|
|
11
|
+
size?: ButtonLinkSize;
|
|
12
|
+
/** Icon before text */
|
|
13
|
+
iconLeft?: ReactNode;
|
|
14
|
+
/** Icon after text */
|
|
15
|
+
iconRight?: ReactNode;
|
|
16
|
+
/** Disabled state */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
font-family: var(--st-font-family);
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/* ── Header ── */
|
|
8
|
+
|
|
9
|
+
.header {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: var(--st-space-1);
|
|
13
|
+
margin-bottom: var(--st-space-2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.left,
|
|
17
|
+
.center,
|
|
18
|
+
.right {
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.headerSelects {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: var(--st-space-1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.headerNav {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.select {
|
|
34
|
+
appearance: none;
|
|
35
|
+
border: none;
|
|
36
|
+
background: transparent;
|
|
37
|
+
font-family: var(--st-font-family);
|
|
38
|
+
font-size: var(--st-font-size-sm);
|
|
39
|
+
font-weight: var(--st-font-weight-medium);
|
|
40
|
+
color: var(--st-color-foreground);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
padding: var(--st-space-1) var(--st-space-5) var(--st-space-1) var(--st-space-1);
|
|
43
|
+
border-radius: var(--st-radius-sm);
|
|
44
|
+
background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 4L5 6.5L7.5 4' stroke='%23737373' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
45
|
+
background-repeat: no-repeat;
|
|
46
|
+
background-position: right var(--st-space-1) center;
|
|
47
|
+
transition: background-color var(--st-transition-fast);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.select:hover {
|
|
51
|
+
background-color: var(--st-color-neutral-100);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.select:focus-visible {
|
|
55
|
+
outline: 2px solid var(--st-color-primary);
|
|
56
|
+
outline-offset: 2px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.navButton {
|
|
60
|
+
all: unset;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
width: 28px;
|
|
66
|
+
height: 28px;
|
|
67
|
+
border-radius: var(--st-radius-md);
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
color: var(--st-color-foreground);
|
|
70
|
+
transition: background-color var(--st-transition-fast);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.navButton:hover {
|
|
74
|
+
background-color: var(--st-color-neutral-100);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.navButton:focus-visible {
|
|
78
|
+
outline: 2px solid var(--st-color-primary);
|
|
79
|
+
outline-offset: 2px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* ── Weekdays ── */
|
|
83
|
+
|
|
84
|
+
.weekdays {
|
|
85
|
+
display: grid;
|
|
86
|
+
grid-template-columns: repeat(7, 1fr);
|
|
87
|
+
text-align: center;
|
|
88
|
+
margin-bottom: var(--st-space-1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.weekday {
|
|
92
|
+
font-size: var(--st-font-size-xs);
|
|
93
|
+
font-weight: var(--st-font-weight-medium);
|
|
94
|
+
color: var(--st-color-muted);
|
|
95
|
+
padding: var(--st-space-1) 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* ── Day grid ── */
|
|
99
|
+
|
|
100
|
+
.grid {
|
|
101
|
+
display: grid;
|
|
102
|
+
grid-template-columns: repeat(7, 1fr);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Day cell — carries the range band background */
|
|
106
|
+
.dayCell {
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
align-items: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.cellRangeStart {
|
|
113
|
+
background: linear-gradient(
|
|
114
|
+
to right,
|
|
115
|
+
transparent 50%,
|
|
116
|
+
var(--st-color-primary-subtle) 50%
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.cellRangeEnd {
|
|
121
|
+
background: linear-gradient(
|
|
122
|
+
to left,
|
|
123
|
+
transparent 50%,
|
|
124
|
+
var(--st-color-primary-subtle) 50%
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.cellRangeMiddle {
|
|
129
|
+
background-color: var(--st-color-primary-subtle);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* ── Day button ── */
|
|
133
|
+
|
|
134
|
+
.day {
|
|
135
|
+
all: unset;
|
|
136
|
+
box-sizing: border-box;
|
|
137
|
+
width: 32px;
|
|
138
|
+
height: 32px;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
font-size: var(--st-font-size-sm);
|
|
143
|
+
font-family: var(--st-font-family);
|
|
144
|
+
border-radius: var(--st-radius-full);
|
|
145
|
+
cursor: pointer;
|
|
146
|
+
position: relative;
|
|
147
|
+
transition: color var(--st-transition-fast),
|
|
148
|
+
background-color var(--st-transition-fast);
|
|
149
|
+
user-select: none;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.day:hover:not(.disabled):not(.active):not(.rangeStart):not(.rangeEnd):not(.outside) {
|
|
153
|
+
color: var(--st-color-primary);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.day:focus-visible {
|
|
157
|
+
outline: 2px solid var(--st-color-primary);
|
|
158
|
+
outline-offset: 2px;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* Outside month */
|
|
162
|
+
.outside {
|
|
163
|
+
color: var(--st-color-neutral-400);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.outside:hover:not(.disabled) {
|
|
167
|
+
color: var(--st-color-neutral-500);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Disabled */
|
|
171
|
+
.disabled {
|
|
172
|
+
color: var(--st-color-neutral-300);
|
|
173
|
+
cursor: default;
|
|
174
|
+
pointer-events: none;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/* Today */
|
|
178
|
+
.today {
|
|
179
|
+
font-weight: var(--st-font-weight-semibold);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Active / Selected */
|
|
183
|
+
.active,
|
|
184
|
+
.rangeStart,
|
|
185
|
+
.rangeEnd {
|
|
186
|
+
background-color: var(--st-color-primary);
|
|
187
|
+
color: var(--st-color-primary-foreground);
|
|
188
|
+
font-weight: var(--st-font-weight-medium);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Range middle */
|
|
192
|
+
.rangeMiddle {
|
|
193
|
+
color: var(--st-color-primary);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* Event indicator dot */
|
|
197
|
+
.event::after {
|
|
198
|
+
content: '';
|
|
199
|
+
position: absolute;
|
|
200
|
+
bottom: 2px;
|
|
201
|
+
left: 50%;
|
|
202
|
+
transform: translateX(-50%);
|
|
203
|
+
width: 4px;
|
|
204
|
+
height: 4px;
|
|
205
|
+
border-radius: var(--st-radius-full);
|
|
206
|
+
background-color: var(--st-color-primary);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.active.event::after,
|
|
210
|
+
.rangeStart.event::after,
|
|
211
|
+
.rangeEnd.event::after {
|
|
212
|
+
background-color: var(--st-color-primary-foreground);
|
|
213
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { forwardRef, useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { CalendarProps } from './Calendar.types';
|
|
4
|
+
import styles from './Calendar.module.css';
|
|
5
|
+
|
|
6
|
+
const MONTH_NAMES = [
|
|
7
|
+
'January',
|
|
8
|
+
'February',
|
|
9
|
+
'March',
|
|
10
|
+
'April',
|
|
11
|
+
'May',
|
|
12
|
+
'June',
|
|
13
|
+
'July',
|
|
14
|
+
'August',
|
|
15
|
+
'September',
|
|
16
|
+
'October',
|
|
17
|
+
'November',
|
|
18
|
+
'December',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const WEEKDAYS = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
22
|
+
|
|
23
|
+
/* ── Inline icons ── */
|
|
24
|
+
|
|
25
|
+
function ChevronLeftIcon() {
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
width="16"
|
|
29
|
+
height="16"
|
|
30
|
+
viewBox="0 0 16 16"
|
|
31
|
+
fill="none"
|
|
32
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
33
|
+
>
|
|
34
|
+
<path
|
|
35
|
+
d="M10 4L6 8L10 12"
|
|
36
|
+
stroke="currentColor"
|
|
37
|
+
strokeWidth="1.5"
|
|
38
|
+
strokeLinecap="round"
|
|
39
|
+
strokeLinejoin="round"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function ChevronRightIcon() {
|
|
46
|
+
return (
|
|
47
|
+
<svg
|
|
48
|
+
width="16"
|
|
49
|
+
height="16"
|
|
50
|
+
viewBox="0 0 16 16"
|
|
51
|
+
fill="none"
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
>
|
|
54
|
+
<path
|
|
55
|
+
d="M6 4L10 8L6 12"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
strokeWidth="1.5"
|
|
58
|
+
strokeLinecap="round"
|
|
59
|
+
strokeLinejoin="round"
|
|
60
|
+
/>
|
|
61
|
+
</svg>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ── Helpers ── */
|
|
66
|
+
|
|
67
|
+
function isSameDay(a: Date, b: Date): boolean {
|
|
68
|
+
return (
|
|
69
|
+
a.getFullYear() === b.getFullYear() &&
|
|
70
|
+
a.getMonth() === b.getMonth() &&
|
|
71
|
+
a.getDate() === b.getDate()
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isInRange(date: Date, start: Date, end: Date): boolean {
|
|
76
|
+
const t = date.getTime();
|
|
77
|
+
return t > start.getTime() && t < end.getTime();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function generateGrid(year: number, month: number): Date[] {
|
|
81
|
+
const firstDayOfWeek = new Date(year, month, 1).getDay();
|
|
82
|
+
const startOffset = (firstDayOfWeek + 6) % 7; // Monday = 0
|
|
83
|
+
const dates: Date[] = [];
|
|
84
|
+
for (let i = 0; i < 42; i++) {
|
|
85
|
+
dates.push(new Date(year, month, 1 - startOffset + i));
|
|
86
|
+
}
|
|
87
|
+
return dates;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* ── Component ── */
|
|
91
|
+
|
|
92
|
+
export const Calendar = forwardRef<HTMLDivElement, CalendarProps>(
|
|
93
|
+
(
|
|
94
|
+
{
|
|
95
|
+
month: controlledMonth,
|
|
96
|
+
year: controlledYear,
|
|
97
|
+
value,
|
|
98
|
+
rangeStart: rawRangeStart,
|
|
99
|
+
rangeEnd: rawRangeEnd,
|
|
100
|
+
events,
|
|
101
|
+
minDate,
|
|
102
|
+
maxDate,
|
|
103
|
+
headerAlign = 'center',
|
|
104
|
+
onDateSelect,
|
|
105
|
+
onMonthChange,
|
|
106
|
+
className,
|
|
107
|
+
...rest
|
|
108
|
+
},
|
|
109
|
+
ref
|
|
110
|
+
) => {
|
|
111
|
+
const today = useMemo(() => new Date(), []);
|
|
112
|
+
const [internalMonth, setInternalMonth] = useState(
|
|
113
|
+
() => controlledMonth ?? today.getMonth()
|
|
114
|
+
);
|
|
115
|
+
const [internalYear, setInternalYear] = useState(
|
|
116
|
+
() => controlledYear ?? today.getFullYear()
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const displayMonth = controlledMonth ?? internalMonth;
|
|
120
|
+
const displayYear = controlledYear ?? internalYear;
|
|
121
|
+
|
|
122
|
+
// Normalize range so start ≤ end
|
|
123
|
+
const rangeStart =
|
|
124
|
+
rawRangeStart &&
|
|
125
|
+
rawRangeEnd &&
|
|
126
|
+
rawRangeEnd.getTime() < rawRangeStart.getTime()
|
|
127
|
+
? rawRangeEnd
|
|
128
|
+
: rawRangeStart;
|
|
129
|
+
const rangeEnd =
|
|
130
|
+
rawRangeStart &&
|
|
131
|
+
rawRangeEnd &&
|
|
132
|
+
rawRangeEnd.getTime() < rawRangeStart.getTime()
|
|
133
|
+
? rawRangeStart
|
|
134
|
+
: rawRangeEnd;
|
|
135
|
+
const hasRange = !!(
|
|
136
|
+
rangeStart &&
|
|
137
|
+
rangeEnd &&
|
|
138
|
+
!isSameDay(rangeStart, rangeEnd)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const days = useMemo(
|
|
142
|
+
() => generateGrid(displayYear, displayMonth),
|
|
143
|
+
[displayYear, displayMonth]
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const eventSet = useMemo(() => {
|
|
147
|
+
if (!events) return new Set<string>();
|
|
148
|
+
return new Set(
|
|
149
|
+
events.map(
|
|
150
|
+
(d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
}, [events]);
|
|
154
|
+
|
|
155
|
+
const navigate = useCallback(
|
|
156
|
+
(newMonth: number, newYear: number) => {
|
|
157
|
+
if (newMonth < 0) {
|
|
158
|
+
newMonth = 11;
|
|
159
|
+
newYear -= 1;
|
|
160
|
+
} else if (newMonth > 11) {
|
|
161
|
+
newMonth = 0;
|
|
162
|
+
newYear += 1;
|
|
163
|
+
}
|
|
164
|
+
if (controlledMonth === undefined) {
|
|
165
|
+
setInternalMonth(newMonth);
|
|
166
|
+
setInternalYear(newYear);
|
|
167
|
+
}
|
|
168
|
+
onMonthChange?.(newMonth, newYear);
|
|
169
|
+
},
|
|
170
|
+
[controlledMonth, onMonthChange]
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const yearRange = useMemo(() => {
|
|
174
|
+
const min = minDate ? minDate.getFullYear() : displayYear - 50;
|
|
175
|
+
const max = maxDate ? maxDate.getFullYear() : displayYear + 50;
|
|
176
|
+
const years: number[] = [];
|
|
177
|
+
for (let y = min; y <= max; y++) years.push(y);
|
|
178
|
+
return years;
|
|
179
|
+
}, [minDate, maxDate, displayYear]);
|
|
180
|
+
|
|
181
|
+
const isDisabled = useCallback(
|
|
182
|
+
(date: Date): boolean => {
|
|
183
|
+
if (minDate) {
|
|
184
|
+
const min = new Date(
|
|
185
|
+
minDate.getFullYear(),
|
|
186
|
+
minDate.getMonth(),
|
|
187
|
+
minDate.getDate()
|
|
188
|
+
);
|
|
189
|
+
if (date < min) return true;
|
|
190
|
+
}
|
|
191
|
+
if (maxDate) {
|
|
192
|
+
const max = new Date(
|
|
193
|
+
maxDate.getFullYear(),
|
|
194
|
+
maxDate.getMonth(),
|
|
195
|
+
maxDate.getDate()
|
|
196
|
+
);
|
|
197
|
+
if (date > max) return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
},
|
|
201
|
+
[minDate, maxDate]
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const getDayClasses = useCallback(
|
|
205
|
+
(date: Date) => {
|
|
206
|
+
const outside = date.getMonth() !== displayMonth;
|
|
207
|
+
const disabled = isDisabled(date);
|
|
208
|
+
const isActive =
|
|
209
|
+
(value != null && isSameDay(date, value)) ||
|
|
210
|
+
(rangeStart != null && !hasRange && isSameDay(date, rangeStart));
|
|
211
|
+
const isRangeStart = hasRange && isSameDay(date, rangeStart!);
|
|
212
|
+
const isRangeEnd = hasRange && isSameDay(date, rangeEnd!);
|
|
213
|
+
const inMiddle = hasRange && isInRange(date, rangeStart!, rangeEnd!);
|
|
214
|
+
const hasEvent = eventSet.has(
|
|
215
|
+
`${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`
|
|
216
|
+
);
|
|
217
|
+
const isToday =
|
|
218
|
+
isSameDay(date, today) &&
|
|
219
|
+
!isActive &&
|
|
220
|
+
!isRangeStart &&
|
|
221
|
+
!isRangeEnd;
|
|
222
|
+
|
|
223
|
+
const dayClass = cn(
|
|
224
|
+
styles.day,
|
|
225
|
+
outside && styles.outside,
|
|
226
|
+
disabled && styles.disabled,
|
|
227
|
+
isActive && styles.active,
|
|
228
|
+
isRangeStart && styles.rangeStart,
|
|
229
|
+
isRangeEnd && styles.rangeEnd,
|
|
230
|
+
inMiddle && styles.rangeMiddle,
|
|
231
|
+
hasEvent && styles.event,
|
|
232
|
+
isToday && styles.today
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const cellClass = cn(
|
|
236
|
+
styles.dayCell,
|
|
237
|
+
isRangeStart && styles.cellRangeStart,
|
|
238
|
+
isRangeEnd && styles.cellRangeEnd,
|
|
239
|
+
inMiddle && styles.cellRangeMiddle
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
return { dayClass, cellClass };
|
|
243
|
+
},
|
|
244
|
+
[
|
|
245
|
+
displayMonth,
|
|
246
|
+
isDisabled,
|
|
247
|
+
value,
|
|
248
|
+
rangeStart,
|
|
249
|
+
rangeEnd,
|
|
250
|
+
hasRange,
|
|
251
|
+
eventSet,
|
|
252
|
+
today,
|
|
253
|
+
]
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
/* ── Header pieces ── */
|
|
257
|
+
|
|
258
|
+
const headerSelects = (
|
|
259
|
+
<div className={styles.headerSelects}>
|
|
260
|
+
<select
|
|
261
|
+
className={styles.select}
|
|
262
|
+
value={displayMonth}
|
|
263
|
+
onChange={(e) => navigate(Number(e.target.value), displayYear)}
|
|
264
|
+
aria-label="Month"
|
|
265
|
+
>
|
|
266
|
+
{MONTH_NAMES.map((name, i) => (
|
|
267
|
+
<option key={i} value={i}>
|
|
268
|
+
{name}
|
|
269
|
+
</option>
|
|
270
|
+
))}
|
|
271
|
+
</select>
|
|
272
|
+
<select
|
|
273
|
+
className={styles.select}
|
|
274
|
+
value={displayYear}
|
|
275
|
+
onChange={(e) => navigate(displayMonth, Number(e.target.value))}
|
|
276
|
+
aria-label="Year"
|
|
277
|
+
>
|
|
278
|
+
{yearRange.map((y) => (
|
|
279
|
+
<option key={y} value={y}>
|
|
280
|
+
{y}
|
|
281
|
+
</option>
|
|
282
|
+
))}
|
|
283
|
+
</select>
|
|
284
|
+
</div>
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const prevButton = (
|
|
288
|
+
<button
|
|
289
|
+
type="button"
|
|
290
|
+
className={styles.navButton}
|
|
291
|
+
onClick={() => navigate(displayMonth - 1, displayYear)}
|
|
292
|
+
aria-label="Previous month"
|
|
293
|
+
>
|
|
294
|
+
<ChevronLeftIcon />
|
|
295
|
+
</button>
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
const nextButton = (
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
className={styles.navButton}
|
|
302
|
+
onClick={() => navigate(displayMonth + 1, displayYear)}
|
|
303
|
+
aria-label="Next month"
|
|
304
|
+
>
|
|
305
|
+
<ChevronRightIcon />
|
|
306
|
+
</button>
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<div ref={ref} className={cn(styles.root, className)} {...rest}>
|
|
311
|
+
<div className={cn(styles.header, styles[headerAlign])}>
|
|
312
|
+
{headerAlign === 'left' && (
|
|
313
|
+
<>
|
|
314
|
+
{headerSelects}
|
|
315
|
+
<div className={styles.headerNav}>
|
|
316
|
+
{prevButton}
|
|
317
|
+
{nextButton}
|
|
318
|
+
</div>
|
|
319
|
+
</>
|
|
320
|
+
)}
|
|
321
|
+
{headerAlign === 'center' && (
|
|
322
|
+
<>
|
|
323
|
+
{prevButton}
|
|
324
|
+
{headerSelects}
|
|
325
|
+
{nextButton}
|
|
326
|
+
</>
|
|
327
|
+
)}
|
|
328
|
+
{headerAlign === 'right' && (
|
|
329
|
+
<>
|
|
330
|
+
<div className={styles.headerNav}>
|
|
331
|
+
{prevButton}
|
|
332
|
+
{nextButton}
|
|
333
|
+
</div>
|
|
334
|
+
{headerSelects}
|
|
335
|
+
</>
|
|
336
|
+
)}
|
|
337
|
+
</div>
|
|
338
|
+
|
|
339
|
+
<div className={styles.weekdays}>
|
|
340
|
+
{WEEKDAYS.map((day) => (
|
|
341
|
+
<span key={day} className={styles.weekday}>
|
|
342
|
+
{day}
|
|
343
|
+
</span>
|
|
344
|
+
))}
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<div className={styles.grid}>
|
|
348
|
+
{days.map((date, i) => {
|
|
349
|
+
const { dayClass, cellClass } = getDayClasses(date);
|
|
350
|
+
return (
|
|
351
|
+
<div key={i} className={cellClass}>
|
|
352
|
+
<button
|
|
353
|
+
type="button"
|
|
354
|
+
className={dayClass}
|
|
355
|
+
disabled={isDisabled(date)}
|
|
356
|
+
onClick={() => onDateSelect?.(date)}
|
|
357
|
+
tabIndex={date.getMonth() !== displayMonth ? -1 : 0}
|
|
358
|
+
>
|
|
359
|
+
{date.getDate()}
|
|
360
|
+
</button>
|
|
361
|
+
</div>
|
|
362
|
+
);
|
|
363
|
+
})}
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
Calendar.displayName = 'Calendar';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type CalendarHeaderAlign = 'left' | 'center' | 'right';
|
|
4
|
+
|
|
5
|
+
export interface CalendarProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
/** Displayed month (0–11). Component is controlled when provided. */
|
|
7
|
+
month?: number;
|
|
8
|
+
/** Displayed year. Component is controlled when provided. */
|
|
9
|
+
year?: number;
|
|
10
|
+
/** Selected date (single-selection mode). */
|
|
11
|
+
value?: Date | null;
|
|
12
|
+
/** Range start date. */
|
|
13
|
+
rangeStart?: Date | null;
|
|
14
|
+
/** Range end date. */
|
|
15
|
+
rangeEnd?: Date | null;
|
|
16
|
+
/** Dates that display an event indicator dot. */
|
|
17
|
+
events?: Date[];
|
|
18
|
+
/** Minimum selectable date. */
|
|
19
|
+
minDate?: Date;
|
|
20
|
+
/** Maximum selectable date. */
|
|
21
|
+
maxDate?: Date;
|
|
22
|
+
/** Header layout: where month/year selects and nav arrows are placed. */
|
|
23
|
+
headerAlign?: CalendarHeaderAlign;
|
|
24
|
+
/** Called when a day is clicked. */
|
|
25
|
+
onDateSelect?: (date: Date) => void;
|
|
26
|
+
/** Called when the displayed month/year changes via navigation. */
|
|
27
|
+
onMonthChange?: (month: number, year: number) => void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
font-family: var(--st-font-family);
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--st-space-4);
|
|
6
|
+
padding: var(--st-space-6);
|
|
7
|
+
background: var(--st-color-surface);
|
|
8
|
+
border-radius: var(--st-radius-xl);
|
|
9
|
+
box-shadow: var(--st-shadow-lg);
|
|
10
|
+
border: 1px solid var(--st-color-border);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.calendars {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: var(--st-space-8);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rangeInfo {
|
|
19
|
+
font-size: var(--st-font-size-sm);
|
|
20
|
+
color: var(--st-color-muted);
|
|
21
|
+
text-align: center;
|
|
22
|
+
margin: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.actions {
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: flex-end;
|
|
28
|
+
gap: var(--st-space-3);
|
|
29
|
+
}
|