best-react-datepicker 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/chunk-A3NQUSC5.cjs +1155 -0
  2. package/dist/chunk-A3NQUSC5.cjs.map +1 -0
  3. package/dist/chunk-FBN3SFQJ.js +1140 -0
  4. package/dist/chunk-FBN3SFQJ.js.map +1 -0
  5. package/dist/chunk-HI4J64KK.cjs +592 -0
  6. package/dist/chunk-HI4J64KK.cjs.map +1 -0
  7. package/dist/chunk-NF5M43IO.js +49 -0
  8. package/dist/chunk-NF5M43IO.js.map +1 -0
  9. package/dist/chunk-QW2CUEX4.js +117 -0
  10. package/dist/chunk-QW2CUEX4.js.map +1 -0
  11. package/dist/chunk-R7HLYS5V.cjs +120 -0
  12. package/dist/chunk-R7HLYS5V.cjs.map +1 -0
  13. package/dist/chunk-W6KEY2SO.js +526 -0
  14. package/dist/chunk-W6KEY2SO.js.map +1 -0
  15. package/dist/chunk-WBWQ5RKN.cjs +51 -0
  16. package/dist/chunk-WBWQ5RKN.cjs.map +1 -0
  17. package/dist/hooks.cjs +66 -0
  18. package/dist/hooks.cjs.map +1 -0
  19. package/dist/hooks.d.cts +555 -0
  20. package/dist/hooks.d.ts +555 -0
  21. package/dist/hooks.js +5 -0
  22. package/dist/hooks.js.map +1 -0
  23. package/dist/index.cjs +1502 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +239 -0
  26. package/dist/index.d.ts +239 -0
  27. package/dist/index.js +1303 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/locales.cjs +16 -0
  30. package/dist/locales.cjs.map +1 -0
  31. package/dist/locales.d.cts +6 -0
  32. package/dist/locales.d.ts +6 -0
  33. package/dist/locales.js +3 -0
  34. package/dist/locales.js.map +1 -0
  35. package/dist/presets-B8wfaoTj.d.cts +54 -0
  36. package/dist/presets-CB5Rt4Li.d.ts +54 -0
  37. package/dist/styles.css +751 -0
  38. package/dist/types-DA2PcEiy.d.cts +104 -0
  39. package/dist/types-DA2PcEiy.d.ts +104 -0
  40. package/dist/utils.cjs +282 -0
  41. package/dist/utils.cjs.map +1 -0
  42. package/dist/utils.d.cts +57 -0
  43. package/dist/utils.d.ts +57 -0
  44. package/dist/utils.js +5 -0
  45. package/dist/utils.js.map +1 -0
  46. package/package.json +79 -0
