@barqjs/aria 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +304 -2
- package/package.json +437 -4
- package/src/autocomplete.tsx +581 -0
- package/src/breadcrumbs.tsx +297 -0
- package/src/button.tsx +468 -0
- package/src/calendar.tsx +2316 -0
- package/src/checkbox.tsx +732 -0
- package/src/collections.ts +1059 -0
- package/src/color.ts +2119 -0
- package/src/colorpicker.tsx +2023 -0
- package/src/colorswatchpicker.tsx +240 -0
- package/src/combobox.tsx +3003 -0
- package/src/command.tsx +1203 -0
- package/src/date.ts +674 -0
- package/src/datefield.tsx +2066 -0
- package/src/datepicker.tsx +907 -0
- package/src/dialog.tsx +1077 -0
- package/src/disclosure.tsx +711 -0
- 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 +703 -0
- package/src/drag-and-drop.tsx +669 -0
- package/src/drawer.ts +674 -0
- package/src/dropzone.tsx +208 -0
- package/src/file-trigger.tsx +103 -0
- package/src/focus.ts +1370 -0
- package/src/form.tsx +94 -0
- package/src/gridlist.tsx +1354 -0
- package/src/group.tsx +146 -0
- package/src/i18n.ts +823 -0
- package/src/index.ts +1672 -0
- package/src/interactions/description.ts +73 -0
- package/src/interactions/flags.ts +35 -0
- package/src/interactions/focus-events.ts +226 -0
- package/src/interactions/focusable.ts +86 -0
- package/src/interactions/hover.ts +213 -0
- package/src/interactions/interact-outside.ts +123 -0
- package/src/interactions/keyboard.ts +298 -0
- package/src/interactions/listeners.ts +78 -0
- package/src/interactions/long-press.ts +160 -0
- package/src/interactions/modality.ts +428 -0
- package/src/interactions/move.ts +257 -0
- package/src/interactions/open-link.ts +226 -0
- package/src/interactions/press.ts +915 -0
- package/src/interactions/prevent-focus.ts +102 -0
- package/src/interactions/scroll-wheel.ts +43 -0
- package/src/interactions/text-selection.ts +77 -0
- package/src/interactions.ts +81 -0
- package/src/label.ts +140 -0
- package/src/link.tsx +477 -0
- package/src/listbox.tsx +1247 -0
- package/src/live.ts +208 -0
- package/src/menu.tsx +2383 -0
- package/src/menubar.tsx +579 -0
- package/src/navigation-tree.tsx +357 -0
- package/src/navigation.ts +735 -0
- package/src/numberfield.tsx +942 -0
- package/src/otp.ts +430 -0
- package/src/overlay-arrow.tsx +157 -0
- package/src/overlays.ts +1549 -0
- package/src/platform.ts +75 -0
- package/src/presence.ts +164 -0
- package/src/preview-trigger.tsx +582 -0
- package/src/progress-bar-context.ts +15 -0
- package/src/questionnaire.tsx +1717 -0
- package/src/radio.tsx +641 -0
- package/src/register-dom.ts +12 -0
- package/src/scroller.ts +1165 -0
- package/src/select.tsx +1745 -0
- package/src/selection-indicator.tsx +74 -0
- package/src/selection.ts +1472 -0
- package/src/shared-element-transition.tsx +316 -0
- package/src/sheet.tsx +1461 -0
- package/src/slider.tsx +1137 -0
- package/src/splitter.ts +1152 -0
- package/src/static-collection.ts +211 -0
- package/src/switch.tsx +212 -0
- package/src/table.tsx +2218 -0
- package/src/tabs.tsx +1127 -0
- package/src/tag.tsx +637 -0
- package/src/textarea.tsx +186 -0
- package/src/textfield.tsx +483 -0
- package/src/toast-components.tsx +589 -0
- package/src/toast.ts +658 -0
- package/src/toggle-button-group.tsx +175 -0
- package/src/toggle-input.tsx +86 -0
- package/src/toggle.ts +384 -0
- package/src/togglegroup.ts +365 -0
- package/src/tokenfield.tsx +1673 -0
- package/src/toolbar.tsx +184 -0
- package/src/tooltip.tsx +674 -0
- package/src/tree.tsx +2075 -0
- package/src/utils.ts +787 -0
- package/src/validation.ts +504 -0
- package/src/virtualizer.tsx +837 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A date picker: a date field, and a calendar behind a button.
|
|
3
|
+
*
|
|
4
|
+
* Both halves matter and neither is optional. The field is how anyone who
|
|
5
|
+
* knows the date enters it — typing 03072024 is three seconds and reaching
|
|
6
|
+
* into a calendar for a date six months out is thirty. The calendar is how
|
|
7
|
+
* anyone who is choosing rather than recalling does it, and it is the only way
|
|
8
|
+
* to see which days are available.
|
|
9
|
+
*
|
|
10
|
+
* So the field is the control, and the calendar is a popover the button opens:
|
|
11
|
+
*
|
|
12
|
+
* - **The button is not a Tab stop of its own** in the sense that matters: it
|
|
13
|
+
* is one, but it sits after the segments, so tabbing through a form goes
|
|
14
|
+
* month, day, year, calendar, next field.
|
|
15
|
+
* - **Choosing a date closes the popover** and puts the value in the field,
|
|
16
|
+
* because the calendar exists to answer one question.
|
|
17
|
+
* - **`aria-haspopup="dialog"`,** not `menu` or `listbox`: what opens is a
|
|
18
|
+
* dialog holding a grid, and saying otherwise makes a screen reader promise
|
|
19
|
+
* the wrong keys.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
cells,
|
|
24
|
+
type Accessor,
|
|
25
|
+
type Child,
|
|
26
|
+
createContext,
|
|
27
|
+
getContext,
|
|
28
|
+
getOwner,
|
|
29
|
+
install,
|
|
30
|
+
} from "@barqjs/core";
|
|
31
|
+
import { ref as makeRef, mergeRefs, type RefTarget } from "@barqjs/primitives/refs";
|
|
32
|
+
import { button } from "./button.tsx";
|
|
33
|
+
import { Calendar, RangeCalendar, type DateRange } from "./calendar.tsx";
|
|
34
|
+
import { CalendarDate, CalendarDateTime, toCalendarDate, today, type DateValue } from "./date.ts";
|
|
35
|
+
import { StringDictionary, stringFormatter } from "./i18n.ts";
|
|
36
|
+
import { Popover } from "./dialog.tsx";
|
|
37
|
+
import { focusRing } from "./focus.ts";
|
|
38
|
+
import { hover } from "./interactions/hover.ts";
|
|
39
|
+
import type { ElementRef } from "./interactions/press.ts";
|
|
40
|
+
import { field, type FieldOptions } from "./label.ts";
|
|
41
|
+
import {
|
|
42
|
+
fieldValidation,
|
|
43
|
+
type ValidateFunction,
|
|
44
|
+
type ValidationBehavior,
|
|
45
|
+
type ValidationResult,
|
|
46
|
+
} from "./validation.ts";
|
|
47
|
+
import {
|
|
48
|
+
overlayTriggerState,
|
|
49
|
+
type OverlayTriggerState,
|
|
50
|
+
type OverlayTriggerStateOptions,
|
|
51
|
+
type Placement,
|
|
52
|
+
} from "./overlays.ts";
|
|
53
|
+
import { DateField, type Granularity } from "./datefield.tsx";
|
|
54
|
+
import {
|
|
55
|
+
access,
|
|
56
|
+
callback,
|
|
57
|
+
controllable,
|
|
58
|
+
type DOMProps,
|
|
59
|
+
filterDOMProps,
|
|
60
|
+
fromProps,
|
|
61
|
+
id,
|
|
62
|
+
type MaybeAccessor,
|
|
63
|
+
mergeProps,
|
|
64
|
+
type StyleProps,
|
|
65
|
+
styleProps,
|
|
66
|
+
} from "./utils.ts";
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// State
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
export interface DatePickerStateOptions extends OverlayTriggerStateOptions {
|
|
73
|
+
value?: MaybeAccessor<DateValue | null | undefined>;
|
|
74
|
+
defaultValue?: MaybeAccessor<DateValue | null | undefined>;
|
|
75
|
+
minValue?: MaybeAccessor<DateValue | null | undefined>;
|
|
76
|
+
maxValue?: MaybeAccessor<DateValue | null | undefined>;
|
|
77
|
+
/** @default "day" */
|
|
78
|
+
granularity?: MaybeAccessor<Granularity | undefined>;
|
|
79
|
+
isDisabled?: MaybeAccessor<boolean | undefined>;
|
|
80
|
+
isReadOnly?: MaybeAccessor<boolean | undefined>;
|
|
81
|
+
onChange?: (value: DateValue | null) => void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface DatePickerState extends OverlayTriggerState {
|
|
85
|
+
value: Accessor<DateValue | null>;
|
|
86
|
+
setValue(value: DateValue | null): void;
|
|
87
|
+
/** The day part, for the calendar, which knows nothing about time. */
|
|
88
|
+
dateValue: Accessor<CalendarDate | null>;
|
|
89
|
+
setDateValue(date: CalendarDate | null): void;
|
|
90
|
+
granularity: Accessor<Granularity>;
|
|
91
|
+
isDisabled: Accessor<boolean>;
|
|
92
|
+
isReadOnly: Accessor<boolean>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function datePickerState(options: DatePickerStateOptions): DatePickerState {
|
|
96
|
+
const overlay = overlayTriggerState(options);
|
|
97
|
+
|
|
98
|
+
const [value, setValue] = controllable<DateValue | null>(
|
|
99
|
+
() => access(options.value),
|
|
100
|
+
() => access(options.defaultValue) ?? null,
|
|
101
|
+
options.onChange,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const granularity = (): Granularity => access(options.granularity) ?? "day";
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
...overlay,
|
|
108
|
+
value,
|
|
109
|
+
setValue,
|
|
110
|
+
granularity,
|
|
111
|
+
isDisabled: () => access(options.isDisabled) === true,
|
|
112
|
+
isReadOnly: () => access(options.isReadOnly) === true,
|
|
113
|
+
dateValue: () => {
|
|
114
|
+
const current = value();
|
|
115
|
+
return current === null ? null : toCalendarDate(current);
|
|
116
|
+
},
|
|
117
|
+
setDateValue: (date) => {
|
|
118
|
+
if (date === null) {
|
|
119
|
+
setValue(null);
|
|
120
|
+
overlay.close();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// The time the field already holds is KEPT: choosing a day in the
|
|
124
|
+
// calendar is choosing a day, not resetting the meeting to midnight.
|
|
125
|
+
const current = value();
|
|
126
|
+
const next =
|
|
127
|
+
granularity() === "day"
|
|
128
|
+
? date
|
|
129
|
+
: CalendarDateTime.from(
|
|
130
|
+
date,
|
|
131
|
+
current instanceof CalendarDateTime ? current.time : undefined,
|
|
132
|
+
);
|
|
133
|
+
setValue(next);
|
|
134
|
+
overlay.close();
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Hooks
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
|
|
143
|
+
export interface DatePickerOptions extends FieldOptions {
|
|
144
|
+
ref: ElementRef;
|
|
145
|
+
isDisabled?: MaybeAccessor<boolean | undefined>;
|
|
146
|
+
isReadOnly?: MaybeAccessor<boolean | undefined>;
|
|
147
|
+
isRequired?: MaybeAccessor<boolean | undefined>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface DatePickerResult {
|
|
151
|
+
labelProps: DOMProps;
|
|
152
|
+
/** For the element holding the field and the button. */
|
|
153
|
+
groupProps: DOMProps;
|
|
154
|
+
fieldProps: DOMProps;
|
|
155
|
+
/** Options for {@link button}, not props for an element. */
|
|
156
|
+
buttonProps: DOMProps;
|
|
157
|
+
dialogProps: DOMProps;
|
|
158
|
+
calendarProps: DOMProps;
|
|
159
|
+
descriptionProps: DOMProps;
|
|
160
|
+
errorMessageProps: DOMProps;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function datePicker(options: DatePickerOptions, state: DatePickerState): DatePickerResult {
|
|
164
|
+
const groupId = id();
|
|
165
|
+
const buttonId = id();
|
|
166
|
+
const dialogId = id();
|
|
167
|
+
const messages = stringFormatter(PICKER_STRINGS);
|
|
168
|
+
|
|
169
|
+
const {
|
|
170
|
+
labelProps,
|
|
171
|
+
fieldProps: labelledProps,
|
|
172
|
+
descriptionProps,
|
|
173
|
+
errorMessageProps,
|
|
174
|
+
} = field({ ...options, labelElementType: "span" });
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
descriptionProps,
|
|
178
|
+
errorMessageProps,
|
|
179
|
+
labelProps: mergeProps(labelProps, {
|
|
180
|
+
// A `<span>` label cannot wrap the control, so clicking it has to move
|
|
181
|
+
// focus by hand — to the first SEGMENT, which is where typing goes.
|
|
182
|
+
onClick: () => {
|
|
183
|
+
if (state.isDisabled()) return;
|
|
184
|
+
const group = access(options.ref) as HTMLElement | null;
|
|
185
|
+
group?.querySelector<HTMLElement>('[role="spinbutton"]')?.focus();
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
groupProps: mergeProps(filterDOMProps(options, { labelable: true }), labelledProps, {
|
|
189
|
+
role: "group",
|
|
190
|
+
id: groupId,
|
|
191
|
+
"aria-disabled": () => state.isDisabled() || undefined,
|
|
192
|
+
onKeyDown: (event: KeyboardEvent) =>
|
|
193
|
+
opensOnAltArrow(event, state, state.isDisabled() || state.isReadOnly()),
|
|
194
|
+
}),
|
|
195
|
+
fieldProps: {
|
|
196
|
+
"aria-labelledby": () => access(labelProps.id as MaybeAccessor<string | undefined>),
|
|
197
|
+
},
|
|
198
|
+
buttonProps: {
|
|
199
|
+
id: buttonId,
|
|
200
|
+
// What opens is a dialog holding a grid. `menu` would promise the arrow
|
|
201
|
+
// keys move between menu items.
|
|
202
|
+
"aria-haspopup": "dialog",
|
|
203
|
+
"aria-expanded": () => state.isOpen(),
|
|
204
|
+
"aria-controls": () => (state.isOpen() ? dialogId() : undefined),
|
|
205
|
+
// Named by ITSELF and by the field, so it is announced as "Calendar,
|
|
206
|
+
// Departure" rather than as one of a page of identical buttons.
|
|
207
|
+
"aria-label": () => messages().format("calendar"),
|
|
208
|
+
"aria-labelledby": () =>
|
|
209
|
+
`${buttonId()} ${access(labelProps.id as MaybeAccessor<string | undefined>) ?? groupId()}`,
|
|
210
|
+
isDisabled: () => state.isDisabled() || state.isReadOnly(),
|
|
211
|
+
onPress: () => state.toggle(),
|
|
212
|
+
},
|
|
213
|
+
dialogProps: {
|
|
214
|
+
id: dialogId,
|
|
215
|
+
role: "dialog",
|
|
216
|
+
"aria-labelledby": () =>
|
|
217
|
+
access(labelProps.id as MaybeAccessor<string | undefined>) ?? groupId(),
|
|
218
|
+
},
|
|
219
|
+
calendarProps: {
|
|
220
|
+
"aria-label": () => messages().format("calendar"),
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Alt with an arrow opens the calendar, from anywhere in the field.
|
|
227
|
+
*
|
|
228
|
+
* The segments leave a modified arrow alone, so it reaches the group whichever
|
|
229
|
+
* segment holds focus.
|
|
230
|
+
*/
|
|
231
|
+
function opensOnAltArrow(
|
|
232
|
+
event: KeyboardEvent,
|
|
233
|
+
overlay: Pick<OverlayTriggerState, "isOpen" | "setOpen">,
|
|
234
|
+
isBlocked = false,
|
|
235
|
+
): void {
|
|
236
|
+
if (!event.altKey || (event.key !== "ArrowDown" && event.key !== "ArrowUp")) return;
|
|
237
|
+
if (isBlocked || overlay.isOpen()) return;
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
event.stopPropagation();
|
|
240
|
+
overlay.setOpen(true);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
// Components
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
|
|
247
|
+
interface DatePickerContextValue {
|
|
248
|
+
state: DatePickerState;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const DatePickerContext = createContext<DatePickerContextValue | null>(null);
|
|
252
|
+
|
|
253
|
+
export function useDatePicker(): DatePickerContextValue {
|
|
254
|
+
const value = getContext(DatePickerContext);
|
|
255
|
+
if (value === null || value === undefined) {
|
|
256
|
+
throw new Error("This must be rendered inside a DatePicker.");
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface DatePickerComponentProps extends StyleProps {
|
|
262
|
+
label?: Child;
|
|
263
|
+
description?: Child;
|
|
264
|
+
errorMessage?: Child;
|
|
265
|
+
value?: DateValue | null;
|
|
266
|
+
defaultValue?: DateValue | null;
|
|
267
|
+
placeholderValue?: DateValue;
|
|
268
|
+
minValue?: DateValue | null;
|
|
269
|
+
maxValue?: DateValue | null;
|
|
270
|
+
isDateUnavailable?: (date: CalendarDate) => boolean;
|
|
271
|
+
/** @default "day" */
|
|
272
|
+
granularity?: Granularity;
|
|
273
|
+
hourCycle?: 12 | 24;
|
|
274
|
+
isDisabled?: boolean;
|
|
275
|
+
isReadOnly?: boolean;
|
|
276
|
+
isRequired?: boolean;
|
|
277
|
+
isInvalid?: boolean;
|
|
278
|
+
/** What the page thinks of the date, checked as it changes. */
|
|
279
|
+
validate?: ValidateFunction<DateValue | null>;
|
|
280
|
+
/** @default "aria" */
|
|
281
|
+
validationBehavior?: ValidationBehavior;
|
|
282
|
+
isOpen?: boolean;
|
|
283
|
+
defaultOpen?: boolean;
|
|
284
|
+
name?: string;
|
|
285
|
+
/** @default "bottom start" */
|
|
286
|
+
placement?: Placement;
|
|
287
|
+
"aria-label"?: string;
|
|
288
|
+
"aria-labelledby"?: string;
|
|
289
|
+
ref?: RefTarget<HTMLDivElement>;
|
|
290
|
+
onChange?: (value: DateValue | null) => void;
|
|
291
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* ```tsx
|
|
296
|
+
* <DatePicker label="Departure" value={date()} onChange={date.set} minValue={today()} />
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export function DatePicker(props: DatePickerComponentProps) {
|
|
300
|
+
const groupRef = makeRef<HTMLDivElement>();
|
|
301
|
+
const triggerRef = makeRef<HTMLButtonElement>();
|
|
302
|
+
|
|
303
|
+
const state = datePickerState({
|
|
304
|
+
value: () => props.value,
|
|
305
|
+
defaultValue: () => props.defaultValue,
|
|
306
|
+
minValue: () => props.minValue,
|
|
307
|
+
maxValue: () => props.maxValue,
|
|
308
|
+
granularity: () => props.granularity,
|
|
309
|
+
isDisabled: () => props.isDisabled,
|
|
310
|
+
isReadOnly: () => props.isReadOnly,
|
|
311
|
+
isOpen: () => props.isOpen,
|
|
312
|
+
defaultOpen: () => props.defaultOpen,
|
|
313
|
+
onChange: (value) => props.onChange?.(value),
|
|
314
|
+
onOpenChange: (isOpen) => props.onOpenChange?.(isOpen),
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const {
|
|
318
|
+
labelProps,
|
|
319
|
+
groupProps,
|
|
320
|
+
buttonProps,
|
|
321
|
+
dialogProps,
|
|
322
|
+
calendarProps,
|
|
323
|
+
descriptionProps,
|
|
324
|
+
errorMessageProps,
|
|
325
|
+
} = datePicker(
|
|
326
|
+
{
|
|
327
|
+
ref: groupRef,
|
|
328
|
+
label: () => props.label,
|
|
329
|
+
description: () => props.description,
|
|
330
|
+
errorMessage: () => props.errorMessage,
|
|
331
|
+
isDisabled: () => props.isDisabled,
|
|
332
|
+
isReadOnly: () => props.isReadOnly,
|
|
333
|
+
isRequired: () => props.isRequired,
|
|
334
|
+
isInvalid: () => props.isInvalid,
|
|
335
|
+
"aria-label": () => props["aria-label"],
|
|
336
|
+
"aria-labelledby": () => props["aria-labelledby"],
|
|
337
|
+
},
|
|
338
|
+
state,
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
const trigger = button(buttonProps, triggerRef);
|
|
342
|
+
const { hoverProps, isHovered } = hover({ isDisabled: () => props.isDisabled });
|
|
343
|
+
const { focusProps, isFocusVisible } = focusRing();
|
|
344
|
+
|
|
345
|
+
const owner = getOwner();
|
|
346
|
+
if (owner !== null) install(owner, DatePickerContext, () => ({ state }));
|
|
347
|
+
|
|
348
|
+
const elementProps = mergeProps(
|
|
349
|
+
groupProps,
|
|
350
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
351
|
+
styleProps(cells(props)),
|
|
352
|
+
{
|
|
353
|
+
"data-open": state.isOpen,
|
|
354
|
+
"data-disabled": () => props.isDisabled === true,
|
|
355
|
+
"data-testid": () => props["data-testid"],
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const triggerElementProps = mergeProps(trigger.buttonProps, hoverProps, focusProps, {
|
|
360
|
+
id: buttonProps.id,
|
|
361
|
+
"data-hovered": isHovered,
|
|
362
|
+
"data-focus-visible": isFocusVisible,
|
|
363
|
+
"data-pressed": trigger.isPressed,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
return (
|
|
367
|
+
<>
|
|
368
|
+
<span {...labelProps}>{props.label}</span>
|
|
369
|
+
<div {...elementProps} ref={mergeRefs(groupRef.set, props.ref)}>
|
|
370
|
+
{/* Not labelled again: the group around it already carries the
|
|
371
|
+
label, and naming both makes a screen reader say "Departure
|
|
372
|
+
group, Departure group". The segments name themselves. */}
|
|
373
|
+
<DateField
|
|
374
|
+
value={state.value()}
|
|
375
|
+
placeholderValue={props.placeholderValue}
|
|
376
|
+
minValue={props.minValue}
|
|
377
|
+
maxValue={props.maxValue}
|
|
378
|
+
isDateUnavailable={callback<[CalendarDate], boolean>(cells(props).isDateUnavailable)}
|
|
379
|
+
granularity={props.granularity}
|
|
380
|
+
hourCycle={props.hourCycle}
|
|
381
|
+
isDisabled={props.isDisabled}
|
|
382
|
+
isReadOnly={props.isReadOnly}
|
|
383
|
+
isRequired={props.isRequired}
|
|
384
|
+
isInvalid={props.isInvalid}
|
|
385
|
+
validate={callback<[DateValue | null], string | string[] | true | null | undefined>(
|
|
386
|
+
cells(props).validate,
|
|
387
|
+
)}
|
|
388
|
+
validationBehavior={props.validationBehavior}
|
|
389
|
+
name={props.name}
|
|
390
|
+
onChange={(value) => state.setValue(value)}
|
|
391
|
+
/>
|
|
392
|
+
<button {...triggerElementProps} type="button" ref={triggerRef.set}>
|
|
393
|
+
<span aria-hidden="true">📅</span>
|
|
394
|
+
</button>
|
|
395
|
+
</div>
|
|
396
|
+
<Popover
|
|
397
|
+
triggerRef={triggerRef}
|
|
398
|
+
isOpen={state.isOpen()}
|
|
399
|
+
onOpenChange={state.setOpen}
|
|
400
|
+
placement={props.placement ?? "bottom start"}
|
|
401
|
+
>
|
|
402
|
+
<div {...dialogProps}>
|
|
403
|
+
<Calendar
|
|
404
|
+
aria-label={access(calendarProps["aria-label"] as MaybeAccessor<string>)}
|
|
405
|
+
value={state.dateValue()}
|
|
406
|
+
defaultFocusedValue={
|
|
407
|
+
state.dateValue() ?? toCalendarDate(props.placeholderValue ?? today())
|
|
408
|
+
}
|
|
409
|
+
minValue={props.minValue}
|
|
410
|
+
maxValue={props.maxValue}
|
|
411
|
+
isDateUnavailable={callback<[CalendarDate], boolean>(cells(props).isDateUnavailable)}
|
|
412
|
+
isDisabled={props.isDisabled}
|
|
413
|
+
isReadOnly={props.isReadOnly}
|
|
414
|
+
autoFocus
|
|
415
|
+
onChange={(date) => state.setDateValue(date)}
|
|
416
|
+
/>
|
|
417
|
+
</div>
|
|
418
|
+
</Popover>
|
|
419
|
+
<span {...descriptionProps}>{props.description}</span>
|
|
420
|
+
<span {...errorMessageProps}>{props.errorMessage}</span>
|
|
421
|
+
</>
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// ---------------------------------------------------------------------------
|
|
426
|
+
// A range of days
|
|
427
|
+
// ---------------------------------------------------------------------------
|
|
428
|
+
|
|
429
|
+
/** Two ends, each a day or a day with a time. */
|
|
430
|
+
export interface DateTimeRange<T extends DateValue = DateValue> {
|
|
431
|
+
start: T;
|
|
432
|
+
end: T;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface DateRangePickerComponentProps<T extends DateValue = CalendarDate> extends Omit<
|
|
436
|
+
DatePickerComponentProps,
|
|
437
|
+
"value" | "defaultValue" | "onChange" | "name" | "validate"
|
|
438
|
+
> {
|
|
439
|
+
value?: DateTimeRange<T> | null;
|
|
440
|
+
defaultValue?: DateTimeRange<T> | null;
|
|
441
|
+
startName?: string;
|
|
442
|
+
endName?: string;
|
|
443
|
+
/** What the page thinks of the RANGE, checked as it changes. */
|
|
444
|
+
validate?: ValidateFunction<DateTimeRange<T> | null>;
|
|
445
|
+
onChange?: (value: DateTimeRange<T> | null) => void;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** A range whose end comes before its start, which no stay or booking can be. */
|
|
449
|
+
function reversedRange(
|
|
450
|
+
range: DateTimeRange | null,
|
|
451
|
+
message: () => string,
|
|
452
|
+
): ValidationResult | undefined {
|
|
453
|
+
if (range === null || range.end.compare(range.start) >= 0) return undefined;
|
|
454
|
+
return {
|
|
455
|
+
isInvalid: true,
|
|
456
|
+
validationErrors: [message()],
|
|
457
|
+
validationDetails: {
|
|
458
|
+
badInput: false,
|
|
459
|
+
customError: false,
|
|
460
|
+
patternMismatch: false,
|
|
461
|
+
rangeOverflow: true,
|
|
462
|
+
rangeUnderflow: true,
|
|
463
|
+
stepMismatch: false,
|
|
464
|
+
tooLong: false,
|
|
465
|
+
tooShort: false,
|
|
466
|
+
typeMismatch: false,
|
|
467
|
+
valueMissing: false,
|
|
468
|
+
valid: false,
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Two fields and one calendar.
|
|
475
|
+
*
|
|
476
|
+
* The fields are separate controls — a start and an end are two dates, and one
|
|
477
|
+
* field holding "3 Mar – 7 Mar" is a string nobody can edit a part of — but
|
|
478
|
+
* they share the calendar, where the range is drawn in one gesture. What is
|
|
479
|
+
* wrong with the range as a whole, an end before its start, is said once, by
|
|
480
|
+
* the group, rather than by either field.
|
|
481
|
+
*/
|
|
482
|
+
export function DateRangePicker<T extends DateValue = CalendarDate>(
|
|
483
|
+
props: DateRangePickerComponentProps<T>,
|
|
484
|
+
) {
|
|
485
|
+
const groupRef = makeRef<HTMLDivElement>();
|
|
486
|
+
const triggerRef = makeRef<HTMLButtonElement>();
|
|
487
|
+
const messages = stringFormatter(PICKER_STRINGS);
|
|
488
|
+
|
|
489
|
+
const [value, setValue] = controllable<DateTimeRange<T> | null>(
|
|
490
|
+
() => props.value,
|
|
491
|
+
() => props.defaultValue ?? null,
|
|
492
|
+
(next) => props.onChange?.(next),
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
const overlay = overlayTriggerState({
|
|
496
|
+
isOpen: () => props.isOpen,
|
|
497
|
+
defaultOpen: () => props.defaultOpen,
|
|
498
|
+
onOpenChange: (isOpen) => props.onOpenChange?.(isOpen),
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const buttonId = id();
|
|
502
|
+
const dialogId = id();
|
|
503
|
+
|
|
504
|
+
const isDisabled = (): boolean => props.isDisabled === true;
|
|
505
|
+
|
|
506
|
+
const { isInvalid, errors, errorMessage } = fieldValidation<DateTimeRange<T> | null>({
|
|
507
|
+
value,
|
|
508
|
+
builtinValidation: () => reversedRange(value(), () => messages().format("rangeReversed")),
|
|
509
|
+
validate: callback<[DateTimeRange<T> | null], string | string[] | true | null | undefined>(
|
|
510
|
+
cells(props).validate,
|
|
511
|
+
),
|
|
512
|
+
validationBehavior: () => props.validationBehavior,
|
|
513
|
+
isInvalid: () => props.isInvalid,
|
|
514
|
+
errorMessage: () => props.errorMessage,
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
const {
|
|
518
|
+
labelProps,
|
|
519
|
+
fieldProps: labelledProps,
|
|
520
|
+
descriptionProps,
|
|
521
|
+
errorMessageProps,
|
|
522
|
+
} = field({
|
|
523
|
+
label: () => props.label,
|
|
524
|
+
description: () => props.description,
|
|
525
|
+
errorMessage,
|
|
526
|
+
isInvalid,
|
|
527
|
+
"aria-label": () => props["aria-label"],
|
|
528
|
+
"aria-labelledby": () => props["aria-labelledby"],
|
|
529
|
+
labelElementType: "span",
|
|
530
|
+
});
|
|
531
|
+
const labelId = (): string | undefined =>
|
|
532
|
+
access(labelProps.id as MaybeAccessor<string | undefined>);
|
|
533
|
+
|
|
534
|
+
const trigger = button(
|
|
535
|
+
{
|
|
536
|
+
id: buttonId,
|
|
537
|
+
"aria-haspopup": "dialog",
|
|
538
|
+
"aria-expanded": () => overlay.isOpen(),
|
|
539
|
+
"aria-controls": () => (overlay.isOpen() ? dialogId() : undefined),
|
|
540
|
+
"aria-label": () => messages().format("calendar"),
|
|
541
|
+
"aria-labelledby": () => `${buttonId()} ${labelId() ?? ""}`.trim(),
|
|
542
|
+
isDisabled: () => isDisabled() || props.isReadOnly === true,
|
|
543
|
+
onPress: () => overlay.toggle(),
|
|
544
|
+
},
|
|
545
|
+
triggerRef,
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
const { hoverProps, isHovered } = hover({ isDisabled });
|
|
549
|
+
const { focusProps, isFocusVisible } = focusRing();
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* One end changed. The other is kept, so the range is edited rather than
|
|
553
|
+
* reset, and each end keeps the time typed into it.
|
|
554
|
+
*/
|
|
555
|
+
const setEnd = (which: "start" | "end", reported: DateValue | null): void => {
|
|
556
|
+
const current = value();
|
|
557
|
+
if (reported === null) {
|
|
558
|
+
setValue(null);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
// The field reports a day or a day with a time as its granularity says,
|
|
562
|
+
// which is the kind the caller's range holds.
|
|
563
|
+
const date = reported as T;
|
|
564
|
+
const other = which === "start" ? current?.end : current?.start;
|
|
565
|
+
if (other === undefined) {
|
|
566
|
+
setValue({ start: date, end: date });
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
setValue(which === "start" ? { start: date, end: other } : { start: other, end: date });
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
/** A range drawn in the calendar, with the times the two ends already held. */
|
|
573
|
+
const fromCalendar = (range: DateRange | null): DateTimeRange<T> | null => {
|
|
574
|
+
if (range === null) return null;
|
|
575
|
+
const current = value();
|
|
576
|
+
// A day chosen in the calendar keeps the time its end already had.
|
|
577
|
+
const keep = (day: CalendarDate, was: T | undefined): T =>
|
|
578
|
+
(was instanceof CalendarDateTime ? CalendarDateTime.from(day, was.time) : day) as T;
|
|
579
|
+
return { start: keep(range.start, current?.start), end: keep(range.end, current?.end) };
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const days = (): DateRange | null => {
|
|
583
|
+
const current = value();
|
|
584
|
+
if (current === null) return null;
|
|
585
|
+
return { start: toCalendarDate(current.start), end: toCalendarDate(current.end) };
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
const elementProps = mergeProps(
|
|
589
|
+
labelledProps,
|
|
590
|
+
filterDOMProps(fromProps(cells(props)), { global: true }),
|
|
591
|
+
styleProps(cells(props)),
|
|
592
|
+
{
|
|
593
|
+
role: "group",
|
|
594
|
+
"aria-disabled": () => isDisabled() || undefined,
|
|
595
|
+
"aria-invalid": () => isInvalid() || undefined,
|
|
596
|
+
"data-open": overlay.isOpen,
|
|
597
|
+
"data-invalid": isInvalid,
|
|
598
|
+
"data-testid": () => props["data-testid"],
|
|
599
|
+
onKeyDown: (event: KeyboardEvent) =>
|
|
600
|
+
opensOnAltArrow(event, overlay, isDisabled() || props.isReadOnly === true),
|
|
601
|
+
},
|
|
602
|
+
);
|
|
603
|
+
|
|
604
|
+
return (
|
|
605
|
+
<>
|
|
606
|
+
<span {...labelProps}>{props.label}</span>
|
|
607
|
+
<div {...elementProps} ref={mergeRefs(groupRef.set, props.ref)}>
|
|
608
|
+
<DateField
|
|
609
|
+
aria-label={messages().format("startDate")}
|
|
610
|
+
value={value()?.start ?? null}
|
|
611
|
+
placeholderValue={props.placeholderValue}
|
|
612
|
+
minValue={props.minValue}
|
|
613
|
+
maxValue={props.maxValue}
|
|
614
|
+
isDateUnavailable={callback<[CalendarDate], boolean>(cells(props).isDateUnavailable)}
|
|
615
|
+
granularity={props.granularity}
|
|
616
|
+
hourCycle={props.hourCycle}
|
|
617
|
+
isDisabled={props.isDisabled}
|
|
618
|
+
isReadOnly={props.isReadOnly}
|
|
619
|
+
isRequired={props.isRequired}
|
|
620
|
+
isInvalid={isInvalid() || undefined}
|
|
621
|
+
validationBehavior={props.validationBehavior}
|
|
622
|
+
name={props.startName}
|
|
623
|
+
onChange={(next) => setEnd("start", next)}
|
|
624
|
+
/>
|
|
625
|
+
<span aria-hidden="true">–</span>
|
|
626
|
+
<DateField
|
|
627
|
+
aria-label={messages().format("endDate")}
|
|
628
|
+
value={value()?.end ?? null}
|
|
629
|
+
placeholderValue={props.placeholderValue}
|
|
630
|
+
minValue={props.minValue}
|
|
631
|
+
maxValue={props.maxValue}
|
|
632
|
+
isDateUnavailable={callback<[CalendarDate], boolean>(cells(props).isDateUnavailable)}
|
|
633
|
+
granularity={props.granularity}
|
|
634
|
+
hourCycle={props.hourCycle}
|
|
635
|
+
isDisabled={props.isDisabled}
|
|
636
|
+
isReadOnly={props.isReadOnly}
|
|
637
|
+
isRequired={props.isRequired}
|
|
638
|
+
isInvalid={isInvalid() || undefined}
|
|
639
|
+
validationBehavior={props.validationBehavior}
|
|
640
|
+
name={props.endName}
|
|
641
|
+
onChange={(next) => setEnd("end", next)}
|
|
642
|
+
/>
|
|
643
|
+
<button
|
|
644
|
+
{...mergeProps(trigger.buttonProps, hoverProps, focusProps, {
|
|
645
|
+
id: buttonId,
|
|
646
|
+
"data-hovered": isHovered,
|
|
647
|
+
"data-focus-visible": isFocusVisible,
|
|
648
|
+
})}
|
|
649
|
+
type="button"
|
|
650
|
+
ref={triggerRef.set}
|
|
651
|
+
>
|
|
652
|
+
<span aria-hidden="true">📅</span>
|
|
653
|
+
</button>
|
|
654
|
+
</div>
|
|
655
|
+
<Popover
|
|
656
|
+
triggerRef={triggerRef}
|
|
657
|
+
isOpen={overlay.isOpen()}
|
|
658
|
+
onOpenChange={overlay.setOpen}
|
|
659
|
+
placement={props.placement ?? "bottom start"}
|
|
660
|
+
>
|
|
661
|
+
<div
|
|
662
|
+
id={dialogId}
|
|
663
|
+
role="dialog"
|
|
664
|
+
aria-labelledby={`${buttonId()} ${labelId() ?? ""}`.trim()}
|
|
665
|
+
>
|
|
666
|
+
<RangeCalendar
|
|
667
|
+
aria-label={messages().format("calendar")}
|
|
668
|
+
value={days()}
|
|
669
|
+
defaultFocusedValue={days()?.start ?? toCalendarDate(props.placeholderValue ?? today())}
|
|
670
|
+
minValue={props.minValue}
|
|
671
|
+
maxValue={props.maxValue}
|
|
672
|
+
isDateUnavailable={callback<[CalendarDate], boolean>(cells(props).isDateUnavailable)}
|
|
673
|
+
isDisabled={props.isDisabled}
|
|
674
|
+
isReadOnly={props.isReadOnly}
|
|
675
|
+
autoFocus
|
|
676
|
+
onChange={(range) => {
|
|
677
|
+
setValue(fromCalendar(range));
|
|
678
|
+
overlay.close();
|
|
679
|
+
}}
|
|
680
|
+
/>
|
|
681
|
+
</div>
|
|
682
|
+
</Popover>
|
|
683
|
+
<span {...descriptionProps}>{props.description}</span>
|
|
684
|
+
<span {...errorMessageProps}>
|
|
685
|
+
{() => {
|
|
686
|
+
const given = props.errorMessage;
|
|
687
|
+
if (given !== undefined && given !== null && given !== "") return given;
|
|
688
|
+
const found = errors();
|
|
689
|
+
return found.length === 0 ? null : found.join(" ");
|
|
690
|
+
}}
|
|
691
|
+
</span>
|
|
692
|
+
</>
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// ---------------------------------------------------------------------------
|
|
697
|
+
// Strings
|
|
698
|
+
// ---------------------------------------------------------------------------
|
|
699
|
+
|
|
700
|
+
type PickerKey = "calendar" | "startDate" | "endDate" | "rangeReversed";
|
|
701
|
+
|
|
702
|
+
const PICKER_STRINGS = new StringDictionary<PickerKey>({
|
|
703
|
+
"en-US": {
|
|
704
|
+
calendar: "Calendar",
|
|
705
|
+
startDate: "Start date",
|
|
706
|
+
endDate: "End date",
|
|
707
|
+
rangeReversed: "The start date is after the end date.",
|
|
708
|
+
},
|
|
709
|
+
"ar-AE": {
|
|
710
|
+
calendar: "التقويم",
|
|
711
|
+
startDate: "تاريخ البدء",
|
|
712
|
+
endDate: "تاريخ الانتهاء",
|
|
713
|
+
rangeReversed: "تاريخ البدء يجب أن يكون قبل تاريخ الانتهاء.",
|
|
714
|
+
},
|
|
715
|
+
"bg-BG": {
|
|
716
|
+
calendar: "Календар",
|
|
717
|
+
startDate: "Начална дата",
|
|
718
|
+
endDate: "Крайна дата",
|
|
719
|
+
rangeReversed: "Началната дата трябва да е преди крайната.",
|
|
720
|
+
},
|
|
721
|
+
"cs-CZ": {
|
|
722
|
+
calendar: "Kalendář",
|
|
723
|
+
startDate: "Počáteční datum",
|
|
724
|
+
endDate: "Konečné datum",
|
|
725
|
+
rangeReversed: "Datum zahájení musí předcházet datu ukončení.",
|
|
726
|
+
},
|
|
727
|
+
"da-DK": {
|
|
728
|
+
calendar: "Kalender",
|
|
729
|
+
startDate: "Startdato",
|
|
730
|
+
endDate: "Slutdato",
|
|
731
|
+
rangeReversed: "Startdatoen skal være før slutdatoen.",
|
|
732
|
+
},
|
|
733
|
+
"de-DE": {
|
|
734
|
+
calendar: "Kalender",
|
|
735
|
+
startDate: "Startdatum",
|
|
736
|
+
endDate: "Enddatum",
|
|
737
|
+
rangeReversed: "Das Startdatum muss vor dem Enddatum liegen.",
|
|
738
|
+
},
|
|
739
|
+
"el-GR": {
|
|
740
|
+
calendar: "Ημερολόγιο",
|
|
741
|
+
startDate: "Ημερομηνία έναρξης",
|
|
742
|
+
endDate: "Ημερομηνία λήξης",
|
|
743
|
+
rangeReversed: "Η ημερομηνία έναρξης πρέπει να είναι πριν από την ημερομηνία λήξης.",
|
|
744
|
+
},
|
|
745
|
+
"es-ES": {
|
|
746
|
+
calendar: "Calendario",
|
|
747
|
+
startDate: "Fecha de inicio",
|
|
748
|
+
endDate: "Fecha final",
|
|
749
|
+
rangeReversed: "La fecha de inicio debe ser anterior a la fecha de finalización.",
|
|
750
|
+
},
|
|
751
|
+
"et-EE": {
|
|
752
|
+
calendar: "Kalender",
|
|
753
|
+
startDate: "Alguskuupäev",
|
|
754
|
+
endDate: "Lõppkuupäev",
|
|
755
|
+
rangeReversed: "Alguskuupäev peab olema enne lõppkuupäeva.",
|
|
756
|
+
},
|
|
757
|
+
"fi-FI": {
|
|
758
|
+
calendar: "Kalenteri",
|
|
759
|
+
startDate: "Alkamispäivä",
|
|
760
|
+
endDate: "Päättymispäivä",
|
|
761
|
+
rangeReversed: "Aloituspäivän on oltava ennen lopetuspäivää.",
|
|
762
|
+
},
|
|
763
|
+
"fr-FR": {
|
|
764
|
+
calendar: "Calendrier",
|
|
765
|
+
startDate: "Date de début",
|
|
766
|
+
endDate: "Date de fin",
|
|
767
|
+
rangeReversed: "La date de début doit être antérieure à la date de fin.",
|
|
768
|
+
},
|
|
769
|
+
"he-IL": {
|
|
770
|
+
calendar: "לוח שנה",
|
|
771
|
+
startDate: "תאריך התחלה",
|
|
772
|
+
endDate: "תאריך סיום",
|
|
773
|
+
rangeReversed: "תאריך ההתחלה חייב להיות לפני תאריך הסיום.",
|
|
774
|
+
},
|
|
775
|
+
"hr-HR": {
|
|
776
|
+
calendar: "Kalendar",
|
|
777
|
+
startDate: "Datum početka",
|
|
778
|
+
endDate: "Datum završetka",
|
|
779
|
+
rangeReversed: "Datum početka mora biti prije datuma završetka.",
|
|
780
|
+
},
|
|
781
|
+
"hu-HU": {
|
|
782
|
+
calendar: "Naptár",
|
|
783
|
+
startDate: "Kezdő dátum",
|
|
784
|
+
endDate: "Befejező dátum",
|
|
785
|
+
rangeReversed: "A kezdő dátumnak a befejező dátumnál korábbinak kell lennie.",
|
|
786
|
+
},
|
|
787
|
+
"it-IT": {
|
|
788
|
+
calendar: "Calendario",
|
|
789
|
+
startDate: "Data iniziale",
|
|
790
|
+
endDate: "Data finale",
|
|
791
|
+
rangeReversed: "La data di inizio deve essere antecedente alla data di fine.",
|
|
792
|
+
},
|
|
793
|
+
"ja-JP": {
|
|
794
|
+
calendar: "カレンダー",
|
|
795
|
+
startDate: "開始日",
|
|
796
|
+
endDate: "終了日",
|
|
797
|
+
rangeReversed: "開始日は終了日より前にする必要があります。",
|
|
798
|
+
},
|
|
799
|
+
"ko-KR": {
|
|
800
|
+
calendar: "달력",
|
|
801
|
+
startDate: "시작일",
|
|
802
|
+
endDate: "종료일",
|
|
803
|
+
rangeReversed: "시작일은 종료일 이전이어야 합니다.",
|
|
804
|
+
},
|
|
805
|
+
"lt-LT": {
|
|
806
|
+
calendar: "Kalendorius",
|
|
807
|
+
startDate: "Pradžios data",
|
|
808
|
+
endDate: "Pabaigos data",
|
|
809
|
+
rangeReversed: "Pradžios data turi būti ankstesnė nei pabaigos data.",
|
|
810
|
+
},
|
|
811
|
+
"lv-LV": {
|
|
812
|
+
calendar: "Kalendārs",
|
|
813
|
+
startDate: "Sākuma datums",
|
|
814
|
+
endDate: "Beigu datums",
|
|
815
|
+
rangeReversed: "Sākuma datumam ir jābūt pirms beigu datuma.",
|
|
816
|
+
},
|
|
817
|
+
"nb-NO": {
|
|
818
|
+
calendar: "Kalender",
|
|
819
|
+
startDate: "Startdato",
|
|
820
|
+
endDate: "Sluttdato",
|
|
821
|
+
rangeReversed: "Startdatoen må være før sluttdatoen.",
|
|
822
|
+
},
|
|
823
|
+
"nl-NL": {
|
|
824
|
+
calendar: "Kalender",
|
|
825
|
+
startDate: "Startdatum",
|
|
826
|
+
endDate: "Einddatum",
|
|
827
|
+
rangeReversed: "De startdatum moet voor de einddatum liggen.",
|
|
828
|
+
},
|
|
829
|
+
"pl-PL": {
|
|
830
|
+
calendar: "Kalendarz",
|
|
831
|
+
startDate: "Data początkowa",
|
|
832
|
+
endDate: "Data końcowa",
|
|
833
|
+
rangeReversed: "Data rozpoczęcia musi być wcześniejsza niż data zakończenia.",
|
|
834
|
+
},
|
|
835
|
+
"pt-BR": {
|
|
836
|
+
calendar: "Calendário",
|
|
837
|
+
startDate: "Data inicial",
|
|
838
|
+
endDate: "Data final",
|
|
839
|
+
rangeReversed: "A data inicial deve ser anterior à data final.",
|
|
840
|
+
},
|
|
841
|
+
"pt-PT": {
|
|
842
|
+
calendar: "Calendário",
|
|
843
|
+
startDate: "Data de Início",
|
|
844
|
+
endDate: "Data de Término",
|
|
845
|
+
rangeReversed: "A data de início deve ser anterior à data de fim.",
|
|
846
|
+
},
|
|
847
|
+
"ro-RO": {
|
|
848
|
+
calendar: "Calendar",
|
|
849
|
+
startDate: "Dată început",
|
|
850
|
+
endDate: "Dată final",
|
|
851
|
+
rangeReversed: "Data de început trebuie să fie anterioară datei de sfârșit.",
|
|
852
|
+
},
|
|
853
|
+
"ru-RU": {
|
|
854
|
+
calendar: "Календарь",
|
|
855
|
+
startDate: "Дата начала",
|
|
856
|
+
endDate: "Дата окончания",
|
|
857
|
+
rangeReversed: "Дата начала должна предшествовать дате окончания.",
|
|
858
|
+
},
|
|
859
|
+
"sk-SK": {
|
|
860
|
+
calendar: "Kalendár",
|
|
861
|
+
startDate: "Dátum začatia",
|
|
862
|
+
endDate: "Dátum ukončenia",
|
|
863
|
+
rangeReversed: "Dátum začiatku musí byť skorší ako dátum konca.",
|
|
864
|
+
},
|
|
865
|
+
"sl-SI": {
|
|
866
|
+
calendar: "Koledar",
|
|
867
|
+
startDate: "Datum začetka",
|
|
868
|
+
endDate: "Datum konca",
|
|
869
|
+
rangeReversed: "Začetni datum mora biti pred končnim datumom.",
|
|
870
|
+
},
|
|
871
|
+
"sr-SP": {
|
|
872
|
+
calendar: "Kalendar",
|
|
873
|
+
startDate: "Datum početka",
|
|
874
|
+
endDate: "Datum završetka",
|
|
875
|
+
rangeReversed: "Datum početka mora biti pre datuma završetka.",
|
|
876
|
+
},
|
|
877
|
+
"sv-SE": {
|
|
878
|
+
calendar: "Kalender",
|
|
879
|
+
startDate: "Startdatum",
|
|
880
|
+
endDate: "Slutdatum",
|
|
881
|
+
rangeReversed: "Startdatumet måste vara före slutdatumet.",
|
|
882
|
+
},
|
|
883
|
+
"tr-TR": {
|
|
884
|
+
calendar: "Takvim",
|
|
885
|
+
startDate: "Başlangıç Tarihi",
|
|
886
|
+
endDate: "Bitiş Tarihi",
|
|
887
|
+
rangeReversed: "Başlangıç tarihi bitiş tarihinden önce olmalıdır.",
|
|
888
|
+
},
|
|
889
|
+
"uk-UA": {
|
|
890
|
+
calendar: "Календар",
|
|
891
|
+
startDate: "Дата початку",
|
|
892
|
+
endDate: "Дата завершення",
|
|
893
|
+
rangeReversed: "Дата початку має передувати даті завершення.",
|
|
894
|
+
},
|
|
895
|
+
"zh-CN": {
|
|
896
|
+
calendar: "日历",
|
|
897
|
+
startDate: "开始日期",
|
|
898
|
+
endDate: "结束日期",
|
|
899
|
+
rangeReversed: "开始日期必须早于结束日期。",
|
|
900
|
+
},
|
|
901
|
+
"zh-TW": {
|
|
902
|
+
calendar: "日曆",
|
|
903
|
+
startDate: "開始日期",
|
|
904
|
+
endDate: "結束日期",
|
|
905
|
+
rangeReversed: "開始日期必須在結束日期之前。",
|
|
906
|
+
},
|
|
907
|
+
});
|