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): number input with comma seperator #53

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Conversation

erfanmoghadasi
Copy link
Collaborator

@erfanmoghadasi erfanmoghadasi commented Jul 3, 2024

Closes #52

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

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

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Introduced a new NumberField component for form inputs, allowing users to interact with number fields.
    • Added loading state indicators for number fields to improve user experience during data fetches.
  • Enhancements

    • Expanded form functionality with the lazy loading of the NumberField component.
  • Developer Experience

    • Added VS Code configuration setting for the CodeGPT API key to streamline development setup.

@erfanmoghadasi erfanmoghadasi added the feat Feature label Jul 3, 2024
@erfanmoghadasi erfanmoghadasi requested a review from mrbadri July 3, 2024 11:48
@erfanmoghadasi erfanmoghadasi self-assigned this Jul 3, 2024
@erfanmoghadasi erfanmoghadasi linked an issue Jul 3, 2024 that may be closed by this pull request
Copy link

vercel bot commented Jul 3, 2024

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

Name Status Preview Comments Updated (UTC)
mui-builder ❌ Failed (Inspect) Jul 8, 2024 1:52pm

Copy link

coderabbitai bot commented Jul 3, 2024

Warning

Rate limit exceeded

@mrbadri has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 10 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between c2a905a and 47db246.

Walkthrough

This update introduces a new NumberField component and related features for handling number input in forms. The changes span setting up a new API key configuration, enhancing the form handling logic to support number fields, and updating selectors to lazily load the new component. The update ensures a seamless user experience with added support for formatted number inputs.

Changes

Files/Modules Summary
.vscode/settings.json Added configuration for CodeGPT API key.
apps/docs/src/app/app.tsx Added new form number object to tabs array in App function.
packages/core/src/modules/form/src/components/fields/number/ Introduced NumberField, NumberFieldLoading components and useNumberField, useNumberFieldLoading hooks for handling number field rendering and loading states.
packages/core/src/modules/form/src/types/public.types.ts Updated to export NumberFieldProps and included 'number' in FormTypes and FieldProps types.
packages/core/src/modules/form/src/utils/selector/formSelector.tsx Enhanced to include lazy loading for NumberField component and its loading indicator.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant FormSelector
    participant NumberField
    User->>App: Loads Application
    App->>FormSelector: Initialize form
    FormSelector->>NumberField: Lazy load number field
    NumberField-->>FormSelector: Ready
    FormSelector-->>App: Render number field
    App-->>User: Displays number input
Loading

Assessment against linked issues

