@barqjs/aria 0.2.0-next.0 → 0.2.0-next.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/README.md +24 -13
- package/package.json +127 -37
- package/src/autocomplete.tsx +581 -0
- package/src/breadcrumbs.tsx +21 -20
- package/src/button.tsx +151 -25
- package/src/calendar.tsx +1019 -92
- package/src/checkbox.tsx +214 -52
- package/src/collections.ts +88 -5
- package/src/color.ts +1580 -23
- package/src/colorpicker.tsx +698 -153
- package/src/colorswatchpicker.tsx +240 -0
- package/src/combobox.tsx +635 -113
- package/src/command.tsx +78 -59
- package/src/date.ts +31 -9
- package/src/datefield.tsx +1451 -336
- package/src/datepicker.tsx +465 -114
- package/src/dialog.tsx +302 -115
- package/src/disclosure.tsx +81 -29
- package/src/dnd/clipboard.ts +125 -0
- package/src/dnd/collection.ts +1265 -0
- package/src/dnd/data.ts +409 -0
- package/src/dnd/drag-drop.ts +801 -0
- package/src/dnd/index.ts +133 -0
- package/src/dnd/manager.ts +639 -0
- package/src/dnd/strings.ts +1279 -0
- package/src/dnd/targets.ts +726 -0
- package/src/dnd/types.ts +212 -0
- package/src/dom.ts +3 -6
- package/src/drag-and-drop.tsx +669 -0
- package/src/dropzone.tsx +208 -0
- package/src/file-trigger.tsx +103 -0
- package/src/form.tsx +18 -18
- package/src/gridlist.tsx +912 -121
- package/src/group.tsx +146 -0
- package/src/index.ts +402 -0
- package/src/interactions/focus-events.ts +13 -5
- package/src/interactions/keyboard.ts +195 -2
- package/src/interactions/modality.ts +18 -6
- package/src/interactions/open-link.ts +46 -13
- package/src/interactions/press.ts +35 -18
- package/src/label.ts +18 -6
- package/src/link.tsx +146 -50
- package/src/listbox.tsx +615 -89
- package/src/live.ts +4 -0
- package/src/menu.tsx +182 -89
- package/src/menubar.tsx +21 -17
- package/src/navigation-tree.tsx +357 -0
- package/src/numberfield.tsx +164 -60
- package/src/overlay-arrow.tsx +157 -0
- package/src/overlays.ts +364 -62
- package/src/platform.ts +2 -1
- package/src/preview-trigger.tsx +582 -0
- package/src/progress-bar-context.ts +15 -0
- package/src/questionnaire.tsx +109 -104
- package/src/radio.tsx +101 -27
- package/src/select.tsx +225 -145
- package/src/selection-indicator.tsx +74 -0
- package/src/selection.ts +73 -16
- package/src/shared-element-transition.tsx +316 -0
- package/src/sheet.tsx +1461 -0
- package/src/slider.tsx +139 -44
- package/src/switch.tsx +47 -21
- package/src/table.tsx +0 -0
- package/src/tabs.tsx +198 -89
- package/src/tag.tsx +217 -32
- package/src/textarea.tsx +186 -0
- package/src/textfield.tsx +103 -37
- package/src/toast-components.tsx +589 -0
- package/src/toggle-button-group.tsx +175 -0
- package/src/toggle-input.tsx +38 -0
- package/src/toggle.ts +68 -5
- package/src/tokenfield.tsx +1673 -0
- package/src/toolbar.tsx +15 -10
- package/src/tooltip.tsx +46 -29
- package/src/tree.tsx +2075 -0
- package/src/utils.ts +30 -1
- package/src/validation.ts +79 -22
- package/src/virtualizer.tsx +186 -23
package/src/calendar.tsx
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
import {
|
|
32
|
+
cells,
|
|
32
33
|
type Accessor,
|
|
33
34
|
type Child,
|
|
34
35
|
For,
|
|
@@ -40,6 +41,7 @@ import {
|
|
|
40
41
|
provide,
|
|
41
42
|
Repeat,
|
|
42
43
|
createSignal,
|
|
44
|
+
onSettled,
|
|
43
45
|
untrack,
|
|
44
46
|
} from "@barqjs/core";
|
|
45
47
|
import { isServer } from "@barqjs/web";
|
|
@@ -65,7 +67,14 @@ import {
|
|
|
65
67
|
} from "./date.ts";
|
|
66
68
|
import { activeElement, contains, ownerDocument } from "./dom.ts";
|
|
67
69
|
import { focusRing } from "./focus.ts";
|
|
68
|
-
import {
|
|
70
|
+
import {
|
|
71
|
+
dateFormatter,
|
|
72
|
+
listFormatter,
|
|
73
|
+
type LocalizedString,
|
|
74
|
+
StringDictionary,
|
|
75
|
+
stringFormatter,
|
|
76
|
+
useLocale,
|
|
77
|
+
} from "./i18n.ts";
|
|
69
78
|
import { focusSafely } from "./interactions/focusable.ts";
|
|
70
79
|
import { hover } from "./interactions/hover.ts";
|
|
71
80
|
import type { ElementRef } from "./interactions/press.ts";
|
|
@@ -190,6 +199,15 @@ export interface CalendarStateOptions {
|
|
|
190
199
|
today?: MaybeAccessor<CalendarDate | undefined>;
|
|
191
200
|
/** The IANA zone today is reckoned in. Defaults to the local one. */
|
|
192
201
|
timeZone?: MaybeAccessor<string | undefined>;
|
|
202
|
+
/** Said by the caller, whatever the value is. */
|
|
203
|
+
isInvalid?: MaybeAccessor<boolean | undefined>;
|
|
204
|
+
/**
|
|
205
|
+
* Where the chosen day, or today, sits among several months when the
|
|
206
|
+
* calendar first shows. @default "center"
|
|
207
|
+
*/
|
|
208
|
+
selectionAlignment?: MaybeAccessor<"start" | "center" | "end" | undefined>;
|
|
209
|
+
/** Every month drawn with this many week rows, however many it needs. */
|
|
210
|
+
weeksInMonth?: MaybeAccessor<number | undefined>;
|
|
193
211
|
onChange?: (value: CalendarDate | null) => void;
|
|
194
212
|
onFocusChange?: (date: CalendarDate) => void;
|
|
195
213
|
}
|
|
@@ -211,6 +229,13 @@ export interface CalendarState {
|
|
|
211
229
|
firstDayOfWeek: Accessor<number>;
|
|
212
230
|
isDisabled: Accessor<boolean>;
|
|
213
231
|
isReadOnly: Accessor<boolean>;
|
|
232
|
+
/**
|
|
233
|
+
* The value is one the calendar would not offer, or the caller said it is
|
|
234
|
+
* wrong: the chosen days say so, and point at the error message.
|
|
235
|
+
*/
|
|
236
|
+
isValueInvalid: Accessor<boolean>;
|
|
237
|
+
/** The week rows every month is drawn with, when the caller fixed them. */
|
|
238
|
+
weeksInMonth: Accessor<number | undefined>;
|
|
214
239
|
isSelected(date: CalendarDate): boolean;
|
|
215
240
|
isCellFocused(date: CalendarDate): boolean;
|
|
216
241
|
isCellDisabled(date: CalendarDate): boolean;
|
|
@@ -298,6 +323,41 @@ export function calendarState(options: CalendarStateOptions): CalendarState {
|
|
|
298
323
|
return month.compare(last) > 0 ? month.subtract({ months: visibleMonths() - 1 }) : start;
|
|
299
324
|
};
|
|
300
325
|
|
|
326
|
+
/**
|
|
327
|
+
* The first month on show when the calendar is built, placed so the focused
|
|
328
|
+
* day sits where `selectionAlignment` asks and no month beyond the bounds is
|
|
329
|
+
* shown to make room for it.
|
|
330
|
+
*/
|
|
331
|
+
const aligned = (focused: CalendarDate): CalendarDate => {
|
|
332
|
+
const count = visibleMonths();
|
|
333
|
+
const month = startOfMonth(focused);
|
|
334
|
+
let before: number;
|
|
335
|
+
switch (access(options.selectionAlignment) ?? "center") {
|
|
336
|
+
case "start":
|
|
337
|
+
before = 0;
|
|
338
|
+
break;
|
|
339
|
+
case "end":
|
|
340
|
+
before = count - 1;
|
|
341
|
+
break;
|
|
342
|
+
default: {
|
|
343
|
+
const half = Math.floor(count / 2);
|
|
344
|
+
before = half > 0 && count % 2 === 0 ? half - 1 : half;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
let start = month.subtract({ months: before });
|
|
348
|
+
const max = access(options.maxValue);
|
|
349
|
+
if (max !== undefined && max !== null && focused.compare(max) <= 0) {
|
|
350
|
+
const latest = startOfMonth(max).subtract({ months: count - 1 });
|
|
351
|
+
if (start.compare(latest) > 0) start = latest;
|
|
352
|
+
}
|
|
353
|
+
const min = access(options.minValue);
|
|
354
|
+
if (min !== undefined && min !== null && focused.compare(min) >= 0) {
|
|
355
|
+
const earliest = startOfMonth(min);
|
|
356
|
+
if (start.compare(earliest) < 0) start = earliest;
|
|
357
|
+
}
|
|
358
|
+
return start;
|
|
359
|
+
};
|
|
360
|
+
|
|
301
361
|
// Where the window begins. It stays where it was until the focused day leaves
|
|
302
362
|
// it or a page is asked for, which is what lets focus cross from one visible
|
|
303
363
|
// month into the next without the months changing places under it.
|
|
@@ -308,7 +368,7 @@ export function calendarState(options: CalendarStateOptions): CalendarState {
|
|
|
308
368
|
if (kept !== undefined && kept !== null) return { start: startOfMonth(kept), request };
|
|
309
369
|
|
|
310
370
|
const focused = rawFocusedDate();
|
|
311
|
-
let from =
|
|
371
|
+
let from = aligned(focused);
|
|
312
372
|
if (previous !== undefined) {
|
|
313
373
|
from = request !== null && request !== previous.request ? request.start : previous.start;
|
|
314
374
|
}
|
|
@@ -404,6 +464,15 @@ export function calendarState(options: CalendarStateOptions): CalendarState {
|
|
|
404
464
|
|
|
405
465
|
const move = (duration: Duration): void => land(focusedDate().add(duration), duration);
|
|
406
466
|
|
|
467
|
+
/** A day the calendar would not let anyone choose, for whatever reason. */
|
|
468
|
+
const isRefused = (date: CalendarDate): boolean => {
|
|
469
|
+
const min = access(options.minValue);
|
|
470
|
+
const max = access(options.maxValue);
|
|
471
|
+
if (min !== undefined && min !== null && date.compare(min) < 0) return true;
|
|
472
|
+
if (max !== undefined && max !== null && date.compare(max) > 0) return true;
|
|
473
|
+
return isCellUnavailable(date) || options.isDateDisabled?.(date) === true;
|
|
474
|
+
};
|
|
475
|
+
|
|
407
476
|
const selectDate = (date: CalendarDate): void => {
|
|
408
477
|
if (isReadOnly() || isDisabled()) return;
|
|
409
478
|
if (isCellDisabled(date) || isCellUnavailable(date)) return;
|
|
@@ -431,6 +500,12 @@ export function calendarState(options: CalendarStateOptions): CalendarState {
|
|
|
431
500
|
firstDayOfWeek,
|
|
432
501
|
isDisabled,
|
|
433
502
|
isReadOnly,
|
|
503
|
+
isValueInvalid: () => {
|
|
504
|
+
if (access(options.isInvalid) === true) return true;
|
|
505
|
+
const selected = value();
|
|
506
|
+
return selected !== null && isRefused(selected);
|
|
507
|
+
},
|
|
508
|
+
weeksInMonth: () => access(options.weeksInMonth),
|
|
434
509
|
isSelected: (date) => {
|
|
435
510
|
const selected = value();
|
|
436
511
|
return selected !== null && isSameDay(selected, date);
|
|
@@ -477,9 +552,15 @@ export function calendarState(options: CalendarStateOptions): CalendarState {
|
|
|
477
552
|
|
|
478
553
|
export interface RangeCalendarStateOptions extends Omit<
|
|
479
554
|
CalendarStateOptions,
|
|
480
|
-
"value" | "defaultValue" | "onChange"
|
|
555
|
+
"value" | "defaultValue" | "onChange" | "isDateUnavailable"
|
|
481
556
|
> {
|
|
482
557
|
value?: MaybeAccessor<DateRange | null | undefined>;
|
|
558
|
+
/**
|
|
559
|
+
* Days that exist but cannot be chosen. The second argument is the day the
|
|
560
|
+
* range being drawn began on, or null, so what is available can depend on
|
|
561
|
+
* it: a stay of at most a week from wherever it starts.
|
|
562
|
+
*/
|
|
563
|
+
isDateUnavailable?: (date: CalendarDate, anchorDate: CalendarDate | null) => boolean;
|
|
483
564
|
defaultValue?: MaybeAccessor<DateRange | null | undefined>;
|
|
484
565
|
/** Nothing between the ends may be unavailable. @default false */
|
|
485
566
|
allowsNonContiguousRanges?: MaybeAccessor<boolean | undefined>;
|
|
@@ -504,6 +585,13 @@ export interface RangeCalendarState extends Omit<
|
|
|
504
585
|
/** What the range currently covers: the value, or the drag in progress. */
|
|
505
586
|
highlightedRange: Accessor<DateRange | null>;
|
|
506
587
|
highlightDate(date: CalendarDate): void;
|
|
588
|
+
/** A pointer is down and drawing the range. */
|
|
589
|
+
isDragging: Accessor<boolean>;
|
|
590
|
+
setDragging(isDragging: boolean): void;
|
|
591
|
+
/** Finish the range being drawn at the day it reaches now. */
|
|
592
|
+
commitSelection(): void;
|
|
593
|
+
/** Abandon the range being drawn and the value with it. */
|
|
594
|
+
clearSelection(): void;
|
|
507
595
|
}
|
|
508
596
|
|
|
509
597
|
function ordered(a: CalendarDate, b: CalendarDate): DateRange {
|
|
@@ -519,18 +607,50 @@ export function rangeCalendarState(options: RangeCalendarStateOptions): RangeCal
|
|
|
519
607
|
options.onChange,
|
|
520
608
|
);
|
|
521
609
|
|
|
522
|
-
const [anchorDate,
|
|
610
|
+
const [anchorDate, writeAnchorSignal] = createSignal<CalendarDate | null>(null);
|
|
523
611
|
const [drawn, setDrawn] = createSignal<DateRange | null>(null);
|
|
612
|
+
const [isDragging, setDragging] = createSignal(false);
|
|
613
|
+
|
|
614
|
+
// The anchor and the day the drawing reached, as plain variables too: a
|
|
615
|
+
// pointer's down and up can arrive before a signal write is published, and
|
|
616
|
+
// the up has to see what the down did.
|
|
617
|
+
let anchorNow: CalendarDate | null = null;
|
|
618
|
+
let reached: CalendarDate | null = null;
|
|
619
|
+
|
|
620
|
+
const writeAnchorDate = (date: CalendarDate | null): void => {
|
|
621
|
+
anchorNow = date;
|
|
622
|
+
reached = date;
|
|
623
|
+
writeAnchorSignal(date);
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
const ask = options.isDateUnavailable;
|
|
627
|
+
const visibleMonths = (): number => Math.max(1, Math.floor(access(options.visibleMonths) ?? 1));
|
|
628
|
+
|
|
629
|
+
// Centred on the range's start, unless its end would then be off the
|
|
630
|
+
// window, in which case the start goes first.
|
|
631
|
+
const alignment = (): "start" | "center" | "end" => {
|
|
632
|
+
const given = access(options.selectionAlignment);
|
|
633
|
+
if (given !== undefined) return given;
|
|
634
|
+
const range = untrack(value);
|
|
635
|
+
if (range === null) return "center";
|
|
636
|
+
const count = visibleMonths();
|
|
637
|
+
const half = Math.floor(count / 2);
|
|
638
|
+
const before = half > 0 && count % 2 === 0 ? half - 1 : half;
|
|
639
|
+
const last = endOfMonth(startOfMonth(range.start).add({ months: count - 1 - before }));
|
|
640
|
+
return range.end.compare(last) > 0 ? "start" : "center";
|
|
641
|
+
};
|
|
524
642
|
|
|
525
643
|
const base = calendarState({
|
|
526
|
-
...(options as CalendarStateOptions),
|
|
644
|
+
...(options as Omit<CalendarStateOptions, "isDateUnavailable">),
|
|
527
645
|
value: () => value()?.start ?? null,
|
|
528
646
|
defaultValue: undefined,
|
|
529
647
|
onChange: undefined,
|
|
648
|
+
selectionAlignment: alignment,
|
|
649
|
+
isDateUnavailable: ask === undefined ? undefined : (date) => ask(date, anchorDate()),
|
|
530
650
|
onFocusChange: (date) => {
|
|
531
651
|
// While a range is being drawn, moving focus IS drawing it, whichever
|
|
532
652
|
// way the focus moved: a press, an arrow key or a page button.
|
|
533
|
-
if (
|
|
653
|
+
if (anchorNow !== null) highlightDate(date);
|
|
534
654
|
options.onFocusChange?.(date);
|
|
535
655
|
},
|
|
536
656
|
});
|
|
@@ -561,8 +681,9 @@ export function rangeCalendarState(options: RangeCalendarStateOptions): RangeCal
|
|
|
561
681
|
};
|
|
562
682
|
|
|
563
683
|
const highlightDate = (date: CalendarDate): void => {
|
|
564
|
-
const anchor =
|
|
684
|
+
const anchor = anchorNow;
|
|
565
685
|
if (anchor === null) return;
|
|
686
|
+
reached = date;
|
|
566
687
|
setDrawn(ordered(anchor, date));
|
|
567
688
|
};
|
|
568
689
|
|
|
@@ -570,7 +691,7 @@ export function rangeCalendarState(options: RangeCalendarStateOptions): RangeCal
|
|
|
570
691
|
if (base.isReadOnly() || base.isDisabled()) return;
|
|
571
692
|
if (base.isCellDisabled(date) || base.isCellUnavailable(date)) return;
|
|
572
693
|
|
|
573
|
-
const anchor =
|
|
694
|
+
const anchor = anchorNow;
|
|
574
695
|
if (anchor === null) {
|
|
575
696
|
writeAnchorDate(date);
|
|
576
697
|
setDrawn({ start: date, end: date });
|
|
@@ -590,18 +711,48 @@ export function rangeCalendarState(options: RangeCalendarStateOptions): RangeCal
|
|
|
590
711
|
setValueRaw(range);
|
|
591
712
|
};
|
|
592
713
|
|
|
714
|
+
const isAvailable = (date: CalendarDate): boolean => {
|
|
715
|
+
const min = access(options.minValue);
|
|
716
|
+
const max = access(options.maxValue);
|
|
717
|
+
if (min !== undefined && min !== null && date.compare(min) < 0) return false;
|
|
718
|
+
if (max !== undefined && max !== null && date.compare(max) > 0) return false;
|
|
719
|
+
return !base.isCellUnavailable(date) && options.isDateDisabled?.(date) !== true;
|
|
720
|
+
};
|
|
721
|
+
|
|
593
722
|
return {
|
|
594
723
|
...base,
|
|
595
724
|
selectionMode: "range",
|
|
596
725
|
value,
|
|
597
726
|
setValue: (next) => setValueRaw(next),
|
|
598
|
-
|
|
727
|
+
// The signal is read so a reader is told when it changes; the variable is
|
|
728
|
+
// returned so a handler sees what the event before it in the same tick did.
|
|
729
|
+
anchorDate: () => {
|
|
730
|
+
anchorDate();
|
|
731
|
+
return anchorNow;
|
|
732
|
+
},
|
|
599
733
|
setAnchorDate: (date) => {
|
|
600
734
|
writeAnchorDate(date);
|
|
601
735
|
setDrawn(date === null ? null : { start: date, end: date });
|
|
602
736
|
},
|
|
603
737
|
highlightedRange,
|
|
604
738
|
highlightDate,
|
|
739
|
+
isDragging,
|
|
740
|
+
setDragging: (next) => setDragging(next),
|
|
741
|
+
commitSelection: () => {
|
|
742
|
+
if (anchorNow === null) return;
|
|
743
|
+
selectDate(reached ?? base.focusedDate());
|
|
744
|
+
},
|
|
745
|
+
clearSelection: () => {
|
|
746
|
+
writeAnchorDate(null);
|
|
747
|
+
setDrawn(null);
|
|
748
|
+
setValueRaw(null);
|
|
749
|
+
},
|
|
750
|
+
isValueInvalid: () => {
|
|
751
|
+
if (access(options.isInvalid) === true) return true;
|
|
752
|
+
const range = value();
|
|
753
|
+
if (range === null || anchorDate() !== null) return false;
|
|
754
|
+
return !isAvailable(range.start) || !isAvailable(range.end);
|
|
755
|
+
},
|
|
605
756
|
isSelected: (date) => {
|
|
606
757
|
const range = highlightedRange();
|
|
607
758
|
if (range === null) return false;
|
|
@@ -683,11 +834,20 @@ export function multipleCalendarState(
|
|
|
683
834
|
setValueRaw([...chosen, date]);
|
|
684
835
|
};
|
|
685
836
|
|
|
837
|
+
const isRefused = (date: CalendarDate): boolean => {
|
|
838
|
+
const min = access(options.minValue);
|
|
839
|
+
const max = access(options.maxValue);
|
|
840
|
+
if (min !== undefined && min !== null && date.compare(min) < 0) return true;
|
|
841
|
+
if (max !== undefined && max !== null && date.compare(max) > 0) return true;
|
|
842
|
+
return base.isCellUnavailable(date) || options.isDateDisabled?.(date) === true;
|
|
843
|
+
};
|
|
844
|
+
|
|
686
845
|
return {
|
|
687
846
|
...base,
|
|
688
847
|
selectionMode: "multiple",
|
|
689
848
|
value,
|
|
690
849
|
setValue: (next) => setValueRaw(next),
|
|
850
|
+
isValueInvalid: () => access(options.isInvalid) === true || value().some(isRefused),
|
|
691
851
|
isSelected,
|
|
692
852
|
selectDate,
|
|
693
853
|
selectFocusedDate: () => selectDate(base.focusedDate()),
|
|
@@ -706,6 +866,75 @@ export interface CalendarOptions {
|
|
|
706
866
|
// flag a caller could set and watch do nothing.
|
|
707
867
|
"aria-label"?: MaybeAccessor<string | undefined>;
|
|
708
868
|
"aria-labelledby"?: MaybeAccessor<string | undefined>;
|
|
869
|
+
/** The calendar's element, for telling a release or a blur outside it from one inside. */
|
|
870
|
+
ref?: ElementRef;
|
|
871
|
+
/**
|
|
872
|
+
* What a range half drawn becomes when the pointer is released outside the
|
|
873
|
+
* calendar or focus leaves it: finished where it reached, abandoned, or
|
|
874
|
+
* abandoned with the value cleared. @default "select"
|
|
875
|
+
*/
|
|
876
|
+
commitBehavior?: MaybeAccessor<"clear" | "reset" | "select" | undefined>;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/** What a calendar's cells need from the calendar around them. */
|
|
880
|
+
interface CalendarData {
|
|
881
|
+
errorMessageId: Accessor<string>;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const calendarData = new WeakMap<AnyCalendarState, CalendarData>();
|
|
885
|
+
|
|
886
|
+
/** The press a range is being drawn with, shared by the cells of one calendar. */
|
|
887
|
+
interface Drag {
|
|
888
|
+
/** The day the press began on, and what it did there. */
|
|
889
|
+
origin: CalendarDate | null;
|
|
890
|
+
kind: "anchor" | "boundary" | null;
|
|
891
|
+
/** A touch waits before it draws, in case it is a scroll. */
|
|
892
|
+
timer: ReturnType<typeof setTimeout> | undefined;
|
|
893
|
+
/** A cell handled the press, so the click that follows is not a second one. */
|
|
894
|
+
clickPending: boolean;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
const drags = new WeakMap<AnyCalendarState, Drag>();
|
|
898
|
+
|
|
899
|
+
function dragOf(state: AnyCalendarState): Drag {
|
|
900
|
+
let drag = drags.get(state);
|
|
901
|
+
if (drag === undefined) {
|
|
902
|
+
drag = { origin: null, kind: null, timer: undefined, clickPending: false };
|
|
903
|
+
drags.set(state, drag);
|
|
904
|
+
}
|
|
905
|
+
return drag;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/** A screen reader's pointer has no size; its press is a click, and handled as one. */
|
|
909
|
+
function isVirtualPointer(event: PointerEvent): boolean {
|
|
910
|
+
return event.pointerType === "" || (event.width === 0 && event.height === 0);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Splits a formatted range into its two ends, at the last literal they share.
|
|
915
|
+
*
|
|
916
|
+
* The locale's own range format puts the separator where it belongs, "11–13
|
|
917
|
+
* March" or "March 11 – 13", and the message around the two ends is the
|
|
918
|
+
* locale's too.
|
|
919
|
+
*/
|
|
920
|
+
function formatRange(
|
|
921
|
+
format: Intl.DateTimeFormat,
|
|
922
|
+
start: CalendarDate,
|
|
923
|
+
end: CalendarDate,
|
|
924
|
+
): { startDate: string; endDate: string } {
|
|
925
|
+
const parts = format.formatRangeToParts(start.toDate(), end.toDate());
|
|
926
|
+
let separator = -1;
|
|
927
|
+
for (const [at, part] of parts.entries()) {
|
|
928
|
+
if (part.source === "shared" && part.type === "literal") separator = at;
|
|
929
|
+
else if (part.source === "endRange") break;
|
|
930
|
+
}
|
|
931
|
+
let startDate = "";
|
|
932
|
+
let endDate = "";
|
|
933
|
+
for (const [at, part] of parts.entries()) {
|
|
934
|
+
if (at < separator) startDate += part.value;
|
|
935
|
+
else if (at > separator) endDate += part.value;
|
|
936
|
+
}
|
|
937
|
+
return { startDate, endDate };
|
|
709
938
|
}
|
|
710
939
|
|
|
711
940
|
export interface CalendarResult {
|
|
@@ -723,6 +952,51 @@ export function calendar(options: CalendarOptions, state: AnyCalendarState): Cal
|
|
|
723
952
|
const baseId = id();
|
|
724
953
|
const errorMessageId = id();
|
|
725
954
|
const titleFormat = dateFormatter({ month: "long", year: "numeric" });
|
|
955
|
+
const messages = stringFormatter(CALENDAR_STRINGS);
|
|
956
|
+
const longDate = dateFormatter({
|
|
957
|
+
weekday: "long",
|
|
958
|
+
month: "long",
|
|
959
|
+
year: "numeric",
|
|
960
|
+
day: "numeric",
|
|
961
|
+
});
|
|
962
|
+
const list = listFormatter();
|
|
963
|
+
calendarData.set(state, { errorMessageId });
|
|
964
|
+
|
|
965
|
+
/** What has been chosen, in words, or nothing while a range is half drawn. */
|
|
966
|
+
const selection = (): string => {
|
|
967
|
+
const spoken = (date: CalendarDate): string => longDate().format(date.toDate());
|
|
968
|
+
if (state.selectionMode === "range") {
|
|
969
|
+
const range = state.value();
|
|
970
|
+
if (range === null || state.anchorDate() !== null) return "";
|
|
971
|
+
if (isSameDay(range.start, range.end)) {
|
|
972
|
+
return messages().format("selectedDateDescription", { date: spoken(range.start) });
|
|
973
|
+
}
|
|
974
|
+
const dateRange = messages().format(
|
|
975
|
+
"dateRange",
|
|
976
|
+
formatRange(longDate(), range.start, range.end),
|
|
977
|
+
);
|
|
978
|
+
return messages().format("selectedRangeDescription", { dateRange });
|
|
979
|
+
}
|
|
980
|
+
if (state.selectionMode === "multiple") {
|
|
981
|
+
const days = state.value();
|
|
982
|
+
if (days.length === 0) return "";
|
|
983
|
+
return messages().format("selectedDateDescription", {
|
|
984
|
+
date: list().format(days.map(spoken)),
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
const chosen = state.value();
|
|
988
|
+
return chosen === null
|
|
989
|
+
? ""
|
|
990
|
+
: messages().format("selectedDateDescription", { date: spoken(chosen) });
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
const commit = (): void => {
|
|
994
|
+
if (state.selectionMode !== "range" || state.anchorDate() === null) return;
|
|
995
|
+
const behavior = access(options.commitBehavior) ?? "select";
|
|
996
|
+
if (behavior === "clear") state.clearSelection();
|
|
997
|
+
else if (behavior === "reset") state.setAnchorDate(null);
|
|
998
|
+
else state.commitSelection();
|
|
999
|
+
};
|
|
726
1000
|
|
|
727
1001
|
const title = (): string => {
|
|
728
1002
|
const range = state.visibleRange();
|
|
@@ -740,6 +1014,55 @@ export function calendar(options: CalendarOptions, state: AnyCalendarState): Cal
|
|
|
740
1014
|
previous = current;
|
|
741
1015
|
if (!untrack(state.isFocused)) announce(current);
|
|
742
1016
|
});
|
|
1017
|
+
|
|
1018
|
+
// A choice is said once it is made, since the day pressed is announced
|
|
1019
|
+
// before the press changes it.
|
|
1020
|
+
let chosen = untrack(selection);
|
|
1021
|
+
createEffect(selection, (current) => {
|
|
1022
|
+
if (current === chosen) return;
|
|
1023
|
+
chosen = current;
|
|
1024
|
+
if (current !== "") announce(current, "polite", 4000);
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
if (state.selectionMode === "range") {
|
|
1028
|
+
// A range drawn by dragging ends where the pointer is released. Released
|
|
1029
|
+
// outside the calendar, or anywhere in it but on a day, the range is
|
|
1030
|
+
// finished, abandoned or cleared as `commitBehavior` says.
|
|
1031
|
+
onSettled(() => {
|
|
1032
|
+
const view = typeof window === "undefined" ? null : window;
|
|
1033
|
+
if (view === null) return undefined;
|
|
1034
|
+
const release = (event: PointerEvent): void => {
|
|
1035
|
+
if (isVirtualPointer(event)) return;
|
|
1036
|
+
const drag = dragOf(state);
|
|
1037
|
+
clearTimeout(drag.timer);
|
|
1038
|
+
drag.timer = undefined;
|
|
1039
|
+
drag.origin = null;
|
|
1040
|
+
drag.kind = null;
|
|
1041
|
+
state.setDragging(false);
|
|
1042
|
+
if (state.anchorDate() === null) return;
|
|
1043
|
+
const root = access(options.ref) as Element | null;
|
|
1044
|
+
if (root === null || !contains(root, activeElement(ownerDocument(root)))) return;
|
|
1045
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
1046
|
+
if (
|
|
1047
|
+
target !== null &&
|
|
1048
|
+
contains(root, target) &&
|
|
1049
|
+
target.closest('button, [role="button"]') !== null
|
|
1050
|
+
) {
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
commit();
|
|
1054
|
+
};
|
|
1055
|
+
const clicked = (): void => {
|
|
1056
|
+
dragOf(state).clickPending = false;
|
|
1057
|
+
};
|
|
1058
|
+
view.addEventListener("pointerup", release);
|
|
1059
|
+
view.addEventListener("click", clicked);
|
|
1060
|
+
return () => {
|
|
1061
|
+
view.removeEventListener("pointerup", release);
|
|
1062
|
+
view.removeEventListener("click", clicked);
|
|
1063
|
+
};
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
743
1066
|
}
|
|
744
1067
|
|
|
745
1068
|
return {
|
|
@@ -751,14 +1074,30 @@ export function calendar(options: CalendarOptions, state: AnyCalendarState): Cal
|
|
|
751
1074
|
id: baseId,
|
|
752
1075
|
"aria-label": () => access(options["aria-label"]),
|
|
753
1076
|
"aria-labelledby": () => access(options["aria-labelledby"]),
|
|
1077
|
+
// Leaving the calendar with a range half drawn finishes it, as letting
|
|
1078
|
+
// go of the pointer outside it does. Focus leaving because the focused
|
|
1079
|
+
// day was removed is not leaving, and is told apart a microtask later.
|
|
1080
|
+
onFocusOut: (event: FocusEvent) => {
|
|
1081
|
+
if (state.selectionMode !== "range") return;
|
|
1082
|
+
const root = event.currentTarget as Element | null;
|
|
1083
|
+
if (root === null) return;
|
|
1084
|
+
const next = event.relatedTarget instanceof Element ? event.relatedTarget : null;
|
|
1085
|
+
if (next !== null) {
|
|
1086
|
+
if (!contains(root, next)) commit();
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
queueMicrotask(() => {
|
|
1090
|
+
if (!contains(root, activeElement(ownerDocument(root)))) commit();
|
|
1091
|
+
});
|
|
1092
|
+
},
|
|
754
1093
|
}),
|
|
755
1094
|
prevButtonProps: {
|
|
756
|
-
"aria-label":
|
|
1095
|
+
"aria-label": () => messages().format("previous"),
|
|
757
1096
|
isDisabled: () => state.isDisabled() || state.isPreviousVisibleRangeInvalid(),
|
|
758
1097
|
onPress: () => state.focusPreviousPage(),
|
|
759
1098
|
},
|
|
760
1099
|
nextButtonProps: {
|
|
761
|
-
"aria-label":
|
|
1100
|
+
"aria-label": () => messages().format("next"),
|
|
762
1101
|
isDisabled: () => state.isDisabled() || state.isNextVisibleRangeInvalid(),
|
|
763
1102
|
onPress: () => state.focusNextPage(),
|
|
764
1103
|
},
|
|
@@ -815,7 +1154,9 @@ export function calendarGrid(
|
|
|
815
1154
|
});
|
|
816
1155
|
|
|
817
1156
|
const weeksInMonth = (): number =>
|
|
818
|
-
access(options.fixedWeeks) === true
|
|
1157
|
+
access(options.fixedWeeks) === true
|
|
1158
|
+
? 6
|
|
1159
|
+
: (state.weeksInMonth() ?? getWeeksInMonth(month(), state.firstDayOfWeek()));
|
|
819
1160
|
|
|
820
1161
|
const weekDates = (week: number): CalendarDate[] => {
|
|
821
1162
|
const first = startOfWeek(month(), state.firstDayOfWeek());
|
|
@@ -981,6 +1322,8 @@ export function calendarCell(
|
|
|
981
1322
|
year: "numeric",
|
|
982
1323
|
});
|
|
983
1324
|
const dayFormat = dateFormatter({ day: "numeric" });
|
|
1325
|
+
const messages = stringFormatter(CALENDAR_STRINGS);
|
|
1326
|
+
const drag = dragOf(state);
|
|
984
1327
|
|
|
985
1328
|
const date = (): CalendarDate => access(options.date);
|
|
986
1329
|
|
|
@@ -991,7 +1334,30 @@ export function calendarCell(
|
|
|
991
1334
|
const isDisabled = (): boolean => state.isCellDisabled(date()) || isOutside();
|
|
992
1335
|
const isUnavailable = (): boolean => state.isCellUnavailable(date());
|
|
993
1336
|
const isSelectable = (): boolean => !isDisabled() && !isUnavailable();
|
|
994
|
-
|
|
1337
|
+
|
|
1338
|
+
/** This day is part of a value the calendar says is wrong. */
|
|
1339
|
+
const isInvalid = (): boolean => {
|
|
1340
|
+
if (!state.isValueInvalid()) return false;
|
|
1341
|
+
const day = date();
|
|
1342
|
+
if (state.selectionMode === "range") {
|
|
1343
|
+
const range = state.highlightedRange();
|
|
1344
|
+
return (
|
|
1345
|
+
state.anchorDate() === null &&
|
|
1346
|
+
range !== null &&
|
|
1347
|
+
day.compare(range.start) >= 0 &&
|
|
1348
|
+
day.compare(range.end) <= 0
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
if (state.selectionMode === "multiple") return state.value().some((one) => isSameDay(one, day));
|
|
1352
|
+
const chosen = state.value();
|
|
1353
|
+
return chosen !== null && isSameDay(chosen, day);
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
// A chosen day stays drawn as chosen while it is invalid, even when it is
|
|
1357
|
+
// one that could not be chosen now: the value is what it is, and hiding it
|
|
1358
|
+
// would leave the error pointing at nothing.
|
|
1359
|
+
const isSelected = (): boolean =>
|
|
1360
|
+
(state.isSelected(date()) && isSelectable()) || (isInvalid() && !isDisabled());
|
|
995
1361
|
const isFocused = (): boolean => state.isCellFocused(date()) && !isOutside();
|
|
996
1362
|
const isTodayCell = (): boolean => isSameDay(date(), state.today());
|
|
997
1363
|
|
|
@@ -1021,10 +1387,85 @@ export function calendarCell(
|
|
|
1021
1387
|
}
|
|
1022
1388
|
|
|
1023
1389
|
const label = (): string => {
|
|
1024
|
-
|
|
1025
|
-
if (isTodayCell())
|
|
1026
|
-
|
|
1027
|
-
|
|
1390
|
+
const text = labelFormat().format(date().toDate());
|
|
1391
|
+
if (isTodayCell()) {
|
|
1392
|
+
return messages().format(isSelected() ? "todayDateSelected" : "todayDate", { date: text });
|
|
1393
|
+
}
|
|
1394
|
+
return isSelected() ? messages().format("dateSelected", { date: text }) : text;
|
|
1395
|
+
};
|
|
1396
|
+
|
|
1397
|
+
/** A range drawn by pressing one day and releasing on another. */
|
|
1398
|
+
const onPointerDown = (event: PointerEvent): void => {
|
|
1399
|
+
if (state.selectionMode !== "range" || event.button !== 0 || isVirtualPointer(event)) return;
|
|
1400
|
+
drag.clickPending = true;
|
|
1401
|
+
// A touch keeps the pointer on the element it began on unless released,
|
|
1402
|
+
// and the days it is dragged over would then never hear it.
|
|
1403
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
1404
|
+
if (target?.hasPointerCapture?.(event.pointerId) === true) {
|
|
1405
|
+
target.releasePointerCapture(event.pointerId);
|
|
1406
|
+
}
|
|
1407
|
+
if (!isSelectable()) return;
|
|
1408
|
+
const day = date();
|
|
1409
|
+
if (state.isReadOnly()) {
|
|
1410
|
+
state.setFocusedDate(day);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
if (state.anchorDate() !== null) return;
|
|
1414
|
+
|
|
1415
|
+
// Pressing an end of the chosen range takes hold of it, so dragging moves
|
|
1416
|
+
// that end and leaves the other where it is.
|
|
1417
|
+
const range = state.highlightedRange();
|
|
1418
|
+
if (range !== null && !isInvalid()) {
|
|
1419
|
+
const other = isSameDay(day, range.start)
|
|
1420
|
+
? range.end
|
|
1421
|
+
: isSameDay(day, range.end)
|
|
1422
|
+
? range.start
|
|
1423
|
+
: null;
|
|
1424
|
+
if (other !== null) {
|
|
1425
|
+
state.setAnchorDate(other);
|
|
1426
|
+
state.setFocusedDate(day);
|
|
1427
|
+
state.setDragging(true);
|
|
1428
|
+
drag.origin = day;
|
|
1429
|
+
drag.kind = "boundary";
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
const start = (): void => {
|
|
1435
|
+
drag.timer = undefined;
|
|
1436
|
+
state.setDragging(true);
|
|
1437
|
+
state.selectDate(day);
|
|
1438
|
+
state.setFocusedDate(day);
|
|
1439
|
+
drag.origin = day;
|
|
1440
|
+
drag.kind = "anchor";
|
|
1441
|
+
};
|
|
1442
|
+
if (event.pointerType === "touch") drag.timer = setTimeout(start, 200);
|
|
1443
|
+
else start();
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
const onPointerUp = (event: PointerEvent): void => {
|
|
1447
|
+
if (state.selectionMode !== "range" || event.button !== 0 || isVirtualPointer(event)) return;
|
|
1448
|
+
drag.clickPending = true;
|
|
1449
|
+
if (state.isReadOnly()) return;
|
|
1450
|
+
const day = date();
|
|
1451
|
+
|
|
1452
|
+
// A tap quicker than the wait for a drag is a press like any other.
|
|
1453
|
+
if (drag.timer !== undefined) {
|
|
1454
|
+
clearTimeout(drag.timer);
|
|
1455
|
+
drag.timer = undefined;
|
|
1456
|
+
state.selectDate(day);
|
|
1457
|
+
state.setFocusedDate(day);
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
const fromHere = drag.origin !== null && isSameDay(drag.origin, day);
|
|
1462
|
+
if (drag.kind === "boundary" && fromHere) {
|
|
1463
|
+
// An end pressed and let go without moving starts a new range there.
|
|
1464
|
+
state.setAnchorDate(day);
|
|
1465
|
+
} else if (state.anchorDate() !== null && !(drag.kind === "anchor" && fromHere)) {
|
|
1466
|
+
state.selectDate(day);
|
|
1467
|
+
state.setFocusedDate(day);
|
|
1468
|
+
}
|
|
1028
1469
|
};
|
|
1029
1470
|
|
|
1030
1471
|
return {
|
|
@@ -1041,6 +1482,7 @@ export function calendarCell(
|
|
|
1041
1482
|
role: "gridcell",
|
|
1042
1483
|
"aria-selected": () => isSelected() || undefined,
|
|
1043
1484
|
"aria-disabled": () => (!isSelectable() ? true : undefined),
|
|
1485
|
+
"aria-invalid": () => isInvalid() || undefined,
|
|
1044
1486
|
},
|
|
1045
1487
|
buttonProps: {
|
|
1046
1488
|
role: "button",
|
|
@@ -1048,19 +1490,35 @@ export function calendarCell(
|
|
|
1048
1490
|
// from the last week reaches the next MONTH and not a duplicate.
|
|
1049
1491
|
"aria-hidden": () => isOutside() || undefined,
|
|
1050
1492
|
"aria-label": label,
|
|
1051
|
-
"aria-invalid": () => undefined,
|
|
1493
|
+
"aria-invalid": () => isInvalid() || undefined,
|
|
1494
|
+
// The error message says what is wrong with the value, so the days that
|
|
1495
|
+
// make it up point at it.
|
|
1496
|
+
"aria-describedby": () =>
|
|
1497
|
+
isInvalid() ? calendarData.get(state)?.errorMessageId() : undefined,
|
|
1052
1498
|
// The roving focus: one day in the Tab order, and it moves with the
|
|
1053
1499
|
// arrows.
|
|
1054
1500
|
tabIndex: () =>
|
|
1055
1501
|
isOutside() ? undefined : isFocused() || isSameDay(state.focusedDate(), date()) ? 0 : -1,
|
|
1056
|
-
onPointerEnter: () => {
|
|
1502
|
+
onPointerEnter: (event: PointerEvent) => {
|
|
1057
1503
|
// Drawing a range follows the pointer, so the highlight is what the
|
|
1058
|
-
// user would get by releasing here.
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1504
|
+
// user would get by releasing here. A touch only draws once it has
|
|
1505
|
+
// waited long enough to be a drag rather than a scroll.
|
|
1506
|
+
if (state.selectionMode !== "range" || state.anchorDate() === null) return;
|
|
1507
|
+
if (event.pointerType === "touch" && !state.isDragging()) return;
|
|
1508
|
+
if (isSelectable()) state.highlightDate(date());
|
|
1509
|
+
},
|
|
1510
|
+
onPointerDown,
|
|
1511
|
+
onPointerUp,
|
|
1512
|
+
onContextMenu: (event: MouseEvent) => {
|
|
1513
|
+
// A long press on a touch screen is a drag here, not a menu.
|
|
1514
|
+
if (state.selectionMode === "range") event.preventDefault();
|
|
1062
1515
|
},
|
|
1063
1516
|
onClick: () => {
|
|
1517
|
+
// The pointer already chose; this is the click the browser sends after.
|
|
1518
|
+
if (drag.clickPending) {
|
|
1519
|
+
drag.clickPending = false;
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1064
1522
|
if (isOutside() || state.isCellDisabled(date())) return;
|
|
1065
1523
|
state.setFocusedDate(date());
|
|
1066
1524
|
state.selectDate(date());
|
|
@@ -1088,10 +1546,10 @@ export function useCalendar(): CalendarContextValue {
|
|
|
1088
1546
|
return value;
|
|
1089
1547
|
}
|
|
1090
1548
|
|
|
1091
|
-
function CalendarProvider(props:
|
|
1549
|
+
function CalendarProvider(props: { value: CalendarContextValue; children?: Child }) {
|
|
1092
1550
|
return provide(
|
|
1093
1551
|
CalendarContext,
|
|
1094
|
-
() => props.value
|
|
1552
|
+
() => props.value,
|
|
1095
1553
|
() => props.children as unknown,
|
|
1096
1554
|
);
|
|
1097
1555
|
}
|
|
@@ -1118,6 +1576,12 @@ export interface CalendarComponentProps extends StyleProps {
|
|
|
1118
1576
|
timeZone?: string;
|
|
1119
1577
|
/** @default "narrow" */
|
|
1120
1578
|
weekdayStyle?: "narrow" | "short" | "long";
|
|
1579
|
+
/** Where the chosen day sits among several months when first shown. @default "center" */
|
|
1580
|
+
selectionAlignment?: "start" | "center" | "end";
|
|
1581
|
+
/** Every month drawn with this many week rows. */
|
|
1582
|
+
weeksInMonth?: number;
|
|
1583
|
+
/** Said by the caller, whatever the value is. */
|
|
1584
|
+
isInvalid?: boolean;
|
|
1121
1585
|
errorMessage?: Child;
|
|
1122
1586
|
"aria-label"?: string;
|
|
1123
1587
|
"aria-labelledby"?: string;
|
|
@@ -1132,36 +1596,46 @@ export interface CalendarComponentProps extends StyleProps {
|
|
|
1132
1596
|
* minValue={today()} />
|
|
1133
1597
|
* ```
|
|
1134
1598
|
*/
|
|
1135
|
-
export function Calendar(props:
|
|
1599
|
+
export function Calendar(props: CalendarComponentProps) {
|
|
1136
1600
|
const state = calendarState({
|
|
1137
|
-
value: () => props.value
|
|
1138
|
-
defaultValue: () => props.defaultValue
|
|
1139
|
-
focusedValue: () => props.focusedValue
|
|
1140
|
-
defaultFocusedValue: () => props.defaultFocusedValue
|
|
1141
|
-
minValue: () => props.minValue
|
|
1142
|
-
maxValue: () => props.maxValue
|
|
1143
|
-
isDateUnavailable: callback<[CalendarDate], boolean>(props.isDateUnavailable),
|
|
1144
|
-
isDateDisabled: callback<[CalendarDate], boolean>(props.isDateDisabled),
|
|
1145
|
-
isDisabled: () => props.isDisabled
|
|
1146
|
-
isReadOnly: () => props.isReadOnly
|
|
1147
|
-
autoFocus: () => props.autoFocus
|
|
1148
|
-
allowsDeselection: () => props.allowsDeselection
|
|
1149
|
-
firstDayOfWeek: () => props.firstDayOfWeek
|
|
1150
|
-
timeZone: () => props.timeZone
|
|
1151
|
-
|
|
1152
|
-
|
|
1601
|
+
value: () => props.value,
|
|
1602
|
+
defaultValue: () => props.defaultValue,
|
|
1603
|
+
focusedValue: () => props.focusedValue,
|
|
1604
|
+
defaultFocusedValue: () => props.defaultFocusedValue,
|
|
1605
|
+
minValue: () => props.minValue,
|
|
1606
|
+
maxValue: () => props.maxValue,
|
|
1607
|
+
isDateUnavailable: callback<[CalendarDate], boolean>(cells(props).isDateUnavailable),
|
|
1608
|
+
isDateDisabled: callback<[CalendarDate], boolean>(cells(props).isDateDisabled),
|
|
1609
|
+
isDisabled: () => props.isDisabled,
|
|
1610
|
+
isReadOnly: () => props.isReadOnly,
|
|
1611
|
+
autoFocus: () => props.autoFocus,
|
|
1612
|
+
allowsDeselection: () => props.allowsDeselection,
|
|
1613
|
+
firstDayOfWeek: () => props.firstDayOfWeek,
|
|
1614
|
+
timeZone: () => props.timeZone,
|
|
1615
|
+
isInvalid: () => props.isInvalid,
|
|
1616
|
+
selectionAlignment: () => props.selectionAlignment,
|
|
1617
|
+
weeksInMonth: () => props.weeksInMonth,
|
|
1618
|
+
onChange: (value) => props.onChange?.(value),
|
|
1619
|
+
onFocusChange: (date) => props.onFocusChange?.(date),
|
|
1153
1620
|
});
|
|
1154
1621
|
|
|
1155
|
-
return <CalendarBody state={state} of={props} />;
|
|
1622
|
+
return <CalendarBody state={state} of={cells(props)} />;
|
|
1156
1623
|
}
|
|
1157
1624
|
|
|
1158
1625
|
export interface RangeCalendarComponentProps extends Omit<
|
|
1159
1626
|
CalendarComponentProps,
|
|
1160
|
-
"value" | "defaultValue" | "onChange"
|
|
1627
|
+
"value" | "defaultValue" | "onChange" | "isDateUnavailable"
|
|
1161
1628
|
> {
|
|
1162
1629
|
value?: DateRange | null;
|
|
1163
1630
|
defaultValue?: DateRange | null;
|
|
1164
1631
|
allowsNonContiguousRanges?: boolean;
|
|
1632
|
+
/** Days that cannot be chosen, told the day the range being drawn began on. */
|
|
1633
|
+
isDateUnavailable?: (date: CalendarDate, anchorDate: CalendarDate | null) => boolean;
|
|
1634
|
+
/**
|
|
1635
|
+
* What a range half drawn becomes when the pointer is released outside the
|
|
1636
|
+
* calendar or focus leaves it. @default "select"
|
|
1637
|
+
*/
|
|
1638
|
+
commitBehavior?: "clear" | "reset" | "select";
|
|
1165
1639
|
onChange?: (value: DateRange | null) => void;
|
|
1166
1640
|
}
|
|
1167
1641
|
|
|
@@ -1172,27 +1646,38 @@ export interface RangeCalendarComponentProps extends Omit<
|
|
|
1172
1646
|
* focus between the two DRAWS: what is highlighted is what releasing would
|
|
1173
1647
|
* give, so the user is never guessing.
|
|
1174
1648
|
*/
|
|
1175
|
-
export function RangeCalendar(props:
|
|
1649
|
+
export function RangeCalendar(props: RangeCalendarComponentProps) {
|
|
1176
1650
|
const state = rangeCalendarState({
|
|
1177
|
-
value: () => props.value
|
|
1178
|
-
defaultValue: () => props.defaultValue
|
|
1179
|
-
focusedValue: () => props.focusedValue
|
|
1180
|
-
defaultFocusedValue: () => props.defaultFocusedValue
|
|
1181
|
-
minValue: () => props.minValue
|
|
1182
|
-
maxValue: () => props.maxValue
|
|
1183
|
-
isDateUnavailable: callback<[CalendarDate], boolean>(
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1651
|
+
value: () => props.value,
|
|
1652
|
+
defaultValue: () => props.defaultValue,
|
|
1653
|
+
focusedValue: () => props.focusedValue,
|
|
1654
|
+
defaultFocusedValue: () => props.defaultFocusedValue,
|
|
1655
|
+
minValue: () => props.minValue,
|
|
1656
|
+
maxValue: () => props.maxValue,
|
|
1657
|
+
isDateUnavailable: callback<[CalendarDate, CalendarDate | null], boolean>(
|
|
1658
|
+
cells(props).isDateUnavailable,
|
|
1659
|
+
),
|
|
1660
|
+
isDateDisabled: callback<[CalendarDate], boolean>(cells(props).isDateDisabled),
|
|
1661
|
+
isDisabled: () => props.isDisabled,
|
|
1662
|
+
isReadOnly: () => props.isReadOnly,
|
|
1663
|
+
autoFocus: () => props.autoFocus,
|
|
1664
|
+
firstDayOfWeek: () => props.firstDayOfWeek,
|
|
1665
|
+
timeZone: () => props.timeZone,
|
|
1666
|
+
isInvalid: () => props.isInvalid,
|
|
1667
|
+
selectionAlignment: () => props.selectionAlignment,
|
|
1668
|
+
weeksInMonth: () => props.weeksInMonth,
|
|
1669
|
+
allowsNonContiguousRanges: () => props.allowsNonContiguousRanges,
|
|
1670
|
+
onChange: (value) => props.onChange?.(value),
|
|
1671
|
+
onFocusChange: (date) => props.onFocusChange?.(date),
|
|
1193
1672
|
});
|
|
1194
1673
|
|
|
1195
|
-
return
|
|
1674
|
+
return (
|
|
1675
|
+
<CalendarBody
|
|
1676
|
+
state={state}
|
|
1677
|
+
of={cells(props) as unknown as Incoming<CalendarComponentProps>}
|
|
1678
|
+
commitBehavior={props.commitBehavior}
|
|
1679
|
+
/>
|
|
1680
|
+
);
|
|
1196
1681
|
}
|
|
1197
1682
|
|
|
1198
1683
|
export interface MultipleCalendarComponentProps extends Omit<
|
|
@@ -1216,49 +1701,58 @@ export interface MultipleCalendarComponentProps extends Omit<
|
|
|
1216
1701
|
* says it takes more than one so a screen reader does not announce a choice
|
|
1217
1702
|
* as having replaced the last.
|
|
1218
1703
|
*/
|
|
1219
|
-
export function MultipleCalendar(props:
|
|
1704
|
+
export function MultipleCalendar(props: MultipleCalendarComponentProps) {
|
|
1220
1705
|
const state = multipleCalendarState({
|
|
1221
|
-
value: () => props.value
|
|
1222
|
-
defaultValue: () => props.defaultValue
|
|
1223
|
-
focusedValue: () => props.focusedValue
|
|
1224
|
-
defaultFocusedValue: () => props.defaultFocusedValue
|
|
1225
|
-
minValue: () => props.minValue
|
|
1226
|
-
maxValue: () => props.maxValue
|
|
1227
|
-
isDateUnavailable: callback<[CalendarDate], boolean>(props.isDateUnavailable),
|
|
1228
|
-
isDateDisabled: callback<[CalendarDate], boolean>(props.isDateDisabled),
|
|
1229
|
-
isDisabled: () => props.isDisabled
|
|
1230
|
-
isReadOnly: () => props.isReadOnly
|
|
1231
|
-
autoFocus: () => props.autoFocus
|
|
1232
|
-
firstDayOfWeek: () => props.firstDayOfWeek
|
|
1233
|
-
timeZone: () => props.timeZone
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1706
|
+
value: () => props.value,
|
|
1707
|
+
defaultValue: () => props.defaultValue,
|
|
1708
|
+
focusedValue: () => props.focusedValue,
|
|
1709
|
+
defaultFocusedValue: () => props.defaultFocusedValue,
|
|
1710
|
+
minValue: () => props.minValue,
|
|
1711
|
+
maxValue: () => props.maxValue,
|
|
1712
|
+
isDateUnavailable: callback<[CalendarDate], boolean>(cells(props).isDateUnavailable),
|
|
1713
|
+
isDateDisabled: callback<[CalendarDate], boolean>(cells(props).isDateDisabled),
|
|
1714
|
+
isDisabled: () => props.isDisabled,
|
|
1715
|
+
isReadOnly: () => props.isReadOnly,
|
|
1716
|
+
autoFocus: () => props.autoFocus,
|
|
1717
|
+
firstDayOfWeek: () => props.firstDayOfWeek,
|
|
1718
|
+
timeZone: () => props.timeZone,
|
|
1719
|
+
isInvalid: () => props.isInvalid,
|
|
1720
|
+
selectionAlignment: () => props.selectionAlignment,
|
|
1721
|
+
weeksInMonth: () => props.weeksInMonth,
|
|
1722
|
+
min: () => props.min,
|
|
1723
|
+
max: () => props.max,
|
|
1724
|
+
required: () => props.required,
|
|
1725
|
+
onChange: (value) => props.onChange?.(value),
|
|
1726
|
+
onFocusChange: (date) => props.onFocusChange?.(date),
|
|
1239
1727
|
});
|
|
1240
1728
|
|
|
1241
|
-
return
|
|
1729
|
+
return (
|
|
1730
|
+
<CalendarBody state={state} of={cells(props) as unknown as Incoming<CalendarComponentProps>} />
|
|
1731
|
+
);
|
|
1242
1732
|
}
|
|
1243
1733
|
|
|
1244
1734
|
interface CalendarBodyProps {
|
|
1245
1735
|
state: AnyCalendarState;
|
|
1246
1736
|
/** The calendar's own props, still as Cells. */
|
|
1247
1737
|
of: Incoming<CalendarComponentProps>;
|
|
1738
|
+
commitBehavior?: "clear" | "reset" | "select";
|
|
1248
1739
|
}
|
|
1249
1740
|
|
|
1250
1741
|
/** The heading, the two page buttons and the grid: what both calendars are. */
|
|
1251
|
-
function CalendarBody(incoming:
|
|
1252
|
-
const state = incoming.state
|
|
1253
|
-
const props = incoming.of
|
|
1742
|
+
function CalendarBody(incoming: CalendarBodyProps) {
|
|
1743
|
+
const state = incoming.state;
|
|
1744
|
+
const props = incoming.of;
|
|
1254
1745
|
const prevRef = makeRef<HTMLButtonElement>();
|
|
1255
1746
|
const nextRef = makeRef<HTMLButtonElement>();
|
|
1747
|
+
const rootRef = makeRef<HTMLDivElement>();
|
|
1256
1748
|
|
|
1257
1749
|
const { calendarProps, prevButtonProps, nextButtonProps, errorMessageProps, title, baseId } =
|
|
1258
1750
|
calendar(
|
|
1259
1751
|
{
|
|
1752
|
+
ref: rootRef,
|
|
1260
1753
|
"aria-label": () => props["aria-label"]?.(),
|
|
1261
1754
|
"aria-labelledby": () => props["aria-labelledby"]?.(),
|
|
1755
|
+
commitBehavior: () => incoming.commitBehavior,
|
|
1262
1756
|
},
|
|
1263
1757
|
state,
|
|
1264
1758
|
);
|
|
@@ -1291,7 +1785,7 @@ function CalendarBody(incoming: Incoming<CalendarBodyProps>) {
|
|
|
1291
1785
|
|
|
1292
1786
|
return (
|
|
1293
1787
|
<CalendarProvider value={value}>
|
|
1294
|
-
<div {...elementProps} ref={mergeRefs(props.ref?.())}>
|
|
1788
|
+
<div {...elementProps} ref={mergeRefs(rootRef.set, props.ref?.())}>
|
|
1295
1789
|
<div>
|
|
1296
1790
|
<button {...previous.buttonProps} type="button" ref={prevRef.set}>
|
|
1297
1791
|
<span aria-hidden="true">‹</span>
|
|
@@ -1337,7 +1831,7 @@ export interface CalendarCellComponentProps extends StyleProps {
|
|
|
1337
1831
|
}
|
|
1338
1832
|
|
|
1339
1833
|
/** One day. */
|
|
1340
|
-
export function CalendarCell(props:
|
|
1834
|
+
export function CalendarCell(props: CalendarCellComponentProps) {
|
|
1341
1835
|
const domRef = makeRef<HTMLDivElement>();
|
|
1342
1836
|
const { state } = useCalendar();
|
|
1343
1837
|
|
|
@@ -1353,7 +1847,7 @@ export function CalendarCell(props: Incoming<CalendarCellComponentProps>) {
|
|
|
1353
1847
|
isSelectionStart,
|
|
1354
1848
|
isSelectionEnd,
|
|
1355
1849
|
formattedDate,
|
|
1356
|
-
} = calendarCell({ date: () => props.date
|
|
1850
|
+
} = calendarCell({ date: () => props.date, ref: domRef }, state);
|
|
1357
1851
|
|
|
1358
1852
|
const { hoverProps, isHovered } = hover({ isDisabled });
|
|
1359
1853
|
const { focusProps, isFocusVisible } = focusRing();
|
|
@@ -1362,8 +1856,8 @@ export function CalendarCell(props: Incoming<CalendarCellComponentProps>) {
|
|
|
1362
1856
|
buttonProps,
|
|
1363
1857
|
hoverProps,
|
|
1364
1858
|
focusProps,
|
|
1365
|
-
filterDOMProps(fromProps(props), { global: true }),
|
|
1366
|
-
styleProps(props),
|
|
1859
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
1860
|
+
styleProps(cells(props)),
|
|
1367
1861
|
{
|
|
1368
1862
|
"data-selected": isSelected,
|
|
1369
1863
|
"data-focused": isFocused,
|
|
@@ -1375,15 +1869,448 @@ export function CalendarCell(props: Incoming<CalendarCellComponentProps>) {
|
|
|
1375
1869
|
"data-today": isTodayCell,
|
|
1376
1870
|
"data-selection-start": isSelectionStart,
|
|
1377
1871
|
"data-selection-end": isSelectionEnd,
|
|
1378
|
-
"data-testid": () => props["data-testid"]
|
|
1872
|
+
"data-testid": () => props["data-testid"],
|
|
1379
1873
|
},
|
|
1380
1874
|
);
|
|
1381
1875
|
|
|
1382
1876
|
return (
|
|
1383
1877
|
<div {...cellProps}>
|
|
1384
|
-
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref
|
|
1878
|
+
<div {...elementProps} ref={mergeRefs(domRef.set, props.ref)}>
|
|
1385
1879
|
{formattedDate}
|
|
1386
1880
|
</div>
|
|
1387
1881
|
</div>
|
|
1388
1882
|
);
|
|
1389
1883
|
}
|
|
1884
|
+
|
|
1885
|
+
// ---------------------------------------------------------------------------
|
|
1886
|
+
// Strings
|
|
1887
|
+
// ---------------------------------------------------------------------------
|
|
1888
|
+
|
|
1889
|
+
/** A message with `{name}` slots filled from the variables it is formatted with. */
|
|
1890
|
+
function say(template: string): LocalizedString {
|
|
1891
|
+
return (variables) =>
|
|
1892
|
+
template.replace(/\{(\w+)\}/g, (_, slot: string) => String(variables?.[slot] ?? ""));
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
type CalendarKey =
|
|
1896
|
+
| "previous"
|
|
1897
|
+
| "next"
|
|
1898
|
+
| "selectedDateDescription"
|
|
1899
|
+
| "selectedRangeDescription"
|
|
1900
|
+
| "todayDate"
|
|
1901
|
+
| "todayDateSelected"
|
|
1902
|
+
| "dateSelected"
|
|
1903
|
+
| "minimumDate"
|
|
1904
|
+
| "maximumDate"
|
|
1905
|
+
| "dateRange";
|
|
1906
|
+
|
|
1907
|
+
const CALENDAR_STRINGS = new StringDictionary<CalendarKey>({
|
|
1908
|
+
"en-US": {
|
|
1909
|
+
previous: "Previous month",
|
|
1910
|
+
next: "Next month",
|
|
1911
|
+
selectedDateDescription: say("Selected Date: {date}"),
|
|
1912
|
+
selectedRangeDescription: say("Selected Range: {dateRange}"),
|
|
1913
|
+
todayDate: say("Today, {date}"),
|
|
1914
|
+
todayDateSelected: say("Today, {date} selected"),
|
|
1915
|
+
dateSelected: say("{date} selected"),
|
|
1916
|
+
minimumDate: "First available date",
|
|
1917
|
+
maximumDate: "Last available date",
|
|
1918
|
+
dateRange: say("{startDate} to {endDate}"),
|
|
1919
|
+
},
|
|
1920
|
+
"ar-AE": {
|
|
1921
|
+
previous: "السابق",
|
|
1922
|
+
next: "التالي",
|
|
1923
|
+
selectedDateDescription: say("تاريخ محدد: {date}"),
|
|
1924
|
+
selectedRangeDescription: say("المدى الزمني المحدد: {dateRange}"),
|
|
1925
|
+
todayDate: say("اليوم، {date}"),
|
|
1926
|
+
todayDateSelected: say("اليوم، {date} محدد"),
|
|
1927
|
+
dateSelected: say("{date} المحدد"),
|
|
1928
|
+
minimumDate: "أول تاريخ متاح",
|
|
1929
|
+
maximumDate: "آخر تاريخ متاح",
|
|
1930
|
+
dateRange: say("{startDate} إلى {endDate}"),
|
|
1931
|
+
},
|
|
1932
|
+
"bg-BG": {
|
|
1933
|
+
previous: "Назад",
|
|
1934
|
+
next: "Напред",
|
|
1935
|
+
selectedDateDescription: say("Избрана дата: {date}"),
|
|
1936
|
+
selectedRangeDescription: say("Избран диапазон: {dateRange}"),
|
|
1937
|
+
todayDate: say("Днес, {date}"),
|
|
1938
|
+
todayDateSelected: say("Днес, {date} са избрани"),
|
|
1939
|
+
dateSelected: say("Избрано е {date}"),
|
|
1940
|
+
minimumDate: "Първа налична дата",
|
|
1941
|
+
maximumDate: "Последна налична дата",
|
|
1942
|
+
dateRange: say("{startDate} до {endDate}"),
|
|
1943
|
+
},
|
|
1944
|
+
"cs-CZ": {
|
|
1945
|
+
previous: "Předchozí",
|
|
1946
|
+
next: "Další",
|
|
1947
|
+
selectedDateDescription: say("Vybrané datum: {date}"),
|
|
1948
|
+
selectedRangeDescription: say("Vybrané období: {dateRange}"),
|
|
1949
|
+
todayDate: say("Dnes, {date}"),
|
|
1950
|
+
todayDateSelected: say("Dnes, vybráno {date}"),
|
|
1951
|
+
dateSelected: say("Vybráno {date}"),
|
|
1952
|
+
minimumDate: "První dostupné datum",
|
|
1953
|
+
maximumDate: "Poslední dostupné datum",
|
|
1954
|
+
dateRange: say("{startDate} až {endDate}"),
|
|
1955
|
+
},
|
|
1956
|
+
"da-DK": {
|
|
1957
|
+
previous: "Forrige",
|
|
1958
|
+
next: "Næste",
|
|
1959
|
+
selectedDateDescription: say("Valgt dato: {date}"),
|
|
1960
|
+
selectedRangeDescription: say("Valgt interval: {dateRange}"),
|
|
1961
|
+
todayDate: say("I dag, {date}"),
|
|
1962
|
+
todayDateSelected: say("I dag, {date} valgt"),
|
|
1963
|
+
dateSelected: say("{date} valgt"),
|
|
1964
|
+
minimumDate: "Første ledige dato",
|
|
1965
|
+
maximumDate: "Sidste ledige dato",
|
|
1966
|
+
dateRange: say("{startDate} til {endDate}"),
|
|
1967
|
+
},
|
|
1968
|
+
"de-DE": {
|
|
1969
|
+
previous: "Zurück",
|
|
1970
|
+
next: "Weiter",
|
|
1971
|
+
selectedDateDescription: say("Ausgewähltes Datum: {date}"),
|
|
1972
|
+
selectedRangeDescription: say("Ausgewählter Bereich: {dateRange}"),
|
|
1973
|
+
todayDate: say("Heute, {date}"),
|
|
1974
|
+
todayDateSelected: say("Heute, {date} ausgewählt"),
|
|
1975
|
+
dateSelected: say("{date} ausgewählt"),
|
|
1976
|
+
minimumDate: "Erstes verfügbares Datum",
|
|
1977
|
+
maximumDate: "Letztes verfügbares Datum",
|
|
1978
|
+
dateRange: say("{startDate} bis {endDate}"),
|
|
1979
|
+
},
|
|
1980
|
+
"el-GR": {
|
|
1981
|
+
previous: "Προηγούμενο",
|
|
1982
|
+
next: "Επόμενο",
|
|
1983
|
+
selectedDateDescription: say("Επιλεγμένη ημερομηνία: {date}"),
|
|
1984
|
+
selectedRangeDescription: say("Επιλεγμένο εύρος: {dateRange}"),
|
|
1985
|
+
todayDate: say("Σήμερα, {date}"),
|
|
1986
|
+
todayDateSelected: say("Σήμερα, επιλέχτηκε {date}"),
|
|
1987
|
+
dateSelected: say("Επιλέχθηκε {date}"),
|
|
1988
|
+
minimumDate: "Πρώτη διαθέσιμη ημερομηνία",
|
|
1989
|
+
maximumDate: "Τελευταία διαθέσιμη ημερομηνία",
|
|
1990
|
+
dateRange: say("{startDate} έως {endDate}"),
|
|
1991
|
+
},
|
|
1992
|
+
"es-ES": {
|
|
1993
|
+
previous: "Anterior",
|
|
1994
|
+
next: "Siguiente",
|
|
1995
|
+
selectedDateDescription: say("Fecha seleccionada: {date}"),
|
|
1996
|
+
selectedRangeDescription: say("Intervalo seleccionado: {dateRange}"),
|
|
1997
|
+
todayDate: say("Hoy, {date}"),
|
|
1998
|
+
todayDateSelected: say("Hoy, {date} seleccionado"),
|
|
1999
|
+
dateSelected: say("{date} seleccionado"),
|
|
2000
|
+
minimumDate: "Primera fecha disponible",
|
|
2001
|
+
maximumDate: "Última fecha disponible",
|
|
2002
|
+
dateRange: say("{startDate} a {endDate}"),
|
|
2003
|
+
},
|
|
2004
|
+
"et-EE": {
|
|
2005
|
+
previous: "Eelmine",
|
|
2006
|
+
next: "Järgmine",
|
|
2007
|
+
selectedDateDescription: say("Valitud kuupäev: {date}"),
|
|
2008
|
+
selectedRangeDescription: say("Valitud vahemik: {dateRange}"),
|
|
2009
|
+
todayDate: say("Täna, {date}"),
|
|
2010
|
+
todayDateSelected: say("Täna, {date} valitud"),
|
|
2011
|
+
dateSelected: say("{date} valitud"),
|
|
2012
|
+
minimumDate: "Esimene saadaolev kuupäev",
|
|
2013
|
+
maximumDate: "Viimane saadaolev kuupäev",
|
|
2014
|
+
dateRange: say("{startDate} kuni {endDate}"),
|
|
2015
|
+
},
|
|
2016
|
+
"fi-FI": {
|
|
2017
|
+
previous: "Edellinen",
|
|
2018
|
+
next: "Seuraava",
|
|
2019
|
+
selectedDateDescription: say("Valittu päivämäärä: {date}"),
|
|
2020
|
+
selectedRangeDescription: say("Valittu aikaväli: {dateRange}"),
|
|
2021
|
+
todayDate: say("Tänään, {date}"),
|
|
2022
|
+
todayDateSelected: say("Tänään, {date} valittu"),
|
|
2023
|
+
dateSelected: say("{date} valittu"),
|
|
2024
|
+
minimumDate: "Ensimmäinen varattavissa oleva päivämäärä",
|
|
2025
|
+
maximumDate: "Viimeinen varattavissa oleva päivämäärä",
|
|
2026
|
+
dateRange: say("{startDate} – {endDate}"),
|
|
2027
|
+
},
|
|
2028
|
+
"fr-FR": {
|
|
2029
|
+
previous: "Précédent",
|
|
2030
|
+
next: "Suivant",
|
|
2031
|
+
selectedDateDescription: say("Date sélectionnée : {date}"),
|
|
2032
|
+
selectedRangeDescription: say("Plage sélectionnée : {dateRange}"),
|
|
2033
|
+
todayDate: say("Aujourd'hui, {date}"),
|
|
2034
|
+
todayDateSelected: say("Aujourd’hui, {date} sélectionné"),
|
|
2035
|
+
dateSelected: say("{date} sélectionné"),
|
|
2036
|
+
minimumDate: "Première date disponible",
|
|
2037
|
+
maximumDate: "Dernière date disponible",
|
|
2038
|
+
dateRange: say("{startDate} à {endDate}"),
|
|
2039
|
+
},
|
|
2040
|
+
"he-IL": {
|
|
2041
|
+
previous: "הקודם",
|
|
2042
|
+
next: "הבא",
|
|
2043
|
+
selectedDateDescription: say("תאריך נבחר: {date}"),
|
|
2044
|
+
selectedRangeDescription: say("טווח נבחר: {dateRange}"),
|
|
2045
|
+
todayDate: say("היום, {date}"),
|
|
2046
|
+
todayDateSelected: say("היום, {date} נבחר"),
|
|
2047
|
+
dateSelected: say("{date} נבחר"),
|
|
2048
|
+
minimumDate: "תאריך פנוי ראשון",
|
|
2049
|
+
maximumDate: "תאריך פנוי אחרון",
|
|
2050
|
+
dateRange: say("{startDate} עד {endDate}"),
|
|
2051
|
+
},
|
|
2052
|
+
"hr-HR": {
|
|
2053
|
+
previous: "Prethodni",
|
|
2054
|
+
next: "Sljedeći",
|
|
2055
|
+
selectedDateDescription: say("Odabrani datum: {date}"),
|
|
2056
|
+
selectedRangeDescription: say("Odabrani raspon: {dateRange}"),
|
|
2057
|
+
todayDate: say("Danas, {date}"),
|
|
2058
|
+
todayDateSelected: say("Danas, odabran {date}"),
|
|
2059
|
+
dateSelected: say("{date} odabran"),
|
|
2060
|
+
minimumDate: "Prvi raspoloživi datum",
|
|
2061
|
+
maximumDate: "Posljednji raspoloživi datum",
|
|
2062
|
+
dateRange: say("{startDate} do {endDate}"),
|
|
2063
|
+
},
|
|
2064
|
+
"hu-HU": {
|
|
2065
|
+
previous: "Előző",
|
|
2066
|
+
next: "Következő",
|
|
2067
|
+
selectedDateDescription: say("Kijelölt dátum: {date}"),
|
|
2068
|
+
selectedRangeDescription: say("Kijelölt tartomány: {dateRange}"),
|
|
2069
|
+
todayDate: say("Ma, {date}"),
|
|
2070
|
+
todayDateSelected: say("Ma, {date} kijelölve"),
|
|
2071
|
+
dateSelected: say("{date} kiválasztva"),
|
|
2072
|
+
minimumDate: "Az első elérhető dátum",
|
|
2073
|
+
maximumDate: "Utolsó elérhető dátum",
|
|
2074
|
+
dateRange: say("{startDate}–{endDate}"),
|
|
2075
|
+
},
|
|
2076
|
+
"it-IT": {
|
|
2077
|
+
previous: "Precedente",
|
|
2078
|
+
next: "Successivo",
|
|
2079
|
+
selectedDateDescription: say("Data selezionata: {date}"),
|
|
2080
|
+
selectedRangeDescription: say("Intervallo selezionato: {dateRange}"),
|
|
2081
|
+
todayDate: say("Oggi, {date}"),
|
|
2082
|
+
todayDateSelected: say("Oggi, {date} selezionata"),
|
|
2083
|
+
dateSelected: say("{date} selezionata"),
|
|
2084
|
+
minimumDate: "Prima data disponibile",
|
|
2085
|
+
maximumDate: "Ultima data disponibile",
|
|
2086
|
+
dateRange: say("Da {startDate} a {endDate}"),
|
|
2087
|
+
},
|
|
2088
|
+
"ja-JP": {
|
|
2089
|
+
previous: "前へ",
|
|
2090
|
+
next: "次へ",
|
|
2091
|
+
selectedDateDescription: say("選択した日付 : {date}"),
|
|
2092
|
+
selectedRangeDescription: say("選択範囲 : {dateRange}"),
|
|
2093
|
+
todayDate: say("本日、{date}"),
|
|
2094
|
+
todayDateSelected: say("本日、{date} を選択"),
|
|
2095
|
+
dateSelected: say("{date} を選択"),
|
|
2096
|
+
minimumDate: "最初の利用可能日",
|
|
2097
|
+
maximumDate: "最終利用可能日",
|
|
2098
|
+
dateRange: say("{startDate} から {endDate}"),
|
|
2099
|
+
},
|
|
2100
|
+
"ko-KR": {
|
|
2101
|
+
previous: "이전",
|
|
2102
|
+
next: "다음",
|
|
2103
|
+
selectedDateDescription: say("선택 일자: {date}"),
|
|
2104
|
+
selectedRangeDescription: say("선택 범위: {dateRange}"),
|
|
2105
|
+
todayDate: say("오늘, {date}"),
|
|
2106
|
+
todayDateSelected: say("오늘, {date} 선택됨"),
|
|
2107
|
+
dateSelected: say("{date} 선택됨"),
|
|
2108
|
+
minimumDate: "처음으로 사용 가능한 일자",
|
|
2109
|
+
maximumDate: "마지막으로 사용 가능한 일자",
|
|
2110
|
+
dateRange: say("{startDate} ~ {endDate}"),
|
|
2111
|
+
},
|
|
2112
|
+
"lt-LT": {
|
|
2113
|
+
previous: "Ankstesnis",
|
|
2114
|
+
next: "Paskesnis",
|
|
2115
|
+
selectedDateDescription: say("Pasirinkta data: {date}"),
|
|
2116
|
+
selectedRangeDescription: say("Pasirinktas intervalas: {dateRange}"),
|
|
2117
|
+
todayDate: say("Šiandien, {date}"),
|
|
2118
|
+
todayDateSelected: say("Šiandien, pasirinkta {date}"),
|
|
2119
|
+
dateSelected: say("Pasirinkta {date}"),
|
|
2120
|
+
minimumDate: "Pirmoji galima data",
|
|
2121
|
+
maximumDate: "Paskutinė galima data",
|
|
2122
|
+
dateRange: say("Nuo {startDate} iki {endDate}"),
|
|
2123
|
+
},
|
|
2124
|
+
"lv-LV": {
|
|
2125
|
+
previous: "Atpakaļ",
|
|
2126
|
+
next: "Tālāk",
|
|
2127
|
+
selectedDateDescription: say("Atlasītais datums: {date}"),
|
|
2128
|
+
selectedRangeDescription: say("Atlasītais diapazons: {dateRange}"),
|
|
2129
|
+
todayDate: say("Šodien, {date}"),
|
|
2130
|
+
todayDateSelected: say("Atlasīta šodiena, {date}"),
|
|
2131
|
+
dateSelected: say("Atlasīts: {date}"),
|
|
2132
|
+
minimumDate: "Pirmais pieejamais datums",
|
|
2133
|
+
maximumDate: "Pēdējais pieejamais datums",
|
|
2134
|
+
dateRange: say("No {startDate} līdz {endDate}"),
|
|
2135
|
+
},
|
|
2136
|
+
"nb-NO": {
|
|
2137
|
+
previous: "Forrige",
|
|
2138
|
+
next: "Neste",
|
|
2139
|
+
selectedDateDescription: say("Valgt dato: {date}"),
|
|
2140
|
+
selectedRangeDescription: say("Valgt område: {dateRange}"),
|
|
2141
|
+
todayDate: say("I dag, {date}"),
|
|
2142
|
+
todayDateSelected: say("I dag, {date} valgt"),
|
|
2143
|
+
dateSelected: say("{date} valgt"),
|
|
2144
|
+
minimumDate: "Første tilgjengelige dato",
|
|
2145
|
+
maximumDate: "Siste tilgjengelige dato",
|
|
2146
|
+
dateRange: say("{startDate} til {endDate}"),
|
|
2147
|
+
},
|
|
2148
|
+
"nl-NL": {
|
|
2149
|
+
previous: "Vorige",
|
|
2150
|
+
next: "Volgende",
|
|
2151
|
+
selectedDateDescription: say("Geselecteerde datum: {date}"),
|
|
2152
|
+
selectedRangeDescription: say("Geselecteerd bereik: {dateRange}"),
|
|
2153
|
+
todayDate: say("Vandaag, {date}"),
|
|
2154
|
+
todayDateSelected: say("Vandaag, {date} geselecteerd"),
|
|
2155
|
+
dateSelected: say("{date} geselecteerd"),
|
|
2156
|
+
minimumDate: "Eerste beschikbare datum",
|
|
2157
|
+
maximumDate: "Laatste beschikbare datum",
|
|
2158
|
+
dateRange: say("{startDate} tot {endDate}"),
|
|
2159
|
+
},
|
|
2160
|
+
"pl-PL": {
|
|
2161
|
+
previous: "Wstecz",
|
|
2162
|
+
next: "Dalej",
|
|
2163
|
+
selectedDateDescription: say("Wybrana data: {date}"),
|
|
2164
|
+
selectedRangeDescription: say("Wybrany zakres: {dateRange}"),
|
|
2165
|
+
todayDate: say("Dzisiaj, {date}"),
|
|
2166
|
+
todayDateSelected: say("Dzisiaj wybrano {date}"),
|
|
2167
|
+
dateSelected: say("Wybrano {date}"),
|
|
2168
|
+
minimumDate: "Pierwsza dostępna data",
|
|
2169
|
+
maximumDate: "Ostatnia dostępna data",
|
|
2170
|
+
dateRange: say("{startDate} do {endDate}"),
|
|
2171
|
+
},
|
|
2172
|
+
"pt-BR": {
|
|
2173
|
+
previous: "Anterior",
|
|
2174
|
+
next: "Próximo",
|
|
2175
|
+
selectedDateDescription: say("Data selecionada: {date}"),
|
|
2176
|
+
selectedRangeDescription: say("Intervalo selecionado: {dateRange}"),
|
|
2177
|
+
todayDate: say("Hoje, {date}"),
|
|
2178
|
+
todayDateSelected: say("Hoje, {date} selecionado"),
|
|
2179
|
+
dateSelected: say("{date} selecionado"),
|
|
2180
|
+
minimumDate: "Primeira data disponível",
|
|
2181
|
+
maximumDate: "Última data disponível",
|
|
2182
|
+
dateRange: say("{startDate} a {endDate}"),
|
|
2183
|
+
},
|
|
2184
|
+
"pt-PT": {
|
|
2185
|
+
previous: "Anterior",
|
|
2186
|
+
next: "Próximo",
|
|
2187
|
+
selectedDateDescription: say("Data selecionada: {date}"),
|
|
2188
|
+
selectedRangeDescription: say("Intervalo selecionado: {dateRange}"),
|
|
2189
|
+
todayDate: say("Hoje, {date}"),
|
|
2190
|
+
todayDateSelected: say("Hoje, {date} selecionado"),
|
|
2191
|
+
dateSelected: say("{date} selecionado"),
|
|
2192
|
+
minimumDate: "Primeira data disponível",
|
|
2193
|
+
maximumDate: "Última data disponível",
|
|
2194
|
+
dateRange: say("{startDate} a {endDate}"),
|
|
2195
|
+
},
|
|
2196
|
+
"ro-RO": {
|
|
2197
|
+
previous: "Înainte",
|
|
2198
|
+
next: "Următorul",
|
|
2199
|
+
selectedDateDescription: say("Dată selectată: {date}"),
|
|
2200
|
+
selectedRangeDescription: say("Interval selectat: {dateRange}"),
|
|
2201
|
+
todayDate: say("Astăzi, {date}"),
|
|
2202
|
+
todayDateSelected: say("Azi, {date} selectată"),
|
|
2203
|
+
dateSelected: say("{date} selectată"),
|
|
2204
|
+
minimumDate: "Prima dată disponibilă",
|
|
2205
|
+
maximumDate: "Ultima dată disponibilă",
|
|
2206
|
+
dateRange: say("De la {startDate} până la {endDate}"),
|
|
2207
|
+
},
|
|
2208
|
+
"ru-RU": {
|
|
2209
|
+
previous: "Назад",
|
|
2210
|
+
next: "Далее",
|
|
2211
|
+
selectedDateDescription: say("Выбранная дата: {date}"),
|
|
2212
|
+
selectedRangeDescription: say("Выбранный диапазон: {dateRange}"),
|
|
2213
|
+
todayDate: say("Сегодня, {date}"),
|
|
2214
|
+
todayDateSelected: say("Сегодня, выбрано {date}"),
|
|
2215
|
+
dateSelected: say("Выбрано {date}"),
|
|
2216
|
+
minimumDate: "Первая доступная дата",
|
|
2217
|
+
maximumDate: "Последняя доступная дата",
|
|
2218
|
+
dateRange: say("С {startDate} по {endDate}"),
|
|
2219
|
+
},
|
|
2220
|
+
"sk-SK": {
|
|
2221
|
+
previous: "Predchádzajúce",
|
|
2222
|
+
next: "Nasledujúce",
|
|
2223
|
+
selectedDateDescription: say("Vybratý dátum: {date}"),
|
|
2224
|
+
selectedRangeDescription: say("Vybratý rozsah: {dateRange}"),
|
|
2225
|
+
todayDate: say("Dnes {date}"),
|
|
2226
|
+
todayDateSelected: say("Vybratý dnešný dátum {date}"),
|
|
2227
|
+
dateSelected: say("Vybratý dátum {date}"),
|
|
2228
|
+
minimumDate: "Prvý dostupný dátum",
|
|
2229
|
+
maximumDate: "Posledný dostupný dátum",
|
|
2230
|
+
dateRange: say("Od {startDate} do {endDate}"),
|
|
2231
|
+
},
|
|
2232
|
+
"sl-SI": {
|
|
2233
|
+
previous: "Nazaj",
|
|
2234
|
+
next: "Naprej",
|
|
2235
|
+
selectedDateDescription: say("Izbrani datum: {date}"),
|
|
2236
|
+
selectedRangeDescription: say("Izbrano območje: {dateRange}"),
|
|
2237
|
+
todayDate: say("Danes, {date}"),
|
|
2238
|
+
todayDateSelected: say("Danes, {date} izbrano"),
|
|
2239
|
+
dateSelected: say("{date} izbrano"),
|
|
2240
|
+
minimumDate: "Prvi razpoložljivi datum",
|
|
2241
|
+
maximumDate: "Zadnji razpoložljivi datum",
|
|
2242
|
+
dateRange: say("{startDate} do {endDate}"),
|
|
2243
|
+
},
|
|
2244
|
+
"sr-SP": {
|
|
2245
|
+
previous: "Prethodni",
|
|
2246
|
+
next: "Sledeći",
|
|
2247
|
+
selectedDateDescription: say("Izabrani datum: {date}"),
|
|
2248
|
+
selectedRangeDescription: say("Izabrani period: {dateRange}"),
|
|
2249
|
+
todayDate: say("Danas, {date}"),
|
|
2250
|
+
todayDateSelected: say("Danas, izabran {date}"),
|
|
2251
|
+
dateSelected: say("{date} izabran"),
|
|
2252
|
+
minimumDate: "Prvi raspoloživi datum",
|
|
2253
|
+
maximumDate: "Zadnji raspoloživi datum",
|
|
2254
|
+
dateRange: say("{startDate} do {endDate}"),
|
|
2255
|
+
},
|
|
2256
|
+
"sv-SE": {
|
|
2257
|
+
previous: "Föregående",
|
|
2258
|
+
next: "Nästa",
|
|
2259
|
+
selectedDateDescription: say("Valt datum: {date}"),
|
|
2260
|
+
selectedRangeDescription: say("Valt intervall: {dateRange}"),
|
|
2261
|
+
todayDate: say("Idag, {date}"),
|
|
2262
|
+
todayDateSelected: say("Idag, {date} har valts"),
|
|
2263
|
+
dateSelected: say("{date} har valts"),
|
|
2264
|
+
minimumDate: "Första tillgängliga datum",
|
|
2265
|
+
maximumDate: "Sista tillgängliga datum",
|
|
2266
|
+
dateRange: say("{startDate} till {endDate}"),
|
|
2267
|
+
},
|
|
2268
|
+
"tr-TR": {
|
|
2269
|
+
previous: "Önceki",
|
|
2270
|
+
next: "Sonraki",
|
|
2271
|
+
selectedDateDescription: say("Seçilen Tarih: {date}"),
|
|
2272
|
+
selectedRangeDescription: say("Seçilen Aralık: {dateRange}"),
|
|
2273
|
+
todayDate: say("Bugün, {date}"),
|
|
2274
|
+
todayDateSelected: say("Bugün, {date} seçildi"),
|
|
2275
|
+
dateSelected: say("{date} seçildi"),
|
|
2276
|
+
minimumDate: "İlk müsait tarih",
|
|
2277
|
+
maximumDate: "Son müsait tarih",
|
|
2278
|
+
dateRange: say("{startDate} - {endDate}"),
|
|
2279
|
+
},
|
|
2280
|
+
"uk-UA": {
|
|
2281
|
+
previous: "Попередній",
|
|
2282
|
+
next: "Наступний",
|
|
2283
|
+
selectedDateDescription: say("Вибрана дата: {date}"),
|
|
2284
|
+
selectedRangeDescription: say("Вибраний діапазон: {dateRange}"),
|
|
2285
|
+
todayDate: say("Сьогодні, {date}"),
|
|
2286
|
+
todayDateSelected: say("Сьогодні, вибрано {date}"),
|
|
2287
|
+
dateSelected: say("Вибрано {date}"),
|
|
2288
|
+
minimumDate: "Перша доступна дата",
|
|
2289
|
+
maximumDate: "Остання доступна дата",
|
|
2290
|
+
dateRange: say("{startDate} — {endDate}"),
|
|
2291
|
+
},
|
|
2292
|
+
"zh-CN": {
|
|
2293
|
+
previous: "上一页",
|
|
2294
|
+
next: "下一页",
|
|
2295
|
+
selectedDateDescription: say("选定的日期:{date}"),
|
|
2296
|
+
selectedRangeDescription: say("选定的范围:{dateRange}"),
|
|
2297
|
+
todayDate: say("今天,即 {date}"),
|
|
2298
|
+
todayDateSelected: say("已选择今天,即 {date}"),
|
|
2299
|
+
dateSelected: say("已选择 {date}"),
|
|
2300
|
+
minimumDate: "第一个可用日期",
|
|
2301
|
+
maximumDate: "最后一个可用日期",
|
|
2302
|
+
dateRange: say("{startDate} 至 {endDate}"),
|
|
2303
|
+
},
|
|
2304
|
+
"zh-TW": {
|
|
2305
|
+
previous: "上一頁",
|
|
2306
|
+
next: "下一頁",
|
|
2307
|
+
selectedDateDescription: say("選定的日期:{date}"),
|
|
2308
|
+
selectedRangeDescription: say("選定的範圍:{dateRange}"),
|
|
2309
|
+
todayDate: say("今天,{date}"),
|
|
2310
|
+
todayDateSelected: say("已選取今天,{date}"),
|
|
2311
|
+
dateSelected: say("已選取 {date}"),
|
|
2312
|
+
minimumDate: "第一個可用日期",
|
|
2313
|
+
maximumDate: "最後一個可用日期",
|
|
2314
|
+
dateRange: say("{startDate} 至 {endDate}"),
|
|
2315
|
+
},
|
|
2316
|
+
});
|