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: Export Internationalized Date Types for DatePicker #2170

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@deephaven/utils": "file:../utils",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@internationalized/date": "^3.5.5",
"@react-spectrum/theme-default": "^3.5.1",
"@react-spectrum/utils": "^3.11.5",
"@react-types/radio": "^3.8.1",
Expand Down
20 changes: 20 additions & 0 deletions packages/components/src/spectrum/dateAndTime.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
CalendarDate,
CalendarDateTime,
ZonedDateTime,
} from '@internationalized/date';

export {
Calendar,
type SpectrumCalendarProps as CalendarProps,
Expand All @@ -12,3 +18,17 @@ export {
TimeField,
type SpectrumTimeFieldProps as TimeFieldProps,
} from '@adobe/react-spectrum';

export type { CalendarDate, CalendarDateTime, ZonedDateTime };

// This is the type for the DatePicker value
export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;

// This is the type for DatePicker onChange
export type MappedDateValue<T> = T extends ZonedDateTime
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably add a comment on these types describing why we need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed an update with some comments.

? ZonedDateTime
: T extends CalendarDateTime
? CalendarDateTime
: T extends CalendarDate
? CalendarDate
: never;
Loading