Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autocomplete for string enums with dynamic value not working #1484

Merged

Conversation

KRTirtho
Copy link
Contributor

@KRTirtho KRTirtho commented Sep 8, 2024

Dynamic string enum ("value1" | "value2" | string) auto complete is not showing the values (value1, value2) for particular component's props

image

Some of the props of the components e.g. Button's color prop accepts defined colors red, green, blue etc while also any dynamic values but for this auto complete doesn't work on VSCode and other IDEs resulting in a bad DX. Recently discovered and hugely criticized "value1" | "value2" | string & {} technique fixes this issue.

Also, with the removal dynamic index signature of some of the interfaces that has it, both techniques combined a better DX can be achieved (It is!)

After applying the fix:

image

Summary by CodeRabbit

  • New Features

    • Enhanced flexibility for color and sizing properties across various components (Alert, Avatar, Badge, Button, Checkbox, FileInput, HelperText, Label, Modal, Progress, RangeSlider, Rating, Select, Sidebar, Spinner, TextInput, Textarea, ToggleSwitch) by allowing dynamic string keys.
    • Introduced a patch for the "flowbite-react" library to improve autocomplete functionality for string enums with dynamic values.
  • Bug Fixes

    • Improved type definitions to ensure better validation and error handling for component properties.

Copy link

changeset-bot bot commented Sep 8, 2024

🦋 Changeset detected

Latest commit: 53f84cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
flowbite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 2:41pm
flowbite-react-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 9, 2024 2:41pm

Copy link
Contributor

coderabbitai bot commented Sep 8, 2024

Walkthrough

This pull request introduces significant enhancements to the type definitions across various UI components in the codebase. Specifically, it replaces the existing key types with a new dynamic type, DynamicStringEnumKeysOf, allowing for greater flexibility in property values. This change affects components such as Alert, Avatar, Badge, Button, Checkbox, and others, improving their adaptability to different themes and configurations while maintaining type safety.

Changes

Files Change Summary
packages/ui/src/components/{Alert, Avatar, Badge, Button, Checkbox, FileInput, HelperText, Label, Modal, Progress, RangeSlider, Rating, Select, SidebarCTA, SidebarItem, Spinner, TextInput, Textarea, ToggleSwitch}/... Updated properties to use DynamicStringEnumKeysOf instead of keyof for various enums, enhancing type flexibility.
packages/ui/src/types/index.ts Introduced new types: RemoveIndexSignature<T>, DynamicStringEnum<T>, and DynamicStringEnumKeysOf<T>, enhancing type system expressiveness.

Possibly related PRs

Suggested labels

enhancement, bug

Poem

🐰 In the garden where types bloom,
Dynamic strings dispel the gloom.
With colors bright and sizes wide,
Our components now take pride.
Hopping through code, we cheer and play,
For flexibility's here to stay! 🌼

Tip

New features

Walkthrough comment now includes:

  • Possibly related PRs: A list of potentially related PRs to help you recall past context.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs. You can also provide custom labeling instructions in the UI or configuration file.

Notes:

  • Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
packages/ui/src/components/HelperText/HelperText.tsx (1)

5-5: Correct the import path for DynamicStringEnumKeysOf.

The type DynamicStringEnumKeysOf is defined in packages/ui/src/types/index.ts. Update the import path in HelperText.tsx to correctly reference this location.

  • File: packages/ui/src/components/HelperText/HelperText.tsx
  • Current Import Path: ../../types
  • Correct Import Path: ../types
Analysis chain

Confirm the import of DynamicStringEnumKeysOf.

Ensure that the type DynamicStringEnumKeysOf is correctly defined in the ../../types module and that the import path is accurate.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --type typescript -A 5 $'DynamicStringEnumKeysOf' ../../types

Length of output: 98


Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --glob '*.ts' -A 5 'DynamicStringEnumKeysOf' ../../types

Length of output: 111


Script:

#!/bin/bash
# Description: Search the entire repository for the definition of `DynamicStringEnumKeysOf`.

# Test: Search for the type definition across all TypeScript files in the repository.
rg --glob '*.ts' -A 5 'DynamicStringEnumKeysOf'

Length of output: 184

packages/ui/src/components/Label/Label.tsx (1)

5-5: Update the import path for DynamicStringEnumKeysOf.

