@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.esm.js CHANGED
@@ -746,7 +746,13 @@ function getInitialMonth(selected) {
746
746
  selected.from instanceof Date) {
747
747
  return new Date(selected.from.getFullYear(), selected.from.getMonth(), 1);
748
748
  }
749
- return new Date();
749
+ // The first of this month, not today.
750
+ //
751
+ // Returning today carried its day-of-month into the month arrows, which is
752
+ // what made an untouched calendar skip a month while one with a date
753
+ // already chosen behaved — the selected branches above all pin the day to 1.
754
+ const now = new Date();
755
+ return new Date(now.getFullYear(), now.getMonth(), 1);
750
756
  }
751
757
  function Calendar({ className, selected, onSelect, mode = "single", disabled, fromYear = 1900, toYear, }) {
752
758
  const maxYear = toYear ?? new Date().getFullYear() + 10;
@@ -859,16 +865,15 @@ function Calendar({ className, selected, onSelect, mode = "single", disabled, fr
859
865
  }
860
866
  };
861
867
  const navigateMonth = (direction) => {
862
- setCurrentMonth((prev) => {
863
- const newMonth = new Date(prev);
864
- if (direction === "prev") {
865
- newMonth.setMonth(prev.getMonth() - 1);
866
- }
867
- else {
868
- newMonth.setMonth(prev.getMonth() + 1);
869
- }
870
- return newMonth;
871
- });
868
+ // Built from year and month with the day pinned to 1, never by shifting
869
+ // the month on a copy of the current date.
870
+ //
871
+ // setMonth keeps the day-of-month, so from the 31st it lands on a date
872
+ // that does not exist in a 30-day month and JavaScript rolls it forward:
873
+ // 31 Aug + 1 month became 1 Oct, and September could not be reached at
874
+ // all. It bit every calendar opened with no value selected, because that
875
+ // starting point was today — including today's day-of-month.
876
+ setCurrentMonth((prev) => new Date(prev.getFullYear(), prev.getMonth() + (direction === "next" ? 1 : -1), 1));
872
877
  };
873
878
  const handleMonthChange = (monthStr) => {
874
879
  const nextMonth = Number.parseInt(monthStr, 10);