Skip to content

Commit 7fb4f64

Browse files
authored
feat: Export Internationalized Date Types for DatePicker (#2170)
1 parent a5cb947 commit 7fb4f64

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

package-lock.json

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@deephaven/utils": "file:../utils",
3232
"@fortawesome/fontawesome-svg-core": "^6.2.1",
3333
"@fortawesome/react-fontawesome": "^0.2.0",
34+
"@internationalized/date": "^3.5.5",
3435
"@react-spectrum/theme-default": "^3.5.1",
3536
"@react-spectrum/utils": "^3.11.5",
3637
"@react-types/radio": "^3.8.1",

packages/components/src/spectrum/dateAndTime.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import {
2+
CalendarDate,
3+
CalendarDateTime,
4+
ZonedDateTime,
5+
} from '@internationalized/date';
6+
17
export {
28
Calendar,
39
type SpectrumCalendarProps as CalendarProps,
@@ -12,3 +18,17 @@ export {
1218
TimeField,
1319
type SpectrumTimeFieldProps as TimeFieldProps,
1420
} from '@adobe/react-spectrum';
21+
22+
export type { CalendarDate, CalendarDateTime, ZonedDateTime };
23+
24+
// This is the type for the DatePicker value
25+
export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
26+
27+
// This is the type for DatePicker onChange
28+
export type MappedDateValue<T> = T extends ZonedDateTime
29+
? ZonedDateTime
30+
: T extends CalendarDateTime
31+
? CalendarDateTime
32+
: T extends CalendarDate
33+
? CalendarDate
34+
: never;

0 commit comments

Comments
 (0)