You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/react-daterange-picker/src/DateRangePicker.tsx
+221Lines changed: 221 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -70,44 +70,265 @@ type CalendarProps = Omit<
70
70
typeEventProps=ReturnType<typeofmakeEventProps>;
71
71
72
72
exporttypeDateRangePickerProps={
73
+
/**
74
+
* Automatically focuses the input on mount.
75
+
*
76
+
* @example true
77
+
*/
73
78
autoFocus?: boolean;
79
+
/**
80
+
* `aria-label` for the calendar button.
81
+
*
82
+
* @example 'Toggle calendar'
83
+
*/
74
84
calendarAriaLabel?: string;
85
+
/**
86
+
* Class name(s) that will be added along with `"react-calendar"` to the main React-Calendar `<div>` element.
87
+
*
88
+
* @example 'class1 class2'
89
+
* @example ['class1', 'class2 class3']
90
+
*/
75
91
calendarClassName?: ClassName;
92
+
/**
93
+
* Content of the calendar button. Setting the value explicitly to `null` will hide the icon.
94
+
*
95
+
* @example 'Calendar'
96
+
* @example <CalendarIcon />
97
+
* @example CalendarIcon
98
+
*/
76
99
calendarIcon?: IconOrRenderFunction|null;
100
+
/**
101
+
* Class name(s) that will be added along with `"react-daterange-picker"` to the main React-DateRange-Picker `<div>` element.
102
+
*
103
+
* @example 'class1 class2'
104
+
* @example ['class1', 'class2 class3']
105
+
*/
77
106
className?: ClassName;
107
+
/**
108
+
* `aria-label` for the clear button.
109
+
*
110
+
* @example 'Clear value'
111
+
*/
78
112
clearAriaLabel?: string;
113
+
/**
114
+
* Content of the clear button. Setting the value explicitly to `null` will hide the icon.
115
+
*
116
+
* @example 'Clear'
117
+
* @example <ClearIcon />
118
+
* @example ClearIcon
119
+
*/
79
120
clearIcon?: IconOrRenderFunction|null;
121
+
/**
122
+
* Whether to close the calendar on value selection.
123
+
*
124
+
* **Note**: It's recommended to use `shouldCloseCalendar` function instead.
125
+
*
126
+
* @default true
127
+
* @example false
128
+
*/
80
129
closeCalendar?: boolean;
130
+
/**
131
+
* `data-testid` attribute for the main React-DateRange-Picker `<div>` element.
132
+
*
133
+
* @example 'daterange-picker'
134
+
*/
81
135
'data-testid'?: string;
136
+
/**
137
+
* `aria-label` for the day input.
138
+
*
139
+
* @example 'Day'
140
+
*/
82
141
dayAriaLabel?: string;
142
+
/**
143
+
* `placeholder` for the day input.
144
+
*
145
+
* @default '--'
146
+
* @example 'dd'
147
+
*/
83
148
dayPlaceholder?: string;
149
+
/**
150
+
* When set to `true`, will remove the calendar and the button toggling its visibility.
151
+
*
152
+
* @default false
153
+
* @example true
154
+
*/
84
155
disableCalendar?: boolean;
156
+
/**
157
+
* Whether the date range picker should be disabled.
158
+
*
159
+
* @default false
160
+
* @example true
161
+
*/
85
162
disabled?: boolean;
163
+
/**
164
+
* Input format based on [Unicode Technical Standard #35](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). Supported values are: `y`, `M`, `MM`, `MMM`, `MMMM`, `d`, `dd`.
165
+
*
166
+
* **Note**: When using SSR, setting this prop may help resolving hydration errors caused by locale mismatch between server and client.
167
+
*
168
+
* @example 'y-MM-dd'
169
+
*/
86
170
format?: string;
171
+
/**
172
+
* `id` attribute for the main React-DateRange-Picker `<div>` element.
173
+
*
174
+
* @example 'daterange-picker'
175
+
*/
87
176
id?: string;
177
+
/**
178
+
* Whether the calendar should be opened.
179
+
*
180
+
* @default false
181
+
* @example true
182
+
*/
88
183
isOpen?: boolean;
184
+
/**
185
+
* Locale that should be used by the date range picker and the calendar. Can be any [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag).
186
+
*
187
+
* **Note**: When using SSR, setting this prop may help resolving hydration errors caused by locale mismatch between server and client.
188
+
*
189
+
* @example 'hu-HU'
190
+
*/
89
191
locale?: string;
192
+
/**
193
+
* Maximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although React-DateRange-Picker will ensure that no later date is selected.
194
+
*
195
+
* @example new Date()
196
+
*/
90
197
maxDate?: Date;
198
+
/**
199
+
* The most detailed calendar view that the user shall see. View defined here also becomes the one on which clicking an item in the calendar will select a date and pass it to onChange. Can be `"month"`, `"year"`, `"decade"` or
200
+
*
201
+
* @default 'month'
202
+
* @example 'year'
203
+
*/
91
204
maxDetail?: Detail;
205
+
/**
206
+
* Minimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although React-DateRange-Picker will ensure that no earlier date is selected.
207
+
*
208
+
* @example new Date()
209
+
*/
92
210
minDate?: Date;
211
+
/**
212
+
* `aria-label` for the month input.
213
+
*
214
+
* @example 'Month'
215
+
*/
93
216
monthAriaLabel?: string;
217
+
/**
218
+
* `placeholder` for the month input.
219
+
*
220
+
* @default '--'
221
+
* @example 'mm'
222
+
*/
94
223
monthPlaceholder?: string;
224
+
/**
225
+
* Input name.
226
+
*
227
+
* @default 'daterange'
228
+
*/
95
229
name?: string;
230
+
/**
231
+
* `aria-label` for the native date input.
232
+
*
233
+
* @example 'Date'
234
+
*/
96
235
nativeInputAriaLabel?: string;
236
+
/**
237
+
* Function called when the calendar closes.
238
+
*
239
+
* @example () => alert('Calendar closed')
240
+
*/
97
241
onCalendarClose?: ()=>void;
242
+
/**
243
+
* Function called when the calendar opens.
244
+
*
245
+
* @example () => alert('Calendar opened')
246
+
*/
98
247
onCalendarOpen?: ()=>void;
248
+
/**
249
+
* Function called when the user picks a valid date. If any of the fields were excluded using custom `format`, `new Date(y, 0, 1, 0, 0, 0)`, where `y` is the current year, is going to serve as a "base".
250
+
*
251
+
* @example (value) => alert('New date is: ', value)
* Function called when the user picks an invalid date.
262
+
*
263
+
* @example () => alert('Invalid date')
264
+
*/
101
265
onInvalidChange?: ()=>void;
266
+
/**
267
+
* Whether to open the calendar on input focus. **Note**: It's recommended to use `shouldOpenCalendar` function instead.
268
+
*
269
+
* @default true
270
+
* @example false
271
+
*/
102
272
openCalendarOnFocus?: boolean;
273
+
/**
274
+
* Element to render the calendar in using portal.
275
+
*
276
+
* @example document.getElementById('my-div')
277
+
*/
103
278
portalContainer?: HTMLElement|null;
279
+
/**
280
+
* Divider between date inputs.
281
+
*
282
+
* @default '–'
283
+
* @example ' to '
284
+
*/
104
285
rangeDivider?: React.ReactNode;
286
+
/**
287
+
* Whether date input should be required.
288
+
*
289
+
* @default false
290
+
* @example true
291
+
*/
105
292
required?: boolean;
293
+
/**
294
+
* Function called before the calendar closes. `reason` can be `"buttonClick"`, `"escape"`, `"outsideAction"`, or `"select"`. If it returns `false`, the calendar will not close.
0 commit comments