@react-types/datepicker 3.0.0-nightly.3113 → 3.0.0-nightly.3114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +7 -5
  2. package/src/index.d.ts +76 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/datepicker",
3
- "version": "3.0.0-nightly.3113+404d41859",
3
+ "version": "3.0.0-nightly.3114+68403fe55",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,14 +9,16 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "dependencies": {
12
- "@internationalized/date": "3.0.0-nightly.3113+404d41859",
13
- "@react-types/shared": "3.0.0-nightly.1417+404d41859"
12
+ "@internationalized/date": "3.5.6-nightly.5042+68403fe55",
13
+ "@react-types/calendar": "3.0.0-nightly.3114+68403fe55",
14
+ "@react-types/overlays": "3.8.10-nightly.5042+68403fe55",
15
+ "@react-types/shared": "3.0.0-nightly.3114+68403fe55"
14
16
  },
15
17
  "publishConfig": {
16
18
  "access": "public"
17
19
  },
18
20
  "peerDependencies": {
19
- "react": "^16.8.0 || ^17.0.0-rc.1"
21
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
20
22
  },
21
- "gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
23
+ "gitHead": "68403fe55489dce3de1b3094c957d598ad719861"
22
24
  }
package/src/index.d.ts CHANGED
@@ -16,14 +16,18 @@ import {
16
16
  FocusableProps,
17
17
  HelpTextProps,
18
18
  InputBase,
19
+ InputDOMProps,
19
20
  LabelableProps,
20
21
  RangeValue,
22
+ SpectrumFieldValidation,
21
23
  SpectrumLabelableProps,
22
24
  StyleProps,
23
25
  Validation,
24
26
  ValueBase
25
27
  } from '@react-types/shared';
26
28
  import {CalendarDate, CalendarDateTime, Time, ZonedDateTime} from '@internationalized/date';
29
+ import {OverlayTriggerProps} from '@react-types/overlays';
30
+ import {PageBehavior} from '@react-types/calendar';
27
31
 
28
32
  export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
29
33
  type MappedDateValue<T> =
@@ -32,13 +36,15 @@ type MappedDateValue<T> =
32
36
  T extends CalendarDate ? CalendarDate :
33
37
  never;
34
38
 