The import path in Label.tsx is incorrect. Update it to correctly reference the types directory:

  • Change the import path in packages/ui/src/components/Label/Label.tsx from ../../types to ../types.

This issue might also affect other files with similar incorrect import paths. Please verify and update them accordingly.

Analysis chain

Confirm the import of DynamicStringEnumKeysOf.

Ensure that the type DynamicStringEnumKeysOf is correctly defined in the ../../types module and that the import path is accurate.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --type typescript -A 5 $'DynamicStringEnumKeysOf' ../../types

Length of output: 98


Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg -A 5 'DynamicStringEnumKeysOf' ../../types

Length of output: 97


Script:

#!/bin/bash
# Description: Search for the definition of `DynamicStringEnumKeysOf` across the entire repository.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg -A 5 'DynamicStringEnumKeysOf'

Length of output: 23628

packages/ui/src/components/Sidebar/SidebarCTA.tsx (1)

6-6: Verify and correct the import path for DynamicStringEnumKeysOf.

The type DynamicStringEnumKeysOf is defined in packages/ui/src/types/index.ts. However, the import path ../../types in SidebarCTA.tsx might be incorrect due to a potential issue with the directory structure. Please verify and update the import path to ensure it correctly points to the types module.

  • File: packages/ui/src/components/Sidebar/SidebarCTA.tsx
  • Current Import Path: ../../types
  • Correct Location: packages/ui/src/types/index.ts
Analysis chain

Confirm the import of DynamicStringEnumKeysOf.

Ensure that the type DynamicStringEnumKeysOf is correctly defined in the ../../types module and that the import path is accurate.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --type typescript -A 5 $'DynamicStringEnumKeysOf' ../../types

Length of output: 98


Script:

#!/bin/bash
# Description: Verify the existence and definition of `DynamicStringEnumKeysOf` in the types module.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --type ts -A 5 $'DynamicStringEnumKeysOf' ../../types

Length of output: 107


Script:

#!/bin/bash
# Description: Search for the definition of `DynamicStringEnumKeysOf` in the entire repository.

# Test: Search for the type definition. Expect: At least one occurrence of the type definition.
rg --type ts -A 5 $'DynamicStringEnumKeysOf'

Length of output: 23638

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a044264 and 641f81a.

Files selected for processing (21)
  • packages/ui/src/components/Alert/Alert.tsx (2 hunks)
  • packages/ui/src/components/Avatar/Avatar.tsx (2 hunks)
  • packages/ui/src/components/Badge/Badge.tsx (2 hunks)
  • packages/ui/src/components/Button/Button.tsx (3 hunks)
  • packages/ui/src/components/Checkbox/Checkbox.tsx (2 hunks)
  • packages/ui/src/components/FileInput/FileInput.tsx (2 hunks)
  • packages/ui/src/components/HelperText/HelperText.tsx (2 hunks)
  • packages/ui/src/components/Label/Label.tsx (2 hunks)
  • packages/ui/src/components/Modal/Modal.tsx (2 hunks)
  • packages/ui/src/components/Progress/Progress.tsx (2 hunks)
  • packages/ui/src/components/RangeSlider/RangeSlider.tsx (2 hunks)
  • packages/ui/src/components/Rating/Rating.tsx (2 hunks)
  • packages/ui/src/components/Rating/RatingContext.tsx (1 hunks)
  • packages/ui/src/components/Select/Select.tsx (2 hunks)
  • packages/ui/src/components/Sidebar/SidebarCTA.tsx (2 hunks)
  • packages/ui/src/components/Sidebar/SidebarItem.tsx (2 hunks)
  • packages/ui/src/components/Spinner/Spinner.tsx (2 hunks)
  • packages/ui/src/components/TextInput/TextInput.tsx (2 hunks)
  • packages/ui/src/components/Textarea/Textarea.tsx (2 hunks)
  • packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx (2 hunks)
  • packages/ui/src/types/index.ts (1 hunks)
Additional comments not posted (47)
packages/ui/src/types/index.ts (3)

7-9: Well-implemented type definition for RemoveIndexSignature<T>.

This type correctly excludes string index signatures using TypeScript's conditional types, enhancing type safety by filtering out unwanted properties.


11-11: Correct implementation of DynamicStringEnum<T>.

This type definition allows for a union of a specific type T and any string, facilitating dynamic string enumerations effectively.


