@elliemae/ds-form-date-time-picker 3.70.0-next.46 → 3.70.0-next.48

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.
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(useCurrentDisplayedMonthYearLogic_exports);
34
34
  var React = __toESM(require("react"));
35
35
  var import_react = require("react");
36
36
  var import_useGetMonthYearFromDateStringOrEmptyStartingMonth = require("../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js");
37
+ var import_useGetStartingFocusedDay = require("../../../utils/hooks/useGetStartingFocusedDay.js");
37
38
  var import_dateHelpers = require("../../../utils/dateHelpers.js");
38
39
  function sliceIntoChunks(arr, chunkSize) {
39
40
  const res = [];
@@ -72,7 +73,10 @@ const getDaysArrays = (currentMonth, currentYear) => {
72
73
  return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];
73
74
  };
74
75
  const useCurrentDisplayedMonthYearLogic = () => {
75
- const { month: monthFromDateString, year: yearFromDateString } = (0, import_useGetMonthYearFromDateStringOrEmptyStartingMonth.useGetMonthYearFromDateStringOrEmptyStartingMonth)();
76
+ const { month: monthFromDateStringFallback, year: yearFromDateStringFallback } = (0, import_useGetMonthYearFromDateStringOrEmptyStartingMonth.useGetMonthYearFromDateStringOrEmptyStartingMonth)();
77
+ const { startFocusedDate } = (0, import_useGetStartingFocusedDay.useGetStartingFocusedDay)();
78
+ const monthFromDateString = startFocusedDate ? startFocusedDate.getMonth() : monthFromDateStringFallback;
79
+ const yearFromDateString = startFocusedDate ? startFocusedDate.getFullYear() : yearFromDateStringFallback;
76
80
  const [currentMonth, setCurrentMonth] = (0, import_react.useState)(monthFromDateString);
77
81
  const [currentYear, setCurrentYear] = (0, import_react.useState)(yearFromDateString);
78
82
  const daysArraysRef = (0, import_react.useRef)([]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.tsx", "../../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { useMemo, useCallback, useState, useEffect, createRef, useRef } from 'react';\n// eslint-disable-next-line max-len\nimport { useGetMonthYearFromDateStringOrEmptyStartingMonth } from '../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js';\nimport {\n getSixBySevenCurrentMonthDaysMatrix,\n sumFromDateValues,\n sumValuesToDate,\n getDateStringFromDay,\n} from '../../../utils/dateHelpers.js';\nimport type { DSControlledDateTimePickerT } from '../../../react-desc-prop-types.js';\nimport type { DSControlledDateTimePickerInternalsT } from '../../../sharedTypes.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction sliceIntoChunks<T = any>(arr: Array<T>, chunkSize: number): Array<Array<T>> {\n const res = [];\n for (let i = 0; i < arr.length; i += chunkSize) {\n const chunk = arr.slice(i, i + chunkSize);\n res.push(chunk);\n }\n return res;\n}\ninterface UseCurrentDisplayedMonthYearLogicT {\n currentMonth: DSControlledDateTimePickerInternalsT.DateMonth;\n currentYear: number;\n daysArray: DSControlledDateTimePickerT.MetaMonthDay[];\n invisibleFirstDay?: DSControlledDateTimePickerT.MetaMonthDay;\n daysMatrixByWeekday: DSControlledDateTimePickerT.MetaMonthDay[][];\n invisibleLastDay?: DSControlledDateTimePickerT.MetaMonthDay;\n handlePrevMonth: () => void;\n handlePrevYear: () => void;\n handleNextMonth: () => void;\n handleNextYear: () => void;\n daysArraysRef: React.MutableRefObject<DSControlledDateTimePickerT.MetaMonthDay[]>;\n resetMonthYear: () => void;\n}\n\nconst getDaysArrays = (currentMonth: DSControlledDateTimePickerInternalsT.DateMonth, currentYear: number) => {\n const newDaysArray = getSixBySevenCurrentMonthDaysMatrix(currentMonth, currentYear);\n const hiddenPrevDay = sumValuesToDate(newDaysArray[0].day, {\n daysToSum: -1,\n });\n const hiddenPrevMetaday = {\n day: hiddenPrevDay,\n dayAsString: getDateStringFromDay(hiddenPrevDay),\n isPrevMonthDay: true,\n isNextMonthDay: false,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n const hiddenNextDay = sumValuesToDate(newDaysArray[newDaysArray.length - 1].day, {\n daysToSum: 1,\n });\n const hiddenNextMetaday = {\n day: hiddenNextDay,\n dayAsString: getDateStringFromDay(hiddenNextDay),\n isPrevMonthDay: false,\n isNextMonthDay: true,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];\n};\nexport const useCurrentDisplayedMonthYearLogic = (): UseCurrentDisplayedMonthYearLogicT => {\n const { month: monthFromDateString, year: yearFromDateString } = useGetMonthYearFromDateStringOrEmptyStartingMonth();\n const [currentMonth, setCurrentMonth] = useState(monthFromDateString);\n const [currentYear, setCurrentYear] = useState(yearFromDateString);\n\n const daysArraysRef = useRef<DSControlledDateTimePickerT.MetaMonthDay[]>([]);\n\n const resetMonthYear = useCallback(() => {\n setCurrentMonth(monthFromDateString);\n setCurrentYear(yearFromDateString);\n }, [monthFromDateString, yearFromDateString]);\n // side-effects are really really controlled in this case so use-effect should be fine\n // don't add 200 side-effects to those or else Chaos would hunt us for the years to come\n useEffect(() => {\n setCurrentMonth(monthFromDateString);\n }, [monthFromDateString]);\n useEffect(() => {\n setCurrentYear(yearFromDateString);\n }, [yearFromDateString]);\n\n const daysArray = useMemo(() => getDaysArrays(currentMonth, currentYear), [currentMonth, currentYear]);\n\n daysArraysRef.current = daysArray;\n\n const handlePrevYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: -1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const handlePrevMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: -1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: 1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: 1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const { invisibleFirstDay, daysMatrixByWeekday, invisibleLastDay } = useMemo(() => {\n const [invisible1stDay, ...otherDays] = [...daysArray];\n const invisibleDayLast = otherDays.pop();\n return {\n invisibleFirstDay: invisible1stDay,\n daysMatrixByWeekday: sliceIntoChunks<DSControlledDateTimePickerT.MetaMonthDay>(otherDays, 7),\n invisibleLastDay: invisibleDayLast,\n };\n }, [daysArray]);\n\n return useMemo(\n () => ({\n currentMonth,\n currentYear,\n daysArray,\n invisibleFirstDay,\n daysMatrixByWeekday,\n invisibleLastDay,\n handlePrevYear,\n handlePrevMonth,\n handleNextMonth,\n handleNextYear,\n daysArraysRef,\n resetMonthYear,\n }),\n [\n currentMonth,\n currentYear,\n daysArray,\n daysMatrixByWeekday,\n handleNextMonth,\n handleNextYear,\n handlePrevMonth,\n handlePrevYear,\n invisibleFirstDay,\n invisibleLastDay,\n resetMonthYear,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA6E;AAE7E,+DAAkE;AAClE,yBAKO;AAKP,SAAS,gBAAyB,KAAe,WAAoC;AACnF,QAAM,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,CAAC;AAE9B,QAAM,EAAE,mBAAmB,qBAAqB,iBAAiB,QAAI,sBAAQ,MAAM;AACjF,UAAM,CAAC,iBAAiB,GAAG,SAAS,IAAI,CAAC,GAAG,SAAS;AACrD,UAAM,mBAAmB,UAAU,IAAI;AACvC,WAAO;AAAA,MACL,mBAAmB;AAAA,MACnB,qBAAqB,gBAA0D,WAAW,CAAC;AAAA,MAC3F,kBAAkB;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { useMemo, useCallback, useState, useEffect, createRef, useRef } from 'react';\n// eslint-disable-next-line max-len\nimport { useGetMonthYearFromDateStringOrEmptyStartingMonth } from '../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js';\nimport { useGetStartingFocusedDay } from '../../../utils/hooks/useGetStartingFocusedDay.js';\nimport {\n getSixBySevenCurrentMonthDaysMatrix,\n sumFromDateValues,\n sumValuesToDate,\n getDateStringFromDay,\n} from '../../../utils/dateHelpers.js';\nimport type { DSControlledDateTimePickerT } from '../../../react-desc-prop-types.js';\nimport type { DSControlledDateTimePickerInternalsT } from '../../../sharedTypes.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction sliceIntoChunks<T = any>(arr: Array<T>, chunkSize: number): Array<Array<T>> {\n const res = [];\n for (let i = 0; i < arr.length; i += chunkSize) {\n const chunk = arr.slice(i, i + chunkSize);\n res.push(chunk);\n }\n return res;\n}\ninterface UseCurrentDisplayedMonthYearLogicT {\n currentMonth: DSControlledDateTimePickerInternalsT.DateMonth;\n currentYear: number;\n daysArray: DSControlledDateTimePickerT.MetaMonthDay[];\n invisibleFirstDay?: DSControlledDateTimePickerT.MetaMonthDay;\n daysMatrixByWeekday: DSControlledDateTimePickerT.MetaMonthDay[][];\n invisibleLastDay?: DSControlledDateTimePickerT.MetaMonthDay;\n handlePrevMonth: () => void;\n handlePrevYear: () => void;\n handleNextMonth: () => void;\n handleNextYear: () => void;\n daysArraysRef: React.MutableRefObject<DSControlledDateTimePickerT.MetaMonthDay[]>;\n resetMonthYear: () => void;\n}\n\nconst getDaysArrays = (currentMonth: DSControlledDateTimePickerInternalsT.DateMonth, currentYear: number) => {\n const newDaysArray = getSixBySevenCurrentMonthDaysMatrix(currentMonth, currentYear);\n const hiddenPrevDay = sumValuesToDate(newDaysArray[0].day, {\n daysToSum: -1,\n });\n const hiddenPrevMetaday = {\n day: hiddenPrevDay,\n dayAsString: getDateStringFromDay(hiddenPrevDay),\n isPrevMonthDay: true,\n isNextMonthDay: false,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n const hiddenNextDay = sumValuesToDate(newDaysArray[newDaysArray.length - 1].day, {\n daysToSum: 1,\n });\n const hiddenNextMetaday = {\n day: hiddenNextDay,\n dayAsString: getDateStringFromDay(hiddenNextDay),\n isPrevMonthDay: false,\n isNextMonthDay: true,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];\n};\nexport const useCurrentDisplayedMonthYearLogic = (): UseCurrentDisplayedMonthYearLogicT => {\n const { month: monthFromDateStringFallback, year: yearFromDateStringFallback } =\n useGetMonthYearFromDateStringOrEmptyStartingMonth();\n const { startFocusedDate } = useGetStartingFocusedDay();\n\n /*\n * PUI-15900 https://jira.elliemae.io/browse/PUI-15900\n *\n * The displayed month must stay aligned with the day the calendar will focus on open\n * (see useFocusLogic / useGetStartingFocusedDay). When the input holds a partial date\n * (e.g. a month with no day/year), `useGetMonthYearFromDateStringOrEmptyStartingMonth`\n * would drive the grid to that partial month, while the starting focused day resolves\n * to `onCalendarOpenFocusedDay` \u2014 a day in a different month that is then not rendered,\n * so focus is lost.\n *\n * Whenever a starting focused day is resolved (a complete valid input date, or\n * `onCalendarOpenFocusedDay` when the input is incomplete) the grid follows THAT day's\n * month/year, so the focused day is always visible. Only when there is no starting\n * focused day do we fall back to the input/emptyPickerStartingMonth month.\n */\n const monthFromDateString = startFocusedDate\n ? (startFocusedDate.getMonth() as DSControlledDateTimePickerInternalsT.DateMonth)\n : monthFromDateStringFallback;\n const yearFromDateString = startFocusedDate ? startFocusedDate.getFullYear() : yearFromDateStringFallback;\n\n const [currentMonth, setCurrentMonth] = useState(monthFromDateString);\n const [currentYear, setCurrentYear] = useState(yearFromDateString);\n\n const daysArraysRef = useRef<DSControlledDateTimePickerT.MetaMonthDay[]>([]);\n\n const resetMonthYear = useCallback(() => {\n setCurrentMonth(monthFromDateString);\n setCurrentYear(yearFromDateString);\n }, [monthFromDateString, yearFromDateString]);\n // side-effects are really really controlled in this case so use-effect should be fine\n // don't add 200 side-effects to those or else Chaos would hunt us for the years to come\n useEffect(() => {\n setCurrentMonth(monthFromDateString);\n }, [monthFromDateString]);\n useEffect(() => {\n setCurrentYear(yearFromDateString);\n }, [yearFromDateString]);\n\n const daysArray = useMemo(() => getDaysArrays(currentMonth, currentYear), [currentMonth, currentYear]);\n\n daysArraysRef.current = daysArray;\n\n const handlePrevYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: -1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const handlePrevMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: -1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: 1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: 1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const { invisibleFirstDay, daysMatrixByWeekday, invisibleLastDay } = useMemo(() => {\n const [invisible1stDay, ...otherDays] = [...daysArray];\n const invisibleDayLast = otherDays.pop();\n return {\n invisibleFirstDay: invisible1stDay,\n daysMatrixByWeekday: sliceIntoChunks<DSControlledDateTimePickerT.MetaMonthDay>(otherDays, 7),\n invisibleLastDay: invisibleDayLast,\n };\n }, [daysArray]);\n\n return useMemo(\n () => ({\n currentMonth,\n currentYear,\n daysArray,\n invisibleFirstDay,\n daysMatrixByWeekday,\n invisibleLastDay,\n handlePrevYear,\n handlePrevMonth,\n handleNextMonth,\n handleNextYear,\n daysArraysRef,\n resetMonthYear,\n }),\n [\n currentMonth,\n currentYear,\n daysArray,\n daysMatrixByWeekday,\n handleNextMonth,\n handleNextYear,\n handlePrevMonth,\n handlePrevYear,\n invisibleFirstDay,\n invisibleLastDay,\n resetMonthYear,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAA6E;AAE7E,+DAAkE;AAClE,sCAAyC;AACzC,yBAKO;AAKP,SAAS,gB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B,0BAAY,MAAM;AACvC,UAAM,EAAE,MAAM,QAAQ,QAAI,sCAAkB,EAAE,OAAO,cAAc,MAAM,YAAY,GAAG,EAAE,YAAY,EAAE,CAAC;AACzG,mBAAe,OAAO;AAAA,EACxB,GAAG,CAAC,cAAc,WAAW,CAAC;AAE9B,QAAM,EAAE,mBAAmB,qBAAqB,iBAAiB,QAAI,sBAAQ,MAAM;AACjF,UAAM,CAAC,iBAAiB,GAAG,SAAS,IAAI,CAAC,GAAG,SAAS;AACrD,UAAM,mBAAmB,UAAU,IAAI;AACvC,WAAO;AAAA,MACL,mBAAmB;AAAA,MACnB,qBAAqB,gBAA0D,WAAW,CAAC;AAAA,MAC3F,kBAAkB;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,aAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useMemo, useCallback, useState, useEffect, createRef, useRef } from "react";
3
3
  import { useGetMonthYearFromDateStringOrEmptyStartingMonth } from "../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js";
4
+ import { useGetStartingFocusedDay } from "../../../utils/hooks/useGetStartingFocusedDay.js";
4
5
  import {
5
6
  getSixBySevenCurrentMonthDaysMatrix,
6
7
  sumFromDateValues,
@@ -44,7 +45,10 @@ const getDaysArrays = (currentMonth, currentYear) => {
44
45
  return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];
45
46
  };
46
47
  const useCurrentDisplayedMonthYearLogic = () => {
47
- const { month: monthFromDateString, year: yearFromDateString } = useGetMonthYearFromDateStringOrEmptyStartingMonth();
48
+ const { month: monthFromDateStringFallback, year: yearFromDateStringFallback } = useGetMonthYearFromDateStringOrEmptyStartingMonth();
49
+ const { startFocusedDate } = useGetStartingFocusedDay();
50
+ const monthFromDateString = startFocusedDate ? startFocusedDate.getMonth() : monthFromDateStringFallback;
51
+ const yearFromDateString = startFocusedDate ? startFocusedDate.getFullYear() : yearFromDateStringFallback;
48
52
  const [currentMonth, setCurrentMonth] = useState(monthFromDateString);
49
53
  const [currentYear, setCurrentYear] = useState(yearFromDateString);
50
54
  const daysArraysRef = useRef([]);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/parts/Pickers/Calendar/useCurrentDisplayedMonthYearLogic.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { useMemo, useCallback, useState, useEffect, createRef, useRef } from 'react';\n// eslint-disable-next-line max-len\nimport { useGetMonthYearFromDateStringOrEmptyStartingMonth } from '../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js';\nimport {\n getSixBySevenCurrentMonthDaysMatrix,\n sumFromDateValues,\n sumValuesToDate,\n getDateStringFromDay,\n} from '../../../utils/dateHelpers.js';\nimport type { DSControlledDateTimePickerT } from '../../../react-desc-prop-types.js';\nimport type { DSControlledDateTimePickerInternalsT } from '../../../sharedTypes.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction sliceIntoChunks<T = any>(arr: Array<T>, chunkSize: number): Array<Array<T>> {\n const res = [];\n for (let i = 0; i < arr.length; i += chunkSize) {\n const chunk = arr.slice(i, i + chunkSize);\n res.push(chunk);\n }\n return res;\n}\ninterface UseCurrentDisplayedMonthYearLogicT {\n currentMonth: DSControlledDateTimePickerInternalsT.DateMonth;\n currentYear: number;\n daysArray: DSControlledDateTimePickerT.MetaMonthDay[];\n invisibleFirstDay?: DSControlledDateTimePickerT.MetaMonthDay;\n daysMatrixByWeekday: DSControlledDateTimePickerT.MetaMonthDay[][];\n invisibleLastDay?: DSControlledDateTimePickerT.MetaMonthDay;\n handlePrevMonth: () => void;\n handlePrevYear: () => void;\n handleNextMonth: () => void;\n handleNextYear: () => void;\n daysArraysRef: React.MutableRefObject<DSControlledDateTimePickerT.MetaMonthDay[]>;\n resetMonthYear: () => void;\n}\n\nconst getDaysArrays = (currentMonth: DSControlledDateTimePickerInternalsT.DateMonth, currentYear: number) => {\n const newDaysArray = getSixBySevenCurrentMonthDaysMatrix(currentMonth, currentYear);\n const hiddenPrevDay = sumValuesToDate(newDaysArray[0].day, {\n daysToSum: -1,\n });\n const hiddenPrevMetaday = {\n day: hiddenPrevDay,\n dayAsString: getDateStringFromDay(hiddenPrevDay),\n isPrevMonthDay: true,\n isNextMonthDay: false,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n const hiddenNextDay = sumValuesToDate(newDaysArray[newDaysArray.length - 1].day, {\n daysToSum: 1,\n });\n const hiddenNextMetaday = {\n day: hiddenNextDay,\n dayAsString: getDateStringFromDay(hiddenNextDay),\n isPrevMonthDay: false,\n isNextMonthDay: true,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];\n};\nexport const useCurrentDisplayedMonthYearLogic = (): UseCurrentDisplayedMonthYearLogicT => {\n const { month: monthFromDateString, year: yearFromDateString } = useGetMonthYearFromDateStringOrEmptyStartingMonth();\n const [currentMonth, setCurrentMonth] = useState(monthFromDateString);\n const [currentYear, setCurrentYear] = useState(yearFromDateString);\n\n const daysArraysRef = useRef<DSControlledDateTimePickerT.MetaMonthDay[]>([]);\n\n const resetMonthYear = useCallback(() => {\n setCurrentMonth(monthFromDateString);\n setCurrentYear(yearFromDateString);\n }, [monthFromDateString, yearFromDateString]);\n // side-effects are really really controlled in this case so use-effect should be fine\n // don't add 200 side-effects to those or else Chaos would hunt us for the years to come\n useEffect(() => {\n setCurrentMonth(monthFromDateString);\n }, [monthFromDateString]);\n useEffect(() => {\n setCurrentYear(yearFromDateString);\n }, [yearFromDateString]);\n\n const daysArray = useMemo(() => getDaysArrays(currentMonth, currentYear), [currentMonth, currentYear]);\n\n daysArraysRef.current = daysArray;\n\n const handlePrevYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: -1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const handlePrevMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: -1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: 1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: 1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const { invisibleFirstDay, daysMatrixByWeekday, invisibleLastDay } = useMemo(() => {\n const [invisible1stDay, ...otherDays] = [...daysArray];\n const invisibleDayLast = otherDays.pop();\n return {\n invisibleFirstDay: invisible1stDay,\n daysMatrixByWeekday: sliceIntoChunks<DSControlledDateTimePickerT.MetaMonthDay>(otherDays, 7),\n invisibleLastDay: invisibleDayLast,\n };\n }, [daysArray]);\n\n return useMemo(\n () => ({\n currentMonth,\n currentYear,\n daysArray,\n invisibleFirstDay,\n daysMatrixByWeekday,\n invisibleLastDay,\n handlePrevYear,\n handlePrevMonth,\n handleNextMonth,\n handleNextYear,\n daysArraysRef,\n resetMonthYear,\n }),\n [\n currentMonth,\n currentYear,\n daysArray,\n daysMatrixByWeekday,\n handleNextMonth,\n handleNextYear,\n handlePrevMonth,\n handlePrevYear,\n invisibleFirstDay,\n invisibleLastDay,\n resetMonthYear,\n ],\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,SAAS,aAAa,UAAU,WAAW,WAAW,cAAc;AAE7E,SAAS,yDAAyD;AAClE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,gBAAyB,KAAe,WAAoC;AACnF,QAAM,MAAM,CAAC;AACb,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,WAAW;AAC9C,UAAM,QAAQ,IAAI,MAAM,GAAG,IAAI,SAAS;AACxC,QAAI,KAAK,KAAK;AAAA,EAChB;AACA,SAAO;AACT;AAgBA,MAAM,gBAAgB,CAAC,cAA8D,gBAAwB;AAC3G,QAAM,eAAe,oCAAoC,cAAc,WAAW;AAClF,QAAM,gBAAgB,gBAAgB,aAAa,CAAC,EAAE,KAAK;AAAA,IACzD,WAAW;AAAA,EACb,CAAC;AACD,QAAM,oBAAoB;AAAA,IACxB,KAAK;AAAA,IACL,aAAa,qBAAqB,aAAa;AAAA,IAC/C,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,WAAW,UAA6B;AAAA,IACxC,UAAU;AAAA,EACZ;AACA,QAAM,gBAAgB,gBAAgB,aAAa,aAAa,SAAS,CAAC,EAAE,KAAK;AAAA,IAC/E,WAAW;AAAA,EACb,CAAC;AACD,QAAM,oBAAoB;AAAA,IACxB,KAAK;AAAA,IACL,aAAa,qB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,OAAO;AAAA,EACzD,GAAG,CAAC,cAAc,WAAW,CAAC;AAE9B,QAAM,kBAAkB,YAAY,MAAM;AACxC,UAAM,EAAE,OAAO,UAAU,MAAM,QAAQ,IAAI;AAAA,MACzC,EAAE,OAAO,cAAc,MAAM,YAAY;AAAA,MACzC,EAAE,aAAa,EAAE;AAAA,IACnB;AACA,oBAAgB,QAAQ;AACxB,mBAAe,OAAO;AACtB,kBAAc,UAAU,cAAc,UAAU,OAAO;AAAA,EACzD,GAAG,CAAC,cAAc,WAAW,CAAC;AAE9B,QAAM,iBAAiB,YAAY,MAAM;AACvC,UAAM,EAAE,MAAM,QAAQ,IAAI,kBAAkB,EAAE,OAAO,cAAc,MAAM,YAAY,GAAG,EAAE,YAAY,EAAE,CAAC;AACzG,mBAAe,OAAO;AAAA,EACxB,GAAG,CAAC,cAAc,WAAW,CAAC;AAE9B,QAAM,EAAE,mBAAmB,qBAAqB,iBAAiB,IAAI,QAAQ,MAAM;AACjF,UAAM,CAAC,iBAAiB,GAAG,SAAS,IAAI,CAAC,GAAG,SAAS;AACrD,UAAM,mBAAmB,UAAU,IAAI;AACvC,WAAO;AAAA,MACL,mBAAmB;AAAA,MACnB,qBAAqB,gBAA0D,WAAW,CAAC;AAAA,MAC3F,kBAAkB;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-statements */\n/* eslint-disable max-lines */\nimport { useMemo, useCallback, useState, useEffect, createRef, useRef } from 'react';\n// eslint-disable-next-line max-len\nimport { useGetMonthYearFromDateStringOrEmptyStartingMonth } from '../../../utils/hooks/useGetMonthYearFromDateStringOrEmptyStartingMonth.js';\nimport { useGetStartingFocusedDay } from '../../../utils/hooks/useGetStartingFocusedDay.js';\nimport {\n getSixBySevenCurrentMonthDaysMatrix,\n sumFromDateValues,\n sumValuesToDate,\n getDateStringFromDay,\n} from '../../../utils/dateHelpers.js';\nimport type { DSControlledDateTimePickerT } from '../../../react-desc-prop-types.js';\nimport type { DSControlledDateTimePickerInternalsT } from '../../../sharedTypes.js';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction sliceIntoChunks<T = any>(arr: Array<T>, chunkSize: number): Array<Array<T>> {\n const res = [];\n for (let i = 0; i < arr.length; i += chunkSize) {\n const chunk = arr.slice(i, i + chunkSize);\n res.push(chunk);\n }\n return res;\n}\ninterface UseCurrentDisplayedMonthYearLogicT {\n currentMonth: DSControlledDateTimePickerInternalsT.DateMonth;\n currentYear: number;\n daysArray: DSControlledDateTimePickerT.MetaMonthDay[];\n invisibleFirstDay?: DSControlledDateTimePickerT.MetaMonthDay;\n daysMatrixByWeekday: DSControlledDateTimePickerT.MetaMonthDay[][];\n invisibleLastDay?: DSControlledDateTimePickerT.MetaMonthDay;\n handlePrevMonth: () => void;\n handlePrevYear: () => void;\n handleNextMonth: () => void;\n handleNextYear: () => void;\n daysArraysRef: React.MutableRefObject<DSControlledDateTimePickerT.MetaMonthDay[]>;\n resetMonthYear: () => void;\n}\n\nconst getDaysArrays = (currentMonth: DSControlledDateTimePickerInternalsT.DateMonth, currentYear: number) => {\n const newDaysArray = getSixBySevenCurrentMonthDaysMatrix(currentMonth, currentYear);\n const hiddenPrevDay = sumValuesToDate(newDaysArray[0].day, {\n daysToSum: -1,\n });\n const hiddenPrevMetaday = {\n day: hiddenPrevDay,\n dayAsString: getDateStringFromDay(hiddenPrevDay),\n isPrevMonthDay: true,\n isNextMonthDay: false,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n const hiddenNextDay = sumValuesToDate(newDaysArray[newDaysArray.length - 1].day, {\n daysToSum: 1,\n });\n const hiddenNextMetaday = {\n day: hiddenNextDay,\n dayAsString: getDateStringFromDay(hiddenNextDay),\n isPrevMonthDay: false,\n isNextMonthDay: true,\n isCurrMonthDay: false,\n dayBtnRef: createRef<HTMLButtonElement>() as React.MutableRefObject<HTMLButtonElement>,\n isHidden: true,\n };\n return [hiddenPrevMetaday, ...newDaysArray, hiddenNextMetaday];\n};\nexport const useCurrentDisplayedMonthYearLogic = (): UseCurrentDisplayedMonthYearLogicT => {\n const { month: monthFromDateStringFallback, year: yearFromDateStringFallback } =\n useGetMonthYearFromDateStringOrEmptyStartingMonth();\n const { startFocusedDate } = useGetStartingFocusedDay();\n\n /*\n * PUI-15900 https://jira.elliemae.io/browse/PUI-15900\n *\n * The displayed month must stay aligned with the day the calendar will focus on open\n * (see useFocusLogic / useGetStartingFocusedDay). When the input holds a partial date\n * (e.g. a month with no day/year), `useGetMonthYearFromDateStringOrEmptyStartingMonth`\n * would drive the grid to that partial month, while the starting focused day resolves\n * to `onCalendarOpenFocusedDay` \u2014 a day in a different month that is then not rendered,\n * so focus is lost.\n *\n * Whenever a starting focused day is resolved (a complete valid input date, or\n * `onCalendarOpenFocusedDay` when the input is incomplete) the grid follows THAT day's\n * month/year, so the focused day is always visible. Only when there is no starting\n * focused day do we fall back to the input/emptyPickerStartingMonth month.\n */\n const monthFromDateString = startFocusedDate\n ? (startFocusedDate.getMonth() as DSControlledDateTimePickerInternalsT.DateMonth)\n : monthFromDateStringFallback;\n const yearFromDateString = startFocusedDate ? startFocusedDate.getFullYear() : yearFromDateStringFallback;\n\n const [currentMonth, setCurrentMonth] = useState(monthFromDateString);\n const [currentYear, setCurrentYear] = useState(yearFromDateString);\n\n const daysArraysRef = useRef<DSControlledDateTimePickerT.MetaMonthDay[]>([]);\n\n const resetMonthYear = useCallback(() => {\n setCurrentMonth(monthFromDateString);\n setCurrentYear(yearFromDateString);\n }, [monthFromDateString, yearFromDateString]);\n // side-effects are really really controlled in this case so use-effect should be fine\n // don't add 200 side-effects to those or else Chaos would hunt us for the years to come\n useEffect(() => {\n setCurrentMonth(monthFromDateString);\n }, [monthFromDateString]);\n useEffect(() => {\n setCurrentYear(yearFromDateString);\n }, [yearFromDateString]);\n\n const daysArray = useMemo(() => getDaysArrays(currentMonth, currentYear), [currentMonth, currentYear]);\n\n daysArraysRef.current = daysArray;\n\n const handlePrevYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: -1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const handlePrevMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: -1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextMonth = useCallback(() => {\n const { month: newMonth, year: newYear } = sumFromDateValues(\n { month: currentMonth, year: currentYear },\n { monthsToSum: 1 },\n );\n setCurrentMonth(newMonth);\n setCurrentYear(newYear);\n daysArraysRef.current = getDaysArrays(newMonth, newYear);\n }, [currentMonth, currentYear]);\n\n const handleNextYear = useCallback(() => {\n const { year: newYear } = sumFromDateValues({ month: currentMonth, year: currentYear }, { yearsToSum: 1 });\n setCurrentYear(newYear);\n }, [currentMonth, currentYear]);\n\n const { invisibleFirstDay, daysMatrixByWeekday, invisibleLastDay } = useMemo(() => {\n const [invisible1stDay, ...otherDays] = [...daysArray];\n const invisibleDayLast = otherDays.pop();\n return {\n invisibleFirstDay: invisible1stDay,\n daysMatrixByWeekday: sliceIntoChunks<DSControlledDateTimePickerT.MetaMonthDay>(otherDays, 7),\n invisibleLastDay: invisibleDayLast,\n };\n }, [daysArray]);\n\n return useMemo(\n () => ({\n currentMonth,\n currentYear,\n daysArray,\n invisibleFirstDay,\n daysMatrixByWeekday,\n invisibleLastDay,\n handlePrevYear,\n handlePrevMonth,\n handleNextMonth,\n handleNextYear,\n daysArraysRef,\n resetMonthYear,\n }),\n [\n currentMonth,\n currentYear,\n daysArray,\n daysMatrixByWeekday,\n handleNextMonth,\n handleNextYear,\n handlePrevMonth,\n handlePrevYear,\n invisibleFirstDay,\n invisibleLastDay,\n resetMonthYear,\n ],\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,SAAS,aAAa,UAAU,WAAW,WAAW,cAAc;AAE7E,SAAS,yDAAyD;AAClE,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,gBAAyB,KAAe,WAAoC;AACnF,QAAM,MAAM,CAAC;AACb,WAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,WAAW;AAC9C,UAAM,QAAQ,IAAI,MAAM,GAAG,IAAI,SAAS;AACxC,QAAI,KAAK,KAAK;AAAA,EAChB;AACA,SAAO;AACT;AAgBA,MAAM,gBAAgB,CAAC,cAA8D,gBAAwB;AAC3G,QAAM,eAAe,oCAAoC,cAAc,WAAW;AAClF,QAAM,gBAAgB,gBAAgB,aAAa,CAAC,EAAE,KAAK;AAAA,IACzD,WAAW;AAAA,EACb,CAAC;AACD,QAAM,oBAAoB;AAAA,IACxB,KAAK;AAAA,IACL,aAAa,qBAAqB,aAAa;AAAA,IAC/C,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,WAAW,UAA6B;AAAA,IACxC,UAAU;AAAA,EACZ;AACA,QAAM,gBAAgB,gBAAgB,aAAa,aAAa,SAAS,CAAC,EAAE,KAAK;AAAA,IAC/E,WAAW;AAAA,EACb,CAAC;AACD,QAAM,oB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MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-form-date-time-picker",
3
- "version": "3.70.0-next.46",
3
+ "version": "3.70.0-next.48",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Controlled Form Date Time Picker",
6
6
  "files": [
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "uid": "^2.0.2",
40
- "@elliemae/ds-button-v2": "3.70.0-next.46",
41
- "@elliemae/ds-floating-context": "3.70.0-next.46",
42
- "@elliemae/ds-grid": "3.70.0-next.46",
43
- "@elliemae/ds-system": "3.70.0-next.46",
44
- "@elliemae/ds-props-helpers": "3.70.0-next.46",
45
- "@elliemae/ds-icons": "3.70.0-next.46",
46
- "@elliemae/ds-typescript-helpers": "3.70.0-next.46"
40
+ "@elliemae/ds-floating-context": "3.70.0-next.48",
41
+ "@elliemae/ds-grid": "3.70.0-next.48",
42
+ "@elliemae/ds-button-v2": "3.70.0-next.48",
43
+ "@elliemae/ds-system": "3.70.0-next.48",
44
+ "@elliemae/ds-typescript-helpers": "3.70.0-next.48",
45
+ "@elliemae/ds-props-helpers": "3.70.0-next.48",
46
+ "@elliemae/ds-icons": "3.70.0-next.48"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@elliemae/pui-theme": "~2.13.0",
@@ -51,8 +51,8 @@
51
51
  "jest": "^30.0.0",
52
52
  "styled-components": "~5.3.9",
53
53
  "styled-system": "^5.1.5",
54
- "@elliemae/ds-monorepo-devops": "3.70.0-next.46",
55
- "@elliemae/ds-test-utils": "3.70.0-next.46"
54
+ "@elliemae/ds-test-utils": "3.70.0-next.48",
55
+ "@elliemae/ds-monorepo-devops": "3.70.0-next.48"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@elliemae/pui-theme": "~2.13.0",