package/dist/index.js ADDED
@@ -0,0 +1,1303 @@
1
+ import { useDatePicker, useClickOutside, useKeyboardNav, usePortal, useRangePicker, useTimePicker, useDateTimePicker, useMonthPicker, useYearPicker, useWeekPicker } from './chunk-FBN3SFQJ.js';
2
+ export { useCalendar, useClickOutside, useControllable, useDatePicker, useDateTimePicker, useFocusTrap, useKeyboardNav, useMonthPicker, useMultiPicker, usePortal, useRangePicker, useTimePicker, useWeekPicker, useYearPicker } from './chunk-FBN3SFQJ.js';
3
+ export { createPresets } from './chunk-NF5M43IO.js';
4
+ import { generateHours, generateMinutes } from './chunk-W6KEY2SO.js';
5
+ export { addDays, addMonths, addYears, clone, createDate, differenceInDays, endOfDay, endOfMonth, endOfWeek, endOfYear, formatDate, formatTime, isAfter, isBefore, isBetween, isSameDay, isSameMonth, isSameYear, isToday, isWeekend, parseDate, startOfDay, startOfMonth, startOfWeek, startOfYear, subDays, subMonths, subYears, today } from './chunk-W6KEY2SO.js';
6
+ export { createLocaleFromIntl, defaultLocale } from './chunk-QW2CUEX4.js';
7
+ import { forwardRef, useRef, useState, useEffect, useCallback } from 'react';
8
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
+ import { createPortal } from 'react-dom';
10
+
11
+ var DEFAULT_MONTH_NAMES = [
12
+ "January",
13
+ "February",
14
+ "March",
15
+ "April",
16
+ "May",
17
+ "June",
18
+ "July",
19
+ "August",
20
+ "September",
21
+ "October",
22
+ "November",
23
+ "December"
24
+ ];
25
+ function SelectChevron() {
26
+ return /* @__PURE__ */ jsx("span", { className: "brdp-header__select-chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx("svg", { width: "10", height: "10", viewBox: "0 0 10 10", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M2.5 3.75L5 6.25L7.5 3.75", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) });
27
+ }
28
+ function CalendarHeader({
29
+ label,
30
+ onPrevMonth,
31
+ onNextMonth,
32
+ onLabelClick,
33
+ prevMonthLabel = "Previous month",
34
+ nextMonthLabel = "Next month",
35
+ className,
36
+ showPrev = true,
37
+ showNext = true,
38
+ viewingMonth,
39
+ viewingYear,
40
+ onMonthChange,
41
+ onYearChange,
42
+ minDate,
43
+ maxDate,
44
+ monthNames
45
+ }) {
46
+ const hasDropdowns = viewingMonth != null && viewingYear != null && onMonthChange && onYearChange;
47
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
48
+ const minYear = minDate ? minDate.getFullYear() : currentYear - 100;
49
+ const maxYear = maxDate ? maxDate.getFullYear() : currentYear + 20;
50
+ const names = monthNames ?? DEFAULT_MONTH_NAMES;
51
+ const getMonthOptions = () => {
52
+ const options = [];
53
+ for (let m = 0; m < 12; m++) {
54
+ let disabled = false;
55
+ if (minDate && viewingYear != null && viewingYear === minDate.getFullYear() && m < minDate.getMonth()) {
56
+ disabled = true;
57
+ }
58
+ if (maxDate && viewingYear != null && viewingYear === maxDate.getFullYear() && m > maxDate.getMonth()) {
59
+ disabled = true;
60
+ }
61
+ options.push({ value: m, label: names[m], disabled });
62
+ }
63
+ return options;
64
+ };
65
+ return /* @__PURE__ */ jsxs("div", { className: `brdp-header ${className ?? ""}`, children: [
66
+ showPrev ? /* @__PURE__ */ jsx(
67
+ "button",
68
+ {
69
+ type: "button",
70
+ className: "brdp-header__nav-btn brdp-header__nav-btn--prev",
71
+ onClick: onPrevMonth,
72
+ "aria-label": prevMonthLabel,
73
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
74
+ }
75
+ ) : /* @__PURE__ */ jsx("span", { className: "brdp-header__nav-btn", style: { visibility: "hidden" } }),
76
+ hasDropdowns ? /* @__PURE__ */ jsxs("div", { className: "brdp-header__selects", children: [
77
+ /* @__PURE__ */ jsxs("div", { className: "brdp-header__select-wrapper", children: [
78
+ /* @__PURE__ */ jsx(
79
+ "select",
80
+ {
81
+ className: "brdp-header__select",
82
+ value: viewingMonth,
83
+ onChange: (e) => onMonthChange(Number(e.target.value)),
84
+ "aria-label": "Select month",
85
+ children: getMonthOptions().map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value))
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx(SelectChevron, {})
89
+ ] }),
90
+ /* @__PURE__ */ jsxs("div", { className: "brdp-header__select-wrapper", children: [
91
+ /* @__PURE__ */ jsx(
92
+ "select",
93
+ {
94
+ className: "brdp-header__select",
95
+ value: viewingYear,
96
+ onChange: (e) => onYearChange(Number(e.target.value)),
97
+ "aria-label": "Select year",
98
+ children: Array.from({ length: maxYear - minYear + 1 }, (_, i) => minYear + i).map((y) => /* @__PURE__ */ jsx("option", { value: y, children: y }, y))
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsx(SelectChevron, {})
102
+ ] })
103
+ ] }) : /* @__PURE__ */ jsx(
104
+ "button",
105
+ {
106
+ type: "button",
107
+ className: "brdp-header__label",
108
+ onClick: onLabelClick,
109
+ "aria-live": "polite",
110
+ children: label
111
+ }
112
+ ),
113
+ showNext ? /* @__PURE__ */ jsx(
114
+ "button",
115
+ {
116
+ type: "button",
117
+ className: "brdp-header__nav-btn brdp-header__nav-btn--next",
118
+ onClick: onNextMonth,
119
+ "aria-label": nextMonthLabel,
120
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
121
+ }
122
+ ) : /* @__PURE__ */ jsx("span", { className: "brdp-header__nav-btn", style: { visibility: "hidden" } })
123
+ ] });
124
+ }
125
+ function CalendarDay({
126
+ day,
127
+ isSelected = false,
128
+ isDisabled = false,
129
+ isHighlighted = false,
130
+ isRangeStart = false,
131
+ isRangeEnd = false,
132
+ isInRange = false,
133
+ isInPreviewRange = false,
134
+ isFocused = false,
135
+ onClick,
136
+ onMouseEnter,
137
+ onMouseLeave,
138
+ renderDay,
139
+ className,
140
+ showOutsideDays = true
141
+ }) {
142
+ if (!day.isCurrentMonth && !showOutsideDays) {
143
+ return /* @__PURE__ */ jsx("td", { className: "brdp-day brdp-day--empty", "aria-hidden": "true" });
144
+ }
145
+ const classes = [
146
+ "brdp-day",
147
+ day.isToday && "brdp-day--today",
148
+ isSelected && "brdp-day--selected",
149
+ isDisabled && "brdp-day--disabled",
150
+ !day.isCurrentMonth && "brdp-day--outside",
151
+ day.isWeekend && "brdp-day--weekend",
152
+ isHighlighted && "brdp-day--highlighted",
153
+ isRangeStart && "brdp-day--range-start",
154
+ isRangeEnd && "brdp-day--range-end",
155
+ isInRange && "brdp-day--range-middle",
156
+ isInPreviewRange && "brdp-day--range-preview",
157
+ isFocused && "brdp-day--focused",
158
+ className
159
+ ].filter(Boolean).join(" ");
160
+ return /* @__PURE__ */ jsx("td", { className: classes, role: "gridcell", children: /* @__PURE__ */ jsx(
161
+ "button",
162
+ {
163
+ type: "button",
164
+ className: "brdp-day__btn",
165
+ disabled: isDisabled,
166
+ tabIndex: isFocused ? 0 : -1,
167
+ "aria-selected": isSelected,
168
+ "aria-disabled": isDisabled,
169
+ "aria-label": day.date.toLocaleDateString(),
170
+ onClick: () => onClick?.(day.date),
171
+ onMouseEnter: () => onMouseEnter?.(day.date),
172
+ onMouseLeave,
173
+ "data-date": day.date.toISOString().split("T")[0],
174
+ children: renderDay ? renderDay(day) : day.dayOfMonth
175
+ }
176
+ ) });
177
+ }
178
+ var DEFAULT_DAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
179
+ function CalendarGrid({
180
+ month,
181
+ weekStartsOn = 0,
182
+ dayNames,
183
+ showWeekNumbers = false,
184
+ showOutsideDays = true,
185
+ isSelected,
186
+ isDisabled,
187
+ isHighlighted,
188
+ isRangeStart,
189
+ isRangeEnd,
190
+ isInRange,
191
+ isInPreviewRange,
192
+ focusedDate,
193
+ onDayClick,
194
+ onDayMouseEnter,
195
+ onDayMouseLeave,
196
+ renderDay,
197
+ onKeyDown,
198
+ className
199
+ }) {
200
+ const names = dayNames ?? reorderDayNames(DEFAULT_DAY_NAMES, weekStartsOn);
201
+ const isSameDay2 = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
202
+ return /* @__PURE__ */ jsxs(
203
+ "table",
204
+ {
205
+ className: `brdp-grid ${className ?? ""}`,
206
+ role: "grid",
207
+ "aria-label": month.label,
208
+ onKeyDown,
209
+ children: [
210
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "brdp-grid__weekdays", children: [
211
+ showWeekNumbers && /* @__PURE__ */ jsx("th", { className: "brdp-week-number brdp-week-number--header", "aria-label": "Week number", children: "#" }),
212
+ names.map((name, i) => /* @__PURE__ */ jsx("th", { className: "brdp-grid__weekday", abbr: name, scope: "col", children: name }, i))
213
+ ] }) }),
214
+ /* @__PURE__ */ jsx("tbody", { children: month.weeks.map((week, wi) => /* @__PURE__ */ jsxs("tr", { className: "brdp-grid__week", children: [
215
+ showWeekNumbers && /* @__PURE__ */ jsx("td", { className: "brdp-week-number", "aria-label": `Week ${week.weekNumber}`, children: week.weekNumber }),
216
+ week.days.map((day, di) => /* @__PURE__ */ jsx(
217
+ CalendarDay,
218
+ {
219
+ day,
220
+ isSelected: isSelected?.(day.date) ?? false,
221
+ isDisabled: isDisabled?.(day.date) ?? false,
222
+ isHighlighted: isHighlighted?.(day.date) ?? false,
223
+ isRangeStart: isRangeStart?.(day.date) ?? false,
224
+ isRangeEnd: isRangeEnd?.(day.date) ?? false,
225
+ isInRange: isInRange?.(day.date) ?? false,
226
+ isInPreviewRange: isInPreviewRange?.(day.date) ?? false,
227
+ isFocused: focusedDate ? isSameDay2(day.date, focusedDate) : false,
228
+ onClick: onDayClick,
229
+ onMouseEnter: onDayMouseEnter,
230
+ onMouseLeave: onDayMouseLeave,
231
+ renderDay,
232
+ showOutsideDays
233
+ },
234
+ di
235
+ ))
236
+ ] }, wi)) })
237
+ ]
238
+ }
239
+ );
240
+ }
241
+ function reorderDayNames(names, weekStartsOn) {
242
+ return [...names.slice(weekStartsOn), ...names.slice(0, weekStartsOn)];
243
+ }
244
+ function LiveRegion({ message }) {
245
+ const [announced, setAnnounced] = useState("");
246
+ useEffect(() => {
247
+ if (message) {
248
+ setAnnounced("");
249
+ const timer = setTimeout(() => setAnnounced(message), 100);
250
+ return () => clearTimeout(timer);
251
+ }
252
+ }, [message]);
253
+ return /* @__PURE__ */ jsx(
254
+ "div",
255
+ {
256
+ role: "status",
257
+ "aria-live": "polite",
258
+ "aria-atomic": "true",
259
+ style: {
260
+ position: "absolute",
261
+ width: 1,
262
+ height: 1,
263
+ padding: 0,
264
+ margin: -1,
265
+ overflow: "hidden",
266
+ clip: "rect(0, 0, 0, 0)",
267
+ whiteSpace: "nowrap",
268
+ borderWidth: 0
269
+ },
270
+ children: announced
271
+ }
272
+ );
273
+ }
274
+ function Calendar({
275
+ months,
276
+ viewingYear,
277
+ viewingMonth,
278
+ weekStartsOn = 0,
279
+ dayNames,
280
+ showWeekNumbers = false,
281
+ showOutsideDays = true,
282
+ focusedDate,
283
+ onPrevMonth,
284
+ onNextMonth,
285
+ onLabelClick,
286
+ onDayClick,
287
+ onDayMouseEnter,
288
+ onDayMouseLeave,
289
+ onKeyDown,
290
+ isSelected,
291
+ isDisabled,
292
+ isHighlighted,
293
+ isRangeStart,
294
+ isRangeEnd,
295
+ isInRange,
296
+ isInPreviewRange,
297
+ renderDay,
298
+ renderFooter,
299
+ className,
300
+ dir,
301
+ onMonthSelect,
302
+ onYearSelect,
303
+ minDate,
304
+ maxDate
305
+ }) {
306
+ const totalMonths = months.length;
307
+ return /* @__PURE__ */ jsxs("div", { className: `brdp-calendar ${className ?? ""}`, dir, children: [
308
+ /* @__PURE__ */ jsx(LiveRegion, { message: months[0]?.label ?? "" }),
309
+ /* @__PURE__ */ jsx("div", { className: "brdp-calendar__months", children: months.map((month, i) => /* @__PURE__ */ jsxs("div", { className: "brdp-calendar__month", children: [
310
+ /* @__PURE__ */ jsx(
311
+ CalendarHeader,
312
+ {
313
+ label: month.label,
314
+ onPrevMonth,
315
+ onNextMonth,
316
+ onLabelClick,
317
+ showPrev: i === 0,
318
+ showNext: i === totalMonths - 1,
319
+ viewingMonth: month.month,
320
+ viewingYear: month.year,
321
+ onMonthChange: onMonthSelect ?? void 0,
322
+ onYearChange: onYearSelect ?? void 0,
323
+ minDate,
324
+ maxDate
325
+ }
326
+ ),
327
+ /* @__PURE__ */ jsx(
328
+ CalendarGrid,
329
+ {
330
+ month,
331
+ weekStartsOn,
332
+ dayNames,
333
+ showWeekNumbers,
334
+ showOutsideDays,
335
+ isSelected,
336
+ isDisabled,
337
+ isHighlighted,
338
+ isRangeStart,
339
+ isRangeEnd,
340
+ isInRange,
341
+ isInPreviewRange,
342
+ focusedDate,
343
+ onDayClick,
344
+ onDayMouseEnter,
345
+ onDayMouseLeave,
346
+ renderDay,
347
+ onKeyDown
348
+ }
349
+ )
350
+ ] }, `${month.year}-${month.month}`)) }),
351
+ renderFooter && /* @__PURE__ */ jsx("div", { className: "brdp-footer", children: renderFooter() })
352
+ ] });
353
+ }
354
+ function Portal({ children, container, enabled = true }) {
355
+ const { portalTarget } = usePortal({ enabled: enabled && !container });
356
+ const target = container ?? portalTarget;
357
+ if (!enabled) return /* @__PURE__ */ jsx(Fragment, { children });
358
+ if (!target) return null;
359
+ return createPortal(children, target);
360
+ }
361
+ function Popover({
362
+ children,
363
+ anchorRef,
364
+ isOpen,
365
+ onClose,
366
+ portal = false,
367
+ portalContainer,
368
+ className,
369
+ style,
370
+ ...ariaProps
371
+ }) {
372
+ const popoverRef = useRef(null);
373
+ const [position, setPosition] = useState({});
374
+ useEffect(() => {
375
+ if (!isOpen || !anchorRef.current) return;
376
+ const updatePosition = () => {
377
+ const anchor = anchorRef.current;
378
+ if (!anchor) return;
379
+ if (portal) {
380
+ const rect = anchor.getBoundingClientRect();
381
+ const spaceBelow = window.innerHeight - rect.bottom;
382
+ const placeAbove = spaceBelow < 320 && rect.top > spaceBelow;
383
+ setPosition({
384
+ position: "fixed",
385
+ left: rect.left,
386
+ ...placeAbove ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 },
387
+ zIndex: "var(--brdp-z-portal, 1100)"
388
+ });
389
+ } else {
390
+ setPosition({
391
+ position: "absolute",
392
+ top: "100%",
393
+ left: 0,
394
+ marginTop: 4,
395
+ zIndex: "var(--brdp-z-popover, 1000)"
396
+ });
397
+ }
398
+ };
399
+ updatePosition();
400
+ window.addEventListener("scroll", updatePosition, true);
401
+ window.addEventListener("resize", updatePosition);
402
+ return () => {
403
+ window.removeEventListener("scroll", updatePosition, true);
404
+ window.removeEventListener("resize", updatePosition);
405
+ };
406
+ }, [isOpen, portal, anchorRef]);
407
+ if (!isOpen) return null;
408
+ const content = /* @__PURE__ */ jsx(
409
+ "div",
410
+ {
411
+ ref: popoverRef,
412
+ className: `brdp-popover ${className ?? ""}`,
413
+ style: { ...position, ...style },
414
+ ...ariaProps,
415
+ children
416
+ }
417
+ );
418
+ if (portal) {
419
+ return /* @__PURE__ */ jsx(Portal, { container: portalContainer, enabled: true, children: content });
420
+ }
421
+ return content;
422
+ }
423
+
424
+ // src/components/shared/sizeStyles.ts
425
+ var sizeTokens = {
426
+ sm: {
427
+ "--brdp-cell-size": "32px",
428
+ "--brdp-input-height": "32px",
429
+ "--brdp-header-height": "36px",
430
+ "--brdp-font-size": "12px",
431
+ "--brdp-font-size-sm": "10px",
432
+ "--brdp-spacing-sm": "6px",
433
+ "--brdp-spacing-md": "8px"
434
+ },
435
+ md: {},
436
+ lg: {
437
+ "--brdp-cell-size": "48px",
438
+ "--brdp-input-height": "48px",
439
+ "--brdp-header-height": "56px",
440
+ "--brdp-font-size": "16px",
441
+ "--brdp-font-size-sm": "14px",
442
+ "--brdp-spacing-sm": "10px",
443
+ "--brdp-spacing-md": "16px"
444
+ }
445
+ };
446
+ function getSizeStyles(size) {
447
+ if (!size || size === "md") return {};
448
+ return sizeTokens[size];
449
+ }
450
+ var DatePicker = forwardRef(
451
+ function DatePicker2(props, ref) {
452
+ const {
453
+ className,
454
+ style,
455
+ size,
456
+ renderDay,
457
+ renderFooter,
458
+ portal = false,
459
+ portalContainer,
460
+ dir,
461
+ showOutsideDays = true,
462
+ showWeekNumbers = false,
463
+ dayNames,
464
+ inputProps: extraInputProps,
465
+ id,
466
+ "aria-label": ariaLabel,
467
+ "aria-labelledby": ariaLabelledby,
468
+ "aria-describedby": ariaDescribedby,
469
+ onBlur,
470
+ onFocus,
471
+ ...pickerOptions
472
+ } = props;
473
+ const picker = useDatePicker(pickerOptions);
474
+ const containerRef = useRef(null);
475
+ const inputRef = useRef(null);
476
+ useClickOutside([containerRef], () => {
477
+ if (picker.isOpen) picker.close();
478
+ }, picker.isOpen);
479
+ const focusedDate = picker.focusedDate ?? picker.selectedDate ?? /* @__PURE__ */ new Date();
480
+ const { handleKeyDown } = useKeyboardNav({
481
+ focusedDate,
482
+ onFocusChange: (date) => {
483
+ picker.setFocusedDate(date);
484
+ picker.goToDate(date);
485
+ },
486
+ onSelect: (date) => picker.selectDate(date),
487
+ onClose: () => picker.close(),
488
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
489
+ minDate: pickerOptions.minDate,
490
+ maxDate: pickerOptions.maxDate,
491
+ disabled: pickerOptions.disabled
492
+ });
493
+ const defaultInputProps = picker.getInputProps();
494
+ const popoverProps = picker.getPopoverProps();
495
+ const sizeStyles = getSizeStyles(size);
496
+ return /* @__PURE__ */ jsxs(
497
+ "div",
498
+ {
499
+ ref: containerRef,
500
+ className: `brdp-root ${className ?? ""}`,
501
+ style: { ...sizeStyles, ...style },
502
+ dir: dir ?? picker.locale.dir,
503
+ children: [
504
+ /* @__PURE__ */ jsx(
505
+ "input",
506
+ {
507
+ ...defaultInputProps,
508
+ ...extraInputProps,
509
+ ref: (node) => {
510
+ inputRef.current = node;
511
+ if (typeof ref === "function") ref(node);
512
+ else if (ref) ref.current = node;
513
+ },
514
+ id,
515
+ className: `brdp-input ${extraInputProps?.className ?? ""}`,
516
+ "aria-label": ariaLabel ?? defaultInputProps["aria-label"],
517
+ "aria-labelledby": ariaLabelledby,
518
+ "aria-describedby": ariaDescribedby,
519
+ onBlur: (e) => {
520
+ defaultInputProps.onBlur?.();
521
+ onBlur?.(e);
522
+ },
523
+ onFocus: (e) => {
524
+ defaultInputProps.onFocus?.();
525
+ onFocus?.(e);
526
+ }
527
+ }
528
+ ),
529
+ pickerOptions.name && /* @__PURE__ */ jsx("input", { ...picker.getHiddenInputProps() }),
530
+ /* @__PURE__ */ jsx(
531
+ Popover,
532
+ {
533
+ anchorRef: containerRef,
534
+ isOpen: picker.isOpen,
535
+ onClose: picker.close,
536
+ portal,
537
+ portalContainer,
538
+ ...popoverProps,
539
+ children: /* @__PURE__ */ jsx(
540
+ Calendar,
541
+ {
542
+ months: picker.months,
543
+ viewingYear: picker.viewingYear,
544
+ viewingMonth: picker.viewingMonth,
545
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
546
+ dayNames,
547
+ showWeekNumbers,
548
+ showOutsideDays,
549
+ focusedDate: picker.focusedDate,
550
+ onPrevMonth: picker.goToPrevMonth,
551
+ onNextMonth: picker.goToNextMonth,
552
+ onMonthSelect: (m) => picker.goToMonth(m),
553
+ onYearSelect: (y) => picker.goToYear(y),
554
+ minDate: pickerOptions.minDate,
555
+ maxDate: pickerOptions.maxDate,
556
+ onDayClick: (date) => picker.selectDate(date),
557
+ onKeyDown: handleKeyDown,
558
+ isSelected: picker.isSelected,
559
+ isDisabled: picker.isDateDisabled,
560
+ isHighlighted: picker.isDateHighlighted,
561
+ renderDay,
562
+ renderFooter: renderFooter ?? (picker.clearable ? () => /* @__PURE__ */ jsxs("div", { className: "brdp-footer", children: [
563
+ /* @__PURE__ */ jsx(
564
+ "button",
565
+ {
566
+ type: "button",
567
+ className: "brdp-footer__btn",
568
+ onClick: () => picker.goToToday(),
569
+ children: picker.locale.labels.today
570
+ }
571
+ ),
572
+ /* @__PURE__ */ jsx(
573
+ "button",
574
+ {
575
+ type: "button",
576
+ className: "brdp-footer__btn",
577
+ onClick: () => picker.clearDate(),
578
+ children: picker.locale.labels.clear
579
+ }
580
+ )
581
+ ] }) : void 0),
582
+ dir: dir ?? picker.locale.dir
583
+ }
584
+ )
585
+ }
586
+ )
587
+ ]
588
+ }
589
+ );
590
+ }
591
+ );
592
+ function RangePicker(props) {
593
+ const {
594
+ className,
595
+ style,
596
+ size,
597
+ compact = false,
598
+ showPresets = false,
599
+ presetsPosition = "left",
600
+ renderDay,
601
+ portal = false,
602
+ portalContainer,
603
+ dir,
604
+ showOutsideDays = true,
605
+ showWeekNumbers = false,
606
+ dayNames,
607
+ ...pickerOptions
608
+ } = props;
609
+ if (compact) {
610
+ pickerOptions.numberOfMonths = 1;
611
+ }
612
+ const picker = useRangePicker(pickerOptions);
613
+ const containerRef = useRef(null);
614
+ useClickOutside([containerRef], () => {
615
+ if (picker.isOpen) picker.close();
616
+ }, picker.isOpen);
617
+ const focusedDate = picker.focusedDate ?? picker.range.from ?? /* @__PURE__ */ new Date();
618
+ const { handleKeyDown } = useKeyboardNav({
619
+ focusedDate,
620
+ onFocusChange: (date) => {
621
+ picker.setFocusedDate(date);
622
+ picker.goToDate(date);
623
+ },
624
+ onSelect: (date) => picker.handleDayClick(date),
625
+ onClose: () => picker.close(),
626
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
627
+ minDate: pickerOptions.minDate,
628
+ maxDate: pickerOptions.maxDate,
629
+ disabled: pickerOptions.disabled
630
+ });
631
+ const startInputProps = picker.getStartInputProps();
632
+ const endInputProps = picker.getEndInputProps();
633
+ const popoverProps = picker.getPopoverProps();
634
+ const sizeStyles = getSizeStyles(size);
635
+ const presetsPanel = showPresets && picker.presets.length > 0 && /* @__PURE__ */ jsx("div", { className: `brdp-presets ${compact ? "brdp-presets--bottom" : ""}`, children: picker.presets.map((preset, i) => /* @__PURE__ */ jsx(
636
+ "button",
637
+ {
638
+ ...picker.getPresetButtonProps(preset),
639
+ className: `brdp-presets__item ${picker.activePresetIndex === i ? "brdp-presets__item--active" : ""}`,
640
+ children: preset.label
641
+ },
642
+ i
643
+ )) });
644
+ return /* @__PURE__ */ jsxs(
645
+ "div",
646
+ {
647
+ ref: containerRef,
648
+ className: `brdp-root brdp-root--range ${className ?? ""}`,
649
+ style: { ...sizeStyles, ...style },
650
+ dir: dir ?? picker.locale.dir,
651
+ children: [
652
+ /* @__PURE__ */ jsxs("div", { className: "brdp-range-input", children: [
653
+ /* @__PURE__ */ jsx(
654
+ "input",
655
+ {
656
+ ...startInputProps,
657
+ className: "brdp-input brdp-range-input__start"
658
+ }
659
+ ),
660
+ /* @__PURE__ */ jsx("span", { className: "brdp-range-input__separator", children: picker.separator }),
661
+ /* @__PURE__ */ jsx(
662
+ "input",
663
+ {
664
+ ...endInputProps,
665
+ className: "brdp-input brdp-range-input__end"
666
+ }
667
+ )
668
+ ] }),
669
+ /* @__PURE__ */ jsx(
670
+ Popover,
671
+ {
672
+ anchorRef: containerRef,
673
+ isOpen: picker.isOpen,
674
+ onClose: picker.close,
675
+ portal,
676
+ portalContainer,
677
+ ...popoverProps,
678
+ children: /* @__PURE__ */ jsxs("div", { className: "brdp-range-popover", style: compact ? { flexDirection: "column" } : void 0, children: [
679
+ !compact && presetsPosition === "left" && presetsPanel,
680
+ /* @__PURE__ */ jsx(
681
+ Calendar,
682
+ {
683
+ months: picker.months,
684
+ viewingYear: picker.viewingYear,
685
+ viewingMonth: picker.viewingMonth,
686
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
687
+ dayNames,
688
+ showWeekNumbers,
689
+ showOutsideDays,
690
+ focusedDate: picker.focusedDate,
691
+ onPrevMonth: picker.goToPrevMonth,
692
+ onNextMonth: picker.goToNextMonth,
693
+ onMonthSelect: (m) => picker.goToMonth(m),
694
+ onYearSelect: (y) => picker.goToYear(y),
695
+ minDate: pickerOptions.minDate,
696
+ maxDate: pickerOptions.maxDate,
697
+ onDayClick: (date) => picker.handleDayClick(date),
698
+ onDayMouseEnter: (date) => picker.setHoveredDate(date),
699
+ onDayMouseLeave: () => picker.setHoveredDate(null),
700
+ onKeyDown: handleKeyDown,
701
+ isSelected: picker.isSelected,
702
+ isDisabled: picker.isDateDisabled,
703
+ isHighlighted: picker.isDateHighlighted,
704
+ isRangeStart: picker.isRangeStart,
705
+ isRangeEnd: picker.isRangeEnd,
706
+ isInRange: picker.isInRange,
707
+ isInPreviewRange: picker.isInPreviewRange,
708
+ renderDay,
709
+ dir: dir ?? picker.locale.dir
710
+ }
711
+ ),
712
+ !compact && presetsPosition === "right" && presetsPanel,
713
+ compact && presetsPanel
714
+ ] })
715
+ }
716
+ )
717
+ ]
718
+ }
719
+ );
720
+ }
721
+ function TimePicker(props) {
722
+ const {
723
+ className,
724
+ style,
725
+ size,
726
+ portal = false,
727
+ portalContainer,
728
+ disabled = false,
729
+ clearable = false,
730
+ ...pickerOptions
731
+ } = props;
732
+ const picker = useTimePicker(pickerOptions);
733
+ const containerRef = useRef(null);
734
+ useClickOutside([containerRef], () => {
735
+ if (picker.isOpen) picker.close();
736
+ }, picker.isOpen);
737
+ const inputProps = picker.getInputProps();
738
+ const sizeStyles = getSizeStyles(size);
739
+ return /* @__PURE__ */ jsxs(
740
+ "div",
741
+ {
742
+ ref: containerRef,
743
+ className: `brdp-root brdp-root--time ${className ?? ""}`,
744
+ style: { ...sizeStyles, ...style },
745
+ children: [
746
+ /* @__PURE__ */ jsx(
747
+ "input",
748
+ {
749
+ ...inputProps,
750
+ className: "brdp-input brdp-input--time",
751
+ disabled
752
+ }
753
+ ),
754
+ /* @__PURE__ */ jsx(
755
+ Popover,
756
+ {
757
+ anchorRef: containerRef,
758
+ isOpen: picker.isOpen && !disabled,
759
+ onClose: picker.close,
760
+ portal,
761
+ portalContainer,
762
+ role: "listbox",
763
+ "aria-label": "Select time",
764
+ children: /* @__PURE__ */ jsxs("div", { className: "brdp-time", children: [
765
+ /* @__PURE__ */ jsx(
766
+ TimeColumn,
767
+ {
768
+ values: picker.availableHours,
769
+ activeValue: picker.hours,
770
+ onSelect: (v) => picker.setHours(v),
771
+ label: "Hours",
772
+ pad: picker.format === "24h",
773
+ isOpen: picker.isOpen && !disabled
774
+ }
775
+ ),
776
+ /* @__PURE__ */ jsx(
777
+ TimeColumn,
778
+ {
779
+ values: picker.availableMinutes,
780
+ activeValue: picker.minutes,
781
+ onSelect: (v) => picker.setMinutes(v),
782
+ label: "Minutes",
783
+ pad: true,
784
+ isOpen: picker.isOpen && !disabled
785
+ }
786
+ ),
787
+ picker.showSeconds && /* @__PURE__ */ jsx(
788
+ TimeColumn,
789
+ {
790
+ values: picker.availableSeconds,
791
+ activeValue: picker.seconds,
792
+ onSelect: (v) => picker.setSeconds(v),
793
+ label: "Seconds",
794
+ pad: true,
795
+ isOpen: picker.isOpen && !disabled
796
+ }
797
+ ),
798
+ picker.format === "12h" && /* @__PURE__ */ jsx("div", { className: "brdp-time__column", role: "listbox", "aria-label": "AM/PM", children: ["AM", "PM"].map((m) => /* @__PURE__ */ jsx(
799
+ "button",
800
+ {
801
+ type: "button",
802
+ className: `brdp-time__option ${picker.meridiem === m ? "brdp-time__option--active" : ""}`,
803
+ role: "option",
804
+ "aria-selected": picker.meridiem === m,
805
+ onClick: () => picker.setMeridiem(m),
806
+ children: m
807
+ },
808
+ m
809
+ )) })
810
+ ] })
811
+ }
812
+ )
813
+ ]
814
+ }
815
+ );
816
+ }
817
+ function TimeColumn({
818
+ values,
819
+ activeValue,
820
+ onSelect,
821
+ label,
822
+ pad = false,
823
+ isOpen = false
824
+ }) {
825
+ const activeRef = useRef(null);
826
+ const scrollToActive = useCallback(() => {
827
+ if (activeRef.current) {
828
+ activeRef.current.scrollIntoView({ block: "center", behavior: "smooth" });
829
+ }
830
+ }, []);
831
+ useEffect(() => {
832
+ if (isOpen) {
833
+ const timer = setTimeout(scrollToActive, 50);
834
+ return () => clearTimeout(timer);
835
+ }
836
+ }, [isOpen, scrollToActive]);
837
+ useEffect(() => {
838
+ scrollToActive();
839
+ }, [activeValue, scrollToActive]);
840
+ return /* @__PURE__ */ jsx("div", { className: "brdp-time__column", role: "listbox", "aria-label": label, children: values.map((v) => /* @__PURE__ */ jsx(
841
+ "button",
842
+ {
843
+ ref: activeValue === v ? activeRef : void 0,
844
+ type: "button",
845
+ className: `brdp-time__option ${activeValue === v ? "brdp-time__option--active" : ""}`,
846
+ role: "option",
847
+ "aria-selected": activeValue === v,
848
+ onClick: () => onSelect(v),
849
+ children: pad ? String(v).padStart(2, "0") : v
850
+ },
851
+ v
852
+ )) });
853
+ }
854
+ function DateTimePicker(props) {
855
+ const {
856
+ className,
857
+ style,
858
+ size,
859
+ renderDay,
860
+ portal = false,
861
+ portalContainer,
862
+ dir,
863
+ showOutsideDays = true,
864
+ dayNames,
865
+ ...pickerOptions
866
+ } = props;
867
+ const picker = useDateTimePicker(pickerOptions);
868
+ const containerRef = useRef(null);
869
+ useClickOutside([containerRef], () => {
870
+ if (picker.isOpen) picker.close();
871
+ }, picker.isOpen);
872
+ const focusedDate = picker.focusedDate ?? picker.selectedDate ?? /* @__PURE__ */ new Date();
873
+ const { handleKeyDown } = useKeyboardNav({
874
+ focusedDate,
875
+ onFocusChange: (date) => {
876
+ picker.setFocusedDate(date);
877
+ picker.goToDate(date);
878
+ },
879
+ onSelect: (date) => picker.selectDate(date),
880
+ onClose: () => picker.close(),
881
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
882
+ minDate: pickerOptions.minDate,
883
+ maxDate: pickerOptions.maxDate,
884
+ disabled: pickerOptions.disabled
885
+ });
886
+ const inputProps = picker.getInputProps();
887
+ const popoverProps = picker.getPopoverProps();
888
+ const sizeStyles = getSizeStyles(size);
889
+ const hours = generateHours(picker.timeFormat);
890
+ const minutes = generateMinutes(picker.minuteStep);
891
+ return /* @__PURE__ */ jsxs(
892
+ "div",
893
+ {
894
+ ref: containerRef,
895
+ className: `brdp-root brdp-root--datetime ${className ?? ""}`,
896
+ style: { ...sizeStyles, ...style },
897
+ dir: dir ?? picker.locale.dir,
898
+ children: [
899
+ /* @__PURE__ */ jsx(
900
+ "input",
901
+ {
902
+ ...inputProps,
903
+ value: picker.formattedValue,
904
+ className: "brdp-input"
905
+ }
906
+ ),
907
+ /* @__PURE__ */ jsx(
908
+ Popover,
909
+ {
910
+ anchorRef: containerRef,
911
+ isOpen: picker.isOpen,
912
+ onClose: picker.close,
913
+ portal,
914
+ portalContainer,
915
+ ...popoverProps,
916
+ children: /* @__PURE__ */ jsxs("div", { className: "brdp-datetime", children: [
917
+ /* @__PURE__ */ jsxs("div", { className: "brdp-datetime__tabs", children: [
918
+ /* @__PURE__ */ jsx(
919
+ "button",
920
+ {
921
+ type: "button",
922
+ className: `brdp-datetime__tab ${picker.activeTab === "date" ? "brdp-datetime__tab--active" : ""}`,
923
+ onClick: () => picker.setActiveTab("date"),
924
+ children: picker.locale.labels.startDate.replace("Start ", "")
925
+ }
926
+ ),
927
+ /* @__PURE__ */ jsx(
928
+ "button",
929
+ {
930
+ type: "button",
931
+ className: `brdp-datetime__tab ${picker.activeTab === "time" ? "brdp-datetime__tab--active" : ""}`,
932
+ onClick: () => picker.setActiveTab("time"),
933
+ children: picker.locale.labels.time
934
+ }
935
+ )
936
+ ] }),
937
+ picker.activeTab === "date" && /* @__PURE__ */ jsx(
938
+ Calendar,
939
+ {
940
+ months: picker.months,
941
+ viewingYear: picker.viewingYear,
942
+ viewingMonth: picker.viewingMonth,
943
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
944
+ dayNames,
945
+ showOutsideDays,
946
+ focusedDate: picker.focusedDate,
947
+ onPrevMonth: picker.goToPrevMonth,
948
+ onNextMonth: picker.goToNextMonth,
949
+ onMonthSelect: (m) => picker.goToMonth(m),
950
+ onYearSelect: (y) => picker.goToYear(y),
951
+ minDate: pickerOptions.minDate,
952
+ maxDate: pickerOptions.maxDate,
953
+ onDayClick: (date) => {
954
+ picker.selectDate(date);
955
+ picker.setActiveTab("time");
956
+ },
957
+ onKeyDown: handleKeyDown,
958
+ isSelected: picker.isSelected,
959
+ isDisabled: picker.isDateDisabled,
960
+ isHighlighted: picker.isDateHighlighted,
961
+ renderDay,
962
+ dir: dir ?? picker.locale.dir
963
+ }
964
+ ),
965
+ picker.activeTab === "time" && /* @__PURE__ */ jsxs("div", { className: "brdp-time", children: [
966
+ /* @__PURE__ */ jsx("div", { className: "brdp-time__column", role: "listbox", "aria-label": "Hours", children: hours.map((h) => /* @__PURE__ */ jsx(
967
+ "button",
968
+ {
969
+ type: "button",
970
+ className: `brdp-time__option ${picker.hours === h ? "brdp-time__option--active" : ""}`,
971
+ role: "option",
972
+ "aria-selected": picker.hours === h,
973
+ onClick: () => picker.setHours(h),
974
+ children: picker.timeFormat === "24h" ? String(h).padStart(2, "0") : h
975
+ },
976
+ h
977
+ )) }),
978
+ /* @__PURE__ */ jsx("div", { className: "brdp-time__column", role: "listbox", "aria-label": "Minutes", children: minutes.map((m) => /* @__PURE__ */ jsx(
979
+ "button",
980
+ {
981
+ type: "button",
982
+ className: `brdp-time__option ${picker.minutes === m ? "brdp-time__option--active" : ""}`,
983
+ role: "option",
984
+ "aria-selected": picker.minutes === m,
985
+ onClick: () => picker.setMinutes(m),
986
+ children: String(m).padStart(2, "0")
987
+ },
988
+ m
989
+ )) }),
990
+ picker.timeFormat === "12h" && /* @__PURE__ */ jsx("div", { className: "brdp-time__column", role: "listbox", "aria-label": "AM/PM", children: ["AM", "PM"].map((m) => /* @__PURE__ */ jsx(
991
+ "button",
992
+ {
993
+ type: "button",
994
+ className: `brdp-time__option ${picker.meridiem === m ? "brdp-time__option--active" : ""}`,
995
+ role: "option",
996
+ "aria-selected": picker.meridiem === m,
997
+ onClick: () => picker.setMeridiem(m),
998
+ children: m
999
+ },
1000
+ m
1001
+ )) })
1002
+ ] }),
1003
+ /* @__PURE__ */ jsx("div", { className: "brdp-footer", children: /* @__PURE__ */ jsx(
1004
+ "button",
1005
+ {
1006
+ type: "button",
1007
+ className: "brdp-footer__btn brdp-footer__btn--apply",
1008
+ onClick: () => picker.close(),
1009
+ children: picker.locale.labels.apply
1010
+ }
1011
+ ) })
1012
+ ] })
1013
+ }
1014
+ )
1015
+ ]
1016
+ }
1017
+ );
1018
+ }
1019
+ function MonthPicker(props) {
1020
+ const {
1021
+ className,
1022
+ style,
1023
+ size,
1024
+ placeholder,
1025
+ portal = false,
1026
+ portalContainer,
1027
+ clearable = false,
1028
+ ...pickerOptions
1029
+ } = props;
1030
+ const picker = useMonthPicker(pickerOptions);
1031
+ const containerRef = useRef(null);
1032
+ useClickOutside([containerRef], () => {
1033
+ if (picker.isOpen) picker.close();
1034
+ }, picker.isOpen);
1035
+ const inputProps = picker.getInputProps();
1036
+ const sizeStyles = getSizeStyles(size);
1037
+ return /* @__PURE__ */ jsxs(
1038
+ "div",
1039
+ {
1040
+ ref: containerRef,
1041
+ className: `brdp-root brdp-root--month ${className ?? ""}`,
1042
+ style: { ...sizeStyles, ...style },
1043
+ children: [
1044
+ /* @__PURE__ */ jsx(
1045
+ "input",
1046
+ {
1047
+ ...inputProps,
1048
+ className: "brdp-input",
1049
+ placeholder
1050
+ }
1051
+ ),
1052
+ /* @__PURE__ */ jsx(
1053
+ Popover,
1054
+ {
1055
+ anchorRef: containerRef,
1056
+ isOpen: picker.isOpen,
1057
+ onClose: picker.close,
1058
+ portal,
1059
+ portalContainer,
1060
+ role: "dialog",
1061
+ "aria-modal": true,
1062
+ "aria-label": "Select month",
1063
+ children: /* @__PURE__ */ jsxs("div", { className: "brdp-month-picker", children: [
1064
+ /* @__PURE__ */ jsxs("div", { className: "brdp-header", children: [
1065
+ /* @__PURE__ */ jsx(
1066
+ "button",
1067
+ {
1068
+ type: "button",
1069
+ className: "brdp-header__nav-btn",
1070
+ onClick: picker.goToPrevYear,
1071
+ "aria-label": picker.locale.labels.previousYear,
1072
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
1073
+ }
1074
+ ),
1075
+ /* @__PURE__ */ jsx("span", { className: "brdp-header__label", children: picker.viewingYear }),
1076
+ /* @__PURE__ */ jsx(
1077
+ "button",
1078
+ {
1079
+ type: "button",
1080
+ className: "brdp-header__nav-btn",
1081
+ onClick: picker.goToNextYear,
1082
+ "aria-label": picker.locale.labels.nextYear,
1083
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
1084
+ }
1085
+ )
1086
+ ] }),
1087
+ /* @__PURE__ */ jsx("div", { className: "brdp-month-grid", role: "grid", children: picker.monthGrid.map((item) => /* @__PURE__ */ jsx(
1088
+ "button",
1089
+ {
1090
+ ...picker.getMonthButtonProps(item.month),
1091
+ className: `brdp-month-grid__cell ${item.isSelected ? "brdp-month-grid__cell--selected" : ""} ${item.isDisabled ? "brdp-month-grid__cell--disabled" : ""}`,
1092
+ children: item.label
1093
+ },
1094
+ item.month
1095
+ )) })
1096
+ ] })
1097
+ }
1098
+ )
1099
+ ]
1100
+ }
1101
+ );
1102
+ }
1103
+ function YearPicker(props) {
1104
+ const {
1105
+ className,
1106
+ style,
1107
+ size,
1108
+ placeholder,
1109
+ portal = false,
1110
+ portalContainer,
1111
+ ...pickerOptions
1112
+ } = props;
1113
+ const picker = useYearPicker(pickerOptions);
1114
+ const containerRef = useRef(null);
1115
+ useClickOutside([containerRef], () => {
1116
+ if (picker.isOpen) picker.close();
1117
+ }, picker.isOpen);
1118
+ const inputProps = picker.getInputProps();
1119
+ const sizeStyles = getSizeStyles(size);
1120
+ const lastYear = picker.years[picker.years.length - 1]?.year ?? 0;
1121
+ return /* @__PURE__ */ jsxs(
1122
+ "div",
1123
+ {
1124
+ ref: containerRef,
1125
+ className: `brdp-root brdp-root--year ${className ?? ""}`,
1126
+ style: { ...sizeStyles, ...style },
1127
+ children: [
1128
+ /* @__PURE__ */ jsx(
1129
+ "input",
1130
+ {
1131
+ ...inputProps,
1132
+ className: "brdp-input",
1133
+ placeholder: placeholder ?? "Select year"
1134
+ }
1135
+ ),
1136
+ /* @__PURE__ */ jsx(
1137
+ Popover,
1138
+ {
1139
+ anchorRef: containerRef,
1140
+ isOpen: picker.isOpen,
1141
+ onClose: picker.close,
1142
+ portal,
1143
+ portalContainer,
1144
+ role: "dialog",
1145
+ "aria-modal": true,
1146
+ "aria-label": "Select year",
1147
+ children: /* @__PURE__ */ jsxs("div", { className: "brdp-year-picker", children: [
1148
+ /* @__PURE__ */ jsxs("div", { className: "brdp-header", children: [
1149
+ /* @__PURE__ */ jsx(
1150
+ "button",
1151
+ {
1152
+ type: "button",
1153
+ className: "brdp-header__nav-btn",
1154
+ onClick: picker.goToPrevDecade,
1155
+ "aria-label": "Previous years",
1156
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ jsxs("span", { className: "brdp-header__label", children: [
1160
+ picker.decadeStart,
1161
+ " \u2013 ",
1162
+ lastYear
1163
+ ] }),
1164
+ /* @__PURE__ */ jsx(
1165
+ "button",
1166
+ {
1167
+ type: "button",
1168
+ className: "brdp-header__nav-btn",
1169
+ onClick: picker.goToNextDecade,
1170
+ "aria-label": "Next years",
1171
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
1172
+ }
1173
+ )
1174
+ ] }),
1175
+ /* @__PURE__ */ jsx("div", { className: "brdp-year-grid", role: "grid", children: picker.years.map((item) => /* @__PURE__ */ jsx(
1176
+ "button",
1177
+ {
1178
+ ...picker.getYearButtonProps(item.year),
1179
+ className: `brdp-year-grid__cell ${item.isSelected ? "brdp-year-grid__cell--selected" : ""} ${item.isCurrentYear ? "brdp-year-grid__cell--current" : ""} ${item.isDisabled ? "brdp-year-grid__cell--disabled" : ""}`,
1180
+ children: item.year
1181
+ },
1182
+ item.year
1183
+ )) })
1184
+ ] })
1185
+ }
1186
+ )
1187
+ ]
1188
+ }
1189
+ );
1190
+ }
1191
+ function WeekPicker(props) {
1192
+ const {
1193
+ className,
1194
+ style,
1195
+ size,
1196
+ placeholder,
1197
+ portal = false,
1198
+ portalContainer,
1199
+ dir,
1200
+ showOutsideDays = true,
1201
+ dayNames,
1202
+ ...pickerOptions
1203
+ } = props;
1204
+ const picker = useWeekPicker(pickerOptions);
1205
+ const containerRef = useRef(null);
1206
+ useClickOutside([containerRef], () => {
1207
+ if (picker.isOpen) picker.close();
1208
+ }, picker.isOpen);
1209
+ const focusedDate = picker.focusedDate ?? picker.selectedWeek?.start ?? /* @__PURE__ */ new Date();
1210
+ const { handleKeyDown } = useKeyboardNav({
1211
+ focusedDate,
1212
+ onFocusChange: (date) => {
1213
+ picker.setFocusedDate(date);
1214
+ picker.goToDate(date);
1215
+ },
1216
+ onSelect: (date) => picker.selectWeek(date),
1217
+ onClose: () => picker.close(),
1218
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
1219
+ minDate: pickerOptions.minDate,
1220
+ maxDate: pickerOptions.maxDate,
1221
+ disabled: pickerOptions.disabled
1222
+ });
1223
+ const inputProps = picker.getInputProps();
1224
+ const sizeStyles = getSizeStyles(size);
1225
+ return /* @__PURE__ */ jsxs(
1226
+ "div",
1227
+ {
1228
+ ref: containerRef,
1229
+ className: `brdp-root brdp-root--week ${className ?? ""}`,
1230
+ style: { ...sizeStyles, ...style },
1231
+ dir: dir ?? picker.locale.dir,
1232
+ children: [
1233
+ /* @__PURE__ */ jsx(
1234
+ "input",
1235
+ {
1236
+ ...inputProps,
1237
+ className: "brdp-input",
1238
+ placeholder: placeholder ?? "Select week"
1239
+ }
1240
+ ),
1241
+ /* @__PURE__ */ jsx(
1242
+ Popover,
1243
+ {
1244
+ anchorRef: containerRef,
1245
+ isOpen: picker.isOpen,
1246
+ onClose: picker.close,
1247
+ portal,
1248
+ portalContainer,
1249
+ role: "dialog",
1250
+ "aria-modal": true,
1251
+ "aria-label": "Select week",
1252
+ children: /* @__PURE__ */ jsx(
1253
+ Calendar,
1254
+ {
1255
+ months: picker.months,
1256
+ viewingYear: picker.viewingYear,
1257
+ viewingMonth: picker.viewingMonth,
1258
+ weekStartsOn: pickerOptions.weekStartsOn ?? picker.locale.weekStartsOn,
1259
+ dayNames,
1260
+ showWeekNumbers: true,
1261
+ showOutsideDays,
1262
+ focusedDate: picker.focusedDate,
1263
+ onPrevMonth: picker.goToPrevMonth,
1264
+ onNextMonth: picker.goToNextMonth,
1265
+ onMonthSelect: (m) => picker.goToMonth(m),
1266
+ onYearSelect: (y) => picker.goToYear(y),
1267
+ minDate: pickerOptions.minDate,
1268
+ maxDate: pickerOptions.maxDate,
1269
+ onDayClick: (date) => {
1270
+ picker.selectWeek(date);
1271
+ picker.close();
1272
+ },
1273
+ onKeyDown: handleKeyDown,
1274
+ isSelected: (date) => picker.isInSelectedWeek(date),
1275
+ isDisabled: picker.isDateDisabled,
1276
+ isHighlighted: picker.isDateHighlighted,
1277
+ dir: dir ?? picker.locale.dir
1278
+ }
1279
+ )
1280
+ }
1281
+ )
1282
+ ]
1283
+ }
1284
+ );
1285
+ }
1286
+ var hiddenStyle = {
1287
+ position: "absolute",
1288
+ width: 1,
1289
+ height: 1,
1290
+ padding: 0,
1291
+ margin: -1,
1292
+ overflow: "hidden",
1293
+ clip: "rect(0, 0, 0, 0)",
1294
+ whiteSpace: "nowrap",
1295
+ borderWidth: 0
1296
+ };
1297
+ function VisuallyHidden({ children }) {
1298
+ return /* @__PURE__ */ jsx("span", { style: hiddenStyle, children });
1299
+ }
1300
+
1301
+ export { Calendar, CalendarDay, CalendarGrid, CalendarHeader, DatePicker, DateTimePicker, LiveRegion, MonthPicker, Popover, Portal, RangePicker, TimePicker, VisuallyHidden, WeekPicker, YearPicker, getSizeStyles };
1302
+ //# sourceMappingURL=index.js.map
1303
+ //# sourceMappingURL=index.js.map