13-13: Effective type definition for DynamicStringEnumKeysOf<T extends object>.

This type definition correctly computes the keys of an object type T after applying the RemoveIndexSignature transformation, ensuring that only non-indexed keys are included.

packages/ui/src/components/Rating/RatingContext.tsx (1)

10-10: Appropriate update to RatingContext type definition.

The modification of the size property to use DynamicStringEnumKeysOf<FlowbiteStarSizes> enhances flexibility and expressiveness, allowing for a broader range of string keys.

packages/ui/src/components/Checkbox/Checkbox.tsx (1)

19-19: Well-executed update to CheckboxProps interface.

The update of the color property to DynamicStringEnumKeysOf<FlowbiteColors> enhances the flexibility and type safety of the component's props, allowing for a more dynamic set of string keys.

packages/ui/src/components/HelperText/HelperText.tsx (1)

22-22: Approve the change to color property type.

The modification from keyof HelperColors to DynamicStringEnumKeysOf<HelperColors> enhances flexibility. Ensure that this change integrates well with other components that use HelperText.

packages/ui/src/components/Label/Label.tsx (1)

24-24: Approve the change to color property type.

The modification from keyof LabelColors to DynamicStringEnumKeysOf<LabelColors> enhances flexibility. Ensure that this change integrates well with other components that use Label.

packages/ui/src/components/Sidebar/SidebarCTA.tsx (1)

16-16: Approve the change to color property type.

The modification from keyof FlowbiteSidebarCTAColors to DynamicStringEnumKeysOf<FlowbiteSidebarCTAColors> enhances flexibility. Ensure that this change integrates well with other components that use SidebarCTA.

packages/ui/src/components/Rating/Rating.tsx (2)

7-7: Approved import statement.

The import of DynamicStringEnumKeysOf is correctly formatted and necessary for the changes in the RatingProps interface.


21-21: Approved modification with a suggestion to verify integration.

The change to the size property type in RatingProps enhances flexibility and aligns with the PR's objectives. However, ensure that this change integrates well with other components that use RatingProps.

Run the following script to verify the integration of size property across the project:

Verification successful

Integration of size property in RatingProps is verified.

The size property in RatingProps is correctly integrated and used within the RatingComponent and its storybook tests. There are no type mismatches or integration issues found.

  • RatingProps is used in Rating.tsx and Rating.stories.tsx.
  • The size property has a default value and is part of the component's context.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `size` property in `RatingProps` across the project.

# Test: Search for the usage of `size` property. Expect: No type mismatches.
rg --type typescript -A 5 $'size'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the integration of `size` property in `RatingProps` across the project.

# Find all TypeScript files and search for the usage of `size` property.
fd --extension ts --exec rg 'size' {}

Length of output: 515


Script:

#!/bin/bash
# Description: Verify the integration of `RatingProps` interface and its `size` property across the project.

# Search for the definition and usage of `RatingProps` to ensure proper integration.
rg --type ts 'RatingProps' -A 10

Length of output: 3323

packages/ui/src/components/Textarea/Textarea.tsx (2)

6-6: Approved import statement.

The import of DynamicStringEnumKeysOf is correctly formatted and necessary for the changes in the TextareaProps interface.


21-21: Approved modification with a suggestion to verify integration.

The change to the color property type in TextareaProps enhances flexibility and aligns with the PR's objectives. However, ensure that this change integrates well with other components that use TextareaProps.

Run the following script to verify the integration of color property across the project:

Verification successful

Verification successful: No issues found with the color property integration.

The change to the color property type in TextareaProps is consistent with similar changes across other components and aligns well with the existing codebase structure. No type mismatches or errors were found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `color` property in `TextareaProps` across the project.

# Test: Search for the usage of `color` property. Expect: No type mismatches.
rg --type typescript -A 5 $'color'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `color` property in `TextareaProps` across the project.

# Test: Search for the usage of `color` property. Expect: No type mismatches.
rg --type ts -A 5 $'color'

Length of output: 194745

packages/ui/src/components/RangeSlider/RangeSlider.tsx (2)

6-6: Approved import statement.

The import of DynamicStringEnumKeysOf is correctly formatted and necessary for the changes in the RangeSliderProps interface.


27-27: Approved modification with a suggestion to verify integration.

