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

feat(form): radio input with radio group component #45

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

erfanmoghadasi
Copy link
Collaborator

@erfanmoghadasi erfanmoghadasi commented Apr 29, 2024

Closes #44

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Introduced radio input functionality in forms.
    • Added RadioGroup component to manage and display radio options.
    • Enhanced form selector to support radio input fields.
  • Improvements

    • Updated form input labels for consistency.
    • Enhanced configurability and functionality of radio components with new type definitions.
  • Removals

    • Removed nested checkbox objects under form-checkbox-1 for better form management.

@erfanmoghadasi erfanmoghadasi self-assigned this Apr 29, 2024
@erfanmoghadasi erfanmoghadasi linked an issue Apr 29, 2024 that may be closed by this pull request
Copy link

vercel bot commented Apr 29, 2024

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

Name Status Preview Comments Updated (UTC)
mui-builder ❌ Failed (Inspect) Jul 13, 2024 11:04am

Copy link

coderabbitai bot commented Apr 29, 2024

Walkthrough

The recent changes introduce new functionalities to handle radio input fields within a form module. This includes adding a RadioGroup component, defining necessary type definitions, and enhancing the form selector to manage radio inputs. Nested checkbox objects have been removed, and label properties updated for consistency.

Changes

Files/Modules Change Summary
apps/docs/src/app/app.tsx Added a radio input object and removed nested checkbox objects; updated label properties.
packages/core/src/modules/form/src/components/fields/radio/radio.types.ts Introduced type definitions for RadioProps and RadioGroupProps.
packages/core/src/modules/form/src/components/fields/radio/radioGroup.tsx Added RadioGroup component to manage radio options.
packages/core/src/modules/form/src/components/fields/radio/useRadio.ts Introduced useRadio custom hook for radio input management.
packages/core/src/modules/form/src/components/fields/radio/useRadioGroup.ts Introduced useRadioGroup custom hook to handle radio group functionality.
packages/core/src/modules/form/src/types/public.types.ts Updated types to include RadioGroupProps and radio as form types.
packages/core/src/modules/form/src/utils/selector/formSelector.tsx Enhanced FormSelector to support radio input fields by adding a case for radio.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FormSelector
    participant RadioGroup
    participant Radio
    User->>FormSelector: Select radio input
    FormSelector->>RadioGroup: Initialize radio group
    RadioGroup->>Radio: Create radio options
    User->>RadioGroup: Interact with radio buttons
    RadioGroup->>FormSelector: Return selected value
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Handle a group of radio input that wrapped with radioGroup component (#44)

Poem

In the forms where fields reside,
Radio buttons now take pride.
Options clear, with labels true,
User choices come into view.
Checkboxes have bid adieu,
With changes fresh, the app renews.
🐇💻✨


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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

@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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 944db6b and 587bca9.
Files selected for processing (3)
  • apps/docs/src/app/app.tsx (2 hunks)
  • packages/core/src/modules/form/src/types/public.types.ts (2 hunks)
  • packages/core/src/modules/form/src/utils/selector/formSelector.tsx (2 hunks)
Additional Context Used
Biome (19)
apps/docs/src/app/app.tsx (4)

143-143: Do not use template literals if interpolation and special-character handling are not needed.


5-6: Some named imports are only used as types.


6-7: Some named imports are only used as types.


245-245: Avoid passing children using a prop

packages/core/src/modules/form/src/types/public.types.ts (7)

1-1: All these imports are only used as types.


2-3: All these imports are only used as types.


3-7: All these imports are only used as types.


7-8: All these imports are only used as types.


8-9: All these imports are only used as types.


9-10: All these imports are only used as types.


10-11: All these imports are only used as types.

packages/core/src/modules/form/src/utils/selector/formSelector.tsx (8)

21-21: This variable implicitly has the any type.


1-1: Some named imports are only used as types.


2-3: All these imports are only used as types.


3-7: All these imports are only used as types.


7-8: All these imports are only used as types.


8-9: All these imports are only used as types.


9-10: All these imports are only used as types.


10-11: All these imports are only used as types.

Additional comments not posted (4)
packages/core/src/modules/form/src/types/public.types.ts (3)

9-9: The import of RadioGroupProps is correctly added to support the new radio input type.


24-24: The addition of 'radio' to the FormTypes enum aligns with the new functionality introduced in this PR.


31-31: The inclusion of RadioGroupProps in the FieldProps union type is appropriate for supporting the new radio input functionality.

apps/docs/src/app/app.tsx (1)

187-200: The addition of the radio input configuration is correctly implemented and aligns with the objectives of the PR. The properties are appropriately set, and the structure is consistent with other form fields.

Comment on lines +71 to +80
case 'radio':
SelectedComponent = lazy(
() => import('../../components/fields/radio/radioGroup')
);

return (
<Suspense key={fieldProps.id} fallback={<SubmitLoading {...loading} />}>
<SelectedComponent {...(fieldProps as RadioGroupProps)} />
</Suspense>
);
Copy link

Choose a reason for hiding this comment

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

The implementation for the 'radio' case in the switch statement follows the established pattern and correctly uses lazy loading and suspense. Consider using a more specific loading component for radio fields, similar to other field types, to enhance user experience.

- <Suspense key={fieldProps.id} fallback={<SubmitLoading {...loading} />}>
+ <Suspense key={fieldProps.id} fallback={<RadioLoading {...loading} />}>

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
case 'radio':
SelectedComponent = lazy(
() => import('../../components/fields/radio/radioGroup')
);
return (
<Suspense key={fieldProps.id} fallback={<SubmitLoading {...loading} />}>
<SelectedComponent {...(fieldProps as RadioGroupProps)} />
</Suspense>
);
case 'radio':
SelectedComponent = lazy(
() => import('../../components/fields/radio/radioGroup')
);
return (
<Suspense key={fieldProps.id} fallback={<RadioLoading {...loading} />}>
<SelectedComponent {...(fieldProps as RadioGroupProps)} />
</Suspense>
);

Copy link

@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 (2)
packages/core/src/modules/form/src/utils/selector/formSelector.tsx (1)

72-81: Consider using a more specific loading component for radio fields.

The implementation for the 'radio' case in the switch statement follows the established pattern and correctly uses lazy loading and suspense. Consider using a more specific loading component for radio fields, similar to other field types, to enhance user experience.

- <Suspense key={fieldProps.id} fallback={<SubmitLoading {...loading} />}>
+ <Suspense key={fieldProps.id} fallback={<RadioLoading {...loading} />}>
apps/docs/src/app/app.tsx (1)

187-201: Potential Duplicate IDs Detected

The id: 'radio-1' appears to be a duplicate, which could cause issues. Additionally, formId: '20' appears multiple times, which might be acceptable if they belong to different forms but needs verification. The name: 'fol' does not appear to have duplicates.

Please verify the context of formId: '20' and id: 'radio-1' to ensure they are unique within their respective forms.

  • Potential duplicate id: 'radio-1'
  • Multiple instances of formId: '20'
Analysis chain

LGTM! Verify the uniqueness and integration of radio input properties.

The radio input object is well-structured and follows the established pattern for defining form fields. Ensure that the formId, id, and name properties are unique and correctly integrated within the form.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the uniqueness and integration of radio input properties.

# Test: Search for duplicate `formId`, `id`, and `name` properties. Expect: No duplicates.
rg --type js -e 'formId: .+,' -e 'id: .+,' -e 'name: .+,' apps/docs/src/app/app.tsx

Length of output: 1589

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 587bca9 and 6518310.

Files selected for processing (7)
  • apps/docs/src/app/app.tsx (3 hunks)
  • packages/core/src/modules/form/src/components/fields/radio/radio.types.ts (1 hunks)
  • packages/core/src/modules/form/src/components/fields/radio/radioGroup.tsx (1 hunks)
  • packages/core/src/modules/form/src/components/fields/radio/useRadio.ts (1 hunks)
  • packages/core/src/modules/form/src/components/fields/radio/useRadioGroup.ts (1 hunks)
  • packages/core/src/modules/form/src/types/public.types.ts (3 hunks)
  • packages/core/src/modules/form/src/utils/selector/formSelector.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • packages/core/src/modules/form/src/components/fields/radio/useRadio.ts
Additional comments not posted (10)
packages/core/src/modules/form/src/components/fields/radio/radioGroup.tsx (3)

1-8: Imports look good.

The imports are necessary and correctly referenced.


10-20: Component definition looks good.

The RadioGroup component correctly uses the custom hook useRadioGroup and renders the radio options.


22-22: Export statement looks good.

The RadioGroup component is correctly exported as the default export.

packages/core/src/modules/form/src/components/fields/radio/radio.types.ts (2)

1-5: Imports look good.

The imports are necessary and correctly referenced.


13-28: Type definitions look good.

The RadioProps and RadioGroupProps type definitions are comprehensive and correctly defined.

packages/core/src/modules/form/src/types/public.types.ts (2)

7-7: Import looks good.

The import of RadioGroupProps is necessary and correctly referenced.


Line range hint 25-38: Type definitions look good.

The updates to FormTypes and FieldProps to include the new radio form type and RadioGroupProps are comprehensive and correctly defined.

packages/core/src/modules/form/src/components/fields/radio/useRadioGroup.ts (2)

1-12: Imports look good.

The imports are necessary and correctly referenced.


14-84: Custom hook implementation looks good.

The useRadioGroup hook is correctly implemented and comprehensive, managing radio group functionality for forms.

apps/docs/src/app/app.tsx (1)

248-248: LGTM!

The inputLabelProps children update to 'input label' is straightforward and corrects the label text.

id: 'radio-1',
name: 'fol',
defaultValue: '2',
radioInputsList: [
Copy link
Owner

Choose a reason for hiding this comment

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

Convert to options

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.

radio input in form module
2 participants