@entur/datepicker 11.7.0 → 11.8.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.
@@ -304,9 +304,158 @@ const CalendarButton = ({
304
304
  const { buttonProps } = button.useButton(props, ref);
305
305
  return /* @__PURE__ */ jsxRuntime.jsx(button$1.IconButton, { ...buttonProps, ref, className, style, children });
306
306
  };
307
+ const CalendarGrid = ({
308
+ state,
309
+ startDate,
310
+ navigationDescription,
311
+ showWeekNumbers,
312
+ weekNumberHeader,
313
+ renderCell
314
+ }) => {
315
+ const calendarGridId = utils.useRandomId("eds-calendar");
316
+ const { locale } = i18n.useLocale();
317
+ const gridStartDate = startDate ?? state.visibleRange.start;
318
+ const { gridProps, headerProps, weekDays } = calendar.useCalendarGrid(
319
+ { startDate: gridStartDate },
320
+ state
321
+ );
322
+ const weeksInMonth = date.getWeeksInMonth(gridStartDate, locale);
323
+ const weeksArray = Array.from(Array(weeksInMonth).keys());
324
+ const weekDaysMapped = () => {
325
+ if (locale.toLowerCase().includes("no"))
326
+ return ["ma", "ti", "on", "to", "fr", "lø", "sø"];
327
+ if (locale.toLowerCase().includes("en")) {
328
+ if (weekDays[0] === "M")
329
+ return ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
330
+ if (weekDays[0] === "S")
331
+ return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
332
+ }
333
+ return weekDays.map((day) => day.toLowerCase());
334
+ };
335
+ const getNavigationDescription = () => {
336
+ if (navigationDescription) return navigationDescription;
337
+ if (locale.toLowerCase().includes("en"))
338
+ return "Use the arrow keys to navigate between dates";
339
+ return "Bruk piltastene til å navigere mellom datoer";
340
+ };
341
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
342
+ /* @__PURE__ */ jsxRuntime.jsxs(
343
+ "table",
344
+ {
345
+ ...gridProps,
346
+ cellSpacing: "0",
347
+ className: "eds-datepicker__calendar__grid",
348
+ children: [
349
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { ...headerProps, children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
350
+ showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx("th", { className: "eds-datepicker__calendar__grid__weeknumber-header", children: weekNumberHeader }),
351
+ weekDaysMapped().map((day) => /* @__PURE__ */ jsxRuntime.jsx("th", { children: day }, day))
352
+ ] }) }),
353
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeksArray.map((weekIndex) => {
354
+ const weekNumber = getWeekNumberForDate(
355
+ state.getDatesInWeek(weekIndex, gridStartDate)[0]
356
+ );
357
+ const weekNumberString = showWeekNumbers ? `, ${weekNumberHeader} ${weekNumber},` : "";
358
+ return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
359
+ showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx(
360
+ "th",
361
+ {
362
+ "aria-label": `${weekNumberHeader} ${weekNumber}`,
363
+ className: "eds-datepicker__calendar__grid__weeknumber",
364
+ children: weekNumber
365
+ }
366
+ ),
367
+ state.getDatesInWeek(weekIndex, gridStartDate).map(
368
+ (date2, i) => date2 ? renderCell(
369
+ date2,
370
+ gridStartDate,
371
+ weekNumberString,
372
+ calendarGridId + "description"
373
+ ) : /* @__PURE__ */ jsxRuntime.jsx("td", {}, i)
374
+ )
375
+ ] }, weekIndex);
376
+ }) })
377
+ ]
378
+ }
379
+ ),
380
+ /* @__PURE__ */ jsxRuntime.jsx(a11y.VisuallyHidden, { id: calendarGridId + "description", children: getNavigationDescription() })
381
+ ] });
382
+ };
383
+ const CalendarBase = ({
384
+ state,
385
+ calendarProps,
386
+ prevButtonProps,
387
+ nextButtonProps,
388
+ title,
389
+ calendarRef,
390
+ style,
391
+ className,
392
+ navigationDescription,
393
+ showWeekNumbers,
394
+ weekNumberHeader,
395
+ renderCell
396
+ }) => {
397
+ const { locale } = i18n.useLocale();
398
+ const monthCount = state.visibleRange.end.month - state.visibleRange.start.month + 1 + (state.visibleRange.end.year - state.visibleRange.start.year) * 12;
399
+ const getMonthTitle = (startDate) => new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(
400
+ new Date(startDate.year, startDate.month - 1)
401
+ );
402
+ return /* @__PURE__ */ jsxRuntime.jsx(
403
+ "div",
404
+ {
405
+ ...calendarProps,
406
+ ref: calendarRef,
407
+ className: classNames("eds-datepicker__calendar", className),
408
+ style,
409
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eds-datepicker__calendar__grids", children: Array.from({ length: monthCount }, (_, i) => {
410
+ const startDate = state.visibleRange.start.add({ months: i });
411
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-datepicker__calendar__month", children: [
412
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-datepicker__calendar__header", children: [
413
+ i === 0 && /* @__PURE__ */ jsxRuntime.jsx(
414
+ CalendarButton,
415
+ {
416
+ ...prevButtonProps,
417
+ "aria-label": ariaLabelIfNorwegian(
418
+ "Forrige måned",
419
+ locale,
420
+ prevButtonProps
421
+ ),
422
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.LeftArrowIcon, { size: 20 })
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { children: monthCount > 1 ? getMonthTitle(startDate) : title }),
426
+ i === monthCount - 1 && /* @__PURE__ */ jsxRuntime.jsx(
427
+ CalendarButton,
428
+ {
429
+ ...nextButtonProps,
430
+ "aria-label": ariaLabelIfNorwegian(
431
+ "Neste måned",
432
+ locale,
433
+ nextButtonProps
434
+ ),
435
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.RightArrowIcon, { size: 20 })
436
+ }
437
+ )
438
+ ] }),
439
+ /* @__PURE__ */ jsxRuntime.jsx(
440
+ CalendarGrid,
441
+ {
442
+ state,
443
+ startDate,
444
+ navigationDescription,
445
+ showWeekNumbers,
446
+ weekNumberHeader,
447
+ renderCell
448
+ }
449
+ )
450
+ ] }, i);
451
+ }) })
452
+ }
453
+ );
454
+ };
307
455
  const CalendarCell = ({
308
456
  state,
309
457
  date: date$1,
458
+ currentMonth,
310
459
  showOutsideMonth = false,
311
460
  onSelectedCellClick = () => {
312
461
  return;
@@ -330,6 +479,8 @@ const CalendarCell = ({
330
479
  formattedDate
331
480
  } = calendar.useCalendarCell({ date: date$1 }, state, cellRef);
332
481
  const ariaLabel = `${buttonProps["aria-label"]}${weekNumberString} ${ariaLabelForDate?.(date$1) ?? ""}`;
482
+ const isOverflowDate = date$1.month !== currentMonth.month || date$1.year !== currentMonth.year;
483
+ const isBetweenVisibleMonths = isOverflowDate && !isOutsideVisibleRange;
333
484
  const cellCanBeSelected = showOutsideMonth ? !(isDisabled || isUnavailable) : !(isOutsideVisibleRange || isDisabled || isUnavailable);
334
485
  const shouldHideDate = !showOutsideMonth && isOutsideVisibleRange;
335
486
  const extendedButtonProps = {
@@ -345,21 +496,31 @@ const CalendarCell = ({
345
496
  onCellClick();
346
497
  }
347
498
  }
499
+ },
500
+ ...isBetweenVisibleMonths && {
501
+ tabIndex: -1,
502
+ role: "presentation",
503
+ onClick: void 0,
504
+ onKeyDown: void 0,
505
+ onKeyUp: void 0,
506
+ onPointerDown: void 0,
507
+ onFocus: void 0
348
508
  }
349
509
  };
350
510
  return /* @__PURE__ */ jsxRuntime.jsx("td", { ...cellProps, className: "eds-datepicker__calendar__grid__cell__td", children: /* @__PURE__ */ jsxRuntime.jsx(
351
511
  "div",
352
512
  {
353
513
  ...extendedButtonProps,
354
- "aria-label": ariaLabel,
355
- "aria-hidden": shouldHideDate,
514
+ "aria-label": isBetweenVisibleMonths ? void 0 : ariaLabel,
515
+ "aria-hidden": shouldHideDate || isBetweenVisibleMonths,
356
516
  ref: cellRef,
357
517
  hidden: shouldHideDate,
358
518
  className: classNames("eds-datepicker__calendar__grid__cell", {
359
519
  [classNameForDate?.(date$1) ?? ""]: !shouldHideDate,
360
- "eds-datepicker__calendar__grid__cell--selected": isSelected,
520
+ "eds-datepicker__calendar__grid__cell--selected": isSelected && !isOverflowDate,
361
521
  "eds-datepicker__calendar__grid__cell--disabled": isDisabled || isUnavailable,
362
522
  "eds-datepicker__calendar__grid__cell--outside-month": isOutsideVisibleRange && !showOutsideMonth,
523
+ "eds-datepicker__calendar__grid__cell--between-months": isBetweenVisibleMonths,
363
524
  "eds-datepicker__calendar__grid__cell--outside-month--visible": isOutsideVisibleRange && showOutsideMonth,
364
525
  "eds-datepicker__calendar__grid__cell--today": date.isEqualDay(
365
526
  date$1,
@@ -368,11 +529,13 @@ const CalendarCell = ({
368
529
  }),
369
530
  ...rest,
370
531
  onClick: (e) => {
532
+ if (isBetweenVisibleMonths) return;
371
533
  extendedButtonProps?.onClick?.(e);
372
534
  isSelected && onSelectedCellClick();
373
535
  cellCanBeSelected && onCellClick();
374
536
  },
375
537
  onKeyUp: (e) => {
538
+ if (isBetweenVisibleMonths) return;
376
539
  extendedButtonProps?.onKeyUp?.(e);
377
540
  if (e.key === "Enter") {
378
541
  isSelected && onSelectedCellClick();
@@ -383,103 +546,15 @@ const CalendarCell = ({
383
546
  }
384
547
  ) });
385
548
  };
386
- const CalendarGrid = ({
387
- state,
388
- navigationDescription,
389
- onSelectedCellClick = () => {
390
- return;
391
- },
392
- onCellClick = () => {
393
- return;
394
- },
395
- showWeekNumbers,
396
- weekNumberHeader,
397
- showOutsideMonth = false,
398
- classNameForDate,
399
- ariaLabelForDate,
400
- ...rest
401
- }) => {
402
- const calendarGridId = utils.useRandomId("eds-calendar");
403
- const { locale } = i18n.useLocale();
404
- const { gridProps, headerProps, weekDays } = calendar.useCalendarGrid(rest, state);
405
- const weeksInMonth = date.getWeeksInMonth(state.visibleRange.start, locale);
406
- const weeksArray = Array.from(Array(weeksInMonth).keys());
407
- const weekDaysMapped = () => {
408
- if (locale.toLowerCase().includes("no"))
409
- return ["ma", "ti", "on", "to", "fr", "lø", "sø"];
410
- if (locale.toLowerCase().includes("en")) {
411
- if (weekDays[0] === "M")
412
- return ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
413
- if (weekDays[0] === "S")
414
- return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
415
- }
416
- return weekDays.map((day) => day.toLowerCase());
417
- };
418
- const getNavigationDescription = () => {
419
- if (navigationDescription) return navigationDescription;
420
- if (locale.toLowerCase().includes("en"))
421
- return "Use the arrow keys to navigate between dates";
422
- return "Bruk piltastene til å navigere mellom datoer";
423
- };
424
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
425
- /* @__PURE__ */ jsxRuntime.jsxs(
426
- "table",
427
- {
428
- ...gridProps,
429
- cellSpacing: "0",
430
- className: "eds-datepicker__calendar__grid",
431
- children: [
432
- /* @__PURE__ */ jsxRuntime.jsx("thead", { ...headerProps, children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
433
- showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx("th", { className: "eds-datepicker__calendar__grid__weeknumber-header", children: weekNumberHeader }),
434
- weekDaysMapped().map((day) => /* @__PURE__ */ jsxRuntime.jsx("th", { children: day }, day))
435
- ] }) }),
436
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeksArray.map((weekIndex) => {
437
- const weekNumber = getWeekNumberForDate(
438
- state.getDatesInWeek(weekIndex)[0]
439
- );
440
- return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
441
- showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx(
442
- "th",
443
- {
444
- "aria-label": `${weekNumberHeader} ${weekNumber}`,
445
- className: "eds-datepicker__calendar__grid__weeknumber",
446
- children: weekNumber
447
- }
448
- ),
449
- state.getDatesInWeek(weekIndex).map(
450
- (date2, i) => date2 ? /* @__PURE__ */ jsxRuntime.jsx(
451
- CalendarCell,
452
- {
453
- state,
454
- date: date2,
455
- "aria-describedby": calendarGridId + "description",
456
- weekNumberString: showWeekNumbers ? `, ${weekNumberHeader} ${weekNumber},` : "",
457
- onSelectedCellClick,
458
- onCellClick,
459
- classNameForDate,
460
- ariaLabelForDate,
461
- showOutsideMonth
462
- },
463
- `${date2.month}.${date2.day}`
464
- ) : /* @__PURE__ */ jsxRuntime.jsx("td", {}, i)
465
- )
466
- ] }, weekIndex);
467
- }) })
468
- ]
469
- }
470
- ),
471
- /* @__PURE__ */ jsxRuntime.jsx(a11y.VisuallyHidden, { id: calendarGridId + "description", children: getNavigationDescription() })
472
- ] });
473
- };
474
549
  const Calendar = ({
475
550
  locale: localOverride,
476
551
  ...rest
477
552
  }) => {
478
553
  const props = { isDisabled: rest.disabled, ...rest };
479
554
  const { locale } = i18n.useLocale();
480
- return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(CalendarBase, { ...props }) });
555
+ return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(_Calendar, { ...props }) });
481
556
  };
