@salutejs/plasma-new-hope 0.81.1-canary.1209.9113456949.0 → 0.82.0-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Calendar/Calendar.types.js.map +1 -1
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js +3 -1
- package/cjs/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +4 -1
- package/cjs/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/cjs/components/Calendar/hooks/useDays.js +6 -3
- package/cjs/components/Calendar/hooks/useDays.js.map +1 -1
- package/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js +2 -1
- package/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js.map +1 -1
- package/es/components/Calendar/Calendar.types.js.map +1 -1
- package/es/components/Calendar/CalendarBase/CalendarBase.js +3 -1
- package/es/components/Calendar/CalendarBase/CalendarBase.js.map +1 -1
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js +4 -1
- package/es/components/Calendar/CalendarDouble/CalendarDouble.js.map +1 -1
- package/es/components/Calendar/hooks/useDays.js +6 -3
- package/es/components/Calendar/hooks/useDays.js.map +1 -1
- package/es/components/Calendar/ui/CalendarDays/CalendarDays.js +2 -1
- package/es/components/Calendar/ui/CalendarDays/CalendarDays.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Calendar/CalendarBase/CalendarBase.js +3 -1
- package/styled-components/cjs/components/Calendar/CalendarDouble/CalendarDouble.js +4 -1
- package/styled-components/cjs/components/Calendar/hooks/useDays.js +6 -3
- package/styled-components/cjs/components/Calendar/ui/CalendarDays/CalendarDays.js +2 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +18 -6
- package/styled-components/cjs/examples/plasma_b2c/components/TextArea/TextArea.config.js +4 -4
- package/styled-components/cjs/examples/plasma_web/components/Calendar/Calendar.stories.tsx +18 -6
- package/styled-components/cjs/examples/plasma_web/components/TextArea/TextArea.config.js +4 -4
- package/styled-components/cjs/examples/sds_engineer/components/Calendar/Calendar.stories.tsx +18 -6
- package/styled-components/es/components/Calendar/CalendarBase/CalendarBase.js +3 -1
- package/styled-components/es/components/Calendar/CalendarDouble/CalendarDouble.js +4 -1
- package/styled-components/es/components/Calendar/hooks/useDays.js +6 -3
- package/styled-components/es/components/Calendar/ui/CalendarDays/CalendarDays.js +2 -1
- package/styled-components/es/examples/plasma_b2c/components/Calendar/Calendar.stories.tsx +18 -6
- package/styled-components/es/examples/plasma_b2c/components/TextArea/TextArea.config.js +4 -4
- package/styled-components/es/examples/plasma_web/components/Calendar/Calendar.stories.tsx +18 -6
- package/styled-components/es/examples/plasma_web/components/TextArea/TextArea.config.js +4 -4
- package/styled-components/es/examples/sds_engineer/components/Calendar/Calendar.stories.tsx +18 -6
- package/types/components/Calendar/Calendar.types.d.ts +4 -0
- package/types/components/Calendar/Calendar.types.d.ts.map +1 -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/hooks/useDays.d.ts +1 -1
- package/types/components/Calendar/hooks/useDays.d.ts.map +1 -1
- package/types/components/Calendar/ui/CalendarDays/CalendarDays.d.ts.map +1 -1
- package/types/components/Calendar/ui/CalendarDays/CalendarDays.types.d.ts +1 -0
- package/types/components/Calendar/ui/CalendarDays/CalendarDays.types.d.ts.map +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarBase.js","sources":["../../../../src/components/Calendar/CalendarBase/CalendarBase.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useReducer, useState, KeyboardEvent, HTMLAttributes, forwardRef } from 'react';\n\nimport type { Calendar, DateObject, UseKeyNavigationProps } from '../Calendar.types';\nimport type { CalendarStateType } from '../store/types';\nimport { getInitialState, reducer } from '../store/reducer';\nimport { ActionType, CalendarState } from '../store/types';\nimport { isValueUpdate, YEAR_RENDER_COUNT } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader, CalendarMonths, CalendarYears } from '../ui';\nimport { RootProps } from '../../../engines';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { IsOutOfRange, StyledCalendar } from './CalendarBase.styles';\n\nexport type CalendarBaseProps = HTMLAttributes<HTMLDivElement> &\n Calendar & {\n /**\n * Тип отображения календаря: дни, месяца, года.\n */\n type?: CalendarStateType;\n };\n\n/**\n * Компонент календаря.\n */\nexport const calendarBaseRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarBaseProps>(\n (\n { value: externalValue, min, max, type = 'Days', eventList, disabledList, onChangeValue, ...rest },\n outerRootRef,\n ) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n const [prevType, setPrevType] = useState(type);\n const [prevValue, setPrevValue] = useState(value);\n const [outOfRangeKey, setOutOfRangeKey] = useState<number>(0);\n\n const [state, dispatch] = useReducer(reducer, getInitialState(value, [5, 6], type));\n\n const { date, calendarState, startYear, size } = state;\n\n const handlePrev = useCallback<UseKeyNavigationProps['onPrev']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.PREVIOUS_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.PREVIOUS_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.PREVIOUS_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.PREVIOUS_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const handleNext = useCallback<UseKeyNavigationProps['onNext']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.NEXT_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.NEXT_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.NEXT_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.NEXT_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs, isOutOfRange] = useKeyNavigation({\n size,\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const handleOnChangeMonth = useCallback((monthIndex: number) => {\n dispatch({\n type: ActionType.UPDATE_MONTH,\n payload: { calendarState: CalendarState.Days, monthIndex, size: [5, 6] },\n });\n }, []);\n\n const handleOnChangeYear = useCallback((year: number) => {\n dispatch({\n type: ActionType.UPDATE_YEAR,\n payload: { calendarState: CalendarState.Months, year },\n });\n }, []);\n\n const handleUpdateCalendarState = useCallback(\n (newCalendarState: CalendarStateType, newSize: [number, number]) => {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: newCalendarState, size: newSize },\n });\n },\n [],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n dispatch({\n type: ActionType.UPDATE_DATE,\n payload: { value },\n });\n\n setPrevValue(value);\n }\n\n if (prevType !== type) {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: type },\n });\n\n setPrevType(type);\n }\n\n // Изменяем ключ каждый раз как пытаемся перейти на даты которые находятся за пределами min/max ограничений.\n // Это необходимо для того чтобы screen-reader корректно озвучивал уведомление aria-live=\"assertive\"\n // о том что нет доступных дат\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n setOutOfRangeKey((previousState) => Number(!previousState));\n\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n {isOutOfRange && (\n <IsOutOfRange\n key={outOfRangeKey}\n aria-atomic=\"true\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-relevant=\"additions\"\n >\n Далее нет доступных дат.\n </IsOutOfRange>\n )}\n <CalendarHeader\n firstDate={date}\n startYear={startYear}\n type={calendarState}\n onPrev={handlePrev}\n onNext={handleNext}\n onUpdateCalendarState={handleUpdateCalendarState}\n />\n {calendarState === CalendarState.Days && (\n <CalendarDays\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={date}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={handleKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Months && (\n <CalendarMonths\n date={date}\n selectIndexes={selectIndexes}\n onChangeMonth={handleOnChangeMonth}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Years && (\n <CalendarYears\n date={date}\n startYear={startYear}\n selectIndexes={selectIndexes}\n onChangeYear={handleOnChangeYear}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n </Root>\n );\n },\n );\n\nexport const calendarBaseConfig = {\n name: 'CalendarBase',\n tag: 'div',\n layout: calendarBaseRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarBaseRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","_ref$type","type","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","_useState4","prevType","setPrevType","_useState5","_useState6","prevValue","setPrevValue","_useState7","_useState8","outOfRangeKey","setOutOfRangeKey","_useReducer","useReducer","reducer","getInitialState","_useReducer2","state","dispatch","date","calendarState","startYear","size","handlePrev","useCallback","withShift","arguments","length","undefined","CalendarState","Days","ActionType","PREVIOUS_YEAR","payload","step","PREVIOUS_MONTH","monthIndex","year","Months","Years","PREVIOUS_START_YEAR","yearsCount","YEAR_RENDER_COUNT","handleNext","NEXT_YEAR","NEXT_MONTH","NEXT_START_YEAR","_useKeyNavigation","useKeyNavigation","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","isOutOfRange","handleOnChangeDay","newDate","coord","newDay","Date","day","handleOnChangeMonth","UPDATE_MONTH","handleOnChangeYear","UPDATE_YEAR","handleUpdateCalendarState","newCalendarState","newSize","UPDATE_CALENDAR_STATE","isValueUpdate","UPDATE_DATE","handleKeyDown","event","previousState","Number","React","createElement","_extends","ref","IsOutOfRange","key","role","CalendarHeader","firstDate","onUpdateCalendarState","CalendarDays","onChangeDay","onHoverDay","onSetSelected","CalendarMonths","onChangeMonth","CalendarYears","onChangeYear","calendarBaseConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;AAuBA;AACA;AACA;IACaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC5FC,UAAU,CACN,UAAAC,IAAA,EAEIC,YAAY,EACX;AAAA,IAAA,IAFQC,a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AA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNJ,IAAAA,IAAI,EAAE,SAAS;AACfhF,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"CalendarBase.js","sources":["../../../../src/components/Calendar/CalendarBase/CalendarBase.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useReducer, useState, KeyboardEvent, HTMLAttributes, forwardRef } from 'react';\n\nimport type { Calendar, DateObject, UseKeyNavigationProps } from '../Calendar.types';\nimport type { CalendarStateType } from '../store/types';\nimport { getInitialState, reducer } from '../store/reducer';\nimport { ActionType, CalendarState } from '../store/types';\nimport { isValueUpdate, YEAR_RENDER_COUNT } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader, CalendarMonths, CalendarYears } from '../ui';\nimport { RootProps } from '../../../engines';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { IsOutOfRange, StyledCalendar } from './CalendarBase.styles';\n\nexport type CalendarBaseProps = HTMLAttributes<HTMLDivElement> &\n Calendar & {\n /**\n * Тип отображения календаря: дни, месяца, года.\n */\n type?: CalendarStateType;\n };\n\n/**\n * Компонент календаря.\n */\nexport const calendarBaseRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarBaseProps>(\n (\n {\n value: externalValue,\n min,\n max,\n includeEdgeDates,\n type = 'Days',\n eventList,\n disabledList,\n onChangeValue,\n ...rest\n },\n outerRootRef,\n ) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n const [prevType, setPrevType] = useState(type);\n const [prevValue, setPrevValue] = useState(value);\n const [outOfRangeKey, setOutOfRangeKey] = useState<number>(0);\n\n const [state, dispatch] = useReducer(reducer, getInitialState(value, [5, 6], type));\n\n const { date, calendarState, startYear, size } = state;\n\n const handlePrev = useCallback<UseKeyNavigationProps['onPrev']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.PREVIOUS_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.PREVIOUS_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.PREVIOUS_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.PREVIOUS_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const handleNext = useCallback<UseKeyNavigationProps['onNext']>(\n (withShift = false) => {\n if (calendarState === CalendarState.Days) {\n if (withShift) {\n dispatch({\n type: ActionType.NEXT_YEAR,\n payload: { step: 1 },\n });\n\n return;\n }\n\n dispatch({\n type: ActionType.NEXT_MONTH,\n payload: { monthIndex: date.monthIndex, year: date.year },\n });\n\n return;\n }\n\n if (calendarState === CalendarState.Months) {\n dispatch({ type: ActionType.NEXT_YEAR, payload: { step: 1 } });\n\n return;\n }\n\n if (calendarState === CalendarState.Years) {\n dispatch({ type: ActionType.NEXT_START_YEAR, payload: { yearsCount: YEAR_RENDER_COUNT } });\n }\n },\n [date, calendarState],\n );\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs, isOutOfRange] = useKeyNavigation({\n size,\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const handleOnChangeMonth = useCallback((monthIndex: number) => {\n dispatch({\n type: ActionType.UPDATE_MONTH,\n payload: { calendarState: CalendarState.Days, monthIndex, size: [5, 6] },\n });\n }, []);\n\n const handleOnChangeYear = useCallback((year: number) => {\n dispatch({\n type: ActionType.UPDATE_YEAR,\n payload: { calendarState: CalendarState.Months, year },\n });\n }, []);\n\n const handleUpdateCalendarState = useCallback(\n (newCalendarState: CalendarStateType, newSize: [number, number]) => {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: newCalendarState, size: newSize },\n });\n },\n [],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n dispatch({\n type: ActionType.UPDATE_DATE,\n payload: { value },\n });\n\n setPrevValue(value);\n }\n\n if (prevType !== type) {\n dispatch({\n type: ActionType.UPDATE_CALENDAR_STATE,\n payload: { calendarState: type },\n });\n\n setPrevType(type);\n }\n\n // Изменяем ключ каждый раз как пытаемся перейти на даты которые находятся за пределами min/max ограничений.\n // Это необходимо для того чтобы screen-reader корректно озвучивал уведомление aria-live=\"assertive\"\n // о том что нет доступных дат\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n setOutOfRangeKey((previousState) => Number(!previousState));\n\n onKeyDown(event);\n },\n [onKeyDown],\n );\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n {isOutOfRange && (\n <IsOutOfRange\n key={outOfRangeKey}\n aria-atomic=\"true\"\n role=\"alert\"\n aria-live=\"assertive\"\n aria-relevant=\"additions\"\n >\n Далее нет доступных дат.\n </IsOutOfRange>\n )}\n <CalendarHeader\n firstDate={date}\n startYear={startYear}\n type={calendarState}\n onPrev={handlePrev}\n onNext={handleNext}\n onUpdateCalendarState={handleUpdateCalendarState}\n />\n {calendarState === CalendarState.Days && (\n <CalendarDays\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n includeEdgeDates={includeEdgeDates}\n value={externalValue}\n date={date}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={handleKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Months && (\n <CalendarMonths\n date={date}\n selectIndexes={selectIndexes}\n onChangeMonth={handleOnChangeMonth}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n {calendarState === CalendarState.Years && (\n <CalendarYears\n date={date}\n startYear={startYear}\n selectIndexes={selectIndexes}\n onChangeYear={handleOnChangeYear}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n )}\n </Root>\n );\n },\n );\n\nexport const calendarBaseConfig = {\n name: 'CalendarBase',\n tag: 'div',\n layout: calendarBaseRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarBaseRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","includeEdgeDates","_ref$type","type","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","_useState4","prevType","setPrevType","_useState5","_useState6","prevValue","setPrevValue","_useState7","_useState8","outOfRangeKey","setOutOfRangeKey","_useReducer","useReducer","reducer","getInitialState","_useReducer2","state","dispatch","date","calendarState","startYear","size","handlePrev","useCallback","withShift","arguments","length","undefined","CalendarState","Days","ActionType","PREVIOUS_YEAR","payload","step","PREVIOUS_MONTH","monthIndex","year","Months","Years","PREVIOUS_START_YEAR","yearsCount","YEAR_RENDER_COUNT","handleNext","NEXT_YEAR","NEXT_MONTH","NEXT_START_YEAR","_useKeyNavigation","useKeyNavigation","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","isOutOfRange","handleOnChangeDay","newDate","coord","newDay","Date","day","handleOnChangeMonth","UPDATE_MONTH","handleOnChangeYear","UPDATE_YEAR","handleUpdateCalendarState","newCalendarState","newSize","UPDATE_CALENDAR_STATE","isValueUpdate","UPDATE_DATE","handleKeyDown","event","previousState","Number","React","createElement","_extends","ref","IsOutOfRange","key","role","CalendarHeader","firstDate","onUpdateCalendarState","CalendarDays","onChangeDay","onHoverDay","onSetSelected","CalendarMonths","onChangeMonth","CalendarYears","onChangeYear","calendarBaseConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","sizeCSS","defaults"],"mappings":";;;;;;;;;;;;;;;AAuBA;AACA;AACA;IACaA,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC5FC,UAAU,CACN,UAAAC,IAAA,EAYIC,YAAY,EACX;AAAA,IAAA,IAXUC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MACLC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MACHC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MACHC,gBAAgB,GAAAN,IAAA,CAAhBM,gBAAgB;MAAAC,SAAA,GAAAP,IAAA,CAChBQ,IAAI;AAAJA,MAAAA,IAAI,GAAAD,SAAA,KAAG,KAAA,CAAA,GAAA,MAAM,GAAAA,SAAA;MACbE,SAAS,GAAAT,IAAA,CAATS,SAAS;MACTC,YAAY,GAAAV,IAAA,CAAZU,YAAY;MACZC,aAAa,GAAAX,IAAA,CAAbW,aAAa;AACVC,MAAAA,IAAI,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA,CAAA,CAAA;IAIX,IAAAC,QAAA,GAAkCC,OAAO,CACrC,YAAA;QAAA,OAAOC,KAAK,CAACC,OAAO,CAAChB,aAAa,CAAC,GAAGA,aAAa,GAAG,CAACA,aAAa,CAAC,CAAA;AAAA,OAAC,EACtE,CAACA,aAAa,CAClB,CAAC;MAAAiB,SAAA,GAAAC,cAAA,CAAAL,QAAA,EAAA,CAAA,CAAA;AAHMM,MA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;AACXE,MAAAA,SAAS,EAAEA,SAAU;AACrB+B,MAAAA,aAAa,EAAEA,aAAc;AAC7B0C,MAAAA,YAAY,EAAE7B,kBAAmB;AACjCyB,MAAAA,aAAa,EAAEpC,eAAgB;AAC/BD,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,SAAS,EAAEA,SAAAA;AAAU,KACxB,CAEH,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMwC,kBAAkB,GAAG;AAC9BC,EAAAA,IAAI,EAAE,cAAc;AACpBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEjI,gBAAgB;AACxBkI,EAAAA,IAAI,EAAEC,cAAc;AACpBC,EAAAA,UAAU,EAAE;AACRC,IAAAA,IAAI,EAAE;AACFC,MAAAA,GAAG,EAAEC,IAAAA;KACR;AACDlF,IAAAA,IAAI,EAAE;AACFiF,MAAAA,GAAG,EAAEE,MAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNJ,IAAAA,IAAI,EAAE,SAAS;AACfhF,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -10,7 +10,7 @@ import { base } from './variations/_view/base.js';
|
|
10
10
|
import { StyledWrapper, StyledSeparator, StyledCalendar } from './CalendarDouble.styles.js';
|
11
11
|
|
12
12
|
var _StyledSeparator;
|
13
|
-
var _excluded = ["value", "min", "max", "eventList", "disabledList", "onChangeValue"];
|
13
|
+
var _excluded = ["value", "min", "max", "includeEdgeDates", "eventList", "disabledList", "onChangeValue"];
|
14
14
|
/**
|
15
15
|
* Компонент двойного календаря.
|
16
16
|
*/
|
@@ -19,6 +19,7 @@ var calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
|
19
19
|
var externalValue = _ref.value,
|
20
20
|
min = _ref.min,
|
21
21
|
max = _ref.max,
|
22
|
+
includeEdgeDates = _ref.includeEdgeDates,
|
22
23
|
eventList = _ref.eventList,
|
23
24
|
disabledList = _ref.disabledList,
|
24
25
|
onChangeValue = _ref.onChangeValue,
|
@@ -142,6 +143,7 @@ var calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
|
142
143
|
disabledList: disabledList,
|
143
144
|
min: min,
|
144
145
|
max: max,
|
146
|
+
includeEdgeDates: includeEdgeDates,
|
145
147
|
value: externalValue,
|
146
148
|
date: firstDate,
|
147
149
|
hoveredDay: hoveredDay,
|
@@ -158,6 +160,7 @@ var calendarDoubleRoot = function calendarDoubleRoot(Root) {
|
|
158
160
|
disabledList: disabledList,
|
159
161
|
min: min,
|
160
162
|
max: max,
|
163
|
+
includeEdgeDates: includeEdgeDates,
|
161
164
|
value: externalValue,
|
162
165
|
date: secondDate,
|
163
166
|
hoveredDay: hoveredDay,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarDouble.js","sources":["../../../../src/components/Calendar/CalendarDouble/CalendarDouble.tsx"],"sourcesContent":["import React, { useState, useCallback, useMemo, forwardRef, HTMLAttributes } from 'react';\n\nimport type { Calendar, DateObject } from '../Calendar.types';\nimport { getDateFromValue, getNextDate, getPrevDate, isValueUpdate } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader } from '../ui';\nimport { RootProps } from '../../../engines/types';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { StyledCalendar, StyledSeparator, StyledWrapper } from './CalendarDouble.styles';\n\nexport type CalendarDoubleProps = HTMLAttributes<HTMLDivElement> & Calendar;\n\n/**\n * Компонент двойного календаря.\n */\nexport const calendarDoubleRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarDoubleProps>(\n ({ value: externalValue, min, max, eventList, disabledList, onChangeValue, ...rest }, outerRootRef) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n\n const [date, setDate] = useState<DateObject>(getDateFromValue(value));\n const [prevValue, setPrevValue] = useState(value);\n const [doubleDate, setMonths] = useState(() => {\n const nextDate = getDateFromValue(firstValue);\n const [initialYear, initialMonth] = getNextDate(nextDate.year, nextDate.monthIndex);\n\n return {\n monthIndex: [nextDate.monthIndex, initialMonth],\n year: [nextDate.year, initialYear],\n };\n });\n\n const handleMonth = useCallback(\n (getDate: (currentYear: number, currentMonth: number) => number[]) => {\n const [newCurrentYear, newCurrentMonth] = getDate(doubleDate.year[0], doubleDate.monthIndex[0]);\n const [newNextYear, newNextMonth] = getDate(doubleDate.year[1], doubleDate.monthIndex[1]);\n\n setMonths({\n monthIndex: [newCurrentMonth, newNextMonth],\n year: [newCurrentYear, newNextYear],\n });\n },\n [doubleDate],\n );\n\n const handlePrev = useCallback(() => {\n handleMonth(getPrevDate);\n }, [handleMonth]);\n\n const handleNext = useCallback(() => {\n handleMonth(getNextDate);\n }, [handleMonth]);\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs] = useKeyNavigation({\n isDouble: true,\n size: [11, 6],\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const firstDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[0],\n monthIndex: doubleDate.monthIndex[0],\n }),\n [date, doubleDate],\n );\n\n const secondDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[1],\n monthIndex: doubleDate.monthIndex[1],\n }),\n [date, doubleDate],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n const newDate = getDateFromValue(value);\n\n const { year, monthIndex } = newDate;\n\n const {\n monthIndex: [, prevMonthIndex],\n year: [, prevYear],\n } = doubleDate;\n\n if (prevMonthIndex !== monthIndex || prevYear !== year) {\n const [nextYear, nextMonthIndex] = getNextDate(year, monthIndex);\n\n setDate(newDate);\n\n setMonths({\n monthIndex: [monthIndex, nextMonthIndex],\n year: [year, nextYear],\n });\n }\n\n setPrevValue(value);\n }\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n <CalendarHeader\n isDouble\n firstDate={firstDate}\n secondDate={secondDate}\n onPrev={handlePrev}\n onNext={handleNext}\n />\n\n <StyledWrapper>\n <CalendarDays\n isDouble\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={firstDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n <StyledSeparator />\n <CalendarDays\n isDouble\n isSecond\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n value={externalValue}\n date={secondDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n </StyledWrapper>\n </Root>\n );\n },\n );\n\nexport const calendarDoubleConfig = {\n name: 'CalendarDouble',\n tag: 'div',\n layout: calendarDoubleRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarDoubleRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","getDateFromValue","_useState4","date","setDate","_useState5","_useState6","prevValue","setPrevValue","_useState7","nextDate","_getNextDate","getNextDate","year","monthIndex","_getNextDate2","initialYear","initialMonth","_useState8","doubleDate","setMonths","handleMonth","useCallback","getDate","_getDate","_getDate2","newCurrentYear","newCurrentMonth","_getDate3","_getDate4","newNextYear","newNextMonth","handlePrev","getPrevDate","handleNext","_useKeyNavigation","useKeyNavigation","isDouble","size","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","handleOnChangeDay","newDate","coord","newDay","Date","day","firstDate","secondDate","isValueUpdate","_doubleDate$monthInde","prevMonthIndex","_doubleDate$year","prevYear","_getNextDate3","_getNextDate4","nextYear","nextMonthIndex","React","createElement","_extends","ref","CalendarHeader","StyledWrapper","CalendarDays","onChangeDay","onHoverDay","onSetSelected","_StyledSeparator","StyledSeparator","isSecond","calendarDoubleConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","defaults"],"mappings":";;;;;;;;;;;;;AAaA;AACA;AACA;IACaA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC9FC,UAAU,CACN,UAAAC,IAAA,EAAsFC,YAAY,EAAK;AAAA,IAAA,IAA7FC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MAAiBC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MAAEC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MAAEC,SAAS,GAAAN,IAAA,CAATM,SAAS;MAAEC,YAAY,GAAAP,IAAA,CAAZO,YAAY;MAAEC,aAAa,GAAAR,IAAA,CAAbQ,aAAa;AAAKC,MAAAA,IAAI,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;IAC9E,IAAAC,QAAA,GAAkCC,OAAO,CACrC,YAAA;QAAA,OAAOC,KAAK,CAACC,OAAO,CAACb,aAAa,CAAC,GAAGA,aAAa,GAAG,CAACA,aAAa,CAAC,CAAA;AAAA,OAAC,EACtE,CAACA,aAAa,CAClB,CAAC;MAAAc,SAAA,GAAAC,cAAA,CAAAL,QAAA,EAAA,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,EAAAA,QAAQ,EAAE;AACNH,IAAAA,IAAI,EAAE,SAAS;AACf7C,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
1
|
+
{"version":3,"file":"CalendarDouble.js","sources":["../../../../src/components/Calendar/CalendarDouble/CalendarDouble.tsx"],"sourcesContent":["import React, { useState, useCallback, useMemo, forwardRef, HTMLAttributes } from 'react';\n\nimport type { Calendar, DateObject } from '../Calendar.types';\nimport { getDateFromValue, getNextDate, getPrevDate, isValueUpdate } from '../utils';\nimport { useKeyNavigation } from '../hooks';\nimport { CalendarDays, CalendarHeader } from '../ui';\nimport { RootProps } from '../../../engines/types';\n\nimport { base as viewCSS } from './variations/_view/base';\nimport { StyledCalendar, StyledSeparator, StyledWrapper } from './CalendarDouble.styles';\n\nexport type CalendarDoubleProps = HTMLAttributes<HTMLDivElement> & Calendar;\n\n/**\n * Компонент двойного календаря.\n */\nexport const calendarDoubleRoot = (Root: RootProps<HTMLDivElement, HTMLAttributes<HTMLDivElement>>) =>\n forwardRef<HTMLDivElement, CalendarDoubleProps>(\n (\n { value: externalValue, min, max, includeEdgeDates, eventList, disabledList, onChangeValue, ...rest },\n outerRootRef,\n ) => {\n const [firstValue, secondValue] = useMemo(\n () => (Array.isArray(externalValue) ? externalValue : [externalValue]),\n [externalValue],\n );\n const value = secondValue || firstValue;\n const [hoveredDay, setHoveredDay] = useState<DateObject | undefined>();\n\n const [date, setDate] = useState<DateObject>(getDateFromValue(value));\n const [prevValue, setPrevValue] = useState(value);\n const [doubleDate, setMonths] = useState(() => {\n const nextDate = getDateFromValue(firstValue);\n const [initialYear, initialMonth] = getNextDate(nextDate.year, nextDate.monthIndex);\n\n return {\n monthIndex: [nextDate.monthIndex, initialMonth],\n year: [nextDate.year, initialYear],\n };\n });\n\n const handleMonth = useCallback(\n (getDate: (currentYear: number, currentMonth: number) => number[]) => {\n const [newCurrentYear, newCurrentMonth] = getDate(doubleDate.year[0], doubleDate.monthIndex[0]);\n const [newNextYear, newNextMonth] = getDate(doubleDate.year[1], doubleDate.monthIndex[1]);\n\n setMonths({\n monthIndex: [newCurrentMonth, newNextMonth],\n year: [newCurrentYear, newNextYear],\n });\n },\n [doubleDate],\n );\n\n const handlePrev = useCallback(() => {\n handleMonth(getPrevDate);\n }, [handleMonth]);\n\n const handleNext = useCallback(() => {\n handleMonth(getNextDate);\n }, [handleMonth]);\n\n const [selectIndexes, onKeyDown, onSelectIndexes, outerRefs] = useKeyNavigation({\n isDouble: true,\n size: [11, 6],\n onNext: handleNext,\n onPrev: handlePrev,\n });\n\n const handleOnChangeDay = useCallback(\n (newDate: DateObject, coord: number[]) => {\n const newDay = new Date(newDate.year, newDate.monthIndex, newDate.day);\n onChangeValue?.(newDay);\n\n onSelectIndexes(coord);\n },\n [onChangeValue, onSelectIndexes],\n );\n\n const firstDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[0],\n monthIndex: doubleDate.monthIndex[0],\n }),\n [date, doubleDate],\n );\n\n const secondDate = useMemo(\n () => ({\n day: date.day,\n year: doubleDate.year[1],\n monthIndex: doubleDate.monthIndex[1],\n }),\n [date, doubleDate],\n );\n\n if (value && prevValue && isValueUpdate(value, prevValue)) {\n const newDate = getDateFromValue(value);\n\n const { year, monthIndex } = newDate;\n\n const {\n monthIndex: [, prevMonthIndex],\n year: [, prevYear],\n } = doubleDate;\n\n if (prevMonthIndex !== monthIndex || prevYear !== year) {\n const [nextYear, nextMonthIndex] = getNextDate(year, monthIndex);\n\n setDate(newDate);\n\n setMonths({\n monthIndex: [monthIndex, nextMonthIndex],\n year: [year, nextYear],\n });\n }\n\n setPrevValue(value);\n }\n\n return (\n <Root ref={outerRootRef} aria-label=\"Выбор даты\" {...rest}>\n <CalendarHeader\n isDouble\n firstDate={firstDate}\n secondDate={secondDate}\n onPrev={handlePrev}\n onNext={handleNext}\n />\n\n <StyledWrapper>\n <CalendarDays\n isDouble\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n includeEdgeDates={includeEdgeDates}\n value={externalValue}\n date={firstDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n <StyledSeparator />\n <CalendarDays\n isDouble\n isSecond\n eventList={eventList}\n disabledList={disabledList}\n min={min}\n max={max}\n includeEdgeDates={includeEdgeDates}\n value={externalValue}\n date={secondDate}\n hoveredDay={hoveredDay}\n selectIndexes={selectIndexes}\n onChangeDay={handleOnChangeDay}\n onHoverDay={setHoveredDay}\n onSetSelected={onSelectIndexes}\n onKeyDown={onKeyDown}\n outerRefs={outerRefs}\n />\n </StyledWrapper>\n </Root>\n );\n },\n );\n\nexport const calendarDoubleConfig = {\n name: 'CalendarDouble',\n tag: 'div',\n layout: calendarDoubleRoot,\n base: StyledCalendar,\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'primary',\n size: 'm',\n },\n};\n"],"names":["calendarDoubleRoot","Root","forwardRef","_ref","outerRootRef","externalValue","value","min","max","includeEdgeDates","eventList","disabledList","onChangeValue","rest","_objectWithoutProperties","_excluded","_useMemo","useMemo","Array","isArray","_useMemo2","_slicedToArray","firstValue","secondValue","_useState","useState","_useState2","hoveredDay","setHoveredDay","_useState3","getDateFromValue","_useState4","date","setDate","_useState5","_useState6","prevValue","setPrevValue","_useState7","nextDate","_getNextDate","getNextDate","year","monthIndex","_getNextDate2","initialYear","initialMonth","_useState8","doubleDate","setMonths","handleMonth","useCallback","getDate","_getDate","_getDate2","newCurrentYear","newCurrentMonth","_getDate3","_getDate4","newNextYear","newNextMonth","handlePrev","getPrevDate","handleNext","_useKeyNavigation","useKeyNavigation","isDouble","size","onNext","onPrev","_useKeyNavigation2","selectIndexes","onKeyDown","onSelectIndexes","outerRefs","handleOnChangeDay","newDate","coord","newDay","Date","day","firstDate","secondDate","isValueUpdate","_doubleDate$monthInde","prevMonthIndex","_doubleDate$year","prevYear","_getNextDate3","_getNextDate4","nextYear","nextMonthIndex","React","createElement","_extends","ref","CalendarHeader","StyledWrapper","CalendarDays","onChangeDay","onHoverDay","onSetSelected","_StyledSeparator","StyledSeparator","isSecond","calendarDoubleConfig","name","tag","layout","base","StyledCalendar","variations","view","css","viewCSS","defaults"],"mappings":";;;;;;;;;;;;;AAaA;AACA;AACA;IACaA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBAC9FC,UAAU,CACN,UAAAC,IAAA,EAEIC,YAAY,EACX;AAAA,IAAA,IAFQC,aAAa,GAAAF,IAAA,CAApBG,KAAK;MAAiBC,GAAG,GAAAJ,IAAA,CAAHI,GAAG;MAAEC,GAAG,GAAAL,IAAA,CAAHK,GAAG;MAAEC,gBAAgB,GAAAN,IAAA,CAAhBM,gBAAgB;MAAEC,SAAS,GAAAP,IAAA,CAATO,SAAS;MAAEC,YAAY,GAAAR,IAAA,CAAZQ,YAAY;MAAEC,aAAa,GAAAT,IAAA,CAAbS,aAAa;AAAKC,MAAAA,IAAI,GAAAC,wBAAA,CAAAX,IAAA,EAAAY,SAAA,CAAA,CAAA;IAGnG,IAAAC,QAAA,GAAkCC,OAAO,CACrC,YAAA;QAAA,OAAOC,KAAK,CAACC,OAAO,CAACd,aAAa,CAAC,GAAGA,aAAa,GAAG,CAACA,aAAa,CAAC,CAAA;AAAA,OAAC,EACtE,CAACA,aAAa,CAClB,CAAC;MAAAe,SAAA,GAAAC,cAAA,CAAAL,QAAA,EAAA,CAAA,CAAA;AAHMM,MAAAA,UAAU,GAAAF,SAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,WAAW,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;AAI9B,IAAA,IAAMd,KAAK,GAAGiB,WAAW,IAAID,UAAU,CAAA;AACvC,IAAA,IAAAE,SAAA,GAAoCC,QAAQ,EAA0B;MAAAC,UAAA,GAAAL,cAAA,CAAAG,SAAA,E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,SAAAA;AAAU,KACxB,CAAC,EAAA4B,gBAAA,KAAAA,gBAAA,gBACFV,KAAA,CAAAC,aAAA,CAACU,eAAe,MAAE,CAAC,CAAA,eACnBX,KAAA,CAAAC,aAAA,CAACK,YAAY,EAAA;MACThC,QAAQ,EAAA,IAAA;MACRsC,QAAQ,EAAA,IAAA;AACR9F,MAAAA,SAAS,EAAEA,SAAU;AACrBC,MAAAA,YAAY,EAAEA,YAAa;AAC3BJ,MAAAA,GAAG,EAAEA,GAAI;AACTC,MAAAA,GAAG,EAAEA,GAAI;AACTC,MAAAA,gBAAgB,EAAEA,gBAAiB;AACnCH,MAAAA,KAAK,EAAED,aAAc;AACrB2B,MAAAA,IAAI,EAAEkD,UAAW;AACjBvD,MAAAA,UAAU,EAAEA,UAAW;AACvB4C,MAAAA,aAAa,EAAEA,aAAc;AAC7B4B,MAAAA,WAAW,EAAExB,iBAAkB;AAC/ByB,MAAAA,UAAU,EAAExE,aAAc;AAC1ByE,MAAAA,aAAa,EAAE5B,eAAgB;AAC/BD,MAAAA,SAAS,EAAEA,SAAU;AACrBE,MAAAA,SAAS,EAAEA,SAAAA;KACd,CACU,CACb,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAM+B,oBAAoB,GAAG;AAChCC,EAAAA,IAAI,EAAE,gBAAgB;AACtBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE5G,kBAAkB;AAC1B6G,EAAAA,IAAI,EAAEC,cAAc;AACpBC,EAAAA,UAAU,EAAE;AACRC,IAAAA,IAAI,EAAE;AACFC,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNH,IAAAA,IAAI,EAAE,SAAS;AACf7C,IAAAA,IAAI,EAAE,GAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -174,6 +174,7 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
174
174
|
var disabledList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
175
175
|
var min = arguments.length > 3 ? arguments[3] : undefined;
|
176
176
|
var max = arguments.length > 4 ? arguments[4] : undefined;
|
177
|
+
var includeEdgeDates = arguments.length > 5 ? arguments[5] : undefined;
|
177
178
|
var eventsMap = getPropsMap(eventList);
|
178
179
|
var disabledDaysMap = getPropsMap(disabledList);
|
179
180
|
var daysList = days.filter(function (_ref3) {
|
@@ -191,7 +192,9 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
191
192
|
day = date.day;
|
192
193
|
var keyDay = "".concat(year, "-").concat(monthIndex, "-").concat(day);
|
193
194
|
var currentDate = new Date(year, monthIndex, day);
|
194
|
-
var
|
195
|
+
var minValue = min && (includeEdgeDates ? min > currentDate : min >= currentDate);
|
196
|
+
var maxValue = max && (includeEdgeDates ? max < currentDate : max <= currentDate);
|
197
|
+
var isOutOfMinMaxRange = minValue || maxValue;
|
195
198
|
dayItem.events = eventsMap.get(keyDay);
|
196
199
|
dayItem.disabled = disabledDaysMap.has(keyDay) || isOutOfMinMaxRange;
|
197
200
|
dayItem.isOutOfMinMaxRange = isOutOfMinMaxRange;
|
@@ -204,7 +207,7 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
204
207
|
/**
|
205
208
|
* Хук для получения списка дней.
|
206
209
|
*/
|
207
|
-
var useDays = function useDays(date, value, eventList, disabledList, min, max) {
|
210
|
+
var useDays = function useDays(date, value, eventList, disabledList, min, max, includeEdgeDates) {
|
208
211
|
return useMemo(function () {
|
209
212
|
var monthIndex = date.monthIndex,
|
210
213
|
year = date.year;
|
@@ -212,7 +215,7 @@ var useDays = function useDays(date, value, eventList, disabledList, min, max) {
|
|
212
215
|
var offsetDayInWeek = getOffsetDayInWeek(monthIndex, year);
|
213
216
|
var days = [].concat(_toConsumableArray(getDaysInPrevMonth(date, offsetDayInWeek, value)), _toConsumableArray(getDaysInCurrentMonth(date, daysInMonth, value)), _toConsumableArray(getDaysInNextMonth(date, daysInMonth, offsetDayInWeek, value)));
|
214
217
|
if (eventList !== null && eventList !== void 0 && eventList.length || disabledList !== null && disabledList !== void 0 && disabledList.length || max || min) {
|
215
|
-
var modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max);
|
218
|
+
var modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max, includeEdgeDates);
|
216
219
|
return getMatrix(modifiedDays);
|
217
220
|
}
|
218
221
|
return getMatrix(days);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDays.js","sources":["../../../../src/components/Calendar/hooks/useDays.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport {\n getDateFromValue,\n getDaysInMonth,\n getMatrix,\n getNextDate,\n getOffsetDayInWeek,\n getPrevDate,\n IsCurrentDay,\n isDayInRange,\n isSelectedDay,\n} from '../utils';\nimport type { CalendarValueType, DateItem, DateObject, DisabledDay, EventDay } from '../Calendar.types';\n\n/**\n * Метод возвращающий массив дней в предыдущем месяце.\n */\nconst getDaysInPrevMonth = (date: DateObject, offsetDayInWeek: number, value: CalendarValueType) => {\n const [prevYear, prevMonth] = getPrevDate(date.year, date.monthIndex);\n const daysInPrevMonth = getDaysInMonth(prevMonth, prevYear);\n\n return Array.from(Array(offsetDayInWeek), (_, i) => ({\n isCurrent: false,\n isSelected: false,\n isDayInCurrentMonth: false,\n inRange: Array.isArray(value)\n ? isDayInRange(prevYear, prevMonth, daysInPrevMonth - (offsetDayInWeek - i) + 1, value)\n : false,\n date: {\n day: daysInPrevMonth - (offsetDayInWeek - i) + 1,\n monthIndex: prevMonth,\n year: prevYear,\n },\n }));\n};\n\n/**\n * Метод возвращающий массив дней в текущем месяце.\n */\nconst getDaysInCurrentMonth = (date: DateObject, daysInMonth: number, value: CalendarValueType) => {\n return Array.from(Array(daysInMonth), (_, i) => ({\n isCurrent: IsCurrentDay(date, i + 1),\n isSelected: Array.isArray(value)\n ? Boolean(value.find((v) => isSelectedDay(date, i + 1, v)))\n : isSelectedDay(date, i + 1, value),\n isDayInCurrentMonth: true,\n inRange: Array.isArray(value) ? isDayInRange(date.year, date.monthIndex, i + 1, value) : false,\n date: {\n day: i + 1,\n monthIndex: date.monthIndex,\n year: date.year,\n },\n }));\n};\n\n/**\n * Метод возвращающий массив дней в следующем месяце.\n */\nconst getDaysInNextMonth = (\n date: DateObject,\n daysInMonth: number,\n offsetDayInWeek: number,\n value: CalendarValueType,\n) => {\n const [nextYear, nextMonthIndex] = getNextDate(date.year, date.monthIndex);\n const visibleDayCount = 42;\n const restDaysInCalendar = visibleDayCount - (daysInMonth + offsetDayInWeek);\n\n return Array.from(Array(restDaysInCalendar), (_, i) => ({\n isCurrent: false,\n isSelected: false,\n isDayInCurrentMonth: false,\n inRange: Array.isArray(value) ? isDayInRange(nextYear, nextMonthIndex, i + 1, value) : false,\n date: {\n day: i + 1,\n monthIndex: nextMonthIndex,\n year: nextYear,\n },\n }));\n};\n\nconst isDisabledArrowLeft = (date: Date, min?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(currentDate.getDate() - 1);\n\n return (min && min >= currentDate) || (min && min >= date);\n};\n\nconst isDisabledArrowRight = (date: Date, max?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(currentDate.getDate() + 1);\n\n return (max && max <= currentDate) || (max && max <= date);\n};\n\nconst isDisabledArrowUp = (date: Date, min?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(date.getDate() - 7);\n\n return min && min >= currentDate;\n};\n\nconst isDisabledArrowDown = (date: Date, max?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(date.getDate() + 7);\n\n return max && max <= currentDate;\n};\n\nconst isDisabledNextMonth = ({ year, monthIndex, day }: DateObject, max?: Date) => {\n if (!max) {\n return false;\n }\n\n const currentDate = new Date(year, monthIndex, day);\n\n currentDate.setDate(currentDate.getDate() + 1);\n\n let isOut = true;\n\n while (isOut && currentDate <= max) {\n isOut = max <= currentDate;\n\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return isOut;\n};\n\nconst isDisabledPreviousMonth = ({ year, monthIndex, day }: DateObject, min?: Date) => {\n if (!min) {\n return false;\n }\n\n const currentDate = new Date(year, monthIndex, day);\n\n currentDate.setDate(currentDate.getDate() - 1);\n\n let isOut = true;\n\n while (isOut && currentDate >= min) {\n isOut = min >= currentDate;\n\n currentDate.setDate(currentDate.getDate() - 1);\n }\n\n return isOut;\n};\n\nconst getDisabledArrowKey = (currentDate: Date, min?: Date, max?: Date) => {\n const disabledArrowKey = [];\n\n if (isDisabledArrowLeft(currentDate, min)) {\n disabledArrowKey.push('left');\n }\n\n if (isDisabledArrowRight(currentDate, max)) {\n disabledArrowKey.push('right');\n }\n\n if (isDisabledArrowDown(currentDate, max)) {\n disabledArrowKey.push('down');\n }\n\n if (isDisabledArrowUp(currentDate, min)) {\n disabledArrowKey.push('up');\n }\n\n return disabledArrowKey.join(',');\n};\n\nconst getDisabledMonths = (list: DateObject[], min?: Date, max?: Date) => {\n const disabledMonth = [];\n\n if (isDisabledPreviousMonth(list[0], min)) {\n disabledMonth.push('previous');\n }\n\n if (isDisabledNextMonth(list[list.length - 1], max)) {\n disabledMonth.push('next');\n }\n\n return disabledMonth.join(',');\n};\n\n/**\n * Метод для получения набора неповторяющихся дат.\n */\nconst getPropsMap = <T extends EventDay | DisabledDay>(props: T[]) =>\n props.reduce((acc, prop) => {\n const { year, monthIndex, day } = getDateFromValue(prop.date);\n\n const key = `${year}-${monthIndex}-${day}`;\n\n const propList = acc.get(key) || [];\n propList.push(prop);\n\n return acc.set(key, propList);\n }, new Map<string, T[]>());\n\n/**\n * Метод модифицирующий дни (добавляющий свойства events и disabled).\n */\nconst getDaysWithModifications = (\n days: DateItem[],\n eventList: EventDay[] = [],\n disabledList: DisabledDay[] = [],\n min?: Date,\n max?: Date,\n) => {\n const eventsMap = getPropsMap(eventList);\n const disabledDaysMap = getPropsMap(disabledList);\n\n const daysList = days.filter(({ isDayInCurrentMonth }) => isDayInCurrentMonth).map(({ date }) => date);\n\n const disabledMonths = getDisabledMonths(daysList, min, max);\n\n return days.map((dayItem) => {\n const { date } = dayItem;\n const { year, monthIndex, day } = date;\n\n const keyDay = `${year}-${monthIndex}-${day}`;\n const currentDate = new Date(year, monthIndex, day);\n\n const isOutOfMinMaxRange = (min && min >= currentDate) || (max && max <= currentDate);\n\n dayItem.events = eventsMap.get(keyDay);\n dayItem.disabled = disabledDaysMap.has(keyDay) || isOutOfMinMaxRange;\n\n dayItem.isOutOfMinMaxRange = isOutOfMinMaxRange;\n dayItem.disabledArrowKey = getDisabledArrowKey(currentDate, min, max);\n dayItem.disabledMonths = disabledMonths;\n\n return dayItem;\n });\n};\n\n/**\n * Хук для получения списка дней.\n */\nexport const useDays = (\n date: DateObject,\n value: CalendarValueType,\n eventList?: EventDay[],\n disabledList?: DisabledDay[],\n min?: Date,\n max?: Date,\n) =>\n useMemo(() => {\n const { monthIndex, year } = date;\n const daysInMonth = getDaysInMonth(monthIndex, year);\n const offsetDayInWeek = getOffsetDayInWeek(monthIndex, year);\n\n const days = [\n ...getDaysInPrevMonth(date, offsetDayInWeek, value),\n ...getDaysInCurrentMonth(date, daysInMonth, value),\n ...getDaysInNextMonth(date, daysInMonth, offsetDayInWeek, value),\n ];\n\n if (eventList?.length || disabledList?.length || max || min) {\n const modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max);\n return getMatrix<DateItem>(modifiedDays);\n }\n\n return getMatrix<DateItem>(days);\n }, [date, value, eventList, disabledList, max, min]);\n"],"names":["getDaysInPrevMonth","date","offsetDayInWeek","value","_getPrevDate","getPrevDate","year","monthIndex","_getPrevDate2","_slicedToArray","prevYear","prevMonth","daysInPrevMonth","getDaysInMonth","Array","from","_","i","isCurrent","isSelected","isDayInCurrentMonth","inRange","isArray","isDayInRange","day","getDaysInCurrentMonth","daysInMonth","IsCurrentDay","Boolean","find","v","isSelectedDay","getDaysInNextMonth","_getNextDate","getNextDate","_getNextDate2","nextYear","nextMonthIndex","visibleDayCount","restDaysInCalendar","isDisabledArrowLeft","min","currentDate","Date","setDate","getDate","isDisabledArrowRight","max","isDisabledArrowUp","isDisabledArrowDown","isDisabledNextMonth","_ref","isOut","isDisabledPreviousMonth","_ref2","getDisabledArrowKey","disabledArrowKey","push","join","getDisabledMonths","list","disabledMonth","length","getPropsMap","props","reduce","acc","prop","_getDateFromValue","getDateFromValue","key","concat","propList","get","set","Map","getDaysWithModifications","days","eventList","arguments","undefined","disabledList","eventsMap","disabledDaysMap","daysList","filter","_ref3","map","_ref4","disabledMonths","dayItem","keyDay","isOutOfMinMaxRange","events","disabled","has","useDays","useMemo","getOffsetDayInWeek","_toConsumableArray","modifiedDays","getMatrix"],"mappings":";;;;AAeA;AACA;AACA;AACA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,IAAgB,EAAEC,eAAuB,EAAEC,KAAwB,EAAK;EAChG,IAAAC,YAAA,GAA8BC,WAAW,CAACJ,IAAI,CAACK,IAAI,EAAEL,IAAI,CAACM,UAAU,CAAC;IAAAC,aAAA,GAAAC,cAAA,CAAAL,YAAA,EAAA,CAAA,CAAA;AAA9DM,IAAAA,QAAQ,GAAAF,aAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,SAAS,GAAAH,aAAA,CAAA,CAAA,CAAA,CAAA;AAC1B,EAAA,IAAMI,eAAe,GAAGC,cAAc,CAACF,SAAS,EAAED,QAAQ,CAAC,CAAA;AAE3D,EAAA,OAAOI,KAAK,CAACC,IAAI,CAACD,KAAK,CAACZ,eAAe,CAAC,EAAE,UAACc,CAAC,EAAEC,CAAC,EAAA;IAAA,OAAM;AACjDC,MAAAA,SAAS,EAAE,KAAK;AAChBC,MAAAA,UAAU,EAAE,KAAK;AACjBC,MAAAA,mBAAmB,EAAE,KAAK;MAC1BC,OAAO,EAAEP,KAAK,CAACQ,OAAO,CAACnB,KAAK,CAAC,GACvBoB,YAAY,CAACb,QAAQ,EAAEC,SAAS,EAAEC,eAAe,IAAIV,eAAe,GAAGe,CAAC,CAAC,GAAG,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,IAAI,CAAA;AACxB,IAAA,IAAMoB,WAAW,GAAGb,cAAc,CAACN,UAAU,EAAED,IAAI,CAAC,CAAA;AACpD,IAAA,IAAMJ,eAAe,GAAGgG,kBAAkB,CAAC3F,UAAU,EAAED,IAAI,CAAC,CAAA;AAE5D,IAAA,IAAMuE,IAAI,GAAAN,EAAAA,CAAAA,MAAA,CAAA4B,kBAAA,CACHnG,kBAAkB,CAACC,IAAI,EAAEC,eAAe,EAAEC,KAAK,CAAC,CAAAgG,EAAAA,kBAAA,CAChD1E,qBAAqB,CAACxB,IAAI,EAAEyB,WAAW,EAAEvB,KAAK,CAAC,CAAA,EAAAgG,kBAAA,CAC/CnE,kBAAkB,CAAC/B,IAAI,EAAEyB,WAAW,EAAExB,eAAe,EAAEC,KAAK,CAAC,CACnE,CAAA,CAAA;AAED,IAAA,IAAI2E,SAAS,KAATA,IAAAA,IAAAA,SAAS,eAATA,SAAS,CAAEhB,MAAM,IAAImB,YAAY,aAAZA,YAAY,KAAA,KAAA,CAAA,IAAZA,YAAY,CAAEnB,MAAM,IAAIf,GAAG,IAAIN,GAAG,EAAE;AACzD,MAAA,IAAM2D,YAAY,GAAGxB,wBAAwB,CAACC,IAAI,EAAEC,SAAS,EAAEG,YAAY,EAAExC,GAAG,EAAEM,GAAG,CAAC,CAAA;MACtF,OAAOsD,SAAS,CAAWD,YAAY,CAAC,CAAA;AAC5C,KAAA;IAEA,OAAOC,SAAS,CAAWxB,IAAI,CAAC,CAAA;AACpC,GAAC,EAAE,CAAC5E,IAAI,EAAEE,KAAK,EAAE2E,SAAS,EAAEG,YAAY,EAAElC,GAAG,EAAEN,GAAG,CAAC,CAAC,CAAA;AAAA;;;;"}
|
1
|
+
{"version":3,"file":"useDays.js","sources":["../../../../src/components/Calendar/hooks/useDays.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport {\n getDateFromValue,\n getDaysInMonth,\n getMatrix,\n getNextDate,\n getOffsetDayInWeek,\n getPrevDate,\n IsCurrentDay,\n isDayInRange,\n isSelectedDay,\n} from '../utils';\nimport type { CalendarValueType, DateItem, DateObject, DisabledDay, EventDay } from '../Calendar.types';\n\n/**\n * Метод возвращающий массив дней в предыдущем месяце.\n */\nconst getDaysInPrevMonth = (date: DateObject, offsetDayInWeek: number, value: CalendarValueType) => {\n const [prevYear, prevMonth] = getPrevDate(date.year, date.monthIndex);\n const daysInPrevMonth = getDaysInMonth(prevMonth, prevYear);\n\n return Array.from(Array(offsetDayInWeek), (_, i) => ({\n isCurrent: false,\n isSelected: false,\n isDayInCurrentMonth: false,\n inRange: Array.isArray(value)\n ? isDayInRange(prevYear, prevMonth, daysInPrevMonth - (offsetDayInWeek - i) + 1, value)\n : false,\n date: {\n day: daysInPrevMonth - (offsetDayInWeek - i) + 1,\n monthIndex: prevMonth,\n year: prevYear,\n },\n }));\n};\n\n/**\n * Метод возвращающий массив дней в текущем месяце.\n */\nconst getDaysInCurrentMonth = (date: DateObject, daysInMonth: number, value: CalendarValueType) => {\n return Array.from(Array(daysInMonth), (_, i) => ({\n isCurrent: IsCurrentDay(date, i + 1),\n isSelected: Array.isArray(value)\n ? Boolean(value.find((v) => isSelectedDay(date, i + 1, v)))\n : isSelectedDay(date, i + 1, value),\n isDayInCurrentMonth: true,\n inRange: Array.isArray(value) ? isDayInRange(date.year, date.monthIndex, i + 1, value) : false,\n date: {\n day: i + 1,\n monthIndex: date.monthIndex,\n year: date.year,\n },\n }));\n};\n\n/**\n * Метод возвращающий массив дней в следующем месяце.\n */\nconst getDaysInNextMonth = (\n date: DateObject,\n daysInMonth: number,\n offsetDayInWeek: number,\n value: CalendarValueType,\n) => {\n const [nextYear, nextMonthIndex] = getNextDate(date.year, date.monthIndex);\n const visibleDayCount = 42;\n const restDaysInCalendar = visibleDayCount - (daysInMonth + offsetDayInWeek);\n\n return Array.from(Array(restDaysInCalendar), (_, i) => ({\n isCurrent: false,\n isSelected: false,\n isDayInCurrentMonth: false,\n inRange: Array.isArray(value) ? isDayInRange(nextYear, nextMonthIndex, i + 1, value) : false,\n date: {\n day: i + 1,\n monthIndex: nextMonthIndex,\n year: nextYear,\n },\n }));\n};\n\nconst isDisabledArrowLeft = (date: Date, min?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(currentDate.getDate() - 1);\n\n return (min && min >= currentDate) || (min && min >= date);\n};\n\nconst isDisabledArrowRight = (date: Date, max?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(currentDate.getDate() + 1);\n\n return (max && max <= currentDate) || (max && max <= date);\n};\n\nconst isDisabledArrowUp = (date: Date, min?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(date.getDate() - 7);\n\n return min && min >= currentDate;\n};\n\nconst isDisabledArrowDown = (date: Date, max?: Date) => {\n const currentDate = new Date(date);\n\n currentDate.setDate(date.getDate() + 7);\n\n return max && max <= currentDate;\n};\n\nconst isDisabledNextMonth = ({ year, monthIndex, day }: DateObject, max?: Date) => {\n if (!max) {\n return false;\n }\n\n const currentDate = new Date(year, monthIndex, day);\n\n currentDate.setDate(currentDate.getDate() + 1);\n\n let isOut = true;\n\n while (isOut && currentDate <= max) {\n isOut = max <= currentDate;\n\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return isOut;\n};\n\nconst isDisabledPreviousMonth = ({ year, monthIndex, day }: DateObject, min?: Date) => {\n if (!min) {\n return false;\n }\n\n const currentDate = new Date(year, monthIndex, day);\n\n currentDate.setDate(currentDate.getDate() - 1);\n\n let isOut = true;\n\n while (isOut && currentDate >= min) {\n isOut = min >= currentDate;\n\n currentDate.setDate(currentDate.getDate() - 1);\n }\n\n return isOut;\n};\n\nconst getDisabledArrowKey = (currentDate: Date, min?: Date, max?: Date) => {\n const disabledArrowKey = [];\n\n if (isDisabledArrowLeft(currentDate, min)) {\n disabledArrowKey.push('left');\n }\n\n if (isDisabledArrowRight(currentDate, max)) {\n disabledArrowKey.push('right');\n }\n\n if (isDisabledArrowDown(currentDate, max)) {\n disabledArrowKey.push('down');\n }\n\n if (isDisabledArrowUp(currentDate, min)) {\n disabledArrowKey.push('up');\n }\n\n return disabledArrowKey.join(',');\n};\n\nconst getDisabledMonths = (list: DateObject[], min?: Date, max?: Date) => {\n const disabledMonth = [];\n\n if (isDisabledPreviousMonth(list[0], min)) {\n disabledMonth.push('previous');\n }\n\n if (isDisabledNextMonth(list[list.length - 1], max)) {\n disabledMonth.push('next');\n }\n\n return disabledMonth.join(',');\n};\n\n/**\n * Метод для получения набора неповторяющихся дат.\n */\nconst getPropsMap = <T extends EventDay | DisabledDay>(props: T[]) =>\n props.reduce((acc, prop) => {\n const { year, monthIndex, day } = getDateFromValue(prop.date);\n\n const key = `${year}-${monthIndex}-${day}`;\n\n const propList = acc.get(key) || [];\n propList.push(prop);\n\n return acc.set(key, propList);\n }, new Map<string, T[]>());\n\n/**\n * Метод модифицирующий дни (добавляющий свойства events и disabled).\n */\nconst getDaysWithModifications = (\n days: DateItem[],\n eventList: EventDay[] = [],\n disabledList: DisabledDay[] = [],\n min?: Date,\n max?: Date,\n includeEdgeDates?: boolean,\n) => {\n const eventsMap = getPropsMap(eventList);\n const disabledDaysMap = getPropsMap(disabledList);\n\n const daysList = days.filter(({ isDayInCurrentMonth }) => isDayInCurrentMonth).map(({ date }) => date);\n\n const disabledMonths = getDisabledMonths(daysList, min, max);\n\n return days.map((dayItem) => {\n const { date } = dayItem;\n const { year, monthIndex, day } = date;\n\n const keyDay = `${year}-${monthIndex}-${day}`;\n const currentDate = new Date(year, monthIndex, day);\n\n const minValue = min && (includeEdgeDates ? min > currentDate : min >= currentDate);\n const maxValue = max && (includeEdgeDates ? max < currentDate : max <= currentDate);\n const isOutOfMinMaxRange = minValue || maxValue;\n\n dayItem.events = eventsMap.get(keyDay);\n dayItem.disabled = disabledDaysMap.has(keyDay) || isOutOfMinMaxRange;\n\n dayItem.isOutOfMinMaxRange = isOutOfMinMaxRange;\n dayItem.disabledArrowKey = getDisabledArrowKey(currentDate, min, max);\n dayItem.disabledMonths = disabledMonths;\n\n return dayItem;\n });\n};\n\n/**\n * Хук для получения списка дней.\n */\nexport const useDays = (\n date: DateObject,\n value: CalendarValueType,\n eventList?: EventDay[],\n disabledList?: DisabledDay[],\n min?: Date,\n max?: Date,\n includeEdgeDates?: boolean,\n) =>\n useMemo(() => {\n const { monthIndex, year } = date;\n const daysInMonth = getDaysInMonth(monthIndex, year);\n const offsetDayInWeek = getOffsetDayInWeek(monthIndex, year);\n\n const days = [\n ...getDaysInPrevMonth(date, offsetDayInWeek, value),\n ...getDaysInCurrentMonth(date, daysInMonth, value),\n ...getDaysInNextMonth(date, daysInMonth, offsetDayInWeek, value),\n ];\n\n if (eventList?.length || disabledList?.length || max || min) {\n const modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max, includeEdgeDates);\n return getMatrix<DateItem>(modifiedDays);\n }\n\n return getMatrix<DateItem>(days);\n }, [date, value, eventList, disabledList, max, min]);\n"],"names":["getDaysInPrevMonth","date","offsetDayInWeek","value","_getPrevDate","getPrevDate","year","monthIndex","_getPrevDate2","_slicedToArray","prevYear","prevMonth","daysInPrevMonth","getDaysInMonth","Array","from","_","i","isCurrent","isSelected","isDayInCurrentMonth","inRange","isArray","isDayInRange","day","getDaysInCurrentMonth","daysInMonth","IsCurrentDay","Boolean","find","v","isSelectedDay","getDaysInNextMonth","_getNextDate","getNextDate","_getNextDate2","nextYear","nextMonthIndex","visibleDayCount","restDaysInCalendar","isDisabledArrowLeft","min","currentDate","Date","setDate","getDate","isDisabledArrowRight","max","isDisabledArrowUp","isDisabledArrowDown","isDisabledNextMonth","_ref","isOut","isDisabledPreviousMonth","_ref2","getDisabledArrowKey","disabledArrowKey","push","join","getDisabledMonths","list","disabledMonth","length","getPropsMap","props","reduce","acc","prop","_getDateFromValue","getDateFromValue","key","concat","propList","get","set","Map","getDaysWithModifications","days","eventList","arguments","undefined","disabledList","includeEdgeDates","eventsMap","disabledDaysMap","daysList","filter","_ref3","map","_ref4","disabledMonths","dayItem","keyDay","minValue","maxValue","isOutOfMinMa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IAAA,IAAMoB,WAAW,GAAGb,cAAc,CAACN,UAAU,EAAED,IAAI,CAAC,CAAA;AACpD,IAAA,IAAMJ,eAAe,GAAGmG,kBAAkB,CAAC9F,UAAU,EAAED,IAAI,CAAC,CAAA;AAE5D,IAAA,IAAMuE,IAAI,GAAAN,EAAAA,CAAAA,MAAA,CAAA+B,kBAAA,CACHtG,kBAAkB,CAACC,IAAI,EAAEC,eAAe,EAAEC,KAAK,CAAC,CAAAmG,EAAAA,kBAAA,CAChD7E,qBAAqB,CAACxB,IAAI,EAAEyB,WAAW,EAAEvB,KAAK,CAAC,CAAA,EAAAmG,kBAAA,CAC/CtE,kBAAkB,CAAC/B,IAAI,EAAEyB,WAAW,EAAExB,eAAe,EAAEC,KAAK,CAAC,CACnE,CAAA,CAAA;AAED,IAAA,IAAI2E,SAAS,KAATA,IAAAA,IAAAA,SAAS,eAATA,SAAS,CAAEhB,MAAM,IAAImB,YAAY,aAAZA,YAAY,KAAA,KAAA,CAAA,IAAZA,YAAY,CAAEnB,MAAM,IAAIf,GAAG,IAAIN,GAAG,EAAE;AACzD,MAAA,IAAM8D,YAAY,GAAG3B,wBAAwB,CAACC,IAAI,EAAEC,SAAS,EAAEG,YAAY,EAAExC,GAAG,EAAEM,GAAG,EAAEmC,gBAAgB,CAAC,CAAA;MACxG,OAAOsB,SAAS,CAAWD,YAAY,CAAC,CAAA;AAC5C,KAAA;IAEA,OAAOC,SAAS,CAAW3B,IAAI,CAAC,CAAA;AACpC,GAAC,EAAE,CAAC5E,IAAI,EAAEE,KAAK,EAAE2E,SAAS,EAAEG,YAAY,EAAElC,GAAG,EAAEN,GAAG,CAAC,CAAC,CAAA;AAAA;;;;"}
|
@@ -16,6 +16,7 @@ var CalendarDays = function CalendarDays(_ref) {
|
|
16
16
|
disabledList = _ref.disabledList,
|
17
17
|
min = _ref.min,
|
18
18
|
max = _ref.max,
|
19
|
+
includeEdgeDates = _ref.includeEdgeDates,
|
19
20
|
hoveredDay = _ref.hoveredDay,
|
20
21
|
selectIndexes = _ref.selectIndexes,
|
21
22
|
isDouble = _ref.isDouble,
|
@@ -25,7 +26,7 @@ var CalendarDays = function CalendarDays(_ref) {
|
|
25
26
|
onHoverDay = _ref.onHoverDay,
|
26
27
|
onSetSelected = _ref.onSetSelected,
|
27
28
|
onKeyDown = _ref.onKeyDown;
|
28
|
-
var _useDays = useDays(currentDate, value, eventList, disabledList, min, max),
|
29
|
+
var _useDays = useDays(currentDate, value, eventList, disabledList, min, max, includeEdgeDates),
|
29
30
|
_useDays2 = _slicedToArray(_useDays, 2),
|
30
31
|
days = _useDays2[0],
|
31
32
|
selected = _useDays2[1];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CalendarDays.js","sources":["../../../../../src/components/Calendar/ui/CalendarDays/CalendarDays.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from 'react';\n\nimport { useDays } from '../../hooks';\nimport {\n canSelectDate,\n FULL_DAY_NAMES,\n getInRange,\n getSideInRange,\n isSameDay,\n isSelectProcess,\n ROW_STEP,\n SHORT_DAY_NAMES,\n} from '../../utils';\nimport { CalendarDayItem } from '../CalendarDayItem/CalendarDayItem';\nimport { DateItem } from '../../Calendar.types';\n\nimport { StyledCalendarDays, StyledCalendarDaysHint, StyledFlex } from './CalendarDays.styles';\nimport type { CalendarDaysProps } from './CalendarDays.types';\n\n/**\n * Компонент дней в календаре.\n */\nexport const CalendarDays: React.FC<CalendarDaysProps> = ({\n date: currentDate,\n value,\n eventList,\n disabledList,\n min,\n max,\n hoveredDay,\n selectIndexes,\n isDouble,\n isSecond,\n outerRefs,\n onChangeDay,\n onHoverDay,\n onSetSelected,\n onKeyDown,\n}) => {\n const [days, selected] = useDays(currentDate, value, eventList, disabledList, min, max);\n const selectedRef = useRef(selected);\n const onSetSelectedRef = useRef(onSetSelected);\n\n const offset = isSecond ? ROW_STEP : 0;\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 handleOnChangeDay = useCallback(\n (i: number, j: number) => (event: React.MouseEvent<HTMLDivElement>) => {\n const selectedDate = getSelectedDate(event);\n\n if (!selectedDate) {\n return;\n }\n\n onChangeDay(selectedDate, [i + offset, j]);\n\n if (isSelectProcess(value)) {\n onHoverDay?.(undefined);\n }\n },\n [getSelectedDate, onChangeDay, offset, value, onHoverDay],\n );\n\n const handleOnHoverDay = 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 onHoverDay?.(selectedDate);\n },\n [getSelectedDate, onHoverDay, value],\n );\n\n const handleOnFocusDay = useCallback(() => {\n // заглушка будет убрана при реализации доступности\n }, []);\n\n const getRefs = useCallback(\n (element: HTMLDivElement, isDayInCurrentMonth: boolean, i: number, j: number) => {\n if (isDayInCurrentMonth) {\n outerRefs.current[i + offset][j] = element;\n }\n },\n [offset, outerRefs],\n );\n\n useEffect(() => {\n if (selectedRef.current) {\n onSetSelectedRef.current?.(selectedRef.current);\n }\n }, []);\n\n return (\n <StyledCalendarDays role=\"grid\" aria-labelledby=\"id-grid-label\" onKeyDown={onKeyDown}>\n <StyledCalendarDaysHint id=\"withShift\">\n Для навигации только по доступным датам удерживайте клавишу Shift.\n </StyledCalendarDaysHint>\n <StyledFlex role=\"row\">\n {SHORT_DAY_NAMES.map((name) => (\n <CalendarDayItem\n role=\"columnheader\"\n aria-label={FULL_DAY_NAMES[name]}\n key={name}\n dayOfWeek\n day={name}\n />\n ))}\n </StyledFlex>\n {days.map((day: DateItem[], i) => (\n <StyledFlex role=\"row\" key={i}>\n {day.map(\n (\n {\n date,\n events,\n disabled,\n isSelected,\n isCurrent,\n isDayInCurrentMonth,\n inRange,\n isOutOfMinMaxRange = false,\n disabledArrowKey,\n disabledMonths,\n },\n j,\n ) => (\n <CalendarDayItem\n ref={(element: HTMLDivElement) => getRefs(element, isDayInCurrentMonth, i, j)}\n eventList={events}\n disabled={disabled}\n day={date.day}\n year={date.year}\n monthIndex={date.monthIndex}\n isFocused={\n i + offset === selectIndexes?.[0] && j === selectIndexes?.[1] && !isOutOfMinMaxRange\n }\n isSelected={isSelected}\n isCurrent={isCurrent}\n isDayInCurrentMonth={isDayInCurrentMonth}\n isDouble={isDouble}\n isHovered={isSameDay(date, hoveredDay)}\n inRange={getInRange(value, date, hoveredDay, inRange)}\n sideInRange={getSideInRange(value, date, hoveredDay, isSelected)}\n onClick={disabled ? undefined : handleOnChangeDay(i, j)}\n onMouseOver={disabled ? undefined : handleOnHoverDay}\n onFocus={handleOnFocusDay}\n key={`StyledDay-${j}`}\n role=\"gridcell\"\n disabledArrowKey={disabledArrowKey}\n disabledMonths={disabledMonths}\n />\n ),\n )}\n </StyledFlex>\n ))}\n </StyledCalendarDays>\n );\n};\n"],"names":["CalendarDays","_ref","currentDate","date","value","eventList","disabledList","min","max","hoveredDay","selectIndexes","isDouble","isSecond","outerRefs","onChangeDay","onHoverDay","onSetSelected","onKeyDown","_useDays","useDays","_useDays2","_slicedToArray","days","selected","selectedRef","useRef","onSetSelectedRef","offset","ROW_STEP","getSelectedDate","useCallback","event","_event$currentTarget$","currentTarget","dataset","day","monthIndex","year","selectedDate","Number","canSelectDate","handleOnChangeDay","i","j","isSelectProcess","undefined","handleOnHoverDay","isSelectedDone","Array","isArray","handleOnFocusDay","getRefs","element","isDayInCurrentMonth","current","useEffect","_onSetSelectedRef$cur","call","React","createElement","StyledCalendarDays","role","_StyledCalendarDaysHi","StyledCalendarDaysHint","id","StyledFlex","SHORT_DAY_NAMES","map","name","CalendarDayItem","FULL_DAY_NAMES","key","dayOfWeek","_ref2","events","disabled","isSelected","isCurrent","inRange","_ref2$isOutOfMinMaxRa","isOutOfMinMaxRange","disabledArrowKey","disabledMonths","ref","isFocused","isHovered","isSameDay","getInRange","sideInRange","getSideInRange","onClick","onMouseOver","onFocus","concat"],"mappings":";;;;;;;;AAmBA;AACA;AACA;IACaA,YAAyC,GAAG,SAA5CA,YAAyCA,CAAAC,IAAA,EAgBhD;AAAA,EAAA,IAfIC,WAAW,GAAAD,IAAA,CAAjBE,IAAI;IACJC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IACZC,GAAG,GAAAN,IAAA,CAAHM,GAAG;IACHC,GAAG,GAAAP,IAAA,CAAHO,GAAG;IACHC,UAAU,GAAAR,IAAA,CAAVQ,UAAU;IACVC,aAAa,GAAAT,IAAA,CAAbS,aAAa;IACbC,QAAQ,GAAAV,IAAA,CAARU,QAAQ;IACRC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,SAAS,GAAAZ,IAAA,CAATY,SAAS;IACTC,WAAW,GAAAb,IAAA,CAAXa,WAAW;IACXC,UAAU,GAAAd,IAAA,CAAVc,UAAU;IACVC,aAAa,GAAAf,IAAA,CAAbe,aAAa;IACbC,SAAS,GAAAhB,IAAA,CAATgB,SAAS,CAAA;AAET,EAAA,IAAAC,QAAA,GAAyBC,OAAO,CAACjB,WAAW,EAAEE,KAAK,EAAEC,SAAS,EAAEC,YAAY,EAAEC,GAAG,EAAEC,GAAG,CAAC;IAAAY,SAAA,GAAAC,cAAA,CAAAH,QAAA,EAAA,CAAA,CAAA;AAAhFI,IAAAA,IAAI,GAAAF,SAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,QAAQ,GAAAH,SAAA,CAAA,CAAA,CAAA,CAAA;AACrB,EAAA,IAAMI,WAAW,GAAGC,MAAM,CAACF,QAAQ,CAAC,CAAA;AACpC,EAAA,IAAMG,gBAAgB,GAAGD,MAAM,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AmB,EAAEA,mBAAoB;AACzC1C,QAAAA,QAAQ,EAAEA,QAAS;AACnB0E,QAAAA,SAAS,EAAEC,SAAS,CAACnF,IAAI,EAAEM,UAAU,CAAE;QACvCqE,OAAO,EAAES,UAAU,CAACnF,KAAK,EAAED,IAAI,EAAEM,UAAU,EAAEqE,OAAO,CAAE;QACtDU,WAAW,EAAEC,cAAc,CAACrF,KAAK,EAAED,IAAI,EAAEM,UAAU,EAAEmE,UAAU,CAAE;QACjEc,OAAO,EAAEf,QAAQ,GAAG9B,SAAS,GAAGJ,iBAAiB,CAACC,CAAC,EAAEC,CAAC,CAAE;AACxDgD,QAAAA,WAAW,EAAEhB,QAAQ,GAAG9B,SAAS,GAAGC,gBAAiB;AACrD8C,QAAAA,OAAO,EAAE1C,gBAAiB;AAC1BqB,QAAAA,GAAG,EAAAsB,YAAAA,CAAAA,MAAA,CAAelD,CAAC,CAAG;AACtBkB,QAAAA,IAAI,EAAC,UAAU;AACfoB,QAAAA,gBAAgB,EAAEA,gBAAiB;AACnCC,QAAAA,cAAc,EAAEA,cAAAA;AAAe,OAClC,CAAC,CAAA;AAAA,KAEV,CACQ,CAAC,CAAA;AAAA,GAChB,CACe,CAAC,CAAA;AAE7B;;;;"}
|
1
|
+
{"version":3,"file":"CalendarDays.js","sources":["../../../../../src/components/Calendar/ui/CalendarDays/CalendarDays.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from 'react';\n\nimport { useDays } from '../../hooks';\nimport {\n canSelectDate,\n FULL_DAY_NAMES,\n getInRange,\n getSideInRange,\n isSameDay,\n isSelectProcess,\n ROW_STEP,\n SHORT_DAY_NAMES,\n} from '../../utils';\nimport { CalendarDayItem } from '../CalendarDayItem/CalendarDayItem';\nimport { DateItem } from '../../Calendar.types';\n\nimport { StyledCalendarDays, StyledCalendarDaysHint, StyledFlex } from './CalendarDays.styles';\nimport type { CalendarDaysProps } from './CalendarDays.types';\n\n/**\n * Компонент дней в календаре.\n */\nexport const CalendarDays: React.FC<CalendarDaysProps> = ({\n date: currentDate,\n value,\n eventList,\n disabledList,\n min,\n max,\n includeEdgeDates,\n hoveredDay,\n selectIndexes,\n isDouble,\n isSecond,\n outerRefs,\n onChangeDay,\n onHoverDay,\n onSetSelected,\n onKeyDown,\n}) => {\n const [days, selected] = useDays(currentDate, value, eventList, disabledList, min, max, includeEdgeDates);\n const selectedRef = useRef(selected);\n const onSetSelectedRef = useRef(onSetSelected);\n\n const offset = isSecond ? ROW_STEP : 0;\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 handleOnChangeDay = useCallback(\n (i: number, j: number) => (event: React.MouseEvent<HTMLDivElement>) => {\n const selectedDate = getSelectedDate(event);\n\n if (!selectedDate) {\n return;\n }\n\n onChangeDay(selectedDate, [i + offset, j]);\n\n if (isSelectProcess(value)) {\n onHoverDay?.(undefined);\n }\n },\n [getSelectedDate, onChangeDay, offset, value, onHoverDay],\n );\n\n const handleOnHoverDay = 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 onHoverDay?.(selectedDate);\n },\n [getSelectedDate, onHoverDay, value],\n );\n\n const handleOnFocusDay = useCallback(() => {\n // заглушка будет убрана при реализации доступности\n }, []);\n\n const getRefs = useCallback(\n (element: HTMLDivElement, isDayInCurrentMonth: boolean, i: number, j: number) => {\n if (isDayInCurrentMonth) {\n outerRefs.current[i + offset][j] = element;\n }\n },\n [offset, outerRefs],\n );\n\n useEffect(() => {\n if (selectedRef.current) {\n onSetSelectedRef.current?.(selectedRef.current);\n }\n }, []);\n\n return (\n <StyledCalendarDays role=\"grid\" aria-labelledby=\"id-grid-label\" onKeyDown={onKeyDown}>\n <StyledCalendarDaysHint id=\"withShift\">\n Для навигации только по доступным датам удерживайте клавишу Shift.\n </StyledCalendarDaysHint>\n <StyledFlex role=\"row\">\n {SHORT_DAY_NAMES.map((name) => (\n <CalendarDayItem\n role=\"columnheader\"\n aria-label={FULL_DAY_NAMES[name]}\n key={name}\n dayOfWeek\n day={name}\n />\n ))}\n </StyledFlex>\n {days.map((day: DateItem[], i) => (\n <StyledFlex role=\"row\" key={i}>\n {day.map(\n (\n {\n date,\n events,\n disabled,\n isSelected,\n isCurrent,\n isDayInCurrentMonth,\n inRange,\n isOutOfMinMaxRange = false,\n disabledArrowKey,\n disabledMonths,\n },\n j,\n ) => (\n <CalendarDayItem\n ref={(element: HTMLDivElement) => getRefs(element, isDayInCurrentMonth, i, j)}\n eventList={events}\n disabled={disabled}\n day={date.day}\n year={date.year}\n monthIndex={date.monthIndex}\n isFocused={\n i + offset === selectIndexes?.[0] && j === selectIndexes?.[1] && !isOutOfMinMaxRange\n }\n isSelected={isSelected}\n isCurrent={isCurrent}\n isDayInCurrentMonth={isDayInCurrentMonth}\n isDouble={isDouble}\n isHovered={isSameDay(date, hoveredDay)}\n inRange={getInRange(value, date, hoveredDay, inRange)}\n sideInRange={getSideInRange(value, date, hoveredDay, isSelected)}\n onClick={disabled ? undefined : handleOnChangeDay(i, j)}\n onMouseOver={disabled ? undefined : handleOnHoverDay}\n onFocus={handleOnFocusDay}\n key={`StyledDay-${j}`}\n role=\"gridcell\"\n disabledArrowKey={disabledArrowKey}\n disabledMonths={disabledMonths}\n />\n ),\n )}\n </StyledFlex>\n ))}\n </StyledCalendarDays>\n );\n};\n"],"names":["CalendarDays","_ref","currentDate","date","value","eventList","disabledList","min","max","includeEdgeDates","hoveredDay","selectIndexes","isDouble","isSecond","outerRefs","onChangeDay","onHoverDay","onSetSelected","onKeyDown","_useDays","useDays","_useDays2","_slicedToArray","days","selected","selectedRef","useRef","onSetSelectedRef","offset","ROW_STEP","getSelectedDate","useCallback","event","_event$currentTarget$","currentTarget","dataset","day","monthIndex","year","selectedDate","Number","canSelectDate","handleOnChangeDay","i","j","isSelectProcess","undefined","handleOnHoverDay","isSelectedDone","Array","isArray","handleOnFocusDay","getRefs","element","isDayInCurrentMonth","current","useEffect","_onSetSelectedRef$cur","call","React","createElement","StyledCalendarDays","role","_StyledCalendarDaysHi","StyledCalendarDaysHint","id","StyledFlex","SHORT_DAY_NAMES","map","name","CalendarDayItem","FULL_DAY_NAMES","key","dayOfWeek","_ref2","events","disabled","isSelected","isCurrent","inRange","_ref2$isOutOfMinMaxRa","isOutOfMinMaxRange","disabledArrowKey","disabledMonths","ref","isFocused","isHovered","isSameDay","getInRange","sideInRange","getSideInRange","onClick","onMouseOver","onFocus","concat"],"mappings":";;;;;;;;AAmBA;AACA;AACA;IACaA,YAAyC,GAAG,SAA5CA,YAAyCA,CAAAC,IAAA,EAiBhD;AAAA,EAAA,IAhBIC,WAAW,GAAAD,IAAA,CAAjBE,IAAI;IACJC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,SAAS,GAAAJ,IAAA,CAATI,SAAS;IACTC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IACZC,GAAG,GAAAN,IAAA,CAAHM,GAAG;IACHC,GAAG,GAAAP,IAAA,CAAHO,GAAG;IACHC,gBAAgB,GAAAR,IAAA,CAAhBQ,gBAAgB;IAChBC,UAAU,GAAAT,IAAA,CAAVS,UAAU;IACVC,aAAa,GAAAV,IAAA,CAAbU,aAAa;IACbC,QAAQ,GAAAX,IAAA,CAARW,QAAQ;IACRC,QAAQ,GAAAZ,IAAA,CAARY,QAAQ;IACRC,SAAS,GAAAb,IAAA,CAATa,SAAS;IACTC,WAAW,GAAAd,IAAA,CAAXc,WAAW;IACXC,UAAU,GAAAf,IAAA,CAAVe,UAAU;IACVC,aAAa,GAAAhB,IAAA,CAAbgB,aAAa;IACbC,SAAS,G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@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.82.0-dev.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -102,5 +102,5 @@
|
|
102
102
|
"react-popper": "2.3.0",
|
103
103
|
"storeon": "3.1.5"
|
104
104
|
},
|
105
|
-
"gitHead": "
|
105
|
+
"gitHead": "31e6bd9f3b1d26127a62b4b00b6f821bdab73509"
|
106
106
|
}
|
@@ -14,7 +14,7 @@ var _ui = /*#__PURE__*/require("../ui");
|
|
14
14
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
15
15
|
var _base2 = /*#__PURE__*/require("./variations/_size/base");
|
16
16
|
var _CalendarBase = /*#__PURE__*/require("./CalendarBase.styles");
|
17
|
-
var _excluded = ["value", "min", "max", "type", "eventList", "disabledList", "onChangeValue"];
|
17
|
+
var _excluded = ["value", "min", "max", "includeEdgeDates", "type", "eventList", "disabledList", "onChangeValue"];
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
19
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
20
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -34,6 +34,7 @@ var calendarBaseRoot = exports.calendarBaseRoot = function calendarBaseRoot(Root
|
|
34
34
|
var externalValue = _ref.value,
|
35
35
|
min = _ref.min,
|
36
36
|
max = _ref.max,
|
37
|
+
includeEdgeDates = _ref.includeEdgeDates,
|
37
38
|
_ref$type = _ref.type,
|
38
39
|
type = _ref$type === void 0 ? 'Days' : _ref$type,
|
39
40
|
eventList = _ref.eventList,
|
@@ -242,6 +243,7 @@ var calendarBaseRoot = exports.calendarBaseRoot = function calendarBaseRoot(Root
|
|
242
243
|
disabledList: disabledList,
|
243
244
|
min: min,
|
244
245
|
max: max,
|
246
|
+
includeEdgeDates: includeEdgeDates,
|
245
247
|
value: externalValue,
|
246
248
|
date: date,
|
247
249
|
hoveredDay: hoveredDay,
|
@@ -12,7 +12,7 @@ var _ui = /*#__PURE__*/require("../ui");
|
|
12
12
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
13
13
|
var _CalendarDouble = /*#__PURE__*/require("./CalendarDouble.styles");
|
14
14
|
var _StyledSeparator;
|
15
|
-
var _excluded = ["value", "min", "max", "eventList", "disabledList", "onChangeValue"];
|
15
|
+
var _excluded = ["value", "min", "max", "includeEdgeDates", "eventList", "disabledList", "onChangeValue"];
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
18
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
@@ -32,6 +32,7 @@ var calendarDoubleRoot = exports.calendarDoubleRoot = function calendarDoubleRoo
|
|
32
32
|
var externalValue = _ref.value,
|
33
33
|
min = _ref.min,
|
34
34
|
max = _ref.max,
|
35
|
+
includeEdgeDates = _ref.includeEdgeDates,
|
35
36
|
eventList = _ref.eventList,
|
36
37
|
disabledList = _ref.disabledList,
|
37
38
|
onChangeValue = _ref.onChangeValue,
|
@@ -155,6 +156,7 @@ var calendarDoubleRoot = exports.calendarDoubleRoot = function calendarDoubleRoo
|
|
155
156
|
disabledList: disabledList,
|
156
157
|
min: min,
|
157
158
|
max: max,
|
159
|
+
includeEdgeDates: includeEdgeDates,
|
158
160
|
value: externalValue,
|
159
161
|
date: firstDate,
|
160
162
|
hoveredDay: hoveredDay,
|
@@ -171,6 +173,7 @@ var calendarDoubleRoot = exports.calendarDoubleRoot = function calendarDoubleRoo
|
|
171
173
|
disabledList: disabledList,
|
172
174
|
min: min,
|
173
175
|
max: max,
|
176
|
+
includeEdgeDates: includeEdgeDates,
|
174
177
|
value: externalValue,
|
175
178
|
date: secondDate,
|
176
179
|
hoveredDay: hoveredDay,
|
@@ -188,6 +188,7 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
188
188
|
var disabledList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
189
189
|
var min = arguments.length > 3 ? arguments[3] : undefined;
|
190
190
|
var max = arguments.length > 4 ? arguments[4] : undefined;
|
191
|
+
var includeEdgeDates = arguments.length > 5 ? arguments[5] : undefined;
|
191
192
|
var eventsMap = getPropsMap(eventList);
|
192
193
|
var disabledDaysMap = getPropsMap(disabledList);
|
193
194
|
var daysList = days.filter(function (_ref3) {
|
@@ -205,7 +206,9 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
205
206
|
day = date.day;
|
206
207
|
var keyDay = "".concat(year, "-").concat(monthIndex, "-").concat(day);
|
207
208
|
var currentDate = new Date(year, monthIndex, day);
|
208
|
-
var
|
209
|
+
var minValue = min && (includeEdgeDates ? min > currentDate : min >= currentDate);
|
210
|
+
var maxValue = max && (includeEdgeDates ? max < currentDate : max <= currentDate);
|
211
|
+
var isOutOfMinMaxRange = minValue || maxValue;
|
209
212
|
dayItem.events = eventsMap.get(keyDay);
|
210
213
|
dayItem.disabled = disabledDaysMap.has(keyDay) || isOutOfMinMaxRange;
|
211
214
|
dayItem.isOutOfMinMaxRange = isOutOfMinMaxRange;
|
@@ -218,7 +221,7 @@ var getDaysWithModifications = function getDaysWithModifications(days) {
|
|
218
221
|
/**
|
219
222
|
* Хук для получения списка дней.
|
220
223
|
*/
|
221
|
-
var useDays = exports.useDays = function useDays(date, value, eventList, disabledList, min, max) {
|
224
|
+
var useDays = exports.useDays = function useDays(date, value, eventList, disabledList, min, max, includeEdgeDates) {
|
222
225
|
return (0, _react.useMemo)(function () {
|
223
226
|
var monthIndex = date.monthIndex,
|
224
227
|
year = date.year;
|
@@ -226,7 +229,7 @@ var useDays = exports.useDays = function useDays(date, value, eventList, disable
|
|
226
229
|
var offsetDayInWeek = (0, _utils.getOffsetDayInWeek)(monthIndex, year);
|
227
230
|
var days = [].concat(_toConsumableArray(getDaysInPrevMonth(date, offsetDayInWeek, value)), _toConsumableArray(getDaysInCurrentMonth(date, daysInMonth, value)), _toConsumableArray(getDaysInNextMonth(date, daysInMonth, offsetDayInWeek, value)));
|
228
231
|
if (eventList !== null && eventList !== void 0 && eventList.length || disabledList !== null && disabledList !== void 0 && disabledList.length || max || min) {
|
229
|
-
var modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max);
|
232
|
+
var modifiedDays = getDaysWithModifications(days, eventList, disabledList, min, max, includeEdgeDates);
|
230
233
|
return (0, _utils.getMatrix)(modifiedDays);
|
231
234
|
}
|
232
235
|
return (0, _utils.getMatrix)(days);
|
@@ -29,6 +29,7 @@ var CalendarDays = exports.CalendarDays = function CalendarDays(_ref) {
|
|
29
29
|
disabledList = _ref.disabledList,
|
30
30
|
min = _ref.min,
|
31
31
|
max = _ref.max,
|
32
|
+
includeEdgeDates = _ref.includeEdgeDates,
|
32
33
|
hoveredDay = _ref.hoveredDay,
|
33
34
|
selectIndexes = _ref.selectIndexes,
|
34
35
|
isDouble = _ref.isDouble,
|
@@ -38,7 +39,7 @@ var CalendarDays = exports.CalendarDays = function CalendarDays(_ref) {
|
|
38
39
|
onHoverDay = _ref.onHoverDay,
|
39
40
|
onSetSelected = _ref.onSetSelected,
|
40
41
|
onKeyDown = _ref.onKeyDown;
|
41
|
-
var _useDays = (0, _hooks.useDays)(currentDate, value, eventList, disabledList, min, max),
|
42
|
+
var _useDays = (0, _hooks.useDays)(currentDate, value, eventList, disabledList, min, max, includeEdgeDates),
|
42
43
|
_useDays2 = _slicedToArray(_useDays, 2),
|
43
44
|
days = _useDays2[0],
|
44
45
|
selected = _useDays2[1];
|