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(docs): types in date-related doc pages #3393

Open
wants to merge 8 commits into
base: canary
Choose a base branch
from

Conversation

wingkwong
Copy link
Member

@wingkwong wingkwong commented Jul 2, 2024

Closes #

📝 Description

Add a brief description

⛳️ Current behavior (updates)

Please describe the current behavior that you are modifying

🚀 New behavior

Please describe the behavior or changes this PR adds

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

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Updated onChange handlers in date-input, date-picker, DateRangePicker, and RangeCalendar components to use MappedDateValue for better date handling.
    • Introduced new date-related types and classes, including SupportedCalendars, MappedDateValue, DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime.
  • Refactor

    • Improved height handling in the useImage function with a more efficient useMemo implementation.

Copy link

vercel bot commented Jul 2, 2024

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 Jul 6, 2024 10:23am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2024 10:23am

Copy link

changeset-bot bot commented Jul 2, 2024

⚠️ No Changeset found

Latest commit: 94b8ed2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link
Contributor

coderabbitai bot commented Jul 2, 2024

Walkthrough

Recent updates to the documentation and codebase include enhancing type definitions related to date and time handling, refining data structures, and adjusting method parameters. These changes largely focus on standardizing how dates and times are represented across components and improving the handling of component properties in the useImage hook.

Changes

File Path Change Summary
apps/docs/content/docs/components/calendar.mdx Reorganized and added type definitions for various calendar and date-time classes and methods.
apps/docs/content/docs/components/date-input.mdx Updated onChange handler to expect MappedDateValue; introduced new types for date handling.
apps/docs/content/docs/components/date-picker.mdx Updated onChange handler to accept MappedDateValue and added multiple new date-related types and classes.
apps/docs/content/docs/components/date-range-picker.mdx Added new types for date handling, including RangeValue, MappedDateValue, and various date-time classes with specific properties and methods.
apps/docs/content/docs/components/range-calendar.mdx Updated onChange handler to expect RangeValue with nested MappedDateValue<DateValue>.
packages/components/image/src/use-image.ts Updated useImage function to remove height destructuring from props, instead calculating inside a useMemo, and adjusted the return object to include both width (w) and height (h).

Sequence Diagram(s)