The change to the sizing property type in RangeSliderProps enhances flexibility and aligns with the PR's objectives. However, ensure that this change integrates well with other components that use RangeSliderProps.

Run the following script to verify the integration of sizing property across the project:

Verification successful

Integration of sizing property verified successfully.

The sizing property is consistently used across various components and examples, aligning with the new type DynamicStringEnumKeysOf<FlowbiteTextInputSizes>. No type mismatches or errors were found, and the property is well-covered in test and storybook files. The integration appears successful.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `sizing` property in `RangeSliderProps` across the project.

# Test: Search for the usage of `sizing` property. Expect: No type mismatches.
rg --type typescript -A 5 $'sizing'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the integration of `sizing` property in `RangeSliderProps` across the project.

# Test: Search for the usage of `sizing` property. Expect: No type mismatches.
rg --type ts -A 5 $'sizing'

Length of output: 30237

packages/ui/src/components/Badge/Badge.tsx (3)

5-5: Approved import addition.

The import of DynamicStringEnumKeysOf is correctly added to support the new dynamic type definitions in the component.


32-32: Approved type enhancement for size.

The change from keyof BadgeSizes to DynamicStringEnumKeysOf<BadgeSizes> increases the flexibility and adaptability of the size property. Ensure that this change is well integrated with other components that use the Badge component.

Run the following script to verify the integration with other components:

Verification successful

Integration of size property in Badge component verified.

The size property of the Badge component, now using DynamicStringEnumKeysOf<BadgeSizes>, is well integrated across the codebase. It is used in various examples and stories, indicating proper handling and testing of this change.

  • Files with size usage:
    • apps/web/examples/badge/badge.sizes.tsx
    • apps/web/examples/badge/badge.asLink.tsx
    • apps/web/examples/badge/badge.withIconOnly.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `Badge` component with other components.

# Test: Search for the usage of `Badge` component. Expect: Proper handling of the `size` property.
rg --type typescript -A 5 $'Badge'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `Badge` component with other components.

# Test: Search for the usage of `Badge` component. Expect: Proper handling of the `size` property.
rg --type ts -A 5 $'Badge'

Length of output: 38745


29-29: Approved type enhancement for color.

The change from keyof FlowbiteColors to DynamicStringEnumKeysOf<FlowbiteColors> enhances the flexibility and developer experience by supporting dynamic string values. Ensure that this change is well integrated with other components that use the Badge component.

Run the following script to verify the integration with other components:

Verification successful

Integration of Badge component verified successfully.

The Badge component, with its updated color property type, is well integrated across various components and examples in the codebase. The usage of the color property is consistent and aligns with the intended flexibility enhancement.

  • packages/ui/src/components/Sidebar/SidebarItem.tsx
  • packages/ui/src/components/Sidebar/Sidebar.stories.tsx
  • Various example files in apps/web/examples/badge/
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `Badge` component with other components.

# Test: Search for the usage of `Badge` component. Expect: Proper handling of the `color` property.
rg --type typescript -A 5 $'Badge'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `Badge` component with other components.

# Test: Search for the usage of `Badge` component. Expect: Proper handling of the `color` property.
rg --type ts -A 5 $'Badge'

Length of output: 38745

packages/ui/src/components/Select/Select.tsx (2)

6-6: Confirm import correctness.

The import of DynamicStringEnumKeysOf is crucial for the changes in this PR. Ensure that the path ../../types correctly points to the file where DynamicStringEnumKeysOf is defined.


40-40: Review type changes in SelectProps.

The changes to the color and sizing properties to use DynamicStringEnumKeysOf are intended to enhance flexibility. Confirm that these changes integrate well with the rest of the component and do not affect existing functionality adversely.

Also applies to: 44-44

packages/ui/src/components/Spinner/Spinner.tsx (2)

5-5: Confirm import correctness.

The import of DynamicStringEnumKeysOf is crucial for the changes in this PR. Ensure that the path ../../types correctly points to the file where DynamicStringEnumKeysOf is defined.


34-34: Review type changes in SpinnerProps.

The changes to the color and size properties to use DynamicStringEnumKeysOf are intended to enhance flexibility. Confirm that these changes integrate well with the rest of the component and do not affect existing functionality adversely.

Also applies to: 36-36

packages/ui/src/components/Progress/Progress.tsx (2)

