@fluentui/react-calendar-compat 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -2
- package/lib/components/Calendar/Calendar.types.js +0 -1
- package/lib/components/Calendar/Calendar.types.js.map +1 -1
- package/lib/components/CalendarDay/CalendarDay.types.js +3 -1
- package/lib/components/CalendarDay/CalendarDay.types.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js +3 -0
- package/lib/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js +3 -1
- package/lib/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -1
- package/lib/components/CalendarDayGrid/useWeekCornerStyles.styles.raw.js.map +1 -1
- package/lib/components/CalendarDayGrid/useWeeks.js.map +1 -1
- package/lib/components/CalendarMonth/CalendarMonth.js +2 -0
- package/lib/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/lib/components/CalendarMonth/CalendarMonth.types.js +3 -1
- package/lib/components/CalendarMonth/CalendarMonth.types.js.map +1 -1
- package/lib/components/CalendarPicker/CalendarPicker.types.js.map +1 -1
- package/lib/components/CalendarYear/CalendarYear.js +3 -0
- package/lib/components/CalendarYear/CalendarYear.js.map +1 -1
- package/lib/components/CalendarYear/CalendarYear.types.js +3 -1
- package/lib/components/CalendarYear/CalendarYear.types.js.map +1 -1
- package/lib/utils/dateGrid/dateGrid.types.js.map +1 -1
- package/lib/utils/dateGrid/findAvailableDate.js.map +1 -1
- package/lib/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -1
- package/lib/utils/dateGrid/getDayGrid.js.map +1 -1
- package/lib/utils/dateGrid/isAfterMaxDate.js.map +1 -1
- package/lib/utils/dateGrid/isBeforeMinDate.js.map +1 -1
- package/lib/utils/dateGrid/isContiguous.js.map +1 -1
- package/lib/utils/dateGrid/isRestrictedDate.js.map +1 -1
- package/lib-commonjs/components/Calendar/Calendar.types.js +0 -2
- package/lib-commonjs/components/Calendar/Calendar.types.js.map +1 -1
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js +3 -3
- package/lib-commonjs/components/CalendarDay/CalendarDay.types.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js +3 -0
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js +3 -3
- package/lib-commonjs/components/CalendarDayGrid/CalendarDayGrid.types.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/useWeekCornerStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CalendarDayGrid/useWeeks.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js +2 -0
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js +3 -3
- package/lib-commonjs/components/CalendarMonth/CalendarMonth.types.js.map +1 -1
- package/lib-commonjs/components/CalendarPicker/CalendarPicker.types.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/CalendarYear.js +3 -0
- package/lib-commonjs/components/CalendarYear/CalendarYear.js.map +1 -1
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js +3 -3
- package/lib-commonjs/components/CalendarYear/CalendarYear.types.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/dateGrid.types.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/findAvailableDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/getDateRangeTypeToUse.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/getDayGrid.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isAfterMaxDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isBeforeMinDate.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isContiguous.js.map +1 -1
- package/lib-commonjs/utils/dateGrid/isRestrictedDate.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarYear/CalendarYear.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { mergeClasses } from '@griffel/react';\nimport { useCalendarYearStyles_unstable } from './useCalendarYearStyles.styles';\nimport type {\n CalendarYearStrings,\n CalendarYearProps,\n CalendarYearRange,\n CalendarYearHeaderProps,\n} from './CalendarYear.types';\n\nconst CELL_COUNT = 12;\nconst CELLS_PER_ROW = 4;\n\nconst DefaultCalendarYearStrings: CalendarYearStrings = {\n prevRangeAriaLabel: undefined,\n nextRangeAriaLabel: undefined,\n};\ninterface CalendarYearGrid {\n focus(): void;\n}\n\ninterface CalendarYearGridCellProps extends CalendarYearProps {\n year: number;\n current?: boolean;\n selected?: boolean;\n disabled?: boolean;\n onSelectYear?: (year: number) => void;\n onRenderYear?: (year: number) => React.ReactNode;\n}\n\ninterface CalendarYearGridProps extends CalendarYearProps, CalendarYearRange {\n selectedYear?: number;\n animateBackwards?: boolean;\n componentRef?: React.RefObject<CalendarYearGridCell | null>;\n}\n\ninterface CalendarYearGridCell {\n focus(): void;\n}\n\nconst CalendarYearGridCell: React.FunctionComponent<CalendarYearGridCellProps> = props => {\n const {\n className,\n highlightCurrentYear,\n highlightSelectedYear,\n year,\n selected,\n disabled,\n componentRef,\n onSelectYear,\n onRenderYear,\n } = props;\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n React.useImperativeHandle(\n componentRef,\n () => ({\n focus() {\n buttonRef.current?.focus?.();\n },\n }),\n [],\n );\n\n const onClick = () => {\n onSelectYear?.(year);\n };\n\n const onKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter) {\n onSelectYear?.(year);\n }\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n highlightCurrent: highlightCurrentYear,\n highlightSelected: highlightSelectedYear,\n });\n\n return (\n <button\n className={mergeClasses(classNames.itemButton, selected && classNames.selected, disabled && classNames.disabled)}\n type=\"button\"\n role=\"gridcell\"\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? onKeyDown : undefined}\n disabled={disabled}\n aria-selected={selected}\n ref={buttonRef}\n >\n {onRenderYear?.(year) ?? year}\n </button>\n );\n};\nCalendarYearGridCell.displayName = 'CalendarYearGridCell';\n\nconst CalendarYearGrid: React.FunctionComponent<CalendarYearGridProps> = props => {\n const {\n className,\n fromYear,\n toYear,\n animationDirection,\n animateBackwards,\n minYear,\n maxYear,\n onSelectYear,\n selectedYear,\n componentRef,\n } = props;\n\n const selectedCellRef = React.useRef<CalendarYearGridCell>(null);\n\n const currentCellRef = React.useRef<CalendarYearGridCell>(null);\n\n React.useImperativeHandle(\n componentRef,\n () => ({\n focus() {\n (selectedCellRef.current || currentCellRef.current)?.focus?.();\n },\n }),\n [],\n );\n\n const renderCell = (yearToRender: number): React.ReactNode => {\n const selected = yearToRender === selectedYear;\n const disabled =\n (minYear !== undefined && yearToRender < minYear) || (maxYear !== undefined && yearToRender > maxYear);\n const current = yearToRender === new Date().getFullYear();\n\n return (\n <CalendarYearGridCell\n {...props}\n key={yearToRender}\n year={yearToRender}\n selected={selected}\n current={current}\n disabled={disabled}\n onSelectYear={onSelectYear}\n componentRef={selected ? selectedCellRef : current ? currentCellRef : undefined}\n />\n );\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n animateBackwards,\n animationDirection,\n });\n\n const onRenderYear = (value: number) => {\n return props.onRenderYear?.(value) ?? value;\n };\n\n const gridAriaLabel = `${onRenderYear(fromYear)} - ${onRenderYear(toYear)}`;\n\n let year = fromYear;\n const cells: React.ReactNode[][] = [];\n\n for (let i = 0; i < (toYear - fromYear + 1) / CELLS_PER_ROW; i++) {\n cells.push([]);\n for (let j = 0; j < CELLS_PER_ROW; j++) {\n cells[i].push(renderCell(year));\n year++;\n }\n }\n\n const arrowNavigationAttributes = useArrowNavigationGroup({ axis: 'grid' });\n\n return (\n <div {...arrowNavigationAttributes} className={classNames.gridContainer} role=\"grid\" aria-label={gridAriaLabel}>\n {cells.map((cellRow: React.ReactNode[], index: number) => {\n return (\n <div key={'yearPickerRow_' + index + '_' + fromYear} role=\"row\" className={classNames.buttonRow}>\n {cellRow}\n </div>\n );\n })}\n </div>\n );\n};\nCalendarYearGrid.displayName = 'CalendarYearGrid';\n\nconst CalendarYearNavDirection = {\n Previous: 0 as const,\n Next: 1 as const,\n};\n\ninterface CalendarYearNavArrowProps extends CalendarYearHeaderProps {\n direction: (typeof CalendarYearNavDirection)[keyof typeof CalendarYearNavDirection];\n}\n\nconst CalendarYearNavArrow: React.FunctionComponent<CalendarYearNavArrowProps> = props => {\n const {\n className,\n strings = DefaultCalendarYearStrings,\n direction,\n onSelectPrev,\n onSelectNext,\n fromYear,\n toYear,\n maxYear,\n minYear,\n navigationIcons,\n } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n const ariaLabel =\n direction === CalendarYearNavDirection.Previous ? strings.prevRangeAriaLabel : strings.nextRangeAriaLabel;\n const newRangeOffset = direction === CalendarYearNavDirection.Previous ? -CELL_COUNT : CELL_COUNT;\n const newRange = { fromYear: fromYear + newRangeOffset, toYear: toYear + newRangeOffset };\n const ariaLabelString = ariaLabel ? (typeof ariaLabel === 'string' ? ariaLabel : ariaLabel(newRange)) : undefined;\n const disabled =\n direction === CalendarYearNavDirection.Previous\n ? minYear !== undefined && fromYear < minYear\n : maxYear !== undefined && props.fromYear + CELL_COUNT > maxYear;\n\n const onNavigate = () => {\n direction === CalendarYearNavDirection.Previous ? onSelectPrev?.() : onSelectNext?.();\n };\n\n const onKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter) {\n onNavigate();\n }\n };\n\n return (\n <button\n className={mergeClasses(classNames.navigationButton, disabled && classNames.disabled)}\n onClick={!disabled ? onNavigate : undefined}\n onKeyDown={!disabled ? onKeyDown : undefined}\n type=\"button\"\n title={ariaLabelString}\n disabled={disabled}\n >\n {direction === CalendarYearNavDirection.Previous ? navigationIcons.upNavigation : navigationIcons.downNavigation}\n </button>\n );\n};\nCalendarYearNavArrow.displayName = 'CalendarYearNavArrow';\n\nconst CalendarYearNav: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const { className } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n return (\n <div className={classNames.navigationButtonsContainer}>\n <CalendarYearNavArrow {...props} direction={CalendarYearNavDirection.Previous} />\n <CalendarYearNavArrow {...props} direction={CalendarYearNavDirection.Next} />\n </div>\n );\n};\nCalendarYearNav.displayName = 'CalendarYearNav';\n\nconst CalendarYearTitle: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const {\n className,\n fromYear,\n toYear,\n strings = DefaultCalendarYearStrings,\n animateBackwards,\n animationDirection,\n } = props;\n\n const onHeaderSelect = () => {\n props.onHeaderSelect?.(true);\n };\n\n const onHeaderKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter || ev.key === Space) {\n onHeaderSelect();\n }\n };\n\n const onRenderYear = (year: number) => {\n return props.onRenderYear?.(year) ?? year;\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n hasHeaderClickCallback: !!props.onHeaderSelect,\n animateBackwards,\n animationDirection,\n });\n\n if (props.onHeaderSelect) {\n const rangeAriaLabel = strings.rangeAriaLabel;\n const headerAriaLabelFormatString = strings.headerAriaLabelFormatString;\n const currentDateRange = rangeAriaLabel\n ? typeof rangeAriaLabel === 'string'\n ? rangeAriaLabel\n : rangeAriaLabel(props)\n : undefined;\n\n const ariaLabel = headerAriaLabelFormatString\n ? headerAriaLabelFormatString.replace('{0}', currentDateRange ?? '')\n : currentDateRange;\n\n return (\n <button\n className={classNames.currentItemButton}\n onClick={onHeaderSelect}\n onKeyDown={onHeaderKeyDown}\n aria-label={ariaLabel}\n role=\"button\"\n type=\"button\"\n >\n <span aria-live=\"assertive\" aria-atomic=\"true\">\n {onRenderYear(fromYear)} - {onRenderYear(toYear)}\n </span>\n </button>\n );\n }\n\n return (\n <div className={classNames.current}>\n {onRenderYear(fromYear)} - {onRenderYear(toYear)}\n </div>\n );\n};\nCalendarYearTitle.displayName = 'CalendarYearTitle';\n\nconst CalendarYearHeader: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const { className, animateBackwards, animationDirection, onRenderTitle } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n hasHeaderClickCallback: !!props.onHeaderSelect,\n animateBackwards,\n animationDirection,\n });\n\n return (\n <div className={classNames.headerContainer}>\n {onRenderTitle?.(props) ?? <CalendarYearTitle {...props} />}\n <CalendarYearNav {...props} />\n </div>\n );\n};\nCalendarYearHeader.displayName = 'CalendarYearHeader';\n\nfunction useAnimateBackwards({ selectedYear, navigatedYear }: CalendarYearProps) {\n const rangeYear = selectedYear || navigatedYear || new Date().getFullYear();\n const fromYear = Math.floor(rangeYear / 10) * 10;\n\n const previousFromYearRef = React.useRef<number | undefined>(fromYear);\n React.useRef(() => {\n previousFromYearRef.current = fromYear;\n });\n const previousFromYear = previousFromYearRef.current;\n\n if (!previousFromYear || previousFromYear === fromYear) {\n return undefined;\n } else if (previousFromYear > fromYear) {\n return true;\n } else {\n return false;\n }\n}\n\nfunction useYearRangeState({ selectedYear, navigatedYear, onNavigateDate }: CalendarYearProps) {\n const rangeYear = React.useMemo(() => {\n return selectedYear || navigatedYear || Math.floor(new Date().getFullYear() / 10) * 10;\n }, [navigatedYear, selectedYear]);\n\n const [fromYear, setFromYear] = React.useState<number>(rangeYear);\n\n const onNavNext = () => {\n const newFromYear = fromYear + CELL_COUNT;\n setFromYear(newFromYear);\n onNavigateDate?.(newFromYear);\n };\n\n const onNavPrevious = () => {\n const newFromYear = fromYear - CELL_COUNT;\n setFromYear(newFromYear);\n onNavigateDate?.(newFromYear);\n };\n\n React.useEffect(() => {\n setFromYear(rangeYear);\n }, [rangeYear]);\n\n const toYear = fromYear + CELL_COUNT - 1;\n\n return [fromYear, toYear, onNavNext, onNavPrevious] as const;\n}\n\n/**\n * @internal\n */\nexport const CalendarYear: React.FunctionComponent<CalendarYearProps> = props => {\n const animateBackwards = useAnimateBackwards(props);\n const [fromYear, toYear, onNavNext, onNavPrevious] = useYearRangeState(props);\n\n const gridRef = React.useRef<CalendarYearGrid>(null);\n\n React.useImperativeHandle(props.componentRef, () => ({\n focus() {\n gridRef.current?.focus?.();\n },\n }));\n\n const { className } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n return (\n <div className={classNames.root}>\n <CalendarYearHeader\n {...props}\n fromYear={fromYear}\n toYear={toYear}\n onSelectPrev={onNavPrevious}\n onSelectNext={onNavNext}\n animateBackwards={animateBackwards}\n />\n <CalendarYearGrid\n {...props}\n fromYear={fromYear}\n toYear={toYear}\n animateBackwards={animateBackwards}\n componentRef={gridRef}\n />\n </div>\n );\n};\nCalendarYear.displayName = 'CalendarYear';\n"],"names":["React","Enter","Space","useArrowNavigationGroup","mergeClasses","useCalendarYearStyles_unstable","CELL_COUNT","CELLS_PER_ROW","DefaultCalendarYearStrings","prevRangeAriaLabel","undefined","nextRangeAriaLabel","CalendarYearGridCell","props","className","highlightCurrentYear","highlightSelectedYear","year","selected","disabled","componentRef","onSelectYear","onRenderYear","buttonRef","useRef","useImperativeHandle","focus","current","onClick","onKeyDown","ev","key","classNames","highlightCurrent","highlightSelected","button","itemButton","type","role","aria-selected","ref","displayName","CalendarYearGrid","fromYear","toYear","animationDirection","animateBackwards","minYear","maxYear","selectedYear","selectedCellRef","currentCellRef","renderCell","yearToRender","Date","getFullYear","value","gridAriaLabel","cells","i","push","j","arrowNavigationAttributes","axis","div","gridContainer","aria-label","map","cellRow","index","buttonRow","CalendarYearNavDirection","Previous","Next","CalendarYearNavArrow","strings","direction","onSelectPrev","onSelectNext","navigationIcons","ariaLabel","newRangeOffset","newRange","ariaLabelString","onNavigate","navigationButton","title","upNavigation","downNavigation","CalendarYearNav","navigationButtonsContainer","CalendarYearTitle","onHeaderSelect","onHeaderKeyDown","hasHeaderClickCallback","rangeAriaLabel","headerAriaLabelFormatString","currentDateRange","replace","currentItemButton","span","aria-live","aria-atomic","CalendarYearHeader","onRenderTitle","headerContainer","useAnimateBackwards","navigatedYear","rangeYear","Math","floor","previousFromYearRef","previousFromYear","useYearRangeState","onNavigateDate","useMemo","setFromYear","useState","onNavNext","newFromYear","onNavPrevious","useEffect","CalendarYear","gridRef","root"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,EAAEC,KAAK,QAAQ,0BAA0B;AACvD,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,8BAA8B,QAAQ,iCAAiC;AAQhF,MAAMC,aAAa;AACnB,MAAMC,gBAAgB;AAEtB,MAAMC,6BAAkD;IACtDC,oBAAoBC;IACpBC,oBAAoBD;AACtB;AAwBA,MAAME,uBAA2EC,CAAAA;IAC/E,MAAM,EACJC,SAAS,EACTC,oBAAoB,EACpBC,qBAAqB,EACrBC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,YAAY,EACb,GAAGT;IAEJ,MAAMU,YAAYvB,MAAMwB,MAAM,CAAoB;IAElDxB,MAAMyB,mBAAmB,CACvBL,cACA,IAAO,CAAA;YACLM;oBACEH,0BAAAA;iBAAAA,qBAAAA,UAAUI,OAAO,cAAjBJ,0CAAAA,2BAAAA,mBAAmBG,KAAK,cAAxBH,+CAAAA,8BAAAA;YACF;QACF,CAAA,GACA,EAAE;IAGJ,MAAMK,UAAU;QACdP,yBAAAA,mCAAAA,aAAeJ;IACjB;IAEA,MAAMY,YAAY,CAACC;QACjB,IAAIA,GAAGC,GAAG,KAAK9B,OAAO;YACpBoB,yBAAAA,mCAAAA,aAAeJ;QACjB;IACF;IAEA,MAAMe,aAAa3B,+BAA+B;QAChDS;QACAmB,kBAAk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;QACRE,kBAAkBA;QAClB1B,cAAcuG;;AAItB,EAAE;AACFD,aAAajF,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarYear/CalendarYear.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { mergeClasses } from '@griffel/react';\nimport { useCalendarYearStyles_unstable } from './useCalendarYearStyles.styles';\nimport type {\n CalendarYearStrings,\n CalendarYearProps,\n CalendarYearRange,\n CalendarYearHeaderProps,\n} from './CalendarYear.types';\n\nconst CELL_COUNT = 12;\nconst CELLS_PER_ROW = 4;\n\nconst DefaultCalendarYearStrings: CalendarYearStrings = {\n prevRangeAriaLabel: undefined,\n nextRangeAriaLabel: undefined,\n};\ninterface CalendarYearGrid {\n focus(): void;\n}\n\ninterface CalendarYearGridCellProps extends CalendarYearProps {\n year: number;\n current?: boolean;\n selected?: boolean;\n disabled?: boolean;\n onSelectYear?: (year: number) => void;\n onRenderYear?: (year: number) => React.ReactNode;\n}\n\ninterface CalendarYearGridProps extends CalendarYearProps, CalendarYearRange {\n selectedYear?: number;\n animateBackwards?: boolean;\n componentRef?: React.RefObject<CalendarYearGridCell | null>;\n}\n\ninterface CalendarYearGridCell {\n focus(): void;\n}\n\nconst CalendarYearGridCell: React.FunctionComponent<CalendarYearGridCellProps> = props => {\n const {\n className,\n highlightCurrentYear,\n highlightSelectedYear,\n year,\n selected,\n disabled,\n componentRef,\n onSelectYear,\n onRenderYear,\n } = props;\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n React.useImperativeHandle(\n componentRef,\n () => ({\n focus() {\n buttonRef.current?.focus?.();\n },\n }),\n [],\n );\n\n const onClick = () => {\n onSelectYear?.(year);\n };\n\n const onKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter) {\n onSelectYear?.(year);\n }\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n highlightCurrent: highlightCurrentYear,\n highlightSelected: highlightSelectedYear,\n });\n\n return (\n <button\n className={mergeClasses(classNames.itemButton, selected && classNames.selected, disabled && classNames.disabled)}\n type=\"button\"\n role=\"gridcell\"\n onClick={!disabled ? onClick : undefined}\n onKeyDown={!disabled ? onKeyDown : undefined}\n disabled={disabled}\n aria-selected={selected}\n ref={buttonRef}\n >\n {onRenderYear?.(year) ?? year}\n </button>\n );\n};\nCalendarYearGridCell.displayName = 'CalendarYearGridCell';\n\nconst CalendarYearGrid: React.FunctionComponent<CalendarYearGridProps> = props => {\n const {\n className,\n fromYear,\n toYear,\n animationDirection,\n animateBackwards,\n minYear,\n maxYear,\n onSelectYear,\n selectedYear,\n componentRef,\n } = props;\n\n const selectedCellRef = React.useRef<CalendarYearGridCell>(null);\n\n const currentCellRef = React.useRef<CalendarYearGridCell>(null);\n\n React.useImperativeHandle(\n componentRef,\n () => ({\n focus() {\n (selectedCellRef.current || currentCellRef.current)?.focus?.();\n },\n }),\n [],\n );\n\n const renderCell = (yearToRender: number): React.ReactNode => {\n const selected = yearToRender === selectedYear;\n const disabled =\n (minYear !== undefined && yearToRender < minYear) || (maxYear !== undefined && yearToRender > maxYear);\n const current = yearToRender === new Date().getFullYear();\n\n return (\n <CalendarYearGridCell\n {...props}\n key={yearToRender}\n year={yearToRender}\n selected={selected}\n current={current}\n disabled={disabled}\n onSelectYear={onSelectYear}\n componentRef={selected ? selectedCellRef : current ? currentCellRef : undefined}\n />\n );\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n animateBackwards,\n animationDirection,\n });\n\n const onRenderYear = (value: number) => {\n return props.onRenderYear?.(value) ?? value;\n };\n\n const gridAriaLabel = `${onRenderYear(fromYear)} - ${onRenderYear(toYear)}`;\n\n let year = fromYear;\n const cells: React.ReactNode[][] = [];\n\n for (let i = 0; i < (toYear - fromYear + 1) / CELLS_PER_ROW; i++) {\n cells.push([]);\n for (let j = 0; j < CELLS_PER_ROW; j++) {\n cells[i].push(renderCell(year));\n year++;\n }\n }\n\n const arrowNavigationAttributes = useArrowNavigationGroup({ axis: 'grid' });\n\n return (\n <div {...arrowNavigationAttributes} className={classNames.gridContainer} role=\"grid\" aria-label={gridAriaLabel}>\n {cells.map((cellRow: React.ReactNode[], index: number) => {\n return (\n <div key={'yearPickerRow_' + index + '_' + fromYear} role=\"row\" className={classNames.buttonRow}>\n {cellRow}\n </div>\n );\n })}\n </div>\n );\n};\nCalendarYearGrid.displayName = 'CalendarYearGrid';\n\nconst CalendarYearNavDirection = {\n Previous: 0 as const,\n Next: 1 as const,\n};\n\ninterface CalendarYearNavArrowProps extends CalendarYearHeaderProps {\n direction: (typeof CalendarYearNavDirection)[keyof typeof CalendarYearNavDirection];\n}\n\nconst CalendarYearNavArrow: React.FunctionComponent<CalendarYearNavArrowProps> = props => {\n const {\n className,\n strings = DefaultCalendarYearStrings,\n direction,\n onSelectPrev,\n onSelectNext,\n fromYear,\n toYear,\n maxYear,\n minYear,\n navigationIcons,\n } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n const ariaLabel =\n direction === CalendarYearNavDirection.Previous ? strings.prevRangeAriaLabel : strings.nextRangeAriaLabel;\n const newRangeOffset = direction === CalendarYearNavDirection.Previous ? -CELL_COUNT : CELL_COUNT;\n const newRange = { fromYear: fromYear + newRangeOffset, toYear: toYear + newRangeOffset };\n const ariaLabelString = ariaLabel ? (typeof ariaLabel === 'string' ? ariaLabel : ariaLabel(newRange)) : undefined;\n const disabled =\n direction === CalendarYearNavDirection.Previous\n ? minYear !== undefined && fromYear < minYear\n : maxYear !== undefined && props.fromYear + CELL_COUNT > maxYear;\n\n const onNavigate = () => {\n direction === CalendarYearNavDirection.Previous ? onSelectPrev?.() : onSelectNext?.();\n };\n\n const onKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter) {\n onNavigate();\n }\n };\n\n return (\n <button\n className={mergeClasses(classNames.navigationButton, disabled && classNames.disabled)}\n onClick={!disabled ? onNavigate : undefined}\n onKeyDown={!disabled ? onKeyDown : undefined}\n type=\"button\"\n title={ariaLabelString}\n disabled={disabled}\n >\n {direction === CalendarYearNavDirection.Previous ? navigationIcons.upNavigation : navigationIcons.downNavigation}\n </button>\n );\n};\nCalendarYearNavArrow.displayName = 'CalendarYearNavArrow';\n\nconst CalendarYearNav: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const { className } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n return (\n <div className={classNames.navigationButtonsContainer}>\n <CalendarYearNavArrow {...props} direction={CalendarYearNavDirection.Previous} />\n <CalendarYearNavArrow {...props} direction={CalendarYearNavDirection.Next} />\n </div>\n );\n};\nCalendarYearNav.displayName = 'CalendarYearNav';\n\nconst CalendarYearTitle: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const {\n className,\n fromYear,\n toYear,\n strings = DefaultCalendarYearStrings,\n animateBackwards,\n animationDirection,\n } = props;\n\n const onHeaderSelect = () => {\n props.onHeaderSelect?.(true);\n };\n\n const onHeaderKeyDown = (ev: React.KeyboardEvent<HTMLElement>) => {\n if (ev.key === Enter || ev.key === Space) {\n onHeaderSelect();\n }\n };\n\n const onRenderYear = (year: number) => {\n return props.onRenderYear?.(year) ?? year;\n };\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n hasHeaderClickCallback: !!props.onHeaderSelect,\n animateBackwards,\n animationDirection,\n });\n\n if (props.onHeaderSelect) {\n const rangeAriaLabel = strings.rangeAriaLabel;\n const headerAriaLabelFormatString = strings.headerAriaLabelFormatString;\n const currentDateRange = rangeAriaLabel\n ? typeof rangeAriaLabel === 'string'\n ? rangeAriaLabel\n : rangeAriaLabel(props)\n : undefined;\n\n const ariaLabel = headerAriaLabelFormatString\n ? headerAriaLabelFormatString.replace('{0}', currentDateRange ?? '')\n : currentDateRange;\n\n return (\n <button\n className={classNames.currentItemButton}\n onClick={onHeaderSelect}\n onKeyDown={onHeaderKeyDown}\n aria-label={ariaLabel}\n role=\"button\"\n type=\"button\"\n >\n <span aria-live=\"assertive\" aria-atomic=\"true\">\n {onRenderYear(fromYear)} - {onRenderYear(toYear)}\n </span>\n </button>\n );\n }\n\n return (\n <div className={classNames.current}>\n {onRenderYear(fromYear)} - {onRenderYear(toYear)}\n </div>\n );\n};\nCalendarYearTitle.displayName = 'CalendarYearTitle';\n\nconst CalendarYearHeader: React.FunctionComponent<CalendarYearHeaderProps> = props => {\n const { className, animateBackwards, animationDirection, onRenderTitle } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n hasHeaderClickCallback: !!props.onHeaderSelect,\n animateBackwards,\n animationDirection,\n });\n\n return (\n <div className={classNames.headerContainer}>\n {onRenderTitle?.(props) ?? <CalendarYearTitle {...props} />}\n <CalendarYearNav {...props} />\n </div>\n );\n};\nCalendarYearHeader.displayName = 'CalendarYearHeader';\n\nfunction useAnimateBackwards({ selectedYear, navigatedYear }: CalendarYearProps) {\n const rangeYear = selectedYear || navigatedYear || new Date().getFullYear();\n const fromYear = Math.floor(rangeYear / 10) * 10;\n\n const previousFromYearRef = React.useRef<number | undefined>(fromYear);\n React.useRef(() => {\n previousFromYearRef.current = fromYear;\n });\n // eslint-disable-next-line react-hooks/refs\n const previousFromYear = previousFromYearRef.current;\n\n // eslint-disable-next-line react-hooks/refs\n if (!previousFromYear || previousFromYear === fromYear) {\n return undefined;\n } else if (previousFromYear > fromYear) {\n return true;\n } else {\n return false;\n }\n}\n\nfunction useYearRangeState({ selectedYear, navigatedYear, onNavigateDate }: CalendarYearProps) {\n const rangeYear = React.useMemo(() => {\n return selectedYear || navigatedYear || Math.floor(new Date().getFullYear() / 10) * 10;\n }, [navigatedYear, selectedYear]);\n\n const [fromYear, setFromYear] = React.useState<number>(rangeYear);\n\n const onNavNext = () => {\n const newFromYear = fromYear + CELL_COUNT;\n setFromYear(newFromYear);\n onNavigateDate?.(newFromYear);\n };\n\n const onNavPrevious = () => {\n const newFromYear = fromYear - CELL_COUNT;\n setFromYear(newFromYear);\n onNavigateDate?.(newFromYear);\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setFromYear(rangeYear);\n }, [rangeYear]);\n\n const toYear = fromYear + CELL_COUNT - 1;\n\n return [fromYear, toYear, onNavNext, onNavPrevious] as const;\n}\n\n/**\n * @internal\n */\nexport const CalendarYear: React.FunctionComponent<CalendarYearProps> = props => {\n const animateBackwards = useAnimateBackwards(props);\n const [fromYear, toYear, onNavNext, onNavPrevious] = useYearRangeState(props);\n\n const gridRef = React.useRef<CalendarYearGrid>(null);\n\n React.useImperativeHandle(props.componentRef, () => ({\n focus() {\n gridRef.current?.focus?.();\n },\n }));\n\n const { className } = props;\n\n const classNames = useCalendarYearStyles_unstable({\n className,\n });\n\n return (\n <div className={classNames.root}>\n <CalendarYearHeader\n {...props}\n fromYear={fromYear}\n toYear={toYear}\n onSelectPrev={onNavPrevious}\n onSelectNext={onNavNext}\n animateBackwards={animateBackwards}\n />\n <CalendarYearGrid\n {...props}\n fromYear={fromYear}\n toYear={toYear}\n animateBackwards={animateBackwards}\n componentRef={gridRef}\n />\n </div>\n );\n};\nCalendarYear.displayName = 'CalendarYear';\n"],"names":["React","Enter","Space","useArrowNavigationGroup","mergeClasses","useCalendarYearStyles_unstable","CELL_COUNT","CELLS_PER_ROW","DefaultCalendarYearStrings","prevRangeAriaLabel","undefined","nextRangeAriaLabel","CalendarYearGridCell","props","className","highlightCurrentYear","highlightSelectedYear","year","selected","disabled","componentRef","onSelectYear","onRenderYear","buttonRef","useRef","useImperativeHandle","focus","current","onClick","onKeyDown","ev","key","classNames","highlightCurrent","highlightSelected","button","itemButton","type","role","aria-selected","ref","displayName","CalendarYearGrid","fromYear","toYear","animationDirection","animateBackwards","minYear","maxYear","selectedYear","selectedCellRef","currentCellRef","renderCell","yearToRender","Date","getFullYear","value","gridAriaLabel","cells","i","push","j","arrowNavigationAttributes","axis","div","gridContainer","aria-label","map","cellRow","index","buttonRow","CalendarYearNavDirection","Previous","Next","CalendarYearNavArrow","strings","direction","onSelectPrev","onSelectNext","navigationIcons","ariaLabel","newRangeOffset","newRange","ariaLabelString","onNavigate","navigationButton","title","upNavigation","downNavigation","CalendarYearNav","navigationButtonsContainer","CalendarYearTitle","onHeaderSelect","onHeaderKeyDown","hasHeaderClickCallback","rangeAriaLabel","headerAriaLabelFormatString","currentDateRange","replace","currentItemButton","span","aria-live","aria-atomic","CalendarYearHeader","onRenderTitle","headerContainer","useAnimateBackwards","navigatedYear","rangeYear","Math","floor","previousFromYearRef","previousFromYear","useYearRangeState","onNavigateDate","useMemo","setFromYear","useState","onNavNext","newFromYear","onNavPrevious","useEffect","CalendarYear","gridRef","root"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,EAAEC,KAAK,QAAQ,0BAA0B;AACvD,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,8BAA8B,QAAQ,iCAAiC;AAQhF,MAAMC,aAAa;AACnB,MAAMC,gBAAgB;AAEtB,MAAMC,6BAAkD;IACtDC,oBAAoBC;IACpBC,oBAAoBD;AACtB;AAwBA,MAAME,uBAA2EC,CAAAA;IAC/E,MAAM,EACJC,SAAS,EACTC,oBAAoB,EACpBC,qBAAqB,EACrBC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,YAAY,EACZC,YAAY,EACZC,YAAY,EACb,GAAGT;IAEJ,MAAMU,YAAYvB,MAAMwB,MAAM,CAAoB;IAElDxB,MAAMyB,mBAAmB,CACvBL,cACA,IAAO,CAAA;YACLM;oBACEH,0BAAAA;iBAAAA,qBAAAA,UAAUI,OAAO,cAAjBJ,0CAAAA,2BAAAA,mBAAmBG,KAAK,cAAxBH,+CAAAA,8BAAAA;YACF;QACF,CAAA,GACA,EAAE;IAGJ,MAAMK,UAAU;QACdP,yBAAAA,mCAAAA,aAAeJ;IACjB;IAEA,MAAMY,YAAY,CAACC;QACjB,IAAIA,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7B,oBAACrB;QACE,GAAG1F,KAAK;QACT8B,UAAUA;QACVC,QAAQA;QACRiC,cAAc2C;QACd1C,cAAcwC;QACdxE,kBAAkBA;sBAEpB,oBAACJ;QACE,GAAG7B,KAAK;QACT8B,UAAUA;QACVC,QAAQA;QACRE,kBAAkBA;QAClB1B,cAAcuG;;AAItB,EAAE;AACFD,aAAajF,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarYear/CalendarYear.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { AnimationDirection } from '../Calendar/Calendar.types';\nimport type { CalendarNavigationIcons } from '../Calendar/calendarNavigationIcons';\nimport type { CalendarPickerStyleProps, CalendarPickerStyles } from '../CalendarPicker/CalendarPicker.types';\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarYear {\n focus(): void;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearRange {\n fromYear: number;\n toYear: number;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearRangeToString {\n (range: CalendarYearRange): string;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearStrings {\n rangeAriaLabel?: string | CalendarYearRangeToString;\n prevRangeAriaLabel?: string | CalendarYearRangeToString;\n nextRangeAriaLabel?: string | CalendarYearRangeToString;\n headerAriaLabelFormatString?: string;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearProps {\n /**\n * Optional callback to access the ICalendarYear interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarYear | null>;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings?: CalendarYearStrings;\n\n /**\n * The currently selected year\n */\n selectedYear?: number;\n\n /**\n * The currently navigated year\n */\n navigatedYear?: number;\n\n /**\n * Callback action when a year is selected\n * @param year - The year the user selected\n */\n onSelectYear?: (year: number) => void;\n\n /**\n * Callback action when the decade is navigated\n * @param year - The year at the start of the new decade range being navigated to\n */\n onNavigateDate?: (year: number) => void;\n\n /**\n * Callback action when the header is selected\n */\n onHeaderSelect?: (focus: boolean) => void;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a year earlier than this value.\n */\n minYear?: number;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a year later than this value.\n */\n maxYear?: number;\n\n /**\n * Whether the year picker should highlight the current year\n * @default false\n */\n highlightCurrentYear?: boolean;\n\n /**\n * Whether the year picker should highlight the selected year\n * @default false\n */\n highlightSelectedYear?: boolean;\n\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * Custom renderer for the title\n */\n onRenderTitle?: (props: CalendarYearHeaderProps) => React.ReactNode;\n\n /**\n * Custom renderer for the year\n */\n onRenderYear?: (year: number) => React.ReactNode;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or veritcal\n */\n animationDirection?: AnimationDirection;\n\n /**\n * Custom navigation icons.\n */\n navigationIcons: CalendarNavigationIcons;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearStyleProps extends CalendarPickerStyleProps {}\n\n/**\n * @internal\n */\nexport interface CalendarYearStyles extends CalendarPickerStyles {}\n\n/**\n * @internal\n */\nexport interface CalendarYearHeaderProps extends CalendarYearProps, CalendarYearRange {\n /**\n * Callback action when the 'previous' navigation button is selected\n */\n onSelectPrev?: () => void;\n\n /**\n * Callback action when the 'next' navigation button is selected\n */\n onSelectNext?: () => void;\n\n /**\n * Whether title entering animation should be forwards or backwards\n */\n animateBackwards?: boolean;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarYear/CalendarYear.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { AnimationDirection } from '../Calendar/Calendar.types';\nimport type { CalendarNavigationIcons } from '../Calendar/calendarNavigationIcons';\nimport type { CalendarPickerStyleProps, CalendarPickerStyles } from '../CalendarPicker/CalendarPicker.types';\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarYear {\n focus(): void;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearRange {\n fromYear: number;\n toYear: number;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearRangeToString {\n (range: CalendarYearRange): string;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearStrings {\n rangeAriaLabel?: string | CalendarYearRangeToString;\n prevRangeAriaLabel?: string | CalendarYearRangeToString;\n nextRangeAriaLabel?: string | CalendarYearRangeToString;\n headerAriaLabelFormatString?: string;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearProps {\n /**\n * Optional callback to access the ICalendarYear interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarYear | null>;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings?: CalendarYearStrings;\n\n /**\n * The currently selected year\n */\n selectedYear?: number;\n\n /**\n * The currently navigated year\n */\n navigatedYear?: number;\n\n /**\n * Callback action when a year is selected\n * @param year - The year the user selected\n */\n onSelectYear?: (year: number) => void;\n\n /**\n * Callback action when the decade is navigated\n * @param year - The year at the start of the new decade range being navigated to\n */\n onNavigateDate?: (year: number) => void;\n\n /**\n * Callback action when the header is selected\n */\n onHeaderSelect?: (focus: boolean) => void;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a year earlier than this value.\n */\n minYear?: number;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a year later than this value.\n */\n maxYear?: number;\n\n /**\n * Whether the year picker should highlight the current year\n * @default false\n */\n highlightCurrentYear?: boolean;\n\n /**\n * Whether the year picker should highlight the selected year\n * @default false\n */\n highlightSelectedYear?: boolean;\n\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * Custom renderer for the title\n */\n onRenderTitle?: (props: CalendarYearHeaderProps) => React.ReactNode;\n\n /**\n * Custom renderer for the year\n */\n onRenderYear?: (year: number) => React.ReactNode;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or veritcal\n */\n animationDirection?: AnimationDirection;\n\n /**\n * Custom navigation icons.\n */\n navigationIcons: CalendarNavigationIcons;\n}\n\n/**\n * @internal\n */\nexport interface CalendarYearStyleProps extends CalendarPickerStyleProps {}\n\n/**\n * @internal\n */\nexport interface CalendarYearStyles extends CalendarPickerStyles {}\n\n/**\n * @internal\n */\nexport interface CalendarYearHeaderProps extends CalendarYearProps, CalendarYearRange {\n /**\n * Callback action when the 'previous' navigation button is selected\n */\n onSelectPrev?: () => void;\n\n /**\n * Callback action when the 'next' navigation button is selected\n */\n onSelectNext?: () => void;\n\n /**\n * Whether title entering animation should be forwards or backwards\n */\n animateBackwards?: boolean;\n}\n"],"names":[],"mappings":"AA0IA;;CAEC,GACD,WAeC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/dateGrid.types.ts"],"sourcesContent":["import { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../constants';\n\nexport interface Day {\n /** `Date.toString()` value of current date */\n key: string;\n /** `Date.getDate()` value of current date */\n date: string;\n /** `Date` object of current date */\n originalDate: Date;\n /** Is current date is in the same month as \"today\" date */\n isInMonth: boolean;\n /** Is current date is \"today\" date */\n isToday: boolean;\n /** Is current date is selected in range */\n isSelected: boolean;\n /** Is current date is selected */\n isSingleSelected: boolean;\n /** Is current date within restriction boundaries */\n isInBounds: boolean;\n /** Is current date marked */\n isMarked: boolean;\n}\n\nexport interface AvailableDateOptions extends RestrictedDatesOptions {\n /** Date from which we start the search */\n initialDate: Date;\n /** Ideal available date */\n targetDate: Date;\n /** Direction of search (`1` - search in future / `-1` search in past) */\n direction: number;\n}\n\nexport interface RestrictedDatesOptions {\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n}\n\nexport interface DayGridOptions extends RestrictedDatesOptions {\n /**\n * The first day of the week for your locale.\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n */\n showWeekNumbers?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Which days in the generated grid should be marked.\n */\n markedDays?: Date[];\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n */\n weeksToShow?: number;\n}\n"],"names":[],"mappings":"AAiDA,WA4DC"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/dateGrid.types.ts"],"sourcesContent":["import type { DayOfWeek, DateRangeType, FirstWeekOfYear } from '../constants';\n\nexport interface Day {\n /** `Date.toString()` value of current date */\n key: string;\n /** `Date.getDate()` value of current date */\n date: string;\n /** `Date` object of current date */\n originalDate: Date;\n /** Is current date is in the same month as \"today\" date */\n isInMonth: boolean;\n /** Is current date is \"today\" date */\n isToday: boolean;\n /** Is current date is selected in range */\n isSelected: boolean;\n /** Is current date is selected */\n isSingleSelected: boolean;\n /** Is current date within restriction boundaries */\n isInBounds: boolean;\n /** Is current date marked */\n isMarked: boolean;\n}\n\nexport interface AvailableDateOptions extends RestrictedDatesOptions {\n /** Date from which we start the search */\n initialDate: Date;\n /** Ideal available date */\n targetDate: Date;\n /** Direction of search (`1` - search in future / `-1` search in past) */\n direction: number;\n}\n\nexport interface RestrictedDatesOptions {\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n}\n\nexport interface DayGridOptions extends RestrictedDatesOptions {\n /**\n * The first day of the week for your locale.\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n */\n showWeekNumbers?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Which days in the generated grid should be marked.\n */\n markedDays?: Date[];\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n */\n weeksToShow?: number;\n}\n"],"names":[],"mappings":"AAiDA,WA4DC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/findAvailableDate.ts"],"sourcesContent":["import { AvailableDateOptions } from './dateGrid.types';\n\nimport { isRestrictedDate } from './isRestrictedDate';\n\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { compareDatePart, addDays } from '../dateMath/dateMath';\n\n/**\n * Returns closest available date given the restriction `options`, or undefined otherwise\n * @param options - list of search options\n */\nexport const findAvailableDate = (options: AvailableDateOptions): Date | undefined => {\n const { targetDate, initialDate, direction, ...restrictedDateOptions } = options;\n let availableDate = targetDate;\n // if the target date is available, return it immediately\n if (!isRestrictedDate(targetDate, restrictedDateOptions)) {\n return targetDate;\n }\n\n while (\n compareDatePart(initialDate, availableDate) !== 0 &&\n isRestrictedDate(availableDate, restrictedDateOptions) &&\n !isAfterMaxDate(availableDate, restrictedDateOptions) &&\n !isBeforeMinDate(availableDate, restrictedDateOptions)\n ) {\n availableDate = addDays(availableDate, direction);\n }\n\n if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {\n return availableDate;\n }\n\n return undefined;\n};\n"],"names":["isRestrictedDate","isAfterMaxDate","isBeforeMinDate","compareDatePart","addDays","findAvailableDate","options","targetDate","initialDate","direction","restrictedDateOptions","availableDate","undefined"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,eAAe,EAAEC,OAAO,QAAQ,uBAAuB;AAEhE;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGC,uBAAuB,GAAGJ;IACzE,IAAIK,gBAAgBJ;IACpB,yDAAyD;IACzD,IAAI,CAACP,iBAAiBO,YAAYG,wBAAwB;QACxD,OAAOH;IACT;IAEA,MACEJ,gBAAgBK,aAAaG,mBAAmB,KAChDX,iBAAiBW,eAAeD,0BAChC,CAACT,eAAeU,eAAeD,0BAC/B,CAACR,gBAAgBS,eAAeD,uBAChC;QACAC,gBAAgBP,QAAQO,eAAeF;IACzC;IAEA,IAAIN,gBAAgBK,aAAaG,mBAAmB,KAAK,CAACX,iBAAiBW,eAAeD,wBAAwB;QAChH,OAAOC;IACT;IAEA,OAAOC;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/findAvailableDate.ts"],"sourcesContent":["import type { AvailableDateOptions } from './dateGrid.types';\n\nimport { isRestrictedDate } from './isRestrictedDate';\n\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { compareDatePart, addDays } from '../dateMath/dateMath';\n\n/**\n * Returns closest available date given the restriction `options`, or undefined otherwise\n * @param options - list of search options\n */\nexport const findAvailableDate = (options: AvailableDateOptions): Date | undefined => {\n const { targetDate, initialDate, direction, ...restrictedDateOptions } = options;\n let availableDate = targetDate;\n // if the target date is available, return it immediately\n if (!isRestrictedDate(targetDate, restrictedDateOptions)) {\n return targetDate;\n }\n\n while (\n compareDatePart(initialDate, availableDate) !== 0 &&\n isRestrictedDate(availableDate, restrictedDateOptions) &&\n !isAfterMaxDate(availableDate, restrictedDateOptions) &&\n !isBeforeMinDate(availableDate, restrictedDateOptions)\n ) {\n availableDate = addDays(availableDate, direction);\n }\n\n if (compareDatePart(initialDate, availableDate) !== 0 && !isRestrictedDate(availableDate, restrictedDateOptions)) {\n return availableDate;\n }\n\n return undefined;\n};\n"],"names":["isRestrictedDate","isAfterMaxDate","isBeforeMinDate","compareDatePart","addDays","findAvailableDate","options","targetDate","initialDate","direction","restrictedDateOptions","availableDate","undefined"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,eAAe,EAAEC,OAAO,QAAQ,uBAAuB;AAEhE;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAE,GAAGC,uBAAuB,GAAGJ;IACzE,IAAIK,gBAAgBJ;IACpB,yDAAyD;IACzD,IAAI,CAACP,iBAAiBO,YAAYG,wBAAwB;QACxD,OAAOH;IACT;IAEA,MACEJ,gBAAgBK,aAAaG,mBAAmB,KAChDX,iBAAiBW,eAAeD,0BAChC,CAACT,eAAeU,eAAeD,0BAC/B,CAACR,gBAAgBS,eAAeD,uBAChC;QACAC,gBAAgBP,QAAQO,eAAeF;IACzC;IAEA,IAAIN,gBAAgBK,aAAaG,mBAAmB,KAAK,CAACX,iBAAiBW,eAAeD,wBAAwB;QAChH,OAAOC;IACT;IAEA,OAAOC;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/getDateRangeTypeToUse.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/getDateRangeTypeToUse.ts"],"sourcesContent":["import type { DayOfWeek } from '../constants';\nimport { DateRangeType } from '../constants';\nimport { isContiguous } from './isContiguous';\n/**\n * Return corrected date range type, given `dateRangeType` and list of working days.\n * For non-contiguous working days and working week range type, returns general week range type.\n * For other cases returns input date range type.\n * @param dateRangeType - input type of range\n * @param workWeekDays - list of working days in a week\n */\nexport const getDateRangeTypeToUse = (\n dateRangeType: DateRangeType,\n workWeekDays: DayOfWeek[] | undefined,\n firstDayOfWeek: DayOfWeek,\n): DateRangeType => {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n if (!isContiguous(workWeekDays, true, firstDayOfWeek) || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n};\n"],"names":["DateRangeType","isContiguous","getDateRangeTypeToUse","dateRangeType","workWeekDays","firstDayOfWeek","WorkWeek","length","Week"],"mappings":"AACA,SAASA,aAAa,QAAQ,eAAe;AAC7C,SAASC,YAAY,QAAQ,iBAAiB;AAC9C;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAwB,CACnCC,eACAC,cACAC;IAEA,IAAID,gBAAgBD,kBAAkBH,cAAcM,QAAQ,EAAE;QAC5D,IAAI,CAACL,aAAaG,cAAc,MAAMC,mBAAmBD,aAAaG,MAAM,KAAK,GAAG;YAClF,OAAOP,cAAcQ,IAAI;QAC3B;IACF;IAEA,OAAOL;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/getDayGrid.ts"],"sourcesContent":["import { addDays, compareDates, getDateRangeArray, isInDateRangeArray } from '../dateMath/dateMath';\nimport { DAYS_IN_WEEK } from '../constants';\nimport { Day, DayGridOptions } from './dateGrid.types';\nimport { getDateRangeTypeToUse } from './getDateRangeTypeToUse';\nimport { getBoundedDateRange } from './getBoundedDateRange';\nimport { isRestrictedDate } from './isRestrictedDate';\n\n/**\n * Generates a grid of days, given the `options`.\n * Returns one additional week at the begining from the previous range\n * and one at the end from the future range\n * @param options - parameters to specify date related restrictions for the resulting grid\n */\nexport const getDayGrid = (options: DayGridOptions): Day[][] => {\n const {\n selectedDate,\n dateRangeType,\n firstDayOfWeek,\n today,\n minDate,\n maxDate,\n weeksToShow,\n workWeekDays,\n daysToSelectInDayView,\n restrictedDates,\n markedDays,\n } = options;\n const restrictedDateOptions = { minDate, maxDate, restrictedDates };\n\n const todaysDate = today || new Date();\n\n const navigatedDate = options.navigatedDate ? options.navigatedDate : todaysDate;\n\n let date;\n if (weeksToShow && weeksToShow <= 4) {\n // if showing less than a full month, just use date == navigatedDate\n date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), navigatedDate.getDate());\n } else {\n date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);\n }\n const weeks: Day[][] = [];\n\n // Cycle the date backwards to get to the first day of the week.\n while (date.getDay() !== firstDayOfWeek) {\n date.setDate(date.getDate() - 1);\n }\n\n // add the transition week as last week of previous range\n date = addDays(date, -DAYS_IN_WEEK);\n\n // a flag to indicate whether all days of the week are outside the month\n let isAllDaysOfWeekOutOfMonth = false;\n\n // in work week view if the days aren't contiguous we use week view instead\n const selectedDateRangeType = getDateRangeTypeToUse(dateRangeType, workWeekDays, firstDayOfWeek);\n\n let selectedDates: Date[] = [];\n\n if (selectedDate) {\n selectedDates = getDateRangeArray(\n selectedDate,\n selectedDateRangeType,\n firstDayOfWeek,\n workWeekDays,\n daysToSelectInDayView,\n );\n selectedDates = getBoundedDateRange(selectedDates, minDate, maxDate);\n }\n\n let shouldGetWeeks = true;\n\n for (let weekIndex = 0; shouldGetWeeks; weekIndex++) {\n const week: Day[] = [];\n\n isAllDaysOfWeekOutOfMonth = true;\n\n for (let dayIndex = 0; dayIndex < DAYS_IN_WEEK; dayIndex++) {\n const originalDate = new Date(date.getTime());\n const dayInfo: Day = {\n key: date.toString(),\n date: date.getDate().toString(),\n originalDate,\n isInMonth: date.getMonth() === navigatedDate.getMonth(),\n isToday: compareDates(todaysDate, date),\n isSelected: isInDateRangeArray(date, selectedDates),\n isSingleSelected: selectedDates.length === 1 && compareDates(date, selectedDate),\n isInBounds: !isRestrictedDate(date, restrictedDateOptions),\n isMarked: markedDays?.some((markedDay: Date) => compareDates(originalDate, markedDay)) || false,\n };\n\n week.push(dayInfo);\n\n if (dayInfo.isInMonth) {\n isAllDaysOfWeekOutOfMonth = false;\n }\n\n date.setDate(date.getDate() + 1);\n }\n\n // We append the condition of the loop depending upon the showSixWeeksByDefault prop.\n shouldGetWeeks = weeksToShow ? weekIndex < weeksToShow + 1 : !isAllDaysOfWeekOutOfMonth || weekIndex === 0;\n\n // we don't check shouldGetWeeks before pushing because we want to add one extra week for transition state\n weeks.push(week);\n }\n\n return weeks;\n};\n"],"names":["addDays","compareDates","getDateRangeArray","isInDateRangeArray","DAYS_IN_WEEK","getDateRangeTypeToUse","getBoundedDateRange","isRestrictedDate","getDayGrid","options","selectedDate","dateRangeType","firstDayOfWeek","today","minDate","maxDate","weeksToShow","workWeekDays","daysToSelectInDayView","restrictedDates","markedDays","restrictedDateOptions","todaysDate","Date","navigatedDate","date","getFullYear","getMonth","getDate","weeks","getDay","setDate","isAllDaysOfWeekOutOfMonth","selectedDateRangeType","selectedDates","shouldGetWeeks","weekIndex","week","dayIndex","originalDate","getTime","dayInfo","key","toString","isInMonth","isToday","isSelected","isSingleSelected","length","isInBounds","isMarked","some","markedDay","push"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,uBAAuB;AACpG,SAASC,YAAY,QAAQ,eAAe;AAE5C,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD;;;;;CAKC,GACD,OAAO,MAAMC,aAAa,CAACC;IACzB,MAAM,EACJC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,qBAAqB,EACrBC,eAAe,EACfC,UAAU,EACX,GAAGX;IACJ,MAAMY,wBAAwB;QAAEP;QAASC;QAASI;IAAgB;IAElE,MAAMG,aAAaT,SAAS,IAAIU;IAEhC,MAAMC,gBAAgBf,QAAQe,aAAa,GAAGf,QAAQe,aAAa,GAAGF;IAEtE,IAAIG;IACJ,IAAIT,eAAeA,eAAe,GAAG;QACnC,oEAAoE;QACpES,OAAO,IAAIF,KAAKC,cAAcE,WAAW,IAAIF,cAAcG,QAAQ,IAAIH,cAAcI,OAAO;IAC9F,OAAO;QACLH,OAAO,IAAIF,KAAKC,cAAcE,WAAW,IAAIF,cAAcG,QAAQ,IAAI;IACzE;IACA,MAAME,QAAiB,EAAE;IAEzB,gEAAgE;IAChE,MAAOJ,KAAKK,MAAM,OAAOlB,eAAgB;QACvCa,KAAKM,OAAO,CAACN,KAAKG,OAAO,KAAK;IAChC;IAEA,yDAAyD;IACzDH,OAAOzB,QAAQyB,MAAM,CAACrB;IAEtB,wEAAwE;IACxE,IAAI4B,4BAA4B;IAEhC,2EAA2E;IAC3E,MAAMC,wBAAwB5B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RangeArray } from '../dateMath/dateMath';\nimport { DAYS_IN_WEEK } from '../constants';\nimport type { Day, DayGridOptions } from './dateGrid.types';\nimport { getDateRangeTypeToUse } from './getDateRangeTypeToUse';\nimport { getBoundedDateRange } from './getBoundedDateRange';\nimport { isRestrictedDate } from './isRestrictedDate';\n\n/**\n * Generates a grid of days, given the `options`.\n * Returns one additional week at the begining from the previous range\n * and one at the end from the future range\n * @param options - parameters to specify date related restrictions for the resulting grid\n */\nexport const getDayGrid = (options: DayGridOptions): Day[][] => {\n const {\n selectedDate,\n dateRangeType,\n firstDayOfWeek,\n today,\n minDate,\n maxDate,\n weeksToShow,\n workWeekDays,\n daysToSelectInDayView,\n restrictedDates,\n markedDays,\n } = options;\n const restrictedDateOptions = { minDate, maxDate, restrictedDates };\n\n const todaysDate = today || new Date();\n\n const navigatedDate = options.navigatedDate ? options.navigatedDate : todaysDate;\n\n let date;\n if (weeksToShow && weeksToShow <= 4) {\n // if showing less than a full month, just use date == navigatedDate\n date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), navigatedDate.getDate());\n } else {\n date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);\n }\n const weeks: Day[][] = [];\n\n // Cycle the date backwards to get to the first day of the week.\n while (date.getDay() !== firstDayOfWeek) {\n date.setDate(date.getDate() - 1);\n }\n\n // add the transition week as last week of previous range\n date = addDays(date, -DAYS_IN_WEEK);\n\n // a flag to indicate whether all days of the week are outside the month\n let isAllDaysOfWeekOutOfMonth = false;\n\n // in work week view if the days aren't contiguous we use week view instead\n const selectedDateRangeType = getDateRangeTypeToUse(dateRangeType, workWeekDays, firstDayOfWeek);\n\n let selectedDates: Date[] = [];\n\n if (selectedDate) {\n selectedDates = getDateRangeArray(\n selectedDate,\n selectedDateRangeType,\n firstDayOfWeek,\n workWeekDays,\n daysToSelectInDayView,\n );\n selectedDates = getBoundedDateRange(selectedDates, minDate, maxDate);\n }\n\n let shouldGetWeeks = true;\n\n for (let weekIndex = 0; shouldGetWeeks; weekIndex++) {\n const week: Day[] = [];\n\n isAllDaysOfWeekOutOfMonth = true;\n\n for (let dayIndex = 0; dayIndex < DAYS_IN_WEEK; dayIndex++) {\n const originalDate = new Date(date.getTime());\n const dayInfo: Day = {\n key: date.toString(),\n date: date.getDate().toString(),\n originalDate,\n isInMonth: date.getMonth() === navigatedDate.getMonth(),\n isToday: compareDates(todaysDate, date),\n isSelected: isInDateRangeArray(date, selectedDates),\n isSingleSelected: selectedDates.length === 1 && compareDates(date, selectedDate),\n isInBounds: !isRestrictedDate(date, restrictedDateOptions),\n isMarked: markedDays?.some((markedDay: Date) => compareDates(originalDate, markedDay)) || false,\n };\n\n week.push(dayInfo);\n\n if (dayInfo.isInMonth) {\n isAllDaysOfWeekOutOfMonth = false;\n }\n\n date.setDate(date.getDate() + 1);\n }\n\n // We append the condition of the loop depending upon the showSixWeeksByDefault prop.\n shouldGetWeeks = weeksToShow ? weekIndex < weeksToShow + 1 : !isAllDaysOfWeekOutOfMonth || weekIndex === 0;\n\n // we don't check shouldGetWeeks before pushing because we want to add one extra week for transition state\n weeks.push(week);\n }\n\n return weeks;\n};\n"],"names":["addDays","compareDates","getDateRangeArray","isInDateRangeArray","DAYS_IN_WEEK","getDateRangeTypeToUse","getBoundedDateRange","isRestrictedDate","getDayGrid","options","selectedDate","dateRangeType","firstDayOfWeek","today","minDate","maxDate","weeksToShow","workWeekDays","daysToSelectInDayView","restrictedDates","markedDays","restrictedDateOptions","todaysDate","Date","navigatedDate","date","getFullYear","getMonth","getDate","weeks","getDay","setDate","isAllDaysOfWeekOutOfMonth","selectedDateRangeType","selectedDates","shouldGetWeeks","weekIndex","week","dayIndex","originalDate","getTime","dayInfo","key","toString","isInMonth","isToday","isSelected","isSingleSelected","length","isInBounds","isMarked","some","markedDay","push"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,uBAAuB;AACpG,SAASC,YAAY,QAAQ,eAAe;AAE5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E;QAEtBL,4BAA4B;QAE5B,IAAK,IAAIM,WAAW,GAAGA,WAAWlC,cAAckC,WAAY;YAC1D,MAAMC,eAAe,IAAIhB,KAAKE,KAAKe,OAAO;YAC1C,MAAMC,UAAe;gBACnBC,KAAKjB,KAAKkB,QAAQ;gBAClBlB,MAAMA,KAAKG,OAAO,GAAGe,QAAQ;gBAC7BJ;gBACAK,WAAWnB,KAAKE,QAAQ,OAAOH,cAAcG,QAAQ;gBACrDkB,SAAS5C,aAAaqB,YAAYG;gBAClCqB,YAAY3C,mBAAmBsB,MAAMS;gBACrCa,kBAAkBb,cAAcc,MAAM,KAAK,KAAK/C,aAAawB,MAAMf;gBACnEuC,YAAY,CAAC1C,iBAAiBkB,MAAMJ;gBACpC6B,UAAU9B,CAAAA,uBAAAA,iCAAAA,WAAY+B,IAAI,CAAC,CAACC,YAAoBnD,aAAasC,cAAca,gBAAe;YAC5F;YAEAf,KAAKgB,IAAI,CAACZ;YAEV,IAAIA,QAAQG,SAAS,EAAE;gBACrBZ,4BAA4B;YAC9B;YAEAP,KAAKM,OAAO,CAACN,KAAKG,OAAO,KAAK;QAChC;QAEA,qFAAqF;QACrFO,iBAAiBnB,cAAcoB,YAAYpB,cAAc,IAAI,CAACgB,6BAA6BI,cAAc;QAEzG,0GAA0G;QAC1GP,MAAMwB,IAAI,CAAChB;IACb;IAEA,OAAOR;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/isAfterMaxDate.ts"],"sourcesContent":["import { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens later than max date\n * @param date - date to check\n * @param options - object with max date to check against\n */\nexport const isAfterMaxDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { maxDate } = options;\n return maxDate ? compareDatePart(date, maxDate) >= 1 : false;\n};\n"],"names":["compareDatePart","isAfterMaxDate","date","options","maxDate"],"mappings":"AACA,SAASA,eAAe,QAAQ,uBAAuB;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,iBAAiB,CAACC,MAAYC;IACzC,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,OAAOC,UAAUJ,gBAAgBE,MAAME,YAAY,IAAI;AACzD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/isAfterMaxDate.ts"],"sourcesContent":["import type { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens later than max date\n * @param date - date to check\n * @param options - object with max date to check against\n */\nexport const isAfterMaxDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { maxDate } = options;\n return maxDate ? compareDatePart(date, maxDate) >= 1 : false;\n};\n"],"names":["compareDatePart","isAfterMaxDate","date","options","maxDate"],"mappings":"AACA,SAASA,eAAe,QAAQ,uBAAuB;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,iBAAiB,CAACC,MAAYC;IACzC,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,OAAOC,UAAUJ,gBAAgBE,MAAME,YAAY,IAAI;AACzD,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/isBeforeMinDate.ts"],"sourcesContent":["import { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens earlier than min date\n * @param date - date to check\n * @param options - object with min date to check against\n */\nexport const isBeforeMinDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { minDate } = options;\n return minDate ? compareDatePart(minDate, date) >= 1 : false;\n};\n"],"names":["compareDatePart","isBeforeMinDate","date","options","minDate"],"mappings":"AACA,SAASA,eAAe,QAAQ,uBAAuB;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,kBAAkB,CAACC,MAAYC;IAC1C,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,OAAOC,UAAUJ,gBAAgBI,SAASF,SAAS,IAAI;AACzD,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/isBeforeMinDate.ts"],"sourcesContent":["import type { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDatePart } from '../dateMath/dateMath';\n\n/**\n * Checks if `date` happens earlier than min date\n * @param date - date to check\n * @param options - object with min date to check against\n */\nexport const isBeforeMinDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { minDate } = options;\n return minDate ? compareDatePart(minDate, date) >= 1 : false;\n};\n"],"names":["compareDatePart","isBeforeMinDate","date","options","minDate"],"mappings":"AACA,SAASA,eAAe,QAAQ,uBAAuB;AAEvD;;;;CAIC,GACD,OAAO,MAAMC,kBAAkB,CAACC,MAAYC;IAC1C,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,OAAOC,UAAUJ,gBAAgBI,SAASF,SAAS,IAAI;AACzD,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/isContiguous.ts"],"sourcesContent":["import { DayOfWeek } from '../constants';\n\n/**\n * Returns whether provided week days are contiguous.\n * @param days - list of days in a week\n * @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not\n * @param firstDayOfWeek - decides which day of week is the first one in the order.\n */\nexport const isContiguous = (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek): boolean => {\n const daySet = new Set(days);\n let amountOfNoNeighbors = 0;\n for (const day of days) {\n const nextDay = (day + 1) % 7;\n if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {\n amountOfNoNeighbors++;\n }\n }\n\n // In case the full week is provided, then each day has a neighbor\n //, otherwise the last day does not have a neighbor.\n return amountOfNoNeighbors < 2;\n};\n"],"names":["isContiguous","days","isSingleWeek","firstDayOfWeek","daySet","Set","amountOfNoNeighbors","day","nextDay","has"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,eAAe,CAACC,MAAmBC,cAAuBC;IACrE,MAAMC,SAAS,IAAIC,IAAIJ;IACvB,IAAIK,sBAAsB;IAC1B,KAAK,MAAMC,OAAON,KAAM;QACtB,MAAMO,UAAU,AAACD,CAAAA,MAAM,CAAA,IAAK;QAC5B,IAAI,CAAEH,CAAAA,OAAOK,GAAG,CAACD,YAAa,CAAA,CAACN,gBAAgBC,mBAAmBK,OAAM,CAAC,GAAI;YAC3EF;QACF;IACF;IAEA,kEAAkE;IAClE,oDAAoD;IACpD,OAAOA,sBAAsB;AAC/B,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/isContiguous.ts"],"sourcesContent":["import type { DayOfWeek } from '../constants';\n\n/**\n * Returns whether provided week days are contiguous.\n * @param days - list of days in a week\n * @param isSingleWeek - decides whether the contiguous logic applies across week boundaries or not\n * @param firstDayOfWeek - decides which day of week is the first one in the order.\n */\nexport const isContiguous = (days: DayOfWeek[], isSingleWeek: boolean, firstDayOfWeek: DayOfWeek): boolean => {\n const daySet = new Set(days);\n let amountOfNoNeighbors = 0;\n for (const day of days) {\n const nextDay = (day + 1) % 7;\n if (!(daySet.has(nextDay) && (!isSingleWeek || firstDayOfWeek !== nextDay))) {\n amountOfNoNeighbors++;\n }\n }\n\n // In case the full week is provided, then each day has a neighbor\n //, otherwise the last day does not have a neighbor.\n return amountOfNoNeighbors < 2;\n};\n"],"names":["isContiguous","days","isSingleWeek","firstDayOfWeek","daySet","Set","amountOfNoNeighbors","day","nextDay","has"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,MAAMA,eAAe,CAACC,MAAmBC,cAAuBC;IACrE,MAAMC,SAAS,IAAIC,IAAIJ;IACvB,IAAIK,sBAAsB;IAC1B,KAAK,MAAMC,OAAON,KAAM;QACtB,MAAMO,UAAU,AAACD,CAAAA,MAAM,CAAA,IAAK;QAC5B,IAAI,CAAEH,CAAAA,OAAOK,GAAG,CAACD,YAAa,CAAA,CAACN,gBAAgBC,mBAAmBK,OAAM,CAAC,GAAI;YAC3EF;QACF;IACF;IAEA,kEAAkE;IAClE,oDAAoD;IACpD,OAAOA,sBAAsB;AAC/B,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/dateGrid/isRestrictedDate.ts"],"sourcesContent":["import { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDates } from '../dateMath/dateMath';\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\n/**\n * Checks if `date` falls into the restricted `options`\n * @param date - date to check\n * @param options - restriction options (min date, max date and list of restricted dates)\n */\nexport const isRestrictedDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { restrictedDates, minDate, maxDate } = options;\n if (!restrictedDates && !minDate && !maxDate) {\n return false;\n }\n const inRestrictedDates = restrictedDates && restrictedDates.some((rd: Date) => compareDates(rd, date));\n return inRestrictedDates || isBeforeMinDate(date, options) || isAfterMaxDate(date, options);\n};\n"],"names":["compareDates","isBeforeMinDate","isAfterMaxDate","isRestrictedDate","date","options","restrictedDates","minDate","maxDate","inRestrictedDates","some","rd"],"mappings":"AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,cAAc,QAAQ,mBAAmB;AAElD;;;;CAIC,GACD,OAAO,MAAMC,mBAAmB,CAACC,MAAYC;IAC3C,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGH;IAC9C,IAAI,CAACC,mBAAmB,CAACC,WAAW,CAACC,SAAS;QAC5C,OAAO;IACT;IACA,MAAMC,oBAAoBH,mBAAmBA,gBAAgBI,IAAI,CAAC,CAACC,KAAaX,aAAaW,IAAIP;IACjG,OAAOK,qBAAqBR,gBAAgBG,MAAMC,YAAYH,eAAeE,MAAMC;AACrF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/utils/dateGrid/isRestrictedDate.ts"],"sourcesContent":["import type { RestrictedDatesOptions } from './dateGrid.types';\nimport { compareDates } from '../dateMath/dateMath';\nimport { isBeforeMinDate } from './isBeforeMinDate';\nimport { isAfterMaxDate } from './isAfterMaxDate';\n\n/**\n * Checks if `date` falls into the restricted `options`\n * @param date - date to check\n * @param options - restriction options (min date, max date and list of restricted dates)\n */\nexport const isRestrictedDate = (date: Date, options: RestrictedDatesOptions): boolean => {\n const { restrictedDates, minDate, maxDate } = options;\n if (!restrictedDates && !minDate && !maxDate) {\n return false;\n }\n const inRestrictedDates = restrictedDates && restrictedDates.some((rd: Date) => compareDates(rd, date));\n return inRestrictedDates || isBeforeMinDate(date, options) || isAfterMaxDate(date, options);\n};\n"],"names":["compareDates","isBeforeMinDate","isAfterMaxDate","isRestrictedDate","date","options","restrictedDates","minDate","maxDate","inRestrictedDates","some","rd"],"mappings":"AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,cAAc,QAAQ,mBAAmB;AAElD;;;;CAIC,GACD,OAAO,MAAMC,mBAAmB,CAACC,MAAYC;IAC3C,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGH;IAC9C,IAAI,CAACC,mBAAmB,CAACC,WAAW,CAACC,SAAS;QAC5C,OAAO;IACT;IACA,MAAMC,oBAAoBH,mBAAmBA,gBAAgBI,IAAI,CAAC,CAACC,KAAaX,aAAaW,IAAIP;IACjG,OAAOK,qBAAqBR,gBAAgBG,MAAMC,YAAYH,eAAeE,MAAMC;AACrF,EAAE"}
|
|
@@ -8,8 +8,6 @@ Object.defineProperty(exports, "AnimationDirection", {
|
|
|
8
8
|
return AnimationDirection;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
11
|
var AnimationDirection = /*#__PURE__*/ function(AnimationDirection) {
|
|
14
12
|
/**
|
|
15
13
|
* Grid will transition out and in horizontally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Calendar/Calendar.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { CalendarStrings, DateFormatting, DateRangeType, DayOfWeek, FirstWeekOfYear } from '../../utils';\nimport type { CalendarDayProps } from '../CalendarDay/CalendarDay.types';\nimport type { CalendarMonthProps } from '../CalendarMonth/CalendarMonth.types';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendar {\n /** Sets focus to the selected date. */\n focus: () => void;\n}\n\nexport interface CalendarProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * Optional callback to access the ICalendar interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendar | null>;\n\n /**\n * Customized props for the calendar day\n */\n calendarDayProps?: Partial<CalendarDayProps>;\n\n /**\n * Customized props for the calendar month\n */\n calendarMonthProps?: Partial<CalendarMonthProps>;\n\n /**\n * Optional class name to add to the root element.\n */\n className?: string;\n\n /**\n * Callback for when a date is selected\n * @param date - The date the user selected\n * @param selectedDateRangeArray - The resultant list of dates that are selected based on the date range type set\n * for the component.\n */\n onSelectDate?: (date: Date, selectedDateRangeArray?: Date[]) => void;\n\n /**\n * Callback for when calendar is closed\n */\n onDismiss?: () => void;\n\n /**\n * ID for the calendar\n */\n id?: string;\n\n /**\n * Default value of the Calendar, if any\n */\n value?: Date;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n * @default DateRangeType.Day\n */\n dateRangeType?: DateRangeType;\n\n /**\n * The first day of the week for your locale.\n * @default DayOfWeek.Sunday\n */\n firstDayOfWeek?: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start.\n * @default FirstWeekOfYear.FirstDay\n */\n firstWeekOfYear?: FirstWeekOfYear;\n\n /**\n * Whether the month picker is shown beside the day picker or hidden.\n * @default true\n */\n isMonthPickerVisible?: boolean;\n\n /**\n * Whether the day picker is shown beside the month picker or hidden.\n * @default true\n */\n isDayPickerVisible?: boolean;\n\n /**\n * Show month picker on top of date picker when visible.\n * @default false\n */\n showMonthPickerAsOverlay?: boolean;\n\n /**\n * Whether the \"Go to today\" link should be shown or not\n */\n showGoToToday?: boolean;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings?: CalendarStrings;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter?: DateFormatting;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * Whether the calendar should show 6 weeks by default.\n * @default false\n */\n showSixWeeksByDefault?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is `WorkWeek`.\n * If `dateRangeType` is not `WorkWeek` this property does nothing.\n * @default [Monday,Tuesday,Wednesday,Thursday,Friday]\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Whether the month picker should highlight the current month\n * @default false\n */\n highlightCurrentMonth?: boolean;\n\n /**\n * Whether the month picker should highlight the selected month\n * @default false\n */\n highlightSelectedMonth?: boolean;\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarStyleProps {\n /**\n * Custom CSS class for the calendar.\n */\n className?: string;\n\n /**\n * Whether the month picker is visible\n */\n isMonthPickerVisible?: boolean;\n\n /**\n * Whether the day picker is visible\n */\n isDayPickerVisible?: boolean;\n\n /**\n * Whether only month picker is shown\n */\n monthPickerOnly?: boolean;\n\n /**\n * Whether the month picker is overlaid on the day picker\n */\n showMonthPickerAsOverlay?: boolean;\n\n /**\n * @deprecated Use `overlaidWithButton`\n */\n overlayedWithButton?: boolean;\n\n /**\n * Whether the month and day picker are overlaid and the 'go to today' button is shown\n */\n overlaidWithButton?: boolean;\n\n /**\n * Whether the go to today button is shown\n */\n showGoToToday?: boolean;\n\n /**\n * Whether the week numbers are shown\n */\n showWeekNumbers?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarStyles {\n /**\n * Style for the root element.\n */\n root: string;\n\n divider: string;\n\n goTodayButton: string;\n\n monthPickerWrapper: string;\n\n liveRegion: string;\n}\n\nexport enum AnimationDirection {\n /**\n * Grid will transition out and in horizontally\n */\n Horizontal,\n\n /**\n * Grid will transition out and in vertically\n */\n Vertical,\n}\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Calendar/Calendar.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { CalendarStrings, DateFormatting, DateRangeType, DayOfWeek, FirstWeekOfYear } from '../../utils';\nimport type { CalendarDayProps } from '../CalendarDay/CalendarDay.types';\nimport type { CalendarMonthProps } from '../CalendarMonth/CalendarMonth.types';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendar {\n /** Sets focus to the selected date. */\n focus: () => void;\n}\n\nexport interface CalendarProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * Optional callback to access the ICalendar interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendar | null>;\n\n /**\n * Customized props for the calendar day\n */\n calendarDayProps?: Partial<CalendarDayProps>;\n\n /**\n * Customized props for the calendar month\n */\n calendarMonthProps?: Partial<CalendarMonthProps>;\n\n /**\n * Optional class name to add to the root element.\n */\n className?: string;\n\n /**\n * Callback for when a date is selected\n * @param date - The date the user selected\n * @param selectedDateRangeArray - The resultant list of dates that are selected based on the date range type set\n * for the component.\n */\n onSelectDate?: (date: Date, selectedDateRangeArray?: Date[]) => void;\n\n /**\n * Callback for when calendar is closed\n */\n onDismiss?: () => void;\n\n /**\n * ID for the calendar\n */\n id?: string;\n\n /**\n * Default value of the Calendar, if any\n */\n value?: Date;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n * @default DateRangeType.Day\n */\n dateRangeType?: DateRangeType;\n\n /**\n * The first day of the week for your locale.\n * @default DayOfWeek.Sunday\n */\n firstDayOfWeek?: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start.\n * @default FirstWeekOfYear.FirstDay\n */\n firstWeekOfYear?: FirstWeekOfYear;\n\n /**\n * Whether the month picker is shown beside the day picker or hidden.\n * @default true\n */\n isMonthPickerVisible?: boolean;\n\n /**\n * Whether the day picker is shown beside the month picker or hidden.\n * @default true\n */\n isDayPickerVisible?: boolean;\n\n /**\n * Show month picker on top of date picker when visible.\n * @default false\n */\n showMonthPickerAsOverlay?: boolean;\n\n /**\n * Whether the \"Go to today\" link should be shown or not\n */\n showGoToToday?: boolean;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings?: CalendarStrings;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter?: DateFormatting;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * Whether the calendar should show 6 weeks by default.\n * @default false\n */\n showSixWeeksByDefault?: boolean;\n\n /**\n * The days that are selectable when `dateRangeType` is `WorkWeek`.\n * If `dateRangeType` is not `WorkWeek` this property does nothing.\n * @default [Monday,Tuesday,Wednesday,Thursday,Friday]\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Whether the month picker should highlight the current month\n * @default false\n */\n highlightCurrentMonth?: boolean;\n\n /**\n * Whether the month picker should highlight the selected month\n * @default false\n */\n highlightSelectedMonth?: boolean;\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarStyleProps {\n /**\n * Custom CSS class for the calendar.\n */\n className?: string;\n\n /**\n * Whether the month picker is visible\n */\n isMonthPickerVisible?: boolean;\n\n /**\n * Whether the day picker is visible\n */\n isDayPickerVisible?: boolean;\n\n /**\n * Whether only month picker is shown\n */\n monthPickerOnly?: boolean;\n\n /**\n * Whether the month picker is overlaid on the day picker\n */\n showMonthPickerAsOverlay?: boolean;\n\n /**\n * @deprecated Use `overlaidWithButton`\n */\n overlayedWithButton?: boolean;\n\n /**\n * Whether the month and day picker are overlaid and the 'go to today' button is shown\n */\n overlaidWithButton?: boolean;\n\n /**\n * Whether the go to today button is shown\n */\n showGoToToday?: boolean;\n\n /**\n * Whether the week numbers are shown\n */\n showWeekNumbers?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarStyles {\n /**\n * Style for the root element.\n */\n root: string;\n\n divider: string;\n\n goTodayButton: string;\n\n monthPickerWrapper: string;\n\n liveRegion: string;\n}\n\nexport enum AnimationDirection {\n /**\n * Grid will transition out and in horizontally\n */\n Horizontal,\n\n /**\n * Grid will transition out and in vertically\n */\n Vertical,\n}\n"],"names":["AnimationDirection"],"mappings":";;;;+BAgPYA;;;;;;AAAL,yBAAKA,WAAAA,GAAAA,SAAAA,kBAAAA;IACV;;GAEC,GAAA,kBAAA,CAAA,kBAAA,CAAA,aAAA,GAAA,EAAA,GAAA;IAGD;;GAEC,GAAA,kBAAA,CAAA,kBAAA,CAAA,WAAA,GAAA,EAAA,GAAA;WARSA;MAUX"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/ "use strict";
|
|
2
4
|
Object.defineProperty(exports, "__esModule", {
|
|
3
5
|
value: true
|
|
4
6
|
});
|
|
5
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
6
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarDay/CalendarDay.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { CalendarStrings, DateFormatting } from '../../utils';\nimport type { CalendarDayGridProps, CalendarDayGridStyleProps } from '../CalendarDayGrid/CalendarDayGrid.types';\nimport type { CalendarNavigationIcons } from '../Calendar/calendarNavigationIcons';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarDay {\n focus(): void;\n}\n\nexport interface CalendarDayProps extends CalendarDayGridProps {\n /**\n * Optional callback to access the ICalendarDay interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarDay | null>;\n\n /**\n * Additional CSS class(es) to apply to the CalendarDay.\n */\n className?: string;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings: CalendarStrings;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * Callback issued when a date in the calendar is navigated\n * @param date - The date that is navigated to\n * @param focusOnNavigatedDay - Whether to set the focus to the navigated date.\n */\n onNavigateDate: (date: Date, focusOnNavigatedDay: boolean) => void;\n\n /**\n * Callback issued when calendar day is closed\n */\n onDismiss?: () => void;\n\n /**\n * Callback function when the header is selected\n */\n onHeaderSelect?: () => void;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter: DateFormatting;\n\n /**\n * Whether the calendar should show 6 weeks by default.\n * @default false\n */\n showSixWeeksByDefault?: boolean;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n\n /**\n * Custom navigation icons.\n */\n navigationIcons: CalendarNavigationIcons;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayStyleProps extends CalendarDayGridStyleProps {\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * Whether the header is clickable\n */\n headerIsClickable?: boolean;\n\n /**\n * Whether week numbers are being shown\n */\n showWeekNumbers?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayStyles {\n /**\n * Style for the root element.\n */\n root: string;\n\n /**\n * The style for the header button and forward/back navigation button container\n */\n header: string;\n\n /**\n * The style for the title text inside the header\n */\n monthAndYear: string;\n\n /**\n * The style for the wrapper around forward/back/close buttons\n */\n monthComponents: string;\n\n /**\n * The style for the forward/back/close buttons\n */\n headerIconButton: string;\n\n /**\n * The style to apply for disabled elements\n */\n disabledStyle: string;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarDay/CalendarDay.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { CalendarStrings, DateFormatting } from '../../utils';\nimport type { CalendarDayGridProps, CalendarDayGridStyleProps } from '../CalendarDayGrid/CalendarDayGrid.types';\nimport type { CalendarNavigationIcons } from '../Calendar/calendarNavigationIcons';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarDay {\n focus(): void;\n}\n\nexport interface CalendarDayProps extends CalendarDayGridProps {\n /**\n * Optional callback to access the ICalendarDay interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarDay | null>;\n\n /**\n * Additional CSS class(es) to apply to the CalendarDay.\n */\n className?: string;\n\n /**\n * Localized strings to use in the Calendar\n */\n strings: CalendarStrings;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * Callback issued when a date in the calendar is navigated\n * @param date - The date that is navigated to\n * @param focusOnNavigatedDay - Whether to set the focus to the navigated date.\n */\n onNavigateDate: (date: Date, focusOnNavigatedDay: boolean) => void;\n\n /**\n * Callback issued when calendar day is closed\n */\n onDismiss?: () => void;\n\n /**\n * Callback function when the header is selected\n */\n onHeaderSelect?: () => void;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter: DateFormatting;\n\n /**\n * Whether the calendar should show 6 weeks by default.\n * @default false\n */\n showSixWeeksByDefault?: boolean;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n\n /**\n * Custom navigation icons.\n */\n navigationIcons: CalendarNavigationIcons;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayStyleProps extends CalendarDayGridStyleProps {\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * Whether the header is clickable\n */\n headerIsClickable?: boolean;\n\n /**\n * Whether week numbers are being shown\n */\n showWeekNumbers?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayStyles {\n /**\n * Style for the root element.\n */\n root: string;\n\n /**\n * The style for the header button and forward/back navigation button container\n */\n header: string;\n\n /**\n * The style for the title text inside the header\n */\n monthAndYear: string;\n\n /**\n * The style for the wrapper around forward/back/close buttons\n */\n monthComponents: string;\n\n /**\n * The style for the forward/back/close buttons\n */\n headerIconButton: string;\n\n /**\n * The style to apply for disabled elements\n */\n disabledStyle: string;\n}\n"],"names":[],"mappings":"AAuHA;;CAEC,GACD,WA8BC"}
|
|
@@ -40,8 +40,10 @@ function useAnimateBackwards(weeks) {
|
|
|
40
40
|
previousNavigatedDateRef.current = weeks[0][0].originalDate;
|
|
41
41
|
});
|
|
42
42
|
const previousNavigatedDate = previousNavigatedDateRef.current;
|
|
43
|
+
// eslint-disable-next-line react-hooks/refs
|
|
43
44
|
if (!previousNavigatedDate || previousNavigatedDate.getTime() === weeks[0][0].originalDate.getTime()) {
|
|
44
45
|
return undefined;
|
|
46
|
+
// eslint-disable-next-line react-hooks/refs
|
|
45
47
|
} else if (previousNavigatedDate <= weeks[0][0].originalDate) {
|
|
46
48
|
return false;
|
|
47
49
|
} else {
|
|
@@ -59,6 +61,7 @@ const CalendarDayGrid = (props)=>{
|
|
|
59
61
|
maxDate,
|
|
60
62
|
restrictedDates
|
|
61
63
|
};
|
|
64
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
62
65
|
let dateRange = (0, _utils.getDateRangeArray)(selectedDate, dateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);
|
|
63
66
|
dateRange = (0, _utils.getBoundedDateRange)(dateRange, minDate, maxDate);
|
|
64
67
|
dateRange = dateRange.filter((d)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarDayGrid/CalendarDayGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { useId } from '@fluentui/react-utilities';\nimport { getBoundedDateRange, getDateRangeArray, isRestrictedDate, DateRangeType, DayOfWeek } from '../../utils';\nimport { useCalendarDayGridStyles_unstable } from './useCalendarDayGridStyles.styles';\nimport { CalendarMonthHeaderRow } from './CalendarMonthHeaderRow';\nimport { CalendarGridRow } from './CalendarGridRow';\nimport { useWeeks } from './useWeeks';\nimport { useWeekCornerStyles, WeekCorners } from './useWeekCornerStyles.styles';\nimport { mergeClasses } from '@griffel/react';\nimport type { Day } from '../../utils';\nimport type { CalendarDayGridProps } from './CalendarDayGrid.types';\n\nexport interface DayInfo extends Day {\n onSelected: () => void;\n setRef(element: HTMLElement | null): void;\n}\n\nfunction useDayRefs() {\n const daysRef = React.useRef<Record<string, HTMLElement>>({});\n\n const getSetRefCallback = (dayKey: string) => (element: HTMLElement | null) => {\n if (element === null) {\n delete daysRef.current[dayKey];\n } else {\n daysRef.current[dayKey] = element;\n }\n };\n\n return [daysRef, getSetRefCallback] as const;\n}\n\nfunction useAnimateBackwards(weeks: DayInfo[][]): boolean | undefined {\n const previousNavigatedDateRef = React.useRef<Date | undefined>(undefined);\n React.useEffect(() => {\n previousNavigatedDateRef.current = weeks[0][0].originalDate;\n });\n const previousNavigatedDate = previousNavigatedDateRef.current;\n\n if (!previousNavigatedDate || previousNavigatedDate.getTime() === weeks[0][0].originalDate.getTime()) {\n return undefined;\n } else if (previousNavigatedDate <= weeks[0][0].originalDate) {\n return false;\n } else {\n return true;\n }\n}\n\nexport const CalendarDayGrid: React.FunctionComponent<CalendarDayGridProps> = props => {\n const navigatedDayRef = React.useRef<HTMLTableCellElement>(\n null,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLTableCellElement | null>;\n\n const activeDescendantId = useId();\n\n const onSelectDate = (selectedDate: Date): void => {\n const { firstDayOfWeek, minDate, maxDate, workWeekDays, daysToSelectInDayView, restrictedDates } = props;\n const restrictedDatesOptions = { minDate, maxDate, restrictedDates };\n\n let dateRange = getDateRangeArray(selectedDate, dateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);\n dateRange = getBoundedDateRange(dateRange, minDate, maxDate);\n\n dateRange = dateRange.filter((d: Date) => {\n return !isRestrictedDate(d, restrictedDatesOptions);\n });\n\n props.onSelectDate?.(selectedDate, dateRange);\n props.onNavigateDate?.(selectedDate, true);\n };\n\n const [daysRef, getSetRefCallback] = useDayRefs();\n\n const weeks = useWeeks(props, onSelectDate, getSetRefCallback);\n const animateBackwards = useAnimateBackwards(weeks);\n const [getWeekCornerStyles, calculateRoundedStyles] = useWeekCornerStyles(props);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n focus() {\n navigatedDayRef.current?.focus?.();\n },\n }),\n [],\n );\n\n /**\n *\n * Section for setting hover/pressed styles. Because we want arbitrary blobs of days to be selectable, to support\n * highlighting every day in the month for month view, css :hover style isn't enough, so we need mouse callbacks\n * to set classnames on all relevant child refs to apply the styling\n *\n */\n const getDayInfosInRangeOfDay = (dayToCompare: DayInfo): DayInfo[] => {\n // The hover state looks weird with non-contiguous days in work week view. In work week, show week hover state\n const dateRangeHoverType = getDateRangeTypeToUse(props.dateRangeType, props.workWeekDays);\n\n // gets all the dates for the given date range type that are in the same date range as the given day\n const dateRange = getDateRangeArray(\n dayToCompare.originalDate,\n dateRangeHoverType,\n props.firstDayOfWeek,\n props.workWeekDays,\n props.daysToSelectInDayView,\n ).map((date: Date) => date.getTime());\n\n // gets all the day refs for the given dates\n const dayInfosInRange = weeks.reduce((accumulatedValue: DayInfo[], currentWeek: DayInfo[]) => {\n return accumulatedValue.concat(\n currentWeek.filter((weekDay: DayInfo) => dateRange.indexOf(weekDay.originalDate.getTime()) !== -1),\n );\n }, []);\n\n return dayInfosInRange;\n };\n\n const getRefsFromDayInfos = (dayInfosInRange: DayInfo[]): (HTMLElement | null)[] => {\n let dayRefs: (HTMLElement | null)[] = [];\n dayRefs = dayInfosInRange.map((dayInfo: DayInfo) => daysRef.current[dayInfo.key]);\n\n return dayRefs;\n };\n\n const {\n gridLabel,\n dateRangeType,\n showWeekNumbers,\n labelledBy,\n lightenDaysOutsideNavigatedMonth,\n animationDirection,\n } = props;\n\n const classNames = useCalendarDayGridStyles_unstable({\n animateBackwards,\n animationDirection,\n dateRangeType,\n lightenDaysOutsideNavigatedMonth:\n lightenDaysOutsideNavigatedMonth === undefined ? true : lightenDaysOutsideNavigatedMonth,\n showWeekNumbers,\n });\n\n // When the month is highlighted get the corner dates so that styles can be added to them\n const weekCorners: WeekCorners = getWeekCornerStyles(weeks!);\n const partialWeekProps = {\n weeks,\n navigatedDayRef,\n calculateRoundedStyles,\n activeDescendantId,\n classNames,\n weekCorners,\n getDayInfosInRangeOfDay,\n getRefsFromDayInfos,\n } as const;\n\n const arrowNavigationAttributes = useArrowNavigationGroup({ axis: 'grid-linear' });\n\n return (\n <table\n className={mergeClasses(classNames.table, props.className)}\n aria-multiselectable=\"false\"\n aria-label={gridLabel}\n aria-labelledby={labelledBy}\n aria-activedescendant={activeDescendantId}\n role=\"grid\"\n {...arrowNavigationAttributes}\n >\n <tbody>\n <CalendarMonthHeaderRow {...props} classNames={classNames} weeks={weeks} />\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n week={weeks[0]}\n weekIndex={-1}\n rowClassName={classNames.firstTransitionWeek}\n aria-role=\"presentation\"\n ariaHidden={true}\n />\n {weeks!.slice(1, weeks!.length - 1).map((week: DayInfo[], weekIndex: number) => (\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n key={weekIndex}\n week={week}\n weekIndex={weekIndex}\n rowClassName={classNames.weekRow}\n />\n ))}\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n week={weeks![weeks!.length - 1]}\n weekIndex={-2}\n rowClassName={classNames.lastTransitionWeek}\n aria-role=\"presentation\"\n ariaHidden={true}\n />\n </tbody>\n </table>\n );\n};\nCalendarDayGrid.displayName = 'CalendarDayGrid';\n\n/**\n * When given work week, if the days are non-contiguous, the hover states look really weird. So for non-contiguous\n * work weeks, we'll just show week view instead.\n */\nfunction getDateRangeTypeToUse(dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined): DateRangeType {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n const sortedWWDays = workWeekDays.slice().sort();\n let isContiguous = true;\n for (let i = 1; i < sortedWWDays.length; i++) {\n if (sortedWWDays[i] !== sortedWWDays[i - 1] + 1) {\n isContiguous = false;\n break;\n }\n }\n\n if (!isContiguous || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n}\n"],"names":["React","useArrowNavigationGroup","useId","getBoundedDateRange","getDateRangeArray","isRestrictedDate","DateRangeType","useCalendarDayGridStyles_unstable","CalendarMonthHeaderRow","CalendarGridRow","useWeeks","useWeekCornerStyles","mergeClasses","useDayRefs","daysRef","useRef","getSetRefCallback","dayKey","element","current","useAnimateBackwards","weeks","previousNavigatedDateRef","undefined","useEffect","originalDate","previousNavigatedDate","getTime","CalendarDayGrid","props","navigatedDayRef","activeDescendantId","onSelectDate","selectedDate","firstDayOfWeek","minDate","maxDate","workWeekDays","daysToSelectInDayView","restrictedDates","restrictedDatesOptions","dateRange","dateRangeType","filter","d","onNavigateDate","animateBackwards","getWeekCornerStyles","calculateRoundedStyles","useImperativeHandle","componentRef","focus","getDayInfosInRangeOfDay","dayToCompare","dateRangeHoverType","getDateRangeTypeToUse","map","date","dayInfosInRange","reduce","accumulatedValue","currentWeek","concat","weekDay","indexOf","getRefsFromDayInfos","dayRefs","dayInfo","key","gridLabel","showWeekNumbers","labelledBy","lightenDaysOutsideNavigatedMonth","animationDirection","classNames","weekCorners","partialWeekProps","arrowNavigationAttributes","axis","table","className","aria-multiselectable","aria-label","aria-labelledby","aria-activedescendant","role","tbody","week","weekIndex","rowClassName","firstTransitionWeek","aria-role","ariaHidden","slice","length","weekRow","lastTransitionWeek","displayName","WorkWeek","sortedWWDays","sort","isContiguous","i","Week"],"mappings":"AAAA;;;;;+BAkDa4B;;;;;;;iEAhDU,QAAQ;8BACS,0BAA0B;gCAC5C,4BAA4B;uBACiD,cAAc;gDAC/D,oCAAoC;wCAC/C,2BAA2B;iCAClC,oBAAoB;0BAC3B,aAAa;2CACW,+BAA+B;wBACnD,iBAAiB;AAS9C,SAASf;IACP,MAAMC,UAAUd,OAAMe,MAAM,CAA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vE,MAAOwE,KAAK,CAAC,GAAGxE,MAAOyE,MAAM,GAAG,GAAGtC,GAAG,CAAC,CAAC+B,MAAiBC,YAAAA,WAAAA,GACxD,OAAA,aAAA,CAAC/E,gCAAAA,EAAAA;YACE,GAAGoB,KAAK;YACR,GAAG+C,gBAAgB;YACpBR,KAAKoB;YACLD,MAAMA;YACNC,WAAWA;YACXC,cAAcf,WAAWqB,OAAO;2BAGpC,OAAA,aAAA,CAACtF,gCAAAA,EAAAA;QACE,GAAGoB,KAAK;QACR,GAAG+C,gBAAgB;QACpBW,MAAMlE,KAAM,CAACA,MAAOyE,MAAM,GAAG,EAAE;QAC/BN,WAAW,CAAC;QACZC,cAAcf,WAAWsB,kBAAkB;QAC3CL,aAAU;QACVC,YAAY;;AAKtB,EAAE;AACFhE,gBAAgBqE,WAAW,GAAG;AAE9B;;;CAGC,GACD,SAAS1C,sBAAsBb,aAA4B,EAAEL,YAAqC;IAChG,IAAIA,gBAAgBK,kBAAkBpC,oBAAAA,CAAc4F,QAAQ,EAAE;QAC5D,MAAMC,eAAe9D,aAAawD,KAAK,GAAGO,IAAI;QAC9C,IAAIC,eAAe;QACnB,IAAK,IAAIC,IAAI,GAAGA,IAAIH,aAAaL,MAAM,EAAEQ,IAAK;YAC5C,IAAIH,YAAY,CAACG,EAAE,KAAKH,YAAY,CAACG,IAAI,EAAE,GAAG,GAAG;gBAC/CD,eAAe;gBACf;YACF;QACF;QAEA,IAAI,CAACA,gBAAgBhE,aAAayD,MAAM,KAAK,GAAG;YAC9C,OAAOxF,oBAAAA,CAAciG,IAAI;QAC3B;IACF;IAEA,OAAO7D;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarDayGrid/CalendarDayGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { useId } from '@fluentui/react-utilities';\nimport { getBoundedDateRange, getDateRangeArray, isRestrictedDate, DateRangeType } from '../../utils';\nimport { useCalendarDayGridStyles_unstable } from './useCalendarDayGridStyles.styles';\nimport { CalendarMonthHeaderRow } from './CalendarMonthHeaderRow';\nimport { CalendarGridRow } from './CalendarGridRow';\nimport { useWeeks } from './useWeeks';\nimport type { WeekCorners } from './useWeekCornerStyles.styles';\nimport { useWeekCornerStyles } from './useWeekCornerStyles.styles';\nimport { mergeClasses } from '@griffel/react';\nimport type { Day, DayOfWeek } from '../../utils';\nimport type { CalendarDayGridProps } from './CalendarDayGrid.types';\n\nexport interface DayInfo extends Day {\n onSelected: () => void;\n setRef(element: HTMLElement | null): void;\n}\n\nfunction useDayRefs() {\n const daysRef = React.useRef<Record<string, HTMLElement>>({});\n\n const getSetRefCallback = (dayKey: string) => (element: HTMLElement | null) => {\n if (element === null) {\n delete daysRef.current[dayKey];\n } else {\n daysRef.current[dayKey] = element;\n }\n };\n\n return [daysRef, getSetRefCallback] as const;\n}\n\nfunction useAnimateBackwards(weeks: DayInfo[][]): boolean | undefined {\n const previousNavigatedDateRef = React.useRef<Date | undefined>(undefined);\n React.useEffect(() => {\n previousNavigatedDateRef.current = weeks[0][0].originalDate;\n });\n const previousNavigatedDate = previousNavigatedDateRef.current;\n\n // eslint-disable-next-line react-hooks/refs\n if (!previousNavigatedDate || previousNavigatedDate.getTime() === weeks[0][0].originalDate.getTime()) {\n return undefined;\n // eslint-disable-next-line react-hooks/refs\n } else if (previousNavigatedDate <= weeks[0][0].originalDate) {\n return false;\n } else {\n return true;\n }\n}\n\nexport const CalendarDayGrid: React.FunctionComponent<CalendarDayGridProps> = props => {\n const navigatedDayRef = React.useRef<HTMLTableCellElement>(\n null,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ) as React.MutableRefObject<HTMLTableCellElement | null>;\n\n const activeDescendantId = useId();\n\n const onSelectDate = (selectedDate: Date): void => {\n const { firstDayOfWeek, minDate, maxDate, workWeekDays, daysToSelectInDayView, restrictedDates } = props;\n const restrictedDatesOptions = { minDate, maxDate, restrictedDates };\n\n // eslint-disable-next-line react-hooks/immutability\n let dateRange = getDateRangeArray(selectedDate, dateRangeType, firstDayOfWeek, workWeekDays, daysToSelectInDayView);\n dateRange = getBoundedDateRange(dateRange, minDate, maxDate);\n\n dateRange = dateRange.filter((d: Date) => {\n return !isRestrictedDate(d, restrictedDatesOptions);\n });\n\n props.onSelectDate?.(selectedDate, dateRange);\n props.onNavigateDate?.(selectedDate, true);\n };\n\n const [daysRef, getSetRefCallback] = useDayRefs();\n\n const weeks = useWeeks(props, onSelectDate, getSetRefCallback);\n const animateBackwards = useAnimateBackwards(weeks);\n const [getWeekCornerStyles, calculateRoundedStyles] = useWeekCornerStyles(props);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n focus() {\n navigatedDayRef.current?.focus?.();\n },\n }),\n [],\n );\n\n /**\n *\n * Section for setting hover/pressed styles. Because we want arbitrary blobs of days to be selectable, to support\n * highlighting every day in the month for month view, css :hover style isn't enough, so we need mouse callbacks\n * to set classnames on all relevant child refs to apply the styling\n *\n */\n const getDayInfosInRangeOfDay = (dayToCompare: DayInfo): DayInfo[] => {\n // The hover state looks weird with non-contiguous days in work week view. In work week, show week hover state\n const dateRangeHoverType = getDateRangeTypeToUse(props.dateRangeType, props.workWeekDays);\n\n // gets all the dates for the given date range type that are in the same date range as the given day\n const dateRange = getDateRangeArray(\n dayToCompare.originalDate,\n dateRangeHoverType,\n props.firstDayOfWeek,\n props.workWeekDays,\n props.daysToSelectInDayView,\n ).map((date: Date) => date.getTime());\n\n // gets all the day refs for the given dates\n const dayInfosInRange = weeks.reduce((accumulatedValue: DayInfo[], currentWeek: DayInfo[]) => {\n return accumulatedValue.concat(\n currentWeek.filter((weekDay: DayInfo) => dateRange.indexOf(weekDay.originalDate.getTime()) !== -1),\n );\n }, []);\n\n return dayInfosInRange;\n };\n\n const getRefsFromDayInfos = (dayInfosInRange: DayInfo[]): (HTMLElement | null)[] => {\n let dayRefs: (HTMLElement | null)[] = [];\n dayRefs = dayInfosInRange.map((dayInfo: DayInfo) => daysRef.current[dayInfo.key]);\n\n return dayRefs;\n };\n\n const {\n gridLabel,\n dateRangeType,\n showWeekNumbers,\n labelledBy,\n lightenDaysOutsideNavigatedMonth,\n animationDirection,\n } = props;\n\n const classNames = useCalendarDayGridStyles_unstable({\n animateBackwards,\n animationDirection,\n dateRangeType,\n lightenDaysOutsideNavigatedMonth:\n lightenDaysOutsideNavigatedMonth === undefined ? true : lightenDaysOutsideNavigatedMonth,\n showWeekNumbers,\n });\n\n // When the month is highlighted get the corner dates so that styles can be added to them\n const weekCorners: WeekCorners = getWeekCornerStyles(weeks!);\n const partialWeekProps = {\n weeks,\n navigatedDayRef,\n calculateRoundedStyles,\n activeDescendantId,\n classNames,\n weekCorners,\n getDayInfosInRangeOfDay,\n getRefsFromDayInfos,\n } as const;\n\n const arrowNavigationAttributes = useArrowNavigationGroup({ axis: 'grid-linear' });\n\n return (\n <table\n className={mergeClasses(classNames.table, props.className)}\n aria-multiselectable=\"false\"\n aria-label={gridLabel}\n aria-labelledby={labelledBy}\n aria-activedescendant={activeDescendantId}\n role=\"grid\"\n {...arrowNavigationAttributes}\n >\n <tbody>\n <CalendarMonthHeaderRow {...props} classNames={classNames} weeks={weeks} />\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n week={weeks[0]}\n weekIndex={-1}\n rowClassName={classNames.firstTransitionWeek}\n aria-role=\"presentation\"\n ariaHidden={true}\n />\n {weeks!.slice(1, weeks!.length - 1).map((week: DayInfo[], weekIndex: number) => (\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n key={weekIndex}\n week={week}\n weekIndex={weekIndex}\n rowClassName={classNames.weekRow}\n />\n ))}\n <CalendarGridRow\n {...props}\n {...partialWeekProps}\n week={weeks![weeks!.length - 1]}\n weekIndex={-2}\n rowClassName={classNames.lastTransitionWeek}\n aria-role=\"presentation\"\n ariaHidden={true}\n />\n </tbody>\n </table>\n );\n};\nCalendarDayGrid.displayName = 'CalendarDayGrid';\n\n/**\n * When given work week, if the days are non-contiguous, the hover states look really weird. So for non-contiguous\n * work weeks, we'll just show week view instead.\n */\nfunction getDateRangeTypeToUse(dateRangeType: DateRangeType, workWeekDays: DayOfWeek[] | undefined): DateRangeType {\n if (workWeekDays && dateRangeType === DateRangeType.WorkWeek) {\n const sortedWWDays = workWeekDays.slice().sort();\n let isContiguous = true;\n for (let i = 1; i < sortedWWDays.length; i++) {\n if (sortedWWDays[i] !== sortedWWDays[i - 1] + 1) {\n isContiguous = false;\n break;\n }\n }\n\n if (!isContiguous || workWeekDays.length === 0) {\n return DateRangeType.Week;\n }\n }\n\n return dateRangeType;\n}\n"],"names":["React","useArrowNavigationGroup","useId","getBoundedDateRange","getDateRangeArray","isRestrictedDate","DateRangeType","useCalendarDayGridStyles_unstable","CalendarMonthHeaderRow","CalendarGridRow","useWeeks","useWeekCornerStyles","mergeClasses","useDayRefs","daysRef","useRef","getSetRefCallback","dayKey","element","current","useAnimateBackwards","weeks","previousNavigatedDateRef","undefined","useEffect","originalDate","previousNavigatedDate","getTime","CalendarDayGrid","props","navigatedDayRef","activeDescendantId","onSelectDate","selectedDate","firstDayOfWeek","minDate","maxDate","workWeekDays","daysToSelectInDayView","restrictedDates","restrictedDatesOptions","dateRange","dateRangeType","filter","d","onNavigateDate","animateBackwards","getWeekCornerStyles","calculateRoundedStyles","useImperativeHandle","componentRef","focus","getDayInfosInRangeOfDay","dayToCompare","dateRangeHoverType","getDateRangeTypeToUse","map","date","dayInfosInRange","reduce","accumulatedValue","currentWeek","concat","weekDay","indexOf","getRefsFromDayInfos","dayRefs","dayInfo","key","gridLabel","showWeekNumbers","labelledBy","lightenDaysOutsideNavigatedMonth","animationDirection","classNames","weekCorners","partialWeekProps","arrowNavigationAttributes","axis","table","className","aria-multiselectable","aria-label","aria-labelledby","aria-activedescendant","role","tbody","week","weekIndex","rowClassName","firstTransitionWeek","aria-role","ariaHidden","slice","length","weekRow","lastTransitionWeek","displayName","WorkWeek","sortedWWDays","sort","isContiguous","i","Week"],"mappings":"AAAA;;;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A,CAAciG,IAAI;QAC3B;IACF;IAEA,OAAO7D;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/ "use strict";
|
|
2
4
|
Object.defineProperty(exports, "__esModule", {
|
|
3
5
|
value: true
|
|
4
6
|
});
|
|
5
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
6
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarDayGrid/CalendarDayGrid.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { AnimationDirection } from '../Calendar/Calendar.types';\nimport { DayOfWeek, FirstWeekOfYear, DateRangeType } from '../../utils';\nimport type { CalendarStrings, DateFormatting, DayGridOptions } from '../../utils';\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarDayGrid {\n focus(): void;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridProps extends DayGridOptions {\n /**\n * Optional callback to access the ICalendarDayGrid interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarDayGrid | null>;\n\n /**\n * Additional CSS class(es) to apply to the CalendarDayGrid.\n */\n className?: string;\n\n /**\n * Localized strings to use in the CalendarDayGrid\n */\n strings: CalendarStrings;\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * Callback issued when a date is selected\n * @param date - The date the user selected\n * @param selectedDateRangeArray - The resultant list of dates that are selected based on the date range type set\n * for the component.\n */\n onSelectDate?: (date: Date, selectedDateRangeArray?: Date[]) => void;\n\n /**\n * Callback issued when a date in the calendar is navigated\n * @param date - The date that is navigated to\n * @param focusOnNavigatedDay - Whether to set the focus to the navigated date.\n */\n onNavigateDate: (date: Date, focusOnNavigatedDay: boolean) => void;\n\n /**\n * Callback issued when calendar day is closed\n */\n onDismiss?: () => void;\n\n /**\n * The first day of the week for your locale.\n * @default DayOfWeek.Sunday\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n * @default FirstWeekOfYear.FirstDay\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n * @default DateRangeType.Day\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n * @default 1\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter: DateFormatting;\n\n /**\n * Ref callback for individual days. Allows for customization of the styling, properties, or listeners of the\n * specific day.\n */\n customDayCellRef?: (element: HTMLElement, date: Date, classNames: CalendarDayGridStyles) => void;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n * @default undefined\n */\n weeksToShow?: number;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n * @default [Monday,Tuesday,Wednesday,Thursday,Friday]\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n\n /**\n * Label string for the grid\n */\n gridLabel?: string;\n\n /**\n * The ID of the control that labels this one\n */\n labelledBy?: string;\n\n /**\n * Whether to show days outside the selected month with lighter styles\n * @default true\n */\n lightenDaysOutsideNavigatedMonth?: boolean;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or veritcal\n */\n animationDirection?: AnimationDirection;\n\n /**\n * Optional callback function to mark specific days with a small symbol. Fires when the date range changes,\n * gives the starting and ending displayed dates and expects the list of which days in between should be\n * marked.\n */\n getMarkedDays?: (startingDate: Date, endingDate: Date) => Date[];\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridStyleProps {\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * The date range type\n */\n dateRangeType?: DateRangeType;\n\n /**\n * Whether week numbers are being shown\n */\n showWeekNumbers?: boolean;\n\n /**\n * Whether to show days outside the selected month with lighter styles\n */\n lightenDaysOutsideNavigatedMonth?: boolean;\n\n /**\n * Whether grid entering animation should be forwards or backwards\n */\n animateBackwards?: boolean;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or vertical\n */\n animationDirection?: AnimationDirection;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridStyles {\n /**\n * The style for the root div\n */\n wrapper?: string;\n\n /**\n * The style for the table containing the grid\n */\n table?: string;\n\n /**\n * The style to apply to the grid cells for days\n */\n dayCell?: string;\n\n /**\n * The style to apply to grid cells for days in the selected range\n */\n daySelected?: string;\n\n /**\n * The classname applied when a single day is selected\n */\n daySingleSelected?: string;\n\n /**\n * The style to apply to row around weeks\n */\n weekRow?: string;\n\n /**\n * The style to apply to the column headers above the weeks\n */\n weekDayLabelCell?: string;\n\n /**\n * The style to apply to grid cells for week numbers\n */\n weekNumberCell?: string;\n\n /**\n * The style to apply to individual days that are outside the min/max date range\n */\n dayOutsideBounds?: string;\n\n /**\n * The style to apply to individual days that are outside the current month\n */\n dayOutsideNavigatedMonth?: string;\n\n /**\n * The style to apply to the button element within the day cells\n */\n dayButton?: string;\n\n /**\n * The style to apply to the individual button element that matches the \"today\" parameter\n */\n dayIsToday?: string;\n\n /**\n * The style applied to the first placeholder week used during transitions\n */\n firstTransitionWeek?: string;\n\n /**\n * The style applied to the last placeholder week used during transitions\n */\n lastTransitionWeek?: string;\n\n /**\n * The style applied to the marker on days to mark as important\n */\n dayMarker?: string;\n\n /**\n * The classname applied to the day \"today\" span\n */\n dayTodayMarker?: string;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarDayGrid/CalendarDayGrid.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { AnimationDirection } from '../Calendar/Calendar.types';\nimport type { DayOfWeek, FirstWeekOfYear, DateRangeType } from '../../utils';\nimport type { CalendarStrings, DateFormatting, DayGridOptions } from '../../utils';\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ICalendarDayGrid {\n focus(): void;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridProps extends DayGridOptions {\n /**\n * Optional callback to access the ICalendarDayGrid interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<ICalendarDayGrid | null>;\n\n /**\n * Additional CSS class(es) to apply to the CalendarDayGrid.\n */\n className?: string;\n\n /**\n * Localized strings to use in the CalendarDayGrid\n */\n strings: CalendarStrings;\n\n /**\n * The currently selected date\n */\n selectedDate: Date;\n\n /**\n * The currently navigated date\n */\n navigatedDate: Date;\n\n /**\n * Callback issued when a date is selected\n * @param date - The date the user selected\n * @param selectedDateRangeArray - The resultant list of dates that are selected based on the date range type set\n * for the component.\n */\n onSelectDate?: (date: Date, selectedDateRangeArray?: Date[]) => void;\n\n /**\n * Callback issued when a date in the calendar is navigated\n * @param date - The date that is navigated to\n * @param focusOnNavigatedDay - Whether to set the focus to the navigated date.\n */\n onNavigateDate: (date: Date, focusOnNavigatedDay: boolean) => void;\n\n /**\n * Callback issued when calendar day is closed\n */\n onDismiss?: () => void;\n\n /**\n * The first day of the week for your locale.\n * @default DayOfWeek.Sunday\n */\n firstDayOfWeek: DayOfWeek;\n\n /**\n * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,\n * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values\n * @default FirstWeekOfYear.FirstDay\n */\n firstWeekOfYear: FirstWeekOfYear;\n\n /**\n * The date range type indicating how many days should be selected as the user\n * selects days\n * @default DateRangeType.Day\n */\n dateRangeType: DateRangeType;\n\n /**\n * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day\n * views.\n * @default 1\n */\n daysToSelectInDayView?: number;\n\n /**\n * Value of today. If unspecified, current time in client machine will be used.\n */\n today?: Date;\n\n /**\n * Whether the calendar should show the week number (weeks 1 to 53) before each week row\n * @default false\n */\n showWeekNumbers?: boolean;\n\n /**\n * Apply additional formatting to dates, for example localized date formatting.\n */\n dateTimeFormatter: DateFormatting;\n\n /**\n * Ref callback for individual days. Allows for customization of the styling, properties, or listeners of the\n * specific day.\n */\n customDayCellRef?: (element: HTMLElement, date: Date, classNames: CalendarDayGridStyles) => void;\n\n /**\n * How many weeks to show by default. If not provided, will show enough weeks to display the current\n * month, between 4 and 6 depending\n * @default undefined\n */\n weeksToShow?: number;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date earlier than this value.\n */\n minDate?: Date;\n\n /**\n * If set the Calendar will not allow navigation to or selection of a date later than this value.\n */\n maxDate?: Date;\n\n /**\n * If set the Calendar will not allow selection of dates in this array.\n */\n restrictedDates?: Date[];\n\n /**\n * The days that are selectable when `dateRangeType` is WorkWeek.\n * If `dateRangeType` is not WorkWeek this property does nothing.\n * @default [Monday,Tuesday,Wednesday,Thursday,Friday]\n */\n workWeekDays?: DayOfWeek[];\n\n /**\n * Whether the close button should be shown or not\n * @default false\n */\n showCloseButton?: boolean;\n\n /**\n * Allows all dates and buttons to be focused, including disabled ones\n * @default false\n */\n allFocusable?: boolean;\n\n /**\n * Label string for the grid\n */\n gridLabel?: string;\n\n /**\n * The ID of the control that labels this one\n */\n labelledBy?: string;\n\n /**\n * Whether to show days outside the selected month with lighter styles\n * @default true\n */\n lightenDaysOutsideNavigatedMonth?: boolean;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or veritcal\n */\n animationDirection?: AnimationDirection;\n\n /**\n * Optional callback function to mark specific days with a small symbol. Fires when the date range changes,\n * gives the starting and ending displayed dates and expects the list of which days in between should be\n * marked.\n */\n getMarkedDays?: (startingDate: Date, endingDate: Date) => Date[];\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridStyleProps {\n /**\n * Accept custom classNames\n */\n className?: string;\n\n /**\n * The date range type\n */\n dateRangeType?: DateRangeType;\n\n /**\n * Whether week numbers are being shown\n */\n showWeekNumbers?: boolean;\n\n /**\n * Whether to show days outside the selected month with lighter styles\n */\n lightenDaysOutsideNavigatedMonth?: boolean;\n\n /**\n * Whether grid entering animation should be forwards or backwards\n */\n animateBackwards?: boolean;\n\n /**\n * The cardinal directions for animation to occur during transitions, either horizontal or vertical\n */\n animationDirection?: AnimationDirection;\n}\n\n/**\n * @internal\n */\nexport interface CalendarDayGridStyles {\n /**\n * The style for the root div\n */\n wrapper?: string;\n\n /**\n * The style for the table containing the grid\n */\n table?: string;\n\n /**\n * The style to apply to the grid cells for days\n */\n dayCell?: string;\n\n /**\n * The style to apply to grid cells for days in the selected range\n */\n daySelected?: string;\n\n /**\n * The classname applied when a single day is selected\n */\n daySingleSelected?: string;\n\n /**\n * The style to apply to row around weeks\n */\n weekRow?: string;\n\n /**\n * The style to apply to the column headers above the weeks\n */\n weekDayLabelCell?: string;\n\n /**\n * The style to apply to grid cells for week numbers\n */\n weekNumberCell?: string;\n\n /**\n * The style to apply to individual days that are outside the min/max date range\n */\n dayOutsideBounds?: string;\n\n /**\n * The style to apply to individual days that are outside the current month\n */\n dayOutsideNavigatedMonth?: string;\n\n /**\n * The style to apply to the button element within the day cells\n */\n dayButton?: string;\n\n /**\n * The style to apply to the individual button element that matches the \"today\" parameter\n */\n dayIsToday?: string;\n\n /**\n * The style applied to the first placeholder week used during transitions\n */\n firstTransitionWeek?: string;\n\n /**\n * The style applied to the last placeholder week used during transitions\n */\n lastTransitionWeek?: string;\n\n /**\n * The style applied to the marker on days to mark as important\n */\n dayMarker?: string;\n\n /**\n * The classname applied to the day \"today\" span\n */\n dayTodayMarker?: string;\n}\n"],"names":[],"mappings":"AAyNA;;CAEC,GACD,WAgFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarDayGrid/useWeekCornerStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { DateRangeType } from '../../utils/constants';\nimport { getDateRangeArray } from '../../utils/index';\nimport { DayInfo } from './CalendarDayGrid';\nimport { CalendarDayGridProps } from './CalendarDayGrid.types';\n\n/**\n * @internal\n */\nexport const weekCornersClassNames = {\n topRightCornerDate: 'fui-CalendarDayGrid__topRightCornerDate',\n topLeftCornerDate: 'fui-CalendarDayGrid__topLeftCornerDate',\n bottomRightCornerDate: 'fui-CalendarDayGrid__bottomRightCornerDate',\n bottomLeftCornerDate: 'fui-CalendarDayGrid__bottomLeftCornerDate',\n};\n\n/**\n * @internal\n */\nexport interface WeekCorners {\n [key: string]: string;\n}\n\n/**\n * @internal\n */\nexport function useWeekCornerStyles(\n props: CalendarDayGridProps,\n): readonly [\n (initialWeeks: DayInfo[][]) => WeekCorners,\n (above: boolean, below: boolean, left: boolean, right: boolean) => string,\n] {\n const { dir } = useFluent_unstable();\n\n /**\n *\n * Section for setting the rounded corner styles on individual day cells. Individual day cells need different\n * corners to be rounded depending on which date range type and where the cell is located in the current grid.\n * If we just round all of the corners, there isn't a good overlap and we get gaps between contiguous day boxes\n * in Edge browser.\n *\n */\n const getWeekCornerStyles = (initialWeeks: DayInfo[][]): WeekCorners => {\n const weekCornersStyled: { [key: string]: string } = {};\n /* need to handle setting all of the corners on arbitrarily shaped blobs\n __\n __|A |\n |B |C |__\n |D |E |F |\n\n in this case, A needs top left rounded, top right rounded\n B needs top left rounded\n C doesn't need any rounding\n D needs bottom left rounded\n E doesn't need any rounding\n F needs top right rounding\n */\n\n // cut off the animation transition weeks\n const weeks = initialWeeks.slice(1, initialWeeks.length - 1);\n\n // if there's an item above, lose both top corners. Item below, lose both bottom corners, etc.\n weeks.forEach((week: DayInfo[], weekIndex: number) => {\n week.forEach((day: DayInfo, dayIndex: number) => {\n const above =\n weeks[weekIndex - 1] &&\n weeks[weekIndex - 1][dayIndex] &&\n isInSameHoverRange(\n weeks[weekIndex - 1][dayIndex].originalDate,\n day.originalDate,\n weeks[weekIndex - 1][dayIndex].isSelected,\n day.isSelected,\n );\n const below =\n weeks[weekIndex + 1] &&\n weeks[weekIndex + 1][dayIndex] &&\n isInSameHoverRange(\n weeks[weekIndex + 1][dayIndex].originalDate,\n day.originalDate,\n weeks[weekIndex + 1][dayIndex].isSelected,\n day.isSelected,\n );\n const left =\n weeks[weekIndex][dayIndex - 1] &&\n isInSameHoverRange(\n weeks[weekIndex][dayIndex - 1].originalDate,\n day.originalDate,\n weeks[weekIndex][dayIndex - 1].isSelected,\n day.isSelected,\n );\n const right =\n weeks[weekIndex][dayIndex + 1] &&\n isInSameHoverRange(\n weeks[weekIndex][dayIndex + 1].originalDate,\n day.originalDate,\n weeks[weekIndex][dayIndex + 1].isSelected,\n day.isSelected,\n );\n\n weekCornersStyled[weekIndex + '_' + dayIndex] = calculateRoundedStyles(above, below, left, right);\n });\n });\n\n return weekCornersStyled;\n };\n\n const calculateRoundedStyles = (above: boolean, below: boolean, left: boolean, right: boolean): string => {\n const style = [];\n const roundedTopLeft = !above && !left;\n const roundedTopRight = !above && !right;\n const roundedBottomLeft = !below && !left;\n const roundedBottomRight = !below && !right;\n\n if (roundedTopLeft) {\n style.push(dir === 'rtl' ? weekCornersClassNames.topRightCornerDate : weekCornersClassNames.topLeftCornerDate);\n }\n if (roundedTopRight) {\n style.push(dir === 'rtl' ? weekCornersClassNames.topLeftCornerDate : weekCornersClassNames.topRightCornerDate);\n }\n if (roundedBottomLeft) {\n style.push(\n dir === 'rtl' ? weekCornersClassNames.bottomRightCornerDate : weekCornersClassNames.bottomLeftCornerDate,\n );\n }\n if (roundedBottomRight) {\n style.push(\n dir === 'rtl' ? weekCornersClassNames.bottomLeftCornerDate : weekCornersClassNames.bottomRightCornerDate,\n );\n }\n\n return mergeClasses(...style);\n };\n\n const isInSameHoverRange = (date1: Date, date2: Date, date1Selected: boolean, date2Selected: boolean): boolean => {\n const { dateRangeType, firstDayOfWeek, workWeekDays } = props;\n\n // The hover state looks weird with non-contiguous days in work week view. In work week, show week hover state\n const dateRangeHoverType = dateRangeType === DateRangeType.WorkWeek ? DateRangeType.Week : dateRangeType;\n\n // we do not pass daysToSelectInDayView because we handle setting those styles dyanamically in onMouseOver\n const dateRange = getDateRangeArray(date1, dateRangeHoverType, firstDayOfWeek, workWeekDays);\n\n if (date1Selected !== date2Selected) {\n // if one is selected and the other is not, they can't be in the same range\n return false;\n } else if (date1Selected && date2Selected) {\n // if they're both selected at the same time they must be in the same range\n return true;\n }\n\n // otherwise, both must be unselected, so check the dateRange\n return dateRange.filter((date: Date) => date.getTime() === date2.getTime()).length > 0;\n };\n\n return [getWeekCornerStyles, calculateRoundedStyles] as const;\n}\n"],"names":["useFluent_unstable","mergeClasses","DateRangeType","getDateRangeArray","weekCornersClassNames","topRightCornerDate","topLeftCornerDate","bottomRightCornerDate","bottomLeftCornerDate","useWeekCornerStyles","props","dir","getWeekCornerStyles","initialWeeks","weekCornersStyled","weeks","slice","length","forEach","week","weekIndex","day","dayIndex","above","isInSameHoverRange","originalDate","isSelected","below","left","right","calculateRoundedStyles","style","roundedTopLeft","roundedTopRight","roundedBottomLeft","roundedBottomRight","push","date1","date2","date1Selected","date2Selected","dateRangeType","firstDayOfWeek","workWeekDays","dateRangeHoverType","WorkWeek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AEC,YAAY,EAAE,GAAGjC;QAExD,8GAA8G;QAC9G,MAAMkC,qBAAqBH,kBAAkBvC,wBAAAA,CAAc2C,QAAQ,GAAG3C,wBAAAA,CAAc4C,IAAI,GAAGL;QAE3F,0GAA0G;QAC1G,MAAMM,gBAAY5C,wBAAAA,EAAkBkC,OAAOO,oBAAoBF,gBAAgBC;QAE/E,IAAIJ,kBAAkBC,eAAe;YACnC,2EAA2E;YAC3E,OAAO;QACT,OAAO,IAAID,iBAAiBC,eAAe;YACzC,2EAA2E;YAC3E,OAAO;QACT;QAEA,6DAA6D;QAC7D,OAAOO,UAAUC,MAAM,CAAC,CAACC,OAAeA,KAAKC,OAAO,OAAOZ,MAAMY,OAAO,IAAIjC,MAAM,GAAG;IACvF;IAEA,OAAO;QAACL;QAAqBkB;KAAuB;AACtD"}
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarDayGrid/useWeekCornerStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { mergeClasses } from '@griffel/react';\nimport { DateRangeType } from '../../utils/constants';\nimport { getDateRangeArray } from '../../utils/index';\nimport type { DayInfo } from './CalendarDayGrid';\nimport type { CalendarDayGridProps } from './CalendarDayGrid.types';\n\n/**\n * @internal\n */\nexport const weekCornersClassNames = {\n topRightCornerDate: 'fui-CalendarDayGrid__topRightCornerDate',\n topLeftCornerDate: 'fui-CalendarDayGrid__topLeftCornerDate',\n bottomRightCornerDate: 'fui-CalendarDayGrid__bottomRightCornerDate',\n bottomLeftCornerDate: 'fui-CalendarDayGrid__bottomLeftCornerDate',\n};\n\n/**\n * @internal\n */\nexport interface WeekCorners {\n [key: string]: string;\n}\n\n/**\n * @internal\n */\nexport function useWeekCornerStyles(\n props: CalendarDayGridProps,\n): readonly [\n (initialWeeks: DayInfo[][]) => WeekCorners,\n (above: boolean, below: boolean, left: boolean, right: boolean) => string,\n] {\n const { dir } = useFluent_unstable();\n\n /**\n *\n * Section for setting the rounded corner styles on individual day cells. Individual day cells need different\n * corners to be rounded depending on which date range type and where the cell is located in the current grid.\n * If we just round all of the corners, there isn't a good overlap and we get gaps between contiguous day boxes\n * in Edge browser.\n *\n */\n const getWeekCornerStyles = (initialWeeks: DayInfo[][]): WeekCorners => {\n const weekCornersStyled: { [key: string]: string } = {};\n /* need to handle setting all of the corners on arbitrarily shaped blobs\n __\n __|A |\n |B |C |__\n |D |E |F |\n\n in this case, A needs top left rounded, top right rounded\n B needs top left rounded\n C doesn't need any rounding\n D needs bottom left rounded\n E doesn't need any rounding\n F needs top right rounding\n */\n\n // cut off the animation transition weeks\n const weeks = initialWeeks.slice(1, initialWeeks.length - 1);\n\n // if there's an item above, lose both top corners. Item below, lose both bottom corners, etc.\n weeks.forEach((week: DayInfo[], weekIndex: number) => {\n week.forEach((day: DayInfo, dayIndex: number) => {\n const above =\n weeks[weekIndex - 1] &&\n weeks[weekIndex - 1][dayIndex] &&\n isInSameHoverRange(\n weeks[weekIndex - 1][dayIndex].originalDate,\n day.originalDate,\n weeks[weekIndex - 1][dayIndex].isSelected,\n day.isSelected,\n );\n const below =\n weeks[weekIndex + 1] &&\n weeks[weekIndex + 1][dayIndex] &&\n isInSameHoverRange(\n weeks[weekIndex + 1][dayIndex].originalDate,\n day.originalDate,\n weeks[weekIndex + 1][dayIndex].isSelected,\n day.isSelected,\n );\n const left =\n weeks[weekIndex][dayIndex - 1] &&\n isInSameHoverRange(\n weeks[weekIndex][dayIndex - 1].originalDate,\n day.originalDate,\n weeks[weekIndex][dayIndex - 1].isSelected,\n day.isSelected,\n );\n const right =\n weeks[weekIndex][dayIndex + 1] &&\n isInSameHoverRange(\n weeks[weekIndex][dayIndex + 1].originalDate,\n day.originalDate,\n weeks[weekIndex][dayIndex + 1].isSelected,\n day.isSelected,\n );\n\n weekCornersStyled[weekIndex + '_' + dayIndex] = calculateRoundedStyles(above, below, left, right);\n });\n });\n\n return weekCornersStyled;\n };\n\n const calculateRoundedStyles = (above: boolean, below: boolean, left: boolean, right: boolean): string => {\n const style = [];\n const roundedTopLeft = !above && !left;\n const roundedTopRight = !above && !right;\n const roundedBottomLeft = !below && !left;\n const roundedBottomRight = !below && !right;\n\n if (roundedTopLeft) {\n style.push(dir === 'rtl' ? weekCornersClassNames.topRightCornerDate : weekCornersClassNames.topLeftCornerDate);\n }\n if (roundedTopRight) {\n style.push(dir === 'rtl' ? weekCornersClassNames.topLeftCornerDate : weekCornersClassNames.topRightCornerDate);\n }\n if (roundedBottomLeft) {\n style.push(\n dir === 'rtl' ? weekCornersClassNames.bottomRightCornerDate : weekCornersClassNames.bottomLeftCornerDate,\n );\n }\n if (roundedBottomRight) {\n style.push(\n dir === 'rtl' ? weekCornersClassNames.bottomLeftCornerDate : weekCornersClassNames.bottomRightCornerDate,\n );\n }\n\n return mergeClasses(...style);\n };\n\n const isInSameHoverRange = (date1: Date, date2: Date, date1Selected: boolean, date2Selected: boolean): boolean => {\n const { dateRangeType, firstDayOfWeek, workWeekDays } = props;\n\n // The hover state looks weird with non-contiguous days in work week view. In work week, show week hover state\n const dateRangeHoverType = dateRangeType === DateRangeType.WorkWeek ? DateRangeType.Week : dateRangeType;\n\n // we do not pass daysToSelectInDayView because we handle setting those styles dyanamically in onMouseOver\n const dateRange = getDateRangeArray(date1, dateRangeHoverType, firstDayOfWeek, workWeekDays);\n\n if (date1Selected !== date2Selected) {\n // if one is selected and the other is not, they can't be in the same range\n return false;\n } else if (date1Selected && date2Selected) {\n // if they're both selected at the same time they must be in the same range\n return true;\n }\n\n // otherwise, both must be unselected, so check the dateRange\n return dateRange.filter((date: Date) => date.getTime() === date2.getTime()).length > 0;\n };\n\n return [getWeekCornerStyles, calculateRoundedStyles] as const;\n}\n"],"names":["useFluent_unstable","mergeClasses","DateRangeType","getDateRangeArray","weekCornersClassNames","topRightCornerDate","topLeftCornerDate","bottomRightCornerDate","bottomLeftCornerDate","useWeekCornerStyles","props","dir","getWeekCornerStyles","initialWeeks","weekCornersStyled","weeks","slice","length","forEach","week","weekIndex","day","dayIndex","above","isInSameHoverRange","originalDate","isSelected","below","left","right","calculateRoundedStyles","style","roundedTopLeft","roundedTopRight","roundedBottomLeft","roundedBottomRight","push","date1","date2","date1Selected","date2Selected","dateRangeType","firstDayOfWeek","workWeekDays","dateRangeHoverType","WorkWeek","Week","dateRange","filter","date","getTime"],"mappings":"AAAA;;;;;;;;;;;;IA6BgBS,mBAAAA;;;IAjBHL,qBAAAA;;;;qCAVsB,kCAAkC;uBACxC,iBAAiB;2BAChB,wBAAwB;uBACpB,oBAAoB;AAO/C,8BAA8B;IACnCC,oBAAoB;IACpBC,mBAAmB;IACnBC,uBAAuB;IACvBC,sBAAsB;AACxB,EAAE;AAYK,6BACLE,KAA2B;IAK3B,MAAM,EAAEC,GAAG,EAAE,OAAGX,uCAAAA;IAEhB;;;;;;;GAOC,GACD,MAAMY,sBAAsB,CAACC;QAC3B,MAAMC,oBAA+C,CAAC;QACtD;;;;;;;;;;;;IAYA,GAEA,yCAAyC;QACzC,MAAMC,QAAQF,aAAaG,KAAK,CAAC,GAAGH,aAAaI,MAAM,GAAG;QAE1D,8FAA8F;QAC9FF,MAAMG,OAAO,CAAC,CAACC,MAAiBC;YAC9BD,KAAKD,OAAO,CAAC,CAACG,KAAcC;gBAC1B,MAAMC,QACJR,KAAK,CAACK,YAAY,EAAE,IACpBL,KAAK,CAACK,YAAY,EAAE,CAACE,SAAS,IAC9BE,mBACET,KAAK,CAACK,YAAY,EAAE,CAACE,SAAS,CAACG,YAAY,EAC3CJ,IAAII,YAAY,EAChBV,KAAK,CAACK,YAAY,EAAE,CAACE,SAAS,CAACI,UAAU,EACzCL,IAAIK,UAAU;gBAElB,MAAMC,QACJZ,KAAK,CAACK,YAAY,EAAE,IACpBL,KAAK,CAACK,YAAY,EAAE,CAACE,SAAS,IAC9BE,mBACET,KAAK,CAACK,YAAY,EAAE,CAACE,SAAS,CAACG,YAAY,EAC3CJ,IAAII,YAAY,EAChBV,KAAK,CAACK,YAAY,EAAE,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AQP,sBAAsBI,oBAAoB,GAAGJ,sBAAsBG,qBAAqB;QAE5G;QAEA,WAAON,mBAAAA,KAAgB8B;IACzB;IAEA,MAAMP,qBAAqB,CAACa,OAAaC,OAAaC,eAAwBC;QAC5E,MAAM,EAAEC,aAAa,EAAEC,cAAc,EAAEC,YAAY,EAAE,GAAGjC;QAExD,8GAA8G;QAC9G,MAAMkC,qBAAqBH,kBAAkBvC,wBAAAA,CAAc2C,QAAQ,GAAG3C,wBAAAA,CAAc4C,IAAI,GAAGL;QAE3F,0GAA0G;QAC1G,MAAMM,gBAAY5C,wBAAAA,EAAkBkC,OAAOO,oBAAoBF,gBAAgBC;QAE/E,IAAIJ,kBAAkBC,eAAe;YACnC,2EAA2E;YAC3E,OAAO;QACT,OAAO,IAAID,iBAAiBC,eAAe;YACzC,2EAA2E;YAC3E,OAAO;QACT;QAEA,6DAA6D;QAC7D,OAAOO,UAAUC,MAAM,CAAC,CAACC,OAAeA,KAAKC,OAAO,OAAOZ,MAAMY,OAAO,IAAIjC,MAAM,GAAG;IACvF;IAEA,OAAO;QAACL;QAAqBkB;KAAuB;AACtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CalendarDayGrid/useWeeks.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { compareDates, DAYS_IN_WEEK, getDayGrid } from '../../utils/index';\nimport { DayInfo } from './CalendarDayGrid';\nimport { CalendarDayGridProps } from './CalendarDayGrid.types';\n\n/**\n * @internal\n */\nexport function useWeeks(\n props: CalendarDayGridProps,\n onSelectDate: (date: Date) => void,\n getSetRefCallback: (dayKey: string) => (element: HTMLElement | null) => void,\n): DayInfo[][] {\n 'use no memo';\n\n /**\n * Initial parsing of the given props to generate IDayInfo two dimensional array, which contains a representation\n * of every day in the grid. Convenient for helping with conversions between day refs and Date objects in callbacks.\n */\n const weeks = React.useMemo((): DayInfo[][] => {\n const weeksGrid = getDayGrid(props);\n\n const firstVisibleDay = weeksGrid[1][0].originalDate;\n const lastVisibleDay = weeksGrid[weeksGrid.length - 1][6].originalDate;\n const markedDays = props.getMarkedDays?.(firstVisibleDay, lastVisibleDay) || [];\n\n /**\n * Weeks is a 2D array. Weeks[0] contains the last week of the prior range,\n * Weeks[weeks.length - 1] contains first week of next range. These are for transition states.\n *\n * Weeks[1... weeks.length - 2] contains the actual visible data\n */\n const returnValue: DayInfo[][] = [];\n\n for (let weekIndex = 0; weekIndex < weeksGrid.length; weekIndex++) {\n const week: DayInfo[] = [];\n for (let dayIndex = 0; dayIndex < DAYS_IN_WEEK; dayIndex++) {\n const day = weeksGrid[weekIndex][dayIndex];\n const dayInfo: DayInfo = {\n onSelected: () => onSelectDate(day.originalDate),\n setRef: getSetRefCallback(day.key),\n ...day,\n isMarked: day.isMarked || markedDays?.some(markedDay => compareDates(day.originalDate, markedDay)),\n };\n\n week.push(dayInfo);\n }\n returnValue.push(week);\n }\n\n return returnValue;\n // TODO: this is missing deps on getSetRefCallback and onSelectDate (and depending on the entire\n // props object may not be a good idea due to likely frequent mutation). It would be easy to\n // fix getSetRefCallback to not mutate every render, but onSelectDate is passed down from\n // Calendar and trying to fix it requires a huge cascade of changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n\n return weeks;\n}\n"],"names":["React","compareDates","DAYS_IN_WEEK","getDayGrid","useWeeks","props","onSelectDate","getSetRefCallback","weeks","useMemo","weeksGrid","firstVisibleDay","originalDate","lastVisibleDay","length","markedDays","getMarkedDays","returnValue","weekIndex","week","dayIndex","day","dayInfo","onSelected","setRef","key","isMarked","some","markedDay","push"],"mappings":"AAAA;;;;;+BAUgBI;;;;;;;iEARO,QAAQ;uBACwB,oBAAoB;AAOpE,kBACLC,KAA2B,EAC3BC,YAAkC,EAClCC,iBAA4E;IAE5E;IAEA;;;GAGC,GACD,MAAMC,QAAQR,OAAMS,OAAO,CAAC;YAKPJ;QAJnB,MAAMK,gBAAYP,iBAAAA,EAAWE;QAE7B,MAAMM,kBAAkBD,SAAS,CAAC,EAAE,CAAC,EAAE,CAACE,YAAY;QACpD,MAAMC,iBAAiBH,SAAS,CAACA,UAAUI,MAAM,GAAG,EAAE,CAAC,EAAE,CAACF,YAAY;QACtE,MAAMG,aAAaV,CAAAA,CAAAA,uBAAAA,MAAMW,aAAAA,AAAa,MAAA,QAAnBX,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,IAAAA,CAAAA,OAAsBM,iBAAiBE,eAAAA,KAAmB,EAAE;QAE/E;;;;;KAKC,GACD,MAAMI,cAA2B,EAAE;QAEnC,IAAK,IAAIC,YAAY,GAAGA,YAAYR,UAAUI,MAAM,EAAEI,YAAa;YACjE,MAAMC,OAAkB,EAAE;YAC1B,IAAK,IAAIC,WAAW,GAAGA,WAAWlB,mBAAAA,EAAckB,WAAY;gBAC1D,MAAMC,MAAMX,SAAS,CAACQ,UAAU,CAACE,SAAS;gBAC1C,MAAME,UAAmB;oBACvBC,YAAY,IAAMjB,aAAae,IAAIT,YAAY;oBAC/CY,QAAQjB,kBAAkBc,IAAII,GAAG;oBACjC,GAAGJ,GAAG;oBACNK,UAAUL,IAAIK,QAAQ,KAAIX,eAAAA,QAAAA,eAAAA,KAAAA,IAAAA,KAAAA,IAAAA,WAAYY,IAAI,CAACC,CAAAA,gBAAa3B,mBAAAA,EAAaoB,IAAIT,YAAY,EAAEgB,WAAAA;gBACzF;gBAEAT,KAAKU,IAAI,CAACP;YACZ;YACAL,YAAYY,IAAI,CAACV;QACnB;QAEA,OAAOF;IACP,gGAAgG;IAChG,4FAA4F;IAC5F,yFAAyF;IACzF,oEAAoE;IACpE,uDAAuD;IACzD,GAAG;QAACZ;KAAM;IAEV,OAAOG;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/components/CalendarDayGrid/useWeeks.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { compareDates, DAYS_IN_WEEK, getDayGrid } from '../../utils/index';\nimport type { DayInfo } from './CalendarDayGrid';\nimport type { CalendarDayGridProps } from './CalendarDayGrid.types';\n\n/**\n * @internal\n */\nexport function useWeeks(\n props: CalendarDayGridProps,\n onSelectDate: (date: Date) => void,\n getSetRefCallback: (dayKey: string) => (element: HTMLElement | null) => void,\n): DayInfo[][] {\n 'use no memo';\n\n /**\n * Initial parsing of the given props to generate IDayInfo two dimensional array, which contains a representation\n * of every day in the grid. Convenient for helping with conversions between day refs and Date objects in callbacks.\n */\n const weeks = React.useMemo((): DayInfo[][] => {\n const weeksGrid = getDayGrid(props);\n\n const firstVisibleDay = weeksGrid[1][0].originalDate;\n const lastVisibleDay = weeksGrid[weeksGrid.length - 1][6].originalDate;\n const markedDays = props.getMarkedDays?.(firstVisibleDay, lastVisibleDay) || [];\n\n /**\n * Weeks is a 2D array. Weeks[0] contains the last week of the prior range,\n * Weeks[weeks.length - 1] contains first week of next range. These are for transition states.\n *\n * Weeks[1... weeks.length - 2] contains the actual visible data\n */\n const returnValue: DayInfo[][] = [];\n\n for (let weekIndex = 0; weekIndex < weeksGrid.length; weekIndex++) {\n const week: DayInfo[] = [];\n for (let dayIndex = 0; dayIndex < DAYS_IN_WEEK; dayIndex++) {\n const day = weeksGrid[weekIndex][dayIndex];\n const dayInfo: DayInfo = {\n onSelected: () => onSelectDate(day.originalDate),\n setRef: getSetRefCallback(day.key),\n ...day,\n isMarked: day.isMarked || markedDays?.some(markedDay => compareDates(day.originalDate, markedDay)),\n };\n\n week.push(dayInfo);\n }\n returnValue.push(week);\n }\n\n return returnValue;\n // TODO: this is missing deps on getSetRefCallback and onSelectDate (and depending on the entire\n // props object may not be a good idea due to likely frequent mutation). It would be easy to\n // fix getSetRefCallback to not mutate every render, but onSelectDate is passed down from\n // Calendar and trying to fix it requires a huge cascade of changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n\n return weeks;\n}\n"],"names":["React","compareDates","DAYS_IN_WEEK","getDayGrid","useWeeks","props","onSelectDate","getSetRefCallback","weeks","useMemo","weeksGrid","firstVisibleDay","originalDate","lastVisibleDay","length","markedDays","getMarkedDays","returnValue","weekIndex","week","dayIndex","day","dayInfo","onSelected","setRef","key","isMarked","some","markedDay","push"],"mappings":"AAAA;;;;;+BAUgBI;;;;;;;iEARO,QAAQ;uBACwB,oBAAoB;AAOpE,kBACLC,KAA2B,EAC3BC,YAAkC,EAClCC,iBAA4E;IAE5E;IAEA;;;GAGC,GACD,MAAMC,QAAQR,OAAMS,OAAO,CAAC;YAKPJ;QAJnB,MAAMK,gBAAYP,iBAAAA,EAAWE;QAE7B,MAAMM,kBAAkBD,SAAS,CAAC,EAAE,CAAC,EAAE,CAACE,YAAY;QACpD,MAAMC,iBAAiBH,SAAS,CAACA,UAAUI,MAAM,GAAG,EAAE,CAAC,EAAE,CAACF,YAAY;QACtE,MAAMG,aAAaV,CAAAA,CAAAA,uBAAAA,MAAMW,aAAAA,AAAa,MAAA,QAAnBX,yBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,IAAAA,CAAAA,OAAsBM,iBAAiBE,eAAAA,KAAmB,EAAE;QAE/E;;;;;KAKC,GACD,MAAMI,cAA2B,EAAE;QAEnC,IAAK,IAAIC,YAAY,GAAGA,YAAYR,UAAUI,MAAM,EAAEI,YAAa;YACjE,MAAMC,OAAkB,EAAE;YAC1B,IAAK,IAAIC,WAAW,GAAGA,WAAWlB,mBAAAA,EAAckB,WAAY;gBAC1D,MAAMC,MAAMX,SAAS,CAACQ,UAAU,CAACE,SAAS;gBAC1C,MAAME,UAAmB;oBACvBC,YAAY,IAAMjB,aAAae,IAAIT,YAAY;oBAC/CY,QAAQjB,kBAAkBc,IAAII,GAAG;oBACjC,GAAGJ,GAAG;oBACNK,UAAUL,IAAIK,QAAQ,KAAIX,eAAAA,QAAAA,eAAAA,KAAAA,IAAAA,KAAAA,IAAAA,WAAYY,IAAI,CAACC,CAAAA,gBAAa3B,mBAAAA,EAAaoB,IAAIT,YAAY,EAAEgB,WAAAA;gBACzF;gBAEAT,KAAKU,IAAI,CAACP;YACZ;YACAL,YAAYY,IAAI,CAACV;QACnB;QAEA,OAAOF;IACP,gGAAgG;IAChG,4FAA4F;IAC5F,yFAAyF;IACzF,oEAAoE;IACpE,uDAAuD;IACzD,GAAG;QAACZ;KAAM;IAEV,OAAOG;AACT"}
|
|
@@ -24,7 +24,9 @@ function useAnimateBackwards({ navigatedDate }) {
|
|
|
24
24
|
_react.useEffect(()=>{
|
|
25
25
|
previousYearRef.current = currentYear;
|
|
26
26
|
});
|
|
27
|
+
// eslint-disable-next-line react-hooks/refs
|
|
27
28
|
const previousYear = previousYearRef.current;
|
|
29
|
+
// eslint-disable-next-line react-hooks/refs
|
|
28
30
|
if (previousYear === undefined || previousYear === currentYear) {
|
|
29
31
|
return undefined;
|
|
30
32
|
} else {
|