@salutejs/plasma-new-hope 0.263.1-canary.1764.13286897844.0 → 0.264.0-canary.1757.13287195621.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/cjs/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js.map +1 -1
- package/emotion/cjs/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/emotion/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/emotion/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/emotion/cjs/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/emotion/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/emotion/cjs/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +10 -10
- package/emotion/cjs/examples/plasma_b2c/components/DatePicker/DatePicker.stories.tsx +12 -0
- package/emotion/cjs/examples/plasma_web/components/Calendar/Calendar.stories.tsx +10 -10
- package/emotion/cjs/examples/plasma_web/components/DatePicker/DatePicker.stories.tsx +13 -1
- package/emotion/es/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/emotion/es/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/emotion/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/emotion/es/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/emotion/es/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/emotion/es/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +10 -10
- package/emotion/es/examples/plasma_b2c/components/DatePicker/DatePicker.stories.tsx +12 -0
- package/emotion/es/examples/plasma_web/components/Calendar/Calendar.stories.tsx +10 -10
- package/emotion/es/examples/plasma_web/components/DatePicker/DatePicker.stories.tsx +13 -1
- package/es/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/es/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js.map +1 -1
- package/es/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/es/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js.map +1 -1
- package/es/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/es/components/Calendar/ui/CalendarYears/CalendarYears.js.map +1 -1
- package/package.json +5 -5
- package/styled-components/cjs/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/styled-components/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/styled-components/cjs/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/styled-components/cjs/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/styled-components/cjs/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +10 -10
- package/styled-components/cjs/examples/plasma_b2c/components/DatePicker/DatePicker.stories.tsx +12 -0
- package/styled-components/cjs/examples/plasma_web/components/Calendar/Calendar.stories.tsx +10 -10
- package/styled-components/cjs/examples/plasma_web/components/DatePicker/DatePicker.stories.tsx +13 -1
- package/styled-components/es/components/Calendar/CalendarBase/CalendarBase.js +4 -2
- package/styled-components/es/components/Calendar/CalendarDouble/CalendarDouble.js +4 -2
- package/styled-components/es/components/Calendar/ui/CalendarMonths/CalendarMonths.js +4 -2
- package/styled-components/es/components/Calendar/ui/CalendarQuarters/CalendarQuarters.js +4 -2
- package/styled-components/es/components/Calendar/ui/CalendarYears/CalendarYears.js +4 -2
- package/styled-components/es/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +10 -10
- package/styled-components/es/examples/plasma_b2c/components/DatePicker/DatePicker.stories.tsx +12 -0
- package/styled-components/es/examples/plasma_web/components/Calendar/Calendar.stories.tsx +10 -10
- package/styled-components/es/examples/plasma_web/components/DatePicker/DatePicker.stories.tsx +13 -1
- package/types/components/Calendar/CalendarBase/CalendarBase.d.ts.map +1 -1
- package/types/components/Calendar/CalendarDouble/CalendarDouble.d.ts.map +1 -1
- package/types/components/Calendar/ui/CalendarMonths/CalendarMonths.d.ts.map +1 -1
- package/types/components/Calendar/ui/CalendarQuarters/CalendarQuarters.d.ts.map +1 -1
- package/types/components/Calendar/ui/CalendarYears/CalendarYears.d.ts.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarYears.js","sources":["../../../../../src/components/Calendar/ui/CalendarYears/CalendarYears.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from 'react';\n\nimport { useYears } from '../../hooks';\nimport { innerTokens, tokens } from '../../Calendar.tokens';\nimport { ROW_YEAR_STEP, canSelectDate, getInRange, getSideInRange, isSameDay, isSelectProcess } from '../../utils';\nimport { DateStructureItem } from '../DateStructureItem/DateStructureItem';\n\nimport type { CalendarYearsProps } from './CalendarYears.types';\nimport { StyledCalendarYears, StyledFlex } from './CalendarYears.styles';\n\n/**\n * Компонент годов в календаре.\n */\nexport const CalendarYears: React.FC<CalendarYearsProps> = ({\n date: currentDate,\n value,\n startYear,\n selectIndexes,\n eventList,\n disabledList,\n min,\n max,\n outerRefs,\n isDouble,\n isSecond,\n hoveredYear,\n onChangeYear,\n onHoverYear,\n onSetSelected,\n onKeyDown,\n}) => {\n const [years, selected] = useYears({ date: currentDate, value, startYear, eventList, disabledList, min, max });\n const selectedRef = useRef(selected);\n const onSetSelectedRef = useRef(onSetSelected);\n\n const offset = isSecond ? ROW_YEAR_STEP : 0;\n\n const yearItemTokens = {\n [`${innerTokens.dateStructureFontFamily}`]: `var(${tokens.calendarYearFontFamily})`,\n [`${innerTokens.dateStructureFontSize}`]: `var(${tokens.calendarYearFontSize})`,\n [`${innerTokens.dateStructureFontWeight}`]: `var(${tokens.calendarYearFontWeight})`,\n [`${innerTokens.dateStructureFontLineHeight}`]: `var(${tokens.calendarYearFontLineHeight})`,\n [`${innerTokens.dateStructureFontLetterSpacing}`]: `var(${tokens.calendarYearFontLetterSpacing})`,\n [`${innerTokens.dateStructureFontStyle}`]: `var(${tokens.calendarYearFontStyle})`,\n [`${innerTokens.dateStructureSelectedFontWeight}`]: `var(${tokens.calendarYearSelectedFontWeight})`,\n [`${innerTokens.dateStructureWidth}`]: `var(${tokens.calendarYearItemWidth})`,\n [`${innerTokens.dateStructureHeight}`]: `var(${tokens.calendarYearItemHeight})`,\n [`${innerTokens.dateStructureBorderRadius}`]: `var(${tokens.calendarYearItemBorderRadius})`,\n };\n\n const getSelectedDate = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n const { day, monthIndex, year } = event.currentTarget.dataset;\n\n const selectedDate = {\n day: Number(day),\n monthIndex: Number(monthIndex),\n year: Number(year),\n };\n\n if (!canSelectDate(selectedDate, value, disabledList)) {\n return;\n }\n\n return selectedDate;\n },\n [disabledList, value],\n );\n\n const handleOnChangeYear = useCallback(\n (i: number, j: number) => (event: React.MouseEvent<HTMLDivElement>) => {\n /**\n * нужно вызвать stopImmediatePropagation для случаев, когда\n * обработчик события onClick навешивается снаружи.\n * Как, например, в компоненте Popup\n */\n event.nativeEvent.stopImmediatePropagation();\n\n const selectedDate = getSelectedDate(event);\n\n if (!selectedDate) {\n return;\n }\n\n onChangeYear(selectedDate, [i + offset, j]);\n\n if (isSelectProcess(value)) {\n onHoverYear?.(undefined);\n }\n },\n [getSelectedDate, onChangeYear, offset, value, onHoverYear],\n );\n\n const handleOnHoverYear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n const selectedDate = getSelectedDate(event);\n const isSelectedDone = Array.isArray(value) && value[0] && value[1];\n\n if (!selectedDate || !Array.isArray(value) || isSelectedDone) {\n return;\n }\n\n onHoverYear?.(selectedDate);\n },\n [getSelectedDate, onHoverYear, value],\n );\n\n const handleMouseOutGrid = () => onHoverYear?.(undefined);\n\n const getRefs = useCallback(\n (element: HTMLDivElement, i: number, j: number) => {\n outerRefs.current[i + offset][j] = element;\n },\n [outerRefs],\n );\n\n useEffect(() => {\n if (selectedRef.current) {\n onSetSelectedRef.current?.(selectedRef.current);\n }\n }, []);\n\n return (\n <StyledCalendarYears\n role=\"grid\"\n aria-labelledby=\"id-grid-label\"\n onKeyDown={onKeyDown}\n onMouseLeave={handleMouseOutGrid}\n >\n {years.map((year, i) => (\n <StyledFlex role=\"row\" key={i}>\n {year.map(\n (\n {\n yearValue,\n isSelected,\n isCurrent,\n date,\n events,\n isOutOfMinMaxRange,\n inRange,\n disabled,\n disabledArrowKey,\n disabledDates,\n },\n j,\n ) => {\n return (\n <DateStructureItem\n ref={(element: HTMLDivElement) => getRefs(element, i, j)}\n style={yearItemTokens}\n eventList={events}\n disabled={disabled}\n day={date.day}\n year={yearValue}\n monthIndex={date.monthIndex}\n isFocused={\n i + offset === selectIndexes?.[0] &&\n j === selectIndexes?.[1] &&\n !isOutOfMinMaxRange\n }\n isSelected={isSelected}\n isCurrent={isCurrent}\n isDouble={isDouble}\n isHovered={isSameDay(date, hoveredYear)}\n inRange={getInRange(value, date, hoveredYear, inRange)}\n sideInRange={getSideInRange(value, date, hoveredYear, isSelected)}\n onClick={disabled ? undefined : handleOnChangeYear(i, j)}\n onMouseOver={disabled ? undefined : handleOnHoverYear}\n key={`StyledYear-${i}-${j}`}\n role=\"gridcell\"\n data-year={yearValue}\n data-month-index={date.monthIndex}\n data-day={date.day}\n aria-label={String(yearValue)}\n disabledArrowKey={disabledArrowKey}\n disabledMonths={disabledDates}\n isDayInCurrentMonth\n >\n {yearValue}\n </DateStructureItem>\n );\n },\n )}\n </StyledFlex>\n ))}\n </StyledCalendarYears>\n );\n};\n"],"names":["CalendarYears","_ref","currentDate","date","value","startYear","selectIndexes","eventList","disabledList","min","max","outerRefs","isDouble","isSecond","hoveredYear","onChangeYear","onHoverYear","onSetSelected","onKeyDown","_useYears","useYears","_useYears2","_slicedToArray","years","selected","selectedRef","useRef","onSetSelectedRef","offset","ROW_YEAR_STEP","yearItemTokens","_defineProperty","concat","innerTokens","dateStructureFontFamily","tokens","calendarYearFontFamily","dateStructureFontSize","calendarYearFontSize","dateStructureFontWeight","calendarYearFontWeight","dateStructureFontLineHeight","calendarYearFontLineHeight","dateStructureFontLetterSpacing","calendarYearFontLetterSpacing","dateStructureFontStyle","calendarYearFontStyle","dateStructureSelectedFontWeight","calendarYearSelectedFontWeight","dateStructureWidth","calendarYearItemWidth","dateStructureHeight","calendarYearItemHeight","dateStructureBorderRadius","calendarYearItemBorderRadius","getSelectedDate","useCallback","event","_event$currentTarget$","currentTarget","dataset","day","monthIndex","year","selectedDate","Number","canSelectDate","handleOnChangeYear","i","j","nativeEvent","stopImmediatePropagation","isSelectProcess","undefined","handleOnHoverYear","isSelectedDone","Array","isArray","handleMouseOutGrid","getRefs","element","current","useEffect","_onSetSelectedRef$cur","call","React","createElement","StyledCalendarYears","role","onMouseLeave","map","StyledFlex","key","_ref2","yearValue","isSelected","isCurrent","events","isOutOfMinMaxRange","inRange","disabled","disabledArrowKey","disabledDates","DateStructureItem","ref","style","isFocused","isHovered","isSameDay","getInRange","sideInRange","getSideInRange","onClick","onMouseOver","String","disabledMonths","isDayInCurrentMonth"],"mappings":";;;;;;;;;;;;;;;;;;AAUA;AACA;AACA;IACaA,aAA2C,GAAG,SAA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AAO,EAAEU,8BAAU,CAACzG,KAAK,EAAED,IAAI,EAAEW,WAAW,EAAEqF,OAAO,CAAE;QACvDW,WAAW,EAAEC,kCAAc,CAAC3G,KAAK,EAAED,IAAI,EAAEW,WAAW,EAAEiF,UAAU,CAAE;QAClEiB,OAAO,EAAEZ,QAAQ,GAAG3B,SAAS,GAAGN,kBAAkB,CAACC,CAAC,EAAEC,CAAC,CAAE;AACzD4C,QAAAA,WAAW,EAAEb,QAAQ,GAAG3B,SAAS,GAAGC,iBAAkB;QACtDkB,GAAG,EAAA,aAAA,CAAA5D,MAAA,CAAgBoC,CAAC,OAAApC,MAAA,CAAIqC,CAAC,CAAG;AAC5BmB,QAAAA,IAAI,EAAC,UAAU;AACf,QAAA,WAAA,EAAWM,SAAU;QACrB,kBAAkB3F,EAAAA,IAAI,CAAC2D,UAAW;QAClC,UAAU3D,EAAAA,IAAI,CAAC0D,GAAI;QACnB,YAAYqD,EAAAA,MAAM,CAACpB,SAAS,CAAE;AAC9BO,QAAAA,gBAAgB,EAAEA,gBAAiB;AACnCc,QAAAA,cAAc,EAAEb,aAAc;QAC9Bc,mBAAmB,EAAA,IAAA;AAAA,OAAA,EAElBtB,SACc,CAAC,CAAA;AAE5B,KACJ,CACQ,CAAC,CAAA;AAAA,GAChB,CACgB,CAAC,CAAA;AAE9B;;;;"}
|
1
|
+
{"version":3,"file":"CalendarYears.js","sources":["../../../../../src/components/Calendar/ui/CalendarYears/CalendarYears.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from 'react';\n\nimport { useYears } from '../../hooks';\nimport { innerTokens, tokens } from '../../Calendar.tokens';\nimport { ROW_YEAR_STEP, canSelectDate, getInRange, getSideInRange, isSameDay, isSelectProcess } from '../../utils';\nimport { DateStructureItem } from '../DateStructureItem/DateStructureItem';\n\nimport type { CalendarYearsProps } from './CalendarYears.types';\nimport { StyledCalendarYears, StyledFlex } from './CalendarYears.styles';\n\n/**\n * Компонент годов в календаре.\n */\nexport const CalendarYears: React.FC<CalendarYearsProps> = ({\n date: currentDate,\n value,\n startYear,\n selectIndexes,\n eventList,\n disabledList,\n min,\n max,\n outerRefs,\n isDouble,\n isSecond,\n hoveredYear,\n onChangeYear,\n onHoverYear,\n onSetSelected,\n onKeyDown,\n}) => {\n const minDate = min ? new Date(min.getFullYear(), 0, 1) : undefined;\n const maxDate = max ? new Date(max.getFullYear(), 11, 31) : undefined;\n\n const [years, selected] = useYears({\n date: currentDate,\n value,\n startYear,\n eventList,\n disabledList,\n min: minDate,\n max: maxDate,\n });\n const selectedRef = useRef(selected);\n const onSetSelectedRef = useRef(onSetSelected);\n\n const offset = isSecond ? ROW_YEAR_STEP : 0;\n\n const yearItemTokens = {\n [`${innerTokens.dateStructureFontFamily}`]: `var(${tokens.calendarYearFontFamily})`,\n [`${innerTokens.dateStructureFontSize}`]: `var(${tokens.calendarYearFontSize})`,\n [`${innerTokens.dateStructureFontWeight}`]: `var(${tokens.calendarYearFontWeight})`,\n [`${innerTokens.dateStructureFontLineHeight}`]: `var(${tokens.calendarYearFontLineHeight})`,\n [`${innerTokens.dateStructureFontLetterSpacing}`]: `var(${tokens.calendarYearFontLetterSpacing})`,\n [`${innerTokens.dateStructureFontStyle}`]: `var(${tokens.calendarYearFontStyle})`,\n [`${innerTokens.dateStructureSelectedFontWeight}`]: `var(${tokens.calendarYearSelectedFontWeight})`,\n [`${innerTokens.dateStructureWidth}`]: `var(${tokens.calendarYearItemWidth})`,\n [`${innerTokens.dateStructureHeight}`]: `var(${tokens.calendarYearItemHeight})`,\n [`${innerTokens.dateStructureBorderRadius}`]: `var(${tokens.calendarYearItemBorderRadius})`,\n };\n\n const getSelectedDate = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n const { day, monthIndex, year } = event.currentTarget.dataset;\n\n const selectedDate = {\n day: Number(day),\n monthIndex: Number(monthIndex),\n year: Number(year),\n };\n\n if (!canSelectDate(selectedDate, value, disabledList)) {\n return;\n }\n\n return selectedDate;\n },\n [disabledList, value],\n );\n\n const handleOnChangeYear = useCallback(\n (i: number, j: number) => (event: React.MouseEvent<HTMLDivElement>) => {\n /**\n * нужно вызвать stopImmediatePropagation для случаев, когда\n * обработчик события onClick навешивается снаружи.\n * Как, например, в компоненте Popup\n */\n event.nativeEvent.stopImmediatePropagation();\n\n const selectedDate = getSelectedDate(event);\n\n if (!selectedDate) {\n return;\n }\n\n onChangeYear(selectedDate, [i + offset, j]);\n\n if (isSelectProcess(value)) {\n onHoverYear?.(undefined);\n }\n },\n [getSelectedDate, onChangeYear, offset, value, onHoverYear],\n );\n\n const handleOnHoverYear = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n const selectedDate = getSelectedDate(event);\n const isSelectedDone = Array.isArray(value) && value[0] && value[1];\n\n if (!selectedDate || !Array.isArray(value) || isSelectedDone) {\n return;\n }\n\n onHoverYear?.(selectedDate);\n },\n [getSelectedDate, onHoverYear, value],\n );\n\n const handleMouseOutGrid = () => onHoverYear?.(undefined);\n\n const getRefs = useCallback(\n (element: HTMLDivElement, i: number, j: number) => {\n outerRefs.current[i + offset][j] = element;\n },\n [outerRefs],\n );\n\n useEffect(() => {\n if (selectedRef.current) {\n onSetSelectedRef.current?.(selectedRef.current);\n }\n }, []);\n\n return (\n <StyledCalendarYears\n role=\"grid\"\n aria-labelledby=\"id-grid-label\"\n onKeyDown={onKeyDown}\n onMouseLeave={handleMouseOutGrid}\n >\n {years.map((year, i) => (\n <StyledFlex role=\"row\" key={i}>\n {year.map(\n (\n {\n yearValue,\n isSelected,\n isCurrent,\n date,\n events,\n isOutOfMinMaxRange,\n inRange,\n disabled,\n disabledArrowKey,\n disabledDates,\n },\n j,\n ) => {\n return (\n <DateStructureItem\n ref={(element: HTMLDivElement) => getRefs(element, i, j)}\n style={yearItemTokens}\n eventList={events}\n disabled={disabled}\n day={date.day}\n year={yearValue}\n monthIndex={date.monthIndex}\n isFocused={\n i + offset === selectIndexes?.[0] &&\n j === selectIndexes?.[1] &&\n !isOutOfMinMaxRange\n }\n isSelected={isSelected}\n isCurrent={isCurrent}\n isDouble={isDouble}\n isHovered={isSameDay(date, hoveredYear)}\n inRange={getInRange(value, date, hoveredYear, inRange)}\n sideInRange={getSideInRange(value, date, hoveredYear, isSelected)}\n onClick={disabled ? undefined : handleOnChangeYear(i, j)}\n onMouseOver={disabled ? undefined : handleOnHoverYear}\n key={`StyledYear-${i}-${j}`}\n role=\"gridcell\"\n data-year={yearValue}\n data-month-index={date.monthIndex}\n data-day={date.day}\n aria-label={String(yearValue)}\n disabledArrowKey={disabledArrowKey}\n disabledMonths={disabledDates}\n isDayInCurrentMonth\n >\n {yearValue}\n </DateStructureItem>\n );\n },\n )}\n </StyledFlex>\n ))}\n </StyledCalendarYears>\n );\n};\n"],"names":["CalendarYears","_ref","currentDate","date","value","startYear","selectIndexes","eventList","disabledList","min","max","outerRefs","isDouble","isSecond","hoveredYear","onChangeYear","onHoverYear","onSetSelected","onKeyDown","minDate","Date","getFullYear","undefined","maxDate","_useYears","useYears","_useYears2","_slicedToArray","years","selected","selectedRef","useRef","onSetSelectedRef","offset","ROW_YEAR_STEP","yearItemTokens","_defineProperty","concat","innerTokens","dateStructureFontFamily","tokens","calendarYearFontFamily","dateStructureFontSize","calendarYearFontSize","dateStructureFontWeight","calendarYearFontWeight","dateStructureFontLineHeight","calendarYearFontLineHeight","dateStructureFontLetterSpacing","calendarYearFontLetterSpacing","dateStructureFontStyle","calendarYearFontStyle","dateStructureSelectedFontWeight","calendarYearSelectedFontWeight","dateStructureWidth","calendarYearItemWidth","dateStructureHeight","calendarYearItemHeight","dateStructureBorderRadius","calendarYearItemBorderRadius","getSelectedDate","useCallback","event","_event$currentTarget$","currentTarget","dataset","day","monthIndex","year","selectedDate","Number","canSelectDate","handleOnChangeYear","i","j","nativeEvent","stopImmediatePropagation","isSelectProcess","handleOnHoverYear","isSelectedDone","Array","isArray","handleMouseOutGrid","getRefs","element","current","useEffect","_onSetSelectedRef$cur","call","React","createElement","StyledCalendarYears","role","onMouseLeave","map","StyledFlex","key","_ref2","yearValue","isSelected","isCurrent","events","isOutOfMinMaxRange","inRange","disabled","disabledArrowKey","disabledDates","DateStructureItem","ref","style","isFocused","isHovered","isSameDay","getInRange","sideInRange","getSideInRange","onClick","onMouseOver","String","disabledMonths","isDayInCurrentMonth"],"mappings":";;;;;;;;;;;;;;;;;;AAUA;AACA;AACA;IACaA,aAA2C,GAAG,SAA9CA,aAA2CA,CAAAC,IAAA,EAiBlD;AAAA,EAAA,IAhBIC,WAAW,GAAAD,IAAA,CAAjBE,IAAI;IACJC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,YAAY,GAAAP,IAAA,CAAZO,YAAY;IACZC,GAAG,GAAAR,IAAA,CAAHQ,GAAG;IACHC,GAAG,GAAAT,IAAA,CAAHS,GAAG;IACHC,SAAS,GAAAV,IAAA,CAATU,SAAS;IACTC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,QAAQ,GAAAZ,IAAA,CAARY,QAAQ;IACRC,WAAW,GAAAb,IAAA,CAAXa,WAAW;IACXC,YAAY,GAAAd,IAAA,CAAZc,YAAY;IACZC,WAAW,GAAAf,IAAA,CAAXe,WAAW;IACXC,aAAa,GAAAhB,IAAA,CAAbgB,aAAa;IACbC,SAAS,GAAAjB,IAAA,CAATiB,SAAS,CAAA;AAET,EAAA,IAAMC,OAAO,GAAGV,GAAG,GAAG,IAAIW,IAAI,CAACX,GAAG,CAACY,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAGC,SAAS,CAAA;AACnE,EAAA,IAAMC,OAAO,GAAGb,GAAG,GAAG,IAAIU,IAAI,CAACV,GAAG,CAACW,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAGC,SAAS,CAAA;EAErE,IAAAE,SAAA,GAA0BC,iBAAQ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AA;AAAA,OAAA,EAElBtB,SACc,CAAC,CAAA;AAE5B,KACJ,CACQ,CAAC,CAAA;AAAA,GAChB,CACgB,CAAC,CAAA;AAE9B;;;;"}
|
@@ -32,8 +32,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
32
32
|
var calendarBaseRoot = exports.calendarBaseRoot = function calendarBaseRoot(Root) {
|
33
33
|
return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, outerRootRef) {
|
34
34
|
var externalValue = _ref.value,
|
35
|
-
|
36
|
-
|
35
|
+
minDate = _ref.min,
|
36
|
+
maxDate = _ref.max,
|
37
37
|
includeEdgeDates = _ref.includeEdgeDates,
|
38
38
|
_ref$type = _ref.type,
|
39
39
|
type = _ref$type === void 0 ? 'Days' : _ref$type,
|
@@ -72,6 +72,8 @@ var calendarBaseRoot = exports.calendarBaseRoot = function calendarBaseRoot(Root
|
|
72
72
|
_useState8 = _slicedToArray(_useState7, 2),
|
73
73
|
outOfRangeKey = _useState8[0],
|
74
74
|
setOutOfRangeKey = _useState8[1];
|
75
|
+
var min = minDate && new Date(minDate);
|
76
|
+
var max = maxDate && new Date(maxDate);
|
75
77
|
var _useReducer = (0, _react.useReducer)(_reducer.reducer, (0, _reducer.getInitialState)(value, min, type)),
|
76
78
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
77
79
|
state = _useReducer2[0],
|
@@ -33,8 +33,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
33
33
|
var calendarDoubleRoot = exports.calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
34
34
|
return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, outerRootRef) {
|
35
35
|
var externalValue = _ref.value,
|
36
|
-
|
37
|
-
|
36
|
+
minDate = _ref.min,
|
37
|
+
maxDate = _ref.max,
|
38
38
|
includeEdgeDates = _ref.includeEdgeDates,
|
39
39
|
_ref$type = _ref.type,
|
40
40
|
type = _ref$type === void 0 ? 'Days' : _ref$type,
|
@@ -73,6 +73,8 @@ var calendarDoubleRoot = exports.calendarDoubleRoot = function calendarDoubleRoo
|
|
73
73
|
_useState8 = _slicedToArray(_useState7, 2),
|
74
74
|
outOfRangeKey = _useState8[0],
|
75
75
|
setOutOfRangeKey = _useState8[1];
|
76
|
+
var min = minDate && new Date(minDate);
|
77
|
+
var max = maxDate && new Date(maxDate);
|
76
78
|
var _useReducer = (0, _react.useReducer)(_reducer.reducer, (0, _reducer.getInitialState)(value, min, type, true)),
|
77
79
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
78
80
|
state = _useReducer2[0],
|
@@ -42,13 +42,15 @@ var CalendarMonths = exports.CalendarMonths = function CalendarMonths(_ref) {
|
|
42
42
|
onSetSelected = _ref.onSetSelected,
|
43
43
|
onKeyDown = _ref.onKeyDown,
|
44
44
|
locale = _ref.locale;
|
45
|
+
var minDate = min ? new Date(min.getFullYear(), min.getMonth(), 1) : undefined;
|
46
|
+
var maxDate = max ? new Date(max.getFullYear(), max.getMonth() + 1, 0) : undefined;
|
45
47
|
var _useMonths = (0, _hooks.useMonths)({
|
46
48
|
date: currentDate,
|
47
49
|
value: value,
|
48
50
|
eventList: eventList,
|
49
51
|
disabledList: disabledList,
|
50
|
-
min:
|
51
|
-
max:
|
52
|
+
min: minDate,
|
53
|
+
max: maxDate,
|
52
54
|
locale: locale
|
53
55
|
}),
|
54
56
|
_useMonths2 = _slicedToArray(_useMonths, 2),
|
@@ -41,13 +41,15 @@ var CalendarQuarters = exports.CalendarQuarters = function CalendarQuarters(_ref
|
|
41
41
|
onHoverQuarter = _ref.onHoverQuarter,
|
42
42
|
onSetSelected = _ref.onSetSelected,
|
43
43
|
onKeyDown = _ref.onKeyDown;
|
44
|
+
var minDate = min ? new Date(min.getFullYear(), min.getMonth(), 1) : undefined;
|
45
|
+
var maxDate = max ? new Date(max.getFullYear(), max.getMonth() + 1, 0) : undefined;
|
44
46
|
var _useQuarters = (0, _hooks.useQuarters)({
|
45
47
|
date: currentDate,
|
46
48
|
value: value,
|
47
49
|
eventList: eventList,
|
48
50
|
disabledList: disabledList,
|
49
|
-
min:
|
50
|
-
max:
|
51
|
+
min: minDate,
|
52
|
+
max: maxDate
|
51
53
|
}),
|
52
54
|
_useQuarters2 = _slicedToArray(_useQuarters, 2),
|
53
55
|
quarters = _useQuarters2[0],
|
@@ -42,14 +42,16 @@ var CalendarYears = exports.CalendarYears = function CalendarYears(_ref) {
|
|
42
42
|
onHoverYear = _ref.onHoverYear,
|
43
43
|
onSetSelected = _ref.onSetSelected,
|
44
44
|
onKeyDown = _ref.onKeyDown;
|
45
|
+
var minDate = min ? new Date(min.getFullYear(), 0, 1) : undefined;
|
46
|
+
var maxDate = max ? new Date(max.getFullYear(), 11, 31) : undefined;
|
45
47
|
var _useYears = (0, _hooks.useYears)({
|
46
48
|
date: currentDate,
|
47
49
|
value: value,
|
48
50
|
startYear: startYear,
|
49
51
|
eventList: eventList,
|
50
52
|
disabledList: disabledList,
|
51
|
-
min:
|
52
|
-
max:
|
53
|
+
min: minDate,
|
54
|
+
max: maxDate
|
53
55
|
}),
|
54
56
|
_useYears2 = _slicedToArray(_useYears, 2),
|
55
57
|
years = _useYears2[0],
|
@@ -100,11 +100,11 @@ const StoryDefault = (args: CalendarProps) => {
|
|
100
100
|
isDouble={isDouble}
|
101
101
|
date={date}
|
102
102
|
value={(isRange ? valueRange : value) as Date & [Date, Date?]}
|
103
|
-
min={min}
|
104
|
-
max={max}
|
105
103
|
includeEdgeDates={includeEdgeDates}
|
106
104
|
locale={locale}
|
107
105
|
onChangeValue={(isRange ? handleOnRangeChange : handleOnChange) as (value: Date | [Date, Date?]) => void}
|
106
|
+
min={min}
|
107
|
+
max={max}
|
108
108
|
/>
|
109
109
|
);
|
110
110
|
};
|
@@ -146,24 +146,24 @@ const StoryBase = (args: CalendarBaseProps & { displayDouble: boolean }) => {
|
|
146
146
|
<CalendarDouble
|
147
147
|
size={size}
|
148
148
|
value={value}
|
149
|
-
min={min}
|
150
|
-
max={max}
|
151
149
|
includeEdgeDates={includeEdgeDates}
|
152
150
|
type={type}
|
153
151
|
locale={locale}
|
154
152
|
onChangeValue={handleOnChange}
|
153
|
+
{...(min && { min: new Date(min) })}
|
154
|
+
{...(max && { max: new Date(max) })}
|
155
155
|
{...rest}
|
156
156
|
/>
|
157
157
|
) : (
|
158
158
|
<CalendarBase
|
159
159
|
size={size}
|
160
160
|
value={value}
|
161
|
-
min={min}
|
162
|
-
max={max}
|
163
161
|
includeEdgeDates={includeEdgeDates}
|
164
162
|
type={type}
|
165
163
|
locale={locale}
|
166
164
|
onChangeValue={handleOnChange}
|
165
|
+
{...(min && { min: new Date(min) })}
|
166
|
+
{...(max && { max: new Date(max) })}
|
167
167
|
{...rest}
|
168
168
|
/>
|
169
169
|
);
|
@@ -233,24 +233,24 @@ const StoryRange = (args: CalendarBaseRangeProps & { displayDouble: boolean }) =
|
|
233
233
|
<CalendarBaseRange
|
234
234
|
size={size}
|
235
235
|
value={values}
|
236
|
-
min={min}
|
237
|
-
max={max}
|
238
236
|
includeEdgeDates={includeEdgeDates}
|
239
237
|
type={type}
|
240
238
|
onChangeValue={handleOnChange}
|
241
239
|
locale={locale}
|
240
|
+
{...(min && { min: new Date(min) })}
|
241
|
+
{...(max && { max: new Date(max) })}
|
242
242
|
{...rest}
|
243
243
|
/>
|
244
244
|
) : (
|
245
245
|
<CalendarDoubleRange
|
246
246
|
size={size}
|
247
247
|
value={values}
|
248
|
-
min={min}
|
249
|
-
max={max}
|
250
248
|
includeEdgeDates={includeEdgeDates}
|
251
249
|
type={type}
|
252
250
|
onChangeValue={handleOnChange}
|
253
251
|
locale={locale}
|
252
|
+
{...(min && { min: new Date(min) })}
|
253
|
+
{...(max && { max: new Date(max) })}
|
254
254
|
{...rest}
|
255
255
|
/>
|
256
256
|
);
|
@@ -80,6 +80,8 @@ const StoryDefault = ({
|
|
80
80
|
size,
|
81
81
|
lang,
|
82
82
|
format,
|
83
|
+
min,
|
84
|
+
max,
|
83
85
|
...rest
|
84
86
|
}: StoryPropsDefault) => {
|
85
87
|
const [isOpen, setIsOpen] = useState(false);
|
@@ -103,6 +105,8 @@ const StoryDefault = ({
|
|
103
105
|
lang={lang}
|
104
106
|
format={format}
|
105
107
|
onCommitDate={() => setIsOpen(false)}
|
108
|
+
min={min}
|
109
|
+
max={max}
|
106
110
|
{...rest}
|
107
111
|
/>
|
108
112
|
);
|
@@ -188,6 +192,8 @@ const StoryRange = ({
|
|
188
192
|
secondValueSuccess,
|
189
193
|
size,
|
190
194
|
lang,
|
195
|
+
min,
|
196
|
+
max,
|
191
197
|
...rest
|
192
198
|
}: StoryPropsRange) => {
|
193
199
|
const rangeRef = useRef<RangeInputRefs>(null);
|
@@ -240,6 +246,8 @@ const StoryRange = ({
|
|
240
246
|
onChangeSecondValue(e, currentValue);
|
241
247
|
}}
|
242
248
|
lang={lang}
|
249
|
+
min={min}
|
250
|
+
max={max}
|
243
251
|
{...dividerIconProps}
|
244
252
|
{...rest}
|
245
253
|
/>
|
@@ -306,6 +314,8 @@ const StoryDeferred = ({
|
|
306
314
|
valueError,
|
307
315
|
valueSuccess,
|
308
316
|
size,
|
317
|
+
min,
|
318
|
+
max,
|
309
319
|
...rest
|
310
320
|
}: StoryPropsDefault) => {
|
311
321
|
const [isOpen, setIsOpen] = useState(false);
|
@@ -338,6 +348,8 @@ const StoryDeferred = ({
|
|
338
348
|
onChangeValue(e, currentValue);
|
339
349
|
}}
|
340
350
|
onCommitDate={() => setIsOpen(false)}
|
351
|
+
{...(min && { min: new Date(min) })}
|
352
|
+
{...(max && { max: new Date(max) })}
|
341
353
|
{...rest}
|
342
354
|
/>
|
343
355
|
</>
|
@@ -100,11 +100,11 @@ const StoryDefault = (args: CalendarProps) => {
|
|
100
100
|
isDouble={isDouble}
|
101
101
|
date={date}
|
102
102
|
value={(isRange ? valueRange : value) as Date & [Date, Date?]}
|
103
|
-
min={min}
|
104
|
-
max={max}
|
105
103
|
includeEdgeDates={includeEdgeDates}
|
106
104
|
locale={locale}
|
107
105
|
onChangeValue={(isRange ? handleOnRangeChange : handleOnChange) as (value: Date | [Date, Date?]) => void}
|
106
|
+
min={min}
|
107
|
+
max={max}
|
108
108
|
/>
|
109
109
|
);
|
110
110
|
};
|
@@ -146,24 +146,24 @@ const StoryBase = (args: CalendarBaseProps & { displayDouble: boolean }) => {
|
|
146
146
|
<CalendarDouble
|
147
147
|
size={size}
|
148
148
|
value={value}
|
149
|
-
min={min}
|
150
|
-
max={max}
|
151
149
|
includeEdgeDates={includeEdgeDates}
|
152
150
|
type={type}
|
153
151
|
locale={locale}
|
154
152
|
onChangeValue={handleOnChange}
|
153
|
+
{...(min && { min: new Date(min) })}
|
154
|
+
{...(max && { max: new Date(max) })}
|
155
155
|
{...rest}
|
156
156
|
/>
|
157
157
|
) : (
|
158
158
|
<CalendarBase
|
159
159
|
size={size}
|
160
160
|
value={value}
|
161
|
-
min={min}
|
162
|
-
max={max}
|
163
161
|
includeEdgeDates={includeEdgeDates}
|
164
162
|
type={type}
|
165
163
|
locale={locale}
|
166
164
|
onChangeValue={handleOnChange}
|
165
|
+
{...(min && { min: new Date(min) })}
|
166
|
+
{...(max && { max: new Date(max) })}
|
167
167
|
{...rest}
|
168
168
|
/>
|
169
169
|
);
|
@@ -233,24 +233,24 @@ const StoryRange = (args: CalendarBaseRangeProps & { displayDouble: boolean }) =
|
|
233
233
|
<CalendarBaseRange
|
234
234
|
size={size}
|
235
235
|
value={values}
|
236
|
-
min={min}
|
237
|
-
max={max}
|
238
236
|
includeEdgeDates={includeEdgeDates}
|
239
237
|
type={type}
|
240
238
|
onChangeValue={handleOnChange}
|
241
239
|
locale={locale}
|
240
|
+
{...(min && { min: new Date(min) })}
|
241
|
+
{...(max && { max: new Date(max) })}
|
242
242
|
{...rest}
|
243
243
|
/>
|
244
244
|
) : (
|
245
245
|
<CalendarDoubleRange
|
246
246
|
size={size}
|
247
247
|
value={values}
|
248
|
-
min={min}
|
249
|
-
max={max}
|
250
248
|
includeEdgeDates={includeEdgeDates}
|
251
249
|
type={type}
|
252
250
|
onChangeValue={handleOnChange}
|
253
251
|
locale={locale}
|
252
|
+
{...(min && { min: new Date(min) })}
|
253
|
+
{...(max && { max: new Date(max) })}
|
254
254
|
{...rest}
|
255
255
|
/>
|
256
256
|
);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { ComponentProps, useEffect, useRef, useState } from 'react';
|
2
2
|
import type { StoryObj, Meta } from '@storybook/react';
|
3
3
|
import { action } from '@storybook/addon-actions';
|
4
|
-
import { IconPlaceholder } from '@salutejs/plasma-sb-utils';
|
4
|
+
import { disableProps, IconPlaceholder } from '@salutejs/plasma-sb-utils';
|
5
5
|
|
6
6
|
import { WithTheme } from '../../../_helpers';
|
7
7
|
import { IconButton } from '../IconButton/IconButton';
|
@@ -80,6 +80,8 @@ const StoryDefault = ({
|
|
80
80
|
size,
|
81
81
|
lang,
|
82
82
|
format,
|
83
|
+
min,
|
84
|
+
max,
|
83
85
|
...rest
|
84
86
|
}: StoryPropsDefault) => {
|
85
87
|
const [isOpen, setIsOpen] = useState(false);
|
@@ -103,6 +105,8 @@ const StoryDefault = ({
|
|
103
105
|
lang={lang}
|
104
106
|
format={format}
|
105
107
|
onCommitDate={() => setIsOpen(false)}
|
108
|
+
min={min}
|
109
|
+
max={max}
|
106
110
|
{...rest}
|
107
111
|
/>
|
108
112
|
);
|
@@ -188,6 +192,8 @@ const StoryRange = ({
|
|
188
192
|
secondValueSuccess,
|
189
193
|
size,
|
190
194
|
lang,
|
195
|
+
min,
|
196
|
+
max,
|
191
197
|
...rest
|
192
198
|
}: StoryPropsRange) => {
|
193
199
|
const rangeRef = useRef<RangeInputRefs>(null);
|
@@ -240,6 +246,8 @@ const StoryRange = ({
|
|
240
246
|
onChangeSecondValue(e, currentValue);
|
241
247
|
}}
|
242
248
|
lang={lang}
|
249
|
+
min={min}
|
250
|
+
max={max}
|
243
251
|
{...dividerIconProps}
|
244
252
|
{...rest}
|
245
253
|
/>
|
@@ -306,6 +314,8 @@ const StoryDeferred = ({
|
|
306
314
|
valueError,
|
307
315
|
valueSuccess,
|
308
316
|
size,
|
317
|
+
min,
|
318
|
+
max,
|
309
319
|
...rest
|
310
320
|
}: StoryPropsDefault) => {
|
311
321
|
const [isOpen, setIsOpen] = useState(false);
|
@@ -338,6 +348,8 @@ const StoryDeferred = ({
|
|
338
348
|
onChangeValue(e, currentValue);
|
339
349
|
}}
|
340
350
|
onCommitDate={() => setIsOpen(false)}
|
351
|
+
{...(min && { min: new Date(min) })}
|
352
|
+
{...(max && { max: new Date(max) })}
|
341
353
|
{...rest}
|
342
354
|
/>
|
343
355
|
</>
|
@@ -23,8 +23,8 @@ import { IsOutOfRange, StyledCalendar } from './CalendarBase.styles';
|
|
23
23
|
export var calendarBaseRoot = function calendarBaseRoot(Root) {
|
24
24
|
return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
|
25
25
|
var externalValue = _ref.value,
|
26
|
-
|
27
|
-
|
26
|
+
minDate = _ref.min,
|
27
|
+
maxDate = _ref.max,
|
28
28
|
includeEdgeDates = _ref.includeEdgeDates,
|
29
29
|
_ref$type = _ref.type,
|
30
30
|
type = _ref$type === void 0 ? 'Days' : _ref$type,
|
@@ -63,6 +63,8 @@ export var calendarBaseRoot = function calendarBaseRoot(Root) {
|
|
63
63
|
_useState8 = _slicedToArray(_useState7, 2),
|
64
64
|
outOfRangeKey = _useState8[0],
|
65
65
|
setOutOfRangeKey = _useState8[1];
|
66
|
+
var min = minDate && new Date(minDate);
|
67
|
+
var max = maxDate && new Date(maxDate);
|
66
68
|
var _useReducer = useReducer(reducer, getInitialState(value, min, type)),
|
67
69
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
68
70
|
state = _useReducer2[0],
|
@@ -24,8 +24,8 @@ import { StyledCalendar, StyledSeparator, StyledWrapper } from './CalendarDouble
|
|
24
24
|
export var calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
25
25
|
return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
|
26
26
|
var externalValue = _ref.value,
|
27
|
-
|
28
|
-
|
27
|
+
minDate = _ref.min,
|
28
|
+
maxDate = _ref.max,
|
29
29
|
includeEdgeDates = _ref.includeEdgeDates,
|
30
30
|
_ref$type = _ref.type,
|
31
31
|
type = _ref$type === void 0 ? 'Days' : _ref$type,
|
@@ -64,6 +64,8 @@ export var calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
|
64
64
|
_useState8 = _slicedToArray(_useState7, 2),
|
65
65
|
outOfRangeKey = _useState8[0],
|
66
66
|
setOutOfRangeKey = _useState8[1];
|
67
|
+
var min = minDate && new Date(minDate);
|
68
|
+
var max = maxDate && new Date(maxDate);
|
67
69
|
var _useReducer = useReducer(reducer, getInitialState(value, min, type, true)),
|
68
70
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
69
71
|
state = _useReducer2[0],
|
@@ -35,13 +35,15 @@ export var CalendarMonths = function CalendarMonths(_ref) {
|
|
35
35
|
onSetSelected = _ref.onSetSelected,
|
36
36
|
onKeyDown = _ref.onKeyDown,
|
37
37
|
locale = _ref.locale;
|
38
|
+
var minDate = min ? new Date(min.getFullYear(), min.getMonth(), 1) : undefined;
|
39
|
+
var maxDate = max ? new Date(max.getFullYear(), max.getMonth() + 1, 0) : undefined;
|
38
40
|
var _useMonths = useMonths({
|
39
41
|
date: currentDate,
|
40
42
|
value: value,
|
41
43
|
eventList: eventList,
|
42
44
|
disabledList: disabledList,
|
43
|
-
min:
|
44
|
-
max:
|
45
|
+
min: minDate,
|
46
|
+
max: maxDate,
|
45
47
|
locale: locale
|
46
48
|
}),
|
47
49
|
_useMonths2 = _slicedToArray(_useMonths, 2),
|
@@ -34,13 +34,15 @@ export var CalendarQuarters = function CalendarQuarters(_ref) {
|
|
34
34
|
onHoverQuarter = _ref.onHoverQuarter,
|
35
35
|
onSetSelected = _ref.onSetSelected,
|
36
36
|
onKeyDown = _ref.onKeyDown;
|
37
|
+
var minDate = min ? new Date(min.getFullYear(), min.getMonth(), 1) : undefined;
|
38
|
+
var maxDate = max ? new Date(max.getFullYear(), max.getMonth() + 1, 0) : undefined;
|
37
39
|
var _useQuarters = useQuarters({
|
38
40
|
date: currentDate,
|
39
41
|
value: value,
|
40
42
|
eventList: eventList,
|
41
43
|
disabledList: disabledList,
|
42
|
-
min:
|
43
|
-
max:
|
44
|
+
min: minDate,
|
45
|
+
max: maxDate
|
44
46
|
}),
|
45
47
|
_useQuarters2 = _slicedToArray(_useQuarters, 2),
|
46
48
|
quarters = _useQuarters2[0],
|
@@ -35,14 +35,16 @@ export var CalendarYears = function CalendarYears(_ref) {
|
|
35
35
|
onHoverYear = _ref.onHoverYear,
|
36
36
|
onSetSelected = _ref.onSetSelected,
|
37
37
|
onKeyDown = _ref.onKeyDown;
|
38
|
+
var minDate = min ? new Date(min.getFullYear(), 0, 1) : undefined;
|
39
|
+
var maxDate = max ? new Date(max.getFullYear(), 11, 31) : undefined;
|
38
40
|
var _useYears = useYears({
|
39
41
|
date: currentDate,
|
40
42
|
value: value,
|
41
43
|
startYear: startYear,
|
42
44
|
eventList: eventList,
|
43
45
|
disabledList: disabledList,
|
44
|
-
min:
|
45
|
-
max:
|
46
|
+
min: minDate,
|
47
|
+
max: maxDate
|
46
48
|
}),
|
47
49
|
_useYears2 = _slicedToArray(_useYears, 2),
|
48
50
|
years = _useYears2[0],
|
@@ -100,11 +100,11 @@ const StoryDefault = (args: CalendarProps) => {
|
|
100
100
|
isDouble={isDouble}
|
101
101
|
date={date}
|
102
102
|
value={(isRange ? valueRange : value) as Date & [Date, Date?]}
|
103
|
-
min={min}
|
104
|
-
max={max}
|
105
103
|
includeEdgeDates={includeEdgeDates}
|
106
104
|
locale={locale}
|
107
105
|
onChangeValue={(isRange ? handleOnRangeChange : handleOnChange) as (value: Date | [Date, Date?]) => void}
|
106
|
+
min={min}
|
107
|
+
max={max}
|
108
108
|
/>
|
109
109
|
);
|
110
110
|
};
|
@@ -146,24 +146,24 @@ const StoryBase = (args: CalendarBaseProps & { displayDouble: boolean }) => {
|
|
146
146
|
<CalendarDouble
|
147
147
|
size={size}
|
148
148
|
value={value}
|
149
|
-
min={min}
|
150
|
-
max={max}
|
151
149
|
includeEdgeDates={includeEdgeDates}
|
152
150
|
type={type}
|
153
151
|
locale={locale}
|
154
152
|
onChangeValue={handleOnChange}
|
153
|
+
{...(min && { min: new Date(min) })}
|
154
|
+
{...(max && { max: new Date(max) })}
|
155
155
|
{...rest}
|
156
156
|
/>
|
157
157
|
) : (
|
158
158
|
<CalendarBase
|
159
159
|
size={size}
|
160
160
|
value={value}
|
161
|
-
min={min}
|
162
|
-
max={max}
|
163
161
|
includeEdgeDates={includeEdgeDates}
|
164
162
|
type={type}
|
165
163
|
locale={locale}
|
166
164
|
onChangeValue={handleOnChange}
|
165
|
+
{...(min && { min: new Date(min) })}
|
166
|
+
{...(max && { max: new Date(max) })}
|
167
167
|
{...rest}
|
168
168
|
/>
|
169
169
|
);
|
@@ -233,24 +233,24 @@ const StoryRange = (args: CalendarBaseRangeProps & { displayDouble: boolean }) =
|
|
233
233
|
<CalendarBaseRange
|
234
234
|
size={size}
|
235
235
|
value={values}
|
236
|
-
min={min}
|
237
|
-
max={max}
|
238
236
|
includeEdgeDates={includeEdgeDates}
|
239
237
|
type={type}
|
240
238
|
onChangeValue={handleOnChange}
|
241
239
|
locale={locale}
|
240
|
+
{...(min && { min: new Date(min) })}
|
241
|
+
{...(max && { max: new Date(max) })}
|
242
242
|
{...rest}
|
243
243
|
/>
|
244
244
|
) : (
|
245
245
|
<CalendarDoubleRange
|
246
246
|
size={size}
|
247
247
|
value={values}
|
248
|
-
min={min}
|
249
|
-
max={max}
|
250
248
|
includeEdgeDates={includeEdgeDates}
|
251
249
|
type={type}
|
252
250
|
onChangeValue={handleOnChange}
|
253
251
|
locale={locale}
|
252
|
+
{...(min && { min: new Date(min) })}
|
253
|
+
{...(max && { max: new Date(max) })}
|
254
254
|
{...rest}
|
255
255
|
/>
|
256
256
|
);
|