6-6: Confirm import correctness.

The import of DynamicStringEnumKeysOf is crucial for the changes in this PR. Ensure that the path ../../types correctly points to the file where DynamicStringEnumKeysOf is defined.


34-34: Review type change in ProgressProps.

The change to the size property to use DynamicStringEnumKeysOf is intended to enhance flexibility. Confirm that this change integrates well with the rest of the component and does not affect existing functionality adversely.

packages/ui/src/components/ToggleSwitch/ToggleSwitch.tsx (3)

6-6: Confirm import path and module resolution.

Ensure that the import path for DynamicStringEnumKeysOf is correct and that the module resolves properly in the project structure.


32-32: Approve the new type for sizing but verify its usage.

The change to use DynamicStringEnumKeysOf<FlowbiteTextInputSizes> for the sizing property enhances flexibility. Verify that this change is compatible with all existing usages of the sizing property in the codebase.


31-31: Approve the new type for color but verify its usage.

The change to use DynamicStringEnumKeysOf<FlowbiteColors> for the color property enhances flexibility. Verify that this change is compatible with all existing usages of the color property in the codebase.

packages/ui/src/components/Modal/Modal.tsx (3)

19-19: Correct Import for DynamicStringEnumKeysOf

The import of DynamicStringEnumKeysOf from ../../types is correctly placed and necessary for the changes in the ModalProps interface.


63-63: Enhanced Type Flexibility for size Property

The change from keyof ModalSizes to DynamicStringEnumKeysOf<ModalSizes> enhances type flexibility. Ensure that ModalSizes is correctly implemented to support dynamic keys.

Verification successful

Verified: ModalSizes Supports Dynamic Keys

The ModalSizes interface includes an index signature, confirming its support for dynamic keys. This validates the change to DynamicStringEnumKeysOf<ModalSizes> for the size property. No further action is needed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `ModalSizes` to support dynamic keys.

# Test: Search for the `ModalSizes` interface definition. Expect: Dynamic keys support.
rg --type typescript -A 5 $'interface ModalSizes'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the implementation of `ModalSizes` to support dynamic keys.

# Test: Search for the `ModalSizes` interface definition. Expect: Dynamic keys support.
rg --type ts -A 5 $'interface ModalSizes'

Length of output: 486


59-59: Enhanced Type Flexibility for position Property

The change from keyof ModalPositions to DynamicStringEnumKeysOf<ModalPositions> enhances type flexibility. Ensure that ModalPositions is correctly implemented to support dynamic keys.

Verification successful

Enhanced Type Flexibility for position Property Confirmed

The ModalPositions interface supports dynamic keys through an index signature, validating the change to DynamicStringEnumKeysOf<ModalPositions> for the position property. This implementation ensures enhanced type flexibility as intended.

  • ModalPositions is defined with an index signature allowing dynamic keys.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `ModalPositions` to support dynamic keys.

# Test: Search for the `ModalPositions` interface definition. Expect: Dynamic keys support.
rg --type typescript -A 5 $'interface ModalPositions'

Length of output: 89


Script:

#!/bin/bash
# Description: Verify the implementation of `ModalPositions` to support dynamic keys.

# Test: Search for the `ModalPositions` interface definition. Expect: Dynamic keys support.
rg --type ts -A 5 $'interface ModalPositions'

Length of output: 481

packages/ui/src/components/FileInput/FileInput.tsx (3)

6-6: Correct import for new dynamic type functionality.

The import of DynamicStringEnumKeysOf is essential for the new functionality introduced in this PR. This change is correctly implemented.


31-31: Enhanced flexibility for color property.

The change to color?: DynamicStringEnumKeysOf<FlowbiteTextInputColors> enhances the flexibility and developer experience by allowing a broader range of string values. This change is correctly implemented.


33-33: Enhanced flexibility for sizing property.

The change to sizing?: DynamicStringEnumKeysOf<FlowbiteTextInputSizes> enhances the flexibility and developer experience by allowing a broader range of string values. This change is correctly implemented.

packages/ui/src/components/Alert/Alert.tsx (2)

6-6: Correct import for new dynamic type functionality.

The import of DynamicStringEnumKeysOf is essential for the new functionality introduced in this PR. This change is correctly implemented.


27-27: Enhanced flexibility for color property.

