react-modular-datepicker 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/classNames.ts","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/components/Day.tsx","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: string;\n empty?: string;\n rangeStart?: string;\n rangeEnd?: string;\n rangeBetween?: string;\n rangeHovering?: string;\n [key: string]: string | undefined;\n}\n\nexport const defaultClassNames = {\n root: \"w-fit flex flex-col p-4 bg-white rounded-lg shadow-lg\",\n header: \"flex items-center justify-between border-b-2 border-brand-gray-light/40 pb-2\",\n headerMultiMonth: \"border-b-0 pb-0\",\n calendarsContainer: \"flex flex-wrap gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] max-w-full\",\n navButtonSlotStart: \"w-9 flex justify-start\",\n navButtonSlotEnd: \"w-9 flex justify-end\",\n headerTitleContainer: \"font-semibold text-brand-text text-center flex-1\",\n weekdayGrid: \"grid grid-cols-7 gap-1 mb-1 border-b border-brand-gray-light/40\",\n weekday: \"text-center text-xs text-gray-400 py-2\",\n daysGrid: \"grid grid-cols-7 gap-px bg-brand-gray-light/20\",\n footer: \"mt-4\",\n\n navButton: \"p-2 text-brand-text hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n navButtonHidden: \"invisible pointer-events-none\",\n monthYearContainer: \"flex gap-8\",\n monthYearLabel: \"flex gap-1 items-center font-semibold text-brand-text\",\n monthYearButton: \"hover:bg-gray-100 px-2 py-1 rounded cursor-pointer\",\n\n day: {\n day: \"rmdp-day group\",\n selected: \"rmdp-day-selected\",\n unselected: \"rmdp-day-unselected\",\n disabled: \"rmdp-day-disabled\",\n empty: \"rmdp-day-empty\",\n rangeStart: \"rmdp-day-range-start\",\n rangeEnd: \"rmdp-day-range-end\",\n rangeBetween: \"rmdp-day-range-between\",\n rangeHovering: \"rmdp-day-range-hovering\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n monthButtonSelected: \"bg-brand-gold text-white\",\n monthButtonUnselected: \"text-brand-text\",\n\n yearsGrid: \"grid grid-cols-3 gap-2 max-h-[210px] overflow-y-auto pr-2 animate-slide-in-top rmdp-scrollbar\",\n yearButton: \"py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n yearButtonSelected: \"bg-brand-gold text-white\",\n yearButtonUnselected: \"text-brand-text\",\n}\n\nexport interface CalendarClassNames {\n root?: string;\n header?: string;\n headerMultiMonth?: string;\n calendarsContainer?: string;\n calendarContainer?: string;\n navButtonSlotStart?: string;\n navButtonSlotEnd?: string;\n headerTitleContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: string;\n navButtonHidden?: string;\n monthYearContainer?: string;\n monthYearLabel?: string;\n monthYearButton?: string;\n\n day?: DayClassNames;\n\n monthsGrid?: string;\n monthButton?: string;\n monthButtonSelected?: string;\n monthButtonUnselected?: string;\n\n yearsGrid?: string;\n yearButton?: string;\n yearButtonSelected?: string;\n yearButtonUnselected?: string;\n}\n\nexport const mergeClassNames = (custom?: CalendarClassNames): Required<CalendarClassNames> => {\n const result = { ...defaultClassNames };\n if (!custom) return result;\n\n for (const key in custom) {\n const k = key as keyof CalendarClassNames;\n if (k === 'day' && custom.day) {\n result.day = { ...defaultClassNames.day, ...custom.day };\n } else if (custom[k]) {\n (result as any)[k] = custom[k];\n }\n }\n return result;\n};\n","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import React from 'react';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args: any) => any;\n getForwardProps: (args: any) => any;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: { back: string; forward: string };\n classNames: Required<CalendarClassNames>;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n if (calendars.length > 1 && calendars.length < 12) {\n return null;\n }\n\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n\n const headerClassName = [\n classNames.header,\n calendars.length > 1 ? classNames.headerMultiMonth : ''\n ].filter(Boolean).join(' ');\n\n const navButtonClassName = (isHidden: boolean) => [\n classNames.navButton,\n isHidden ? classNames.navButtonHidden : ''\n ].filter(Boolean).join(' ');\n\n const isNavHidden = !!(currentView && currentView !== 'days');\n\n return (\n <div className={headerClassName}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={navButtonClassName(isNavHidden)}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={classNames.monthYearContainer}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={classNames.monthYearButton}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={classNames.monthYearButton}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n <span>\n {first.year === last.year ? first.year : `${first.year} - ${last.year}`}\n </span>\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={navButtonClassName(isNavHidden)}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","import React from 'react';\nimport type { CalendarClassNames, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: any }) => any;\n dayProps?: Record<string, any>;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, dayProps, classNames }) => {\n if (!dateObj) {\n return <div className={classNames.day.empty} />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames.day;\n\n let stateClasses = \"rounded-full\";\n if (isRangeStart && isRangeEnd) {\n stateClasses = `${dayClasses.selected} rounded-full`;\n } else if (isRangeStart) {\n stateClasses = `${dayClasses.rangeStart} ${isRangeActive ? 'rounded-l-full rounded-r-none' : 'rounded-full'}`;\n } else if (isRangeEnd) {\n stateClasses = `${dayClasses.rangeEnd} ${isRangeActive ? 'rounded-r-full rounded-l-none' : 'rounded-full'}`;\n } else if (isRangeBetween) {\n stateClasses = dayClasses.rangeBetween || '';\n } else if (isRangeHovering) {\n stateClasses = dayClasses.rangeHovering || '';\n } else if (selected) {\n stateClasses = dayClasses.selected || '';\n } else if (!selectable) {\n stateClasses = dayClasses.disabled || '';\n } else {\n stateClasses = dayClasses.unselected || '';\n }\n\n const modifierClasses = (dateObj.modifiers || [])\n .map(m => (dayClasses as any)[m] || m)\n .filter(Boolean)\n .join(' ');\n\n const className = [dayClasses.day, stateClasses, modifierClasses]\n .filter(Boolean)\n .join(' ');\n\n return (\n <button\n {...getDateProps({ dateObj, ...dayProps })}\n className={className}\n >\n {date.getDate()}\n </button>\n );\n};\n","import React from 'react';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n return (\n <div className={classNames.monthsGrid}>\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n return (\n <button\n key={name}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => !disabled && onMonthSelect(idx)}\n className={`${classNames.monthButton} ${idx === month ? classNames.monthButtonSelected : classNames.monthButtonUnselected}`}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef } from 'react';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (yearListRef.current) {\n const selectedYearBtn = yearListRef.current.querySelector('[data-selected=\"true\"]');\n if (selectedYearBtn) {\n selectedYearBtn.scrollIntoView({ block: 'center' });\n }\n }\n }, []);\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n return (\n <div ref={yearListRef} className={classNames.yearsGrid}>\n {years.map((y) => (\n <button\n key={y}\n data-selected={y === year}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => onYearSelect(y)}\n className={`${classNames.yearButton} ${y === year ? classNames.yearButtonSelected : classNames.yearButtonUnselected}`}\n >\n {y}\n </button>\n ))}\n </div>\n );\n};\n","import React, { useState } from 'react';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { mergeClassNames } from '../classNames';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarClassNames, DateObj } from '../types';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { CalendarHeader, ChevronLeftIcon, ChevronRightIcon } from './CalendarHeader';\nimport { Day } from './Day';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: any) => React.ReactNode);\n footer?: React.ReactNode;\n getDayProps?: (dateObj: DateObj) => Record<string, any>;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames: customClassNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n getDayProps,\n ...useDatesProps\n } = props;\n\n const classNames = mergeClassNames(customClassNames);\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n // Adjust weekday names based on firstDayOfWeek\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const stepOffset = useDatesProps.monthsToDisplay || 1;\n\n const wrappedGetBackProps = (args: any) => {\n const props = getBackProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args: any) => {\n const props = getForwardProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div className={`rmdp ${classNames.root}`}>\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={classNames.calendarsContainer}>\n {view === 'months' && calendars.map((calendar) => (\n <div key={`months-${calendar.year}`} className={classNames.calendarContainer}>\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div key={`years-${calendar.year}`} className={classNames.calendarContainer}>\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar, index) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <div className={classNames.header}>\n <div className={classNames.navButtonSlotStart}>\n {index === 0 && calendars.length < 12 && (\n <button\n {...wrappedGetBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={classNames.navButton}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n )}\n </div>\n <span className={classNames.headerTitleContainer}>\n {monthNames[calendar.month]}\n {calendars.length < 12 ? ` ${calendar.year}` : ''}\n </span>\n <div className={classNames.navButtonSlotEnd}>\n {index === calendars.length - 1 && calendars.length < 12 && (\n <button\n {...wrappedGetForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={classNames.navButton}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n )}\n </div>\n </div>\n )}\n <div className={classNames.weekdayGrid}>\n {sortedWeekdays.map((day) => (\n <div key={day} className={classNames.weekday}>{day}</div>\n ))}\n </div>\n <div key={`daysGrid-${calendar.month}-${calendar.year}`} className={`${classNames.daysGrid} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n dayProps={dateObj ? getDayProps?.(dateObj) : undefined}\n classNames={classNames}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":";;;;;AAaA,IAAa,IAAoB;CAC/B,MAAM;CACN,QAAQ;CACR,kBAAkB;CAClB,oBAAoB;CACpB,mBAAmB;CACnB,oBAAoB;CACpB,kBAAkB;CAClB,sBAAsB;CACtB,aAAa;CACb,SAAS;CACT,UAAU;CACV,QAAQ;CAER,WAAW;CACX,iBAAiB;CACjB,oBAAoB;CACpB,gBAAgB;CAChB,iBAAiB;CAEjB,KAAK;EACH,KAAK;EACL,UAAU;EACV,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY;EACZ,UAAU;EACV,cAAc;EACd,eAAe;CACjB;CAEA,YAAY;CACZ,aAAa;CACb,qBAAqB;CACrB,uBAAuB;CAEvB,WAAW;CACX,YAAY;CACZ,oBAAoB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AK,WAAW,EAAW;IAAS,UAAA;GAAY,CAAA;EACxD;;AAET"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/components/Day.tsx","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n selectMonth?: string;\n selectYear?: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month',\n selectMonth: 'Select month',\n selectYear: 'Select year'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import clsx from 'clsx';\nimport React from 'react';\nimport { Translations } from '../i18n';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args: any) => any;\n getForwardProps: (args: any) => any;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: Translations;\n classNames?: CalendarClassNames;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n if (calendars.length > 1 && calendars.length < 12) {\n return null;\n }\n\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n\n const isNavHidden = !!(currentView && currentView !== 'days');\n const navButtonClassName = clsx(\n 'rmd-nav-button',\n isNavHidden && 'rmd-nav-button-hidden',\n classNames?.navButton,\n isNavHidden && classNames?.navButtonHidden\n );\n\n const monthYearLabelClassName = clsx(\n 'rmd-month-year-label',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.monthYearLabel\n );\n\n return (\n <div className={clsx(\n 'rmd-header',\n calendars.length > 1 && 'rmd-header-multi-month',\n classNames?.header,\n calendars.length > 1 && classNames?.headerMultiMonth\n )}>\n <button\n {...getBackProps({ calendars })}\n className={navButtonClassName}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={clsx('rmd-month-year-container', classNames?.monthYearContainer)}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={monthYearLabelClassName}>\n <button\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${monthNames[calendars[0].month]}, ${t.selectMonth || 'Select month'}`}\n aria-expanded={currentView === 'months'}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${calendars[0].year}, ${t.selectYear || 'Select year'}`}\n aria-expanded={currentView === 'years'}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={monthYearLabelClassName}>\n <span>\n {first.year === last.year ? first.year : `${first.year} - ${last.year}`}\n </span>\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n className={navButtonClassName}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","import React from 'react';\nimport clsx from 'clsx';\nimport type { CalendarClassNames, DateAdapter, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: any }) => any;\n dayProps?: Record<string, any>;\n classNames?: CalendarClassNames;\n tabIndex?: number;\n adapter?: DateAdapter;\n locale?: string;\n onKeyDown?: (e: React.KeyboardEvent, dateObj: DateObj) => void;\n onFocus?: (dateObj: DateObj) => void;\n buttonRef?: (el: HTMLButtonElement | null) => void;\n}\n\nexport const Day: React.FC<DayProps> = ({\n dateObj,\n getDateProps,\n dayProps,\n classNames,\n tabIndex = -1,\n adapter,\n locale,\n onKeyDown,\n onFocus,\n buttonRef\n}) => {\n if (!dateObj) {\n return <div role=\"gridcell\" aria-hidden=\"true\" className={clsx('rmd-day-empty', classNames?.day?.empty)} />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames?.day;\n\n let semanticStateClass = '';\n let customStateClass = '';\n\n if (isRangeStart && isRangeEnd) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (isRangeStart) {\n semanticStateClass = clsx('rmd-day-range-start', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeStart || '';\n } else if (isRangeEnd) {\n semanticStateClass = clsx('rmd-day-range-end', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeEnd || '';\n } else if (isRangeBetween) {\n semanticStateClass = 'rmd-day-range-between';\n customStateClass = dayClasses?.rangeBetween || '';\n } else if (isRangeHovering) {\n semanticStateClass = 'rmd-day-range-hovering';\n customStateClass = dayClasses?.rangeHovering || '';\n } else if (selected) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (!selectable) {\n semanticStateClass = 'rmd-day-disabled';\n customStateClass = dayClasses?.disabled || '';\n } else {\n semanticStateClass = 'rmd-day-unselected';\n customStateClass = dayClasses?.unselected || '';\n }\n\n const modifierClasses = (dateObj.modifiers || [])\n .map(m => (dayClasses as any)?.[m] || m)\n .filter(Boolean);\n\n const formattedDateLabel = adapter\n ? adapter.format(adapter.date(date), 'dddd, MMMM D, YYYY', locale)\n : date.toDateString();\n\n const isSelected = !!(selected || isRangeStart || isRangeEnd);\n\n const baseProps = getDateProps({ dateObj, ...dayProps });\n\n return (\n <button\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={!selectable}\n aria-label={formattedDateLabel}\n tabIndex={tabIndex}\n {...baseProps}\n ref={buttonRef}\n onKeyDown={(e) => {\n baseProps.onKeyDown?.(e);\n onKeyDown?.(e, dateObj);\n }}\n onFocus={(e) => {\n baseProps.onFocus?.(e);\n onFocus?.(dateObj);\n }}\n className={clsx(\n 'rmd-day',\n dayClasses?.day,\n semanticStateClass,\n customStateClass,\n modifierClasses\n )}\n >\n {date.getDate()}\n </button>\n );\n};\n","import React, { useState, useRef, useEffect } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const [focusedMonth, setFocusedMonth] = useState<number>(month);\n const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n useEffect(() => {\n buttonRefs.current[focusedMonth]?.focus();\n }, [focusedMonth]);\n\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent, idx: number) => {\n let nextIndex = focusedMonth;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextIndex = (idx - 1 + 12) % 12;\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextIndex = (idx + 1) % 12;\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextIndex = (idx - 3 + 12) % 12;\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextIndex = (idx + 3) % 12;\n break;\n case 'Home':\n e.preventDefault();\n nextIndex = 0;\n break;\n case 'End':\n e.preventDefault();\n nextIndex = 11;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!isMonthDisabled(idx)) {\n onMonthSelect(idx);\n }\n return;\n default:\n return;\n }\n\n setFocusedMonth(nextIndex);\n };\n\n const gridClassName = clsx('rmd-months-grid', classNames?.monthsGrid);\n\n return (\n <div\n role=\"grid\"\n aria-label=\"Select month\"\n className={gridClassName}\n >\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n const isSelected = idx === month;\n const isFocused = idx === focusedMonth;\n const buttonClassName = clsx(\n 'rmd-month-button',\n isSelected ? 'rmd-month-button-selected' : 'rmd-month-button-unselected',\n classNames?.monthButton,\n isSelected ? classNames?.monthButtonSelected : classNames?.monthButtonUnselected\n );\n\n return (\n <button\n key={name}\n ref={(el) => {\n buttonRefs.current[idx] = el;\n }}\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={disabled}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => !disabled && onMonthSelect(idx)}\n onKeyDown={(e) => handleKeyDown(e, idx)}\n onFocus={() => setFocusedMonth(idx)}\n className={buttonClassName}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n const [focusedYear, setFocusedYear] = useState<number>(year);\n const buttonRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years: number[] = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n useEffect(() => {\n if (yearListRef.current) {\n const container = yearListRef.current;\n const selectedYearBtn = container.querySelector('[data-selected=\"true\"]') as HTMLElement | null;\n if (selectedYearBtn) {\n const targetScrollTop =\n selectedYearBtn.offsetTop - container.clientHeight / 2 + selectedYearBtn.clientHeight / 2;\n container.scrollTop = Math.max(0, targetScrollTop);\n }\n }\n }, []);\n\n useEffect(() => {\n const btn = buttonRefs.current.get(focusedYear);\n if (btn) {\n btn.focus();\n }\n }, [focusedYear]);\n\n const handleKeyDown = (e: React.KeyboardEvent, y: number) => {\n let nextYear = focusedYear;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 1);\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 1);\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 3);\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 3);\n break;\n case 'PageUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 10);\n break;\n case 'PageDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 10);\n break;\n case 'Home':\n e.preventDefault();\n nextYear = startYear;\n break;\n case 'End':\n e.preventDefault();\n nextYear = endYear;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n onYearSelect(y);\n return;\n default:\n return;\n }\n\n setFocusedYear(nextYear);\n };\n\n return (\n <div\n ref={yearListRef}\n role=\"grid\"\n aria-label=\"Select year\"\n className={clsx('rmd-years-grid', classNames?.yearsGrid)}\n >\n {years.map((y) => {\n const isSelected = y === year;\n const isFocused = y === focusedYear;\n const buttonClassName = clsx(\n 'rmd-year-button',\n isSelected ? 'rmd-year-button-selected' : 'rmd-year-button-unselected',\n classNames?.yearButton,\n isSelected ? classNames?.yearButtonSelected : classNames?.yearButtonUnselected\n );\n\n return (\n <button\n key={y}\n ref={(el) => {\n if (el) buttonRefs.current.set(y, el);\n else buttonRefs.current.delete(y);\n }}\n data-selected={isSelected}\n role=\"gridcell\"\n aria-selected={isSelected}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => onYearSelect(y)}\n onKeyDown={(e) => handleKeyDown(e, y)}\n onFocus={() => setFocusedYear(y)}\n className={buttonClassName}\n >\n {y}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useState, useRef, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarClassNames, DateObj } from '../types';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { CalendarHeader, ChevronLeftIcon, ChevronRightIcon } from './CalendarHeader';\nimport { Day } from './Day';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: any) => React.ReactNode);\n footer?: React.ReactNode;\n getDayProps?: (dateObj: DateObj) => Record<string, any>;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nconst getDateKey = (d: Date): string =>\n `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n getDayProps,\n ...useDatesProps\n } = props;\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n const [daysHeight, setDaysHeight] = useState<number | null>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const [announcement, setAnnouncement] = useState<string>('');\n\n const daysContainerRef = useRef<HTMLDivElement | null>(null);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n const isKeyboardNavigating = useRef<boolean>(false);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n useEffect(() => {\n if (view === 'days' && daysContainerRef.current) {\n const el = daysContainerRef.current;\n const updateHeight = () => {\n if (el.offsetHeight > 0) {\n setDaysHeight(el.offsetHeight);\n }\n };\n updateHeight();\n\n if (typeof ResizeObserver !== 'undefined') {\n const observer = new ResizeObserver(() => {\n updateHeight();\n });\n observer.observe(el);\n return () => observer.disconnect();\n }\n }\n }, [view, calendars]);\n\n useEffect(() => {\n if (view === 'days' && calendars.length > 0) {\n if (calendars.length === 1) {\n setAnnouncement(`${monthNames[calendars[0].month]} ${calendars[0].year}`);\n } else {\n setAnnouncement(\n `${monthNames[calendars[0].month]} ${calendars[0].year} to ${\n monthNames[calendars[calendars.length - 1].month]\n } ${calendars[calendars.length - 1].year}`\n );\n }\n } else if (view === 'months') {\n setAnnouncement('Month selection view');\n } else if (view === 'years') {\n setAnnouncement('Year selection view');\n }\n }, [view, calendars, monthNames]);\n\n // Determine default active focused date if focusedDate is not set\n const defaultFocusedDate = useMemo(() => {\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.selected) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.today) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && !dateObj.prevMonth && !dateObj.nextMonth) {\n return dateObj.date;\n }\n }\n }\n }\n return calendars[0]?.weeks[0]?.find((d) => d?.selectable)?.date || new Date();\n }, [calendars]);\n\n const currentFocusedDate = focusedDate || defaultFocusedDate;\n\n useEffect(() => {\n if (view === 'days' && currentFocusedDate && isKeyboardNavigating.current) {\n const key = getDateKey(currentFocusedDate);\n const btn = dayButtonRefs.current.get(key);\n if (btn) {\n btn.focus();\n }\n }\n }, [currentFocusedDate, calendars, view]);\n\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const stepOffset = useDatesProps.monthsToDisplay || 1;\n\n const wrappedGetBackProps = (args: any) => {\n const props = getBackProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args: any) => {\n const props = getForwardProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const handleDayKeyDown = (e: React.KeyboardEvent, dateObj: DateObj) => {\n const isRTL = Boolean(\n rootRef.current?.closest('[dir=\"rtl\"]') ||\n (typeof document !== 'undefined' && document.documentElement.dir === 'rtl')\n );\n\n let newDate: Date | null = null;\n const current = adapter.date(dateObj.date);\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? 1 : -1, 'day'));\n break;\n case 'ArrowRight':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? -1 : 1, 'day'));\n break;\n case 'ArrowUp':\n e.preventDefault();\n newDate = adapter.toDate(adapter.subtract(current, 7, 'day'));\n break;\n case 'ArrowDown':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, 7, 'day'));\n break;\n case 'Home': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = (currentDayOfWeek - firstDayOfWeek + 7) % 7;\n newDate = adapter.toDate(adapter.subtract(current, diff, 'day'));\n break;\n }\n case 'End': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = 6 - ((currentDayOfWeek - firstDayOfWeek + 7) % 7);\n newDate = adapter.toDate(adapter.add(current, diff, 'day'));\n break;\n }\n case 'PageUp': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.subtract(current, 1, unit));\n break;\n }\n case 'PageDown': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.add(current, 1, unit));\n break;\n }\n case 'Enter':\n case ' ': {\n // Native button press handles click event\n return;\n }\n default:\n return;\n }\n\n if (newDate) {\n isKeyboardNavigating.current = true;\n setFocusedDate(newDate);\n\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const targetMonth = adapter.startOf(adapter.date(newDate), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setOffset(newOffset);\n }\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div ref={rootRef} className={clsx('rmd', 'rmd-root', classNames?.root)}>\n <div className=\"rmd-sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </div>\n\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={clsx('rmd-calendars-container', classNames?.calendarsContainer)}>\n {view === 'months' && calendars.map((calendar) => (\n <div\n key={`months-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div\n key={`years-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar, index) => (\n <div\n key={`${calendar.month}-${calendar.year}`}\n ref={index === 0 ? daysContainerRef : undefined}\n role=\"grid\"\n aria-label={`${monthNames[calendar.month]} ${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n >\n {calendars.length > 1 && (\n <div className={clsx('rmd-header', classNames?.header)}>\n <div className={clsx('rmd-nav-button-slot-start', classNames?.navButtonSlotStart)}>\n {index === 0 && calendars.length < 12 && (\n <button\n {...wrappedGetBackProps({ calendars })}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n )}\n </div>\n <span className={clsx('rmd-header-title-container', classNames?.headerTitleContainer)}>\n {monthNames[calendar.month]}\n {calendars.length < 12 ? ` ${calendar.year}` : ''}\n </span>\n <div className={clsx('rmd-nav-button-slot-end', classNames?.navButtonSlotEnd)}>\n {index === calendars.length - 1 && calendars.length < 12 && (\n <button\n {...wrappedGetForwardProps({ calendars })}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n )}\n </div>\n </div>\n )}\n <div role=\"row\" className={clsx('rmd-weekday-grid', classNames?.weekdayGrid)}>\n {sortedWeekdays.map((day) => (\n <div\n key={day}\n role=\"columnheader\"\n aria-label={day}\n className={clsx('rmd-weekday', classNames?.weekday)}\n >\n {day}\n </div>\n ))}\n </div>\n <div\n key={`daysGrid-${calendar.month}-${calendar.year}`}\n role=\"row\"\n className={clsx(\n 'rmd-days-grid',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.daysGrid\n )}\n >\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => {\n if (!dateObj) {\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={null}\n getDateProps={getDateProps}\n classNames={classNames}\n />\n );\n }\n\n const dateKey = getDateKey(dateObj.date);\n const isFocused = adapter.isSame(\n adapter.date(dateObj.date),\n adapter.date(currentFocusedDate),\n 'day'\n );\n\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n dayProps={getDayProps?.(dateObj)}\n classNames={classNames}\n tabIndex={isFocused ? 0 : -1}\n adapter={adapter}\n locale={locale}\n onKeyDown={handleDayKeyDown}\n onFocus={(dObj) => {\n setFocusedDate(dObj.date);\n }}\n buttonRef={(el) => {\n if (el) {\n dayButtonRefs.current.set(dateKey, el);\n } else {\n dayButtonRefs.current.delete(dateKey);\n }\n }}\n />\n );\n })\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={clsx('rmd-footer', classNames?.footer)}>{footer}</div>}\n </div>\n );\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;CAAG,IAAa,OAAO,KAAjB,YAA8B,OAAO,KAAjB,UAAmB,KAAG;MAAO,IAAa,OAAO,KAAjB,UAAmB;MAAG,MAAM,QAAQ,CAAC,GAAE;GAAC,IAAI,IAAE,EAAE;GAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;EAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;CAAA;CAAG,OAAO;AAAC;AAAC,SAAgB,IAAM;CAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,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,kBAAC,OAAD;SAEE,MAAK;SACL,cAAY;SACZ,WAAW,EAAK,eAAe,GAAY,OAAO;SAEjD,UAAA;QACE,GANE,CAMF,CACN;OACE,CAAA;OACL,kBAAC,OAAD;QAEE,MAAK;QACL,WAAW,EACT,iBACA,MAAmB,UAAU,kBAC7B,MAAmB,WAAW,mBAC9B,GAAY,QACd;QAEC,UAAA,EAAS,MAAM,KAAK,GAAM,MACzB,EAAK,KAAK,GAAS,MAAO;SACxB,IAAI,CAAC,GACH,OACE,kBAAC,GAAD;UAEE,SAAS;UACK;UACF;SACb,GAJM,GAAG,EAAG,GAAG,GAIf;SAIL,IAAM,IAAU,EAAW,EAAQ,IAAI,GACjC,IAAY,EAAQ,OACxB,EAAQ,KAAK,EAAQ,IAAI,GACzB,EAAQ,KAAK,CAAkB,GAC/B,KACF;SAEA,OACE,kBAAC,GAAD;UAEW;UACK;UACd,UAAU,IAAc,CAAO;UACnB;UACZ,UAAU,IAAY,IAAI;UACjB;UACD;UACR,WAAW;UACX,UAAU,MAAS;WACjB,EAAe,EAAK,IAAI;UAC1B;UACA,YAAY,MAAO;WACjB,AAAI,IACF,EAAc,QAAQ,IAAI,GAAS,CAAE,IAErC,EAAc,QAAQ,OAAO,CAAO;UAExC;SACD,GAnBM,GAAG,EAAG,GAAG,GAmBf;QAEL,CAAC,CACH;OACG,GAtDE,YAAY,EAAS,MAAM,GAAG,EAAS,MAsDzC;MACF;KAxGE,GAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MAwGhC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAK,cAAc,GAAY,MAAM;IAAI,UAAA;GAAY,CAAA;EAC7E;;AAET"}
@@ -110,89 +110,91 @@ function v({ maxDate: n, offsetMonth: r, handleOffsetChanged: a, adapter: o }, {
110
110
  ...u
111
111
  };
112
112
  }
113
- function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disabledDates: a, monthsToDisplay: c = 1, firstDayOfWeek: l = 0, showOutsideDays: u = !1, offset: d, onDateSelected: f, onOffsetChanged: y = () => {}, selected: b, modifiers: x, selectionMode: S = "single", adapter: C = p, onChange: w, onMonthChange: T, onYearChange: E }) {
114
- let [D, O] = s(0), [k, A] = s(void 0), j = h(d, D), M = o((t) => {
115
- m(d) || O(t), y(t);
116
- let n = C.toDate(C.add(C.startOf(C.date(e), "month"), t, "month"));
117
- T?.(n), E?.(n);
113
+ function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disabledDates: a, monthsToDisplay: c = 1, firstDayOfWeek: l = 0, offset: u, onDateSelected: d, onOffsetChanged: f = () => {}, selected: y, modifiers: b, selectionMode: x = "single", adapter: S = p, onChange: C, onMonthChange: w, onYearChange: T }) {
114
+ let [E, D] = s(0), [O, k] = s(void 0), A = h(u, E), j = o((t) => {
115
+ m(u) || D(t), f(t);
116
+ let n = S.add(S.startOf(S.date(e), "month"), t, "month"), r = Array.from({ length: c }, (e, t) => S.toDate(S.startOf(S.add(n, t, "month"), "month")));
117
+ w?.(r);
118
+ let i = S.toDate(n);
119
+ T?.(i);
118
120
  }, [
119
- d,
120
- y,
121
+ u,
122
+ f,
121
123
  e,
122
- C,
123
- T,
124
- E
125
- ]), N = o((e, t) => {
126
- if (f?.(e, t), w) {
127
- if (S === "single") w(e.date);
128
- else if (S === "multiple") {
129
- let t = Array.isArray(b) ? b : b ? [b] : [];
130
- t.some((t) => C.isSame(C.date(t), C.date(e.date), "day")) ? w(t.filter((t) => !C.isSame(C.date(t), C.date(e.date), "day"))) : w([...t, e.date]);
131
- } else if (S === "range") {
132
- let t = b && typeof b == "object" && !(b instanceof Date) && !Array.isArray(b) ? b : {
124
+ S,
125
+ c,
126
+ w,
127
+ T
128
+ ]), M = o((e, t) => {
129
+ if (d?.(e, t), C) {
130
+ if (x === "single") C(e.date);
131
+ else if (x === "multiple") {
132
+ let t = Array.isArray(y) ? y : y ? [y] : [];
133
+ t.some((t) => S.isSame(S.date(t), S.date(e.date), "day")) ? C(t.filter((t) => !S.isSame(S.date(t), S.date(e.date), "day"))) : C([...t, e.date]);
134
+ } else if (x === "range") {
135
+ let t = y && typeof y == "object" && !(y instanceof Date) && !Array.isArray(y) ? y : {
133
136
  start: void 0,
134
137
  end: void 0
135
138
  };
136
- !t.start || t.start && t.end ? w({
139
+ !t.start || t.start && t.end ? C({
137
140
  start: e.date,
138
141
  end: void 0
139
- }) : C.isBefore(C.date(e.date), C.date(t.start), "day") ? w({
142
+ }) : S.isBefore(S.date(e.date), S.date(t.start), "day") ? C({
140
143
  start: e.date,
141
144
  end: t.start
142
- }) : w({
145
+ }) : C({
143
146
  start: t.start,
144
147
  end: e.date
145
148
  });
146
149
  }
147
150
  }
148
151
  }, [
149
- f,
150
- w,
151
- S,
152
- b,
153
- C
152
+ d,
153
+ C,
154
+ x,
155
+ y,
156
+ S
154
157
  ]);
155
158
  return {
156
159
  calendars: n({
157
160
  date: e,
158
- selected: b,
161
+ selected: y,
159
162
  disabledDates: a,
160
- modifiers: x,
163
+ modifiers: b,
161
164
  monthsToDisplay: c,
162
165
  minDate: i,
163
166
  maxDate: r,
164
- offset: j,
167
+ offset: A,
165
168
  firstDayOfWeek: l,
166
- showOutsideDays: u,
167
- adapter: C,
168
- selectionMode: S,
169
- hoveredDate: k
169
+ adapter: S,
170
+ selectionMode: x,
171
+ hoveredDate: O
170
172
  }),
171
173
  getDateProps: (e) => ({
172
- ...g(N, e),
174
+ ...g(M, e),
173
175
  onMouseEnter: t(e.onMouseEnter, () => {
174
- A(e.dateObj.date);
176
+ k(e.dateObj.date);
175
177
  }),
176
178
  onMouseLeave: t(e.onMouseLeave, () => {
177
- A(void 0);
179
+ k(void 0);
178
180
  })
179
181
  }),
180
182
  getBackProps: _.bind(null, {
181
183
  minDate: i,
182
- offsetMonth: j,
183
- handleOffsetChanged: M,
184
- adapter: C
184
+ offsetMonth: A,
185
+ handleOffsetChanged: j,
186
+ adapter: S
185
187
  }),
186
188
  getForwardProps: v.bind(null, {
187
189
  maxDate: r,
188
- offsetMonth: j,
189
- handleOffsetChanged: M,
190
- adapter: C
190
+ offsetMonth: A,
191
+ handleOffsetChanged: j,
192
+ adapter: S
191
193
  }),
192
- setOffset: M
194
+ setOffset: j
193
195
  };
194
196
  }
195
197
  //#endregion
196
198
  export { f as n, p as r, y as t };
197
199
 
198
- //# sourceMappingURL=useDates-CjPuu-VA.js.map
200
+ //# sourceMappingURL=useDates-BVAPuyDo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDates-BVAPuyDo.js","names":[],"sources":["../src/adapters/dayjs.ts","../src/useDates.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport type { DateAdapter } from '../types';\n\ndayjs.extend(isBetween);\ndayjs.extend(customParseFormat);\ndayjs.extend(localeData);\n\nexport class DayjsAdapter implements DateAdapter<Dayjs> {\n date(value?: any): Dayjs {\n return dayjs(value);\n }\n\n add(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.add(amount, unit);\n }\n\n subtract(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.subtract(amount, unit);\n }\n\n startOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.startOf(unit);\n }\n\n endOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.endOf(unit);\n }\n\n isBefore(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isBefore(comparison, unit);\n }\n\n isAfter(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isAfter(comparison, unit);\n }\n\n isSame(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isSame(comparison, unit);\n }\n\n set(date: Dayjs, unit: 'day' | 'month' | 'year', value: number): Dayjs {\n if (unit === 'day') return date.date(value);\n return date.set(unit, value);\n }\n\n get(date: Dayjs, unit: 'day' | 'month' | 'year'): number {\n if (unit === 'day') return date.date();\n return date.get(unit);\n }\n\n format(date: Dayjs, formatStr: string, locale?: string): string {\n if (locale) {\n return date.locale(locale).format(formatStr);\n }\n return date.format(formatStr);\n }\n\n getDaysInMonth(date: Dayjs): number {\n return date.daysInMonth();\n }\n\n toDate(date: Dayjs): Date {\n return date.toDate();\n }\n\n diff(date: Dayjs, comparison: Dayjs, unit: 'month' | 'year'): number {\n return date.diff(comparison, unit);\n }\n\n getMonths(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().months() : dayjs.localeData().months();\n }\n\n getWeekdays(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().weekdaysShort().map(d => d.toUpperCase()) : dayjs.localeData().weekdaysShort().map(d => d.toUpperCase());\n }\n}\n\nexport const defaultAdapter = new DayjsAdapter();\n","import { useState, useCallback } from 'react';\nimport type { DateAdapter, DateObj, SelectionMode, Calendar } from './types';\nimport { defaultAdapter } from './adapters/dayjs';\nimport {\n addMonth,\n composeEventHandlers,\n getCalendars,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth\n} from './utils';\n\nfunction isOffsetControlled(propOffset?: number) {\n return propOffset !== undefined;\n}\n\nfunction getOffset(prop?: number, state: number = 0): number {\n return isOffsetControlled(prop) ? prop! : state;\n}\n\nfunction getDateProps(\n onDateSelected: (dateObj: DateObj, event: any) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: any) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps(\n { minDate, offsetMonth, handleOffsetChanged, adapter }: { minDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth - subtractMonth({ calendars, offset, minDate, adapter })\n );\n }),\n disabled: isBackDisabled({ calendars, minDate, adapter }),\n ...rest\n };\n}\n\nfunction getForwardProps(\n { maxDate, offsetMonth, handleOffsetChanged, adapter }: { maxDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth + addMonth({ calendars, offset, maxDate, adapter })\n );\n }),\n disabled: isForwardDisabled({ calendars, maxDate, adapter }),\n ...rest\n };\n}\n\nexport interface UseDatesProps {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: any) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date };\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (dates: Date[]) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const startDate = adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month');\n const firstDays = Array.from({ length: monthsToDisplay }, (_, i) =>\n adapter.toDate(adapter.startOf(adapter.add(startDate, i, 'month'), 'month'))\n );\n onMonthChange?.(firstDays);\n\n const newDate = adapter.toDate(startDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, monthsToDisplay, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: any) => {\n onDateSelected?.(dateObj, event);\n\n if (!onChange) return;\n\n if (selectionMode === 'single') {\n onChange(dateObj.date);\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(selected) ? selected : (selected ? [selected as Date] : []);\n const isAlreadySelected = currentSelected.some(d => adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day'));\n if (isAlreadySelected) {\n onChange(currentSelected.filter(d => !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')));\n } else {\n onChange([...currentSelected, dateObj.date]);\n }\n } else if (selectionMode === 'range') {\n const range = (selected && typeof selected === 'object' && !(selected instanceof Date) && !Array.isArray(selected)) ? (selected as { start?: Date, end?: Date }) : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n onChange({ start: dateObj.date, end: undefined });\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n onChange({ start: dateObj.date, end: range.start });\n } else {\n onChange({ start: range.start, end: dateObj.date });\n }\n }\n }\n }, [onDateSelected, onChange, selectionMode, selected, adapter]);\n\n const calendars = getCalendars({\n date,\n selected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: (args: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }) => {\n const props = getDateProps(handleDateSelected, args);\n return {\n ...props,\n onMouseEnter: composeEventHandlers(args.onMouseEnter, () => {\n setHoveredDate(args.dateObj.date);\n }),\n onMouseLeave: composeEventHandlers(args.onMouseLeave, () => {\n setHoveredDate(undefined);\n })\n };\n },\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n setOffset: handleOffsetChanged\n };\n}\n"],"mappings":";;;;;;AAOA,EAAM,OAAO,CAAS,GACtB,EAAM,OAAO,CAAiB,GAC9B,EAAM,OAAO,CAAU;AAEvB,IAAa,IAAb,MAAwD;CACtD,KAAK,GAAoB;EACvB,OAAO,EAAM,CAAK;CACpB;CAEA,IAAI,GAAa,GAAgB,GAAuC;EACtE,OAAO,EAAK,IAAI,GAAQ,CAAI;CAC9B;CAEA,SAAS,GAAa,GAAgB,GAAuC;EAC3E,OAAO,EAAK,SAAS,GAAQ,CAAI;CACnC;CAEA,QAAQ,GAAa,GAAuC;EAC1D,OAAO,EAAK,QAAQ,CAAI;CAC1B;CAEA,MAAM,GAAa,GAAuC;EACxD,OAAO,EAAK,MAAM,CAAI;CACxB;CAEA,SAAS,GAAa,GAAmB,GAA0C;EACjF,OAAO,EAAK,SAAS,GAAY,CAAI;CACvC;CAEA,QAAQ,GAAa,GAAmB,GAA0C;EAChF,OAAO,EAAK,QAAQ,GAAY,CAAI;CACtC;CAEA,OAAO,GAAa,GAAmB,GAA0C;EAC/E,OAAO,EAAK,OAAO,GAAY,CAAI;CACrC;CAEA,IAAI,GAAa,GAAgC,GAAsB;EAErE,OADI,MAAS,QAAc,EAAK,KAAK,CAAK,IACnC,EAAK,IAAI,GAAM,CAAK;CAC7B;CAEA,IAAI,GAAa,GAAwC;EAEvD,OADI,MAAS,QAAc,EAAK,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oB;IACxD,EAAe,EAAK,QAAQ,IAAI;GACpC,CAAC;GACD,cAAc,EAAqB,EAAK,oBAAoB;IACxD,EAAe,KAAA,CAAS;GAC5B,CAAC;EACL;EAEJ,cAAc,EAAa,KAAK,MAAM;GAClC;GACA;GACA;GACA;EACJ,CAAC;EACD,iBAAiB,EAAgB,KAAK,MAAM;GACxC;GACA;GACA;GACA;EACJ,CAAC;EACD,WAAW;CACf;AACJ"}
@@ -1,2 +1,2 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./utils.cjs");let l=require("react"),u=require("dayjs");u=s(u,1);let d=require("dayjs/plugin/isBetween");d=s(d,1);let f=require("dayjs/plugin/customParseFormat");f=s(f,1);let p=require("dayjs/plugin/localeData");p=s(p,1),u.default.extend(d.default),u.default.extend(f.default),u.default.extend(p.default);var m=class{date(e){return(0,u.default)(e)}add(e,t,n){return e.add(t,n)}subtract(e,t,n){return e.subtract(t,n)}startOf(e,t){return e.startOf(t)}endOf(e,t){return e.endOf(t)}isBefore(e,t,n){return e.isBefore(t,n)}isAfter(e,t,n){return e.isAfter(t,n)}isSame(e,t,n){return e.isSame(t,n)}set(e,t,n){return t===`day`?e.date(n):e.set(t,n)}get(e,t){return t===`day`?e.date():e.get(t)}format(e,t,n){return n?e.locale(n).format(t):e.format(t)}getDaysInMonth(e){return e.daysInMonth()}toDate(e){return e.toDate()}diff(e,t,n){return e.diff(t,n)}getMonths(e){return e?(0,u.default)().locale(e).localeData().months():u.default.localeData().months()}getWeekdays(e){return e?(0,u.default)().locale(e).localeData().weekdaysShort().map(e=>e.toUpperCase()):u.default.localeData().weekdaysShort().map(e=>e.toUpperCase())}},h=new m;function g(e){return e!==void 0}function _(e,t=0){return g(e)?e:t}function v(e,{onClick:t,dateObj:n,...r}){return{onClick:c.composeEventHandlers(t,t=>{e(n,t)}),disabled:!n.selectable,"aria-pressed":n.selected,role:`button`,...r}}function y({minDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t-c.subtractMonth({calendars:o,offset:a,minDate:e,adapter:r}))}),disabled:c.isBackDisabled({calendars:o,minDate:e,adapter:r}),...s}}function b({maxDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t+c.addMonth({calendars:o,offset:a,maxDate:e,adapter:r}))}),disabled:c.isForwardDisabled({calendars:o,maxDate:e,adapter:r}),...s}}function x({date:e=new Date,maxDate:t,minDate:n,disabledDates:r,monthsToDisplay:i=1,firstDayOfWeek:a=0,showOutsideDays:o=!1,offset:s,onDateSelected:u,onOffsetChanged:d=()=>{},selected:f,modifiers:p,selectionMode:m=`single`,adapter:x=h,onChange:S,onMonthChange:C,onYearChange:w}){let[T,E]=(0,l.useState)(0),[D,O]=(0,l.useState)(void 0),k=_(s,T),A=(0,l.useCallback)(t=>{g(s)||E(t),d(t);let n=x.toDate(x.add(x.startOf(x.date(e),`month`),t,`month`));C?.(n),w?.(n)},[s,d,e,x,C,w]),j=(0,l.useCallback)((e,t)=>{if(u?.(e,t),S){if(m===`single`)S(e.date);else if(m===`multiple`){let t=Array.isArray(f)?f:f?[f]:[];t.some(t=>x.isSame(x.date(t),x.date(e.date),`day`))?S(t.filter(t=>!x.isSame(x.date(t),x.date(e.date),`day`))):S([...t,e.date])}else if(m===`range`){let t=f&&typeof f==`object`&&!(f instanceof Date)&&!Array.isArray(f)?f:{start:void 0,end:void 0};!t.start||t.start&&t.end?S({start:e.date,end:void 0}):x.isBefore(x.date(e.date),x.date(t.start),`day`)?S({start:e.date,end:t.start}):S({start:t.start,end:e.date})}}},[u,S,m,f,x]);return{calendars:c.getCalendars({date:e,selected:f,disabledDates:r,modifiers:p,monthsToDisplay:i,minDate:n,maxDate:t,offset:k,firstDayOfWeek:a,showOutsideDays:o,adapter:x,selectionMode:m,hoveredDate:D}),getDateProps:e=>({...v(j,e),onMouseEnter:c.composeEventHandlers(e.onMouseEnter,()=>{O(e.dateObj.date)}),onMouseLeave:c.composeEventHandlers(e.onMouseLeave,()=>{O(void 0)})}),getBackProps:y.bind(null,{minDate:n,offsetMonth:k,handleOffsetChanged:A,adapter:x}),getForwardProps:b.bind(null,{maxDate:t,offsetMonth:k,handleOffsetChanged:A,adapter:x}),setOffset:A}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
2
- //# sourceMappingURL=useDates-c17u4Qfs.cjs.map
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./utils.cjs");let l=require("react"),u=require("dayjs");u=s(u,1);let d=require("dayjs/plugin/isBetween");d=s(d,1);let f=require("dayjs/plugin/customParseFormat");f=s(f,1);let p=require("dayjs/plugin/localeData");p=s(p,1),u.default.extend(d.default),u.default.extend(f.default),u.default.extend(p.default);var m=class{date(e){return(0,u.default)(e)}add(e,t,n){return e.add(t,n)}subtract(e,t,n){return e.subtract(t,n)}startOf(e,t){return e.startOf(t)}endOf(e,t){return e.endOf(t)}isBefore(e,t,n){return e.isBefore(t,n)}isAfter(e,t,n){return e.isAfter(t,n)}isSame(e,t,n){return e.isSame(t,n)}set(e,t,n){return t===`day`?e.date(n):e.set(t,n)}get(e,t){return t===`day`?e.date():e.get(t)}format(e,t,n){return n?e.locale(n).format(t):e.format(t)}getDaysInMonth(e){return e.daysInMonth()}toDate(e){return e.toDate()}diff(e,t,n){return e.diff(t,n)}getMonths(e){return e?(0,u.default)().locale(e).localeData().months():u.default.localeData().months()}getWeekdays(e){return e?(0,u.default)().locale(e).localeData().weekdaysShort().map(e=>e.toUpperCase()):u.default.localeData().weekdaysShort().map(e=>e.toUpperCase())}},h=new m;function g(e){return e!==void 0}function _(e,t=0){return g(e)?e:t}function v(e,{onClick:t,dateObj:n,...r}){return{onClick:c.composeEventHandlers(t,t=>{e(n,t)}),disabled:!n.selectable,"aria-pressed":n.selected,role:`button`,...r}}function y({minDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t-c.subtractMonth({calendars:o,offset:a,minDate:e,adapter:r}))}),disabled:c.isBackDisabled({calendars:o,minDate:e,adapter:r}),...s}}function b({maxDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t+c.addMonth({calendars:o,offset:a,maxDate:e,adapter:r}))}),disabled:c.isForwardDisabled({calendars:o,maxDate:e,adapter:r}),...s}}function x({date:e=new Date,maxDate:t,minDate:n,disabledDates:r,monthsToDisplay:i=1,firstDayOfWeek:a=0,offset:o,onDateSelected:s,onOffsetChanged:u=()=>{},selected:d,modifiers:f,selectionMode:p=`single`,adapter:m=h,onChange:x,onMonthChange:S,onYearChange:C}){let[w,T]=(0,l.useState)(0),[E,D]=(0,l.useState)(void 0),O=_(o,w),k=(0,l.useCallback)(t=>{g(o)||T(t),u(t);let n=m.add(m.startOf(m.date(e),`month`),t,`month`),r=Array.from({length:i},(e,t)=>m.toDate(m.startOf(m.add(n,t,`month`),`month`)));S?.(r);let a=m.toDate(n);C?.(a)},[o,u,e,m,i,S,C]),A=(0,l.useCallback)((e,t)=>{if(s?.(e,t),x){if(p===`single`)x(e.date);else if(p===`multiple`){let t=Array.isArray(d)?d:d?[d]:[];t.some(t=>m.isSame(m.date(t),m.date(e.date),`day`))?x(t.filter(t=>!m.isSame(m.date(t),m.date(e.date),`day`))):x([...t,e.date])}else if(p===`range`){let t=d&&typeof d==`object`&&!(d instanceof Date)&&!Array.isArray(d)?d:{start:void 0,end:void 0};!t.start||t.start&&t.end?x({start:e.date,end:void 0}):m.isBefore(m.date(e.date),m.date(t.start),`day`)?x({start:e.date,end:t.start}):x({start:t.start,end:e.date})}}},[s,x,p,d,m]);return{calendars:c.getCalendars({date:e,selected:d,disabledDates:r,modifiers:f,monthsToDisplay:i,minDate:n,maxDate:t,offset:O,firstDayOfWeek:a,adapter:m,selectionMode:p,hoveredDate:E}),getDateProps:e=>({...v(A,e),onMouseEnter:c.composeEventHandlers(e.onMouseEnter,()=>{D(e.dateObj.date)}),onMouseLeave:c.composeEventHandlers(e.onMouseLeave,()=>{D(void 0)})}),getBackProps:y.bind(null,{minDate:n,offsetMonth:O,handleOffsetChanged:k,adapter:m}),getForwardProps:b.bind(null,{maxDate:t,offsetMonth:O,handleOffsetChanged:k,adapter:m}),setOffset:k}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
2
+ //# sourceMappingURL=useDates-DqKgwgF7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDates-DqKgwgF7.cjs","names":[],"sources":["../src/adapters/dayjs.ts","../src/useDates.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport type { DateAdapter } from '../types';\n\ndayjs.extend(isBetween);\ndayjs.extend(customParseFormat);\ndayjs.extend(localeData);\n\nexport class DayjsAdapter implements DateAdapter<Dayjs> {\n date(value?: any): Dayjs {\n return dayjs(value);\n }\n\n add(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.add(amount, unit);\n }\n\n subtract(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.subtract(amount, unit);\n }\n\n startOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.startOf(unit);\n }\n\n endOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.endOf(unit);\n }\n\n isBefore(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isBefore(comparison, unit);\n }\n\n isAfter(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isAfter(comparison, unit);\n }\n\n isSame(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isSame(comparison, unit);\n }\n\n set(date: Dayjs, unit: 'day' | 'month' | 'year', value: number): Dayjs {\n if (unit === 'day') return date.date(value);\n return date.set(unit, value);\n }\n\n get(date: Dayjs, unit: 'day' | 'month' | 'year'): number {\n if (unit === 'day') return date.date();\n return date.get(unit);\n }\n\n format(date: Dayjs, formatStr: string, locale?: string): string {\n if (locale) {\n return date.locale(locale).format(formatStr);\n }\n return date.format(formatStr);\n }\n\n getDaysInMonth(date: Dayjs): number {\n return date.daysInMonth();\n }\n\n toDate(date: Dayjs): Date {\n return date.toDate();\n }\n\n diff(date: Dayjs, comparison: Dayjs, unit: 'month' | 'year'): number {\n return date.diff(comparison, unit);\n }\n\n getMonths(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().months() : dayjs.localeData().months();\n }\n\n getWeekdays(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().weekdaysShort().map(d => d.toUpperCase()) : dayjs.localeData().weekdaysShort().map(d => d.toUpperCase());\n }\n}\n\nexport const defaultAdapter = new DayjsAdapter();\n","import { useState, useCallback } from 'react';\nimport type { DateAdapter, DateObj, SelectionMode, Calendar } from './types';\nimport { defaultAdapter } from './adapters/dayjs';\nimport {\n addMonth,\n composeEventHandlers,\n getCalendars,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth\n} from './utils';\n\nfunction isOffsetControlled(propOffset?: number) {\n return propOffset !== undefined;\n}\n\nfunction getOffset(prop?: number, state: number = 0): number {\n return isOffsetControlled(prop) ? prop! : state;\n}\n\nfunction getDateProps(\n onDateSelected: (dateObj: DateObj, event: any) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: any) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps(\n { minDate, offsetMonth, handleOffsetChanged, adapter }: { minDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth - subtractMonth({ calendars, offset, minDate, adapter })\n );\n }),\n disabled: isBackDisabled({ calendars, minDate, adapter }),\n ...rest\n };\n}\n\nfunction getForwardProps(\n { maxDate, offsetMonth, handleOffsetChanged, adapter }: { maxDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth + addMonth({ calendars, offset, maxDate, adapter })\n );\n }),\n disabled: isForwardDisabled({ calendars, maxDate, adapter }),\n ...rest\n };\n}\n\nexport interface UseDatesProps {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: any) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date };\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (dates: Date[]) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const startDate = adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month');\n const firstDays = Array.from({ length: monthsToDisplay }, (_, i) =>\n adapter.toDate(adapter.startOf(adapter.add(startDate, i, 'month'), 'month'))\n );\n onMonthChange?.(firstDays);\n\n const newDate = adapter.toDate(startDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, monthsToDisplay, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: any) => {\n onDateSelected?.(dateObj, event);\n\n if (!onChange) return;\n\n if (selectionMode === 'single') {\n onChange(dateObj.date);\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(selected) ? selected : (selected ? [selected as Date] : []);\n const isAlreadySelected = currentSelected.some(d => adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day'));\n if (isAlreadySelected) {\n onChange(currentSelected.filter(d => !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')));\n } else {\n onChange([...currentSelected, dateObj.date]);\n }\n } else if (selectionMode === 'range') {\n const range = (selected && typeof selected === 'object' && !(selected instanceof Date) && !Array.isArray(selected)) ? (selected as { start?: Date, end?: Date }) : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n onChange({ start: dateObj.date, end: undefined });\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n onChange({ start: dateObj.date, end: range.start });\n } else {\n onChange({ start: range.start, end: dateObj.date });\n }\n }\n }\n }, [onDateSelected, onChange, selectionMode, selected, adapter]);\n\n const calendars = getCalendars({\n date,\n selected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: (args: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }) => {\n const props = getDateProps(handleDateSelected, args);\n return {\n ...props,\n onMouseEnter: composeEventHandlers(args.onMouseEnter, () => {\n setHoveredDate(args.dateObj.date);\n }),\n onMouseLeave: composeEventHandlers(args.onMouseLeave, () => {\n setHoveredDate(undefined);\n })\n };\n },\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n setOffset: handleOffsetChanged\n };\n}\n"],"mappings":"kuBAOA,EAAA,QAAM,OAAO,EAAA,OAAS,EACtB,EAAA,QAAM,OAAO,EAAA,OAAiB,EAC9B,EAAA,QAAM,OAAO,EAAA,OAAU,EAEvB,IAAa,EAAb,KAAwD,CACtD,KAAK,EAAoB,CACvB,OAAA,EAAO,EAAA,QAAA,CAAM,CAAK,CACpB,CAEA,IAAI,EAAa,EAAgB,EAAuC,CACtE,OAAO,EAAK,IAAI,EAAQ,CAAI,CAC9B,CAEA,SAAS,EAAa,EAAgB,EAAuC,CAC3E,OAAO,EAAK,SAAS,EAAQ,CAAI,CACnC,CAEA,QAAQ,EAAa,EAAuC,CAC1D,OAAO,EAAK,QAAQ,CAAI,CAC1B,CAEA,MAAM,EAAa,EAAuC,CACxD,OAAO,EAAK,MAAM,CAAI,CACxB,CAEA,SAAS,EAAa,EAAmB,EAA0C,CACjF,OAAO,EAAK,SAAS,EAAY,CAAI,CACvC,CAEA,QAAQ,EAAa,EAAmB,EAA0C,CAChF,OAAO,EAAK,QAAQ,EAAY,CAAI,CACtC,CAEA,OAAO,EAAa,EAAmB,EAA0C,CAC/E,OAAO,EAAK,OAAO,EAAY,CAAI,CACrC,CAEA,IAAI,EAAa,EAAgC,EAAsB,CAErE,OADI,IAAS,MAAc,EAAK,KAAK,CAAK,EACnC,EAAK,IAAI,EAAM,CAAK,CAC7B,CAEA,IAAI,EAAa,EAAwC,CAEvD,OADI,IAAS,MAAc,EAAK,KAAK,EAC9B,EAAK,IAAI,CAAI,CACtB,CAEA,OAAO,EAAa,EAAmB,EAAyB,CAI9D,OAHI,EACK,EAAK,OAAO,CAAM,CAAC,CAAC,OAAO,CAAS,EAEtC,EAAK,OAAO,CAAS,CAC9B,C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AAQ,IAAI,CACpC,CAAC,EACD,aAAc,EAAA,qBAAqB,EAAK,iBAAoB,CACxD,EAAe,IAAA,EAAS,CAC5B,CAAC,CACL,GAEJ,aAAc,EAAa,KAAK,KAAM,CAClC,UACA,cACA,sBACA,SACJ,CAAC,EACD,gBAAiB,EAAgB,KAAK,KAAM,CACxC,UACA,cACA,sBACA,SACJ,CAAC,EACD,UAAW,CACf,CACJ"}
package/dist/useDates.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-c17u4Qfs.cjs");require("./utils.cjs"),exports.useDates=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-DqKgwgF7.cjs");require("./utils.cjs"),exports.useDates=e.t;
@@ -6,7 +6,6 @@ export interface UseDatesProps {
6
6
  disabledDates?: Date[];
7
7
  monthsToDisplay?: number;
8
8
  firstDayOfWeek?: number;
9
- showOutsideDays?: boolean;
10
9
  offset?: number;
11
10
  onDateSelected?: (dateObj: DateObj, event: any) => void;
12
11
  onOffsetChanged?: (newOffset: number) => void;
@@ -21,10 +20,10 @@ export interface UseDatesProps {
21
20
  start?: Date;
22
21
  end?: Date;
23
22
  } | null) => void;
24
- onMonthChange?: (date: Date) => void;
23
+ onMonthChange?: (dates: Date[]) => void;
25
24
  onYearChange?: (date: Date) => void;
26
25
  }
27
- export declare function useDates({ date, maxDate, minDate, disabledDates, monthsToDisplay, firstDayOfWeek, showOutsideDays, offset, onDateSelected, onOffsetChanged, selected, modifiers, selectionMode, adapter, onChange, onMonthChange, onYearChange }: UseDatesProps): {
26
+ export declare function useDates({ date, maxDate, minDate, disabledDates, monthsToDisplay, firstDayOfWeek, offset, onDateSelected, onOffsetChanged, selected, modifiers, selectionMode, adapter, onChange, onMonthChange, onYearChange }: UseDatesProps): {
28
27
  calendars: Calendar[];
29
28
  getDateProps: (args: {
30
29
  onClick?: (event: any) => void;
package/dist/useDates.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./useDates-CjPuu-VA.js";
1
+ import { t as e } from "./useDates-BVAPuyDo.js";
2
2
  import "./utils.js";
3
3
  export { e as useDates };
package/dist/utils.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(...e){return(t,...n)=>e.some(e=>(e&&e(t,...n),t&&t.defaultPrevented))}function t({calendars:e,offset:t,minDate:n,adapter:r}){let i=e[0].firstDayOfMonth,a=r.subtract(r.date(i),t,`month`);return n&&r.isBefore(a,r.startOf(r.date(n),`month`))?r.diff(r.startOf(r.date(i),`month`),r.startOf(r.date(n),`month`),`month`):t}function n({calendars:e,offset:t,maxDate:n,adapter:r}){let i=e[e.length-1].firstDayOfMonth,a=r.add(r.date(i),t,`month`);return n&&r.isAfter(a,r.startOf(r.date(n),`month`))?r.diff(r.startOf(r.date(n),`month`),r.startOf(r.date(i),`month`),`month`):t}function r({date:e,selected:t,disabledDates:n,modifiers:r,monthsToDisplay:a,minDate:o,maxDate:s,offset:c,firstDayOfWeek:l,showOutsideDays:u,adapter:d,selectionMode:f,hoveredDate:p}){let m=[],h=d.add(d.startOf(d.date(e),`month`),c,`month`);for(let e=0;e<a;e++){let a=d.add(h,e,`month`);m.push(i({month:d.get(a,`month`),year:d.get(a,`year`),selectedDates:t,disabledDates:n,modifiers:r,minDate:o,maxDate:s,firstDayOfWeek:l,showOutsideDays:u,adapter:d,selectionMode:f,hoveredDate:p}))}return m}function i({month:e,year:t,selectedDates:n,disabledDates:r,modifiers:i,minDate:l,maxDate:u,firstDayOfWeek:d,showOutsideDays:f,adapter:p,selectionMode:m,hoveredDate:h}){let g=p.set(p.set(p.date(),`year`,t),`month`,e);e=p.get(g,`month`),t=p.get(g,`year`);let _=p.getDaysInMonth(g),v=[];for(let o=1;o<=_;o++){let s=a(p.toDate(p.set(g,`day`,o)),n,r,i,l,u,p,m,!1,h,e,t);v.push(s)}let y=p.toDate(p.startOf(g,`month`)),b=p.toDate(p.endOf(g,`month`)),x=o({firstDayOfMonth:y,minDate:l,maxDate:u,selectedDates:n,disabledDates:r,modifiers:i,firstDayOfWeek:d,showOutsideDays:f,adapter:p,selectionMode:m,hoveredDate:h,month:e,year:t}),S=s({lastDayOfMonth:b,minDate:l,maxDate:u,selectedDates:n,disabledDates:r,modifiers:i,firstDayOfWeek:d,showOutsideDays:f,adapter:p,selectionMode:m,hoveredDate:h,month:e,year:t});v.unshift(...x),v.push(...S);let C=c(v);return{firstDayOfMonth:y,lastDayOfMonth:b,month:e,year:t,weeks:C}}function a(e,t,n,r,i,a,o,s,c=!1,d,f,p){let{selected:m,isRangeStart:h,isRangeEnd:g,isRangeBetween:_,isRangeHovering:v,isRangeActive:y}=l(t,e,o,s,d),b=o.isSame(o.date(e),o.date(),`day`),x=c&&o.isBefore(o.date(e),o.startOf(o.date(e),`month`)),S=c&&o.isAfter(o.date(e),o.endOf(o.date(e),`month`)),C={"text-brand-gold border border-brand-gold":e=>o.isSame(o.date(e),o.date(),`day`),"text-white cursor-default!":(e,t)=>o.get(o.date(e),`month`)!==t,...r},w=Object.keys(C).filter(t=>C[t](e,f??o.get(o.date(e),`month`),p??o.get(o.date(e),`year`)));return b&&w.push(`today`),c&&w.push(`outside`),x&&w.push(`prev-month`),S&&w.push(`next-month`),{date:e,selected:m,modifiers:w,selectable:u(i,a,n,e,o),today:b,prevMonth:x,nextMonth:S,isRangeStart:h,isRangeEnd:g,isRangeBetween:_,isRangeHovering:v,isRangeActive:y}}function o({firstDayOfMonth:e,minDate:t,maxDate:n,selectedDates:r,disabledDates:i,modifiers:o,firstDayOfWeek:s,showOutsideDays:c,adapter:l,selectionMode:u,hoveredDate:d,month:f,year:p}){let m=[],h=(l.toDate(l.date(e)).getDay()+7-s)%7,g=l.subtract(l.date(e),1,`day`);for(let e=0;e<h;e++){let e=a(l.toDate(g),r,i,o,t,n,l,u,!0,d,f,p);e.prevMonth=!0,c||(e.selectable=!1),m.unshift(e),g=l.subtract(g,1,`day`)}return m}function s({lastDayOfMonth:e,minDate:t,maxDate:n,selectedDates:r,disabledDates:i,modifiers:o,firstDayOfWeek:s,showOutsideDays:c,adapter:l,selectionMode:u,hoveredDate:d,month:f,year:p}){let m=[],h=(l.toDate(l.date(e)).getDay()+7-s)%7,g=l.add(l.date(e),1,`day`);for(let e=0;e<6-h;e++){let e=a(l.toDate(g),r,i,o,t,n,l,u,!0,d,f,p);e.nextMonth=!0,c||(e.selectable=!1),m.push(e),g=l.add(g,1,`day`)}return m}function c(e){let t=Math.ceil(e.length/7),n=[];for(let r=0;r<t;r++){n[r]=[];for(let t=0;t<7;t++)n[r].push(e[r*7+t])}return n}function l(e,t,n,r,i){if(!e&&!i)return{selected:!1};let a=n.date(t);if(r===`single`&&e instanceof Date)return{selected:n.isSame(a,n.date(e),`day`)};if(r===`multiple`&&Array.isArray(e))return{selected:e.some(e=>n.isSame(a,n.date(e),`day`))};if(r===`range`){let{start:t,end:r}=e&&typeof e==`object`&&!(e instanceof Date)&&!Array.isArray(e)?e:{start:void 0,end:void 0},o=t?n.isSame(a,n.date(t),`day`):!1,s=r?n.isSame(a,n.date(r),`day`):!1,c=t&&r?n.isAfter(a,n.date(t),`day`)&&n.isBefore(a,n.date(r),`day`):!1,l=!1;if(t&&!r&&i){let e=n.date(i),r=n.date(t);n.isAfter(e,r,`day`)?(l=n.isAfter(a,r,`day`)&&n.isBefore(a,e,`day`)||n.isSame(a,e,`day`),n.isSame(a,e,`day`)&&(s=!0)):n.isBefore(e,r,`day`)&&(l=n.isAfter(a,e,`day`)&&n.isBefore(a,r,`day`)||n.isSame(a,e,`day`),n.isSame(a,e,`day`)&&(o=!0),n.isSame(a,r,`day`)&&(o=!1,s=!0))}let u=!!(t&&r&&!n.isSame(n.date(t),n.date(r),`day`)||t&&!r&&i&&!n.isSame(n.date(t),n.date(i),`day`));return{selected:o||s||c,isRangeStart:o,isRangeEnd:s,isRangeBetween:c,isRangeHovering:l,isRangeActive:u}}return Array.isArray(e)&&e.length===1&&r===`single`?{selected:n.isSame(a,n.date(e[0]),`day`)}:{selected:!1}}function u(e,t,n,r,i){let a=i.date(r),o=e&&i.isBefore(a,i.date(e),`day`),s=t&&i.isAfter(a,i.date(t),`day`),c=n?.some(e=>i.isSame(a,i.date(e),`day`));return!o&&!s&&!c}function d({calendars:e,minDate:t,adapter:n}){if(!t)return!1;let r=e[0].firstDayOfMonth;return n.isSame(n.startOf(n.date(r),`month`),n.startOf(n.date(t),`month`),`month`)||n.isBefore(n.date(r),n.date(t),`month`)}function f({calendars:e,maxDate:t,adapter:n}){if(!t)return!1;let r=e[e.length-1].firstDayOfMonth;return n.isSame(n.startOf(n.date(r),`month`),n.startOf(n.date(t),`month`),`month`)||n.isAfter(n.date(r),n.date(t),`month`)}exports.addMonth=n,exports.composeEventHandlers=e,exports.getCalendars=r,exports.isBackDisabled=d,exports.isForwardDisabled=f,exports.subtractMonth=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(...e){return(t,...n)=>e.some(e=>(e&&e(t,...n),t&&t.defaultPrevented))}function t({calendars:e,offset:t,minDate:n,adapter:r}){let i=e[0].firstDayOfMonth,a=r.subtract(r.date(i),t,`month`);return n&&r.isBefore(a,r.startOf(r.date(n),`month`))?r.diff(r.startOf(r.date(i),`month`),r.startOf(r.date(n),`month`),`month`):t}function n({calendars:e,offset:t,maxDate:n,adapter:r}){let i=e[e.length-1].firstDayOfMonth,a=r.add(r.date(i),t,`month`);return n&&r.isAfter(a,r.startOf(r.date(n),`month`))?r.diff(r.startOf(r.date(n),`month`),r.startOf(r.date(i),`month`),`month`):t}function r({date:e,selected:t,disabledDates:n,modifiers:r,monthsToDisplay:a,minDate:o,maxDate:s,offset:c,firstDayOfWeek:l,adapter:u,selectionMode:d,hoveredDate:f}){let p=[],m=u.add(u.startOf(u.date(e),`month`),c,`month`);for(let e=0;e<a;e++){let a=u.add(m,e,`month`);p.push(i({month:u.get(a,`month`),year:u.get(a,`year`),selectedDates:t,disabledDates:n,modifiers:r,minDate:o,maxDate:s,firstDayOfWeek:l,adapter:u,selectionMode:d,hoveredDate:f}))}return p}function i({month:e,year:t,selectedDates:n,disabledDates:r,modifiers:i,minDate:l,maxDate:u,firstDayOfWeek:d,adapter:f,selectionMode:p,hoveredDate:m}){let h=f.set(f.set(f.startOf(f.date(),`year`),`year`,t),`month`,e);e=f.get(h,`month`),t=f.get(h,`year`);let g=f.getDaysInMonth(h),_=[];for(let o=1;o<=g;o++){let s=a(f.toDate(f.set(h,`day`,o)),n,r,i,l,u,f,p,!1,m,e,t);_.push(s)}let v=f.toDate(f.startOf(h,`month`)),y=f.toDate(f.endOf(h,`month`)),b=o({firstDayOfMonth:v,minDate:l,maxDate:u,selectedDates:n,disabledDates:r,modifiers:i,firstDayOfWeek:d,adapter:f,selectionMode:p,hoveredDate:m,month:e,year:t}),x=s({lastDayOfMonth:y,minDate:l,maxDate:u,selectedDates:n,disabledDates:r,modifiers:i,firstDayOfWeek:d,adapter:f,selectionMode:p,hoveredDate:m,month:e,year:t});_.unshift(...b),_.push(...x);let S=c(_);return{firstDayOfMonth:v,lastDayOfMonth:y,month:e,year:t,weeks:S}}function a(e,t,n,r,i,a,o,s,c=!1,d,f,p){let{selected:m,isRangeStart:h,isRangeEnd:g,isRangeBetween:_,isRangeHovering:v,isRangeActive:y}=c?{selected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeBetween:!1,isRangeHovering:!1,isRangeActive:!1}:l(t,e,o,s,d),b=o.isSame(o.date(e),o.date(),`day`),x=c&&o.isBefore(o.date(e),o.startOf(o.date(e),`month`)),S=c&&o.isAfter(o.date(e),o.endOf(o.date(e),`month`)),C={"text-brand-gold border border-brand-gold":e=>o.isSame(o.date(e),o.date(),`day`),"text-white cursor-default!":(e,t)=>o.get(o.date(e),`month`)!==t,...r},w=Object.keys(C).filter(t=>C[t](e,f??o.get(o.date(e),`month`),p??o.get(o.date(e),`year`)));return b&&w.push(`today`),c&&w.push(`outside`),x&&w.push(`prev-month`),S&&w.push(`next-month`),{date:e,selected:m,modifiers:w,selectable:u(i,a,n,e,o),today:b,prevMonth:x,nextMonth:S,isRangeStart:h,isRangeEnd:g,isRangeBetween:_,isRangeHovering:v,isRangeActive:y}}function o({firstDayOfMonth:e,minDate:t,maxDate:n,selectedDates:r,disabledDates:i,modifiers:o,firstDayOfWeek:s,adapter:c,selectionMode:l,hoveredDate:u,month:d,year:f}){let p=[],m=(c.toDate(c.date(e)).getDay()+7-s)%7,h=c.subtract(c.date(e),1,`day`);for(let e=0;e<m;e++){let e=a(c.toDate(h),r,i,o,t,n,c,l,!0,u,d,f);e.prevMonth=!0,p.unshift(e),h=c.subtract(h,1,`day`)}return p}function s({lastDayOfMonth:e,minDate:t,maxDate:n,selectedDates:r,disabledDates:i,modifiers:o,firstDayOfWeek:s,adapter:c,selectionMode:l,hoveredDate:u,month:d,year:f}){let p=[],m=(c.toDate(c.date(e)).getDay()+7-s)%7,h=c.add(c.date(e),1,`day`);for(let e=0;e<6-m;e++){let e=a(c.toDate(h),r,i,o,t,n,c,l,!0,u,d,f);e.nextMonth=!0,p.push(e),h=c.add(h,1,`day`)}return p}function c(e){let t=Math.ceil(e.length/7),n=[];for(let r=0;r<t;r++){n[r]=[];for(let t=0;t<7;t++)n[r].push(e[r*7+t])}return n}function l(e,t,n,r,i){if(!e&&!i)return{selected:!1};let a=n.date(t);if(r===`single`&&e instanceof Date)return{selected:n.isSame(a,n.date(e),`day`)};if(r===`multiple`&&Array.isArray(e))return{selected:e.some(e=>n.isSame(a,n.date(e),`day`))};if(r===`range`){let{start:t,end:r}=e&&typeof e==`object`&&!(e instanceof Date)&&!Array.isArray(e)?e:{start:void 0,end:void 0},o=t?n.isSame(a,n.date(t),`day`):!1,s=r?n.isSame(a,n.date(r),`day`):!1,c=t&&r?n.isAfter(a,n.date(t),`day`)&&n.isBefore(a,n.date(r),`day`):!1,l=!1;if(t&&!r&&i){let e=n.date(i),r=n.date(t);n.isAfter(e,r,`day`)?(l=n.isAfter(a,r,`day`)&&n.isBefore(a,e,`day`)||n.isSame(a,e,`day`),n.isSame(a,e,`day`)&&(s=!0)):n.isBefore(e,r,`day`)&&(l=n.isAfter(a,e,`day`)&&n.isBefore(a,r,`day`)||n.isSame(a,e,`day`),n.isSame(a,e,`day`)&&(o=!0),n.isSame(a,r,`day`)&&(o=!1,s=!0))}let u=!!(t&&r&&!n.isSame(n.date(t),n.date(r),`day`)||t&&!r&&i&&!n.isSame(n.date(t),n.date(i),`day`));return{selected:o||s||c,isRangeStart:o,isRangeEnd:s,isRangeBetween:c,isRangeHovering:l,isRangeActive:u}}return Array.isArray(e)&&e.length===1&&r===`single`?{selected:n.isSame(a,n.date(e[0]),`day`)}:{selected:!1}}function u(e,t,n,r,i){let a=i.date(r),o=e&&i.isBefore(a,i.date(e),`day`),s=t&&i.isAfter(a,i.date(t),`day`),c=n?.some(e=>i.isSame(a,i.date(e),`day`));return!o&&!s&&!c}function d({calendars:e,minDate:t,adapter:n}){if(!t)return!1;let r=e[0].firstDayOfMonth;return n.isSame(n.startOf(n.date(r),`month`),n.startOf(n.date(t),`month`),`month`)||n.isBefore(n.date(r),n.date(t),`month`)}function f({calendars:e,maxDate:t,adapter:n}){if(!t)return!1;let r=e[e.length-1].firstDayOfMonth;return n.isSame(n.startOf(n.date(r),`month`),n.startOf(n.date(t),`month`),`month`)||n.isAfter(n.date(r),n.date(t),`month`)}exports.addMonth=n,exports.composeEventHandlers=e,exports.getCalendars=r,exports.isBackDisabled=d,exports.isForwardDisabled=f,exports.subtractMonth=t;
2
2
  //# sourceMappingURL=utils.cjs.map