35
- export type Granularity = 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
36
- interface DatePickerBase<T extends DateValue> extends InputBase, Validation, FocusableProps, LabelableProps, HelpTextProps {
39
+ export type Granularity = 'day' | 'hour' | 'minute' | 'second';
40
+ interface DateFieldBase<T extends DateValue> extends InputBase, Validation<MappedDateValue<T>>, FocusableProps, LabelableProps, HelpTextProps, OverlayTriggerProps {
37
41
  /** The minimum allowed date that a user may select. */
38
42
  minValue?: DateValue,
39
43
  /** The maximum allowed date that a user may select. */
40
44
  maxValue?: DateValue,
41
- /** A placeholder date to display when no value is selected. Defaults to today's date at midnight. */
45
+ /** Callback that is called for each date of the calendar. If it returns true, then the date is unavailable. */
46
+ isDateUnavailable?: (date: DateValue) => boolean,
47
+ /** A placeholder date that influences the format of the placeholder shown when no value is selected. Defaults to today's date at midnight. */
42
48
  placeholderValue?: T,
43
49
  /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */
44
50
  hourCycle?: 12 | 24,
@@ -48,19 +54,50 @@ interface DatePickerBase<T extends DateValue> extends InputBase, Validation, Foc
48
54
  * Whether to hide the time zone abbreviation.
49
55
  * @default false
50
56
  */
51
- hideTimeZone?: boolean
57
+ hideTimeZone?: boolean,
58
+ /**
59
+ * Whether to always show leading zeros in the month, day, and hour fields.
60
+ * By default, this is determined by the user's locale.
61
+ */
62
+ shouldForceLeadingZeros?: boolean
52
63
  }
53
64
 
65
+ interface AriaDateFieldBaseProps<T extends DateValue> extends DateFieldBase<T>, AriaLabelingProps, DOMProps {}
66
+ export interface DateFieldProps<T extends DateValue> extends DateFieldBase<T>, ValueBase<T | null, MappedDateValue<T>> {}
67
+ export interface AriaDateFieldProps<T extends DateValue> extends DateFieldProps<T>, AriaDateFieldBaseProps<T>, InputDOMProps {}
68
+
69
+ interface DatePickerBase<T extends DateValue> extends DateFieldBase<T>, OverlayTriggerProps {
70
+ /**
71
+ * Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration.
72
+ * @default visible
73
+ */
74
+ pageBehavior?: PageBehavior
75
+ }
54
76
  export interface AriaDatePickerBaseProps<T extends DateValue> extends DatePickerBase<T>, AriaLabelingProps, DOMProps {}
55
77
 
56
- export interface DatePickerProps<T extends DateValue> extends DatePickerBase<T>, ValueBase<T, MappedDateValue<T>> {}
57
- export interface AriaDatePickerProps<T extends DateValue> extends AriaDatePickerBaseProps<T>, DatePickerProps<T> {}
78
+ export interface DatePickerProps<T extends DateValue> extends DatePickerBase<T>, ValueBase<T | null, MappedDateValue<T>> {}
79
+ export interface AriaDatePickerProps<T extends DateValue> extends DatePickerProps<T>, AriaDatePickerBaseProps<T>, InputDOMProps {}
58
80
 
59
81
  export type DateRange = RangeValue<DateValue>;
60
- export interface DateRangePickerProps<T extends DateValue> extends DatePickerBase<T>, ValueBase<RangeValue<T>, RangeValue<MappedDateValue<T>>> {}
61
- export interface AriaDateRangePickerProps<T extends DateValue> extends AriaDatePickerBaseProps<T>, DateRangePickerProps<T> {}
82
+ export interface DateRangePickerProps<T extends DateValue> extends Omit<DatePickerBase<T>, 'validate'>, Validation<RangeValue<MappedDateValue<T>>>, ValueBase<RangeValue<T> | null, RangeValue<MappedDateValue<T>>> {
83
+ /**
84
+ * When combined with `isDateUnavailable`, determines whether non-contiguous ranges,
85
+ * i.e. ranges containing unavailable dates, may be selected.
86
+ */
87
+ allowsNonContiguousRanges?: boolean,
88
+ /**
89
+ * The name of the start date input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
90
+ */
91
+ startName?: string,
92
+ /**
93
+ * The name of the end date input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
94
+ */
95
+ endName?: string
96
+ }
97
+
98
+ export interface AriaDateRangePickerProps<T extends DateValue> extends Omit<AriaDatePickerBaseProps<T>, 'validate'>, DateRangePickerProps<T> {}
62
99
 
63
- interface SpectrumDatePickerBase<T extends DateValue> extends AriaDatePickerBaseProps<T>, SpectrumLabelableProps, StyleProps {
100
+ interface SpectrumDateFieldBase<T extends DateValue> extends SpectrumLabelableProps, HelpTextProps, SpectrumFieldValidation<MappedDateValue<T>>, StyleProps {
64
101
  /**
65
102
  * Whether the date picker should be displayed with a quiet style.
66
103
  * @default false
@@ -70,17 +107,25 @@ interface SpectrumDatePickerBase<T extends DateValue> extends AriaDatePickerBase
70
107
  * Whether to show the localized date format as help text below the field.
71
108
  * @default false
72
109
  */
73
- showFormatHelpText?: boolean,
110
+ showFormatHelpText?: boolean
111
+ }
112
+
113
+ interface SpectrumDatePickerBase<T extends DateValue> extends SpectrumDateFieldBase<T>, SpectrumLabelableProps, StyleProps {
74
114
  /**
75
115
  * The maximum number of months to display at once in the calendar popover, if screen space permits.
76
116
  * @default 1
77
117
  */
78
- maxVisibleMonths?: number
118
+ maxVisibleMonths?: number,
119
+ /**
120
+ * Whether the calendar popover should automatically flip direction when space is limited.
121
+ * @default true
122
+ */
123
+ shouldFlip?: boolean
79
124
  }
80
125
 
81
- export interface SpectrumDatePickerProps<T extends DateValue> extends DatePickerProps<T>, SpectrumDatePickerBase<T> {}
82
- export interface SpectrumDateRangePickerProps<T extends DateValue> extends DateRangePickerProps<T>, SpectrumDatePickerBase<T> {}
83
- export interface SpectrumDateFieldProps<T extends DateValue> extends Omit<SpectrumDatePickerProps<T>, 'maxVisibleMonths'> {}
126
+ export interface SpectrumDatePickerProps<T extends DateValue> extends Omit<AriaDatePickerProps<T>, 'isInvalid' | 'validationState'>, SpectrumDatePickerBase<T> {}
127
+ export interface SpectrumDateRangePickerProps<T extends DateValue> extends Omit<AriaDateRangePickerProps<T>, 'isInvalid' | 'validationState'>, Omit<SpectrumDatePickerBase<T>, 'validate'> {}
128
+ export interface SpectrumDateFieldProps<T extends DateValue> extends Omit<AriaDateFieldProps<T>, 'isInvalid' | 'validationState'>, SpectrumDateFieldBase<T> {}
84
129
 
85
130
  export type TimeValue = Time | CalendarDateTime | ZonedDateTime;
86
131
  type MappedTimeValue<T> =
@@ -89,17 +134,25 @@ type MappedTimeValue<T> =
89
134
  T extends Time ? Time :
90
135
  never;
91
136
 
92
- export interface TimePickerProps<T extends TimeValue> extends InputBase, Validation, FocusableProps, LabelableProps, ValueBase<T, MappedTimeValue<T>> {
137
+ export interface TimePickerProps<T extends TimeValue> extends InputBase, Validation<MappedTimeValue<T>>, FocusableProps, LabelableProps, HelpTextProps, ValueBase<T | null, MappedTimeValue<T>> {
93
138
  /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */
94
139
  hourCycle?: 12 | 24,
95
140
  /**
96
141
  * Determines the smallest unit that is displayed in the time picker.
97
142
  * @default 'minute'
98
143
  */
99
- granularity?: 'hour' | 'minute' | 'second' | 'millisecond',
144
+ granularity?: 'hour' | 'minute' | 'second',
100
145
  /** Whether to hide the time zone abbreviation. */
101
146
  hideTimeZone?: boolean,
102
- /** A placeholder time to display when no value is selected. Defaults to 12:00 or 00:00 depending on the hour cycle. */
147
+ /**
148
+ * Whether to always show leading zeros in the hour field.
149
+ * By default, this is determined by the user's locale.
150
+ */
151
+ shouldForceLeadingZeros?: boolean,
152
+ /**
153
+ * A placeholder time that influences the format of the placeholder shown when no value is selected.
154
+ * Defaults to 12:00 AM or 00:00 depending on the hour cycle.
155
+ */
103
156
  placeholderValue?: T,
104
157
  /** The minimum allowed time that a user may select. */
105
158
  minValue?: TimeValue,
@@ -107,10 +160,15 @@ export interface TimePickerProps<T extends TimeValue> extends InputBase, Validat
107
160
  maxValue?: TimeValue
108
161
  }
109
162
 
110
- export interface SpectrumTimePickerProps<T extends TimeValue> extends TimePickerProps<T>, SpectrumLabelableProps, DOMProps, StyleProps {
163
+ export interface AriaTimeFieldProps<T extends TimeValue> extends TimePickerProps<T>, AriaLabelingProps, DOMProps, InputDOMProps {}
164
+
165
+ export interface SpectrumTimeFieldProps<T extends TimeValue> extends Omit<AriaTimeFieldProps<T>, 'isInvalid' | 'validationState'>, SpectrumFieldValidation<MappedTimeValue<T>>, SpectrumLabelableProps, StyleProps, InputDOMProps {
111
166
  /**
112
167
  * Whether the time field should be displayed with a quiet style.
113
168
  * @default false
114
169
  */
115
170
  isQuiet?: boolean
116
171
  }
172
+
173
+ // backward compatibility
174
+ export type SpectrumTimePickerProps<T extends TimeValue> = SpectrumTimeFieldProps<T>;