react-modular-datepicker 0.0.4 → 0.0.5-canary.0

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/components/Day.tsx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["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 tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\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 className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({ dateObj })}\n className={className}\n >\n {date.getDate()}\n {tooltip && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\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 return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\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 {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: 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 mb-3\",\n calendarsContainer: \"flex flex-col md:flex-row gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] min-h-[260px]\",\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 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled: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: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-4 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-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\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 calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: 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 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 { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\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 renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\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 renderDayTooltip,\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 wrappedGetBackProps = (args: any) => {\n const props = getBackProps(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(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={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) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <div className=\"text-center font-semibold mb-2 text-brand-text\">\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\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 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 classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":"wMAUA,IAAa,GAA2B,CAAE,UAAS,eAAc,aAAY,aAAc,CACzF,GAAI,CAAC,EACH,OAAO,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,wBAA0B,CAAA,EAGlD,GAAM,CAAE,OAAM,WAAU,aAAY,eAAc,aAAY,iBAAgB,kBAAiB,iBAAkB,EAC3G,EAAa,EAAW,IAE1B,EAAe,eACnB,AAaE,EAbE,GAAgB,EACH,GAAG,EAAW,SAAS,eAC7B,EACM,GAAG,EAAW,WAAW,GAAG,EAAgB,gCAAkC,iBACpF,EACM,GAAG,EAAW,SAAS,GAAG,EAAgB,gCAAkC,iBAClF,EACM,EAAW,cAAgB,GACjC,EACM,EAAW,eAAiB,GAClC,EACM,EAAW,UAAY,GAC5B,EAGK,EAAW,YAAc,GAFzB,EAAW,UAAY,GAKxC,IAAM,EAAY,CAChB,EAAW,IACX,EACA,IAAI,EAAQ,WAAa,CAAC,EAAA,CAAG,IAAI,GAAM,EAAmB,IAAM,CAAC,CACnE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAE1B,OACE,EAAA,EAAA,KAAA,CAAC,SAAD,CACE,GAAI,EAAa,CAAE,SAAQ,CAAC,EACjB,YAFb,SAAA,CAIG,EAAK,QAAQ,EACb,IACC,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,oFACb,UAAA,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,+EAAf,SAAA,CACG,GACD,EAAA,EAAA,IAAA,CAAC,MAAD,C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AW,kBAAtE,SAAA,CACG,EAAU,OAAS,IAClB,EAAA,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,iDAAf,SAAA,CACG,EAAW,EAAS,OAAO,IAAE,EAAU,EAAE,CAAC,OAAS,EAAU,EAAU,OAAS,EAAE,CAAC,KAAuB,GAAhB,EAAS,IACjG,KAEP,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAW,YACxB,SAAA,EAAe,IAAK,IACnB,EAAA,EAAA,IAAA,CAAC,MAAD,CAAe,UAAW,EAAW,QAAU,SAAA,CAAS,EAA9C,CAA8C,CACzD,CACE,CAAA,GACL,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,GAAG,EAAW,SAAS,GAAG,IAAmB,OAAS,wBAA0B,IAAmB,QAAU,yBAA2B,KACrJ,SAAA,EAAS,MAAM,KAAK,EAAM,IACzB,EAAK,KAAK,EAAS,KACjB,EAAA,EAAA,IAAA,CAAC,EAAD,CAEW,UACK,eACF,aACZ,QAAS,GAAW,IAAmB,CAAO,CAC/C,EALM,GAAG,EAAG,GAAG,GAKf,CACF,CACH,CACG,CAAA,CACF,CAxBK,EAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MAwBnC,CACN,CACE,IACJ,IAAU,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAW,OAAS,SAAA,CAAY,CAAA,CACxD,GAET"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/components/Day.tsx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["import React, { useState } 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 tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n const [isHovered, setIsHovered] = useState(false);\n\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\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 className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({\n dateObj,\n onMouseEnter: () => setIsHovered(true),\n onMouseLeave: () => setIsHovered(false)\n })}\n className={className}\n >\n {date.getDate()}\n {tooltip && isHovered && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\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 return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\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 {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: 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 mb-3\",\n calendarsContainer: \"flex flex-col md:flex-row gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] min-h-[260px]\",\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 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled: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: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-4 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-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\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 calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: 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 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 { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\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 renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\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 renderDayTooltip,\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 wrappedGetBackProps = (args: any) => {\n const props = getBackProps(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(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={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) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <button\n type=\"button\"\n aria-label={monthNames[calendar.month]}\n className=\"block w-full text-center font-semibold mb-2 text-brand-text\"\n >\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\n </button>\n )}\n <div className={classNames.weekdayGrid}>\n {sortedWeekdays.map((day) => (\n <div key={day} className={classNames.weekday}>{day}</div>\n ))}\n </div>\n <div 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 classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":"wMAUA,IAAa,GAA2B,CAAE,UAAS,eAAc,aAAY,aAAc,CACzF,GAAM,CAAC,EAAW,IAAA,EAAgB,EAAA,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,IAAA,CAAC,MAAD,CAAK,UAAW,EAAW,YACxB,SAAA,EAAe,IAAK,IACnB,EAAA,EAAA,IAAA,CAAC,MAAD,CAAe,UAAW,EAAW,QAAU,SAAA,CAAS,EAA9C,CAA8C,CACzD,CACE,CAAA,GACL,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,GAAG,EAAW,SAAS,GAAG,IAAmB,OAAS,wBAA0B,IAAmB,QAAU,yBAA2B,KACrJ,SAAA,EAAS,MAAM,KAAK,EAAM,IACzB,EAAK,KAAK,EAAS,KACjB,EAAA,EAAA,IAAA,CAAC,EAAD,CAEW,UACK,eACF,aACZ,QAAS,GAAW,IAAmB,CAAO,CAC/C,EALM,GAAG,EAAG,GAAG,GAKf,CACF,CACH,CACG,CAAA,CACF,CA5BK,EAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MA4BnC,CACN,CACE,IACJ,IAAU,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAW,OAAS,SAAA,CAAY,CAAA,CACxD,GAET"}
package/dist/index.mjs CHANGED
@@ -1,21 +1,26 @@
1
- import { n as e, r as t, t as n } from "./useDates-DQabq6Ux.mjs";
1
+ import { n as e, r as t, t as n } from "./useDates-CpcW1GpF.mjs";
2
2
  import { addMonth as r, composeEventHandlers as i, getCalendars as a, isBackDisabled as o, isForwardDisabled as s, subtractMonth as c } from "./utils.mjs";
3
3
  import { useEffect as l, useRef as u, useState as d } from "react";
4
4
  import { jsx as f, jsxs as p } from "react/jsx-runtime";
5
5
  //#region src/components/Day.tsx
6
6
  var m = ({ dateObj: e, getDateProps: t, classNames: n, tooltip: r }) => {
7
+ let [i, a] = d(!1);
7
8
  if (!e) return /* @__PURE__ */ f("div", { className: "aspect-square bg-white" });
8
- let { date: i, selected: a, selectable: o, isRangeStart: s, isRangeEnd: c, isRangeBetween: l, isRangeHovering: u, isRangeActive: d } = e, m = n.day, h = "rounded-full";
9
- h = s && c ? `${m.selected} rounded-full` : s ? `${m.rangeStart} ${d ? "rounded-l-full rounded-r-none" : "rounded-full"}` : c ? `${m.rangeEnd} ${d ? "rounded-r-full rounded-l-none" : "rounded-full"}` : l ? m.rangeBetween || "" : u ? m.rangeHovering || "" : a ? m.selected || "" : o ? m.unselected || "" : m.disabled || "";
10
- let g = [
11
- m.day,
12
- h,
13
- ...(e.modifiers || []).map((e) => m[e] || e)
9
+ let { date: o, selected: s, selectable: c, isRangeStart: l, isRangeEnd: u, isRangeBetween: m, isRangeHovering: h, isRangeActive: g } = e, _ = n.day, v = "rounded-full";
10
+ v = l && u ? `${_.selected} rounded-full` : l ? `${_.rangeStart} ${g ? "rounded-l-full rounded-r-none" : "rounded-full"}` : u ? `${_.rangeEnd} ${g ? "rounded-r-full rounded-l-none" : "rounded-full"}` : m ? _.rangeBetween || "" : h ? _.rangeHovering || "" : s ? _.selected || "" : c ? _.unselected || "" : _.disabled || "";
11
+ let y = [
12
+ _.day,
13
+ v,
14
+ ...(e.modifiers || []).map((e) => _[e] || e)
14
15
  ].filter(Boolean).join(" ");
15
16
  return /* @__PURE__ */ p("button", {
16
- ...t({ dateObj: e }),
17
- className: g,
18
- children: [i.getDate(), r && /* @__PURE__ */ f("div", {
17
+ ...t({
18
+ dateObj: e,
19
+ onMouseEnter: () => a(!0),
20
+ onMouseLeave: () => a(!1)
21
+ }),
22
+ className: y,
23
+ children: [o.getDate(), r && i && /* @__PURE__ */ f("div", {
19
24
  className: "absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10",
20
25
  children: /* @__PURE__ */ p("div", {
21
26
  className: "bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg",
@@ -275,8 +280,10 @@ var _ = () => /* @__PURE__ */ f("svg", {
275
280
  v === "days" && k.map((e) => /* @__PURE__ */ p("div", {
276
281
  className: _.calendarContainer,
277
282
  children: [
278
- k.length > 1 && /* @__PURE__ */ p("div", {
279
- className: "text-center font-semibold mb-2 text-brand-text",
283
+ k.length > 1 && /* @__PURE__ */ p("button", {
284
+ type: "button",
285
+ "aria-label": O[e.month],
286
+ className: "block w-full text-center font-semibold mb-2 text-brand-text",
280
287
  children: [
281
288
  O[e.month],
282
289
  " ",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/components/Day.tsx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["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 tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\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 className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({ dateObj })}\n className={className}\n >\n {date.getDate()}\n {tooltip && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\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 return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\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 {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: 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 mb-3\",\n calendarsContainer: \"flex flex-col md:flex-row gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] min-h-[260px]\",\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 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled: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: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-4 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-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\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 calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: 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 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 { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\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 renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\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 renderDayTooltip,\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 wrappedGetBackProps = (args: any) => {\n const props = getBackProps(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(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={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) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <div className=\"text-center font-semibold mb-2 text-brand-text\">\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\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 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 classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":";;;;;AAUA,IAAa,KAA2B,EAAE,YAAS,iBAAc,eAAY,iBAAc;CACzF,IAAI,CAAC,GACH,OAAO,kBAAC,OAAD,EAAK,WAAU,yBAA0B,CAAA;CAGlD,IAAM,EAAE,SAAM,aAAU,eAAY,iBAAc,eAAY,mBAAgB,oBAAiB,qBAAkB,GAC3G,IAAa,EAAW,KAE1B,IAAe;CACnB,AAaE,IAbE,KAAgB,IACH,GAAG,EAAW,SAAS,iBAC7B,IACM,GAAG,EAAW,WAAW,GAAG,IAAgB,kCAAkC,mBACpF,IACM,GAAG,EAAW,SAAS,GAAG,IAAgB,kCAAkC,mBAClF,IACM,EAAW,gBAAgB,KACjC,IACM,EAAW,iBAAiB,KAClC,IACM,EAAW,YAAY,KAC5B,IAGK,EAAW,cAAc,KAFzB,EAAW,YAAY;CAKxC,IAAM,IAAY;EAChB,EAAW;EACX;EACA,IAAI,EAAQ,aAAa,CAAC,EAAA,CAAG,KAAI,MAAM,EAAmB,MAAM,CAAC;CACnE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAE1B,OACE,kBAAC,UAAD;EACE,GAAI,EAAa,EAAE,WAAQ,CAAC;EACjB;EAFb,UAAA,CAIG,EAAK,QAAQ,GACb,KACC,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,GACD,kBAAC,OAAD,EAAK,WAAU,4FAA6F,CAAA,CACzG;;EACF,CAAA,CAED;;AAEZ;;;ACjDA,SAAgB,EAAY,IAAuB,G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AAG,EAAS,MAAM,GAAG,EAAS,MAwBnC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAW;IAAS,UAAA;GAAY,CAAA;EACxD;;AAET"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/components/Day.tsx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["import React, { useState } 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 tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n const [isHovered, setIsHovered] = useState(false);\n\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\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 className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({\n dateObj,\n onMouseEnter: () => setIsHovered(true),\n onMouseLeave: () => setIsHovered(false)\n })}\n className={className}\n >\n {date.getDate()}\n {tooltip && isHovered && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\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 return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\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 {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: 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 mb-3\",\n calendarsContainer: \"flex flex-col md:flex-row gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] min-h-[260px]\",\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 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled: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: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-4 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-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\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 calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: 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 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 { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\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 renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\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 renderDayTooltip,\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 wrappedGetBackProps = (args: any) => {\n const props = getBackProps(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(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={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) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <button\n type=\"button\"\n aria-label={monthNames[calendar.month]}\n className=\"block w-full text-center font-semibold mb-2 text-brand-text\"\n >\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\n </button>\n )}\n <div className={classNames.weekdayGrid}>\n {sortedWeekdays.map((day) => (\n <div key={day} className={classNames.weekday}>{day}</div>\n ))}\n </div>\n <div 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 classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":";;;;;AAUA,IAAa,KAA2B,EAAE,YAAS,iBAAc,eAAY,iBAAc;CACzF,IAAM,CAAC,GAAW,KAAgB,EAAS,EAAK;CAEhD,IAAI,CAAC,GACH,OAAO,kBAAC,OAAD,EAAK,WAAU,yBAA0B,CAAA;CAGlD,IAAM,EAAE,SAAM,aAAU,eAAY,iBAAc,eAAY,mBAAgB,oBAAiB,qBAAkB,GAC3G,IAAa,EAAW,KAE1B,IAAe;CACnB,AAaE,IAbE,KAAgB,IACH,GAAG,EAAW,SAAS,iBAC7B,IACM,GAAG,EAAW,WAAW,GAAG,IAAgB,kCAAkC,mBACpF,IACM,GAAG,EAAW,SAAS,GAAG,IAAgB,kCAAkC,mBAClF,IACM,EAAW,gBAAgB,KACjC,IACM,EAAW,iBAAiB,KAClC,IACM,EAAW,YAAY,KAC5B,IAGK,EAAW,cAAc,KAFzB,EAAW,YAAY;CAKxC,IAAM,IAAY;EAChB,EAAW;EACX;EACA,IAAI,EAAQ,aAAa,CAAC,EAAA,CAAG,KAAI,MAAM,EAAmB,MAAM,CAAC;CACnE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAE1B,OACE,kBAAC,UAAD;EACE,GAAI,EAAa;GACf;GACA,oBAAoB,EAAa,EAAI;GACrC,oBAAoB,EAAa,EAAK;EACxC,CAAC;EACU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AAG,EAAW,SAAS,GAAG,MAAmB,SAAS,0BAA0B,MAAmB,UAAU,2BAA2B;QACrJ,UAAA,EAAS,MAAM,KAAK,GAAM,MACzB,EAAK,KAAK,GAAS,MACjB,kBAAC,GAAD;SAEW;SACK;SACF;SACZ,SAAS,KAAW,IAAmB,CAAO;QAC/C,GALM,GAAG,EAAG,GAAG,GAKf,CACF,CACH;OACG,CAAA;MACF;KA5BK,GAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MA4BnC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAW;IAAS,UAAA;GAAY,CAAA;EACxD;;AAET"}
@@ -0,0 +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.js");let l=require("react"),u=require("dayjs");u=s(u);let d=require("dayjs/plugin/isBetween");d=s(d);let f=require("dayjs/plugin/customParseFormat");f=s(f);let p=require("dayjs/plugin/localeData");p=s(p),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-CCrn42eQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDates-CCrn42eQ.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 showOutsideDays?: boolean;\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?: (date: 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 showOutsideDays = false,\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 newDate = adapter.toDate(adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month'));\n onMonthChange?.(newDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, 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 showOutsideDays,\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":"ytBAOA,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,EAA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EAAM,OAAS,EAAM,IACtC,EAAS,CAAE,MAAO,EAAQ,KAAM,IAAK,IAAA,EAAU,CAAC,EAE5C,EAAQ,SAAS,EAAQ,KAAK,EAAQ,IAAI,EAAG,EAAQ,KAAK,EAAM,KAAK,EAAG,KAAK,EAC7E,EAAS,CAAE,MAAO,EAAQ,KAAM,IAAK,EAAM,KAAM,CAAC,EAElD,EAAS,CAAE,MAAO,EAAM,MAAO,IAAK,EAAQ,IAAK,CAAC,CAG9D,EACJ,EAAG,CAAC,EAAgB,EAAU,EAAe,EAAU,CAAO,CAAC,EAkB/D,MAAO,CACH,UAjBc,EAAA,aAAa,CAC3B,OACA,WACA,gBACA,YACA,kBACA,UACA,UACA,OAAQ,EACR,iBACA,kBACA,UACA,gBACA,aACJ,CAGI,EACA,aAAe,IAEJ,CACH,GAFU,EAAa,EAAoB,CAExC,EACH,aAAc,EAAA,qBAAqB,EAAK,iBAAoB,CACxD,EAAe,EAAK,QAAQ,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"}
@@ -69,7 +69,6 @@ function g(e, { onClick: n, dateObj: r, ...i }) {
69
69
  e(r, t);
70
70
  }),
71
71
  disabled: !r.selectable,
72
- "aria-label": r.date.toDateString(),
73
72
  "aria-pressed": r.selected,
74
73
  role: "button",
75
74
  ...i
@@ -90,7 +89,6 @@ function _({ minDate: e, offsetMonth: n, handleOffsetChanged: i, adapter: o }, {
90
89
  minDate: e,
91
90
  adapter: o
92
91
  }),
93
- "aria-label": `Go back ${c} month${c === 1 ? "" : "s"}`,
94
92
  ...u
95
93
  };
96
94
  }
@@ -109,7 +107,6 @@ function v({ maxDate: n, offsetMonth: r, handleOffsetChanged: a, adapter: o }, {
109
107
  maxDate: n,
110
108
  adapter: o
111
109
  }),
112
- "aria-label": `Go forward ${c} month${c === 1 ? "" : "s"}`,
113
110
  ...u
114
111
  };
115
112
  }
@@ -198,4 +195,4 @@ function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disab
198
195
  //#endregion
199
196
  export { f as n, p as r, y as t };
200
197
 
201
- //# sourceMappingURL=useDates-DQabq6Ux.mjs.map
198
+ //# sourceMappingURL=useDates-CpcW1GpF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDates-CpcW1GpF.mjs","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 showOutsideDays?: boolean;\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?: (date: 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 showOutsideDays = false,\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 newDate = adapter.toDate(adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month'));\n onMonthChange?.(newDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, 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 showOutsideDays,\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,KAAK,IAC9B,EAAK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GACA;EACJ,CAAC;EACD,iBAAiB,EAAgB,KAAK,MAAM;GACxC;GACA;GACA;GACA;EACJ,CAAC;EACD,WAAW;CACf;AACJ"}
@@ -35,7 +35,6 @@ export declare function useDates({ date, maxDate, minDate, disabledDates, months
35
35
  onMouseLeave: (event: any, ...args: any[]) => boolean;
36
36
  onClick: (event: any, ...args: any[]) => boolean;
37
37
  disabled: boolean;
38
- 'aria-label': string;
39
38
  'aria-pressed': boolean;
40
39
  role: string;
41
40
  };
@@ -47,7 +46,6 @@ export declare function useDates({ date, maxDate, minDate, disabledDates, months
47
46
  }) => {
48
47
  onClick: (event: any, ...args: any[]) => boolean;
49
48
  disabled: boolean;
50
- 'aria-label': string;
51
49
  };
52
50
  getForwardProps: (args_0: {
53
51
  [key: string]: any;
@@ -57,7 +55,6 @@ export declare function useDates({ date, maxDate, minDate, disabledDates, months
57
55
  }) => {
58
56
  onClick: (event: any, ...args: any[]) => boolean;
59
57
  disabled: boolean;
60
- 'aria-label': string;
61
58
  };
62
59
  setOffset: (newOffset: number) => void;
63
60
  };
package/dist/useDates.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-D9EvVlhK.js");require("./utils.js"),exports.useDates=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-CCrn42eQ.js");require("./utils.js"),exports.useDates=e.t;
package/dist/useDates.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./useDates-DQabq6Ux.mjs";
1
+ import { t as e } from "./useDates-CpcW1GpF.mjs";
2
2
  import "./utils.mjs";
3
3
  export { e as useDates };
package/package.json CHANGED
@@ -1,7 +1,17 @@
1
1
  {
2
2
  "name": "react-modular-datepicker",
3
- "version": "0.0.4",
3
+ "version": "0.0.5-canary.0",
4
4
  "description": "A modular, lightweight, and type-safe React datepicker and calendar component with headless hooks for single, multiple, and range selection.",
5
+ "author": "",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/Dragate/react-modular-datepicker#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Dragate/react-modular-datepicker.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/Dragate/react-modular-datepicker/issues"
14
+ },
5
15
  "keywords": [
6
16
  "react",
7
17
  "react-component",
@@ -26,8 +36,12 @@
26
36
  "i18n",
27
37
  "localization"
28
38
  ],
29
- "author": "",
30
- "license": "MIT",
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "main": "./dist/index.js",
43
+ "module": "./dist/index.mjs",
44
+ "types": "./dist/index.d.ts",
31
45
  "peerDependencies": {
32
46
  "dayjs": "^1.11.20",
33
47
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -39,67 +53,17 @@
39
53
  }
40
54
  },
41
55
  "devDependencies": {
42
- "@playwright/test": "^1.60.0",
43
- "@tailwindcss/cli": "^4.3.0",
56
+ "@playwright/test": "^1.63.0",
57
+ "@tailwindcss/cli": "^4.3.3",
44
58
  "@tailwindcss/vite": "^4.3.3",
45
- "@types/react": "^19.2.15",
46
- "@types/react-dom": "^19.2.3",
59
+ "@types/react": "^19.3.0",
60
+ "@types/react-dom": "^19.3.0",
47
61
  "@vitejs/plugin-react": "^6.1.1",
48
- "dayjs": "^1.11.20",
49
- "react": "^19.2.6",
50
- "react-dom": "^19.2.6",
51
- "semver": "^7.8.1",
52
- "tailwindcss": "^4.3.0",
62
+ "semver": "^7.8.5",
63
+ "tailwindcss": "^4.3.3",
53
64
  "typescript": "^6.0.3",
54
- "vite": "^8.3.0",
55
- "vite-plugin-dts": "^5.1.0"
56
- },
57
- "repository": {
58
- "type": "git",
59
- "url": "git+https://github.com/Dragate/react-modular-datepicker.git"
60
- },
61
- "homepage": "https://github.com/Dragate/react-modular-datepicker#readme",
62
- "bugs": {
63
- "url": "https://github.com/Dragate/react-modular-datepicker/issues"
64
- },
65
- "files": [
66
- "dist"
67
- ],
68
- "main": "./dist/index.js",
69
- "module": "./dist/index.mjs",
70
- "types": "./dist/index.d.ts",
71
- "exports": {
72
- ".": {
73
- "import": {
74
- "types": "./dist/index.d.ts",
75
- "default": "./dist/index.mjs"
76
- },
77
- "require": {
78
- "types": "./dist/index.d.ts",
79
- "default": "./dist/index.js"
80
- }
81
- },
82
- "./useDates": {
83
- "import": {
84
- "types": "./dist/useDates.d.ts",
85
- "default": "./dist/useDates.mjs"
86
- },
87
- "require": {
88
- "types": "./dist/useDates.d.ts",
89
- "default": "./dist/useDates.js"
90
- }
91
- },
92
- "./utils": {
93
- "import": {
94
- "types": "./dist/utils.d.ts",
95
- "default": "./dist/utils.mjs"
96
- },
97
- "require": {
98
- "types": "./dist/utils.d.ts",
99
- "default": "./dist/utils.js"
100
- }
101
- },
102
- "./dist/index.css": "./dist/index.css"
65
+ "unplugin-dts": "^1.1.0",
66
+ "vite": "^8.3.0"
103
67
  },
104
68
  "scripts": {
105
69
  "dev": "pnpm run -p \"/^dev:.*/\"",
@@ -109,6 +73,8 @@
109
73
  "build": "pnpm run build:js && pnpm run build:css",
110
74
  "build:js": "vite build",
111
75
  "build:css": "tailwindcss -i src/index.css -o dist/index.css",
112
- "test:e2e": "playwright test"
76
+ "test": "playwright test",
77
+ "test:unit": "playwright test --project=unit",
78
+ "test:e2e": "playwright test --project=e2e"
113
79
  }
114
80
  }