@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,251 @@
|
|
|
1
|
+
import { forwardRef, useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { InputSearchProps } from './InputSearch.types';
|
|
4
|
+
import styles from './InputSearch.module.css';
|
|
5
|
+
|
|
6
|
+
function SearchIcon() {
|
|
7
|
+
return (
|
|
8
|
+
<svg
|
|
9
|
+
width="16"
|
|
10
|
+
height="16"
|
|
11
|
+
viewBox="0 0 16 16"
|
|
12
|
+
fill="none"
|
|
13
|
+
aria-hidden="true"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
fillRule="evenodd"
|
|
17
|
+
clipRule="evenodd"
|
|
18
|
+
d="M0.833313 7.33331C0.833313 3.74346 3.74346 0.833313 7.33331 0.833313C10.9232 0.833313 13.8333 3.74347 13.8333 7.33331C13.8333 8.94827 13.2444 10.4257 12.2695 11.5624L15.0202 14.3131C15.2155 14.5084 15.2155 14.8249 15.0202 15.0202C14.8249 15.2155 14.5084 15.2155 14.3131 15.0202L11.5624 12.2695C10.4257 13.2444 8.94827 13.8333 7.33331 13.8333C3.74347 13.8333 0.833313 10.9232 0.833313 7.33331ZM7.33331 1.83331C4.29575 1.83331 1.83331 4.29575 1.83331 7.33331C1.83331 10.3709 4.29575 12.8333 7.33331 12.8333C10.3709 12.8333 12.8333 10.3709 12.8333 7.33331C12.8333 4.29575 10.3709 1.83331 7.33331 1.83331Z"
|
|
19
|
+
fill="currentColor"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function CloseIcon() {
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
width="20"
|
|
29
|
+
height="20"
|
|
30
|
+
viewBox="0 0 20 20"
|
|
31
|
+
fill="none"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
>
|
|
34
|
+
<path
|
|
35
|
+
fillRule="evenodd"
|
|
36
|
+
clipRule="evenodd"
|
|
37
|
+
d="M4.55806 4.55806C4.80214 4.31398 5.19786 4.31398 5.44194 4.55806L10.5028 9.61889L15.5636 4.55806C15.8077 4.31398 16.2034 4.31398 16.4475 4.55806C16.6916 4.80214 16.6916 5.19786 16.4475 5.44194L11.3867 10.5028L16.4475 15.5636C16.6916 15.8077 16.6916 16.2034 16.4475 16.4475C16.2034 16.6916 15.8077 16.6916 15.5636 16.4475L10.5028 11.3867L5.44194 16.4475C5.19786 16.6916 4.80214 16.6916 4.55806 16.4475C4.31398 16.2034 4.31398 15.8077 4.55806 15.5636L9.61889 10.5028L4.55806 5.44194C4.31398 5.19786 4.31398 4.80214 4.55806 4.55806Z"
|
|
38
|
+
fill="currentColor"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function FeedbackDot() {
|
|
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
|
+
function FeedbackTriangle() {
|
|
59
|
+
return (
|
|
60
|
+
<svg
|
|
61
|
+
width="8"
|
|
62
|
+
height="8"
|
|
63
|
+
viewBox="0 0 8 8"
|
|
64
|
+
fill="none"
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
>
|
|
67
|
+
<path d="M4 0L8 8H0L4 0Z" fill="currentColor" />
|
|
68
|
+
</svg>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function FeedbackDiamond() {
|
|
73
|
+
return (
|
|
74
|
+
<svg
|
|
75
|
+
width="8"
|
|
76
|
+
height="8"
|
|
77
|
+
viewBox="0 0 8 8"
|
|
78
|
+
fill="none"
|
|
79
|
+
aria-hidden="true"
|
|
80
|
+
>
|
|
81
|
+
<path d="M4 0L8 4L4 8L0 4L4 0Z" fill="currentColor" />
|
|
82
|
+
</svg>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const feedbackIcons = {
|
|
87
|
+
success: FeedbackDot,
|
|
88
|
+
error: FeedbackDot,
|
|
89
|
+
warning: FeedbackTriangle,
|
|
90
|
+
ai: FeedbackDiamond,
|
|
91
|
+
} as const;
|
|
92
|
+
|
|
93
|
+
export const InputSearch = forwardRef<HTMLInputElement, InputSearchProps>(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
label,
|
|
97
|
+
placeholder,
|
|
98
|
+
value,
|
|
99
|
+
defaultValue,
|
|
100
|
+
onChange,
|
|
101
|
+
onSearch,
|
|
102
|
+
onClear,
|
|
103
|
+
helperText,
|
|
104
|
+
feedback,
|
|
105
|
+
disabled,
|
|
106
|
+
required,
|
|
107
|
+
className,
|
|
108
|
+
name,
|
|
109
|
+
},
|
|
110
|
+
ref,
|
|
111
|
+
) => {
|
|
112
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
113
|
+
const [focused, setFocused] = useState(false);
|
|
114
|
+
const [internalValue, setInternalValue] = useState(
|
|
115
|
+
() => (defaultValue as string) ?? '',
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const isControlled = value !== undefined;
|
|
119
|
+
const currentValue = isControlled ? String(value) : internalValue;
|
|
120
|
+
const hasValue = currentValue.length > 0;
|
|
121
|
+
|
|
122
|
+
const setRefs = useCallback(
|
|
123
|
+
(node: HTMLInputElement | null) => {
|
|
124
|
+
(inputRef as React.MutableRefObject<HTMLInputElement | null>).current =
|
|
125
|
+
node;
|
|
126
|
+
if (typeof ref === 'function') ref(node);
|
|
127
|
+
else if (ref)
|
|
128
|
+
(ref as React.MutableRefObject<HTMLInputElement | null>).current =
|
|
129
|
+
node;
|
|
130
|
+
},
|
|
131
|
+
[ref],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
135
|
+
if (!isControlled) setInternalValue(e.target.value);
|
|
136
|
+
onChange?.(e);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
140
|
+
setFocused(true);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
144
|
+
setFocused(false);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const handleClear = () => {
|
|
148
|
+
if (!isControlled) setInternalValue('');
|
|
149
|
+
onClear?.();
|
|
150
|
+
inputRef.current?.focus();
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const handleSearch = () => {
|
|
154
|
+
onSearch?.(currentValue);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
158
|
+
if (e.key === 'Enter') {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
handleSearch();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const feedbackStatus = feedback?.status;
|
|
165
|
+
const showClear = (focused || hasValue) && !disabled;
|
|
166
|
+
|
|
167
|
+
const inputBoxCls = cn(
|
|
168
|
+
styles.inputBox,
|
|
169
|
+
focused && styles.focused,
|
|
170
|
+
feedbackStatus && styles[feedbackStatus],
|
|
171
|
+
disabled && styles.disabled,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const inputCls = cn(
|
|
175
|
+
styles.input,
|
|
176
|
+
feedbackStatus === 'error' && styles.input_error,
|
|
177
|
+
feedbackStatus === 'ai' && styles.input_ai,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const FeedbackIcon = feedbackStatus
|
|
181
|
+
? feedbackIcons[feedbackStatus]
|
|
182
|
+
: null;
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<div className={cn(styles.root, className)}>
|
|
186
|
+
{label && (
|
|
187
|
+
<span className={styles.label}>
|
|
188
|
+
{label}
|
|
189
|
+
{required && <span className={styles.required}>*</span>}
|
|
190
|
+
</span>
|
|
191
|
+
)}
|
|
192
|
+
|
|
193
|
+
<div className={inputBoxCls}>
|
|
194
|
+
<input
|
|
195
|
+
ref={setRefs}
|
|
196
|
+
className={inputCls}
|
|
197
|
+
placeholder={placeholder}
|
|
198
|
+
value={isControlled ? currentValue : undefined}
|
|
199
|
+
defaultValue={isControlled ? undefined : defaultValue}
|
|
200
|
+
onChange={handleChange}
|
|
201
|
+
onFocus={handleFocus}
|
|
202
|
+
onBlur={handleBlur}
|
|
203
|
+
onKeyDown={handleKeyDown}
|
|
204
|
+
disabled={disabled}
|
|
205
|
+
required={required}
|
|
206
|
+
name={name}
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
{showClear && (
|
|
210
|
+
<button
|
|
211
|
+
type="button"
|
|
212
|
+
className={styles.clearBtn}
|
|
213
|
+
onClick={handleClear}
|
|
214
|
+
aria-label="Clear search"
|
|
215
|
+
>
|
|
216
|
+
<CloseIcon />
|
|
217
|
+
</button>
|
|
218
|
+
)}
|
|
219
|
+
|
|
220
|
+
<button
|
|
221
|
+
type="button"
|
|
222
|
+
className={styles.searchBtn}
|
|
223
|
+
onClick={handleSearch}
|
|
224
|
+
disabled={disabled}
|
|
225
|
+
aria-label="Search"
|
|
226
|
+
>
|
|
227
|
+
<SearchIcon />
|
|
228
|
+
</button>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
{helperText && (
|
|
232
|
+
<span className={styles.helperText}>{helperText}</span>
|
|
233
|
+
)}
|
|
234
|
+
|
|
235
|
+
{feedback && (
|
|
236
|
+
<span
|
|
237
|
+
className={cn(
|
|
238
|
+
styles.feedbackText,
|
|
239
|
+
styles[`feedback_${feedbackStatus}`],
|
|
240
|
+
)}
|
|
241
|
+
>
|
|
242
|
+
{FeedbackIcon && <FeedbackIcon />}
|
|
243
|
+
{feedback.message}
|
|
244
|
+
</span>
|
|
245
|
+
)}
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
},
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
InputSearch.displayName = 'InputSearch';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type InputSearchFeedbackStatus = 'success' | 'error' | 'warning' | 'ai';
|
|
2
|
+
|
|
3
|
+
export interface InputSearchFeedback {
|
|
4
|
+
status: InputSearchFeedbackStatus;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface InputSearchProps {
|
|
9
|
+
/** Label text above input. */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** Placeholder text for the input. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Controlled value. */
|
|
14
|
+
value?: string;
|
|
15
|
+
/** Uncontrolled initial value. */
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
/** Native change handler for the input. */
|
|
18
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
/** Called with current value on Enter or search icon click. */
|
|
20
|
+
onSearch?: (value: string) => void;
|
|
21
|
+
/** Called when the clear button is clicked. */
|
|
22
|
+
onClear?: () => void;
|
|
23
|
+
/** Helper text below input. */
|
|
24
|
+
helperText?: string;
|
|
25
|
+
/** Validation feedback — affects border + text color. */
|
|
26
|
+
feedback?: InputSearchFeedback;
|
|
27
|
+
/** Disables entire component. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Shows asterisk on label. */
|
|
30
|
+
required?: boolean;
|
|
31
|
+
/** Additional class on root element. */
|
|
32
|
+
className?: string;
|
|
33
|
+
/** Name attribute for the input. */
|
|
34
|
+
name?: string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/* ─── Root ─── */
|
|
2
|
+
.root {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--st-space-2);
|
|
6
|
+
font-family: var(--st-font-family);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* ─── Label ─── */
|
|
10
|
+
.label {
|
|
11
|
+
font-size: var(--st-font-size-sm);
|
|
12
|
+
font-weight: var(--st-font-weight-semibold);
|
|
13
|
+
line-height: var(--st-line-height-tight);
|
|
14
|
+
color: var(--st-color-foreground);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.required {
|
|
18
|
+
color: var(--st-color-error);
|
|
19
|
+
margin-left: var(--st-space-1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* ─── Description ─── */
|
|
23
|
+
.description {
|
|
24
|
+
font-size: var(--st-font-size-xs);
|
|
25
|
+
line-height: var(--st-line-height-normal);
|
|
26
|
+
color: var(--st-color-muted);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ─── Input box ─── */
|
|
30
|
+
.inputBox {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--st-space-2);
|
|
34
|
+
border: 1px solid var(--st-color-border);
|
|
35
|
+
border-radius: var(--st-radius-lg);
|
|
36
|
+
background: var(--st-color-surface);
|
|
37
|
+
padding: 0 var(--st-space-3);
|
|
38
|
+
transition: border-color var(--st-transition-fast),
|
|
39
|
+
box-shadow var(--st-transition-fast);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.inputBox.lg {
|
|
43
|
+
height: 48px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.inputBox.md {
|
|
47
|
+
height: 40px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.inputBox:hover:not(.disabled):not(.error):not(.warning):not(.success):not(.ai):not(.focused) {
|
|
51
|
+
border-color: var(--st-color-border-strong);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.inputBox.focused:not(.disabled):not(.error):not(.warning):not(.success):not(.ai) {
|
|
55
|
+
border-color: var(--st-color-success);
|
|
56
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.inputBox.error {
|
|
60
|
+
border-color: var(--st-color-error);
|
|
61
|
+
box-shadow: 0 0 0 2px var(--st-color-error);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.inputBox.warning {
|
|
65
|
+
border-color: var(--st-color-warning);
|
|
66
|
+
box-shadow: 0 0 0 2px var(--st-color-warning);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.inputBox.success {
|
|
70
|
+
border-color: var(--st-color-success);
|
|
71
|
+
box-shadow: 0 0 0 2px var(--st-color-success);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.inputBox.ai {
|
|
75
|
+
border-color: var(--st-color-info);
|
|
76
|
+
box-shadow: 0 0 0 2px var(--st-color-info);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.inputBox.disabled {
|
|
80
|
+
opacity: 0.5;
|
|
81
|
+
pointer-events: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* ─── Input ─── */
|
|
85
|
+
.input {
|
|
86
|
+
flex: 1;
|
|
87
|
+
min-width: 0;
|
|
88
|
+
border: none;
|
|
89
|
+
outline: none;
|
|
90
|
+
background: transparent;
|
|
91
|
+
font-family: inherit;
|
|
92
|
+
font-size: var(--st-font-size-sm);
|
|
93
|
+
line-height: var(--st-line-height-normal);
|
|
94
|
+
color: var(--st-color-foreground);
|
|
95
|
+
padding: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.input::placeholder {
|
|
99
|
+
color: var(--st-color-muted);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.input_error {
|
|
103
|
+
color: var(--st-color-error);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.input_ai {
|
|
107
|
+
color: var(--st-color-info);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ─── Left / Right element ─── */
|
|
111
|
+
.leftElement,
|
|
112
|
+
.rightElement {
|
|
113
|
+
display: inline-flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
flex-shrink: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ─── Clear button ─── */
|
|
119
|
+
.clearBtn {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
width: 28px;
|
|
124
|
+
height: 28px;
|
|
125
|
+
border: none;
|
|
126
|
+
background: transparent;
|
|
127
|
+
border-radius: var(--st-radius-md);
|
|
128
|
+
color: var(--st-color-muted);
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
padding: 0;
|
|
131
|
+
flex-shrink: 0;
|
|
132
|
+
transition: background var(--st-transition-fast);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.clearBtn:hover {
|
|
136
|
+
background: var(--st-color-neutral-100);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* ─── Footer row ─── */
|
|
140
|
+
.footerRow {
|
|
141
|
+
display: flex;
|
|
142
|
+
justify-content: space-between;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* ─── Helper text ─── */
|
|
146
|
+
.helperText {
|
|
147
|
+
font-size: var(--st-font-size-xs);
|
|
148
|
+
line-height: var(--st-line-height-normal);
|
|
149
|
+
color: var(--st-color-muted);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* ─── Counter ─── */
|
|
153
|
+
.counter {
|
|
154
|
+
font-size: var(--st-font-size-xs);
|
|
155
|
+
line-height: var(--st-line-height-normal);
|
|
156
|
+
color: var(--st-color-muted);
|
|
157
|
+
margin-left: auto;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ─── Feedback text ─── */
|
|
161
|
+
.feedbackText {
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: var(--st-space-1);
|
|
165
|
+
font-size: var(--st-font-size-xs);
|
|
166
|
+
line-height: var(--st-line-height-normal);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.feedback_success {
|
|
170
|
+
color: var(--st-color-success);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.feedback_error {
|
|
174
|
+
color: var(--st-color-error);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.feedback_warning {
|
|
178
|
+
color: var(--st-color-warning);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.feedback_ai {
|
|
182
|
+
color: var(--st-color-info);
|
|
183
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { forwardRef, useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import type { InputTextProps } from './InputText.types';
|
|
4
|
+
import styles from './InputText.module.css';
|
|
5
|
+
|
|
6
|
+
function ClearIcon() {
|
|
7
|
+
return (
|
|
8
|
+
<svg
|
|
9
|
+
width="16"
|
|
10
|
+
height="16"
|
|
11
|
+
viewBox="0 0 16 16"
|
|
12
|
+
fill="none"
|
|
13
|
+
aria-hidden="true"
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
d="M4.5 4.5l7 7M11.5 4.5l-7 7"
|
|
17
|
+
stroke="currentColor"
|
|
18
|
+
strokeWidth="1.5"
|
|
19
|
+
strokeLinecap="round"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function FeedbackDot() {
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
width="8"
|
|
29
|
+
height="8"
|
|
30
|
+
viewBox="0 0 8 8"
|
|
31
|
+
fill="none"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
>
|
|
34
|
+
<circle cx="4" cy="4" r="4" fill="currentColor" />
|
|
35
|
+
</svg>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function FeedbackTriangle() {
|
|
40
|
+
return (
|
|
41
|
+
<svg
|
|
42
|
+
width="8"
|
|
43
|
+
height="8"
|
|
44
|
+
viewBox="0 0 8 8"
|
|
45
|
+
fill="none"
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
>
|
|
48
|
+
<path d="M4 0L8 8H0L4 0Z" fill="currentColor" />
|
|
49
|
+
</svg>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function FeedbackDiamond() {
|
|
54
|
+
return (
|
|
55
|
+
<svg
|
|
56
|
+
width="8"
|
|
57
|
+
height="8"
|
|
58
|
+
viewBox="0 0 8 8"
|
|
59
|
+
fill="none"
|
|
60
|
+
aria-hidden="true"
|
|
61
|
+
>
|
|
62
|
+
<path d="M4 0L8 4L4 8L0 4L4 0Z" fill="currentColor" />
|
|
63
|
+
</svg>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const feedbackIcons = {
|
|
68
|
+
success: FeedbackDot,
|
|
69
|
+
error: FeedbackDot,
|
|
70
|
+
warning: FeedbackTriangle,
|
|
71
|
+
ai: FeedbackDiamond,
|
|
72
|
+
} as const;
|
|
73
|
+
|
|
74
|
+
export const InputText = forwardRef<HTMLInputElement, InputTextProps>(
|
|
75
|
+
(
|
|
76
|
+
{
|
|
77
|
+
size = 'lg',
|
|
78
|
+
label,
|
|
79
|
+
description,
|
|
80
|
+
helperText,
|
|
81
|
+
feedback,
|
|
82
|
+
clearable = false,
|
|
83
|
+
onClear,
|
|
84
|
+
leftElement,
|
|
85
|
+
rightElement,
|
|
86
|
+
disabled,
|
|
87
|
+
required,
|
|
88
|
+
maxLength,
|
|
89
|
+
type,
|
|
90
|
+
value,
|
|
91
|
+
defaultValue,
|
|
92
|
+
onChange,
|
|
93
|
+
onFocus,
|
|
94
|
+
onBlur,
|
|
95
|
+
className,
|
|
96
|
+
...rest
|
|
97
|
+
},
|
|
98
|
+
ref,
|
|
99
|
+
) => {
|
|
100
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
101
|
+
const [focused, setFocused] = useState(false);
|
|
102
|
+
const [internalValue, setInternalValue] = useState(
|
|
103
|
+
() => (defaultValue as string) ?? '',
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const isControlled = value !== undefined;
|
|
107
|
+
const currentValue = isControlled ? String(value) : internalValue;
|
|
108
|
+
const hasValue = currentValue.length > 0;
|
|
109
|
+
|
|
110
|
+
// Merge forwarded ref with internal ref
|
|
111
|
+
const setRefs = useCallback(
|
|
112
|
+
(node: HTMLInputElement | null) => {
|
|
113
|
+
(inputRef as React.MutableRefObject<HTMLInputElement | null>).current =
|
|
114
|
+
node;
|
|
115
|
+
if (typeof ref === 'function') ref(node);
|
|
116
|
+
else if (ref)
|
|
117
|
+
(ref as React.MutableRefObject<HTMLInputElement | null>).current =
|
|
118
|
+
node;
|
|
119
|
+
},
|
|
120
|
+
[ref],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
124
|
+
if (!isControlled) setInternalValue(e.target.value);
|
|
125
|
+
onChange?.(e);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
129
|
+
setFocused(true);
|
|
130
|
+
onFocus?.(e);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
134
|
+
setFocused(false);
|
|
135
|
+
onBlur?.(e);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const handleClear = () => {
|
|
139
|
+
if (!isControlled) setInternalValue('');
|
|
140
|
+
onClear?.();
|
|
141
|
+
inputRef.current?.focus();
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const feedbackStatus = feedback?.status;
|
|
145
|
+
const showClear = clearable && hasValue && !disabled;
|
|
146
|
+
const showFooter = helperText || maxLength != null;
|
|
147
|
+
|
|
148
|
+
const inputBoxCls = cn(
|
|
149
|
+
styles.inputBox,
|
|
150
|
+
styles[size],
|
|
151
|
+
focused && styles.focused,
|
|
152
|
+
feedbackStatus && styles[feedbackStatus],
|
|
153
|
+
disabled && styles.disabled,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const inputCls = cn(
|
|
157
|
+
styles.input,
|
|
158
|
+
feedbackStatus === 'error' && styles.input_error,
|
|
159
|
+
feedbackStatus === 'ai' && styles.input_ai,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const FeedbackIcon = feedbackStatus
|
|
163
|
+
? feedbackIcons[feedbackStatus]
|
|
164
|
+
: null;
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className={cn(styles.root, className)}>
|
|
168
|
+
{label && (
|
|
169
|
+
<span className={styles.label}>
|
|
170
|
+
{label}
|
|
171
|
+
{required && <span className={styles.required}>*</span>}
|
|
172
|
+
</span>
|
|
173
|
+
)}
|
|
174
|
+
|
|
175
|
+
{description && (
|
|
176
|
+
<span className={styles.description}>{description}</span>
|
|
177
|
+
)}
|
|
178
|
+
|
|
179
|
+
<div className={inputBoxCls}>
|
|
180
|
+
{leftElement && (
|
|
181
|
+
<span className={styles.leftElement}>{leftElement}</span>
|
|
182
|
+
)}
|
|
183
|
+
|
|
184
|
+
<input
|
|
185
|
+
ref={setRefs}
|
|
186
|
+
className={inputCls}
|
|
187
|
+
type={type}
|
|
188
|
+
value={isControlled ? currentValue : undefined}
|
|
189
|
+
defaultValue={isControlled ? undefined : defaultValue}
|
|
190
|
+
onChange={handleChange}
|
|
191
|
+
onFocus={handleFocus}
|
|
192
|
+
onBlur={handleBlur}
|
|
193
|
+
disabled={disabled}
|
|
194
|
+
required={required}
|
|
195
|
+
maxLength={maxLength}
|
|
196
|
+
{...rest}
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
{rightElement && (
|
|
200
|
+
<span className={styles.rightElement}>{rightElement}</span>
|
|
201
|
+
)}
|
|
202
|
+
|
|
203
|
+
{showClear && (
|
|
204
|
+
<button
|
|
205
|
+
type="button"
|
|
206
|
+
className={styles.clearBtn}
|
|
207
|
+
onClick={handleClear}
|
|
208
|
+
aria-label="Clear input"
|
|
209
|
+
>
|
|
210
|
+
<ClearIcon />
|
|
211
|
+
</button>
|
|
212
|
+
)}
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
{showFooter && (
|
|
216
|
+
<div className={styles.footerRow}>
|
|
217
|
+
{helperText && (
|
|
218
|
+
<span className={styles.helperText}>{helperText}</span>
|
|
219
|
+
)}
|
|
220
|
+
{maxLength != null && (
|
|
221
|
+
<span className={styles.counter}>
|
|
222
|
+
{currentValue.length}/{maxLength}
|
|
223
|
+
</span>
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
)}
|
|
227
|
+
|
|
228
|
+
{feedback && (
|
|
229
|
+
<span
|
|
230
|
+
className={cn(
|
|
231
|
+
styles.feedbackText,
|
|
232
|
+
styles[`feedback_${feedbackStatus}`],
|
|
233
|
+
)}
|
|
234
|
+
>
|
|
235
|
+
{FeedbackIcon && <FeedbackIcon />}
|
|
236
|
+
{feedback.message}
|
|
237
|
+
</span>
|
|
238
|
+
)}
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
InputText.displayName = 'InputText';
|