The change to color?: DynamicStringEnumKeysOf<FlowbiteColors> enhances the flexibility and developer experience by allowing a broader range of string values. This change is correctly implemented.

packages/ui/src/components/TextInput/TextInput.tsx (3)

6-6: Correct import for new dynamic type functionality.

The import of DynamicStringEnumKeysOf is essential for the new functionality introduced in this PR. This change is correctly implemented.


46-46: Enhanced flexibility for color property.

The change to color?: DynamicStringEnumKeysOf<FlowbiteTextInputColors> enhances the flexibility and developer experience by allowing a broader range of string values. This change is correctly implemented.


51-51: Enhanced flexibility for sizing property.

The change to sizing?: DynamicStringEnumKeysOf<FlowbiteTextInputSizes> enhances the flexibility and developer experience by allowing a broader range of string values. This change is correctly implemented.

packages/ui/src/components/Sidebar/SidebarItem.tsx (2)

7-7: Import statement is correct.

The import of DynamicStringEnumKeysOf is correctly added to support the new dynamic type handling for component props.


38-38: Enhanced type flexibility for labelColor.

The change to labelColor using DynamicStringEnumKeysOf<SidebarItemLabelColors> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use SidebarItem.

Run the following script to verify the integration of labelColor with other components:

Verification successful

Successful integration of labelColor with new type.

The labelColor property, now using DynamicStringEnumKeysOf<SidebarItemLabelColors>, is well-integrated across various components, examples, and tests. This indicates a thorough implementation and validation of the new type.

  • Files with labelColor usage:
    • apps/web/examples/sidebar/sidebar.root.tsx
    • packages/ui/src/components/Sidebar/Sidebar.stories.tsx
    • packages/ui/src/components/Sidebar/SidebarItem.tsx
    • packages/ui/src/components/Sidebar/SidebarCollapse.tsx
    • packages/ui/src/components/Sidebar/Sidebar.spec.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `labelColor` with other components.

# Test: Search for the usage of `labelColor` in other components. Expect: Proper handling of the new type.
rg --type typescript -A 5 $'labelColor'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify the integration of `labelColor` with other components.

# Test: Search for the usage of `labelColor` in other components. Expect: Proper handling of the new type.
rg --type ts -A 5 $'labelColor'

Length of output: 4895

packages/ui/src/components/Avatar/Avatar.tsx (3)

5-5: Import statement is correct.

The import of DynamicStringEnumKeysOf is correctly added to support the new dynamic type handling for component props.


68-68: Enhanced type flexibility for color.

The change to color using DynamicStringEnumKeysOf<AvatarColors> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Avatar.

Run the following script to verify the integration of color with other components:

Verification successful

Integration of color property is consistent across components.

The use of DynamicStringEnumKeysOf<AvatarColors> for the color property in the Avatar component aligns with the usage pattern in other components. This change should integrate smoothly without issues. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `color` with other components.

# Test: Search for the usage of `color` in other components. Expect: Proper handling of the new type.
rg --type typescript -A 5 $'color'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `color` with other components.

# Test: Search for the usage of `color` in other components. Expect: Proper handling of the new type.
rg --type ts -A 5 $'color'

Length of output: 194745


70-70: Enhanced type flexibility for size.

The change to size using DynamicStringEnumKeysOf<AvatarSizes> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Avatar.

Run the following script to verify the integration of size with other components:

packages/ui/src/components/Button/Button.tsx (5)

7-7: Import statement is correct.

The import of DynamicStringEnumKeysOf is correctly added to support the new dynamic type handling for component props.


77-77: Enhanced type flexibility for gradientMonochrome.

The change to gradientMonochrome using DynamicStringEnumKeysOf<ButtonGradientColors> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Button.

Run the following script to verify the integration of gradientMonochrome with other components:

Verification successful

Integration of gradientMonochrome is well-covered.

The gradientMonochrome property, now using DynamicStringEnumKeysOf<ButtonGradientColors>, is integrated across various components, tests, and examples. This indicates a thorough implementation and testing of the new type. No further action is required.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `gradientMonochrome` with other components.

# Test: Search for the usage of `gradientMonochrome` in other components. Expect: Proper handling of the new type.
rg --type typescript -A 5 $'gradientMonochrome'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the integration of `gradientMonochrome` with other components.