482
- const CalendarBase = ({
557
+ const _Calendar = ({
483
558
  selectedDate,
484
559
  onChange,
485
560
  minDate,
@@ -487,6 +562,7 @@ const CalendarBase = ({
487
562
  showWeekNumbers = false,
488
563
  weekNumberHeader = "uke",
489
564
  showOutsideMonth = false,
565
+ visibleDuration,
490
566
  forcedReturnType,
491
567
  style,
492
568
  className,
@@ -515,7 +591,8 @@ const CalendarBase = ({
515
591
  locale,
516
592
  createCalendar,
517
593
  minValue: minDate,
518
- maxValue: getAdjustedMaxDate(maxDate)
594
+ maxValue: getAdjustedMaxDate(maxDate),
595
+ visibleDuration
519
596
  };
520
597
  const state = calendar$1.useCalendarState(_props);
521
598
  const { calendarProps, prevButtonProps, nextButtonProps, title } = calendar.useCalendar(_props, state);
@@ -523,57 +600,36 @@ const CalendarBase = ({
523
600
  () => rest.onValidate?.(!state.isValueInvalid),
524
601
  [state.isValueInvalid]
525
602
  );
526
- return /* @__PURE__ */ jsxRuntime.jsxs(
527
- "div",
603
+ return /* @__PURE__ */ jsxRuntime.jsx(
604
+ CalendarBase,
528
605
  {
529
- ...calendarProps,
530
- ref: calendarRef,
531
- className: classNames("eds-datepicker__calendar", className),
606
+ state,
607
+ calendarProps,
608
+ prevButtonProps,
609
+ nextButtonProps,
610
+ title,
611
+ calendarRef,
532
612
  style,
533
- children: [
534
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-datepicker__calendar__header", children: [
535
- /* @__PURE__ */ jsxRuntime.jsx(
536
- CalendarButton,
537
- {
538
- ...prevButtonProps,
539
- "aria-label": ariaLabelIfNorwegian(
540
- "Forrige måned",
541
- locale,
542
- prevButtonProps
543
- ),
544
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.LeftArrowIcon, { size: 20 })
545
- }
546
- ),
547
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: title }),
548
- /* @__PURE__ */ jsxRuntime.jsx(
549
- CalendarButton,
550
- {
551
- ...nextButtonProps,
552
- "aria-label": ariaLabelIfNorwegian(
553
- "Neste måned",
554
- locale,
555
- nextButtonProps
556
- ),
557
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.RightArrowIcon, { size: 20 })
558
- }
559
- )
560
- ] }),
561
- /* @__PURE__ */ jsxRuntime.jsx(
562
- CalendarGrid,
563
- {
564
- ...rest,
565
- state,
566
- navigationDescription,
567
- onSelectedCellClick,
568
- onCellClick,
569
- classNameForDate,
570
- ariaLabelForDate,
571
- showWeekNumbers,
572
- weekNumberHeader,
573
- showOutsideMonth
574
- }
575
- )
576
- ]
613
+ className,
614
+ navigationDescription,
615
+ showWeekNumbers,
616
+ weekNumberHeader,
617
+ renderCell: (date2, currentMonth, weekNumberString, ariaDescribedBy) => /* @__PURE__ */ jsxRuntime.jsx(
618
+ CalendarCell,
619
+ {
620
+ state,
621
+ date: date2,
622
+ currentMonth,
623
+ "aria-describedby": ariaDescribedBy,
624
+ weekNumberString,
625
+ onSelectedCellClick,
626
+ onCellClick,
627
+ classNameForDate,
628
+ ariaLabelForDate,
629
+ showOutsideMonth
630
+ },
631
+ `${date2.month}.${date2.day}`
632
+ )
577
633
  }
578
634
  );
579
635
  };
@@ -651,101 +707,15 @@ const RangeCalendarCell = ({
651
707
  }
652
708
  ) });
653
709
  };
654
- const RangeCalendarGrid = ({
655
- state,
656
- startDate,
657
- navigationDescription,
658
- showWeekNumbers,
659
- weekNumberHeader,
660
- showOutsideMonth = false,
661
- classNameForDate,
662
- ariaLabelForDate,
663
- ...rest
664
- }) => {
665
- const calendarGridId = utils.useRandomId("eds-calendar");
666
- const { locale } = i18n.useLocale();
667
- const gridStartDate = startDate ?? state.visibleRange.start;
668
- const { gridProps, headerProps, weekDays } = calendar.useCalendarGrid(
669
- { ...rest, startDate: gridStartDate },
670
- state
671
- );
672
- const weeksInMonth = date.getWeeksInMonth(gridStartDate, locale);
673
- const weeksArray = Array.from(Array(weeksInMonth).keys());
674
- const weekDaysMapped = () => {
675
- if (locale.toLowerCase().includes("no"))
676
- return ["ma", "ti", "on", "to", "fr", "lø", "sø"];
677
- if (locale.toLowerCase().includes("en")) {
678
- if (weekDays[0] === "M")
679
- return ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
680
- if (weekDays[0] === "S")
681
- return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
682
- }
683
- return weekDays.map((day) => day.toLowerCase());
684
- };
685
- const getNavigationDescription = () => {
686
- if (navigationDescription) return navigationDescription;
687
- if (locale.toLowerCase().includes("en"))
688
- return "Use the arrow keys to navigate between dates";
689
- return "Bruk piltastene til å navigere mellom datoer";
690
- };
691
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
692
- /* @__PURE__ */ jsxRuntime.jsxs(
693
- "table",
694
- {
695
- ...gridProps,
696
- cellSpacing: "0",
697
- className: "eds-datepicker__calendar__grid",
698
- children: [
699
- /* @__PURE__ */ jsxRuntime.jsx("thead", { ...headerProps, children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
700
- showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx("th", { className: "eds-datepicker__calendar__grid__weeknumber-header", children: weekNumberHeader }),
701
- weekDaysMapped().map((day) => /* @__PURE__ */ jsxRuntime.jsx("th", { children: day }, day))
702
- ] }) }),
703
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeksArray.map((weekIndex) => {
704
- const weekNumber = getWeekNumberForDate(
705
- state.getDatesInWeek(weekIndex, gridStartDate)[0]
706
- );
707
- return /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
708
- showWeekNumbers && /* @__PURE__ */ jsxRuntime.jsx(
709
- "th",
710
- {
711
- "aria-label": `${weekNumberHeader} ${weekNumber}`,
712
- className: "eds-datepicker__calendar__grid__weeknumber",
713
- children: weekNumber
714
- }
715
- ),
716
- state.getDatesInWeek(weekIndex, gridStartDate).map(
717
- (date2, i) => date2 ? /* @__PURE__ */ jsxRuntime.jsx(
718
- RangeCalendarCell,
719
- {
720
- state,
721
- date: date2,
722
- currentMonth: gridStartDate,
723
- "aria-describedby": calendarGridId + "description",
724
- weekNumberString: showWeekNumbers ? `, ${weekNumberHeader} ${weekNumber},` : "",
725
- classNameForDate,
726
- ariaLabelForDate,
727
- showOutsideMonth
728
- },
729
- `${date2.month}.${date2.day}`
730
- ) : /* @__PURE__ */ jsxRuntime.jsx("td", {}, i)
731
- )
732
- ] }, weekIndex);
733
- }) })
734
- ]
735
- }
736
- ),
737
- /* @__PURE__ */ jsxRuntime.jsx(a11y.VisuallyHidden, { id: calendarGridId + "description", children: getNavigationDescription() })
738
- ] });
739
- };
740
710
  const RangeCalendar = ({
741
711
  locale: localOverride,
742
712
  ...rest
743
713
  }) => {
744
714
  const props = { isDisabled: rest.disabled, ...rest };
745
715
  const { locale } = i18n.useLocale();
746
- return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(RangeCalendarBase, { ...props }) });
716
+ return /* @__PURE__ */ jsxRuntime.jsx(i18n.I18nProvider, { locale: localOverride ?? locale, children: /* @__PURE__ */ jsxRuntime.jsx(_RangeCalendar, { ...props }) });
747
717
  };
748
- const RangeCalendarBase = ({
718
+ const _RangeCalendar = ({
749
719
  value,
750
720
  onChange,
751
721
  minDate,
@@ -781,63 +751,34 @@ const RangeCalendarBase = ({
781
751
  () => rest.onValidate?.(!state.isValueInvalid),
782
752
  [state.isValueInvalid]
783
753
  );
784
- const monthCount = state.visibleRange.end.month - state.visibleRange.start.month + 1 + (state.visibleRange.end.year - state.visibleRange.start.year) * 12;
785
- const getMonthTitle = (startDate) => new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(
786
- new Date(startDate.year, startDate.month - 1)
787
- );
788
754
  return /* @__PURE__ */ jsxRuntime.jsx(
789
- "div",
755
+ CalendarBase,
790
756
  {
791
- ...calendarProps,
792
- ref,
793
- className: classNames("eds-datepicker__calendar", className),
757
+ state,
758
+ calendarProps,
759
+ prevButtonProps,
760
+ nextButtonProps,
761
+ title,
762
+ calendarRef: ref,
794
763
  style,
795
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eds-datepicker__calendar__grids", children: Array.from({ length: monthCount }, (_, i) => {
796
- const startDate = state.visibleRange.start.add({ months: i });
797
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-datepicker__calendar__month", children: [
798
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "eds-datepicker__calendar__header", children: [
799
- i === 0 && /* @__PURE__ */ jsxRuntime.jsx(
800
- CalendarButton,
801
- {
802
- ...prevButtonProps,
803
- "aria-label": ariaLabelIfNorwegian(
804
- "Forrige måned",
805
- locale,
806
- prevButtonProps
807
- ),
808
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.LeftArrowIcon, { size: 20 })
809
- }
810
- ),
811
- /* @__PURE__ */ jsxRuntime.jsx("h2", { children: monthCount > 1 ? getMonthTitle(startDate) : title }),
812
- i === monthCount - 1 && /* @__PURE__ */ jsxRuntime.jsx(
813
- CalendarButton,
814
- {
815
- ...nextButtonProps,
816
- "aria-label": ariaLabelIfNorwegian(
817
- "Neste måned",
818
- locale,
819
- nextButtonProps
820
- ),
821
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.RightArrowIcon, { size: 20 })
822
- }
823
- )
824
- ] }),
825
- /* @__PURE__ */ jsxRuntime.jsx(
826
- RangeCalendarGrid,
827
- {
828
- ...rest,
829
- state,
830
- startDate,
831
- navigationDescription,
832
- classNameForDate,
833
- ariaLabelForDate,
834
- showWeekNumbers,
835
- weekNumberHeader,
836
- showOutsideMonth
837
- }
838
- )
839
- ] }, i);
840
- }) })
764
+ className,
765
+ navigationDescription,
766
+ showWeekNumbers,
767
+ weekNumberHeader,
768
+ renderCell: (date2, currentMonth, weekNumberString, ariaDescribedBy) => /* @__PURE__ */ jsxRuntime.jsx(
769
+ RangeCalendarCell,
770
+ {
771
+ state,
772
+ date: date2,
773
+ currentMonth,
774
+ "aria-describedby": ariaDescribedBy,
775
+ weekNumberString,
776
+ classNameForDate,
777
+ ariaLabelForDate,
778
+ showOutsideMonth
779
+ },
780
+ `${date2.month}.${date2.day}`
781
+ )
841
782
  }
842
783
  );
843
784
  };