react-day-picker 9.4.0 → 9.4.1
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.
- package/dist/cjs/DayPicker.js +18 -16
- package/dist/cjs/DayPicker.js.map +1 -1
- package/dist/cjs/components/Weekdays.js +1 -1
- package/dist/cjs/types/props.d.ts +14 -0
- package/dist/esm/DayPicker.js +18 -16
- package/dist/esm/DayPicker.js.map +1 -1
- package/dist/esm/components/Weekdays.js +1 -1
- package/dist/esm/types/props.d.ts +14 -0
- package/examples/FixedWeeks.test.tsx +1 -1
- package/examples/Input.test.tsx +1 -1
- package/examples/ModifiersHidden.test.tsx +1 -1
- package/examples/Range.test.tsx +1 -1
- package/examples/TestCase2511.test.tsx +3 -1
- package/examples/TestCase2585.test.tsx +3 -1
- package/examples/WeeknumberCustom.test.tsx +5 -1
- package/examples/__snapshots__/Range.test.tsx.snap +86 -112
- package/examples/__snapshots__/StylingCssModules.test.tsx.snap +43 -56
- package/package.json +1 -1
- package/src/DayPicker.test.tsx +6 -2
- package/src/DayPicker.tsx +36 -41
- package/src/components/Weekdays.tsx +1 -1
- package/src/style.css +0 -1
- package/src/style.module.css +0 -1
- package/src/types/props.ts +14 -0
- package/website/docs/docs/anatomy.mdx +1 -1
- package/website/docs/docs/styling.mdx +1 -5
- package/website/docs/docs/time-zone.mdx +1 -1
- package/website/docs/guides/accessibility.mdx +14 -46
|
@@ -68,7 +68,9 @@ exports[`should match the snapshot 1`] = `
|
|
|
68
68
|
class="rdp-month_grid"
|
|
69
69
|
role="grid"
|
|
70
70
|
>
|
|
71
|
-
<thead
|
|
71
|
+
<thead
|
|
72
|
+
aria-hidden="true"
|
|
73
|
+
>
|
|
72
74
|
<tr
|
|
73
75
|
class="rdp-weekdays"
|
|
74
76
|
>
|
|
@@ -130,25 +132,17 @@ exports[`should match the snapshot 1`] = `
|
|
|
130
132
|
class="rdp-week"
|
|
131
133
|
>
|
|
132
134
|
<td
|
|
133
|
-
aria-hidden="true"
|
|
134
135
|
class="rdp-day rdp-hidden rdp-outside"
|
|
135
136
|
data-day="2021-10-31"
|
|
136
137
|
data-hidden="true"
|
|
137
138
|
data-month="2021-10"
|
|
138
139
|
data-outside="true"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
aria-label="Sunday, October 31st, 2021"
|
|
142
|
-
class="rdp-day_button"
|
|
143
|
-
tabindex="-1"
|
|
144
|
-
type="button"
|
|
145
|
-
>
|
|
146
|
-
31
|
|
147
|
-
</button>
|
|
148
|
-
</td>
|
|
140
|
+
role="gridcell"
|
|
141
|
+
/>
|
|
149
142
|
<td
|
|
150
143
|
class="rdp-day"
|
|
151
144
|
data-day="2021-11-01"
|
|
145
|
+
role="gridcell"
|
|
152
146
|
>
|
|
153
147
|
<button
|
|
154
148
|
aria-label="Monday, November 1st, 2021"
|
|
@@ -162,6 +156,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
162
156
|
<td
|
|
163
157
|
class="rdp-day"
|
|
164
158
|
data-day="2021-11-02"
|
|
159
|
+
role="gridcell"
|
|
165
160
|
>
|
|
166
161
|
<button
|
|
167
162
|
aria-label="Tuesday, November 2nd, 2021"
|
|
@@ -175,6 +170,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
175
170
|
<td
|
|
176
171
|
class="rdp-day"
|
|
177
172
|
data-day="2021-11-03"
|
|
173
|
+
role="gridcell"
|
|
178
174
|
>
|
|
179
175
|
<button
|
|
180
176
|
aria-label="Wednesday, November 3rd, 2021"
|
|
@@ -188,6 +184,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
188
184
|
<td
|
|
189
185
|
class="rdp-day"
|
|
190
186
|
data-day="2021-11-04"
|
|
187
|
+
role="gridcell"
|
|
191
188
|
>
|
|
192
189
|
<button
|
|
193
190
|
aria-label="Thursday, November 4th, 2021"
|
|
@@ -201,6 +198,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
201
198
|
<td
|
|
202
199
|
class="rdp-day"
|
|
203
200
|
data-day="2021-11-05"
|
|
201
|
+
role="gridcell"
|
|
204
202
|
>
|
|
205
203
|
<button
|
|
206
204
|
aria-label="Friday, November 5th, 2021"
|
|
@@ -214,6 +212,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
214
212
|
<td
|
|
215
213
|
class="rdp-day"
|
|
216
214
|
data-day="2021-11-06"
|
|
215
|
+
role="gridcell"
|
|
217
216
|
>
|
|
218
217
|
<button
|
|
219
218
|
aria-label="Saturday, November 6th, 2021"
|
|
@@ -231,6 +230,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
231
230
|
<td
|
|
232
231
|
class="rdp-day"
|
|
233
232
|
data-day="2021-11-07"
|
|
233
|
+
role="gridcell"
|
|
234
234
|
>
|
|
235
235
|
<button
|
|
236
236
|
aria-label="Sunday, November 7th, 2021"
|
|
@@ -244,6 +244,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
244
244
|
<td
|
|
245
245
|
class="rdp-day"
|
|
246
246
|
data-day="2021-11-08"
|
|
247
|
+
role="gridcell"
|
|
247
248
|
>
|
|
248
249
|
<button
|
|
249
250
|
aria-label="Monday, November 8th, 2021"
|
|
@@ -257,6 +258,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
257
258
|
<td
|
|
258
259
|
class="rdp-day"
|
|
259
260
|
data-day="2021-11-09"
|
|
261
|
+
role="gridcell"
|
|
260
262
|
>
|
|
261
263
|
<button
|
|
262
264
|
aria-label="Tuesday, November 9th, 2021"
|
|
@@ -270,6 +272,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
270
272
|
<td
|
|
271
273
|
class="rdp-day"
|
|
272
274
|
data-day="2021-11-10"
|
|
275
|
+
role="gridcell"
|
|
273
276
|
>
|
|
274
277
|
<button
|
|
275
278
|
aria-label="Wednesday, November 10th, 2021"
|
|
@@ -283,6 +286,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
283
286
|
<td
|
|
284
287
|
class="rdp-day"
|
|
285
288
|
data-day="2021-11-11"
|
|
289
|
+
role="gridcell"
|
|
286
290
|
>
|
|
287
291
|
<button
|
|
288
292
|
aria-label="Thursday, November 11th, 2021"
|
|
@@ -296,6 +300,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
296
300
|
<td
|
|
297
301
|
class="rdp-day"
|
|
298
302
|
data-day="2021-11-12"
|
|
303
|
+
role="gridcell"
|
|
299
304
|
>
|
|
300
305
|
<button
|
|
301
306
|
aria-label="Friday, November 12th, 2021"
|
|
@@ -309,6 +314,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
309
314
|
<td
|
|
310
315
|
class="rdp-day"
|
|
311
316
|
data-day="2021-11-13"
|
|
317
|
+
role="gridcell"
|
|
312
318
|
>
|
|
313
319
|
<button
|
|
314
320
|
aria-label="Saturday, November 13th, 2021"
|
|
@@ -326,6 +332,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
326
332
|
<td
|
|
327
333
|
class="rdp-day"
|
|
328
334
|
data-day="2021-11-14"
|
|
335
|
+
role="gridcell"
|
|
329
336
|
>
|
|
330
337
|
<button
|
|
331
338
|
aria-label="Sunday, November 14th, 2021"
|
|
@@ -339,6 +346,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
339
346
|
<td
|
|
340
347
|
class="rdp-day"
|
|
341
348
|
data-day="2021-11-15"
|
|
349
|
+
role="gridcell"
|
|
342
350
|
>
|
|
343
351
|
<button
|
|
344
352
|
aria-label="Monday, November 15th, 2021"
|
|
@@ -352,6 +360,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
352
360
|
<td
|
|
353
361
|
class="rdp-day"
|
|
354
362
|
data-day="2021-11-16"
|
|
363
|
+
role="gridcell"
|
|
355
364
|
>
|
|
356
365
|
<button
|
|
357
366
|
aria-label="Tuesday, November 16th, 2021"
|
|
@@ -365,6 +374,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
365
374
|
<td
|
|
366
375
|
class="rdp-day"
|
|
367
376
|
data-day="2021-11-17"
|
|
377
|
+
role="gridcell"
|
|
368
378
|
>
|
|
369
379
|
<button
|
|
370
380
|
aria-label="Wednesday, November 17th, 2021"
|
|
@@ -378,6 +388,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
378
388
|
<td
|
|
379
389
|
class="rdp-day"
|
|
380
390
|
data-day="2021-11-18"
|
|
391
|
+
role="gridcell"
|
|
381
392
|
>
|
|
382
393
|
<button
|
|
383
394
|
aria-label="Thursday, November 18th, 2021"
|
|
@@ -391,6 +402,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
391
402
|
<td
|
|
392
403
|
class="rdp-day"
|
|
393
404
|
data-day="2021-11-19"
|
|
405
|
+
role="gridcell"
|
|
394
406
|
>
|
|
395
407
|
<button
|
|
396
408
|
aria-label="Friday, November 19th, 2021"
|
|
@@ -404,6 +416,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
404
416
|
<td
|
|
405
417
|
class="rdp-day"
|
|
406
418
|
data-day="2021-11-20"
|
|
419
|
+
role="gridcell"
|
|
407
420
|
>
|
|
408
421
|
<button
|
|
409
422
|
aria-label="Saturday, November 20th, 2021"
|
|
@@ -421,6 +434,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
421
434
|
<td
|
|
422
435
|
class="rdp-day"
|
|
423
436
|
data-day="2021-11-21"
|
|
437
|
+
role="gridcell"
|
|
424
438
|
>
|
|
425
439
|
<button
|
|
426
440
|
aria-label="Sunday, November 21st, 2021"
|
|
@@ -434,6 +448,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
434
448
|
<td
|
|
435
449
|
class="rdp-day"
|
|
436
450
|
data-day="2021-11-22"
|
|
451
|
+
role="gridcell"
|
|
437
452
|
>
|
|
438
453
|
<button
|
|
439
454
|
aria-label="Monday, November 22nd, 2021"
|
|
@@ -447,6 +462,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
447
462
|
<td
|
|
448
463
|
class="rdp-day"
|
|
449
464
|
data-day="2021-11-23"
|
|
465
|
+
role="gridcell"
|
|
450
466
|
>
|
|
451
467
|
<button
|
|
452
468
|
aria-label="Tuesday, November 23rd, 2021"
|
|
@@ -460,6 +476,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
460
476
|
<td
|
|
461
477
|
class="rdp-day"
|
|
462
478
|
data-day="2021-11-24"
|
|
479
|
+
role="gridcell"
|
|
463
480
|
>
|
|
464
481
|
<button
|
|
465
482
|
aria-label="Wednesday, November 24th, 2021"
|
|
@@ -474,6 +491,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
474
491
|
class="rdp-day rdp-today"
|
|
475
492
|
data-day="2021-11-25"
|
|
476
493
|
data-today="true"
|
|
494
|
+
role="gridcell"
|
|
477
495
|
>
|
|
478
496
|
<button
|
|
479
497
|
aria-label="Today, Thursday, November 25th, 2021"
|
|
@@ -487,6 +505,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
487
505
|
<td
|
|
488
506
|
class="rdp-day"
|
|
489
507
|
data-day="2021-11-26"
|
|
508
|
+
role="gridcell"
|
|
490
509
|
>
|
|
491
510
|
<button
|
|
492
511
|
aria-label="Friday, November 26th, 2021"
|
|
@@ -500,6 +519,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
500
519
|
<td
|
|
501
520
|
class="rdp-day"
|
|
502
521
|
data-day="2021-11-27"
|
|
522
|
+
role="gridcell"
|
|
503
523
|
>
|
|
504
524
|
<button
|
|
505
525
|
aria-label="Saturday, November 27th, 2021"
|
|
@@ -517,6 +537,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
517
537
|
<td
|
|
518
538
|
class="rdp-day"
|
|
519
539
|
data-day="2021-11-28"
|
|
540
|
+
role="gridcell"
|
|
520
541
|
>
|
|
521
542
|
<button
|
|
522
543
|
aria-label="Sunday, November 28th, 2021"
|
|
@@ -530,6 +551,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
530
551
|
<td
|
|
531
552
|
class="rdp-day"
|
|
532
553
|
data-day="2021-11-29"
|
|
554
|
+
role="gridcell"
|
|
533
555
|
>
|
|
534
556
|
<button
|
|
535
557
|
aria-label="Monday, November 29th, 2021"
|
|
@@ -543,6 +565,7 @@ exports[`should match the snapshot 1`] = `
|
|
|
543
565
|
<td
|
|
544
566
|
class="rdp-day"
|
|
545
567
|
data-day="2021-11-30"
|
|
568
|
+
role="gridcell"
|
|
546
569
|
>
|
|
547
570
|
<button
|
|
548
571
|
aria-label="Tuesday, November 30th, 2021"
|
|
@@ -554,73 +577,37 @@ exports[`should match the snapshot 1`] = `
|
|
|
554
577
|
</button>
|
|
555
578
|
</td>
|
|
556
579
|
<td
|
|
557
|
-
aria-hidden="true"
|
|
558
580
|
class="rdp-day rdp-hidden rdp-outside"
|
|
559
581
|
data-day="2021-12-01"
|
|
560
582
|
data-hidden="true"
|
|
561
583
|
data-month="2021-12"
|
|
562
584
|
data-outside="true"
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
aria-label="Wednesday, December 1st, 2021"
|
|
566
|
-
class="rdp-day_button"
|
|
567
|
-
tabindex="-1"
|
|
568
|
-
type="button"
|
|
569
|
-
>
|
|
570
|
-
1
|
|
571
|
-
</button>
|
|
572
|
-
</td>
|
|
585
|
+
role="gridcell"
|
|
586
|
+
/>
|
|
573
587
|
<td
|
|
574
|
-
aria-hidden="true"
|
|
575
588
|
class="rdp-day rdp-hidden rdp-outside"
|
|
576
589
|
data-day="2021-12-02"
|
|
577
590
|
data-hidden="true"
|
|
578
591
|
data-month="2021-12"
|
|
579
592
|
data-outside="true"
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
aria-label="Thursday, December 2nd, 2021"
|
|
583
|
-
class="rdp-day_button"
|
|
584
|
-
tabindex="-1"
|
|
585
|
-
type="button"
|
|
586
|
-
>
|
|
587
|
-
2
|
|
588
|
-
</button>
|
|
589
|
-
</td>
|
|
593
|
+
role="gridcell"
|
|
594
|
+
/>
|
|
590
595
|
<td
|
|
591
|
-
aria-hidden="true"
|
|
592
596
|
class="rdp-day rdp-hidden rdp-outside"
|
|
593
597
|
data-day="2021-12-03"
|
|
594
598
|
data-hidden="true"
|
|
595
599
|
data-month="2021-12"
|
|
596
600
|
data-outside="true"
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
aria-label="Friday, December 3rd, 2021"
|
|
600
|
-
class="rdp-day_button"
|
|
601
|
-
tabindex="-1"
|
|
602
|
-
type="button"
|
|
603
|
-
>
|
|
604
|
-
3
|
|
605
|
-
</button>
|
|
606
|
-
</td>
|
|
601
|
+
role="gridcell"
|
|
602
|
+
/>
|
|
607
603
|
<td
|
|
608
|
-
aria-hidden="true"
|
|
609
604
|
class="rdp-day rdp-hidden rdp-outside"
|
|
610
605
|
data-day="2021-12-04"
|
|
611
606
|
data-hidden="true"
|
|
612
607
|
data-month="2021-12"
|
|
613
608
|
data-outside="true"
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
aria-label="Saturday, December 4th, 2021"
|
|
617
|
-
class="rdp-day_button"
|
|
618
|
-
tabindex="-1"
|
|
619
|
-
type="button"
|
|
620
|
-
>
|
|
621
|
-
4
|
|
622
|
-
</button>
|
|
623
|
-
</td>
|
|
609
|
+
role="gridcell"
|
|
610
|
+
/>
|
|
624
611
|
</tr>
|
|
625
612
|
</tbody>
|
|
626
613
|
</table>
|
package/package.json
CHANGED
package/src/DayPicker.test.tsx
CHANGED
|
@@ -184,12 +184,16 @@ test("should render the custom components", () => {
|
|
|
184
184
|
describe("when interactive", () => {
|
|
185
185
|
test("render a valid HTML", () => {
|
|
186
186
|
render(<DayPicker mode="single" />);
|
|
187
|
-
expect(document.body).toHTMLValidate(
|
|
187
|
+
expect(document.body).toHTMLValidate({
|
|
188
|
+
rules: { "no-redundant-role": "off" } // Redundant role is allowed for VoiceOver
|
|
189
|
+
});
|
|
188
190
|
});
|
|
189
191
|
});
|
|
190
192
|
describe("when not interactive", () => {
|
|
191
193
|
test("render a valid HTML", () => {
|
|
192
194
|
render(<DayPicker />);
|
|
193
|
-
expect(document.body).toHTMLValidate(
|
|
195
|
+
expect(document.body).toHTMLValidate({
|
|
196
|
+
rules: { "no-redundant-role": "off" } // Redundant role is allowed for VoiceOver
|
|
197
|
+
});
|
|
194
198
|
});
|
|
195
199
|
});
|
package/src/DayPicker.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from "react";
|
|
2
|
-
import type {
|
|
3
|
-
ChangeEventHandler,
|
|
4
|
-
MouseEvent,
|
|
5
|
-
FocusEvent,
|
|
6
|
-
KeyboardEvent
|
|
7
|
-
} from "react";
|
|
2
|
+
import type { MouseEvent, FocusEvent, KeyboardEvent, ChangeEvent } from "react";
|
|
8
3
|
|
|
9
4
|
import { UI, DayFlag, SelectionState } from "./UI.js";
|
|
10
5
|
import type { CalendarDay } from "./classes/CalendarDay.js";
|
|
@@ -227,6 +222,24 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
227
222
|
[onDayMouseLeave]
|
|
228
223
|
);
|
|
229
224
|
|
|
225
|
+
const handleMonthChange = useCallback(
|
|
226
|
+
(date: Date) => (e: ChangeEvent<HTMLSelectElement>) => {
|
|
227
|
+
const selectedMonth = Number(e.target.value);
|
|
228
|
+
const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
|
|
229
|
+
goToMonth(month);
|
|
230
|
+
},
|
|
231
|
+
[dateLib, goToMonth]
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const handleYearChange = useCallback(
|
|
235
|
+
(date: Date) => (e: ChangeEvent<HTMLSelectElement>) => {
|
|
236
|
+
const selectedYear = Number(e.target.value);
|
|
237
|
+
const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
|
|
238
|
+
goToMonth(month);
|
|
239
|
+
},
|
|
240
|
+
[dateLib, goToMonth]
|
|
241
|
+
);
|
|
242
|
+
|
|
230
243
|
const { className, style } = useMemo(
|
|
231
244
|
() => ({
|
|
232
245
|
className: [classNames[UI.Root], props.className]
|
|
@@ -266,6 +279,8 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
266
279
|
lang={props.lang}
|
|
267
280
|
nonce={props.nonce}
|
|
268
281
|
title={props.title}
|
|
282
|
+
role={props.role}
|
|
283
|
+
aria-label={props["aria-label"]}
|
|
269
284
|
{...dataAttributes}
|
|
270
285
|
>
|
|
271
286
|
<components.Months
|
|
@@ -284,29 +299,6 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
284
299
|
/>
|
|
285
300
|
)}
|
|
286
301
|
{months.map((calendarMonth, displayIndex) => {
|
|
287
|
-
const handleMonthChange: ChangeEventHandler<HTMLSelectElement> = (
|
|
288
|
-
e
|
|
289
|
-
) => {
|
|
290
|
-
const selectedMonth = Number(
|
|
291
|
-
(e.target as HTMLSelectElement).value
|
|
292
|
-
);
|
|
293
|
-
const month = dateLib.setMonth(
|
|
294
|
-
dateLib.startOfMonth(calendarMonth.date),
|
|
295
|
-
selectedMonth
|
|
296
|
-
);
|
|
297
|
-
goToMonth(month);
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
const handleYearChange: ChangeEventHandler<HTMLSelectElement> = (
|
|
301
|
-
e
|
|
302
|
-
) => {
|
|
303
|
-
const month = dateLib.setYear(
|
|
304
|
-
dateLib.startOfMonth(calendarMonth.date),
|
|
305
|
-
Number(e.target.value)
|
|
306
|
-
);
|
|
307
|
-
goToMonth(month);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
302
|
const dropdownMonths = getMonthOptions(
|
|
311
303
|
calendarMonth.date,
|
|
312
304
|
navStart,
|
|
@@ -350,7 +342,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
350
342
|
classNames={classNames}
|
|
351
343
|
components={components}
|
|
352
344
|
disabled={Boolean(props.disableNavigation)}
|
|
353
|
-
onChange={handleMonthChange}
|
|
345
|
+
onChange={handleMonthChange(calendarMonth.date)}
|
|
354
346
|
options={dropdownMonths}
|
|
355
347
|
style={styles?.[UI.Dropdown]}
|
|
356
348
|
value={calendarMonth.date.getMonth()}
|
|
@@ -371,7 +363,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
371
363
|
classNames={classNames}
|
|
372
364
|
components={components}
|
|
373
365
|
disabled={Boolean(props.disableNavigation)}
|
|
374
|
-
onChange={handleYearChange}
|
|
366
|
+
onChange={handleYearChange(calendarMonth.date)}
|
|
375
367
|
options={dropdownYears}
|
|
376
368
|
style={styles?.[UI.Dropdown]}
|
|
377
369
|
value={calendarMonth.date.getFullYear()}
|
|
@@ -459,6 +451,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
459
451
|
})}
|
|
460
452
|
className={classNames[UI.WeekNumber]}
|
|
461
453
|
scope="row"
|
|
454
|
+
role="rowheader"
|
|
462
455
|
>
|
|
463
456
|
{formatWeekNumber(week.weekNumber)}
|
|
464
457
|
</components.WeekNumber>
|
|
@@ -505,14 +498,15 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
505
498
|
props.modifiersClassNames
|
|
506
499
|
);
|
|
507
500
|
|
|
508
|
-
const ariaLabel =
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
501
|
+
const ariaLabel =
|
|
502
|
+
!isInteractive && !modifiers.hidden
|
|
503
|
+
? labelGridcell(
|
|
504
|
+
date,
|
|
505
|
+
modifiers,
|
|
506
|
+
dateLib.options,
|
|
507
|
+
dateLib
|
|
508
|
+
)
|
|
509
|
+
: undefined;
|
|
516
510
|
|
|
517
511
|
return (
|
|
518
512
|
<components.Day
|
|
@@ -521,7 +515,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
521
515
|
modifiers={modifiers}
|
|
522
516
|
className={className.join(" ")}
|
|
523
517
|
style={style}
|
|
524
|
-
|
|
518
|
+
role="gridcell"
|
|
525
519
|
aria-selected={modifiers.selected || undefined}
|
|
526
520
|
aria-label={ariaLabel}
|
|
527
521
|
data-day={dateLib.format(date, "yyyy-MM-dd")}
|
|
@@ -537,7 +531,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
537
531
|
data-focused={modifiers.focused || undefined}
|
|
538
532
|
data-today={modifiers.today || undefined}
|
|
539
533
|
>
|
|
540
|
-
{isInteractive ? (
|
|
534
|
+
{!modifiers.hidden && isInteractive ? (
|
|
541
535
|
<components.DayButton
|
|
542
536
|
className={classNames[UI.DayButton]}
|
|
543
537
|
style={styles?.[UI.DayButton]}
|
|
@@ -568,6 +562,7 @@ export function DayPicker(props: DayPickerProps) {
|
|
|
568
562
|
{formatDay(date, dateLib.options, dateLib)}
|
|
569
563
|
</components.DayButton>
|
|
570
564
|
) : (
|
|
565
|
+
!modifiers.hidden &&
|
|
571
566
|
formatDay(day.date, dateLib.options, dateLib)
|
|
572
567
|
)}
|
|
573
568
|
</components.Day>
|
package/src/style.css
CHANGED
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
--rdp-nav-height: 2.75rem; /* The height of the navigation bar. */
|
|
28
28
|
|
|
29
29
|
--rdp-range_middle-background-color: var(--rdp-accent-background-color); /* The color of the background for days in the middle of a range. */
|
|
30
|
-
--rdp-range_middle-foreground-color: white; /* The foregraound color for days in the middle of a range. */
|
|
31
30
|
--rdp-range_middle-color: inherit;/* The color of the range text. */
|
|
32
31
|
|
|
33
32
|
--rdp-range_start-color: white; /* The color of the range text. */
|
package/src/style.module.css
CHANGED
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
--rdp-nav-height: 2.75rem; /* The height of the navigation bar. */
|
|
28
28
|
|
|
29
29
|
--rdp-range_middle-background-color: var(--rdp-accent-background-color); /* The color of the background for days in the middle of a range. */
|
|
30
|
-
--rdp-range_middle-foreground-color: white; /* The foregraound color for days in the middle of a range. */
|
|
31
30
|
--rdp-range_middle-color: inherit;/* The color of the range text. */
|
|
32
31
|
|
|
33
32
|
--rdp-range_start-color: white; /* The color of the range text. */
|
package/src/types/props.ts
CHANGED
|
@@ -355,6 +355,20 @@ export interface PropsBase {
|
|
|
355
355
|
* @see https://daypicker.dev/docs/translation#rtl-text-direction
|
|
356
356
|
*/
|
|
357
357
|
dir?: HTMLDivElement["dir"];
|
|
358
|
+
/**
|
|
359
|
+
* The aria-label attribute to add to the container element.
|
|
360
|
+
*
|
|
361
|
+
* @since 9.4.1
|
|
362
|
+
* @see https://daypicker.dev/guides/accessibility
|
|
363
|
+
*/
|
|
364
|
+
["aria-label"]?: string;
|
|
365
|
+
/**
|
|
366
|
+
* The role attribute to add to the container element.
|
|
367
|
+
*
|
|
368
|
+
* @since 9.4.1
|
|
369
|
+
* @see https://daypicker.dev/guides/accessibility
|
|
370
|
+
*/
|
|
371
|
+
role?: "application" | "dialog" | undefined;
|
|
358
372
|
/**
|
|
359
373
|
* A cryptographic nonce ("number used once") which can be used by Content
|
|
360
374
|
* Security Policy for the inline `style` attributes.
|
|
@@ -19,7 +19,7 @@ To better understand the documentation, familiarize yourself with the elements t
|
|
|
19
19
|
|
|
20
20
|
The UI elements are mapped to CSS classes. A complete list can be found in the [`UI`](../api/enumerations/UI.md) enum.
|
|
21
21
|
|
|
22
|
-
<BrowserWindow>
|
|
22
|
+
<BrowserWindow shadow={false}>
|
|
23
23
|
<div style={{ overflow: "auto" }}>
|
|
24
24
|
<a href="/img/anatomy-light.png">
|
|
25
25
|
<img
|
|
@@ -74,7 +74,7 @@ The following table lists the CSS variables used by DayPicker within the `.rdp-r
|
|
|
74
74
|
| `--rdp-nav_button-width` | The width of the navigation buttons. |
|
|
75
75
|
| `--rdp-nav-height` | The height of the navigation bar. |
|
|
76
76
|
| `--rdp-range_middle-background-color` | The color of the background for days in the middle of a range. |
|
|
77
|
-
| `--rdp-range_middle-
|
|
77
|
+
| `--rdp-range_middle-color` | The color of the text for days in the middle of a range. |
|
|
78
78
|
| `--rdp-range_start-color` | The color of the range text at the start of the range. |
|
|
79
79
|
| `--rdp-range_start-background` | Used for the background of the start of the selected range. |
|
|
80
80
|
| `--rdp-range_start-date-background-color` | The background color of the date at the start of the selected range. |
|
|
@@ -117,10 +117,6 @@ export function MyDatePicker() {
|
|
|
117
117
|
}
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
<BrowserWindow>
|
|
121
|
-
<Examples.CssModules />
|
|
122
|
-
</BrowserWindow>
|
|
123
|
-
|
|
124
120
|
## Custom Class Names
|
|
125
121
|
|
|
126
122
|
Use the `classNames` prop to apply custom class names instead of the default ones. The [`ClassNames`](../api/type-aliases/ClassNames.md) type lists all the class names used by DayPicker.
|