@react-types/datepicker 3.13.5 → 3.14.0

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 +8 -7
  2. package/src/index.d.ts +7 -178
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/datepicker",
3
- "version": "3.13.5",
3
+ "version": "3.14.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,16 +9,17 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "dependencies": {
12
- "@internationalized/date": "^3.12.0",
13
- "@react-types/calendar": "^3.8.3",
14
- "@react-types/overlays": "^3.9.4",
15
- "@react-types/shared": "^3.33.1"
12
+ "@react-aria/datepicker": "^3.17.0",
13
+ "@react-spectrum/datepicker": "^3.15.0",
14
+ "@react-stately/datepicker": "^3.17.0"
16
15
  },
17
16
  "publishConfig": {
18
17
  "access": "public"
19
18
  },
20
19
  "peerDependencies": {
21
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
20
+ "@react-spectrum/provider": "^3.0.0",
21
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
22
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
22
23
  },
23
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
24
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
24
25
  }
package/src/index.d.ts CHANGED
@@ -10,185 +10,14 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {
14
- AriaLabelingProps,
15
- DOMProps,
16
- FocusableProps,
17
- HelpTextProps,
18
- InputBase,
19
- InputDOMProps,
20
- LabelableProps,
21
- RangeValue,
22
- SpectrumFieldValidation,
23
- SpectrumLabelableProps,
24
- StyleProps,
25
- Validation,
26
- ValueBase
27
- } from '@react-types/shared';
28
- import {CalendarDate, CalendarDateTime, CalendarIdentifier, Calendar as ICalendar, Time, ZonedDateTime} from '@internationalized/date';
29
- import {OverlayTriggerProps} from '@react-types/overlays';
30
- import {PageBehavior} from '@react-types/calendar';
13
+ import {AriaDatePickerProps} from '@react-aria/datepicker';
14
+ import {DateValue, TimeValue} from '@react-stately/datepicker';
15
+ import {SpectrumTimeFieldProps} from '@react-spectrum/datepicker';
31
16
 
