Skip to content

Commit

Permalink
feat: Export Internationalized Date Types for DatePicker (#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgodinez-dh authored Jul 24, 2024
1 parent a5cb947 commit 7fb4f64
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
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
? ZonedDateTime
: T extends CalendarDateTime
? CalendarDateTime
: T extends CalendarDate
? CalendarDate
: never;

0 comments on commit 7fb4f64

Please sign in to comment.