# Test: Search for the usage of `gradientMonochrome` in other components. Expect: Proper handling of the new type.
rg --type ts -A 5 $'gradientMonochrome'

Length of output: 14808


74-74: Enhanced type flexibility for color.

The change to color using DynamicStringEnumKeysOf<FlowbiteColors> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Button.

Run the following script to verify the integration of color with other components:

Verification successful

Integration of color with other components verified

The color property using DynamicStringEnumKeysOf<FlowbiteColors> is integrated across various components, ensuring consistent handling of dynamic string values. The search results show that the color property is used in multiple components, such as TextInput, Textarea, ToggleSwitch, Spinner, Select, Checkbox, Alert, Badge, Avatar, and Button. This indicates that the change is well-integrated and aligns with the overall type safety and functionality of the components. No issues were found with the integration.

  • The color property is used in components like TextInput, Textarea, ToggleSwitch, Spinner, Select, Checkbox, Alert, Badge, Avatar, and Button.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `color` with other components.

# Test: Search for the usage of `color` in other components. Expect: Proper handling of the new type.
rg --type typescript -A 5 $'color'

Length of output: 68


Script:

#!/bin/bash
# Description: Verify the integration of `color` with other components.

# Test: Search for the usage of `color` in other components. Expect: Proper handling of the new type.
rg --type ts -A 5 $'color'

Length of output: 194745


86-86: Enhanced type flexibility for size.

The change to size using DynamicStringEnumKeysOf<ButtonSizes> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Button.

Run the following script to verify the integration of size with other components:

Verification successful

Integration of size with other components verified.

The size property using DynamicStringEnumKeysOf<ButtonSizes> is integrated across various components, ensuring flexibility and adaptability. The search results indicate that the new type is being used consistently in different parts of the codebase, such as in Button, Spinner, Badge, Avatar, and other components. This suggests that the change is well-integrated and should function as intended.

  • Files and lines where size is used:
    • packages/ui/src/components/Button/Button.tsx
    • packages/ui/src/components/Spinner/Spinner.tsx
    • packages/ui/src/components/Badge/Badge.tsx
    • packages/ui/src/components/Avatar/Avatar.tsx

The integration appears to be consistent and aligns with the intended flexibility of the size property.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `size` with other components.

# Test: Search for the usage of `size` in other components. Expect: Proper handling of the new type.
rg --type typescript -A 5 $'size'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify the integration of `size` with other components.

# Test: Search for the usage of `size` in other components. Expect: Proper handling of the new type.
rg --type ts -A 5 $'size'

Length of output: 144155


76-76: Enhanced type flexibility for gradientDuoTone.

The change to gradientDuoTone using DynamicStringEnumKeysOf<ButtonGradientDuoToneColors> enhances flexibility and adaptability. Ensure that this change integrates well with other components that use Button.

Run the following script to verify the integration of gradientDuoTone with other components:

SutuSebastian
SutuSebastian previously approved these changes Sep 9, 2024
Copy link
Collaborator

@SutuSebastian SutuSebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

I had some progress on this some time ago [see here] but never really had the time to wrap it up, although its functional.

@SutuSebastian
Copy link
Collaborator

SutuSebastian commented Sep 9, 2024

@KRTirtho the only thing left is to make a changeset, run the following command:
bun changeset and select the flowbite-react package, then skip the version bumps until u get to the patch

See changesets docs here.

U only need to push the .md created file, the CI will do the versioning and release.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 641f81a and 53f84cd.

Files selected for processing (1)
  • .changeset/plenty-lemons-bow.md (1 hunks)
Additional comments not posted (1)
.changeset/plenty-lemons-bow.md (1)

1-5: Changeset configuration and description are correctly formatted.

The changeset file is well-prepared, with clear indications of the affected package (flowbite-react) and the type of update (patch). The description succinctly captures the essence of the PR, which is to fix the autocomplete issue for string enums with dynamic values.

@KRTirtho
Copy link
Contributor Author

KRTirtho commented Sep 9, 2024

Thanks for the direction. So, as you instructed, I added the changesets.

@SutuSebastian SutuSebastian merged commit 38913e5 into themesberg:main Sep 9, 2024
8 checks passed
@github-actions github-actions bot mentioned this pull request Sep 9, 2024
@rluders rluders mentioned this pull request Sep 12, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants