@intlayer/design-system 6.1.5 → 6.1.6-canary.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/.vite/manifest.json +13 -9
- package/dist/Form-CriPBaZk.js.map +1 -1
- package/dist/Form-DJrUK3mm.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.cjs +51 -15
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.d.ts +44 -5
- package/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion/Accordion.mjs +52 -16
- package/dist/components/Accordion/Accordion.mjs.map +1 -1
- package/dist/components/Avatar/index.cjs +114 -31
- package/dist/components/Avatar/index.cjs.map +1 -1
- package/dist/components/Avatar/index.d.ts +46 -2
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.mjs +115 -32
- package/dist/components/Avatar/index.mjs.map +1 -1
- package/dist/components/Badge/index.cjs +88 -9
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.ts +80 -2
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.mjs +89 -10
- package/dist/components/Badge/index.mjs.map +1 -1
- package/dist/components/Breadcrumb/index.cjs +124 -59
- package/dist/components/Breadcrumb/index.cjs.map +1 -1
- package/dist/components/Breadcrumb/index.d.ts +89 -5
- package/dist/components/Breadcrumb/index.d.ts.map +1 -1
- package/dist/components/Breadcrumb/index.mjs +124 -59
- package/dist/components/Breadcrumb/index.mjs.map +1 -1
- package/dist/components/Button/Button.cjs +44 -25
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.d.ts +95 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/Button.mjs +44 -25
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/ClickOutsideDiv/index.cjs +38 -7
- package/dist/components/ClickOutsideDiv/index.cjs.map +1 -1
- package/dist/components/ClickOutsideDiv/index.d.ts +13 -0
- package/dist/components/ClickOutsideDiv/index.d.ts.map +1 -1
- package/dist/components/ClickOutsideDiv/index.mjs +39 -8
- package/dist/components/ClickOutsideDiv/index.mjs.map +1 -1
- package/dist/components/Container/index.cjs +2 -0
- package/dist/components/Container/index.cjs.map +1 -1
- package/dist/components/Container/index.d.ts +42 -0
- package/dist/components/Container/index.d.ts.map +1 -1
- package/dist/components/Container/index.mjs +2 -0
- package/dist/components/Container/index.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.cjs +80 -33
- package/dist/components/ContentEditor/ContentEditor.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.d.ts +29 -0
- package/dist/components/ContentEditor/ContentEditor.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditor.mjs +80 -33
- package/dist/components/ContentEditor/ContentEditor.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.cjs +58 -31
- package/dist/components/ContentEditor/ContentEditorInput.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.d.ts +33 -0
- package/dist/components/ContentEditor/ContentEditorInput.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditorInput.mjs +58 -31
- package/dist/components/ContentEditor/ContentEditorInput.mjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs +58 -30
- package/dist/components/ContentEditor/ContentEditorTextArea.cjs.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts +35 -0
- package/dist/components/ContentEditor/ContentEditorTextArea.d.ts.map +1 -1
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs +59 -31
- package/dist/components/ContentEditor/ContentEditorTextArea.mjs.map +1 -1
- package/dist/components/ContentEditor/index.cjs +4 -0
- package/dist/components/ContentEditor/index.cjs.map +1 -1
- package/dist/components/ContentEditor/index.d.ts +2 -0
- package/dist/components/ContentEditor/index.d.ts.map +1 -1
- package/dist/components/ContentEditor/index.mjs +5 -1
- package/dist/components/ContentEditor/index.mjs.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.cjs +9 -1
- package/dist/components/ContentSelector/ContentSelector.cjs.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.d.ts +167 -0
- package/dist/components/ContentSelector/ContentSelector.d.ts.map +1 -1
- package/dist/components/ContentSelector/ContentSelector.mjs +9 -1
- package/dist/components/ContentSelector/ContentSelector.mjs.map +1 -1
- package/dist/components/CopyButton/index.cjs +23 -8
- package/dist/components/CopyButton/index.cjs.map +1 -1
- package/dist/components/CopyButton/index.d.ts +78 -0
- package/dist/components/CopyButton/index.d.ts.map +1 -1
- package/dist/components/CopyButton/index.mjs +23 -8
- package/dist/components/CopyButton/index.mjs.map +1 -1
- package/dist/components/CopyToClipboard/index.cjs +58 -22
- package/dist/components/CopyToClipboard/index.cjs.map +1 -1
- package/dist/components/CopyToClipboard/index.d.ts +68 -2
- package/dist/components/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/components/CopyToClipboard/index.mjs +59 -23
- package/dist/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/components/DropDown/index.cjs +6 -4
- package/dist/components/DropDown/index.cjs.map +1 -1
- package/dist/components/DropDown/index.d.ts +92 -15
- package/dist/components/DropDown/index.d.ts.map +1 -1
- package/dist/components/DropDown/index.mjs +6 -4
- package/dist/components/DropDown/index.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.d.ts +38 -0
- package/dist/components/EditableField/EditableFieldInput.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldInput.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.cjs +10 -2
- package/dist/components/EditableField/EditableFieldLayout.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldLayout.mjs +10 -2
- package/dist/components/EditableField/EditableFieldLayout.mjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.cjs.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.d.ts +42 -0
- package/dist/components/EditableField/EditableFieldTextArea.d.ts.map +1 -1
- package/dist/components/EditableField/EditableFieldTextArea.mjs.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.cjs.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.d.ts +58 -0
- package/dist/components/ExpandCollapse/ExpandCollapse.d.ts.map +1 -1
- package/dist/components/ExpandCollapse/ExpandCollapse.mjs.map +1 -1
- package/dist/components/Footer/index.cjs.map +1 -1
- package/dist/components/Footer/index.d.ts +101 -0
- package/dist/components/Footer/index.d.ts.map +1 -1
- package/dist/components/Footer/index.mjs.map +1 -1
- package/dist/components/Form/elements/MultiselectElement.d.ts.map +1 -1
- package/dist/components/Form/elements/SelectElement.d.ts.map +1 -1
- package/dist/components/Form/elements/SwitchSelectorElement.d.ts.map +1 -1
- package/dist/components/Headers/index.cjs.map +1 -1
- package/dist/components/Headers/index.d.ts +69 -2
- package/dist/components/Headers/index.d.ts.map +1 -1
- package/dist/components/Headers/index.mjs.map +1 -1
- package/dist/components/HeightResizer/index.cjs +10 -7
- package/dist/components/HeightResizer/index.cjs.map +1 -1
- package/dist/components/HeightResizer/index.d.ts +89 -0
- package/dist/components/HeightResizer/index.d.ts.map +1 -1
- package/dist/components/HeightResizer/index.mjs +10 -7
- package/dist/components/HeightResizer/index.mjs.map +1 -1
- package/dist/components/InformationTag/index.cjs.map +1 -1
- package/dist/components/InformationTag/index.d.ts +72 -0
- package/dist/components/InformationTag/index.d.ts.map +1 -1
- package/dist/components/InformationTag/index.mjs.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.cjs.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.d.ts +100 -0
- package/dist/components/KeyboardScreenAdapter/index.d.ts.map +1 -1
- package/dist/components/KeyboardScreenAdapter/index.mjs.map +1 -1
- package/dist/components/Label/index.cjs +25 -3
- package/dist/components/Label/index.cjs.map +1 -1
- package/dist/components/Label/index.d.ts +65 -1
- package/dist/components/Label/index.d.ts.map +1 -1
- package/dist/components/Label/index.mjs +26 -4
- package/dist/components/Label/index.mjs.map +1 -1
- package/dist/components/Link/Link.cjs.map +1 -1
- package/dist/components/Link/Link.d.ts +169 -0
- package/dist/components/Link/Link.d.ts.map +1 -1
- package/dist/components/Link/Link.mjs.map +1 -1
- package/dist/components/Loader/index.cjs.map +1 -1
- package/dist/components/Loader/index.d.ts +82 -11
- package/dist/components/Loader/index.d.ts.map +1 -1
- package/dist/components/Loader/index.mjs.map +1 -1
- package/dist/components/Loader/spinner.cjs.map +1 -1
- package/dist/components/Loader/spinner.d.ts +56 -0
- package/dist/components/Loader/spinner.d.ts.map +1 -1
- package/dist/components/Loader/spinner.mjs.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.cjs +0 -1
- package/dist/components/MarkDownRender/MarkDownRender.cjs.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.d.ts +147 -0
- package/dist/components/MarkDownRender/MarkDownRender.d.ts.map +1 -1
- package/dist/components/MarkDownRender/MarkDownRender.mjs +0 -1
- package/dist/components/MarkDownRender/MarkDownRender.mjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.cjs.map +1 -1
- package/dist/components/MaxHeightSmoother/index.d.ts +152 -0
- package/dist/components/MaxHeightSmoother/index.d.ts.map +1 -1
- package/dist/components/MaxHeightSmoother/index.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +5 -0
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.d.ts +81 -3
- package/dist/components/Modal/Modal.d.ts.map +1 -1
- package/dist/components/Modal/Modal.mjs +5 -0
- package/dist/components/Modal/Modal.mjs.map +1 -1
- package/dist/components/Navbar/Burger.cjs.map +1 -1
- package/dist/components/Navbar/Burger.d.ts +54 -0
- package/dist/components/Navbar/Burger.d.ts.map +1 -1
- package/dist/components/Navbar/Burger.mjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.cjs.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.d.ts +78 -0
- package/dist/components/Navbar/DesktopNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/DesktopNavbar.mjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.cjs.map +1 -1
- package/dist/components/Navbar/MobileNavbar.d.ts +88 -0
- package/dist/components/Navbar/MobileNavbar.d.ts.map +1 -1
- package/dist/components/Navbar/MobileNavbar.mjs.map +1 -1
- package/dist/components/Navbar/index.cjs.map +1 -1
- package/dist/components/Navbar/index.d.ts +69 -0
- package/dist/components/Navbar/index.d.ts.map +1 -1
- package/dist/components/Navbar/index.mjs.map +1 -1
- package/dist/components/Navbar/useNavigation.cjs +8 -1
- package/dist/components/Navbar/useNavigation.cjs.map +1 -1
- package/dist/components/Navbar/useNavigation.d.ts +83 -0
- package/dist/components/Navbar/useNavigation.d.ts.map +1 -1
- package/dist/components/Navbar/useNavigation.mjs +8 -1
- package/dist/components/Navbar/useNavigation.mjs.map +1 -1
- package/dist/components/Pattern/DotPattern.cjs.map +1 -1
- package/dist/components/Pattern/DotPattern.d.ts +101 -0
- package/dist/components/Pattern/DotPattern.d.ts.map +1 -1
- package/dist/components/Pattern/DotPattern.mjs.map +1 -1
- package/dist/components/Pattern/GridPattern.cjs.map +1 -1
- package/dist/components/Pattern/GridPattern.d.ts +114 -0
- package/dist/components/Pattern/GridPattern.d.ts.map +1 -1
- package/dist/components/Pattern/GridPattern.mjs.map +1 -1
- package/dist/components/Pattern/SpotLight.cjs.map +1 -1
- package/dist/components/Pattern/SpotLight.d.ts +125 -0
- package/dist/components/Pattern/SpotLight.d.ts.map +1 -1
- package/dist/components/Pattern/SpotLight.mjs.map +1 -1
- package/dist/components/Popover/index.cjs +10 -10
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.ts +110 -15
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.mjs +10 -10
- package/dist/components/Popover/index.mjs.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.cjs +22 -5
- package/dist/components/PressableSpan/PressableSpan.cjs.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.d.ts +105 -3
- package/dist/components/PressableSpan/PressableSpan.d.ts.map +1 -1
- package/dist/components/PressableSpan/PressableSpan.mjs +22 -5
- package/dist/components/PressableSpan/PressableSpan.mjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.d.ts +182 -0
- package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
- package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.cjs.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.d.ts +44 -0
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.d.ts.map +1 -1
- package/dist/components/RightDrawer/isElementAtTopAndNotCovered.mjs.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.cjs.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.d.ts +102 -0
- package/dist/components/RightDrawer/useRightDrawerStore.d.ts.map +1 -1
- package/dist/components/RightDrawer/useRightDrawerStore.mjs.map +1 -1
- package/dist/components/Select/Multiselect.cjs.map +1 -1
- package/dist/components/Select/Multiselect.d.ts +125 -18
- package/dist/components/Select/Multiselect.d.ts.map +1 -1
- package/dist/components/Select/Multiselect.mjs.map +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.d.ts +214 -7
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.mjs.map +1 -1
- package/dist/components/SwitchSelector/index.cjs.map +1 -1
- package/dist/components/SwitchSelector/index.d.ts +157 -8
- package/dist/components/SwitchSelector/index.d.ts.map +1 -1
- package/dist/components/SwitchSelector/index.mjs.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.d.ts +184 -0
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/Table/Table.mjs.map +1 -1
- package/dist/components/Tag/index.cjs.map +1 -1
- package/dist/components/Tag/index.d.ts +223 -0
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.mjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.cjs.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.d.ts +91 -0
- package/dist/components/TextArea/AutoSizeTextArea.d.ts.map +1 -1
- package/dist/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.cjs.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.d.ts +145 -0
- package/dist/components/TextArea/AutocompleteTextArea.d.ts.map +1 -1
- package/dist/components/TextArea/AutocompleteTextArea.mjs.map +1 -1
- package/dist/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/TextArea/TextArea.d.ts +74 -0
- package/dist/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/components/Toaster/Toast.cjs +4 -0
- package/dist/components/Toaster/Toast.cjs.map +1 -1
- package/dist/components/Toaster/Toast.d.ts +148 -2
- package/dist/components/Toaster/Toast.d.ts.map +1 -1
- package/dist/components/Toaster/Toast.mjs +4 -0
- package/dist/components/Toaster/Toast.mjs.map +1 -1
- package/dist/components/Toaster/Toaster.cjs.map +1 -1
- package/dist/components/Toaster/Toaster.d.ts +42 -0
- package/dist/components/Toaster/Toaster.d.ts.map +1 -1
- package/dist/components/Toaster/Toaster.mjs.map +1 -1
- package/dist/components/Toaster/useToast.cjs.map +1 -1
- package/dist/components/Toaster/useToast.d.ts +199 -2
- package/dist/components/Toaster/useToast.d.ts.map +1 -1
- package/dist/components/Toaster/useToast.mjs.map +1 -1
- package/dist/components/WithResizer/index.cjs.map +1 -1
- package/dist/components/WithResizer/index.d.ts +143 -0
- package/dist/components/WithResizer/index.d.ts.map +1 -1
- package/dist/components/WithResizer/index.mjs.map +1 -1
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/components/index.mjs.map +1 -1
- package/dist/hooks/reactQuery.cjs +2 -1
- package/dist/hooks/reactQuery.cjs.map +1 -1
- package/dist/hooks/reactQuery.d.ts +1 -1
- package/dist/hooks/reactQuery.d.ts.map +1 -1
- package/dist/hooks/reactQuery.mjs +2 -1
- package/dist/hooks/reactQuery.mjs.map +1 -1
- package/dist/utils/image.cjs +30 -0
- package/dist/utils/image.cjs.map +1 -0
- package/dist/utils/image.d.ts +37 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/image.mjs +30 -0
- package/dist/utils/image.mjs.map +1 -0
- package/package.json +20 -18
- package/dist/utils/capitalize.cjs +0 -10
- package/dist/utils/capitalize.cjs.map +0 -1
- package/dist/utils/capitalize.d.ts +0 -2
- package/dist/utils/capitalize.d.ts.map +0 -1
- package/dist/utils/capitalize.mjs +0 -10
- package/dist/utils/capitalize.mjs.map +0 -1
|
@@ -1,46 +1,253 @@
|
|
|
1
1
|
import { ComponentProps, FC } from 'react';
|
|
2
2
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
3
|
+
/**
|
|
4
|
+
* Enum for Select content positioning strategies
|
|
5
|
+
*
|
|
6
|
+
* @enum SelectContentPosition
|
|
7
|
+
*/
|
|
3
8
|
export declare enum SelectContentPosition {
|
|
9
|
+
/** Position relative to the trigger with automatic placement */
|
|
4
10
|
POPPER = "popper",
|
|
11
|
+
/** Align content with the selected item */
|
|
5
12
|
ITEM_ALIGNED = "item-aligned"
|
|
6
13
|
}
|
|
7
14
|
declare const SelectRoot: FC<SelectPrimitive.SelectProps>;
|
|
8
15
|
declare const SelectGroup: import('react').ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
9
16
|
declare const SelectValue: import('react').ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & import('react').RefAttributes<HTMLSpanElement>>;
|
|
17
|
+
/**
|
|
18
|
+
* Select trigger button component that displays the current selection and opens the dropdown
|
|
19
|
+
*
|
|
20
|
+
* Features comprehensive styling with validation states, focus management, and accessibility support.
|
|
21
|
+
* Uses design tokens for consistent theming across the application.
|
|
22
|
+
*
|
|
23
|
+
* @param validationStyleEnabled - Enables automatic success/error styling based on form validation state
|
|
24
|
+
* @param className - Additional CSS classes for custom styling
|
|
25
|
+
* @param children - Content to display inside the trigger (typically SelectValue)
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Select.Trigger validationStyleEnabled>
|
|
30
|
+
* <Select.Value placeholder="Choose option..." />
|
|
31
|
+
* </Select.Trigger>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
10
34
|
declare const SelectTrigger: FC<ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
35
|
+
/**
|
|
36
|
+
* Enables success/error border styling based on HTML5 validation state
|
|
37
|
+
* @default false
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <Select.Trigger validationStyleEnabled>
|
|
41
|
+
* <Select.Value placeholder="Required field" />
|
|
42
|
+
* </Select.Trigger>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
11
45
|
validationStyleEnabled?: boolean;
|
|
12
46
|
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Scroll up button for select content with long lists
|
|
49
|
+
*
|
|
50
|
+
* Automatically appears when content is scrollable upward, providing intuitive navigation
|
|
51
|
+
* for users with large option lists.
|
|
52
|
+
*
|
|
53
|
+
* @param className - Additional CSS classes for custom styling
|
|
54
|
+
*/
|
|
13
55
|
declare const SelectScrollUpButton: FC<ComponentProps<typeof SelectPrimitive.ScrollUpButton>>;
|
|
56
|
+
/**
|
|
57
|
+
* Scroll down button for select content with long lists
|
|
58
|
+
*
|
|
59
|
+
* Automatically appears when content is scrollable downward, providing clear visual
|
|
60
|
+
* indication of additional options below the current view.
|
|
61
|
+
*
|
|
62
|
+
* @param className - Additional CSS classes for custom styling
|
|
63
|
+
*/
|
|
14
64
|
declare const SelectScrollDownButton: FC<ComponentProps<typeof SelectPrimitive.ScrollDownButton>>;
|
|
65
|
+
/**
|
|
66
|
+
* Select dropdown content container with positioning and animation
|
|
67
|
+
*
|
|
68
|
+
* Provides the dropdown interface containing all selectable options. Features smooth
|
|
69
|
+
* animations, flexible positioning strategies, and responsive design for optimal UX.
|
|
70
|
+
*
|
|
71
|
+
* @param position - Positioning strategy for the dropdown content
|
|
72
|
+
* @param className - Additional CSS classes for custom styling
|
|
73
|
+
* @param children - Select items, labels, and separators
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <Select.Content position={SelectContentPosition.POPPER}>
|
|
78
|
+
* <Select.Item value="option1">Option 1</Select.Item>
|
|
79
|
+
* <Select.Item value="option2">Option 2</Select.Item>
|
|
80
|
+
* </Select.Content>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
15
83
|
export declare const SelectContent: FC<ComponentProps<typeof SelectPrimitive.Content>>;
|
|
84
|
+
/**
|
|
85
|
+
* Label component for grouping select options
|
|
86
|
+
*
|
|
87
|
+
* Provides semantic grouping and visual organization of related options within
|
|
88
|
+
* the select dropdown. Enhances accessibility and user experience.
|
|
89
|
+
*
|
|
90
|
+
* @param className - Additional CSS classes for custom styling
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* <Select.Content>
|
|
95
|
+
* <Select.Label>Fruits</Select.Label>
|
|
96
|
+
* <Select.Item value="apple">Apple</Select.Item>
|
|
97
|
+
* <Select.Item value="banana">Banana</Select.Item>
|
|
98
|
+
* <Select.Separator />
|
|
99
|
+
* <Select.Label>Vegetables</Select.Label>
|
|
100
|
+
* <Select.Item value="carrot">Carrot</Select.Item>
|
|
101
|
+
* </Select.Content>
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
16
104
|
export declare const SelectLabel: FC<ComponentProps<typeof SelectPrimitive.Label>>;
|
|
105
|
+
/**
|
|
106
|
+
* Individual selectable item within the dropdown
|
|
107
|
+
*
|
|
108
|
+
* Represents a single option that users can select. Features hover states,
|
|
109
|
+
* selection indicators, and keyboard navigation support for accessible interaction.
|
|
110
|
+
*
|
|
111
|
+
* @param className - Additional CSS classes for custom styling
|
|
112
|
+
* @param children - The display text/content for the option
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* <Select.Item value="dark-mode">
|
|
117
|
+
* 🌙 Dark Mode
|
|
118
|
+
* </Select.Item>
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
17
121
|
declare const SelectItem: FC<ComponentProps<typeof SelectPrimitive.Item>>;
|
|
122
|
+
/**
|
|
123
|
+
* Visual separator for grouping options in the dropdown
|
|
124
|
+
*
|
|
125
|
+
* Creates clear visual division between groups of related options,
|
|
126
|
+
* improving readability and organization in complex select menus.
|
|
127
|
+
*
|
|
128
|
+
* @param className - Additional CSS classes for custom styling
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```tsx
|
|
132
|
+
* <Select.Content>
|
|
133
|
+
* <Select.Item value="recent">Recent Files</Select.Item>
|
|
134
|
+
* <Select.Separator />
|
|
135
|
+
* <Select.Item value="all">All Files</Select.Item>
|
|
136
|
+
* </Select.Content>
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
18
139
|
export declare const SelectSeparator: FC<ComponentProps<typeof SelectPrimitive.Separator>>;
|
|
140
|
+
/**
|
|
141
|
+
* Type definition for the compound Select component with all subcomponents
|
|
142
|
+
*/
|
|
19
143
|
type SelectType = typeof SelectRoot & {
|
|
144
|
+
/** Group container for organizing related options */
|
|
20
145
|
Group: typeof SelectGroup;
|
|
146
|
+
/** Value display component for the trigger */
|
|
21
147
|
Value: typeof SelectValue;
|
|
148
|
+
/** Trigger button that opens the dropdown */
|
|
22
149
|
Trigger: typeof SelectTrigger;
|
|
150
|
+
/** Scroll up button for long lists */
|
|
23
151
|
ScrollUpButton: typeof SelectScrollUpButton;
|
|
152
|
+
/** Scroll down button for long lists */
|
|
24
153
|
ScrollDownButton: typeof SelectScrollDownButton;
|
|
154
|
+
/** Dropdown content container */
|
|
25
155
|
Content: typeof SelectContent;
|
|
156
|
+
/** Label component for option groups */
|
|
26
157
|
Label: typeof SelectLabel;
|
|
158
|
+
/** Individual selectable item */
|
|
27
159
|
Item: typeof SelectItem;
|
|
160
|
+
/** Visual separator between option groups */
|
|
28
161
|
Separator: typeof SelectSeparator;
|
|
29
162
|
};
|
|
30
163
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
164
|
+
* Select - A comprehensive dropdown selection component
|
|
165
|
+
*
|
|
166
|
+
* A fully-featured select component built on Radix UI primitives with extensive customization,
|
|
167
|
+
* accessibility features, and design system integration. Supports single selection with
|
|
168
|
+
* keyboard navigation, validation states, and flexible content positioning.
|
|
169
|
+
*
|
|
170
|
+
* ## Key Features
|
|
171
|
+
* - **Accessibility First**: Full keyboard navigation, screen reader support, and ARIA attributes
|
|
172
|
+
* - **Flexible Positioning**: Multiple positioning strategies for optimal dropdown placement
|
|
173
|
+
* - **Validation Integration**: Built-in support for form validation with visual feedback
|
|
174
|
+
* - **Design System**: Consistent theming with design tokens and style variants
|
|
175
|
+
* - **Responsive Design**: Works seamlessly across desktop and mobile devices
|
|
176
|
+
* - **Rich Content**: Support for icons, separators, labels, and complex option layouts
|
|
177
|
+
*
|
|
178
|
+
* ## Use Cases
|
|
179
|
+
* - Form field selections (theme, language, category)
|
|
180
|
+
* - Settings and configuration options
|
|
181
|
+
* - Filter and sort controls
|
|
182
|
+
* - User preference selections
|
|
183
|
+
* - Any single-choice dropdown interface
|
|
184
|
+
*
|
|
185
|
+
* ## Accessibility
|
|
186
|
+
* - **Keyboard Navigation**: Arrow keys, Enter, Escape, and Home/End support
|
|
187
|
+
* - **Screen Readers**: Proper ARIA labels and state announcements
|
|
188
|
+
* - **Focus Management**: Intuitive focus flow and visual indicators
|
|
189
|
+
* - **High Contrast**: Supports system high contrast modes
|
|
190
|
+
*
|
|
191
|
+
* ## Architecture
|
|
192
|
+
* The Select component follows a compound component pattern with the following structure:
|
|
193
|
+
* - `Select` (root): Manages state and provides context
|
|
194
|
+
* - `Select.Trigger`: Button that displays current value and opens dropdown
|
|
195
|
+
* - `Select.Value`: Displays the selected value with placeholder support
|
|
196
|
+
* - `Select.Content`: Container for the dropdown options
|
|
197
|
+
* - `Select.Item`: Individual selectable options
|
|
198
|
+
* - `Select.Label`: Group labels for organizing options
|
|
199
|
+
* - `Select.Separator`: Visual dividers between option groups
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* Basic usage with simple options:
|
|
203
|
+
* ```tsx
|
|
204
|
+
* <Select defaultValue="system">
|
|
34
205
|
* <Select.Trigger>
|
|
35
|
-
* <Select.Value placeholder="
|
|
206
|
+
* <Select.Value placeholder="Choose theme..." />
|
|
36
207
|
* </Select.Trigger>
|
|
37
208
|
* <Select.Content>
|
|
38
|
-
* <Select.Item value="light"
|
|
39
|
-
* <Select.Item value="dark"
|
|
40
|
-
* <Select.Item value="system"
|
|
209
|
+
* <Select.Item value="light">☀️ Light</Select.Item>
|
|
210
|
+
* <Select.Item value="dark">🌙 Dark</Select.Item>
|
|
211
|
+
* <Select.Item value="system">⚙️ System</Select.Item>
|
|
41
212
|
* </Select.Content>
|
|
42
213
|
* </Select>
|
|
43
214
|
* ```
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* Advanced usage with groups and labels:
|
|
218
|
+
* ```tsx
|
|
219
|
+
* <Select>
|
|
220
|
+
* <Select.Trigger validationStyleEnabled>
|
|
221
|
+
* <Select.Value placeholder="Select category..." />
|
|
222
|
+
* </Select.Trigger>
|
|
223
|
+
* <Select.Content>
|
|
224
|
+
* <Select.Label>Web Technologies</Select.Label>
|
|
225
|
+
* <Select.Item value="react">React</Select.Item>
|
|
226
|
+
* <Select.Item value="vue">Vue</Select.Item>
|
|
227
|
+
* <Select.Separator />
|
|
228
|
+
* <Select.Label>Mobile</Select.Label>
|
|
229
|
+
* <Select.Item value="react-native">React Native</Select.Item>
|
|
230
|
+
* <Select.Item value="flutter">Flutter</Select.Item>
|
|
231
|
+
* </Select.Content>
|
|
232
|
+
* </Select>
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* Form integration with validation:
|
|
237
|
+
* ```tsx
|
|
238
|
+
* <form>
|
|
239
|
+
* <Select required name="country">
|
|
240
|
+
* <Select.Trigger validationStyleEnabled aria-invalid={hasError}>
|
|
241
|
+
* <Select.Value placeholder="Select country..." />
|
|
242
|
+
* </Select.Trigger>
|
|
243
|
+
* <Select.Content position={SelectContentPosition.ITEM_ALIGNED}>
|
|
244
|
+
* <Select.Item value="us">United States</Select.Item>
|
|
245
|
+
* <Select.Item value="ca">Canada</Select.Item>
|
|
246
|
+
* <Select.Item value="uk">United Kingdom</Select.Item>
|
|
247
|
+
* </Select.Content>
|
|
248
|
+
* </Select>
|
|
249
|
+
* </form>
|
|
250
|
+
* ```
|
|
44
251
|
*/
|
|
45
252
|
export declare const Select: SelectType;
|
|
46
253
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAO1D,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGrD,oBAAY,qBAAqB;IAC/B,MAAM,WAAW;IACjB,YAAY,iBAAiB;CAC9B;AAED,QAAA,MAAM,UAAU,iCAAuB,CAAC;AACxC,QAAA,MAAM,WAAW,6HAAwB,CAAC;AAC1C,QAAA,MAAM,WAAW,8HAAwB,CAAC;AAE1C,QAAA,MAAM,aAAa,EAAE,E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AAO,eAAe,CAAC,SAAS,CAAC,CAMjD,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,OAAO,UAAU,GAAG;IACpC,qDAAqD;IACrD,KAAK,EAAE,OAAO,WAAW,CAAC;IAC1B,8CAA8C;IAC9C,KAAK,EAAE,OAAO,WAAW,CAAC;IAC1B,6CAA6C;IAC7C,OAAO,EAAE,OAAO,aAAa,CAAC;IAC9B,sCAAsC;IACtC,cAAc,EAAE,OAAO,oBAAoB,CAAC;IAC5C,wCAAwC;IACxC,gBAAgB,EAAE,OAAO,sBAAsB,CAAC;IAChD,iCAAiC;IACjC,OAAO,EAAE,OAAO,aAAa,CAAC;IAC9B,wCAAwC;IACxC,KAAK,EAAE,OAAO,WAAW,CAAC;IAC1B,iCAAiC;IACjC,IAAI,EAAE,OAAO,UAAU,CAAC;IACxB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,eAAO,MAAM,MAAM,EAAiB,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.mjs","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport {\n CheckIcon,\n ChevronDownIcon,\n ChevronsUpDown,\n ChevronUpIcon,\n} from 'lucide-react';\nimport { type ComponentProps, type FC } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport enum SelectContentPosition {\n POPPER = 'popper',\n ITEM_ALIGNED = 'item-aligned',\n}\n\nconst SelectRoot = SelectPrimitive.Root;\nconst SelectGroup = SelectPrimitive.Group;\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger: FC<\n ComponentProps<typeof SelectPrimitive.Trigger> & {\n validationStyleEnabled?: boolean;\n }\n> = ({ validationStyleEnabled = false, className, children, ...props }) => (\n <SelectPrimitive.Trigger\n className={cn(\n 'border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring focus:outline-hidden flex w-full items-center justify-between whitespace-nowrap rounded-md border px-3 py-2 text-sm focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'bg-input-background text-input-text w-full select-text resize-none rounded-xl border-2 px-2 py-1 text-sm shadow-none outline-0 transition-all',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none]',\n 'aria-[invalid=true]:border-error',\n validationStyleEnabled && 'valid:border-success invalid:border-error',\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronsUpDown className=\"size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n);\n\nconst SelectScrollUpButton: FC<\n ComponentProps<typeof SelectPrimitive.ScrollUpButton>\n> = ({ className, ...props }) => (\n <SelectPrimitive.ScrollUpButton\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpButton>\n);\n\nconst SelectScrollDownButton: FC<\n ComponentProps<typeof SelectPrimitive.ScrollDownButton>\n> = ({ className, ...props }) => (\n <SelectPrimitive.ScrollDownButton\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownButton>\n);\n\nexport const SelectContent: FC<\n ComponentProps<typeof SelectPrimitive.Content>\n> = ({\n className,\n children,\n position = SelectContentPosition.POPPER,\n ...props\n}) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n className={cn(\n 'bg-input-background text-input-text w-full select-text resize-none rounded-xl border-2 p-1 text-sm shadow-none outline-0 transition-all',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden border shadow-md',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n);\n\nexport const SelectLabel: FC<ComponentProps<typeof SelectPrimitive.Label>> = ({\n className,\n ...props\n}) => (\n <SelectPrimitive.Label\n className={cn('px-1 py-0.5 text-sm font-semibold', className)}\n {...props}\n />\n);\n\nconst SelectItem: FC<ComponentProps<typeof SelectPrimitive.Item>> = ({\n className,\n children,\n ...props\n}) => (\n <SelectPrimitive.Item\n className={cn(\n 'focus:bg-neutral/10 outline-hidden relative flex w-full cursor-pointer select-none items-center rounded-lg py-1.5 pl-2 pr-8 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n);\n\nexport const SelectSeparator: FC<\n ComponentProps<typeof SelectPrimitive.Separator>\n> = ({ className, ...props }) => (\n <SelectPrimitive.Separator\n className={cn('-mx-1 my-1 h-px bg-red-300', className)}\n {...props}\n />\n);\n\ntype SelectType = typeof SelectRoot & {\n Group: typeof SelectGroup;\n Value: typeof SelectValue;\n Trigger: typeof SelectTrigger;\n ScrollUpButton: typeof SelectScrollUpButton;\n ScrollDownButton: typeof SelectScrollDownButton;\n Content: typeof SelectContent;\n Label: typeof SelectLabel;\n Item: typeof SelectItem;\n Separator: typeof SelectSeparator;\n};\n\n/**\n * Usage example:\n * ```jsx\n * <Select>\n * <Select.Trigger>\n * <Select.Value placeholder=\"Theme\" />\n * </Select.Trigger>\n * <Select.Content>\n * <Select.Item value=\"light\">Light</Select.Item>\n * <Select.Item value=\"dark\">Dark</Select.Item>\n * <Select.Item value=\"system\">System</Select.Item>\n * </Select.Content>\n * </Select>\n * ```\n */\nexport const Select = SelectRoot as SelectType;\nSelect.Group = SelectGroup;\nSelect.Value = SelectValue;\nSelect.Trigger = SelectTrigger;\nSelect.ScrollUpButton = SelectScrollUpButton;\nSelect.ScrollDownButton = SelectScrollDownButton;\nSelect.Content = SelectContent;\nSelect.Label = SelectLabel;\nSelect.Item = SelectItem;\nSelect.Separator = SelectSeparator;\n"],"names":["SelectContentPosition"],"mappings":";;;;;AAYO,IAAK,0CAAAA,2BAAL;AACLA,yBAAA,QAAA,IAAS;AACTA,yBAAA,cAAA,IAAe;AAFL,SAAAA;AAAA,GAAA,yBAAA,CAAA,CAAA;AAKZ,MAAM,aAAa,gBAAgB;AACnC,MAAM,cAAc,gBAAgB;AACpC,MAAM,cAAc,gBAAgB;AAEpC,MAAM,gBAIF,CAAC,EAAE,yBAAyB,OAAO,WAAW,UAAU,GAAG,MAAA,MAC7D;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,0BAA0B;AAAA,MAC1B;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEH,UAAA;AAAA,MAAA;AAAA,MACD,oBAAC,gBAAgB,MAAhB,EAAqB,SAAO,MAC3B,UAAA,oBAAC,gBAAA,EAAe,WAAU,oBAAA,CAAoB,EAA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ACL,MACE;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEJ,UAAA;AAAA,MAAA,oBAAC,QAAA,EAAK,WAAU,8DACd,UAAA,oBAAC,gBAAgB,eAAhB,EACC,UAAA,oBAAC,WAAA,EAAU,WAAU,SAAA,CAAS,EAAA,CAChC,GACF;AAAA,MACA,oBAAC,gBAAgB,UAAhB,EAA0B,SAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AACtC;AAGK,MAAM,kBAET,CAAC,EAAE,WAAW,GAAG,YACnB;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW,GAAG,8BAA8B,SAAS;AAAA,IACpD,GAAG;AAAA,EAAA;AACN;AA8BK,MAAM,SAAS;AACtB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,iBAAiB;AACxB,OAAO,mBAAmB;AAC1B,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,OAAO;AACd,OAAO,YAAY;"}
|
|
1
|
+
{"version":3,"file":"Select.mjs","sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport {\n CheckIcon,\n ChevronDownIcon,\n ChevronsUpDown,\n ChevronUpIcon,\n} from 'lucide-react';\nimport { type ComponentProps, type FC } from 'react';\nimport { cn } from '../../utils/cn';\n\n/**\n * Enum for Select content positioning strategies\n *\n * @enum SelectContentPosition\n */\nexport enum SelectContentPosition {\n /** Position relative to the trigger with automatic placement */\n POPPER = 'popper',\n /** Align content with the selected item */\n ITEM_ALIGNED = 'item-aligned',\n}\n\nconst SelectRoot = SelectPrimitive.Root;\nconst SelectGroup = SelectPrimitive.Group;\nconst SelectValue = SelectPrimitive.Value;\n\n/**\n * Select trigger button component that displays the current selection and opens the dropdown\n *\n * Features comprehensive styling with validation states, focus management, and accessibility support.\n * Uses design tokens for consistent theming across the application.\n *\n * @param validationStyleEnabled - Enables automatic success/error styling based on form validation state\n * @param className - Additional CSS classes for custom styling\n * @param children - Content to display inside the trigger (typically SelectValue)\n *\n * @example\n * ```tsx\n * <Select.Trigger validationStyleEnabled>\n * <Select.Value placeholder=\"Choose option...\" />\n * </Select.Trigger>\n * ```\n */\nconst SelectTrigger: FC<\n ComponentProps<typeof SelectPrimitive.Trigger> & {\n /**\n * Enables success/error border styling based on HTML5 validation state\n * @default false\n * @example\n * ```tsx\n * <Select.Trigger validationStyleEnabled>\n * <Select.Value placeholder=\"Required field\" />\n * </Select.Trigger>\n * ```\n */\n validationStyleEnabled?: boolean;\n }\n> = ({ validationStyleEnabled = false, className, children, ...props }) => (\n <SelectPrimitive.Trigger\n className={cn(\n 'border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring focus:outline-hidden flex w-full items-center justify-between whitespace-nowrap rounded-md border px-3 py-2 text-sm focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'bg-input-background text-input-text w-full select-text resize-none rounded-xl border-2 px-2 py-1 text-sm shadow-none outline-0 transition-all',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none]',\n 'aria-[invalid=true]:border-error',\n validationStyleEnabled && 'valid:border-success invalid:border-error',\n className\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronsUpDown className=\"size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n);\n\n/**\n * Scroll up button for select content with long lists\n *\n * Automatically appears when content is scrollable upward, providing intuitive navigation\n * for users with large option lists.\n *\n * @param className - Additional CSS classes for custom styling\n */\nconst SelectScrollUpButton: FC<\n ComponentProps<typeof SelectPrimitive.ScrollUpButton>\n> = ({ className, ...props }) => (\n <SelectPrimitive.ScrollUpButton\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpButton>\n);\n\n/**\n * Scroll down button for select content with long lists\n *\n * Automatically appears when content is scrollable downward, providing clear visual\n * indication of additional options below the current view.\n *\n * @param className - Additional CSS classes for custom styling\n */\nconst SelectScrollDownButton: FC<\n ComponentProps<typeof SelectPrimitive.ScrollDownButton>\n> = ({ className, ...props }) => (\n <SelectPrimitive.ScrollDownButton\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className\n )}\n {...props}\n >\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownButton>\n);\n\n/**\n * Select dropdown content container with positioning and animation\n *\n * Provides the dropdown interface containing all selectable options. Features smooth\n * animations, flexible positioning strategies, and responsive design for optimal UX.\n *\n * @param position - Positioning strategy for the dropdown content\n * @param className - Additional CSS classes for custom styling\n * @param children - Select items, labels, and separators\n *\n * @example\n * ```tsx\n * <Select.Content position={SelectContentPosition.POPPER}>\n * <Select.Item value=\"option1\">Option 1</Select.Item>\n * <Select.Item value=\"option2\">Option 2</Select.Item>\n * </Select.Content>\n * ```\n */\nexport const SelectContent: FC<\n ComponentProps<typeof SelectPrimitive.Content>\n> = ({\n className,\n children,\n position = SelectContentPosition.POPPER,\n ...props\n}) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n className={cn(\n 'bg-input-background text-input-text w-full select-text resize-none rounded-xl border-2 p-1 text-sm shadow-none outline-0 transition-all',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden border shadow-md',\n position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className\n )}\n position={position}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n);\n\n/**\n * Label component for grouping select options\n *\n * Provides semantic grouping and visual organization of related options within\n * the select dropdown. Enhances accessibility and user experience.\n *\n * @param className - Additional CSS classes for custom styling\n *\n * @example\n * ```tsx\n * <Select.Content>\n * <Select.Label>Fruits</Select.Label>\n * <Select.Item value=\"apple\">Apple</Select.Item>\n * <Select.Item value=\"banana\">Banana</Select.Item>\n * <Select.Separator />\n * <Select.Label>Vegetables</Select.Label>\n * <Select.Item value=\"carrot\">Carrot</Select.Item>\n * </Select.Content>\n * ```\n */\nexport const SelectLabel: FC<ComponentProps<typeof SelectPrimitive.Label>> = ({\n className,\n ...props\n}) => (\n <SelectPrimitive.Label\n className={cn('px-1 py-0.5 text-sm font-semibold', className)}\n {...props}\n />\n);\n\n/**\n * Individual selectable item within the dropdown\n *\n * Represents a single option that users can select. Features hover states,\n * selection indicators, and keyboard navigation support for accessible interaction.\n *\n * @param className - Additional CSS classes for custom styling\n * @param children - The display text/content for the option\n *\n * @example\n * ```tsx\n * <Select.Item value=\"dark-mode\">\n * 🌙 Dark Mode\n * </Select.Item>\n * ```\n */\nconst SelectItem: FC<ComponentProps<typeof SelectPrimitive.Item>> = ({\n className,\n children,\n ...props\n}) => (\n <SelectPrimitive.Item\n className={cn(\n 'focus:bg-neutral/10 outline-hidden relative flex w-full cursor-pointer select-none items-center rounded-lg py-1.5 pl-2 pr-8 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n);\n\n/**\n * Visual separator for grouping options in the dropdown\n *\n * Creates clear visual division between groups of related options,\n * improving readability and organization in complex select menus.\n *\n * @param className - Additional CSS classes for custom styling\n *\n * @example\n * ```tsx\n * <Select.Content>\n * <Select.Item value=\"recent\">Recent Files</Select.Item>\n * <Select.Separator />\n * <Select.Item value=\"all\">All Files</Select.Item>\n * </Select.Content>\n * ```\n */\nexport const SelectSeparator: FC<\n ComponentProps<typeof SelectPrimitive.Separator>\n> = ({ className, ...props }) => (\n <SelectPrimitive.Separator\n className={cn('-mx-1 my-1 h-px bg-red-300', className)}\n {...props}\n />\n);\n\n/**\n * Type definition for the compound Select component with all subcomponents\n */\ntype SelectType = typeof SelectRoot & {\n /** Group container for organizing related options */\n Group: typeof SelectGroup;\n /** Value display component for the trigger */\n Value: typeof SelectValue;\n /** Trigger button that opens the dropdown */\n Trigger: typeof SelectTrigger;\n /** Scroll up button for long lists */\n ScrollUpButton: typeof SelectScrollUpButton;\n /** Scroll down button for long lists */\n ScrollDownButton: typeof SelectScrollDownButton;\n /** Dropdown content container */\n Content: typeof SelectContent;\n /** Label component for option groups */\n Label: typeof SelectLabel;\n /** Individual selectable item */\n Item: typeof SelectItem;\n /** Visual separator between option groups */\n Separator: typeof SelectSeparator;\n};\n\n/**\n * Select - A comprehensive dropdown selection component\n *\n * A fully-featured select component built on Radix UI primitives with extensive customization,\n * accessibility features, and design system integration. Supports single selection with\n * keyboard navigation, validation states, and flexible content positioning.\n *\n * ## Key Features\n * - **Accessibility First**: Full keyboard navigation, screen reader support, and ARIA attributes\n * - **Flexible Positioning**: Multiple positioning strategies for optimal dropdown placement\n * - **Validation Integration**: Built-in support for form validation with visual feedback\n * - **Design System**: Consistent theming with design tokens and style variants\n * - **Responsive Design**: Works seamlessly across desktop and mobile devices\n * - **Rich Content**: Support for icons, separators, labels, and complex option layouts\n *\n * ## Use Cases\n * - Form field selections (theme, language, category)\n * - Settings and configuration options\n * - Filter and sort controls\n * - User preference selections\n * - Any single-choice dropdown interface\n *\n * ## Accessibility\n * - **Keyboard Navigation**: Arrow keys, Enter, Escape, and Home/End support\n * - **Screen Readers**: Proper ARIA labels and state announcements\n * - **Focus Management**: Intuitive focus flow and visual indicators\n * - **High Contrast**: Supports system high contrast modes\n *\n * ## Architecture\n * The Select component follows a compound component pattern with the following structure:\n * - `Select` (root): Manages state and provides context\n * - `Select.Trigger`: Button that displays current value and opens dropdown\n * - `Select.Value`: Displays the selected value with placeholder support\n * - `Select.Content`: Container for the dropdown options\n * - `Select.Item`: Individual selectable options\n * - `Select.Label`: Group labels for organizing options\n * - `Select.Separator`: Visual dividers between option groups\n *\n * @example\n * Basic usage with simple options:\n * ```tsx\n * <Select defaultValue=\"system\">\n * <Select.Trigger>\n * <Select.Value placeholder=\"Choose theme...\" />\n * </Select.Trigger>\n * <Select.Content>\n * <Select.Item value=\"light\">☀️ Light</Select.Item>\n * <Select.Item value=\"dark\">🌙 Dark</Select.Item>\n * <Select.Item value=\"system\">⚙️ System</Select.Item>\n * </Select.Content>\n * </Select>\n * ```\n *\n * @example\n * Advanced usage with groups and labels:\n * ```tsx\n * <Select>\n * <Select.Trigger validationStyleEnabled>\n * <Select.Value placeholder=\"Select category...\" />\n * </Select.Trigger>\n * <Select.Content>\n * <Select.Label>Web Technologies</Select.Label>\n * <Select.Item value=\"react\">React</Select.Item>\n * <Select.Item value=\"vue\">Vue</Select.Item>\n * <Select.Separator />\n * <Select.Label>Mobile</Select.Label>\n * <Select.Item value=\"react-native\">React Native</Select.Item>\n * <Select.Item value=\"flutter\">Flutter</Select.Item>\n * </Select.Content>\n * </Select>\n * ```\n *\n * @example\n * Form integration with validation:\n * ```tsx\n * <form>\n * <Select required name=\"country\">\n * <Select.Trigger validationStyleEnabled aria-invalid={hasError}>\n * <Select.Value placeholder=\"Select country...\" />\n * </Select.Trigger>\n * <Select.Content position={SelectContentPosition.ITEM_ALIGNED}>\n * <Select.Item value=\"us\">United States</Select.Item>\n * <Select.Item value=\"ca\">Canada</Select.Item>\n * <Select.Item value=\"uk\">United Kingdom</Select.Item>\n * </Select.Content>\n * </Select>\n * </form>\n * ```\n */\nexport const Select = SelectRoot as SelectType;\nSelect.Group = SelectGroup;\nSelect.Value = SelectValue;\nSelect.Trigger = SelectTrigger;\nSelect.ScrollUpButton = SelectScrollUpButton;\nSelect.ScrollDownButton = SelectScrollDownButton;\nSelect.Content = SelectContent;\nSelect.Label = SelectLabel;\nSelect.Item = SelectItem;\nSelect.Separator = SelectSeparator;\n"],"names":["SelectContentPosition"],"mappings":";;;;;AAiBO,IAAK,0CAAAA,2BAAL;AAELA,yBAAA,QAAA,IAAS;AAETA,yBAAA,cAAA,IAAe;AAJL,SAAAA;AAAA,GAAA,yBAAA,CAAA,CAAA;AAOZ,MAAM,aAAa,gBAAgB;AACnC,MAAM,cAAc,gBAAgB;AACpC,MAAM,cAAc,gBAAgB;AAmBpC,MAAM,gBAcF,CAAC,EAAE,yBAAyB,OAAO,WAAW,UAAU,GAAG,MAAA,MAC7D;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,0BAA0B;AAAA,MAC1B;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEH,UAAA;AAAA,MAAA;AAAA,MACD,oBAAC,gBAAgB,MAAhB,EAAqB,SAAO,MAC3B,UAAA,oBAAC,gBAAA,EAAe,WAAU,oBAAA,CAAoB,EAAA,CAChD;AAAA,IAAA;AAAA,EAAA;AACF;AAWF,MAAM,uBAEF,CAAC,EAAE,WAAW,GAAG,YACnB;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEJ,8BAAC,eAAA,CAAA,CAAc;AAAA,EAAA;AACjB;AAWF,MA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EAAA,CAChC,GACF;AAAA,MACA,oBAAC,gBAAgB,UAAhB,EAA0B,SAAA,CAAS;AAAA,IAAA;AAAA,EAAA;AACtC;AAoBK,MAAM,kBAET,CAAC,EAAE,WAAW,GAAG,YACnB;AAAA,EAAC,gBAAgB;AAAA,EAAhB;AAAA,IACC,WAAW,GAAG,8BAA8B,SAAS;AAAA,IACpD,GAAG;AAAA,EAAA;AACN;AAoHK,MAAM,SAAS;AACtB,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,iBAAiB;AACxB,OAAO,mBAAmB;AAC1B,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,OAAO;AACd,OAAO,YAAY;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/SwitchSelector/index.tsx"],"sourcesContent":["'use client';\n\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport {\n useEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { useItemSelector } from '../../hooks';\nimport { cn } from '../../utils/cn';\n\nexport type SwitchSelectorChoice<T = boolean> = {\n content: ReactNode;\n value: T;\n} & HTMLAttributes<HTMLButtonElement>;\nexport type SwitchSelectorChoices<T> = SwitchSelectorChoice<T>[];\n\nconst defaultChoices: SwitchSelectorChoices<boolean> = [\n { content: 'Off', value: false },\n { content: 'On', value: true },\n];\n\nexport type SwitchSelectorProps<T = boolean> = {\n choices?: SwitchSelectorChoices<T>;\n value?: T;\n defaultValue?: T;\n onChange?: (choice: T) => void;\n className?: string;\n} & VariantProps<typeof switchSelectorVariant> &\n VariantProps<typeof choiceVariant>;\n\nexport enum SwitchSelectorColor {\n PRIMARY = 'primary',\n SECONDARY = 'secondary',\n DESTRUCTIVE = 'destructive',\n NEUTRAL = 'neutral',\n LIGHT = 'light',\n DARK = 'dark',\n TEXT = 'text',\n}\n\nconst switchSelectorVariant = cva(\n 'flex flex-row gap-2 rounded-full w-fit border-[1.5px] p-[1.5px]',\n {\n variants: {\n color: {\n [SwitchSelectorColor.PRIMARY]: 'border-primary text-primary',\n [SwitchSelectorColor.SECONDARY]: 'border-secondary text-secondary',\n [SwitchSelectorColor.DESTRUCTIVE]:\n 'border-destructive bg-destructive text-destructive',\n [SwitchSelectorColor.NEUTRAL]: 'border-neutral text-neutral ',\n [SwitchSelectorColor.LIGHT]: 'border-white text-white',\n [SwitchSelectorColor.DARK]: 'border-neutral-800 text-neutral-800',\n [SwitchSelectorColor.TEXT]: 'border-text text-text',\n },\n },\n defaultVariants: {\n color: SwitchSelectorColor.PRIMARY,\n },\n }\n);\n\nexport enum SwitchSelectorSize {\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n}\n\nconst choiceVariant = cva(\n 'z-1 w-full flex-1 text-sm font-medium transition-all duration-300 ease-in-out cursor-pointer aria-selected:cursor-default aria-selected:text-text-opposite motion-reduce:transition-none',\n {\n variants: {\n size: {\n [SwitchSelectorSize.SM]: 'py-1 px-2 text-xs',\n [SwitchSelectorSize.MD]: 'p-2 text-sm',\n [SwitchSelectorSize.LG]: 'p-4 text-base',\n },\n },\n defaultVariants: {\n size: SwitchSelectorSize.MD,\n },\n }\n);\n\nconst indicatorVariant = cva(\n 'absolute top-0 z-[-1] h-full w-auto rounded-full transition-[left,width] duration-300 ease-in-out motion-reduce:transition-none',\n {\n variants: {\n color: {\n [SwitchSelectorColor.PRIMARY]: 'bg-primary aria-selected:text-text',\n [SwitchSelectorColor.SECONDARY]: 'bg-secondary aria-selected:text-text',\n [SwitchSelectorColor.DESTRUCTIVE]:\n 'bg-destructive aria-selected:text-text',\n [SwitchSelectorColor.NEUTRAL]: 'bg-neutral aria-selected:text-white ',\n [SwitchSelectorColor.LIGHT]: 'bg-white aria-selected:text-black',\n [SwitchSelectorColor.DARK]: 'bg-neutral-800 aria-selected:text-white',\n [SwitchSelectorColor.TEXT]: 'bg-text aria-selected:text-text-opposite',\n },\n },\n }\n);\n\n/**\n *\n * Component that allows the user to select one of the provided choices.\n *\n * Example:\n * ```jsx\n * <SwitchSelector\n * choices={[\n * { content: 'Option 1', value: 'option1' },\n * { content: 'Option 2', value: 'option2' },\n * { content: 'Option 3', value: 'option3' },\n * ]}\n * value=\"option1\"\n * onChange={(choice) => console.log(choice)}\n * />\n * ```\n */\nexport const SwitchSelector = <T,>({\n choices = defaultChoices as SwitchSelectorChoices<T>,\n value,\n defaultValue,\n onChange,\n color = SwitchSelectorColor.PRIMARY,\n size = SwitchSelectorSize.MD,\n className,\n}: SwitchSelectorProps<T>) => {\n const [valueState, setValue] = useState<T>(\n value ?? defaultValue ?? choices[0].value\n );\n const optionsRefs = useRef<HTMLButtonElement[]>([]);\n const indicatorRef = useRef<HTMLDivElement | null>(null);\n const { choiceIndicatorPosition } = useItemSelector(optionsRefs);\n\n const handleChange = (newValue: T) => {\n setValue(newValue);\n onChange?.(newValue);\n };\n\n useEffect(() => {\n if (value === undefined) return;\n setValue(value);\n }, [value]);\n\n return (\n <div\n className={switchSelectorVariant({\n color,\n className,\n })}\n role=\"tablist\"\n >\n <div className=\"relative flex size-full flex-row items-center justify-center\">\n {choices.map((choice, index) => {\n const { content, value, ...buttonProps } = choice;\n\n const isKeyOfKey =\n typeof value === 'string' || typeof value === 'number';\n\n const isSelected = value === valueState;\n\n return (\n <button\n {...buttonProps}\n className={cn(\n choiceVariant({\n size,\n })\n )}\n key={isKeyOfKey ? value : index}\n role=\"tab\"\n onClick={() => handleChange(value)}\n aria-selected={isSelected}\n disabled={isSelected}\n ref={(el) => {\n optionsRefs.current[index] = el!;\n }}\n >\n {content}\n </button>\n );\n })}\n {choiceIndicatorPosition && (\n <div\n className={cn(\n indicatorVariant({\n color,\n })\n )}\n style={choiceIndicatorPosition}\n ref={indicatorRef}\n />\n )}\n </div>\n </div>\n );\n};\n"],"names":["SwitchSelectorColor","cva","SwitchSelectorSize","useState","useRef","useItemSelector","useEffect","jsx","jsxs","value","createElement","cn"],"mappings":";;;;;;;;;;;;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,UAAAC,2BAAAA,KAAC,OAAA,EAAI,WAAU,gEACZ,UAAA;AAAA,QAAA,QAAQ,IAAI,CAAC,QAAQ,UAAU;AAC9B,gBAAM,EAAE,SAAS,OAAAC,QAAO,GAAG,gBAAgB;AAE3C,gBAAM,aACJ,OAAOA,WAAU,YAAY,OAAOA,WAAU;AAEhD,gBAAM,aAAaA,WAAU;AAE7B,iBACEC,6BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACE,GAAG;AAAA,cACJ,WAAWC,SAAAA;AAAAA,gBACT,cAAc;AAAA,kBACZ;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,cAEH,KAAK,aAAaF,SAAQ;AAAA,cAC1B,MAAK;AAAA,cACL,SAAS,MAAM,aAAaA,MAAK;AAAA,cACjC,iBAAe;AAAA,cACf,UAAU;AAAA,cACV,KAAK,CAAC,OAAO;AACX,4BAAY,QAAQ,KAAK,IAAI;AAAA,cAC/B;AAAA,YAAA;AAAA,YAEC;AAAA,UAAA;AAAA,QAGP,CAAC;AAAA,QACA,2BACCF,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWI,SAAAA;AAAAA,cACT,iBAAiB;AAAA,gBACf;AAAA,cAAA,CACD;AAAA,YAAA;AAAA,YAEH,OAAO;AAAA,YACP,KAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MACP,EAAA,CAEJ;AAAA,IAAA;AAAA,EAAA;AAGN;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/SwitchSelector/index.tsx"],"sourcesContent":["'use client';\n\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport {\n useEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { useItemSelector } from '../../hooks';\nimport { cn } from '../../utils/cn';\n\n/**\n * Configuration for a single choice in the SwitchSelector\n *\n * @template T - The type of the choice value\n * @interface SwitchSelectorChoice\n */\nexport type SwitchSelectorChoice<T = boolean> = {\n /** The visual content displayed for this choice (text, icons, or React elements) */\n content: ReactNode;\n /** The value associated with this choice */\n value: T;\n} & HTMLAttributes<HTMLButtonElement>;\n\n/**\n * Array of choices for the SwitchSelector component\n *\n * @template T - The type of the choice values\n */\nexport type SwitchSelectorChoices<T> = SwitchSelectorChoice<T>[];\n\nconst defaultChoices: SwitchSelectorChoices<boolean> = [\n { content: 'Off', value: false },\n { content: 'On', value: true },\n];\n\n/**\n * Props interface for the SwitchSelector component\n *\n * @template T - The type of the choice values\n * @interface SwitchSelectorProps\n */\nexport type SwitchSelectorProps<T = boolean> = {\n /**\n * Array of selectable choices\n * @default [{ content: 'Off', value: false }, { content: 'On', value: true }]\n * @example\n * ```tsx\n * <SwitchSelector choices={[\n * { content: 'Draft', value: 'draft' },\n * { content: 'Published', value: 'published' },\n * { content: 'Archived', value: 'archived' }\n * ]} />\n * ```\n */\n choices?: SwitchSelectorChoices<T>;\n\n /**\n * Controlled value for the selected choice\n * @example\n * ```tsx\n * const [status, setStatus] = useState('draft');\n * <SwitchSelector value={status} onChange={setStatus} />\n * ```\n */\n value?: T;\n\n /**\n * Default selected value for uncontrolled mode\n * @example\n * ```tsx\n * <SwitchSelector defaultValue=\"published\" />\n * ```\n */\n defaultValue?: T;\n\n /**\n * Callback function triggered when selection changes\n * @param choice - The newly selected choice value\n * @example\n * ```tsx\n * <SwitchSelector onChange={(value) => console.log('Selected:', value)} />\n * ```\n */\n onChange?: (choice: T) => void;\n\n /** Additional CSS classes for custom styling */\n className?: string;\n} & VariantProps<typeof switchSelectorVariant> &\n VariantProps<typeof choiceVariant>;\n\n/**\n * Color variants for the SwitchSelector component\n *\n * @enum SwitchSelectorColor\n */\nexport enum SwitchSelectorColor {\n /** Primary brand color theme */\n PRIMARY = 'primary',\n /** Secondary accent color theme */\n SECONDARY = 'secondary',\n /** Destructive/error color theme for dangerous actions */\n DESTRUCTIVE = 'destructive',\n /** Neutral gray color theme */\n NEUTRAL = 'neutral',\n /** Light color theme for dark backgrounds */\n LIGHT = 'light',\n /** Dark color theme for light backgrounds */\n DARK = 'dark',\n /** Text color theme that adapts to content */\n TEXT = 'text',\n}\n\nconst switchSelectorVariant = cva(\n 'flex flex-row gap-2 rounded-full w-fit border-[1.5px] p-[1.5px]',\n {\n variants: {\n color: {\n [SwitchSelectorColor.PRIMARY]: 'border-primary text-primary',\n [SwitchSelectorColor.SECONDARY]: 'border-secondary text-secondary',\n [SwitchSelectorColor.DESTRUCTIVE]:\n 'border-destructive bg-destructive text-destructive',\n [SwitchSelectorColor.NEUTRAL]: 'border-neutral text-neutral ',\n [SwitchSelectorColor.LIGHT]: 'border-white text-white',\n [SwitchSelectorColor.DARK]: 'border-neutral-800 text-neutral-800',\n [SwitchSelectorColor.TEXT]: 'border-text text-text',\n },\n },\n defaultVariants: {\n color: SwitchSelectorColor.PRIMARY,\n },\n }\n);\n\n/**\n * Size variants for the SwitchSelector component\n *\n * @enum SwitchSelectorSize\n */\nexport enum SwitchSelectorSize {\n /** Small size - compact for tight layouts */\n SM = 'sm',\n /** Medium size - standard for most use cases */\n MD = 'md',\n /** Large size - prominent for important selections */\n LG = 'lg',\n}\n\nconst choiceVariant = cva(\n 'z-1 w-full flex-1 text-sm font-medium transition-all duration-300 ease-in-out cursor-pointer aria-selected:cursor-default aria-selected:text-text-opposite motion-reduce:transition-none',\n {\n variants: {\n size: {\n [SwitchSelectorSize.SM]: 'py-1 px-2 text-xs',\n [SwitchSelectorSize.MD]: 'p-2 text-sm',\n [SwitchSelectorSize.LG]: 'p-4 text-base',\n },\n },\n defaultVariants: {\n size: SwitchSelectorSize.MD,\n },\n }\n);\n\nconst indicatorVariant = cva(\n 'absolute top-0 z-[-1] h-full w-auto rounded-full transition-[left,width] duration-300 ease-in-out motion-reduce:transition-none',\n {\n variants: {\n color: {\n [SwitchSelectorColor.PRIMARY]: 'bg-primary aria-selected:text-text',\n [SwitchSelectorColor.SECONDARY]: 'bg-secondary aria-selected:text-text',\n [SwitchSelectorColor.DESTRUCTIVE]:\n 'bg-destructive aria-selected:text-text',\n [SwitchSelectorColor.NEUTRAL]: 'bg-neutral aria-selected:text-white ',\n [SwitchSelectorColor.LIGHT]: 'bg-white aria-selected:text-black',\n [SwitchSelectorColor.DARK]: 'bg-neutral-800 aria-selected:text-white',\n [SwitchSelectorColor.TEXT]: 'bg-text aria-selected:text-text-opposite',\n },\n },\n }\n);\n\n/**\n * SwitchSelector - A versatile toggle component for multi-option selection\n *\n * A sophisticated switch selector component that provides an elegant way to choose between\n * multiple options with smooth animations and visual feedback. Built with accessibility\n * in mind, it supports keyboard navigation and screen reader announcements.\n *\n * ## Key Features\n * - **Smooth Animations**: Fluid indicator transitions between options\n * - **Accessible**: Full keyboard navigation and ARIA support\n * - **Flexible Styling**: Multiple color themes and size variants\n * - **Generic Types**: Type-safe values with TypeScript generics\n * - **Controlled/Uncontrolled**: Supports both usage patterns\n * - **Custom Content**: Rich content support including icons and text\n *\n * ## Use Cases\n * - Settings toggles (On/Off, Light/Dark theme)\n * - Status selectors (Draft/Published/Archived)\n * - View mode switches (List/Grid/Card)\n * - Filter options (All/Active/Completed)\n * - Language or region selection\n * - Any multi-option toggle interface\n *\n * ## Accessibility\n * - **Keyboard Navigation**: Tab to focus, arrow keys to navigate options\n * - **Screen Readers**: Proper ARIA labels and role attributes\n * - **Focus Management**: Clear visual focus indicators\n * - **State Announcements**: Selection changes announced to assistive technology\n *\n * ## Visual Design\n * The component features a pill-shaped container with individual choice buttons.\n * A smooth-sliding background indicator highlights the active selection, creating\n * an intuitive and polished user experience.\n *\n * @template T - The type of values for the choices (string, number, boolean, etc.)\n *\n * @example\n * Basic boolean toggle:\n * ```tsx\n * <SwitchSelector\n * defaultValue={false}\n * onChange={(value) => setEnabled(value)}\n * />\n * ```\n *\n * @example\n * Multi-option selector with custom content:\n * ```tsx\n * <SwitchSelector\n * choices={[\n * { content: <>📝 Draft</>, value: 'draft' },\n * { content: <>✅ Published</>, value: 'published' },\n * { content: <>📦 Archived</>, value: 'archived' }\n * ]}\n * value={currentStatus}\n * onChange={setStatus}\n * color={SwitchSelectorColor.SECONDARY}\n * size={SwitchSelectorSize.LG}\n * />\n * ```\n *\n * @example\n * View mode switcher:\n * ```tsx\n * <SwitchSelector\n * choices={[\n * { content: 'List', value: 'list' },\n * { content: 'Grid', value: 'grid' },\n * { content: 'Card', value: 'card' }\n * ]}\n * defaultValue=\"grid\"\n * color={SwitchSelectorColor.NEUTRAL}\n * onChange={(view) => setViewMode(view)}\n * />\n * ```\n *\n * @example\n * Theme selector with icons:\n * ```tsx\n * <SwitchSelector\n * choices={[\n * { content: <>☀️ Light</>, value: 'light' },\n * { content: <>🌙 Dark</>, value: 'dark' },\n * { content: <>⚙️ System</>, value: 'system' }\n * ]}\n * value={theme}\n * onChange={setTheme}\n * size={SwitchSelectorSize.SM}\n * />\n * ```\n */\nexport const SwitchSelector = <T,>({\n choices = defaultChoices as SwitchSelectorChoices<T>,\n value,\n defaultValue,\n onChange,\n color = SwitchSelectorColor.PRIMARY,\n size = SwitchSelectorSize.MD,\n className,\n}: SwitchSelectorProps<T>) => {\n const [valueState, setValue] = useState<T>(\n value ?? defaultValue ?? choices[0].value\n );\n const optionsRefs = useRef<HTMLButtonElement[]>([]);\n const indicatorRef = useRef<HTMLDivElement | null>(null);\n const { choiceIndicatorPosition } = useItemSelector(optionsRefs);\n\n const handleChange = (newValue: T) => {\n setValue(newValue);\n onChange?.(newValue);\n };\n\n useEffect(() => {\n if (value === undefined) return;\n setValue(value);\n }, [value]);\n\n return (\n <div\n className={switchSelectorVariant({\n color,\n className,\n })}\n role=\"tablist\"\n >\n <div className=\"relative flex size-full flex-row items-center justify-center\">\n {choices.map((choice, index) => {\n const { content, value, ...buttonProps } = choice;\n\n const isKeyOfKey =\n typeof value === 'string' || typeof value === 'number';\n\n const isSelected = value === valueState;\n\n return (\n <button\n {...buttonProps}\n className={cn(\n choiceVariant({\n size,\n })\n )}\n key={isKeyOfKey ? value : index}\n role=\"tab\"\n onClick={() => handleChange(value)}\n aria-selected={isSelected}\n disabled={isSelected}\n ref={(el) => {\n optionsRefs.current[index] = el!;\n }}\n >\n {content}\n </button>\n );\n })}\n {choiceIndicatorPosition && (\n <div\n className={cn(\n indicatorVariant({\n color,\n })\n )}\n style={choiceIndicatorPosition}\n ref={indicatorRef}\n />\n )}\n </div>\n </div>\n );\n};\n"],"names":["SwitchSelectorColor","cva","SwitchSelectorSize","useState","useRef","useItemSelector","useEffect","jsx","jsxs","value","createElement","cn"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,iBAAiD;AAAA,EACrD,EAAE,SAAS,OAAO,OAAO,MAAA;AAAA,EACzB,EAAE,SAAS,MAAM,OAAO,KAAA;AAC1B;AA8DO,IAAK,wCAAAA,yBAAL;AAELA,uBAAA,SAAA,IAAU;AAEVA,uBAAA,WAAA,IAAY;AAEZA,uBAAA,aAAA,IAAc;AAEdA,uBAAA,SAAA,IAAU;AAEVA,uBAAA,OAAA,IAAQ;AAERA,uBAAA,MAAA,IAAO;AAEPA,uBAAA,MAAA,IAAO;AAdG,SAAAA;AAAA,GAAA,uBAAA,CAAA,CAAA;AAiBZ,MAAM,wBAAwBC,uBAAAA;AAAAA,EAC5B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,OAAO;AAAA,QACL;AAAA,UAAC;AAAA;AAAA,WAA8B;AAAA,QAC/B;AAAA,UAAC;AAAA;AAAA,WAAgC;AAAA,QACjC;AAAA,UAAC;AAAA;AAAA,WACC;AAAA,QACF;AAAA,UAAC;AAAA;AAAA,WAA8B;AAAA,QAC/B;AAAA,UAAC;AAAA;AAAA,WAA4B;AAAA,QAC7B;AAAA,UAAC;AAAA;AAAA,WAA2B;AAAA,QAC5B;AAAA,UAAC;AAAA;AAAA,WAA2B;AAAA,MAAA;AAAA,IAC9B;AAAA,IAEF,iBAAiB;AAAA,MACf,OAAO;AAAA;AAAA,IAAA;AAAA,EACT;AAEJ;AAOO,IAAK,uCAAAC,wBAAL;AAELA,sBAAA,IAAA,IAAK;AAELA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@@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for a single choice in the SwitchSelector
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the choice value
|
|
7
|
+
* @interface SwitchSelectorChoice
|
|
8
|
+
*/
|
|
3
9
|
export type SwitchSelectorChoice<T = boolean> = {
|
|
10
|
+
/** The visual content displayed for this choice (text, icons, or React elements) */
|
|
4
11
|
content: ReactNode;
|
|
12
|
+
/** The value associated with this choice */
|
|
5
13
|
value: T;
|
|
6
14
|
} & HTMLAttributes<HTMLButtonElement>;
|
|
15
|
+
/**
|
|
16
|
+
* Array of choices for the SwitchSelector component
|
|
17
|
+
*
|
|
18
|
+
* @template T - The type of the choice values
|
|
19
|
+
*/
|
|
7
20
|
export type SwitchSelectorChoices<T> = SwitchSelectorChoice<T>[];
|
|
21
|
+
/**
|
|
22
|
+
* Props interface for the SwitchSelector component
|
|
23
|
+
*
|
|
24
|
+
* @template T - The type of the choice values
|
|
25
|
+
* @interface SwitchSelectorProps
|
|
26
|
+
*/
|
|
8
27
|
export type SwitchSelectorProps<T = boolean> = {
|
|
28
|
+
/**
|
|
29
|
+
* Array of selectable choices
|
|
30
|
+
* @default [{ content: 'Off', value: false }, { content: 'On', value: true }]
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <SwitchSelector choices={[
|
|
34
|
+
* { content: 'Draft', value: 'draft' },
|
|
35
|
+
* { content: 'Published', value: 'published' },
|
|
36
|
+
* { content: 'Archived', value: 'archived' }
|
|
37
|
+
* ]} />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
9
40
|
choices?: SwitchSelectorChoices<T>;
|
|
41
|
+
/**
|
|
42
|
+
* Controlled value for the selected choice
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const [status, setStatus] = useState('draft');
|
|
46
|
+
* <SwitchSelector value={status} onChange={setStatus} />
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
10
49
|
value?: T;
|
|
50
|
+
/**
|
|
51
|
+
* Default selected value for uncontrolled mode
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <SwitchSelector defaultValue="published" />
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
11
57
|
defaultValue?: T;
|
|
58
|
+
/**
|
|
59
|
+
* Callback function triggered when selection changes
|
|
60
|
+
* @param choice - The newly selected choice value
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <SwitchSelector onChange={(value) => console.log('Selected:', value)} />
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
12
66
|
onChange?: (choice: T) => void;
|
|
67
|
+
/** Additional CSS classes for custom styling */
|
|
13
68
|
className?: string;
|
|
14
69
|
} & VariantProps<typeof switchSelectorVariant> & VariantProps<typeof choiceVariant>;
|
|
70
|
+
/**
|
|
71
|
+
* Color variants for the SwitchSelector component
|
|
72
|
+
*
|
|
73
|
+
* @enum SwitchSelectorColor
|
|
74
|
+
*/
|
|
15
75
|
export declare enum SwitchSelectorColor {
|
|
76
|
+
/** Primary brand color theme */
|
|
16
77
|
PRIMARY = "primary",
|
|
78
|
+
/** Secondary accent color theme */
|
|
17
79
|
SECONDARY = "secondary",
|
|
80
|
+
/** Destructive/error color theme for dangerous actions */
|
|
18
81
|
DESTRUCTIVE = "destructive",
|
|
82
|
+
/** Neutral gray color theme */
|
|
19
83
|
NEUTRAL = "neutral",
|
|
84
|
+
/** Light color theme for dark backgrounds */
|
|
20
85
|
LIGHT = "light",
|
|
86
|
+
/** Dark color theme for light backgrounds */
|
|
21
87
|
DARK = "dark",
|
|
88
|
+
/** Text color theme that adapts to content */
|
|
22
89
|
TEXT = "text"
|
|
23
90
|
}
|
|
24
91
|
declare const switchSelectorVariant: (props?: ({
|
|
25
92
|
color?: SwitchSelectorColor | null | undefined;
|
|
26
93
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Size variants for the SwitchSelector component
|
|
96
|
+
*
|
|
97
|
+
* @enum SwitchSelectorSize
|
|
98
|
+
*/
|
|
27
99
|
export declare enum SwitchSelectorSize {
|
|
100
|
+
/** Small size - compact for tight layouts */
|
|
28
101
|
SM = "sm",
|
|
102
|
+
/** Medium size - standard for most use cases */
|
|
29
103
|
MD = "md",
|
|
104
|
+
/** Large size - prominent for important selections */
|
|
30
105
|
LG = "lg"
|
|
31
106
|
}
|
|
32
107
|
declare const choiceVariant: (props?: ({
|
|
33
108
|
size?: SwitchSelectorSize | null | undefined;
|
|
34
109
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
35
110
|
/**
|
|
111
|
+
* SwitchSelector - A versatile toggle component for multi-option selection
|
|
112
|
+
*
|
|
113
|
+
* A sophisticated switch selector component that provides an elegant way to choose between
|
|
114
|
+
* multiple options with smooth animations and visual feedback. Built with accessibility
|
|
115
|
+
* in mind, it supports keyboard navigation and screen reader announcements.
|
|
116
|
+
*
|
|
117
|
+
* ## Key Features
|
|
118
|
+
* - **Smooth Animations**: Fluid indicator transitions between options
|
|
119
|
+
* - **Accessible**: Full keyboard navigation and ARIA support
|
|
120
|
+
* - **Flexible Styling**: Multiple color themes and size variants
|
|
121
|
+
* - **Generic Types**: Type-safe values with TypeScript generics
|
|
122
|
+
* - **Controlled/Uncontrolled**: Supports both usage patterns
|
|
123
|
+
* - **Custom Content**: Rich content support including icons and text
|
|
124
|
+
*
|
|
125
|
+
* ## Use Cases
|
|
126
|
+
* - Settings toggles (On/Off, Light/Dark theme)
|
|
127
|
+
* - Status selectors (Draft/Published/Archived)
|
|
128
|
+
* - View mode switches (List/Grid/Card)
|
|
129
|
+
* - Filter options (All/Active/Completed)
|
|
130
|
+
* - Language or region selection
|
|
131
|
+
* - Any multi-option toggle interface
|
|
36
132
|
*
|
|
37
|
-
*
|
|
133
|
+
* ## Accessibility
|
|
134
|
+
* - **Keyboard Navigation**: Tab to focus, arrow keys to navigate options
|
|
135
|
+
* - **Screen Readers**: Proper ARIA labels and role attributes
|
|
136
|
+
* - **Focus Management**: Clear visual focus indicators
|
|
137
|
+
* - **State Announcements**: Selection changes announced to assistive technology
|
|
138
|
+
*
|
|
139
|
+
* ## Visual Design
|
|
140
|
+
* The component features a pill-shaped container with individual choice buttons.
|
|
141
|
+
* A smooth-sliding background indicator highlights the active selection, creating
|
|
142
|
+
* an intuitive and polished user experience.
|
|
143
|
+
*
|
|
144
|
+
* @template T - The type of values for the choices (string, number, boolean, etc.)
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* Basic boolean toggle:
|
|
148
|
+
* ```tsx
|
|
149
|
+
* <SwitchSelector
|
|
150
|
+
* defaultValue={false}
|
|
151
|
+
* onChange={(value) => setEnabled(value)}
|
|
152
|
+
* />
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* Multi-option selector with custom content:
|
|
157
|
+
* ```tsx
|
|
158
|
+
* <SwitchSelector
|
|
159
|
+
* choices={[
|
|
160
|
+
* { content: <>📝 Draft</>, value: 'draft' },
|
|
161
|
+
* { content: <>✅ Published</>, value: 'published' },
|
|
162
|
+
* { content: <>📦 Archived</>, value: 'archived' }
|
|
163
|
+
* ]}
|
|
164
|
+
* value={currentStatus}
|
|
165
|
+
* onChange={setStatus}
|
|
166
|
+
* color={SwitchSelectorColor.SECONDARY}
|
|
167
|
+
* size={SwitchSelectorSize.LG}
|
|
168
|
+
* />
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* View mode switcher:
|
|
173
|
+
* ```tsx
|
|
174
|
+
* <SwitchSelector
|
|
175
|
+
* choices={[
|
|
176
|
+
* { content: 'List', value: 'list' },
|
|
177
|
+
* { content: 'Grid', value: 'grid' },
|
|
178
|
+
* { content: 'Card', value: 'card' }
|
|
179
|
+
* ]}
|
|
180
|
+
* defaultValue="grid"
|
|
181
|
+
* color={SwitchSelectorColor.NEUTRAL}
|
|
182
|
+
* onChange={(view) => setViewMode(view)}
|
|
183
|
+
* />
|
|
184
|
+
* ```
|
|
38
185
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
186
|
+
* @example
|
|
187
|
+
* Theme selector with icons:
|
|
188
|
+
* ```tsx
|
|
41
189
|
* <SwitchSelector
|
|
42
190
|
* choices={[
|
|
43
|
-
* { content:
|
|
44
|
-
* { content:
|
|
45
|
-
* { content:
|
|
191
|
+
* { content: <>☀️ Light</>, value: 'light' },
|
|
192
|
+
* { content: <>🌙 Dark</>, value: 'dark' },
|
|
193
|
+
* { content: <>⚙️ System</>, value: 'system' }
|
|
46
194
|
* ]}
|
|
47
|
-
* value=
|
|
48
|
-
* onChange={
|
|
195
|
+
* value={theme}
|
|
196
|
+
* onChange={setTheme}
|
|
197
|
+
* size={SwitchSelectorSize.SM}
|
|
49
198
|
* />
|
|
50
199
|
* ```
|
|
51
200
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SwitchSelector/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC9C,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,CAAC,CAAC;CACV,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SwitchSelector/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf;;;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