@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,375 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useState,
|
|
4
|
+
useRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useCallback,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { cn } from '../../utils/cn';
|
|
9
|
+
import type {
|
|
10
|
+
SelectDropdownProps,
|
|
11
|
+
SelectOption,
|
|
12
|
+
SelectOptionGroup,
|
|
13
|
+
} from './SelectDropdown.types';
|
|
14
|
+
import { SelectDropdownOverlay } from './SelectDropdownOverlay';
|
|
15
|
+
import styles from './SelectDropdown.module.css';
|
|
16
|
+
|
|
17
|
+
function ChevronDownIcon() {
|
|
18
|
+
return (
|
|
19
|
+
<svg
|
|
20
|
+
width="16"
|
|
21
|
+
height="16"
|
|
22
|
+
viewBox="0 0 16 16"
|
|
23
|
+
fill="none"
|
|
24
|
+
aria-hidden="true"
|
|
25
|
+
>
|
|
26
|
+
<path
|
|
27
|
+
d="M4 6L8 10L12 6"
|
|
28
|
+
stroke="currentColor"
|
|
29
|
+
strokeWidth="1.5"
|
|
30
|
+
strokeLinecap="round"
|
|
31
|
+
strokeLinejoin="round"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function ChipDismissIcon() {
|
|
38
|
+
return (
|
|
39
|
+
<svg
|
|
40
|
+
width="12"
|
|
41
|
+
height="12"
|
|
42
|
+
viewBox="0 0 12 12"
|
|
43
|
+
fill="none"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
>
|
|
46
|
+
<path
|
|
47
|
+
d="M3 3L9 9M9 3L3 9"
|
|
48
|
+
stroke="currentColor"
|
|
49
|
+
strokeWidth="1.5"
|
|
50
|
+
strokeLinecap="round"
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function FeedbackDot() {
|
|
57
|
+
return (
|
|
58
|
+
<svg
|
|
59
|
+
width="8"
|
|
60
|
+
height="8"
|
|
61
|
+
viewBox="0 0 8 8"
|
|
62
|
+
fill="none"
|
|
63
|
+
aria-hidden="true"
|
|
64
|
+
>
|
|
65
|
+
<circle cx="4" cy="4" r="4" fill="currentColor" />
|
|
66
|
+
</svg>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function FeedbackTriangle() {
|
|
71
|
+
return (
|
|
72
|
+
<svg
|
|
73
|
+
width="8"
|
|
74
|
+
height="8"
|
|
75
|
+
viewBox="0 0 8 8"
|
|
76
|
+
fill="none"
|
|
77
|
+
aria-hidden="true"
|
|
78
|
+
>
|
|
79
|
+
<path d="M4 0L8 8H0L4 0Z" fill="currentColor" />
|
|
80
|
+
</svg>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function FeedbackDiamond() {
|
|
85
|
+
return (
|
|
86
|
+
<svg
|
|
87
|
+
width="8"
|
|
88
|
+
height="8"
|
|
89
|
+
viewBox="0 0 8 8"
|
|
90
|
+
fill="none"
|
|
91
|
+
aria-hidden="true"
|
|
92
|
+
>
|
|
93
|
+
<path d="M4 0L8 4L4 8L0 4L4 0Z" fill="currentColor" />
|
|
94
|
+
</svg>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const feedbackIcons = {
|
|
99
|
+
success: FeedbackDot,
|
|
100
|
+
error: FeedbackDot,
|
|
101
|
+
warning: FeedbackTriangle,
|
|
102
|
+
ai: FeedbackDiamond,
|
|
103
|
+
} as const;
|
|
104
|
+
|
|
105
|
+
function isGroup(
|
|
106
|
+
item: SelectOption | SelectOptionGroup,
|
|
107
|
+
): item is SelectOptionGroup {
|
|
108
|
+
return 'options' in item;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function flattenOptions(
|
|
112
|
+
items: (SelectOption | SelectOptionGroup)[],
|
|
113
|
+
): SelectOption[] {
|
|
114
|
+
const result: SelectOption[] = [];
|
|
115
|
+
for (const item of items) {
|
|
116
|
+
if (isGroup(item)) {
|
|
117
|
+
result.push(...item.options);
|
|
118
|
+
} else {
|
|
119
|
+
result.push(item);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const SelectDropdown = forwardRef<HTMLDivElement, SelectDropdownProps>(
|
|
126
|
+
(props, ref) => {
|
|
127
|
+
const {
|
|
128
|
+
size = 'lg',
|
|
129
|
+
label,
|
|
130
|
+
helperText,
|
|
131
|
+
feedback,
|
|
132
|
+
placeholder = 'Select...',
|
|
133
|
+
disabled = false,
|
|
134
|
+
required,
|
|
135
|
+
searchable = true,
|
|
136
|
+
searchPlaceholder = 'Search',
|
|
137
|
+
options,
|
|
138
|
+
noOptionsText = 'No options',
|
|
139
|
+
className,
|
|
140
|
+
multiple: _multiple,
|
|
141
|
+
value: _value,
|
|
142
|
+
onChange: _onChange,
|
|
143
|
+
...rest
|
|
144
|
+
} = props as SelectDropdownProps & {
|
|
145
|
+
multiple?: boolean;
|
|
146
|
+
value?: unknown;
|
|
147
|
+
onChange?: unknown;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const multiple = props.multiple === true;
|
|
151
|
+
const maxVisibleChips = multiple
|
|
152
|
+
? ((props as { maxVisibleChips?: number }).maxVisibleChips ?? 1)
|
|
153
|
+
: 1;
|
|
154
|
+
|
|
155
|
+
const [open, setOpen] = useState(false);
|
|
156
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
157
|
+
|
|
158
|
+
// Merge forwarded ref with internal ref
|
|
159
|
+
const setRefs = useCallback(
|
|
160
|
+
(node: HTMLDivElement | null) => {
|
|
161
|
+
(rootRef as React.MutableRefObject<HTMLDivElement | null>).current =
|
|
162
|
+
node;
|
|
163
|
+
if (typeof ref === 'function') ref(node);
|
|
164
|
+
else if (ref)
|
|
165
|
+
(ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
|
166
|
+
},
|
|
167
|
+
[ref],
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// Close on click-outside
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
if (!open) return;
|
|
173
|
+
function handleClick(e: MouseEvent) {
|
|
174
|
+
if (
|
|
175
|
+
rootRef.current &&
|
|
176
|
+
!rootRef.current.contains(e.target as Node)
|
|
177
|
+
) {
|
|
178
|
+
setOpen(false);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
document.addEventListener('mousedown', handleClick);
|
|
182
|
+
return () => document.removeEventListener('mousedown', handleClick);
|
|
183
|
+
}, [open]);
|
|
184
|
+
|
|
185
|
+
// Close on Escape
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (!open) return;
|
|
188
|
+
function handleKey(e: KeyboardEvent) {
|
|
189
|
+
if (e.key === 'Escape') setOpen(false);
|
|
190
|
+
}
|
|
191
|
+
document.addEventListener('keydown', handleKey);
|
|
192
|
+
return () => document.removeEventListener('keydown', handleKey);
|
|
193
|
+
}, [open]);
|
|
194
|
+
|
|
195
|
+
const toggleOpen = useCallback(() => {
|
|
196
|
+
if (!disabled) setOpen((prev) => !prev);
|
|
197
|
+
}, [disabled]);
|
|
198
|
+
|
|
199
|
+
const allOptions = flattenOptions(options);
|
|
200
|
+
|
|
201
|
+
// Selected values as array
|
|
202
|
+
const selectedValues: string[] = multiple
|
|
203
|
+
? ((props as { value?: string[] }).value ?? [])
|
|
204
|
+
: (props as { value?: string | null }).value
|
|
205
|
+
? [(props as { value?: string | null }).value as string]
|
|
206
|
+
: [];
|
|
207
|
+
|
|
208
|
+
const handleSelect = useCallback(
|
|
209
|
+
(value: string) => {
|
|
210
|
+
if (multiple) {
|
|
211
|
+
const onChange = (props as { onChange?: (v: string[]) => void })
|
|
212
|
+
.onChange;
|
|
213
|
+
const current = (props as { value?: string[] }).value ?? [];
|
|
214
|
+
if (current.includes(value)) {
|
|
215
|
+
onChange?.(current.filter((v) => v !== value));
|
|
216
|
+
} else {
|
|
217
|
+
onChange?.([...current, value]);
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
const onChange = (
|
|
221
|
+
props as { onChange?: (v: string | null) => void }
|
|
222
|
+
).onChange;
|
|
223
|
+
onChange?.(value);
|
|
224
|
+
setOpen(false);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
[multiple, props],
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const handleChipDismiss = useCallback(
|
|
231
|
+
(value: string, e: React.MouseEvent) => {
|
|
232
|
+
e.stopPropagation();
|
|
233
|
+
if (multiple) {
|
|
234
|
+
const onChange = (props as { onChange?: (v: string[]) => void })
|
|
235
|
+
.onChange;
|
|
236
|
+
const current = (props as { value?: string[] }).value ?? [];
|
|
237
|
+
onChange?.(current.filter((v) => v !== value));
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
[multiple, props],
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const feedbackStatus = feedback?.status;
|
|
244
|
+
const FeedbackIcon = feedbackStatus
|
|
245
|
+
? feedbackIcons[feedbackStatus]
|
|
246
|
+
: null;
|
|
247
|
+
|
|
248
|
+
const triggerCls = cn(
|
|
249
|
+
styles.trigger,
|
|
250
|
+
styles[size],
|
|
251
|
+
open && styles.open,
|
|
252
|
+
feedbackStatus && styles[feedbackStatus],
|
|
253
|
+
disabled && styles.disabled,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
// Render trigger content
|
|
257
|
+
const renderTriggerContent = () => {
|
|
258
|
+
if (multiple) {
|
|
259
|
+
const values = (props as { value?: string[] }).value ?? [];
|
|
260
|
+
if (values.length === 0) {
|
|
261
|
+
return <span className={styles.placeholder}>{placeholder}</span>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const visibleChips = values.slice(0, maxVisibleChips);
|
|
265
|
+
const overflowCount = values.length - maxVisibleChips;
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<div className={styles.chipArea}>
|
|
269
|
+
{visibleChips.map((val) => {
|
|
270
|
+
const opt = allOptions.find((o) => o.value === val);
|
|
271
|
+
return (
|
|
272
|
+
<span key={val} className={styles.valueChip}>
|
|
273
|
+
<span className={styles.chipLabel}>
|
|
274
|
+
{opt?.label ?? val}
|
|
275
|
+
</span>
|
|
276
|
+
<button
|
|
277
|
+
type="button"
|
|
278
|
+
className={styles.chipDismiss}
|
|
279
|
+
onClick={(e) => handleChipDismiss(val, e)}
|
|
280
|
+
aria-label={`Remove ${opt?.label ?? val}`}
|
|
281
|
+
>
|
|
282
|
+
<ChipDismissIcon />
|
|
283
|
+
</button>
|
|
284
|
+
</span>
|
|
285
|
+
);
|
|
286
|
+
})}
|
|
287
|
+
{overflowCount > 0 && (
|
|
288
|
+
<span className={styles.overflowCount}>+{overflowCount}</span>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Single select
|
|
295
|
+
const singleValue = (props as { value?: string | null }).value;
|
|
296
|
+
if (!singleValue) {
|
|
297
|
+
return <span className={styles.placeholder}>{placeholder}</span>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const selectedOpt = allOptions.find((o) => o.value === singleValue);
|
|
301
|
+
return (
|
|
302
|
+
<span className={styles.value}>
|
|
303
|
+
{selectedOpt?.label ?? singleValue}
|
|
304
|
+
</span>
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<div
|
|
310
|
+
ref={setRefs}
|
|
311
|
+
className={cn(styles.root, className)}
|
|
312
|
+
{...rest}
|
|
313
|
+
>
|
|
314
|
+
{label && (
|
|
315
|
+
<span className={styles.label}>
|
|
316
|
+
{label}
|
|
317
|
+
{required && <span className={styles.required}>*</span>}
|
|
318
|
+
</span>
|
|
319
|
+
)}
|
|
320
|
+
|
|
321
|
+
<div
|
|
322
|
+
className={triggerCls}
|
|
323
|
+
role="combobox"
|
|
324
|
+
aria-expanded={open}
|
|
325
|
+
aria-haspopup="listbox"
|
|
326
|
+
tabIndex={disabled ? -1 : 0}
|
|
327
|
+
onClick={toggleOpen}
|
|
328
|
+
onKeyDown={(e) => {
|
|
329
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
toggleOpen();
|
|
332
|
+
}
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
{renderTriggerContent()}
|
|
336
|
+
<span className={cn(styles.chevron, open && styles.chevronOpen)}>
|
|
337
|
+
<ChevronDownIcon />
|
|
338
|
+
</span>
|
|
339
|
+
</div>
|
|
340
|
+
|
|
341
|
+
{helperText && (
|
|
342
|
+
<span className={styles.helperText}>{helperText}</span>
|
|
343
|
+
)}
|
|
344
|
+
|
|
345
|
+
{feedback && (
|
|
346
|
+
<span
|
|
347
|
+
className={cn(
|
|
348
|
+
styles.feedbackText,
|
|
349
|
+
styles[`feedback_${feedbackStatus}`],
|
|
350
|
+
)}
|
|
351
|
+
>
|
|
352
|
+
{FeedbackIcon && <FeedbackIcon />}
|
|
353
|
+
{feedback.message}
|
|
354
|
+
</span>
|
|
355
|
+
)}
|
|
356
|
+
|
|
357
|
+
{open && (
|
|
358
|
+
<div className={styles.popover}>
|
|
359
|
+
<SelectDropdownOverlay
|
|
360
|
+
items={options}
|
|
361
|
+
selectedValues={selectedValues}
|
|
362
|
+
multiple={multiple}
|
|
363
|
+
searchable={searchable}
|
|
364
|
+
searchPlaceholder={searchPlaceholder}
|
|
365
|
+
noOptionsText={noOptionsText}
|
|
366
|
+
onSelect={handleSelect}
|
|
367
|
+
/>
|
|
368
|
+
</div>
|
|
369
|
+
)}
|
|
370
|
+
</div>
|
|
371
|
+
);
|
|
372
|
+
},
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
SelectDropdown.displayName = 'SelectDropdown';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type SelectDropdownSize = 'lg' | 'md';
|
|
4
|
+
export type SelectDropdownFeedbackStatus = 'success' | 'error' | 'warning' | 'ai';
|
|
5
|
+
|
|
6
|
+
export interface SelectDropdownFeedback {
|
|
7
|
+
status: SelectDropdownFeedbackStatus;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SelectOption {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SelectOptionGroup {
|
|
19
|
+
label: string;
|
|
20
|
+
options: SelectOption[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Base extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
24
|
+
size?: SelectDropdownSize;
|
|
25
|
+
label?: string;
|
|
26
|
+
helperText?: string;
|
|
27
|
+
feedback?: SelectDropdownFeedback;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
searchable?: boolean;
|
|
32
|
+
searchPlaceholder?: string;
|
|
33
|
+
options: (SelectOption | SelectOptionGroup)[];
|
|
34
|
+
noOptionsText?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SingleSelectProps extends Base {
|
|
38
|
+
multiple?: false;
|
|
39
|
+
value?: string | null;
|
|
40
|
+
onChange?: (value: string | null) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface MultiSelectProps extends Base {
|
|
44
|
+
multiple: true;
|
|
45
|
+
value?: string[];
|
|
46
|
+
onChange?: (value: string[]) => void;
|
|
47
|
+
maxVisibleChips?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type SelectDropdownProps = SingleSelectProps | MultiSelectProps;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* ─── Option row ─── */
|
|
2
|
+
.option {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--st-space-2);
|
|
6
|
+
padding: var(--st-space-2) var(--st-space-3);
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
font-size: var(--st-font-size-sm);
|
|
9
|
+
line-height: var(--st-line-height-normal);
|
|
10
|
+
color: var(--st-color-foreground);
|
|
11
|
+
transition:
|
|
12
|
+
background-color var(--st-transition-fast),
|
|
13
|
+
color var(--st-transition-fast);
|
|
14
|
+
outline: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ─── Highlighted (keyboard) ─── */
|
|
18
|
+
.option.highlighted {
|
|
19
|
+
background-color: var(--st-color-neutral-100);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* ─── Hover ─── */
|
|
23
|
+
.option:hover:not(.disabled) {
|
|
24
|
+
background-color: var(--st-color-neutral-100);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* ─── Disabled ─── */
|
|
28
|
+
.option.disabled {
|
|
29
|
+
opacity: 0.5;
|
|
30
|
+
cursor: not-allowed;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ─── Checkbox (multiselect) ─── */
|
|
34
|
+
.checkbox {
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
width: 16px;
|
|
40
|
+
height: 16px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.checkboxBox {
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
width: 16px;
|
|
48
|
+
height: 16px;
|
|
49
|
+
border: 1.5px solid var(--st-color-neutral-300);
|
|
50
|
+
border-radius: var(--st-radius-sm);
|
|
51
|
+
background-color: var(--st-color-background);
|
|
52
|
+
transition:
|
|
53
|
+
background-color var(--st-transition-fast),
|
|
54
|
+
border-color var(--st-transition-fast);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.checkboxBox.checked {
|
|
58
|
+
background-color: var(--st-color-success);
|
|
59
|
+
border-color: var(--st-color-success);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.checkboxIcon {
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
color: var(--st-color-success-foreground);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.checkboxIcon svg {
|
|
70
|
+
width: 12px;
|
|
71
|
+
height: 12px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* ─── Content ─── */
|
|
75
|
+
.content {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
flex: 1;
|
|
79
|
+
min-width: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.label {
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
text-overflow: ellipsis;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.description {
|
|
89
|
+
font-size: var(--st-font-size-xs);
|
|
90
|
+
color: var(--st-color-muted);
|
|
91
|
+
line-height: var(--st-line-height-normal);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* ─── Check icon (single select) ─── */
|
|
95
|
+
.checkIcon {
|
|
96
|
+
display: inline-flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
margin-left: auto;
|
|
100
|
+
color: var(--st-color-success);
|
|
101
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { cn } from '../../utils/cn';
|
|
2
|
+
import type { SelectOption } from './SelectDropdown.types';
|
|
3
|
+
import styles from './SelectDropdownOption.module.css';
|
|
4
|
+
|
|
5
|
+
function CheckmarkIcon() {
|
|
6
|
+
return (
|
|
7
|
+
<svg
|
|
8
|
+
width="16"
|
|
9
|
+
height="16"
|
|
10
|
+
viewBox="0 0 16 16"
|
|
11
|
+
fill="none"
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M3 8.5L6.5 12L13 4"
|
|
16
|
+
stroke="currentColor"
|
|
17
|
+
strokeWidth="1.5"
|
|
18
|
+
strokeLinecap="round"
|
|
19
|
+
strokeLinejoin="round"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface SelectDropdownOptionProps {
|
|
26
|
+
option: SelectOption;
|
|
27
|
+
selected: boolean;
|
|
28
|
+
highlighted: boolean;
|
|
29
|
+
multiple: boolean;
|
|
30
|
+
onSelect: (value: string) => void;
|
|
31
|
+
onMouseEnter: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function SelectDropdownOption({
|
|
35
|
+
option,
|
|
36
|
+
selected,
|
|
37
|
+
highlighted,
|
|
38
|
+
multiple,
|
|
39
|
+
onSelect,
|
|
40
|
+
onMouseEnter,
|
|
41
|
+
}: SelectDropdownOptionProps) {
|
|
42
|
+
const handleClick = () => {
|
|
43
|
+
if (!option.disabled) onSelect(option.value);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
className={cn(
|
|
49
|
+
styles.option,
|
|
50
|
+
highlighted && styles.highlighted,
|
|
51
|
+
selected && styles.selected,
|
|
52
|
+
option.disabled && styles.disabled,
|
|
53
|
+
)}
|
|
54
|
+
role="option"
|
|
55
|
+
aria-selected={selected}
|
|
56
|
+
aria-disabled={option.disabled || undefined}
|
|
57
|
+
onClick={handleClick}
|
|
58
|
+
onMouseEnter={onMouseEnter}
|
|
59
|
+
>
|
|
60
|
+
{multiple && (
|
|
61
|
+
<span className={styles.checkbox}>
|
|
62
|
+
<span className={cn(styles.checkboxBox, selected && styles.checked)}>
|
|
63
|
+
{selected && (
|
|
64
|
+
<span className={styles.checkboxIcon}>
|
|
65
|
+
<CheckmarkIcon />
|
|
66
|
+
</span>
|
|
67
|
+
)}
|
|
68
|
+
</span>
|
|
69
|
+
</span>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
<div className={styles.content}>
|
|
73
|
+
<span className={styles.label}>{option.label}</span>
|
|
74
|
+
{option.description && (
|
|
75
|
+
<span className={styles.description}>{option.description}</span>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
{!multiple && selected && (
|
|
80
|
+
<span className={styles.checkIcon}>
|
|
81
|
+
<CheckmarkIcon />
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* ─── Overlay panel ─── */
|
|
2
|
+
.overlay {
|
|
3
|
+
background: var(--st-color-surface);
|
|
4
|
+
border: 1px solid var(--st-color-border);
|
|
5
|
+
border-radius: var(--st-radius-xl);
|
|
6
|
+
box-shadow: var(--st-shadow-lg);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* ─── Search box ─── */
|
|
11
|
+
.searchBox {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: var(--st-space-2);
|
|
15
|
+
padding: var(--st-space-2) var(--st-space-3);
|
|
16
|
+
border-bottom: 1px solid var(--st-color-border);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.searchIcon {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
flex-shrink: 0;
|
|
23
|
+
color: var(--st-color-muted);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.searchInput {
|
|
27
|
+
flex: 1;
|
|
28
|
+
min-width: 0;
|
|
29
|
+
border: none;
|
|
30
|
+
outline: none;
|
|
31
|
+
background: transparent;
|
|
32
|
+
font-family: inherit;
|
|
33
|
+
font-size: var(--st-font-size-sm);
|
|
34
|
+
line-height: var(--st-line-height-normal);
|
|
35
|
+
color: var(--st-color-foreground);
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.searchInput::placeholder {
|
|
40
|
+
color: var(--st-color-muted);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* ─── Option list ─── */
|
|
44
|
+
.optionList {
|
|
45
|
+
max-height: 240px;
|
|
46
|
+
overflow-y: auto;
|
|
47
|
+
padding: var(--st-space-1) 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* ─── Group label ─── */
|
|
51
|
+
.groupLabel {
|
|
52
|
+
display: block;
|
|
53
|
+
padding: var(--st-space-2) var(--st-space-3) var(--st-space-1);
|
|
54
|
+
font-size: var(--st-font-size-xs);
|
|
55
|
+
font-weight: var(--st-font-weight-semibold);
|
|
56
|
+
line-height: var(--st-line-height-tight);
|
|
57
|
+
color: var(--st-color-muted);
|
|
58
|
+
user-select: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ─── Divider ─── */
|
|
62
|
+
.divider {
|
|
63
|
+
height: 1px;
|
|
64
|
+
background: var(--st-color-border);
|
|
65
|
+
margin: var(--st-space-1) 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ─── No options ─── */
|
|
69
|
+
.noOptions {
|
|
70
|
+
padding: var(--st-space-4) var(--st-space-3);
|
|
71
|
+
text-align: center;
|
|
72
|
+
font-size: var(--st-font-size-sm);
|
|
73
|
+
color: var(--st-color-muted);
|
|
74
|
+
}
|