(For this set of changes, generating sequence diagrams isn't necessary, as the changes are primarily related to type definitions, handler parameter updates, and minor refactoring.)


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
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.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9daef56 and fc28b37.

Files selected for processing (1)
  • apps/docs/content/docs/components/range-calendar.mdx (1 hunks)
Additional comments not posted (1)
apps/docs/content/docs/components/range-calendar.mdx (1)

239-239: Correct the onChange handler type.

The onChange handler type has been correctly updated to RangeValue<MappedDateValue<DateValue>>. This change ensures that the handler processes and handles value changes appropriately.

@wingkwong wingkwong changed the title fix(docs): onChange value type in date-range-picker page fix(docs): types in date-related doc pages Jul 6, 2024
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: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fc28b37 and 94b8ed2.

Files selected for processing (6)
  • apps/docs/content/docs/components/calendar.mdx (2 hunks)
  • apps/docs/content/docs/components/date-input.mdx (1 hunks)
  • apps/docs/content/docs/components/date-picker.mdx (1 hunks)
  • apps/docs/content/docs/components/date-range-picker.mdx (1 hunks)
  • apps/docs/content/docs/components/range-calendar.mdx (2 hunks)
  • packages/components/image/src/use-image.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/docs/content/docs/components/range-calendar.mdx
Additional comments not posted (18)
packages/components/image/src/use-image.ts (2)

124-137: Consolidate width and height calculations.

The changes to consolidate width and height calculations into a single useMemo block are efficient and improve code readability.

However, ensure that props is correctly used and passed in the context.

Verification successful

Verified: Correct usage of props in useImage function.

The props object is correctly used and passed within the useImage function. The consolidation of width and height calculations into a single useMemo block is efficient and improves code readability.

  • props is mapped from originalProps and used consistently within the function.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `props` in the `useImage` function.

# Test: Search for the usage of `props` within the `useImage` function. Expect: Correct usage and passing of `props`.
rg --type js --pcre2 "props" packages/components/image/src/use-image.ts

Length of output: 579


170-170: Conditional application of height.

The logic for applying height conditionally based on otherProps is correct.

Ensure that otherProps is properly populated in the context.

apps/docs/content/docs/components/date-input.mdx (3)

330-330: Update onChange handler type.

The update to the onChange handler type aligns with the new date and time types.

Ensure the new type MappedDateValue is correctly used and documented.


361-364: Introduce MappedDateValue type.

The MappedDateValue type maps DateValue to specific date and time types correctly.

Ensure that the mapping logic is accurate.


369-372: Introduce DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime types.

The types represent different date and time formats correctly.

Ensure that the constructors and methods are accurately documented and implemented.

Also applies to: 379-419, 426-474, 481-535

Verification successful

Introduce DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime types.

The types represent different date and time formats correctly. The documentation and implementation for these types, including their constructors and methods, are accurately documented across various locations in the codebase.

  • Verified in:
    • apps/docs/content/components/date-range-picker/international-calendar.ts
    • apps/docs/content/components/date-range-picker/with-time-field.ts
    • apps/docs/content/components/date-range-picker/time-zones.ts
    • apps/docs/content/components/time-input/controlled.ts
    • apps/docs/content/components/time-input/timezones.ts
    • apps/docs/content/components/time-input/hour-cycle.ts
    • apps/docs/content/components/date-range-picker/presets.ts
    • apps/docs/content/components/time-input/hide-timezone.ts
    • apps/docs/content/components/date-range-picker/granularity.ts
    • apps/docs/content/components/range-calendar/controlled.ts
    • apps/docs/content/components/range-calendar/presets.ts
    • apps/docs/content/components/range-calendar/invalid-date.ts
    • apps/docs/content/components/range-calendar/index.ts
    • apps/docs/content/components/date-range-picker/controlled.ts
    • apps/docs/content/components/date-picker/controlled.ts
    • apps/docs/content/components/date-input/controlled.ts
    • apps/docs/content/components/date-input/disabled.ts
    • apps/docs/content/components/date-input/hide-timezone.ts
    • apps/docs/content/components/date-picker/preset.ts
    • apps/docs/content/components/date-picker/time-zones.ts
    • apps/docs/content/components/date-input/error-message-function.ts
    • apps/docs/content/components/date-input/usage.ts
    • apps/docs/content/components/date-input/hourly-cycle.ts
    • apps/docs/content/components/date-input/time-zones.ts
    • apps/docs/content/components/date-input/international-calendar.ts
    • apps/docs/content/components/date-input/variants.ts
    • apps/docs/content/components/date-input/readonly.ts
    • apps/docs/content/components/date-input/label-placements.ts
    • apps/docs/content/components/date-input/granularity.ts
    • apps/docs/content/components/date-input/error-message.ts
    • apps/docs/content/components/date-picker/granularity.ts
    • apps/docs/content/components/date-input/start-end-content.ts
    • apps/docs/content/components/date-picker/international-calendar.ts
    • apps/docs/content/components/date-input/required.ts
    • apps/docs/content/components/date-input/description.ts
    • apps/docs/content/components/calendar/presets.ts
    • apps/docs/content/components/calendar/invalid-date.ts
    • apps/docs/content/components/calendar/index.ts
    • apps/docs/content/components/calendar/controlled.ts
    • apps/docs/content/components/calendar/controlled-focused-value.ts
    • apps/docs/content/docs/components/time-input.mdx
    • apps/docs/content/docs/components/date-range-picker.mdx
    • apps/docs/content/docs/components/date-picker.mdx
    • apps/docs/content/docs/components/range-calendar.mdx
    • apps/docs/content/docs/components/calendar.mdx
    • apps/docs/content/docs/api-references/nextui-provider.mdx
    • apps/docs/content/blog/v2.3.0.mdx
    • apps/docs/config/search-meta.json
    • packages/components/calendar/src/index.ts
    • packages/components/calendar/stories/calendar.stories.tsx
    • packages/components/calendar/src/utils.ts
    • packages/components/calendar/src/use-range-calendar.ts
    • packages/components/calendar/stories/range-calendar.stories.tsx
    • packages/components/calendar/src/use-calendar.ts
    • packages/components/calendar/src/range-calendar.tsx
    • packages/components/calendar/src/calendar.tsx
    • packages/components/calendar/src/use-calendar-base.ts
    • packages/components/calendar/src/use-calendar-picker.ts
    • packages/components/calendar/src/calendar-month.tsx
    • packages/components/calendar/src/calendar-header.tsx
    • packages/components/calendar/src/calendar-cell.tsx
    • packages/components/calendar/__tests__/calendar.test.tsx
    • packages/components/calendar/__tests__/range-calendar.test.tsx
    • packages/components/date-picker/__tests__/date-picker.test.tsx
    • packages/components/date-input/src/use-date-input.ts
    • packages/components/date-input/stories/time-input.stories.tsx
    • packages/components/date-input/src/date-input.tsx
    • packages/components/date-input/stories/date-input.stories.tsx
    • packages/components/date-input/src/index.ts
    • packages/components/date-input/__tests__/time-input.test.tsx
    • packages/components/date-input/__tests__/date-input.test.tsx
    • packages/components/date-picker/src/use-date-picker-base.ts
    • packages/components/date-picker/stories/date-picker.stories.tsx
    • packages/components/date-picker/src/date-range-picker.tsx
    • packages/components/date-picker/src/date-range-picker-field.tsx
    • packages/components/date-picker/src/date-picker.tsx
    • packages/components/date-picker/src/use-date-range-picker.ts
    • packages/components/date-picker/src/use-date-picker.ts
    • packages/components/date-picker/stories/date-range-picker.stories.tsx
    • packages/core/system/src/provider-context.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation and implementation of constructors and methods in `DateValue`, `CalendarDate`, `CalendarDateTime`, and `ZonedDateTime`.

# Test: Search for the documentation and implementation of constructors and methods. Expect: Accurate documentation and implementation.
rg --type ts --pcre2 "(DateValue|CalendarDate|CalendarDateTime|ZonedDateTime)" apps/docs/content/docs/components

Length of output: 114


Script:

#!/bin/bash
# Description: Verify the documentation and implementation of constructors and methods in `DateValue`, `CalendarDate`, `CalendarDateTime`, and `ZonedDateTime`.

# Test: Search for the documentation and implementation of constructors and methods. Expect: Accurate documentation and implementation.
rg --pcre2 "(DateValue|CalendarDate|CalendarDateTime|ZonedDateTime)"

Length of output: 92664

apps/docs/content/docs/components/calendar.mdx (3)

274-277: Introduce DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime types.

The types represent different date and time formats correctly.

Ensure that the constructors and methods are accurately documented and implemented.

Also applies to: 284-324, 331-379, 386-440

Verification successful

Introduce DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime types.

The types represent different date and time formats correctly. The documentation and implementation of their constructors and methods are accurately provided in the codebase.

  • DateValue, CalendarDate, CalendarDateTime, and ZonedDateTime are well-documented in the .mdx files.
  • The constructors and methods for these types are implemented and documented as expected.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation and implementation of constructors and methods in `DateValue`, `CalendarDate`, `CalendarDateTime`, and `ZonedDateTime`.

# Test: Search for the documentation and implementation of constructors and methods. Expect: Accurate documentation and implementation.
rg --type ts --pcre2 "(DateValue|CalendarDate|CalendarDateTime|ZonedDateTime)" apps/docs/content/docs/components

Length of output: 114


Script:

#!/bin/bash
# Description: Verify the documentation and implementation of constructors and methods in `DateValue`, `CalendarDate`, `CalendarDateTime`, and `ZonedDateTime`.

# Test: Search the entire codebase for the documentation and implementation of constructors and methods. Expect: Accurate documentation and implementation.
rg --type-add 'docs:*.{ts,js,mdx}' --type docs --pcre2 "(DateValue|CalendarDate|CalendarDateTime|ZonedDateTime)"

Length of output: 69173


Line range hint 244-261:
Introduce SupportedCalendars type.

The SupportedCalendars type lists various calendar systems correctly.

Ensure that all listed calendars are supported.

Verification successful

All listed calendar types in SupportedCalendars are correctly supported.

The search results confirm that each calendar type listed in the SupportedCalendars type is referenced and supported across various parts of the codebase, including documentation, utility functions, and test files.

  • buddhist: Found in multiple files including dates.ts, types.ts, and several MDX files.
  • ethiopic: Found in dates.ts, types.ts, and several MDX files.
  • ethioaa: Found in dates.ts, types.ts, and several MDX files.
  • coptic: Found in dates.ts, types.ts, and several MDX files.
  • hebrew: Found in dates.ts, types.ts, and several MDX files.
  • indian: Found in dates.ts, types.ts, and several MDX files.
  • islamic-civil: Found in dates.ts, types.ts, and several MDX files.
  • islamic-tbla: Found in dates.ts, types.ts, and several MDX files.
  • islamic-umalqura: Found in dates.ts, types.ts, and several MDX files.
  • japanese: Found in dates.ts, types.ts, and several MDX files.
  • persian: Found in dates.ts, types.ts, and several MDX files.
  • roc: Found in dates.ts, types.ts, and several MDX files.
  • gregory: Found in dates.ts, types.ts, and several MDX files.

All calendar types are adequately supported and referenced in the codebase, confirming the correctness of the SupportedCalendars type definition.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the support for all listed calendars in `SupportedCalendars`.

# Test: Search for the usage and support for all listed calendars. Expect: Correct support for all listed calendars.
rg --type ts --pcre2 "SupportedCalendars" apps/docs/content/docs/components

Length of output: 75


Script:

#!/bin/bash
# Description: Verify the support for each listed calendar in `SupportedCalendars`.

# List of calendar types to verify
calendars=("buddhist" "ethiopic" "ethioaa" "coptic" "hebrew" "indian" "islamic-civil" "islamic-tbla" "islamic-umalqura" "japanese" "persian" "roc" "gregory")

# Search for each calendar type in the codebase
for calendar in "${calendars[@]}"; do
  echo "Searching for support for calendar type: $calendar"
  rg --type ts --pcre2 "$calendar" apps/docs/content/docs/components
done

Length of output: 2911


Script:

#!/bin/bash
# Description: Verify the support for each listed calendar in `SupportedCalendars` across the entire repository.

# List of calendar types to verify
calendars=("buddhist" "ethiopic" "ethioaa" "coptic" "hebrew" "indian" "islamic-civil" "islamic-tbla" "islamic-umalqura" "japanese" "persian" "roc" "gregory")

# Search for each calendar type in the entire repository
for calendar in "${calendars[@]}"; do
  echo "Searching for support for calendar type: $calendar"
  rg --pcre2 "$calendar"
done

Length of output: 23453


266-269: Introduce MappedDateValue type.

The MappedDateValue type maps DateValue to specific date and time types correctly.

Ensure that the mapping logic is accurate.

apps/docs/content/docs/components/date-picker.mdx (4)

367-380: Approved: SupportedCalendars type.

The SupportedCalendars type definition looks correct and comprehensive.


394-396: Approved: DateValue type.

The DateValue type definition as a union of CalendarDate, CalendarDateTime, and ZonedDateTime looks correct.


404-443: Approved: CalendarDate, CalendarDateTime, and ZonedDateTime classes.

The class definitions for CalendarDate, CalendarDateTime, and ZonedDateTime look comprehensive and well-documented. Ensure that the classes are correctly used and instantiated in the codebase.

Also applies to: 451-498, 506-559

Verification successful

Verified: Usage of CalendarDate, CalendarDateTime, and ZonedDateTime classes.

The classes CalendarDate, CalendarDateTime, and ZonedDateTime are correctly used and instantiated across various files in the codebase. The search results show proper references and instantiations of these classes.

  • Files with CalendarDate usage:

    • packages/core/system/src/provider-context.ts
    • apps/docs/content/components/date-input/error-message.ts
    • apps/docs/content/components/date-input/error-message-function.ts
    • apps/docs/content/components/date-input/required.ts
    • apps/docs/content/components/date-input/start-end-content.ts
    • apps/docs/content/components/date-input/variants.ts
    • apps/docs/content/components/date-input/usage.ts
    • apps/docs/content/components/date-input/readonly.ts
    • apps/docs/content/components/date-input/label-placements.ts
    • apps/docs/content/components/date-input/disabled.ts
    • packages/components/date-input/stories/date-input.stories.tsx
    • packages/components/date-picker/__tests__/date-picker.test.tsx
    • packages/components/date-input/__tests__/date-input.test.tsx
    • packages/components/calendar/src/calendar-month.tsx
    • packages/components/calendar/__tests__/calendar.test.tsx
    • packages/components/calendar/src/use-calendar-picker.ts
    • packages/components/calendar/src/calendar-header.tsx
    • packages/components/calendar/src/calendar-cell.tsx
    • packages/components/calendar/src/use-calendar-base.ts
    • packages/components/calendar/__tests__/range-calendar.test.tsx
    • packages/components/calendar/stories/range-calendar.stories.tsx
  • Files with CalendarDateTime usage:

    • packages/components/date-picker/__tests__/date-picker.test.tsx
    • packages/components/date-input/__tests__/date-input.test.tsx
  • Files with ZonedDateTime usage:

    • apps/docs/content/components/time-input/controlled.ts
    • apps/docs/content/components/time-input/hide-timezone.ts
    • packages/components/date-input/stories/time-input.stories.tsx
    • packages/components/date-input/__tests__/time-input.test.tsx

The search results confirm that the classes are used appropriately, and there are no apparent issues with their instantiation or usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `CalendarDate`, `CalendarDateTime`, and `ZonedDateTime` classes in the codebase.

# Test: Search for the usage of the classes. Expect: Correct usage and instantiation.
rg --type ts $'CalendarDate|CalendarDateTime|ZonedDateTime'

Length of output: 22860


386-388: LGTM! But verify the usage of the MappedDateValue type.

The MappedDateValue type definition looks correct. Ensure that the mapping logic is consistently used throughout the codebase.

apps/docs/content/docs/components/date-range-picker.mdx (6)

409-421: LGTM!

The RangeValue interface is well-defined and documented.


423-429: LGTM!

The MappedDateValue type definition is correct and aligns with the new type mappings for date values.


431-437: LGTM!

The DateValue type definition is correct and includes the appropriate date value types.


439-483: LGTM!

The CalendarDate class is well-defined and documented, providing detailed information about each property and method.


486-537: LGTM!

The CalendarDateTime class is well-defined and documented, providing detailed information about each property and method.


541-599: LGTM!

The ZonedDateTime class is well-defined and documented, providing detailed information about each property and method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📋 Scope : Docs Related to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants