@eintrek/erp-theme 1.4.13 → 1.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -791,7 +791,13 @@ function getInitialMonth(selected) {
791
791
  selected.from instanceof Date) {
792
792
  return new Date(selected.from.getFullYear(), selected.from.getMonth(), 1);
793
793
  }
794
- return new Date();
794
+ // The first of this month, not today.
795
+ //
796
+ // Returning today carried its day-of-month into the month arrows, which is
797
+ // what made an untouched calendar skip a month while one with a date
798
+ // already chosen behaved — the selected branches above all pin the day to 1.
799
+ const now = new Date();
800
+ return new Date(now.getFullYear(), now.getMonth(), 1);
795
801
  }
796
802
  function Calendar({ className, selected, onSelect, mode = "single", disabled, fromYear = 1900, toYear, }) {
797
803
  const maxYear = toYear ?? new Date().getFullYear() + 10;
@@ -904,16 +910,15 @@ function Calendar({ className, selected, onSelect, mode = "single", disabled, fr
904
910
  }
905
911
  };
906
912
  const navigateMonth = (direction) => {
907
- setCurrentMonth((prev) => {
908
- const newMonth = new Date(prev);
909
- if (direction === "prev") {
910
- newMonth.setMonth(prev.getMonth() - 1);
911
- }
912
- else {
913
- newMonth.setMonth(prev.getMonth() + 1);
914
- }
915
- return newMonth;
916
- });
913
+ // Built from year and month with the day pinned to 1, never by shifting
914
+ // the month on a copy of the current date.
915
+ //
916
+ // setMonth keeps the day-of-month, so from the 31st it lands on a date
917
+ // that does not exist in a 30-day month and JavaScript rolls it forward:
918
+ // 31 Aug + 1 month became 1 Oct, and September could not be reached at
919
+ // all. It bit every calendar opened with no value selected, because that
920
+ // starting point was today — including today's day-of-month.
921
+ setCurrentMonth((prev) => new Date(prev.getFullYear(), prev.getMonth() + (direction === "next" ? 1 : -1), 1));
917
922
  };
918
923
  const handleMonthChange = (monthStr) => {
919
924
  const nextMonth = Number.parseInt(monthStr, 10);