nextui icon indicating copy to clipboard operation
nextui copied to clipboard

Add form component

Open ryo-manba opened this issue 1 year ago • 6 comments

📝 Description

Added a Form component and upgraded the entire react-aria version to resolve typecheck errors from version mismatches. The details of the react-aria update are provided in the inline comments of the following PR. https://github.com/nextui-org/nextui/pull/3732

⛳️ Current behavior (updates)

Currently, there is no Form component available, and the version of react-aria does not support the latest features related to form handling.

🚀 New behavior

The new Form component has been added, allowing users to utilize features such as validation behavior switching and error handling through serverErrors. Additionally, the react-aria version has been updated to incorporate the latest form-related improvements.

https://github.com/user-attachments/assets/40f6fff6-68a0-4b92-8273-eebd7a52ae1f

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

No.

📝 Additional Information

A guideline on how to use the new Form component will be added in a separate PR. It will be based on the following reference. React Aria Forms Guide

Test

Please verify the following in each story.

  1. The Form component allows toggling of validationBehavior.
  2. Error messages are correctly displayed based on the name field when provided via serverErrors.

Summary by CodeRabbit

  • New Features

    • Introduced a new form component in the @nextui-org/form package for easier form management and validation.
    • Added support for server-side validation in components like Autocomplete, CheckboxGroup, DatePicker, and RadioGroup, enhancing validation capabilities.
  • Bug Fixes

    • Removed the layoutNode prop from the @nextui-org/table package to align with updates in the underlying library.
  • Chores

    • Updated multiple package versions across the NextUI library for improved functionality and compatibility.

ryo-manba avatar May 21 '24 15:05 ryo-manba

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

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 7:56pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 7:56pm

vercel[bot] avatar May 21 '24 15:05 vercel[bot]

🦋 Changeset detected

Latest commit: 1aab6281339e9f951a81510eb9eb7d04a379d7a8

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

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

changeset-bot[bot] avatar May 21 '24 15:05 changeset-bot[bot]

[!IMPORTANT]

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (5)
  • main
  • canary
  • fix/.*
  • chore/.*
  • feat/.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request includes extensive updates to the package.json files across multiple packages in the @nextui-org project. The updates primarily focus on incrementing dependency versions for various @react-aria, @react-stately, and @react-types packages, as well as adding new dependencies like @nextui-org/form in several components. Additionally, some files introduce modifications to testing suites and type definitions, particularly enhancing type safety in the useDropdown hook.

Changes

File Path Change Summary
apps/docs/package.json Updated versions for dependencies, including @internationalized/date and several @react-aria packages.
package.json Updated to version 2.0.0, modified devDependencies for @react-types/link and @react-types/shared.
packages/components/checkbox/package.json Added dependency @nextui-org/form, updated several @react-aria and @react-stately packages.
packages/components/date-picker/tests/date-picker.test.tsx Added validation tests for the DatePicker component, including server-side validation checks.
packages/components/date-picker/package.json Updated @internationalized/date, added @nextui-org/form, and updated several @react-aria and @react-stately packages.
packages/components/date-picker/src/use-date-picker.ts Enhanced useDatePicker hook with new validation behavior and optional classNames property.
packages/components/date-picker/src/use-date-range-picker.ts Enhanced useDateRangePicker hook with new validation behavior and optional classNames property.
packages/components/date-picker/stories/date-picker.stories.tsx Added a new story for server-side validation in the DatePicker.
packages/components/date-picker/stories/date-range-picker.stories.tsx Added a new story for server-side validation in the DateRangePicker.
packages/core/react/package.json Added @nextui-org/form, restored @nextui-org/alert, removed @nextui-org/drawer, updated @react-aria/visually-hidden.
packages/core/react/src/index.ts Added export for @nextui-org/form.
packages/core/system/package.json Updated @internationalized/date, added @react-aria/i18n, and updated several other dependencies.
... ... (similar updates for other packages like accordion, alert, button, etc.)
packages/hooks/use-draggable/package.json Updated @react-aria/interactions from ^3.21.1 to 3.22.4.
packages/hooks/use-intersection-observer/package.json Updated versions for @react-aria/utils, @react-aria/ssr, and @react-types/shared.
packages/hooks/use-pagination/package.json Updated @react-aria/i18n from 3.12.2 to 3.12.3.
packages/utilities/aria-utils/package.json Updated several dependencies, including @react-aria/utils, @react-stately/collections, and @react-types/shared.
.vscode/settings.json Fixed JSON syntax for Tailwind CSS configuration.
packages/components/dropdown/src/use-dropdown.ts Updated return type of useDropdown function to UseDropdownReturn, enhancing type clarity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DatePicker
    participant Form

    User->>Form: Submit with DatePicker
    Form->>DatePicker: Validate input
    DatePicker-->>Form: Return validation result
    Form-->>User: Display validation feedback

Possibly related PRs

  • #3302: This PR introduces month and year pickers to the DateRangePicker and RangeCalendar components, which is directly related to the updates in the package.json for the @nextui-org/date-picker and @nextui-org/calendar packages in the main PR, as both involve enhancements to date selection functionalities.
  • #3501: This PR adds @react-types/shared to the dependencies of the system-rsc package, which is relevant as it reflects ongoing maintenance and updates to dependencies that may also affect the components in the main PR.
  • #3843: Although this PR focuses on fixing image URLs, it is part of the broader documentation and component updates that may relate to the overall maintenance and enhancement efforts reflected in the main PR.

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • jrgarciadev
  • wingkwong

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

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.

coderabbitai[bot] avatar May 21 '24 15:05 coderabbitai[bot]

@ryo-manba please pull the changes from canary

jrgarciadev avatar May 22 '24 21:05 jrgarciadev

@ryo-manba fix conflicts

jrgarciadev avatar Oct 14 '24 14:10 jrgarciadev

@jrgarciadev I've fixed it.

ryo-manba avatar Oct 15 '24 14:10 ryo-manba

When merging, please close the related issue in this PR.

  • https://github.com/nextui-org/nextui/pull/3732

ryo-manba avatar Oct 20 '24 12:10 ryo-manba

Thank you for your contribution, I have been looking forward to this update for a long time!

Because in nextjs, collection controls will fail in server-side components, which is painful for me.

Scholar01 avatar Oct 20 '24 16:10 Scholar01

👀👀 🙏

Scholar01 avatar Oct 22 '24 07:10 Scholar01

@ryo-manba I uninstalled react-aria-components and moved only the needed types and functions to the form package this helps with decreasing the package size https://github.com/nextui-org/nextui/pull/3036/commits/3cf79887508b64e6a3efd4d319b51823598ee003, all tests passed

jrgarciadev avatar Nov 27 '24 19:11 jrgarciadev