From 38913e51536ecf1c8e924a6de571880cb91d2ea0 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Mon, 9 Sep 2024 21:57:48 +0600 Subject: [PATCH] fix: autocomplete for string enums with dynamic value not working (#1484) * fix: typescript autocomplete for string enums accepting dynamic values not working * chore: add missing imports * chore: format and lint changes * chore: add changeset --- .changeset/plenty-lemons-bow.md | 5 +++++ packages/ui/src/components/Alert/Alert.tsx | 4 ++-- packages/ui/src/components/Avatar/Avatar.tsx | 6 +++--- packages/ui/src/components/Badge/Badge.tsx | 6 +++--- packages/ui/src/components/Button/Button.tsx | 10 +++++----- packages/ui/src/components/Checkbox/Checkbox.tsx | 4 ++-- packages/ui/src/components/FileInput/FileInput.tsx | 6 +++--- packages/ui/src/components/HelperText/HelperText.tsx | 4 ++-- packages/ui/src/components/Label/Label.tsx | 4 ++-- packages/ui/src/components/Modal/Modal.tsx | 6 +++--- packages/ui/src/components/Progress/Progress.tsx | 4 ++-- packages/ui/src/components/RangeSlider/RangeSlider.tsx | 4 ++-- packages/ui/src/components/Rating/Rating.tsx | 4 ++-- packages/ui/src/components/Rating/RatingContext.tsx | 3 ++- packages/ui/src/components/Select/Select.tsx | 6 +++--- packages/ui/src/components/Sidebar/SidebarCTA.tsx | 4 ++-- packages/ui/src/components/Sidebar/SidebarItem.tsx | 4 ++-- packages/ui/src/components/Spinner/Spinner.tsx | 6 +++--- packages/ui/src/components/TextInput/TextInput.tsx | 6 +++--- packages/ui/src/components/Textarea/Textarea.tsx | 4 ++-- .../ui/src/components/ToggleSwitch/ToggleSwitch.tsx | 6 +++--- packages/ui/src/types/index.ts | 8 ++++++++ 22 files changed, 64 insertions(+), 50 deletions(-) create mode 100644 .changeset/plenty-lemons-bow.md diff --git a/.changeset/plenty-lemons-bow.md b/.changeset/plenty-lemons-bow.md new file mode 100644 index 000000000..29ebd753d --- /dev/null +++ b/.changeset/plenty-lemons-bow.md @@ -0,0 +1,5 @@ +--- +"flowbite-react": patch +--- + +fix: autocomplete for string enums with dynamic value not working diff --git a/packages/ui/src/components/Alert/Alert.tsx b/packages/ui/src/components/Alert/Alert.tsx index 7f6492969..d3a82513e 100644 --- a/packages/ui/src/components/Alert/Alert.tsx +++ b/packages/ui/src/components/Alert/Alert.tsx @@ -3,7 +3,7 @@ import { HiX } from "react-icons/hi"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors } from "../Flowbite"; export interface FlowbiteAlertTheme { @@ -24,7 +24,7 @@ export interface FlowbiteAlertCloseButtonTheme { export interface AlertProps extends Omit, "color"> { additionalContent?: ReactNode; - color?: keyof FlowbiteColors; + color?: DynamicStringEnumKeysOf; icon?: FC>; onDismiss?: boolean | (() => void); rounded?: boolean; diff --git a/packages/ui/src/components/Avatar/Avatar.tsx b/packages/ui/src/components/Avatar/Avatar.tsx index 2773a36d8..3c40df431 100644 --- a/packages/ui/src/components/Avatar/Avatar.tsx +++ b/packages/ui/src/components/Avatar/Avatar.tsx @@ -2,7 +2,7 @@ import type { ComponentProps, FC, ReactElement } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors, FlowbitePositions, FlowbiteSizes } from "../Flowbite"; import type { FlowbiteAvatarGroupTheme } from "./AvatarGroup"; import { AvatarGroup } from "./AvatarGroup"; @@ -65,9 +65,9 @@ export interface AvatarProps extends Omit, "color"> { alt?: string; bordered?: boolean; img?: string | ((props: AvatarImageProps) => ReactElement); - color?: keyof AvatarColors; + color?: DynamicStringEnumKeysOf; rounded?: boolean; - size?: keyof AvatarSizes; + size?: DynamicStringEnumKeysOf; stacked?: boolean; status?: "away" | "busy" | "offline" | "online"; statusPosition?: keyof FlowbitePositions; diff --git a/packages/ui/src/components/Badge/Badge.tsx b/packages/ui/src/components/Badge/Badge.tsx index c2ba7f989..bfc266fae 100644 --- a/packages/ui/src/components/Badge/Badge.tsx +++ b/packages/ui/src/components/Badge/Badge.tsx @@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from "../Flowbite"; export interface FlowbiteBadgeTheme { @@ -26,10 +26,10 @@ export interface BadgeSizes extends Pick { } export interface BadgeProps extends Omit, "color"> { - color?: keyof FlowbiteColors; + color?: DynamicStringEnumKeysOf; href?: string; icon?: FC>; - size?: keyof BadgeSizes; + size?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsx index 9733e0db7..189d32ba4 100644 --- a/packages/ui/src/components/Button/Button.tsx +++ b/packages/ui/src/components/Button/Button.tsx @@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge"; import type { PolymorphicComponentPropWithRef, PolymorphicRef } from "../../helpers/generic-as-prop"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors, @@ -71,10 +71,10 @@ export type ButtonProps = PolymorphicComponent T, { href?: string; - color?: keyof FlowbiteColors; + color?: DynamicStringEnumKeysOf; fullSized?: boolean; - gradientDuoTone?: keyof ButtonGradientDuoToneColors; - gradientMonochrome?: keyof ButtonGradientColors; + gradientDuoTone?: DynamicStringEnumKeysOf; + gradientMonochrome?: DynamicStringEnumKeysOf; target?: string; isProcessing?: boolean; processingLabel?: string; @@ -83,7 +83,7 @@ export type ButtonProps = PolymorphicComponent outline?: boolean; pill?: boolean; positionInGroup?: keyof PositionInButtonGroup; - size?: keyof ButtonSizes; + size?: DynamicStringEnumKeysOf; theme?: DeepPartial; } >; diff --git a/packages/ui/src/components/Checkbox/Checkbox.tsx b/packages/ui/src/components/Checkbox/Checkbox.tsx index 127ed7fdb..e4895d651 100644 --- a/packages/ui/src/components/Checkbox/Checkbox.tsx +++ b/packages/ui/src/components/Checkbox/Checkbox.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors } from "../Flowbite"; export interface FlowbiteCheckboxTheme { @@ -16,7 +16,7 @@ export interface FlowbiteCheckboxRootTheme { export interface CheckboxProps extends Omit, "type" | "ref" | "color"> { theme?: DeepPartial; - color?: keyof FlowbiteColors; + color?: DynamicStringEnumKeysOf; } export const Checkbox = forwardRef( diff --git a/packages/ui/src/components/FileInput/FileInput.tsx b/packages/ui/src/components/FileInput/FileInput.tsx index 883fc8ce6..5b1c640be 100644 --- a/packages/ui/src/components/FileInput/FileInput.tsx +++ b/packages/ui/src/components/FileInput/FileInput.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import { HelperText } from "../HelperText"; import type { FlowbiteTextInputColors, FlowbiteTextInputSizes } from "../TextInput"; @@ -28,9 +28,9 @@ export interface FlowbiteFileInputFieldInputTheme { } export interface FileInputProps extends Omit, "type" | "ref" | "color"> { - color?: keyof FlowbiteTextInputColors; + color?: DynamicStringEnumKeysOf; helperText?: ReactNode; - sizing?: keyof FlowbiteTextInputSizes; + sizing?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/HelperText/HelperText.tsx b/packages/ui/src/components/HelperText/HelperText.tsx index e0ba31068..98edcd029 100644 --- a/packages/ui/src/components/HelperText/HelperText.tsx +++ b/packages/ui/src/components/HelperText/HelperText.tsx @@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors } from "../Flowbite"; export interface FlowbiteHelperTextTheme { @@ -19,7 +19,7 @@ export interface HelperColors extends Pick, "color"> { - color?: keyof HelperColors; + color?: DynamicStringEnumKeysOf; theme?: DeepPartial; value?: string; } diff --git a/packages/ui/src/components/Label/Label.tsx b/packages/ui/src/components/Label/Label.tsx index 4d8c86b00..cdc3611ba 100644 --- a/packages/ui/src/components/Label/Label.tsx +++ b/packages/ui/src/components/Label/Label.tsx @@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteStateColors } from "../Flowbite"; export interface FlowbiteLabelTheme { @@ -21,7 +21,7 @@ export interface LabelColors extends FlowbiteStateColors { } export interface LabelProps extends Omit, "color"> { - color?: keyof LabelColors; + color?: DynamicStringEnumKeysOf; disabled?: boolean; theme?: DeepPartial; value?: string; diff --git a/packages/ui/src/components/Modal/Modal.tsx b/packages/ui/src/components/Modal/Modal.tsx index 09fc53e72..0813a6ac7 100644 --- a/packages/ui/src/components/Modal/Modal.tsx +++ b/packages/ui/src/components/Modal/Modal.tsx @@ -16,7 +16,7 @@ import { forwardRef, useState, type ComponentPropsWithoutRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbitePositions, FlowbiteSizes } from "../Flowbite"; import type { FlowbiteModalBodyTheme } from "./ModalBody"; import { ModalBody } from "./ModalBody"; @@ -56,11 +56,11 @@ export interface ModalSizes extends Omit { export interface ModalProps extends ComponentPropsWithoutRef<"div"> { onClose?: () => void; - position?: keyof ModalPositions; + position?: DynamicStringEnumKeysOf; popup?: boolean; root?: HTMLElement; show?: boolean; - size?: keyof ModalSizes; + size?: DynamicStringEnumKeysOf; dismissible?: boolean; theme?: DeepPartial; initialFocus?: number | MutableRefObject; diff --git a/packages/ui/src/components/Progress/Progress.tsx b/packages/ui/src/components/Progress/Progress.tsx index 537953fac..ead8c1a11 100644 --- a/packages/ui/src/components/Progress/Progress.tsx +++ b/packages/ui/src/components/Progress/Progress.tsx @@ -3,7 +3,7 @@ import { useId } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors, FlowbiteSizes } from "../Flowbite"; export interface FlowbiteProgressTheme { @@ -31,7 +31,7 @@ export interface ProgressProps extends ComponentProps<"div"> { labelText?: boolean; progress: number; progressLabelPosition?: "inside" | "outside"; - size?: keyof ProgressSizes; + size?: DynamicStringEnumKeysOf; textLabel?: string; textLabelPosition?: "inside" | "outside"; theme?: DeepPartial; diff --git a/packages/ui/src/components/RangeSlider/RangeSlider.tsx b/packages/ui/src/components/RangeSlider/RangeSlider.tsx index d5f5deb2d..2ca8cf818 100644 --- a/packages/ui/src/components/RangeSlider/RangeSlider.tsx +++ b/packages/ui/src/components/RangeSlider/RangeSlider.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteTextInputSizes } from "../TextInput"; export interface FlowbiteRangeSliderTheme { @@ -24,7 +24,7 @@ export interface FlowbiteRangeSliderFieldTheme { } export interface RangeSliderProps extends Omit, "ref" | "type"> { - sizing?: keyof FlowbiteTextInputSizes; + sizing?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Rating/Rating.tsx b/packages/ui/src/components/Rating/Rating.tsx index d1f2c8026..867b7355b 100644 --- a/packages/ui/src/components/Rating/Rating.tsx +++ b/packages/ui/src/components/Rating/Rating.tsx @@ -4,7 +4,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import { RatingAdvanced } from "./RatingAdvanced"; import { RatingContext } from "./RatingContext"; import type { FlowbiteRatingStarTheme, FlowbiteStarSizes } from "./RatingStar"; @@ -18,7 +18,7 @@ export interface FlowbiteRatingTheme { } export interface RatingProps extends ComponentProps<"div"> { - size?: keyof FlowbiteStarSizes; + size?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Rating/RatingContext.tsx b/packages/ui/src/components/Rating/RatingContext.tsx index 225714dc7..30aac095f 100644 --- a/packages/ui/src/components/Rating/RatingContext.tsx +++ b/packages/ui/src/components/Rating/RatingContext.tsx @@ -1,12 +1,13 @@ "use client"; import { createContext, useContext } from "react"; +import { DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteRatingTheme } from "./Rating"; import type { FlowbiteStarSizes } from "./RatingStar"; export type RatingContext = { theme: FlowbiteRatingTheme; - size?: keyof FlowbiteStarSizes; + size?: DynamicStringEnumKeysOf; }; export const RatingContext = createContext(undefined); diff --git a/packages/ui/src/components/Select/Select.tsx b/packages/ui/src/components/Select/Select.tsx index 34097eaa3..6dcb23584 100644 --- a/packages/ui/src/components/Select/Select.tsx +++ b/packages/ui/src/components/Select/Select.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from "../Flowbite"; import { HelperText } from "../HelperText"; @@ -37,11 +37,11 @@ export interface SelectSizes extends Pick { export interface SelectProps extends Omit, "color" | "ref"> { addon?: ReactNode; - color?: keyof SelectColors; + color?: DynamicStringEnumKeysOf; helperText?: ReactNode; icon?: FC>; shadow?: boolean; - sizing?: keyof SelectSizes; + sizing?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Sidebar/SidebarCTA.tsx b/packages/ui/src/components/Sidebar/SidebarCTA.tsx index ae46743f6..1462fdab7 100644 --- a/packages/ui/src/components/Sidebar/SidebarCTA.tsx +++ b/packages/ui/src/components/Sidebar/SidebarCTA.tsx @@ -3,7 +3,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors } from "../Flowbite"; import { useSidebarContext } from "./SidebarContext"; @@ -13,7 +13,7 @@ export interface FlowbiteSidebarCTATheme { } export interface SidebarCTAProps extends Omit, "color"> { - color?: keyof FlowbiteSidebarCTAColors; + color?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Sidebar/SidebarItem.tsx b/packages/ui/src/components/Sidebar/SidebarItem.tsx index 812e43400..60fbe41ac 100644 --- a/packages/ui/src/components/Sidebar/SidebarItem.tsx +++ b/packages/ui/src/components/Sidebar/SidebarItem.tsx @@ -4,7 +4,7 @@ import type { ComponentProps, ElementType, FC, PropsWithChildren, ReactNode } fr import { forwardRef, useId } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import { Badge } from "../Badge"; import type { FlowbiteColors } from "../Flowbite"; import { Tooltip } from "../Tooltip"; @@ -35,7 +35,7 @@ export interface SidebarItemProps extends Omit, "ref">, Re href?: string; icon?: FC>; label?: string; - labelColor?: keyof SidebarItemLabelColors; + labelColor?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Spinner/Spinner.tsx b/packages/ui/src/components/Spinner/Spinner.tsx index 66a8e85b9..3b3017005 100644 --- a/packages/ui/src/components/Spinner/Spinner.tsx +++ b/packages/ui/src/components/Spinner/Spinner.tsx @@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteColors, FlowbiteSizes } from "../Flowbite"; export interface FlowbiteSpinnerTheme { @@ -31,9 +31,9 @@ export interface SpinnerSizes extends Pick, "color"> { - color?: keyof SpinnerColors; + color?: DynamicStringEnumKeysOf; light?: boolean; - size?: keyof SpinnerSizes; + size?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/TextInput/TextInput.tsx b/packages/ui/src/components/TextInput/TextInput.tsx index 828337f09..b651c852d 100644 --- a/packages/ui/src/components/TextInput/TextInput.tsx +++ b/packages/ui/src/components/TextInput/TextInput.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from "../Flowbite"; import { HelperText } from "../HelperText"; @@ -43,12 +43,12 @@ export interface FlowbiteTextInputSizes extends Pick, "ref" | "color"> { addon?: ReactNode; - color?: keyof FlowbiteTextInputColors; + color?: DynamicStringEnumKeysOf; helperText?: ReactNode; icon?: FC>; rightIcon?: FC>; shadow?: boolean; - sizing?: keyof FlowbiteTextInputSizes; + sizing?: DynamicStringEnumKeysOf; theme?: DeepPartial; } diff --git a/packages/ui/src/components/Textarea/Textarea.tsx b/packages/ui/src/components/Textarea/Textarea.tsx index 0b5c6f1c9..1a4d6703f 100644 --- a/packages/ui/src/components/Textarea/Textarea.tsx +++ b/packages/ui/src/components/Textarea/Textarea.tsx @@ -3,7 +3,7 @@ import { forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors } from "../Flowbite"; import { HelperText } from "../HelperText"; @@ -18,7 +18,7 @@ export interface TextareaColors extends Pick, "color" | "ref"> { - color?: keyof TextareaColors; + color?: DynamicStringEnumKeysOf; helperText?: ReactNode; shadow?: boolean; theme?: DeepPartial; diff --git a/packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx b/packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx index 7f89cadfe..97a67f233 100644 --- a/packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx +++ b/packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx @@ -3,7 +3,7 @@ import { forwardRef, useId } from "react"; import { twMerge } from "tailwind-merge"; import { mergeDeep } from "../../helpers/merge-deep"; import { getTheme } from "../../theme-store"; -import type { DeepPartial } from "../../types"; +import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types"; import type { FlowbiteBoolean, FlowbiteColors } from "../Flowbite"; import type { FlowbiteTextInputSizes } from "../TextInput"; @@ -28,8 +28,8 @@ export interface FlowbiteToggleSwitchToggleTheme { export type ToggleSwitchProps = Omit, "onChange" | "ref"> & { checked: boolean; - color?: keyof FlowbiteColors; - sizing?: keyof FlowbiteTextInputSizes; + color?: DynamicStringEnumKeysOf; + sizing?: DynamicStringEnumKeysOf; label?: string; onChange: (checked: boolean) => void; theme?: DeepPartial; diff --git a/packages/ui/src/types/index.ts b/packages/ui/src/types/index.ts index 6ac64c68d..bdf8e039e 100644 --- a/packages/ui/src/types/index.ts +++ b/packages/ui/src/types/index.ts @@ -3,3 +3,11 @@ export type DeepPartial = T extends object [P in keyof T]?: DeepPartial; } : T; + +export type RemoveIndexSignature = { + [K in keyof T as string extends K ? never : K]: T[K]; +}; + +export type DynamicStringEnum = T | (string & {}); + +export type DynamicStringEnumKeysOf = DynamicStringEnum>;