Objective Addressed Explanation
Input Number component supporting formatted number input (#52)

Poem

In the fields of numbers, our code now plays,
Enhancing forms in wondrous ways.
With lazy loading and numbers bright,
Our app now dances in the user's sight.
Oh joy, these features come to light!
🐰✨💻


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: 2

Outside diff range and nitpick comments (4)
packages/core/src/modules/form/src/components/fields/number/number.loading.tsx (1)

1-3: Ensure consistent import ordering.

Consider ordering the imports by external libraries first, followed by internal modules for better readability and maintainability.

packages/core/src/modules/form/src/components/fields/number/number.tsx (1)

1-7: Ensure consistent import ordering.

Consider ordering the imports by external libraries first, followed by internal modules for better readability and maintainability.

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

Line range hint 11-31: Typographical error in type name.

The type name Dependesies should be corrected to Dependencies.

- export type Dependesies = string[];
+ export type Dependencies = string[];
packages/core/src/modules/form/src/components/fields/number/useNumber.ts (1)

1-2: Consider Grouping Related Imports

The imports from react-hook-form are correct. Consider grouping related imports together to improve readability.

- import { useController, useWatch } from 'react-hook-form';
+ import { useController, useWatch } from 'react-hook-form';
+ import useQueryBuilder from '@mui-builder/utils/useQueryBuilder/useQueryBuilder';
+ import UseScript from '@mui-builder/utils/useScript/useScript';
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c547b91 and c2a905a.

Files selected for processing (9)
  • .vscode/settings.json (1 hunks)
  • apps/docs/src/app/app.tsx (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/number.loading.tsx (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/number.tsx (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/number.types.ts (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/useNumber.loading.ts (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/useNumber.ts (1 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)
Files skipped from review due to trivial changes (1)
  • .vscode/settings.json
Additional context used
Biome
packages/core/src/modules/form/src/components/fields/number/useNumber.ts

[error] 53-53: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

Additional comments not posted (7)
packages/core/src/modules/form/src/components/fields/number/number.loading.tsx (2)

7-11: LGTM!

The NumberFieldLoading component correctly uses the Skeleton component from Material-UI and the custom hook useNumberFieldLoading to get the props.


5-5: Avoid potential circular dependency.

Ensure that useNumberFieldLoading does not create a circular dependency with NumberFieldLoading.

Verification successful

No circular dependency detected.

The useNumberFieldLoading does not create a circular dependency with NumberFieldLoading.

  • useNumberFieldLoading is defined in useNumber.loading.ts and does not reference number.loading.tsx.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if there is a circular dependency involving `useNumberFieldLoading`.

# Test: Check for circular dependencies. Expect: No circular dependencies.
rg --type js --type ts 'useNumberFieldLoading' | grep 'number.loading.tsx'

Length of output: 358



Script:

#!/bin/bash
# Description: Check if `useNumberFieldLoading` creates a circular dependency by importing or referencing `number.loading.tsx`.

# Locate the file that defines `useNumberFieldLoading`
file_path=$(fd useNumber.loading.tsx)

# Search for imports or references to `number.loading.tsx` within the located file
rg 'number.loading.tsx' $file_path

Length of output: 64



Script:

#!/bin/bash
# Description: Check if `useNumberFieldLoading` creates a circular dependency by importing or referencing `number.loading.tsx`.

# Locate all files that match `useNumber.loading.tsx`
fd useNumber.loading.tsx

# Search for imports or references to `number.loading.tsx` within the located files
fd useNumber.loading.tsx --exec rg 'number.loading.tsx' {}

Length of output: 87



Script:

#!/bin/bash
# Description: Locate the definition of `useNumberFieldLoading` and check for references to `number.loading.tsx`.

# Locate the definition of `useNumberFieldLoading`
ast-grep --lang ts --pattern 'function useNumberFieldLoading($_) { $$$ }'

# Check for references to `number.loading.tsx` within the located file(s)
fd useNumber.loading.tsx --exec rg 'number.loading.tsx' {}

Length of output: 136



Script:

#!/bin/bash
# Description: Locate all instances of `useNumberFieldLoading` definition and check for references to `number.loading.tsx`.

# Locate all instances of `useNumberFieldLoading` definition
ast-grep --lang ts --pattern 'const useNumberFieldLoading = $_' 
ast-grep --lang ts --pattern 'function useNumberFieldLoading($_) { $$$ }'

# Check for references to `number.loading.tsx` within the located files
fd useNumber.loading.tsx --exec rg 'number.loading.tsx' {}

Length of output: 2137

packages/core/src/modules/form/src/components/fields/number/number.tsx (1)

9-15: LGTM!

The NumberField component correctly uses the TextField component from Material-UI and the custom hook useNumberField to get the props and visibility state.

packages/core/src/modules/form/src/components/fields/number/useNumber.loading.ts (1)

1-22: LGTM!

The useNumberFieldLoading hook correctly extracts and returns the props for the Skeleton component.

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

14-15: Ensure Consistency in Import Statements

The import statements for NumberFieldProps and NumberFieldLoading are correctly added. Make sure the paths are accurate and consistent with the rest of the project.


72-81: New Field Type Integration Looks Good

The integration of the new 'number' field type in the FormSelector component looks good. The lazy loading and fallback to NumberFieldLoading are implemented correctly.

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

222-231: New Number Field Type Added Correctly

The new number field type is added correctly to the children array in the App component. Ensure that the id and formId values are unique and accurate.

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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c2a905a and 0de28fe.

Files selected for processing (3)
  • apps/docs/src/app/app.tsx (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/number.types.ts (1 hunks)
  • packages/core/src/modules/form/src/components/fields/number/useNumber.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/docs/src/app/app.tsx
  • packages/core/src/modules/form/src/components/fields/number/number.types.ts
Additional context used
Biome
packages/core/src/modules/form/src/components/fields/number/useNumber.ts

[error] 60-60: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

Additional comments not posted (8)
packages/core/src/modules/form/src/components/fields/number/useNumber.ts (8)

1-12: LGTM! Imports are relevant and necessary.

The imports are appropriate for the functionality provided in this file.


27-32: LGTM! API and form hooks are used appropriately.

The hooks are correctly used to manage the API and form state.


33-34: LGTM! Props controller usage is appropriate.

The usage of usePropsController and the assignment of newProps are correct.


35-42: LGTM! Script handling is appropriate.

The script handling using the UseScript hook is correct.


44-47: LGTM! Number formatting function is correct.

The formatNumber function correctly formats the number with thousands separators.


65-69: LGTM! useWatch hook is used correctly.

The useWatch hook is correctly used to watch dependencies.


71-79: LGTM! API call handling is correct.

The useQueryBuilder hook is correctly used to handle API calls.


81-111: LGTM! Controller usage and return statement are correct.

The useController hook is correctly used to manage the field state. The return statement correctly returns the field props.

@mrbadri mrbadri merged commit d20e56c into main Jul 8, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[FEAT] Input Number
2 participants