Skip to content

Commit 38913e5

Browse files
authored
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
1 parent a044264 commit 38913e5

File tree

22 files changed

+64
-50
lines changed

22 files changed

+64
-50
lines changed

.changeset/plenty-lemons-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"flowbite-react": patch
3+
---
4+
5+
fix: autocomplete for string enums with dynamic value not working

packages/ui/src/components/Alert/Alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HiX } from "react-icons/hi";
33
import { twMerge } from "tailwind-merge";
44
import { mergeDeep } from "../../helpers/merge-deep";
55
import { getTheme } from "../../theme-store";
6-
import type { DeepPartial } from "../../types";
6+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
77
import type { FlowbiteColors } from "../Flowbite";
88

99
export interface FlowbiteAlertTheme {
@@ -24,7 +24,7 @@ export interface FlowbiteAlertCloseButtonTheme {
2424

2525
export interface AlertProps extends Omit<ComponentProps<"div">, "color"> {
2626
additionalContent?: ReactNode;
27-
color?: keyof FlowbiteColors;
27+
color?: DynamicStringEnumKeysOf<FlowbiteColors>;
2828
icon?: FC<ComponentProps<"svg">>;
2929
onDismiss?: boolean | (() => void);
3030
rounded?: boolean;

packages/ui/src/components/Avatar/Avatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ComponentProps, FC, ReactElement } from "react";
22
import { twMerge } from "tailwind-merge";
33
import { mergeDeep } from "../../helpers/merge-deep";
44
import { getTheme } from "../../theme-store";
5-
import type { DeepPartial } from "../../types";
5+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
66
import type { FlowbiteBoolean, FlowbiteColors, FlowbitePositions, FlowbiteSizes } from "../Flowbite";
77
import type { FlowbiteAvatarGroupTheme } from "./AvatarGroup";
88
import { AvatarGroup } from "./AvatarGroup";
@@ -65,9 +65,9 @@ export interface AvatarProps extends Omit<ComponentProps<"div">, "color"> {
6565
alt?: string;
6666
bordered?: boolean;
6767
img?: string | ((props: AvatarImageProps) => ReactElement);
68-
color?: keyof AvatarColors;
68+
color?: DynamicStringEnumKeysOf<AvatarColors>;
6969
rounded?: boolean;
70-
size?: keyof AvatarSizes;
70+
size?: DynamicStringEnumKeysOf<AvatarSizes>;
7171
stacked?: boolean;
7272
status?: "away" | "busy" | "offline" | "online";
7373
statusPosition?: keyof FlowbitePositions;

packages/ui/src/components/Badge/Badge.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react";
22
import { twMerge } from "tailwind-merge";
33
import { mergeDeep } from "../../helpers/merge-deep";
44
import { getTheme } from "../../theme-store";
5-
import type { DeepPartial } from "../../types";
5+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
66
import type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from "../Flowbite";
77

88
export interface FlowbiteBadgeTheme {
@@ -26,10 +26,10 @@ export interface BadgeSizes extends Pick<FlowbiteSizes, "xs" | "sm"> {
2626
}
2727

2828
export interface BadgeProps extends Omit<ComponentProps<"span">, "color"> {
29-
color?: keyof FlowbiteColors;
29+
color?: DynamicStringEnumKeysOf<FlowbiteColors>;
3030
href?: string;
3131
icon?: FC<ComponentProps<"svg">>;
32-
size?: keyof BadgeSizes;
32+
size?: DynamicStringEnumKeysOf<BadgeSizes>;
3333
theme?: DeepPartial<FlowbiteBadgeTheme>;
3434
}
3535

packages/ui/src/components/Button/Button.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge";
44
import type { PolymorphicComponentPropWithRef, PolymorphicRef } from "../../helpers/generic-as-prop";
55
import { mergeDeep } from "../../helpers/merge-deep";
66
import { getTheme } from "../../theme-store";
7-
import type { DeepPartial } from "../../types";
7+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
88
import type {
99
FlowbiteBoolean,
1010
FlowbiteColors,
@@ -71,10 +71,10 @@ export type ButtonProps<T extends ElementType = "button"> = PolymorphicComponent
7171
T,
7272
{
7373
href?: string;
74-
color?: keyof FlowbiteColors;
74+
color?: DynamicStringEnumKeysOf<FlowbiteColors>;
7575
fullSized?: boolean;
76-
gradientDuoTone?: keyof ButtonGradientDuoToneColors;
77-
gradientMonochrome?: keyof ButtonGradientColors;
76+
gradientDuoTone?: DynamicStringEnumKeysOf<ButtonGradientDuoToneColors>;
77+
gradientMonochrome?: DynamicStringEnumKeysOf<ButtonGradientColors>;
7878
target?: string;
7979
isProcessing?: boolean;
8080
processingLabel?: string;
@@ -83,7 +83,7 @@ export type ButtonProps<T extends ElementType = "button"> = PolymorphicComponent
8383
outline?: boolean;
8484
pill?: boolean;
8585
positionInGroup?: keyof PositionInButtonGroup;
86-
size?: keyof ButtonSizes;
86+
size?: DynamicStringEnumKeysOf<ButtonSizes>;
8787
theme?: DeepPartial<FlowbiteButtonTheme>;
8888
}
8989
>;

packages/ui/src/components/Checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
33
import { twMerge } from "tailwind-merge";
44
import { mergeDeep } from "../../helpers/merge-deep";
55
import { getTheme } from "../../theme-store";
6-
import type { DeepPartial } from "../../types";
6+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
77
import type { FlowbiteColors } from "../Flowbite";
88

99
export interface FlowbiteCheckboxTheme {
@@ -16,7 +16,7 @@ export interface FlowbiteCheckboxRootTheme {
1616

1717
export interface CheckboxProps extends Omit<ComponentProps<"input">, "type" | "ref" | "color"> {
1818
theme?: DeepPartial<FlowbiteCheckboxTheme>;
19-
color?: keyof FlowbiteColors;
19+
color?: DynamicStringEnumKeysOf<FlowbiteColors>;
2020
}
2121

2222
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(

packages/ui/src/components/FileInput/FileInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { forwardRef } from "react";
33
import { twMerge } from "tailwind-merge";
44
import { mergeDeep } from "../../helpers/merge-deep";
55
import { getTheme } from "../../theme-store";
6-
import type { DeepPartial } from "../../types";
6+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
77
import { HelperText } from "../HelperText";
88
import type { FlowbiteTextInputColors, FlowbiteTextInputSizes } from "../TextInput";
99

@@ -28,9 +28,9 @@ export interface FlowbiteFileInputFieldInputTheme {
2828
}
2929

3030
export interface FileInputProps extends Omit<ComponentProps<"input">, "type" | "ref" | "color"> {
31-
color?: keyof FlowbiteTextInputColors;
31+
color?: DynamicStringEnumKeysOf<FlowbiteTextInputColors>;
3232
helperText?: ReactNode;
33-
sizing?: keyof FlowbiteTextInputSizes;
33+
sizing?: DynamicStringEnumKeysOf<FlowbiteTextInputSizes>;
3434
theme?: DeepPartial<FlowbiteFileInputTheme>;
3535
}
3636

packages/ui/src/components/HelperText/HelperText.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react";
22
import { twMerge } from "tailwind-merge";
33
import { mergeDeep } from "../../helpers/merge-deep";
44
import { getTheme } from "../../theme-store";
5-
import type { DeepPartial } from "../../types";
5+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
66
import type { FlowbiteColors } from "../Flowbite";
77

88
export interface FlowbiteHelperTextTheme {
@@ -19,7 +19,7 @@ export interface HelperColors extends Pick<FlowbiteColors, "gray" | "info" | "fa
1919
}
2020

2121
export interface HelperTextProps extends Omit<ComponentProps<"p">, "color"> {
22-
color?: keyof HelperColors;
22+
color?: DynamicStringEnumKeysOf<HelperColors>;
2323
theme?: DeepPartial<FlowbiteHelperTextTheme>;
2424
value?: string;
2525
}

packages/ui/src/components/Label/Label.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ComponentProps, FC } from "react";
22
import { twMerge } from "tailwind-merge";
33
import { mergeDeep } from "../../helpers/merge-deep";
44
import { getTheme } from "../../theme-store";
5-
import type { DeepPartial } from "../../types";
5+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
66
import type { FlowbiteStateColors } from "../Flowbite";
77

88
export interface FlowbiteLabelTheme {
@@ -21,7 +21,7 @@ export interface LabelColors extends FlowbiteStateColors {
2121
}
2222

2323
export interface LabelProps extends Omit<ComponentProps<"label">, "color"> {
24-
color?: keyof LabelColors;
24+
color?: DynamicStringEnumKeysOf<LabelColors>;
2525
disabled?: boolean;
2626
theme?: DeepPartial<FlowbiteLabelTheme>;
2727
value?: string;

packages/ui/src/components/Modal/Modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";
1616
import { twMerge } from "tailwind-merge";
1717
import { mergeDeep } from "../../helpers/merge-deep";
1818
import { getTheme } from "../../theme-store";
19-
import type { DeepPartial } from "../../types";
19+
import type { DeepPartial, DynamicStringEnumKeysOf } from "../../types";
2020
import type { FlowbiteBoolean, FlowbitePositions, FlowbiteSizes } from "../Flowbite";
2121
import type { FlowbiteModalBodyTheme } from "./ModalBody";
2222
import { ModalBody } from "./ModalBody";
@@ -56,11 +56,11 @@ export interface ModalSizes extends Omit<FlowbiteSizes, "xs"> {
5656

5757
export interface ModalProps extends ComponentPropsWithoutRef<"div"> {
5858
onClose?: () => void;
59-
position?: keyof ModalPositions;
59+
position?: DynamicStringEnumKeysOf<ModalPositions>;
6060
popup?: boolean;
6161
root?: HTMLElement;
6262
show?: boolean;
63-
size?: keyof ModalSizes;
63+
size?: DynamicStringEnumKeysOf<ModalSizes>;
6464
dismissible?: boolean;
6565
theme?: DeepPartial<FlowbiteModalTheme>;
6666
initialFocus?: number | MutableRefObject<HTMLElement | null>;

0 commit comments

Comments
 (0)