@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","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","SwitchSelectorSize","value"],"mappings":";;;;;;;;;;;;AAmBA,MAAM,iBAAiD;AAAA,EACrD,EAAE,SAAS,OAAO,OAAO,MAAA;AAAA,EACzB,EAAE,SAAS,MAAM,OAAO,KAAA;AAC1B;AAWO,IAAK,wCAAAA,yBAAL;AACLA,uBAAA,SAAA,IAAU;AACVA,uBAAA,WAAA,IAAY;AACZA,uBAAA,aAAA,IAAc;AACdA,uBAAA,SAAA,IAAU;AACVA,uBAAA,OAAA,IAAQ;AACRA,uBAAA,MAAA,IAAO;AACPA,uBAAA,MAAA,IAAO;AAPG,SAAAA;AAAA,GAAA,uBAAA,CAAA,CAAA;AAUZ,MAAM,wBAAwB;AAAA,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;AAEO,IAAK,uCAAAC,wBAAL;AACLA,sBAAA,IAAA,IAAK;AACLA,sBAAA,IAAA,IAAK;AACLA,sBAAA,IAAA,IAAK;AAHK,SAAAA;AAAA,GAAA,sBAAA,CAAA,CAAA;AAMZ,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAA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,WAAW,sBAAsB;AAAA,QAC/B;AAAA,QACA;AAAA,MAAA,CACD;AAAA,MACD,MAAK;AAAA,MAEL,UAAA,qBAAC,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,iBACE;AAAA,YAAC;AAAA,YAAA;AAAA,cACE,GAAG;AAAA,cACJ,WAAW;AAAA,gBACT,cAAc;AAAA,kBACZ;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,cAEH,KAAK,aAAaA,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,2BACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,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.mjs","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","SwitchSelectorSize","value"],"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,wBAAwB;AAAA,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,sBAAA,IAAA,IAAK;AAELA,s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AM;AACd,QAAI,UAAU,OAAW;AACzB,aAAS,KAAK;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AAEV,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,sBAAsB;AAAA,QAC/B;AAAA,QACA;AAAA,MAAA,CACD;AAAA,MACD,MAAK;AAAA,MAEL,UAAA,qBAAC,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,iBACE;AAAA,YAAC;AAAA,YAAA;AAAA,cACE,GAAG;AAAA,cACJ,WAAW;AAAA,gBACT,cAAc;AAAA,kBACZ;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,cAEH,KAAK,aAAaA,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,2BACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.cjs","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["'use client';\n\nimport { MoveDiagonal } from 'lucide-react';\nimport { HTMLAttributes, useState, type FC } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ExpandCollapse } from '../ExpandCollapse';\nimport { Modal, ModalSize } from '../Modal';\n\ntype TableProps = HTMLAttributes<HTMLTableElement> & {\n isRollable?: boolean;\n};\n\nexport const Table: FC<TableProps> = ({ className, isRollable, ...props }) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n return (\n <div className=\"relative\">\n <div className=\"sticky top-48 z-10\">\n <div className=\"absolute top-4 right-2\">\n <Button\n variant=\"hoverable\"\n size=\"icon-md\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n label=\"Move\"\n Icon={MoveDiagonal}\n />\n </div>\n </div>\n <ExpandCollapse\n isRollable={isRollable}\n className=\"max-w-full overflow-x-auto\"\n >\n <table\n className={cn(\n 'max-w-full overflow-x-auto table-auto text-left min-w-full bg-background',\n className\n )}\n {...props}\n />\n </ExpandCollapse>\n\n <Modal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n size={ModalSize.XL}\n hasCloseButton\n >\n {isModalOpen ? (\n <div className=\"grid\">\n <table\n className={cn(\n 'max-w-full table-auto text-left min-w-full',\n className\n )}\n {...props}\n />\n </div>\n ) : (\n <></>\n )}\n </Modal>\n </div>\n );\n};\n"],"names":["useState","jsxs","jsx","Button","MoveDiagonal","ExpandCollapse","cn","Modal","ModalSize","Fragment"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Table.cjs","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["'use client';\n\nimport { MoveDiagonal } from 'lucide-react';\nimport { HTMLAttributes, useState, type FC } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ExpandCollapse } from '../ExpandCollapse';\nimport { Modal, ModalSize } from '../Modal';\n\n/**\n * Properties for the Table component that extends standard HTML table attributes\n *\n * @interface TableProps\n * @extends {HTMLAttributes<HTMLTableElement>}\n *\n * @property {boolean} [isRollable] - Whether the table content can be collapsed/expanded using the ExpandCollapse wrapper\n * @property {string} [className] - Additional CSS classes for custom styling\n * @property {ReactNode} children - The table content including thead, tbody, tfoot elements\n *\n * @example\n * ```tsx\n * // Basic table usage\n * <Table>\n * <thead>\n * <tr>\n * <th>Name</th>\n * <th>Email</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>John Doe</td>\n * <td>john@example.com</td>\n * </tr>\n * </tbody>\n * </Table>\n *\n * // Collapsible table with custom styling\n * <Table isRollable className=\"border border-gray-300 rounded-lg\">\n * <thead>\n * <tr>\n * <th>Product</th>\n * <th>Price</th>\n * <th>Stock</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>Laptop</td>\n * <td>$999</td>\n * <td>15</td>\n * </tr>\n * </tbody>\n * </Table>\n * ```\n */\ntype TableProps = HTMLAttributes<HTMLTableElement> & {\n isRollable?: boolean;\n};\n\n/**\n * Table component that provides an enhanced table experience with modal expansion and collapsible content\n *\n * The Table component wraps a standard HTML table element with additional functionality:\n * - **Modal Expansion**: Click the diagonal arrow button to view the table in a full-screen modal\n * - **Collapsible Content**: Optionally wrap content in an ExpandCollapse component for space-saving\n * - **Responsive Design**: Handles large tables gracefully with modal overflow\n * - **Sticky Controls**: Table controls remain accessible even when scrolling\n *\n * ## Features\n * - **Modal View**: Full-screen modal for better viewing of large tables\n * - **Expand/Collapse**: Optional collapsible wrapper to save space\n * - **Responsive**: Handles overflow and responsive behavior automatically\n * - **Accessibility**: Maintains proper table semantics and keyboard navigation\n * - **Customizable**: Supports all standard HTML table attributes and styling\n *\n * ## Best Practices\n * - Use semantic HTML table structure (thead, tbody, tfoot)\n * - Provide proper column headers with scope attributes\n * - Use the isRollable prop for large tables that might need space management\n * - Apply consistent styling through the className prop\n * - Consider pagination for very large datasets\n *\n * @param {TableProps} props - The properties for the Table component\n * @returns {JSX.Element} The rendered table with enhanced functionality\n *\n * @example\n * ```tsx\n * // Simple data table\n * <Table>\n * <thead>\n * <tr>\n * <th scope=\"col\">Name</th>\n * <th scope=\"col\">Email</th>\n * <th scope=\"col\">Status</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>John Doe</td>\n * <td>john@example.com</td>\n * <td>\n * <span className=\"px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs\">\n * Active\n * </span>\n * </td>\n * </tr>\n * <tr>\n * <td>Jane Smith</td>\n * <td>jane@example.com</td>\n * <td>\n * <span className=\"px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs\">\n * Pending\n * </span>\n * </td>\n * </tr>\n * </tbody>\n * </Table>\n *\n * // Large collapsible table with custom styling\n * <Table\n * isRollable\n * className=\"border border-gray-200 rounded-lg overflow-hidden\"\n * >\n * <thead className=\"bg-gray-50\">\n * <tr>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Product ID\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Name\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Category\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Price\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Stock\n * </th>\n * </tr>\n * </thead>\n * <tbody className=\"bg-white divide-y divide-gray-200\">\n * {products.map((product) => (\n * <tr key={product.id} className=\"hover:bg-gray-50\">\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-900\">\n * #{product.id}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900\">\n * {product.name}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n * {product.category}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-900\">\n * ${product.price.toFixed(2)}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n * {product.stock} units\n * </td>\n * </tr>\n * ))}\n * </tbody>\n * </Table>\n *\n * // Financial data table with formatted numbers\n * <Table className=\"w-full border-collapse\">\n * <thead>\n * <tr className=\"border-b-2 border-gray-300\">\n * <th scope=\"col\" className=\"text-left py-3 px-4\">Quarter</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Revenue</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Profit</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Growth</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr className=\"border-b border-gray-200\">\n * <td className=\"py-3 px-4 font-medium\">Q1 2024</td>\n * <td className=\"py-3 px-4 text-right\">$2,450,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">$345,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">+12.5%</td>\n * </tr>\n * <tr className=\"border-b border-gray-200\">\n * <td className=\"py-3 px-4 font-medium\">Q2 2024</td>\n * <td className=\"py-3 px-4 text-right\">$2,780,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">$398,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">+13.5%</td>\n * </tr>\n * </tbody>\n * </Table>\n * ```\n *\n * @see {@link ExpandCollapse} - Component used for collapsible table content\n * @see {@link Modal} - Component used for full-screen table view\n * @see {@link Button} - Component used for the modal trigger button\n */\nexport const Table: FC<TableProps> = ({ className, isRollable, ...props }) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n return (\n <div className=\"relative\">\n <div className=\"sticky top-48 z-10\">\n <div className=\"absolute top-4 right-2\">\n <Button\n variant=\"hoverable\"\n size=\"icon-md\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n label=\"Move\"\n Icon={MoveDiagonal}\n />\n </div>\n </div>\n <ExpandCollapse\n isRollable={isRollable}\n className=\"max-w-full overflow-x-auto\"\n >\n <table\n className={cn(\n 'max-w-full overflow-x-auto table-auto text-left min-w-full bg-background',\n className\n )}\n {...props}\n />\n </ExpandCollapse>\n\n <Modal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n size={ModalSize.XL}\n hasCloseButton\n >\n {isModalOpen ? (\n <div className=\"grid\">\n <table\n className={cn(\n 'max-w-full table-auto text-left min-w-full',\n className\n )}\n {...props}\n />\n </div>\n ) : (\n <></>\n )}\n </Modal>\n </div>\n );\n};\n"],"names":["useState","jsxs","jsx","Button","MoveDiagonal","ExpandCollapse","cn","Modal","ModalSize","Fragment"],"mappings":";;;;;;;;;;AAqMO,MAAM,QAAwB,CAAC,EAAE,WAAW,YAAY,GAAG,YAAY;AAC5E,QAAM,CAAC,aAAa,cAAc,IAAIA,aAAAA,SAAS,KAAK;AAEpD,SACEC,2BAAAA,KAAC,OAAA,EAAI,WAAU,YACb,UAAA;AAAA,IAAAC,2BAAAA,IAAC,SAAI,WAAU,sBACb,UAAAA,+BAAC,OAAA,EAAI,WAAU,0BACb,UAAAA,2BAAAA;AAAAA,MAACC,yBAAAA;AAAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAS,MAAM;AACb,yBAAe,IAAI;AAAA,QACrB;AAAA,QACA,OAAM;AAAA,QACN,MAAMC,YAAAA;AAAAA,MAAA;AAAA,IAAA,GAEV,EAAA,CACF;AAAA,IACAF,2BAAAA;AAAAA,MAACG,yCAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAU;AAAA,QAEV,UAAAH,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWI,SAAAA;AAAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAED,GAAG;AAAA,UAAA;AAAA,QAAA;AAAA,MACN;AAAA,IAAA;AAAA,IAGFJ,2BAAAA;AAAAA,MAACK,uBAAAA;AAAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS,MAAM,eAAe,KAAK;AAAA,QACnC,MAAMC,uBAAAA,UAAU;AAAA,QAChB,gBAAc;AAAA,QAEb,UAAA,cACCN,+BAAC,OAAA,EAAI,WAAU,QACb,UAAAA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWI,SAAAA;AAAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAED,GAAG;AAAA,UAAA;AAAA,QAAA,GAER,IAEAJ,+BAAAO,WAAAA,UAAA,CAAA,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;;"}
|
|
@@ -1,7 +1,191 @@
|
|
|
1
1
|
import { HTMLAttributes, FC } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Properties for the Table component that extends standard HTML table attributes
|
|
4
|
+
*
|
|
5
|
+
* @interface TableProps
|
|
6
|
+
* @extends {HTMLAttributes<HTMLTableElement>}
|
|
7
|
+
*
|
|
8
|
+
* @property {boolean} [isRollable] - Whether the table content can be collapsed/expanded using the ExpandCollapse wrapper
|
|
9
|
+
* @property {string} [className] - Additional CSS classes for custom styling
|
|
10
|
+
* @property {ReactNode} children - The table content including thead, tbody, tfoot elements
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Basic table usage
|
|
15
|
+
* <Table>
|
|
16
|
+
* <thead>
|
|
17
|
+
* <tr>
|
|
18
|
+
* <th>Name</th>
|
|
19
|
+
* <th>Email</th>
|
|
20
|
+
* </tr>
|
|
21
|
+
* </thead>
|
|
22
|
+
* <tbody>
|
|
23
|
+
* <tr>
|
|
24
|
+
* <td>John Doe</td>
|
|
25
|
+
* <td>john@example.com</td>
|
|
26
|
+
* </tr>
|
|
27
|
+
* </tbody>
|
|
28
|
+
* </Table>
|
|
29
|
+
*
|
|
30
|
+
* // Collapsible table with custom styling
|
|
31
|
+
* <Table isRollable className="border border-gray-300 rounded-lg">
|
|
32
|
+
* <thead>
|
|
33
|
+
* <tr>
|
|
34
|
+
* <th>Product</th>
|
|
35
|
+
* <th>Price</th>
|
|
36
|
+
* <th>Stock</th>
|
|
37
|
+
* </tr>
|
|
38
|
+
* </thead>
|
|
39
|
+
* <tbody>
|
|
40
|
+
* <tr>
|
|
41
|
+
* <td>Laptop</td>
|
|
42
|
+
* <td>$999</td>
|
|
43
|
+
* <td>15</td>
|
|
44
|
+
* </tr>
|
|
45
|
+
* </tbody>
|
|
46
|
+
* </Table>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
2
49
|
type TableProps = HTMLAttributes<HTMLTableElement> & {
|
|
3
50
|
isRollable?: boolean;
|
|
4
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Table component that provides an enhanced table experience with modal expansion and collapsible content
|
|
54
|
+
*
|
|
55
|
+
* The Table component wraps a standard HTML table element with additional functionality:
|
|
56
|
+
* - **Modal Expansion**: Click the diagonal arrow button to view the table in a full-screen modal
|
|
57
|
+
* - **Collapsible Content**: Optionally wrap content in an ExpandCollapse component for space-saving
|
|
58
|
+
* - **Responsive Design**: Handles large tables gracefully with modal overflow
|
|
59
|
+
* - **Sticky Controls**: Table controls remain accessible even when scrolling
|
|
60
|
+
*
|
|
61
|
+
* ## Features
|
|
62
|
+
* - **Modal View**: Full-screen modal for better viewing of large tables
|
|
63
|
+
* - **Expand/Collapse**: Optional collapsible wrapper to save space
|
|
64
|
+
* - **Responsive**: Handles overflow and responsive behavior automatically
|
|
65
|
+
* - **Accessibility**: Maintains proper table semantics and keyboard navigation
|
|
66
|
+
* - **Customizable**: Supports all standard HTML table attributes and styling
|
|
67
|
+
*
|
|
68
|
+
* ## Best Practices
|
|
69
|
+
* - Use semantic HTML table structure (thead, tbody, tfoot)
|
|
70
|
+
* - Provide proper column headers with scope attributes
|
|
71
|
+
* - Use the isRollable prop for large tables that might need space management
|
|
72
|
+
* - Apply consistent styling through the className prop
|
|
73
|
+
* - Consider pagination for very large datasets
|
|
74
|
+
*
|
|
75
|
+
* @param {TableProps} props - The properties for the Table component
|
|
76
|
+
* @returns {JSX.Element} The rendered table with enhanced functionality
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* // Simple data table
|
|
81
|
+
* <Table>
|
|
82
|
+
* <thead>
|
|
83
|
+
* <tr>
|
|
84
|
+
* <th scope="col">Name</th>
|
|
85
|
+
* <th scope="col">Email</th>
|
|
86
|
+
* <th scope="col">Status</th>
|
|
87
|
+
* </tr>
|
|
88
|
+
* </thead>
|
|
89
|
+
* <tbody>
|
|
90
|
+
* <tr>
|
|
91
|
+
* <td>John Doe</td>
|
|
92
|
+
* <td>john@example.com</td>
|
|
93
|
+
* <td>
|
|
94
|
+
* <span className="px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs">
|
|
95
|
+
* Active
|
|
96
|
+
* </span>
|
|
97
|
+
* </td>
|
|
98
|
+
* </tr>
|
|
99
|
+
* <tr>
|
|
100
|
+
* <td>Jane Smith</td>
|
|
101
|
+
* <td>jane@example.com</td>
|
|
102
|
+
* <td>
|
|
103
|
+
* <span className="px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs">
|
|
104
|
+
* Pending
|
|
105
|
+
* </span>
|
|
106
|
+
* </td>
|
|
107
|
+
* </tr>
|
|
108
|
+
* </tbody>
|
|
109
|
+
* </Table>
|
|
110
|
+
*
|
|
111
|
+
* // Large collapsible table with custom styling
|
|
112
|
+
* <Table
|
|
113
|
+
* isRollable
|
|
114
|
+
* className="border border-gray-200 rounded-lg overflow-hidden"
|
|
115
|
+
* >
|
|
116
|
+
* <thead className="bg-gray-50">
|
|
117
|
+
* <tr>
|
|
118
|
+
* <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
119
|
+
* Product ID
|
|
120
|
+
* </th>
|
|
121
|
+
* <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
122
|
+
* Name
|
|
123
|
+
* </th>
|
|
124
|
+
* <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
125
|
+
* Category
|
|
126
|
+
* </th>
|
|
127
|
+
* <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
128
|
+
* Price
|
|
129
|
+
* </th>
|
|
130
|
+
* <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">
|
|
131
|
+
* Stock
|
|
132
|
+
* </th>
|
|
133
|
+
* </tr>
|
|
134
|
+
* </thead>
|
|
135
|
+
* <tbody className="bg-white divide-y divide-gray-200">
|
|
136
|
+
* {products.map((product) => (
|
|
137
|
+
* <tr key={product.id} className="hover:bg-gray-50">
|
|
138
|
+
* <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
139
|
+
* #{product.id}
|
|
140
|
+
* </td>
|
|
141
|
+
* <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
|
|
142
|
+
* {product.name}
|
|
143
|
+
* </td>
|
|
144
|
+
* <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
145
|
+
* {product.category}
|
|
146
|
+
* </td>
|
|
147
|
+
* <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
148
|
+
* ${product.price.toFixed(2)}
|
|
149
|
+
* </td>
|
|
150
|
+
* <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
151
|
+
* {product.stock} units
|
|
152
|
+
* </td>
|
|
153
|
+
* </tr>
|
|
154
|
+
* ))}
|
|
155
|
+
* </tbody>
|
|
156
|
+
* </Table>
|
|
157
|
+
*
|
|
158
|
+
* // Financial data table with formatted numbers
|
|
159
|
+
* <Table className="w-full border-collapse">
|
|
160
|
+
* <thead>
|
|
161
|
+
* <tr className="border-b-2 border-gray-300">
|
|
162
|
+
* <th scope="col" className="text-left py-3 px-4">Quarter</th>
|
|
163
|
+
* <th scope="col" className="text-right py-3 px-4">Revenue</th>
|
|
164
|
+
* <th scope="col" className="text-right py-3 px-4">Profit</th>
|
|
165
|
+
* <th scope="col" className="text-right py-3 px-4">Growth</th>
|
|
166
|
+
* </tr>
|
|
167
|
+
* </thead>
|
|
168
|
+
* <tbody>
|
|
169
|
+
* <tr className="border-b border-gray-200">
|
|
170
|
+
* <td className="py-3 px-4 font-medium">Q1 2024</td>
|
|
171
|
+
* <td className="py-3 px-4 text-right">$2,450,000</td>
|
|
172
|
+
* <td className="py-3 px-4 text-right text-green-600">$345,000</td>
|
|
173
|
+
* <td className="py-3 px-4 text-right text-green-600">+12.5%</td>
|
|
174
|
+
* </tr>
|
|
175
|
+
* <tr className="border-b border-gray-200">
|
|
176
|
+
* <td className="py-3 px-4 font-medium">Q2 2024</td>
|
|
177
|
+
* <td className="py-3 px-4 text-right">$2,780,000</td>
|
|
178
|
+
* <td className="py-3 px-4 text-right text-green-600">$398,000</td>
|
|
179
|
+
* <td className="py-3 px-4 text-right text-green-600">+13.5%</td>
|
|
180
|
+
* </tr>
|
|
181
|
+
* </tbody>
|
|
182
|
+
* </Table>
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @see {@link ExpandCollapse} - Component used for collapsible table content
|
|
186
|
+
* @see {@link Modal} - Component used for full-screen table view
|
|
187
|
+
* @see {@link Button} - Component used for the modal trigger button
|
|
188
|
+
*/
|
|
5
189
|
export declare const Table: FC<TableProps>;
|
|
6
190
|
export {};
|
|
7
191
|
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAY,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAM1D,KAAK,UAAU,GAAG,cAAc,CAAC,gBAAgB,CAAC,GAAG;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAqDhC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAY,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAM1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,KAAK,UAAU,GAAG,cAAc,CAAC,gBAAgB,CAAC,GAAG;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwIG;AACH,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAqDhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.mjs","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["'use client';\n\nimport { MoveDiagonal } from 'lucide-react';\nimport { HTMLAttributes, useState, type FC } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ExpandCollapse } from '../ExpandCollapse';\nimport { Modal, ModalSize } from '../Modal';\n\ntype TableProps = HTMLAttributes<HTMLTableElement> & {\n isRollable?: boolean;\n};\n\nexport const Table: FC<TableProps> = ({ className, isRollable, ...props }) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n return (\n <div className=\"relative\">\n <div className=\"sticky top-48 z-10\">\n <div className=\"absolute top-4 right-2\">\n <Button\n variant=\"hoverable\"\n size=\"icon-md\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n label=\"Move\"\n Icon={MoveDiagonal}\n />\n </div>\n </div>\n <ExpandCollapse\n isRollable={isRollable}\n className=\"max-w-full overflow-x-auto\"\n >\n <table\n className={cn(\n 'max-w-full overflow-x-auto table-auto text-left min-w-full bg-background',\n className\n )}\n {...props}\n />\n </ExpandCollapse>\n\n <Modal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n size={ModalSize.XL}\n hasCloseButton\n >\n {isModalOpen ? (\n <div className=\"grid\">\n <table\n className={cn(\n 'max-w-full table-auto text-left min-w-full',\n className\n )}\n {...props}\n />\n </div>\n ) : (\n <></>\n )}\n </Modal>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"Table.mjs","sources":["../../../src/components/Table/Table.tsx"],"sourcesContent":["'use client';\n\nimport { MoveDiagonal } from 'lucide-react';\nimport { HTMLAttributes, useState, type FC } from 'react';\nimport { cn } from '../../utils/cn';\nimport { Button } from '../Button';\nimport { ExpandCollapse } from '../ExpandCollapse';\nimport { Modal, ModalSize } from '../Modal';\n\n/**\n * Properties for the Table component that extends standard HTML table attributes\n *\n * @interface TableProps\n * @extends {HTMLAttributes<HTMLTableElement>}\n *\n * @property {boolean} [isRollable] - Whether the table content can be collapsed/expanded using the ExpandCollapse wrapper\n * @property {string} [className] - Additional CSS classes for custom styling\n * @property {ReactNode} children - The table content including thead, tbody, tfoot elements\n *\n * @example\n * ```tsx\n * // Basic table usage\n * <Table>\n * <thead>\n * <tr>\n * <th>Name</th>\n * <th>Email</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>John Doe</td>\n * <td>john@example.com</td>\n * </tr>\n * </tbody>\n * </Table>\n *\n * // Collapsible table with custom styling\n * <Table isRollable className=\"border border-gray-300 rounded-lg\">\n * <thead>\n * <tr>\n * <th>Product</th>\n * <th>Price</th>\n * <th>Stock</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>Laptop</td>\n * <td>$999</td>\n * <td>15</td>\n * </tr>\n * </tbody>\n * </Table>\n * ```\n */\ntype TableProps = HTMLAttributes<HTMLTableElement> & {\n isRollable?: boolean;\n};\n\n/**\n * Table component that provides an enhanced table experience with modal expansion and collapsible content\n *\n * The Table component wraps a standard HTML table element with additional functionality:\n * - **Modal Expansion**: Click the diagonal arrow button to view the table in a full-screen modal\n * - **Collapsible Content**: Optionally wrap content in an ExpandCollapse component for space-saving\n * - **Responsive Design**: Handles large tables gracefully with modal overflow\n * - **Sticky Controls**: Table controls remain accessible even when scrolling\n *\n * ## Features\n * - **Modal View**: Full-screen modal for better viewing of large tables\n * - **Expand/Collapse**: Optional collapsible wrapper to save space\n * - **Responsive**: Handles overflow and responsive behavior automatically\n * - **Accessibility**: Maintains proper table semantics and keyboard navigation\n * - **Customizable**: Supports all standard HTML table attributes and styling\n *\n * ## Best Practices\n * - Use semantic HTML table structure (thead, tbody, tfoot)\n * - Provide proper column headers with scope attributes\n * - Use the isRollable prop for large tables that might need space management\n * - Apply consistent styling through the className prop\n * - Consider pagination for very large datasets\n *\n * @param {TableProps} props - The properties for the Table component\n * @returns {JSX.Element} The rendered table with enhanced functionality\n *\n * @example\n * ```tsx\n * // Simple data table\n * <Table>\n * <thead>\n * <tr>\n * <th scope=\"col\">Name</th>\n * <th scope=\"col\">Email</th>\n * <th scope=\"col\">Status</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr>\n * <td>John Doe</td>\n * <td>john@example.com</td>\n * <td>\n * <span className=\"px-2 py-1 bg-green-100 text-green-800 rounded-full text-xs\">\n * Active\n * </span>\n * </td>\n * </tr>\n * <tr>\n * <td>Jane Smith</td>\n * <td>jane@example.com</td>\n * <td>\n * <span className=\"px-2 py-1 bg-yellow-100 text-yellow-800 rounded-full text-xs\">\n * Pending\n * </span>\n * </td>\n * </tr>\n * </tbody>\n * </Table>\n *\n * // Large collapsible table with custom styling\n * <Table\n * isRollable\n * className=\"border border-gray-200 rounded-lg overflow-hidden\"\n * >\n * <thead className=\"bg-gray-50\">\n * <tr>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Product ID\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Name\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Category\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Price\n * </th>\n * <th scope=\"col\" className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">\n * Stock\n * </th>\n * </tr>\n * </thead>\n * <tbody className=\"bg-white divide-y divide-gray-200\">\n * {products.map((product) => (\n * <tr key={product.id} className=\"hover:bg-gray-50\">\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-900\">\n * #{product.id}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900\">\n * {product.name}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n * {product.category}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-900\">\n * ${product.price.toFixed(2)}\n * </td>\n * <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n * {product.stock} units\n * </td>\n * </tr>\n * ))}\n * </tbody>\n * </Table>\n *\n * // Financial data table with formatted numbers\n * <Table className=\"w-full border-collapse\">\n * <thead>\n * <tr className=\"border-b-2 border-gray-300\">\n * <th scope=\"col\" className=\"text-left py-3 px-4\">Quarter</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Revenue</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Profit</th>\n * <th scope=\"col\" className=\"text-right py-3 px-4\">Growth</th>\n * </tr>\n * </thead>\n * <tbody>\n * <tr className=\"border-b border-gray-200\">\n * <td className=\"py-3 px-4 font-medium\">Q1 2024</td>\n * <td className=\"py-3 px-4 text-right\">$2,450,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">$345,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">+12.5%</td>\n * </tr>\n * <tr className=\"border-b border-gray-200\">\n * <td className=\"py-3 px-4 font-medium\">Q2 2024</td>\n * <td className=\"py-3 px-4 text-right\">$2,780,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">$398,000</td>\n * <td className=\"py-3 px-4 text-right text-green-600\">+13.5%</td>\n * </tr>\n * </tbody>\n * </Table>\n * ```\n *\n * @see {@link ExpandCollapse} - Component used for collapsible table content\n * @see {@link Modal} - Component used for full-screen table view\n * @see {@link Button} - Component used for the modal trigger button\n */\nexport const Table: FC<TableProps> = ({ className, isRollable, ...props }) => {\n const [isModalOpen, setIsModalOpen] = useState(false);\n\n return (\n <div className=\"relative\">\n <div className=\"sticky top-48 z-10\">\n <div className=\"absolute top-4 right-2\">\n <Button\n variant=\"hoverable\"\n size=\"icon-md\"\n onClick={() => {\n setIsModalOpen(true);\n }}\n label=\"Move\"\n Icon={MoveDiagonal}\n />\n </div>\n </div>\n <ExpandCollapse\n isRollable={isRollable}\n className=\"max-w-full overflow-x-auto\"\n >\n <table\n className={cn(\n 'max-w-full overflow-x-auto table-auto text-left min-w-full bg-background',\n className\n )}\n {...props}\n />\n </ExpandCollapse>\n\n <Modal\n isOpen={isModalOpen}\n onClose={() => setIsModalOpen(false)}\n size={ModalSize.XL}\n hasCloseButton\n >\n {isModalOpen ? (\n <div className=\"grid\">\n <table\n className={cn(\n 'max-w-full table-auto text-left min-w-full',\n className\n )}\n {...props}\n />\n </div>\n ) : (\n <></>\n )}\n </Modal>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAqMO,MAAM,QAAwB,CAAC,EAAE,WAAW,YAAY,GAAG,YAAY;AAC5E,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAEpD,SACE,qBAAC,OAAA,EAAI,WAAU,YACb,UAAA;AAAA,IAAA,oBAAC,SAAI,WAAU,sBACb,UAAA,oBAAC,OAAA,EAAI,WAAU,0BACb,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAS,MAAM;AACb,yBAAe,IAAI;AAAA,QACrB;AAAA,QACA,OAAM;AAAA,QACN,MAAM;AAAA,MAAA;AAAA,IAAA,GAEV,EAAA,CACF;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAU;AAAA,QAEV,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAED,GAAG;AAAA,UAAA;AAAA,QAAA;AAAA,MACN;AAAA,IAAA;AAAA,IAGF;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS,MAAM,eAAe,KAAK;AAAA,QACnC,MAAM,UAAU;AAAA,QAChB,gBAAc;AAAA,QAEb,UAAA,cACC,oBAAC,OAAA,EAAI,WAAU,QACb,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,YAAA;AAAA,YAED,GAAG;AAAA,UAAA;AAAA,QAAA,GAER,IAEA,oBAAA,UAAA,CAAA,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAEN,GACF;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/Tag/index.tsx"],"sourcesContent":["import { type VariantProps, cva } from 'class-variance-authority';\nimport type { FC, HTMLAttributes, PropsWithChildren } from 'react';\n\ntype TagProps = PropsWithChildren<VariantProps<typeof containerVariants>> &\n HTMLAttributes<HTMLDivElement>;\n\nexport enum TagRoundedSize {\n NONE = 'none',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n XXL = '2xl',\n XXXL = '3xl',\n FULL = 'full',\n}\n\nexport enum TagColor {\n SUCCESS = 'success',\n ERROR = 'error',\n WARNING = 'warning',\n NEUTRAL = 'neutral',\n TEXT = 'text',\n}\n\nexport enum TagSize {\n XS = 'xs',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n}\n\nexport enum TagBorder {\n NONE = 'none',\n WITH = 'with',\n}\n\nexport enum TagBackground {\n NONE = 'none',\n WITH = 'with',\n}\n\nconst containerVariants = cva('backdrop-blur w-fit', {\n variants: {\n roundedSize: {\n [`${TagRoundedSize.NONE}`]: 'rounded-none',\n [`${TagRoundedSize.SM}`]: 'rounded-sm',\n [`${TagRoundedSize.MD}`]: 'rounded-md',\n [`${TagRoundedSize.LG}`]: 'rounded-lg',\n [`${TagRoundedSize.XL}`]: 'rounded-xl',\n [`${TagRoundedSize.XXL}`]: 'rounded-2xl',\n [`${TagRoundedSize.XXXL}`]: 'rounded-3xl',\n [`${TagRoundedSize.FULL}`]: 'rounded-full',\n },\n color: {\n [`${TagColor.SUCCESS}`]: 'bg-success/10 border-success text-success ',\n [`${TagColor.ERROR}`]: 'bg-error/10 border-error text-error',\n [`${TagColor.WARNING}`]: 'bg-warning/10 border-warning text-warning',\n [`${TagColor.NEUTRAL}`]: 'bg-neutral/10 /10 border-neutral text-neutral ',\n [`${TagColor.TEXT}`]: 'bg-text/10 border-text text-text',\n },\n size: {\n [`${TagSize.XS}`]: 'py-0.5 px-2 text-xs border-[1.2px]',\n [`${TagSize.SM}`]: 'py-0.5 px-2 text-sm border-[1.5px]',\n [`${TagSize.MD}`]: 'py-1 px-2 text-base border-2',\n [`${TagSize.LG}`]: 'py-2 px-3 text-lg border-2',\n [`${TagSize.XL}`]: 'py-4 px-5 text-xl border-2',\n },\n border: {\n [`${TagBorder.NONE}`]: 'border-none',\n [`${TagBorder.WITH}`]: 'border-text border-[1.5px]',\n },\n background: {\n [`${TagBackground.NONE}`]: 'bg-none',\n [`${TagBackground.WITH}`]: '',\n },\n },\n\n defaultVariants: {\n roundedSize: TagRoundedSize.FULL,\n border: TagBorder.NONE,\n color: TagColor.TEXT,\n size: TagSize.MD,\n },\n});\n\nexport const Tag: FC<TagProps> = ({\n children,\n color,\n roundedSize,\n size,\n border,\n background,\n className,\n ...props\n}) => {\n return (\n <div\n className={containerVariants({\n color,\n roundedSize,\n size,\n border,\n background,\n className,\n })}\n {...props}\n >\n {children}\n </div>\n );\n};\n"],"names":["TagRoundedSize","TagColor","TagSize","TagBorder","TagBackground","cva","jsx"],"mappings":";;;;AA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MAAA,CACD;AAAA,MACA,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/Tag/index.tsx"],"sourcesContent":["import { type VariantProps, cva } from 'class-variance-authority';\nimport type { FC, HTMLAttributes, PropsWithChildren } from 'react';\n\n/**\n * Properties for the Tag component extending HTML div attributes and variant options\n *\n * @interface TagProps\n * @extends {PropsWithChildren<VariantProps<typeof containerVariants>>}\n * @extends {HTMLAttributes<HTMLDivElement>}\n *\n * @property {ReactNode} children - The content to display inside the tag\n * @property {TagColor} [color] - Color theme variant of the tag\n * @property {TagRoundedSize} [roundedSize] - Border radius size of the tag\n * @property {TagSize} [size] - Size variant affecting padding and font size\n * @property {TagBorder} [border] - Whether to show a border around the tag\n * @property {TagBackground} [background] - Background visibility option\n * @property {string} [className] - Additional CSS classes for custom styling\n *\n * @example\n * ```tsx\n * // Basic tag\n * <Tag>Default Tag</Tag>\n *\n * // Success tag with border\n * <Tag color={TagColor.SUCCESS} border={TagBorder.WITH}>\n * Success Status\n * </Tag>\n *\n * // Large warning tag\n * <Tag color={TagColor.WARNING} size={TagSize.LG}>\n * Important Warning\n * </Tag>\n * ```\n */\ntype TagProps = PropsWithChildren<VariantProps<typeof containerVariants>> &\n HTMLAttributes<HTMLDivElement>;\n\n/**\n * Enumeration for tag border radius sizes\n *\n * Controls the roundedness of tag corners, from sharp edges to fully rounded pills.\n *\n * @enum {string} TagRoundedSize\n * @property {string} NONE - 'none' - No border radius (sharp corners)\n * @property {string} SM - 'sm' - Small border radius (2px)\n * @property {string} MD - 'md' - Medium border radius (6px)\n * @property {string} LG - 'lg' - Large border radius (8px)\n * @property {string} XL - 'xl' - Extra large border radius (12px)\n * @property {string} XXL - '2xl' - 2x large border radius (16px)\n * @property {string} XXXL - '3xl' - 3x large border radius (24px)\n * @property {string} FULL - 'full' - Fully rounded (50% border radius, pill shape)\n *\n * @example\n * ```tsx\n * // Sharp corners\n * <Tag roundedSize={TagRoundedSize.NONE}>Sharp Tag</Tag>\n *\n * // Pill-shaped tag\n * <Tag roundedSize={TagRoundedSize.FULL}>Pill Tag</Tag>\n *\n * // Medium rounded corners\n * <Tag roundedSize={TagRoundedSize.MD}>Rounded Tag</Tag>\n * ```\n */\nexport enum TagRoundedSize {\n NONE = 'none',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n XXL = '2xl',\n XXXL = '3xl',\n FULL = 'full',\n}\n\n/**\n * Enumeration for tag color themes\n *\n * Provides semantic color options for different tag purposes and meanings.\n * Each color includes background, border, and text color variations.\n *\n * @enum {string} TagColor\n * @property {string} SUCCESS - 'success' - Green theme for positive states, success messages, or completed items\n * @property {string} ERROR - 'error' - Red theme for error states, warnings, or failed operations\n * @property {string} WARNING - 'warning' - Yellow/orange theme for caution, pending states, or important notices\n * @property {string} NEUTRAL - 'neutral' - Gray theme for neutral information or secondary content\n * @property {string} TEXT - 'text' - Default text color theme for general purpose tags\n *\n * @example\n * ```tsx\n * // Status indicators\n * <Tag color={TagColor.SUCCESS}>Completed</Tag>\n * <Tag color={TagColor.ERROR}>Failed</Tag>\n * <Tag color={TagColor.WARNING}>Pending</Tag>\n *\n * // Category tags\n * <Tag color={TagColor.NEUTRAL}>Category</Tag>\n * <Tag color={TagColor.TEXT}>General</Tag>\n * ```\n */\nexport enum TagColor {\n SUCCESS = 'success',\n ERROR = 'error',\n WARNING = 'warning',\n NEUTRAL = 'neutral',\n TEXT = 'text',\n}\n\n/**\n * Enumeration for tag size variants\n *\n * Controls the overall size of tags including padding, font size, and border thickness.\n * Sizes are designed to maintain visual hierarchy and readability.\n *\n * @enum {string} TagSize\n * @property {string} XS - 'xs' - Extra small (0.5rem padding, text-xs, 1.2px border)\n * @property {string} SM - 'sm' - Small (0.5rem padding, text-sm, 1.5px border)\n * @property {string} MD - 'md' - Medium (1rem padding, text-base, 2px border) - Default size\n * @property {string} LG - 'lg' - Large (2rem padding, text-lg, 2px border)\n * @property {string} XL - 'xl' - Extra large (4rem padding, text-xl, 2px border)\n *\n * @example\n * ```tsx\n * // Different sizes for hierarchy\n * <Tag size={TagSize.XS}>Small detail</Tag>\n * <Tag size={TagSize.SM}>Minor category</Tag>\n * <Tag size={TagSize.MD}>Standard tag</Tag>\n * <Tag size={TagSize.LG}>Important label</Tag>\n * <Tag size={TagSize.XL}>Hero tag</Tag>\n * ```\n */\nexport enum TagSize {\n XS = 'xs',\n SM = 'sm',\n MD = 'md',\n LG = 'lg',\n XL = 'xl',\n}\n\n/**\n * Enumeration for tag border visibility\n *\n * Controls whether a border is displayed around the tag.\n *\n * @enum {string} TagBorder\n * @property {string} NONE - 'none' - No border (default)\n * @property {string} WITH - 'with' - Show border with 1.5px thickness\n *\n * @example\n * ```tsx\n * <Tag border={TagBorder.NONE}>Borderless</Tag>\n * <Tag border={TagBorder.WITH}>With Border</Tag>\n * ```\n */\nexport enum TagBorder {\n NONE = 'none',\n WITH = 'with',\n}\n\n/**\n * Enumeration for tag background visibility\n *\n * Controls the background styling of the tag.\n *\n * @enum {string} TagBackground\n * @property {string} NONE - 'none' - No background styling\n * @property {string} WITH - 'with' - Apply background styling\n *\n * @example\n * ```tsx\n * <Tag background={TagBackground.NONE}>No Background</Tag>\n * <Tag background={TagBackground.WITH}>With Background</Tag>\n * ```\n */\nexport enum TagBackground {\n NONE = 'none',\n WITH = 'with',\n}\n\nconst containerVariants = cva('backdrop-blur w-fit', {\n variants: {\n roundedSize: {\n [`${TagRoundedSize.NONE}`]: 'rounded-none',\n [`${TagRoundedSize.SM}`]: 'rounded-sm',\n [`${TagRoundedSize.MD}`]: 'rounded-md',\n [`${TagRoundedSize.LG}`]: 'rounded-lg',\n [`${TagRoundedSize.XL}`]: 'rounded-xl',\n [`${TagRoundedSize.XXL}`]: 'rounded-2xl',\n [`${TagRoundedSize.XXXL}`]: 'rounded-3xl',\n [`${TagRoundedSize.FULL}`]: 'rounded-full',\n },\n color: {\n [`${TagColor.SUCCESS}`]: 'bg-success/10 border-success text-success ',\n [`${TagColor.ERROR}`]: 'bg-error/10 border-error text-error',\n [`${TagColor.WARNING}`]: 'bg-warning/10 border-warning text-warning',\n [`${TagColor.NEUTRAL}`]: 'bg-neutral/10 /10 border-neutral text-neutral ',\n [`${TagColor.TEXT}`]: 'bg-text/10 border-text text-text',\n },\n size: {\n [`${TagSize.XS}`]: 'py-0.5 px-2 text-xs border-[1.2px]',\n [`${TagSize.SM}`]: 'py-0.5 px-2 text-sm border-[1.5px]',\n [`${TagSize.MD}`]: 'py-1 px-2 text-base border-2',\n [`${TagSize.LG}`]: 'py-2 px-3 text-lg border-2',\n [`${TagSize.XL}`]: 'py-4 px-5 text-xl border-2',\n },\n border: {\n [`${TagBorder.NONE}`]: 'border-none',\n [`${TagBorder.WITH}`]: 'border-text border-[1.5px]',\n },\n background: {\n [`${TagBackground.NONE}`]: 'bg-none',\n [`${TagBackground.WITH}`]: '',\n },\n },\n\n defaultVariants: {\n roundedSize: TagRoundedSize.FULL,\n border: TagBorder.NONE,\n color: TagColor.TEXT,\n size: TagSize.MD,\n },\n});\n\n/**\n * Tag component for displaying labels, categories, status indicators, and badges\n *\n * The Tag component is a versatile labeling element that supports multiple visual variants\n * for different use cases. It provides semantic color options, flexible sizing, and\n * customizable styling options for borders and backgrounds.\n *\n * ## Features\n * - **Semantic Colors**: Success, error, warning, neutral, and text color themes\n * - **Flexible Sizing**: Five size variants from extra small to extra large\n * - **Border Radius Options**: Eight rounding options from none to fully rounded\n * - **Border Control**: Optional borders for enhanced visual separation\n * - **Background Control**: Configurable background styling\n * - **Accessibility**: Proper HTML semantics and keyboard navigation support\n *\n * ## Use Cases\n * - **Status Indicators**: Show completion, error, or pending states\n * - **Category Labels**: Organize and categorize content\n * - **Badges**: Display counts, notifications, or achievements\n * - **Keywords**: Tag content with relevant keywords or topics\n * - **Metadata**: Show additional information like dates, authors, or types\n *\n * ## Design Principles\n * - Maintains readability across all size and color combinations\n * - Uses backdrop blur effect for subtle transparency\n * - Follows consistent spacing and typography scales\n * - Provides sufficient color contrast for accessibility\n *\n * @param {TagProps} props - The properties for the Tag component\n * @returns {JSX.Element} The rendered tag element\n *\n * @example\n * ```tsx\n * // Basic status tags\n * <Tag color={TagColor.SUCCESS}>Completed</Tag>\n * <Tag color={TagColor.ERROR}>Failed</Tag>\n * <Tag color={TagColor.WARNING}>In Progress</Tag>\n *\n * // Category tags with borders\n * <Tag color={TagColor.NEUTRAL} border={TagBorder.WITH}>\n * Technology\n * </Tag>\n * <Tag color={TagColor.TEXT} border={TagBorder.WITH}>\n * Design\n * </Tag>\n *\n * // Size variations for hierarchy\n * <div className=\"flex items-center gap-2\">\n * <Tag size={TagSize.XS} color={TagColor.NEUTRAL}>Minor</Tag>\n * <Tag size={TagSize.SM} color={TagColor.TEXT}>Standard</Tag>\n * <Tag size={TagSize.LG} color={TagColor.SUCCESS}>Important</Tag>\n * </div>\n *\n * // Rounded variations\n * <div className=\"flex gap-2\">\n * <Tag roundedSize={TagRoundedSize.NONE}>Sharp</Tag>\n * <Tag roundedSize={TagRoundedSize.MD}>Rounded</Tag>\n * <Tag roundedSize={TagRoundedSize.FULL}>Pill</Tag>\n * </div>\n *\n * // Custom styled tag\n * <Tag\n * color={TagColor.WARNING}\n * size={TagSize.LG}\n * border={TagBorder.WITH}\n * roundedSize={TagRoundedSize.LG}\n * className=\"font-bold uppercase tracking-wide\"\n * >\n * Custom Style\n * </Tag>\n *\n * // Interactive tags with click handlers\n * <Tag\n * color={TagColor.SUCCESS}\n * onClick={() => console.log('Tag clicked')}\n * className=\"cursor-pointer hover:opacity-80 transition-opacity\"\n * >\n * Clickable Tag\n * </Tag>\n * ```\n *\n * @see {@link TagColor} - Available color theme options\n * @see {@link TagSize} - Available size variants\n * @see {@link TagRoundedSize} - Available border radius options\n * @see {@link TagBorder} - Border visibility options\n * @see {@link TagBackground} - Background styling options\n */\nexport const Tag: FC<TagProps> = ({\n children,\n color,\n roundedSize,\n size,\n border,\n background,\n className,\n ...props\n}) => {\n return (\n <div\n className={containerVariants({\n color,\n roundedSize,\n size,\n border,\n background,\n className,\n })}\n {...props}\n >\n {children}\n </div>\n );\n};\n"],"names":["TagRoundedSize","TagColor","TagSize","TagBorder","TagBackground","cva","jsx"],"mappings":";;;;AAgEO,IAAK,mCAAAA,oBAAL;AACLA,kBAAA,MAAA,IAAO;AACPA,kBAAA,IAAA,IAAK;AACLA,kBAAA,IAAA,IAAK;AACLA,kBAAA,IAAA,IAAK;AACLA,kBAAA,IAAA,IAAK;AACLA,kBAAA,KAAA,IAAM;AACNA,kBAAA,MAAA,IAAO;AACPA,kBAAA,MAAA,IAAO;AARG,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;AAoCL,IAAK,6BAAAC,cAAL;AACLA,YAAA,SAAA,IAAU;AACVA,YAAA,OAAA,IAAQ;AACRA,YAAA,SAAA,IAAU;AACVA,YAAA,SAAA,IAAU;AACVA,YAAA,MAAA,IAAO;AALG,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AA+BL,IAAK,4BAAAC,aAAL;AACLA,WAAA,IAAA,IAAK;AACLA,WAAA,IAAA,IAAK;AACLA,WAAA,IAAA,IAAK;AACLA,WAAA,IAAA,IAAK;AACLA,WAAA,IAAA,IAAK;AALK,SAAAA;AAAA,GAAA,WAAA,CAAA,CAAA;AAuBL,IAAK,8BAAAC,eAAL;AACLA,aAAA,MAAA,IAAO;AACPA,aAAA,MAAA,IAAO;AAFG,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAoBL,IAAK,kCAAAC,mBAAL;AACLA,iBAAA,MAAA,IAAO;AACPA,iBAAA,MAAA,IAAO;AAFG,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAKZ,MAAM,oBAAoBC,uBAAAA,IAAI,uBAAuB;AAAA,EACnD,UAAU;AAAA,IACR,aAAa;AAAA,MACX,CAAC,GAAG,MAAA,EAAqB,GAAG;AAAA,MAC5B,CAAC,GAAG,IAAA,EAAmB,GAAG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EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,kBAAkB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,MACA,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;;;;;;;"}
|
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
2
|
import { FC, HTMLAttributes, PropsWithChildren } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Properties for the Tag component extending HTML div attributes and variant options
|
|
5
|
+
*
|
|
6
|
+
* @interface TagProps
|
|
7
|
+
* @extends {PropsWithChildren<VariantProps<typeof containerVariants>>}
|
|
8
|
+
* @extends {HTMLAttributes<HTMLDivElement>}
|
|
9
|
+
*
|
|
10
|
+
* @property {ReactNode} children - The content to display inside the tag
|
|
11
|
+
* @property {TagColor} [color] - Color theme variant of the tag
|
|
12
|
+
* @property {TagRoundedSize} [roundedSize] - Border radius size of the tag
|
|
13
|
+
* @property {TagSize} [size] - Size variant affecting padding and font size
|
|
14
|
+
* @property {TagBorder} [border] - Whether to show a border around the tag
|
|
15
|
+
* @property {TagBackground} [background] - Background visibility option
|
|
16
|
+
* @property {string} [className] - Additional CSS classes for custom styling
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Basic tag
|
|
21
|
+
* <Tag>Default Tag</Tag>
|
|
22
|
+
*
|
|
23
|
+
* // Success tag with border
|
|
24
|
+
* <Tag color={TagColor.SUCCESS} border={TagBorder.WITH}>
|
|
25
|
+
* Success Status
|
|
26
|
+
* </Tag>
|
|
27
|
+
*
|
|
28
|
+
* // Large warning tag
|
|
29
|
+
* <Tag color={TagColor.WARNING} size={TagSize.LG}>
|
|
30
|
+
* Important Warning
|
|
31
|
+
* </Tag>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
3
34
|
type TagProps = PropsWithChildren<VariantProps<typeof containerVariants>> & HTMLAttributes<HTMLDivElement>;
|
|
35
|
+
/**
|
|
36
|
+
* Enumeration for tag border radius sizes
|
|
37
|
+
*
|
|
38
|
+
* Controls the roundedness of tag corners, from sharp edges to fully rounded pills.
|
|
39
|
+
*
|
|
40
|
+
* @enum {string} TagRoundedSize
|
|
41
|
+
* @property {string} NONE - 'none' - No border radius (sharp corners)
|
|
42
|
+
* @property {string} SM - 'sm' - Small border radius (2px)
|
|
43
|
+
* @property {string} MD - 'md' - Medium border radius (6px)
|
|
44
|
+
* @property {string} LG - 'lg' - Large border radius (8px)
|
|
45
|
+
* @property {string} XL - 'xl' - Extra large border radius (12px)
|
|
46
|
+
* @property {string} XXL - '2xl' - 2x large border radius (16px)
|
|
47
|
+
* @property {string} XXXL - '3xl' - 3x large border radius (24px)
|
|
48
|
+
* @property {string} FULL - 'full' - Fully rounded (50% border radius, pill shape)
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* // Sharp corners
|
|
53
|
+
* <Tag roundedSize={TagRoundedSize.NONE}>Sharp Tag</Tag>
|
|
54
|
+
*
|
|
55
|
+
* // Pill-shaped tag
|
|
56
|
+
* <Tag roundedSize={TagRoundedSize.FULL}>Pill Tag</Tag>
|
|
57
|
+
*
|
|
58
|
+
* // Medium rounded corners
|
|
59
|
+
* <Tag roundedSize={TagRoundedSize.MD}>Rounded Tag</Tag>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
4
62
|
export declare enum TagRoundedSize {
|
|
5
63
|
NONE = "none",
|
|
6
64
|
SM = "sm",
|
|
@@ -11,6 +69,31 @@ export declare enum TagRoundedSize {
|
|
|
11
69
|
XXXL = "3xl",
|
|
12
70
|
FULL = "full"
|
|
13
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Enumeration for tag color themes
|
|
74
|
+
*
|
|
75
|
+
* Provides semantic color options for different tag purposes and meanings.
|
|
76
|
+
* Each color includes background, border, and text color variations.
|
|
77
|
+
*
|
|
78
|
+
* @enum {string} TagColor
|
|
79
|
+
* @property {string} SUCCESS - 'success' - Green theme for positive states, success messages, or completed items
|
|
80
|
+
* @property {string} ERROR - 'error' - Red theme for error states, warnings, or failed operations
|
|
81
|
+
* @property {string} WARNING - 'warning' - Yellow/orange theme for caution, pending states, or important notices
|
|
82
|
+
* @property {string} NEUTRAL - 'neutral' - Gray theme for neutral information or secondary content
|
|
83
|
+
* @property {string} TEXT - 'text' - Default text color theme for general purpose tags
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* // Status indicators
|
|
88
|
+
* <Tag color={TagColor.SUCCESS}>Completed</Tag>
|
|
89
|
+
* <Tag color={TagColor.ERROR}>Failed</Tag>
|
|
90
|
+
* <Tag color={TagColor.WARNING}>Pending</Tag>
|
|
91
|
+
*
|
|
92
|
+
* // Category tags
|
|
93
|
+
* <Tag color={TagColor.NEUTRAL}>Category</Tag>
|
|
94
|
+
* <Tag color={TagColor.TEXT}>General</Tag>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
14
97
|
export declare enum TagColor {
|
|
15
98
|
SUCCESS = "success",
|
|
16
99
|
ERROR = "error",
|
|
@@ -18,6 +101,29 @@ export declare enum TagColor {
|
|
|
18
101
|
NEUTRAL = "neutral",
|
|
19
102
|
TEXT = "text"
|
|
20
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Enumeration for tag size variants
|
|
106
|
+
*
|
|
107
|
+
* Controls the overall size of tags including padding, font size, and border thickness.
|
|
108
|
+
* Sizes are designed to maintain visual hierarchy and readability.
|
|
109
|
+
*
|
|
110
|
+
* @enum {string} TagSize
|
|
111
|
+
* @property {string} XS - 'xs' - Extra small (0.5rem padding, text-xs, 1.2px border)
|
|
112
|
+
* @property {string} SM - 'sm' - Small (0.5rem padding, text-sm, 1.5px border)
|
|
113
|
+
* @property {string} MD - 'md' - Medium (1rem padding, text-base, 2px border) - Default size
|
|
114
|
+
* @property {string} LG - 'lg' - Large (2rem padding, text-lg, 2px border)
|
|
115
|
+
* @property {string} XL - 'xl' - Extra large (4rem padding, text-xl, 2px border)
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```tsx
|
|
119
|
+
* // Different sizes for hierarchy
|
|
120
|
+
* <Tag size={TagSize.XS}>Small detail</Tag>
|
|
121
|
+
* <Tag size={TagSize.SM}>Minor category</Tag>
|
|
122
|
+
* <Tag size={TagSize.MD}>Standard tag</Tag>
|
|
123
|
+
* <Tag size={TagSize.LG}>Important label</Tag>
|
|
124
|
+
* <Tag size={TagSize.XL}>Hero tag</Tag>
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
21
127
|
export declare enum TagSize {
|
|
22
128
|
XS = "xs",
|
|
23
129
|
SM = "sm",
|
|
@@ -25,10 +131,40 @@ export declare enum TagSize {
|
|
|
25
131
|
LG = "lg",
|
|
26
132
|
XL = "xl"
|
|
27
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Enumeration for tag border visibility
|
|
136
|
+
*
|
|
137
|
+
* Controls whether a border is displayed around the tag.
|
|
138
|
+
*
|
|
139
|
+
* @enum {string} TagBorder
|
|
140
|
+
* @property {string} NONE - 'none' - No border (default)
|
|
141
|
+
* @property {string} WITH - 'with' - Show border with 1.5px thickness
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* <Tag border={TagBorder.NONE}>Borderless</Tag>
|
|
146
|
+
* <Tag border={TagBorder.WITH}>With Border</Tag>
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
28
149
|
export declare enum TagBorder {
|
|
29
150
|
NONE = "none",
|
|
30
151
|
WITH = "with"
|
|
31
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Enumeration for tag background visibility
|
|
155
|
+
*
|
|
156
|
+
* Controls the background styling of the tag.
|
|
157
|
+
*
|
|
158
|
+
* @enum {string} TagBackground
|
|
159
|
+
* @property {string} NONE - 'none' - No background styling
|
|
160
|
+
* @property {string} WITH - 'with' - Apply background styling
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```tsx
|
|
164
|
+
* <Tag background={TagBackground.NONE}>No Background</Tag>
|
|
165
|
+
* <Tag background={TagBackground.WITH}>With Background</Tag>
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
32
168
|
export declare enum TagBackground {
|
|
33
169
|
NONE = "none",
|
|
34
170
|
WITH = "with"
|
|
@@ -40,6 +176,93 @@ declare const containerVariants: (props?: ({
|
|
|
40
176
|
border?: "none" | "with" | null | undefined;
|
|
41
177
|
background?: "none" | "with" | null | undefined;
|
|
42
178
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
179
|
+
/**
|
|
180
|
+
* Tag component for displaying labels, categories, status indicators, and badges
|
|
181
|
+
*
|
|
182
|
+
* The Tag component is a versatile labeling element that supports multiple visual variants
|
|
183
|
+
* for different use cases. It provides semantic color options, flexible sizing, and
|
|
184
|
+
* customizable styling options for borders and backgrounds.
|
|
185
|
+
*
|
|
186
|
+
* ## Features
|
|
187
|
+
* - **Semantic Colors**: Success, error, warning, neutral, and text color themes
|
|
188
|
+
* - **Flexible Sizing**: Five size variants from extra small to extra large
|
|
189
|
+
* - **Border Radius Options**: Eight rounding options from none to fully rounded
|
|
190
|
+
* - **Border Control**: Optional borders for enhanced visual separation
|
|
191
|
+
* - **Background Control**: Configurable background styling
|
|
192
|
+
* - **Accessibility**: Proper HTML semantics and keyboard navigation support
|
|
193
|
+
*
|
|
194
|
+
* ## Use Cases
|
|
195
|
+
* - **Status Indicators**: Show completion, error, or pending states
|
|
196
|
+
* - **Category Labels**: Organize and categorize content
|
|
197
|
+
* - **Badges**: Display counts, notifications, or achievements
|
|
198
|
+
* - **Keywords**: Tag content with relevant keywords or topics
|
|
199
|
+
* - **Metadata**: Show additional information like dates, authors, or types
|
|
200
|
+
*
|
|
201
|
+
* ## Design Principles
|
|
202
|
+
* - Maintains readability across all size and color combinations
|
|
203
|
+
* - Uses backdrop blur effect for subtle transparency
|
|
204
|
+
* - Follows consistent spacing and typography scales
|
|
205
|
+
* - Provides sufficient color contrast for accessibility
|
|
206
|
+
*
|
|
207
|
+
* @param {TagProps} props - The properties for the Tag component
|
|
208
|
+
* @returns {JSX.Element} The rendered tag element
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```tsx
|
|
212
|
+
* // Basic status tags
|
|
213
|
+
* <Tag color={TagColor.SUCCESS}>Completed</Tag>
|
|
214
|
+
* <Tag color={TagColor.ERROR}>Failed</Tag>
|
|
215
|
+
* <Tag color={TagColor.WARNING}>In Progress</Tag>
|
|
216
|
+
*
|
|
217
|
+
* // Category tags with borders
|
|
218
|
+
* <Tag color={TagColor.NEUTRAL} border={TagBorder.WITH}>
|
|
219
|
+
* Technology
|
|
220
|
+
* </Tag>
|
|
221
|
+
* <Tag color={TagColor.TEXT} border={TagBorder.WITH}>
|
|
222
|
+
* Design
|
|
223
|
+
* </Tag>
|
|
224
|
+
*
|
|
225
|
+
* // Size variations for hierarchy
|
|
226
|
+
* <div className="flex items-center gap-2">
|
|
227
|
+
* <Tag size={TagSize.XS} color={TagColor.NEUTRAL}>Minor</Tag>
|
|
228
|
+
* <Tag size={TagSize.SM} color={TagColor.TEXT}>Standard</Tag>
|
|
229
|
+
* <Tag size={TagSize.LG} color={TagColor.SUCCESS}>Important</Tag>
|
|
230
|
+
* </div>
|
|
231
|
+
*
|
|
232
|
+
* // Rounded variations
|
|
233
|
+
* <div className="flex gap-2">
|
|
234
|
+
* <Tag roundedSize={TagRoundedSize.NONE}>Sharp</Tag>
|
|
235
|
+
* <Tag roundedSize={TagRoundedSize.MD}>Rounded</Tag>
|
|
236
|
+
* <Tag roundedSize={TagRoundedSize.FULL}>Pill</Tag>
|
|
237
|
+
* </div>
|
|
238
|
+
*
|
|
239
|
+
* // Custom styled tag
|
|
240
|
+
* <Tag
|
|
241
|
+
* color={TagColor.WARNING}
|
|
242
|
+
* size={TagSize.LG}
|
|
243
|
+
* border={TagBorder.WITH}
|
|
244
|
+
* roundedSize={TagRoundedSize.LG}
|
|
245
|
+
* className="font-bold uppercase tracking-wide"
|
|
246
|
+
* >
|
|
247
|
+
* Custom Style
|
|
248
|
+
* </Tag>
|
|
249
|
+
*
|
|
250
|
+
* // Interactive tags with click handlers
|
|
251
|
+
* <Tag
|
|
252
|
+
* color={TagColor.SUCCESS}
|
|
253
|
+
* onClick={() => console.log('Tag clicked')}
|
|
254
|
+
* className="cursor-pointer hover:opacity-80 transition-opacity"
|
|
255
|
+
* >
|
|
256
|
+
* Clickable Tag
|
|
257
|
+
* </Tag>
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @see {@link TagColor} - Available color theme options
|
|
261
|
+
* @see {@link TagSize} - Available size variants
|
|
262
|
+
* @see {@link TagRoundedSize} - Available border radius options
|
|
263
|
+
* @see {@link TagBorder} - Border visibility options
|
|
264
|
+
* @see {@link TagBackground} - Background styling options
|
|
265
|
+
*/
|
|
43
266
|
export declare const Tag: FC<TagProps>;
|
|
44
267
|
export {};
|
|
45
268
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnE,KAAK,QAAQ,GAAG,iBAAiB,CAAC,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAAC,GACvE,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjC,oBAAY,cAAc;IACxB,IAAI,SAAS;IACb,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,GAAG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