32
- export type DateValue = CalendarDate | CalendarDateTime | ZonedDateTime;
33
- type MappedDateValue<T> =
34
- T extends ZonedDateTime ? ZonedDateTime :
35
- T extends CalendarDateTime ? CalendarDateTime :
36
- T extends CalendarDate ? CalendarDate :
37
- never;
38
-
39
- export type Granularity = 'day' | 'hour' | 'minute' | 'second';
40
- interface DateFieldBase<T extends DateValue> extends InputBase, Validation<MappedDateValue<T>>, FocusableProps, LabelableProps, HelpTextProps {
41
- /** The minimum allowed date that a user may select. */
42
- minValue?: DateValue | null,
43
- /** The maximum allowed date that a user may select. */
44
- maxValue?: DateValue | null,
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. */
48
- placeholderValue?: T | null,
49
- /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */
50
- hourCycle?: 12 | 24,
51
- /** Determines the smallest unit that is displayed in the date picker. By default, this is `"day"` for dates, and `"minute"` for times. */
52
- granularity?: Granularity,
53
- /**
54
- * Whether to hide the time zone abbreviation.
55
- * @default false
56
- */
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
63
- }
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> | null> {}
67
- export interface AriaDateFieldProps<T extends DateValue> extends DateFieldProps<T>, AriaDateFieldBaseProps<T>, InputDOMProps {
68
- /**
69
- * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
70
- */
71
- autoComplete?: string
72
- }
73
-
74
- interface DatePickerBase<T extends DateValue> extends DateFieldBase<T>, OverlayTriggerProps {
75
- /**
76
- * Controls the behavior of paging. Pagination either works by advancing the visible page by visibleDuration (default) or one unit of visibleDuration.
77
- * @default visible
78
- */
79
- pageBehavior?: PageBehavior,
80
- /**
81
- * The day that starts the week.
82
- */
83
- firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'
84
- }
85
- export interface AriaDatePickerBaseProps<T extends DateValue> extends DatePickerBase<T>, AriaLabelingProps, InputDOMProps, DOMProps {}
86
-
87
- export interface DatePickerProps<T extends DateValue> extends DatePickerBase<T>, ValueBase<T | null, MappedDateValue<T> | null> {}
88
- export interface AriaDatePickerProps<T extends DateValue> extends DatePickerProps<T>, AriaDatePickerBaseProps<T>, InputDOMProps {
89
- /**
90
- * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
91
- */
92
- autoComplete?: string
93
- }
94
-
95
- export type DateRange = RangeValue<DateValue>;
96
- export interface DateRangePickerProps<T extends DateValue> extends Omit<DatePickerBase<T>, 'validate'>, Validation<RangeValue<MappedDateValue<T>>>, ValueBase<RangeValue<T> | null, RangeValue<MappedDateValue<T>> | null> {
97
- /**
98
- * When combined with `isDateUnavailable`, determines whether non-contiguous ranges,
99
- * i.e. ranges containing unavailable dates, may be selected.
100
- */
101
- allowsNonContiguousRanges?: boolean,
102
- /**
103
- * 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).
104
- */
105
- startName?: string,
106
- /**
107
- * 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).
108
- */
109
- endName?: string
110
- }
111
-
112
- export interface AriaDateRangePickerProps<T extends DateValue> extends Omit<AriaDatePickerBaseProps<T>, 'validate' | 'name'>, DateRangePickerProps<T> {}
113
-
114
- interface SpectrumDateFieldBase<T extends DateValue> extends SpectrumLabelableProps, HelpTextProps, SpectrumFieldValidation<MappedDateValue<T>>, StyleProps {
115
- /**
116
- * Whether the date picker should be displayed with a quiet style.
117
- * @default false
118
- */
119
- isQuiet?: boolean,
120
- /**
121
- * Whether to show the localized date format as help text below the field.
122
- * @default false
123
- */
124
- showFormatHelpText?: boolean
125
- }
126
-
127
- interface SpectrumDatePickerBase<T extends DateValue> extends SpectrumDateFieldBase<T>, SpectrumLabelableProps, StyleProps {
128
- /**
129
- * The maximum number of months to display at once in the calendar popover, if screen space permits.
130
- * @default 1
131
- */
132
- maxVisibleMonths?: number,
133
- /**
134
- * Whether the calendar popover should automatically flip direction when space is limited.
135
- * @default true
136
- */
137
- shouldFlip?: boolean,
138
- /**
139
- * A function to create a new [Calendar](https://react-spectrum.adobe.com/internationalized/date/Calendar.html)
140
- * object for a given calendar identifier. This will be used for the popover calendar. If not provided, the
141
- * `createCalendar` function from `@internationalized/date` will be used.
142
- */
143
- createCalendar?: (identifier: CalendarIdentifier) => ICalendar
144
- }
145
-
146
- export interface SpectrumDatePickerProps<T extends DateValue> extends Omit<AriaDatePickerProps<T>, 'isInvalid' | 'validationState' | 'autoComplete'>, SpectrumDatePickerBase<T> {}
147
- export interface SpectrumDateRangePickerProps<T extends DateValue> extends Omit<AriaDateRangePickerProps<T>, 'isInvalid' | 'validationState'>, Omit<SpectrumDatePickerBase<T>, 'validate'> {}
148
- export interface SpectrumDateFieldProps<T extends DateValue> extends Omit<AriaDateFieldProps<T>, 'isInvalid' | 'validationState' | 'autoComplete'>, SpectrumDateFieldBase<T> {}
149
-
150
- export type TimeValue = Time | CalendarDateTime | ZonedDateTime;
151
- type MappedTimeValue<T> =
152
- T extends ZonedDateTime ? ZonedDateTime :
153
- T extends CalendarDateTime ? CalendarDateTime :
154
- T extends Time ? Time :
155
- never;
156
-
157
- export interface TimePickerProps<T extends TimeValue> extends InputBase, Validation<MappedTimeValue<T>>, FocusableProps, LabelableProps, HelpTextProps, ValueBase<T | null, MappedTimeValue<T> | null> {
158
- /** Whether to display the time in 12 or 24 hour format. By default, this is determined by the user's locale. */
159
- hourCycle?: 12 | 24,
160
- /**
161
- * Determines the smallest unit that is displayed in the time picker.
162
- * @default 'minute'
163
- */
164
- granularity?: 'hour' | 'minute' | 'second',
165
- /** Whether to hide the time zone abbreviation. */
166
- hideTimeZone?: boolean,
167
- /**
168
- * Whether to always show leading zeros in the hour field.
169
- * By default, this is determined by the user's locale.
170
- */
171
- shouldForceLeadingZeros?: boolean,
172
- /**
173
- * A placeholder time that influences the format of the placeholder shown when no value is selected.
174
- * Defaults to 12:00 AM or 00:00 depending on the hour cycle.
175
- */
176
- placeholderValue?: T,
177
- /** The minimum allowed time that a user may select. */
178
- minValue?: TimeValue | null,
179
- /** The maximum allowed time that a user may select. */
180
- maxValue?: TimeValue | null
181
- }
182
-
183
- export interface AriaTimeFieldProps<T extends TimeValue> extends TimePickerProps<T>, AriaLabelingProps, DOMProps, InputDOMProps {}
184
-
185
- export interface SpectrumTimeFieldProps<T extends TimeValue> extends Omit<AriaTimeFieldProps<T>, 'isInvalid' | 'validationState'>, SpectrumFieldValidation<MappedTimeValue<T>>, SpectrumLabelableProps, StyleProps, InputDOMProps {
186
- /**
187
- * Whether the time field should be displayed with a quiet style.
188
- * @default false
189
- */
190
- isQuiet?: boolean
191
- }
17
+ export {DateValue, DateRange, TimeValue, MappedDateValue, MappedTimeValue, Granularity, DateFieldProps, DatePickerProps, DateRangePickerProps, TimePickerProps} from '@react-stately/datepicker';
18
+ export {AriaDateFieldProps, AriaDatePickerProps, AriaDateRangePickerProps, AriaTimeFieldProps} from '@react-aria/datepicker';
19
+ export {SpectrumDatePickerProps, SpectrumDateRangePickerProps, SpectrumDateFieldProps, SpectrumTimeFieldProps} from '@react-spectrum/datepicker';
192
20
 
193
21
  // backward compatibility
22
+ export type AriaDatePickerBaseProps<T extends DateValue> = AriaDatePickerProps<T>;
194
23
  export type SpectrumTimePickerProps<T extends TimeValue> = SpectrumTimeFieldProps<T>;