react-modular-datepicker 0.0.9 → 0.0.10-canary.1
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/adapters/dayjs.d.ts +1 -1
- package/dist/components/Calendar.d.ts +3 -2
- package/dist/components/CalendarHeader.d.ts +2 -2
- package/dist/components/Day.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/{useDates-BVAPuyDo.js → useDates-BvwdhdUS.js} +57 -55
- package/dist/useDates-BvwdhdUS.js.map +1 -0
- package/dist/useDates-bLtR7Prk.cjs +2 -0
- package/dist/useDates-bLtR7Prk.cjs.map +1 -0
- package/dist/useDates.cjs +1 -1
- package/dist/useDates.d.ts +43 -22
- package/dist/useDates.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +4 -2
- package/dist/utils.js +2 -2
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/useDates-BVAPuyDo.js.map +0 -1
- package/dist/useDates-DqKgwgF7.cjs +0 -2
- package/dist/useDates-DqKgwgF7.cjs.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/components/Day.tsx","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n selectMonth?: string;\n selectYear?: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month',\n selectMonth: 'Select month',\n selectYear: 'Select year'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import clsx from 'clsx';\nimport React from 'react';\nimport { Translations } from '../i18n';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args: any) => any;\n getForwardProps: (args: any) => any;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: Translations;\n classNames?: CalendarClassNames;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n if (calendars.length > 1 && calendars.length < 12) {\n return null;\n }\n\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n\n const isNavHidden = !!(currentView && currentView !== 'days');\n const navButtonClassName = clsx(\n 'rmd-nav-button',\n isNavHidden && 'rmd-nav-button-hidden',\n classNames?.navButton,\n isNavHidden && classNames?.navButtonHidden\n );\n\n const monthYearLabelClassName = clsx(\n 'rmd-month-year-label',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.monthYearLabel\n );\n\n return (\n <div className={clsx(\n 'rmd-header',\n calendars.length > 1 && 'rmd-header-multi-month',\n classNames?.header,\n calendars.length > 1 && classNames?.headerMultiMonth\n )}>\n <button\n {...getBackProps({ calendars })}\n className={navButtonClassName}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={clsx('rmd-month-year-container', classNames?.monthYearContainer)}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={monthYearLabelClassName}>\n <button\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${monthNames[calendars[0].month]}, ${t.selectMonth || 'Select month'}`}\n aria-expanded={currentView === 'months'}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${calendars[0].year}, ${t.selectYear || 'Select year'}`}\n aria-expanded={currentView === 'years'}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={monthYearLabelClassName}>\n <span>\n {first.year === last.year ? first.year : `${first.year} - ${last.year}`}\n </span>\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n className={navButtonClassName}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","import React from 'react';\nimport clsx from 'clsx';\nimport type { CalendarClassNames, DateAdapter, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: any }) => any;\n dayProps?: Record<string, any>;\n classNames?: CalendarClassNames;\n tabIndex?: number;\n adapter?: DateAdapter;\n locale?: string;\n onKeyDown?: (e: React.KeyboardEvent, dateObj: DateObj) => void;\n onFocus?: (dateObj: DateObj) => void;\n buttonRef?: (el: HTMLButtonElement | null) => void;\n}\n\nexport const Day: React.FC<DayProps> = ({\n dateObj,\n getDateProps,\n dayProps,\n classNames,\n tabIndex = -1,\n adapter,\n locale,\n onKeyDown,\n onFocus,\n buttonRef\n}) => {\n if (!dateObj) {\n return <div role=\"gridcell\" aria-hidden=\"true\" className={clsx('rmd-day-empty', classNames?.day?.empty)} />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames?.day;\n\n let semanticStateClass = '';\n let customStateClass = '';\n\n if (isRangeStart && isRangeEnd) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (isRangeStart) {\n semanticStateClass = clsx('rmd-day-range-start', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeStart || '';\n } else if (isRangeEnd) {\n semanticStateClass = clsx('rmd-day-range-end', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeEnd || '';\n } else if (isRangeBetween) {\n semanticStateClass = 'rmd-day-range-between';\n customStateClass = dayClasses?.rangeBetween || '';\n } else if (isRangeHovering) {\n semanticStateClass = 'rmd-day-range-hovering';\n customStateClass = dayClasses?.rangeHovering || '';\n } else if (selected) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (!selectable) {\n semanticStateClass = 'rmd-day-disabled';\n customStateClass = dayClasses?.disabled || '';\n } else {\n semanticStateClass = 'rmd-day-unselected';\n customStateClass = dayClasses?.unselected || '';\n }\n\n const modifierClasses = (dateObj.modifiers || [])\n .map(m => (dayClasses as any)?.[m] || m)\n .filter(Boolean);\n\n const formattedDateLabel = adapter\n ? adapter.format(adapter.date(date), 'dddd, MMMM D, YYYY', locale)\n : date.toDateString();\n\n const isSelected = !!(selected || isRangeStart || isRangeEnd);\n\n const baseProps = getDateProps({ dateObj, ...dayProps });\n\n return (\n <button\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={!selectable}\n aria-label={formattedDateLabel}\n tabIndex={tabIndex}\n {...baseProps}\n ref={buttonRef}\n onKeyDown={(e) => {\n baseProps.onKeyDown?.(e);\n onKeyDown?.(e, dateObj);\n }}\n onFocus={(e) => {\n baseProps.onFocus?.(e);\n onFocus?.(dateObj);\n }}\n className={clsx(\n 'rmd-day',\n dayClasses?.day,\n semanticStateClass,\n customStateClass,\n modifierClasses\n )}\n >\n {date.getDate()}\n </button>\n );\n};\n","import React, { useState, useRef, useEffect } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const [focusedMonth, setFocusedMonth] = useState<number>(month);\n const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n useEffect(() => {\n buttonRefs.current[focusedMonth]?.focus();\n }, [focusedMonth]);\n\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent, idx: number) => {\n let nextIndex = focusedMonth;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextIndex = (idx - 1 + 12) % 12;\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextIndex = (idx + 1) % 12;\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextIndex = (idx - 3 + 12) % 12;\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextIndex = (idx + 3) % 12;\n break;\n case 'Home':\n e.preventDefault();\n nextIndex = 0;\n break;\n case 'End':\n e.preventDefault();\n nextIndex = 11;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!isMonthDisabled(idx)) {\n onMonthSelect(idx);\n }\n return;\n default:\n return;\n }\n\n setFocusedMonth(nextIndex);\n };\n\n const gridClassName = clsx('rmd-months-grid', classNames?.monthsGrid);\n\n return (\n <div\n role=\"grid\"\n aria-label=\"Select month\"\n className={gridClassName}\n >\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n const isSelected = idx === month;\n const isFocused = idx === focusedMonth;\n const buttonClassName = clsx(\n 'rmd-month-button',\n isSelected ? 'rmd-month-button-selected' : 'rmd-month-button-unselected',\n classNames?.monthButton,\n isSelected ? classNames?.monthButtonSelected : classNames?.monthButtonUnselected\n );\n\n return (\n <button\n key={name}\n ref={(el) => {\n buttonRefs.current[idx] = el;\n }}\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={disabled}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => !disabled && onMonthSelect(idx)}\n onKeyDown={(e) => handleKeyDown(e, idx)}\n onFocus={() => setFocusedMonth(idx)}\n className={buttonClassName}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n const [focusedYear, setFocusedYear] = useState<number>(year);\n const buttonRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years: number[] = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n useEffect(() => {\n if (yearListRef.current) {\n const container = yearListRef.current;\n const selectedYearBtn = container.querySelector('[data-selected=\"true\"]') as HTMLElement | null;\n if (selectedYearBtn) {\n const targetScrollTop =\n selectedYearBtn.offsetTop - container.clientHeight / 2 + selectedYearBtn.clientHeight / 2;\n container.scrollTop = Math.max(0, targetScrollTop);\n }\n }\n }, []);\n\n useEffect(() => {\n const btn = buttonRefs.current.get(focusedYear);\n if (btn) {\n btn.focus();\n }\n }, [focusedYear]);\n\n const handleKeyDown = (e: React.KeyboardEvent, y: number) => {\n let nextYear = focusedYear;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 1);\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 1);\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 3);\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 3);\n break;\n case 'PageUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 10);\n break;\n case 'PageDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 10);\n break;\n case 'Home':\n e.preventDefault();\n nextYear = startYear;\n break;\n case 'End':\n e.preventDefault();\n nextYear = endYear;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n onYearSelect(y);\n return;\n default:\n return;\n }\n\n setFocusedYear(nextYear);\n };\n\n return (\n <div\n ref={yearListRef}\n role=\"grid\"\n aria-label=\"Select year\"\n className={clsx('rmd-years-grid', classNames?.yearsGrid)}\n >\n {years.map((y) => {\n const isSelected = y === year;\n const isFocused = y === focusedYear;\n const buttonClassName = clsx(\n 'rmd-year-button',\n isSelected ? 'rmd-year-button-selected' : 'rmd-year-button-unselected',\n classNames?.yearButton,\n isSelected ? classNames?.yearButtonSelected : classNames?.yearButtonUnselected\n );\n\n return (\n <button\n key={y}\n ref={(el) => {\n if (el) buttonRefs.current.set(y, el);\n else buttonRefs.current.delete(y);\n }}\n data-selected={isSelected}\n role=\"gridcell\"\n aria-selected={isSelected}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => onYearSelect(y)}\n onKeyDown={(e) => handleKeyDown(e, y)}\n onFocus={() => setFocusedYear(y)}\n className={buttonClassName}\n >\n {y}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useState, useRef, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarClassNames, DateObj } from '../types';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { CalendarHeader, ChevronLeftIcon, ChevronRightIcon } from './CalendarHeader';\nimport { Day } from './Day';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: any) => React.ReactNode);\n footer?: React.ReactNode;\n getDayProps?: (dateObj: DateObj) => Record<string, any>;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nconst getDateKey = (d: Date): string =>\n `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n getDayProps,\n ...useDatesProps\n } = props;\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n const [daysHeight, setDaysHeight] = useState<number | null>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const [announcement, setAnnouncement] = useState<string>('');\n\n const daysContainerRef = useRef<HTMLDivElement | null>(null);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n const isKeyboardNavigating = useRef<boolean>(false);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n useEffect(() => {\n if (view === 'days' && daysContainerRef.current) {\n const el = daysContainerRef.current;\n const updateHeight = () => {\n if (el.offsetHeight > 0) {\n setDaysHeight(el.offsetHeight);\n }\n };\n updateHeight();\n\n if (typeof ResizeObserver !== 'undefined') {\n const observer = new ResizeObserver(() => {\n updateHeight();\n });\n observer.observe(el);\n return () => observer.disconnect();\n }\n }\n }, [view, calendars]);\n\n useEffect(() => {\n if (view === 'days' && calendars.length > 0) {\n if (calendars.length === 1) {\n setAnnouncement(`${monthNames[calendars[0].month]} ${calendars[0].year}`);\n } else {\n setAnnouncement(\n `${monthNames[calendars[0].month]} ${calendars[0].year} to ${\n monthNames[calendars[calendars.length - 1].month]\n } ${calendars[calendars.length - 1].year}`\n );\n }\n } else if (view === 'months') {\n setAnnouncement('Month selection view');\n } else if (view === 'years') {\n setAnnouncement('Year selection view');\n }\n }, [view, calendars, monthNames]);\n\n // Determine default active focused date if focusedDate is not set\n const defaultFocusedDate = useMemo(() => {\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.selected) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.today) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && !dateObj.prevMonth && !dateObj.nextMonth) {\n return dateObj.date;\n }\n }\n }\n }\n return calendars[0]?.weeks[0]?.find((d) => d?.selectable)?.date || new Date();\n }, [calendars]);\n\n const currentFocusedDate = focusedDate || defaultFocusedDate;\n\n useEffect(() => {\n if (view === 'days' && currentFocusedDate && isKeyboardNavigating.current) {\n const key = getDateKey(currentFocusedDate);\n const btn = dayButtonRefs.current.get(key);\n if (btn) {\n btn.focus();\n }\n }\n }, [currentFocusedDate, calendars, view]);\n\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const stepOffset = useDatesProps.monthsToDisplay || 1;\n\n const wrappedGetBackProps = (args: any) => {\n const props = getBackProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args: any) => {\n const props = getForwardProps({ offset: stepOffset, ...args });\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const handleDayKeyDown = (e: React.KeyboardEvent, dateObj: DateObj) => {\n const isRTL = Boolean(\n rootRef.current?.closest('[dir=\"rtl\"]') ||\n (typeof document !== 'undefined' && document.documentElement.dir === 'rtl')\n );\n\n let newDate: Date | null = null;\n const current = adapter.date(dateObj.date);\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? 1 : -1, 'day'));\n break;\n case 'ArrowRight':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? -1 : 1, 'day'));\n break;\n case 'ArrowUp':\n e.preventDefault();\n newDate = adapter.toDate(adapter.subtract(current, 7, 'day'));\n break;\n case 'ArrowDown':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, 7, 'day'));\n break;\n case 'Home': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = (currentDayOfWeek - firstDayOfWeek + 7) % 7;\n newDate = adapter.toDate(adapter.subtract(current, diff, 'day'));\n break;\n }\n case 'End': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = 6 - ((currentDayOfWeek - firstDayOfWeek + 7) % 7);\n newDate = adapter.toDate(adapter.add(current, diff, 'day'));\n break;\n }\n case 'PageUp': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.subtract(current, 1, unit));\n break;\n }\n case 'PageDown': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.add(current, 1, unit));\n break;\n }\n case 'Enter':\n case ' ': {\n // Native button press handles click event\n return;\n }\n default:\n return;\n }\n\n if (newDate) {\n isKeyboardNavigating.current = true;\n setFocusedDate(newDate);\n\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const targetMonth = adapter.startOf(adapter.date(newDate), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setOffset(newOffset);\n }\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div ref={rootRef} className={clsx('rmd', 'rmd-root', classNames?.root)}>\n <div className=\"rmd-sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </div>\n\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={clsx('rmd-calendars-container', classNames?.calendarsContainer)}>\n {view === 'months' && calendars.map((calendar) => (\n <div\n key={`months-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div\n key={`years-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar, index) => (\n <div\n key={`${calendar.month}-${calendar.year}`}\n ref={index === 0 ? daysContainerRef : undefined}\n role=\"grid\"\n aria-label={`${monthNames[calendar.month]} ${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n >\n {calendars.length > 1 && (\n <div className={clsx('rmd-header', classNames?.header)}>\n <div className={clsx('rmd-nav-button-slot-start', classNames?.navButtonSlotStart)}>\n {index === 0 && calendars.length < 12 && (\n <button\n {...wrappedGetBackProps({ calendars })}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n )}\n </div>\n <span className={clsx('rmd-header-title-container', classNames?.headerTitleContainer)}>\n {monthNames[calendar.month]}\n {calendars.length < 12 ? ` ${calendar.year}` : ''}\n </span>\n <div className={clsx('rmd-nav-button-slot-end', classNames?.navButtonSlotEnd)}>\n {index === calendars.length - 1 && calendars.length < 12 && (\n <button\n {...wrappedGetForwardProps({ calendars })}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n )}\n </div>\n </div>\n )}\n <div role=\"row\" className={clsx('rmd-weekday-grid', classNames?.weekdayGrid)}>\n {sortedWeekdays.map((day) => (\n <div\n key={day}\n role=\"columnheader\"\n aria-label={day}\n className={clsx('rmd-weekday', classNames?.weekday)}\n >\n {day}\n </div>\n ))}\n </div>\n <div\n key={`daysGrid-${calendar.month}-${calendar.year}`}\n role=\"row\"\n className={clsx(\n 'rmd-days-grid',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.daysGrid\n )}\n >\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => {\n if (!dateObj) {\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={null}\n getDateProps={getDateProps}\n classNames={classNames}\n />\n );\n }\n\n const dateKey = getDateKey(dateObj.date);\n const isFocused = adapter.isSame(\n adapter.date(dateObj.date),\n adapter.date(currentFocusedDate),\n 'day'\n );\n\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n dayProps={getDayProps?.(dateObj)}\n classNames={classNames}\n tabIndex={isFocused ? 0 : -1}\n adapter={adapter}\n locale={locale}\n onKeyDown={handleDayKeyDown}\n onFocus={(dObj) => {\n setFocusedDate(dObj.date);\n }}\n buttonRef={(el) => {\n if (el) {\n dayButtonRefs.current.set(dateKey, el);\n } else {\n dayButtonRefs.current.delete(dateKey);\n }\n }}\n />\n );\n })\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={clsx('rmd-footer', classNames?.footer)}>{footer}</div>}\n </div>\n );\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;CAAG,IAAa,OAAO,KAAjB,YAA8B,OAAO,KAAjB,UAAmB,KAAG;MAAO,IAAa,OAAO,KAAjB,UAAmB;MAAG,MAAM,QAAQ,CAAC,GAAE;GAAC,IAAI,IAAE,EAAE;GAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;EAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;CAAA;CAAG,OAAO;AAAC;AAAC,SAAgB,IAAM;CAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,IAAE,UAAU,QAAM,IAAE,EAAE,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;CAAG,OAAO;AAAC;;;ACY/W,SAAgB,EAAY,IAAuB,GAAgB,GAA+B;CAChG,OAAO;EACL,QAAQ,EAAQ,UAAU,CAAM;EAChC,UAAU,EAAQ,YAAY,CAAM;EACpC,MAAM;EACN,SAAS;EACT,aAAa;EACb,YAAY;CACd;AACF;AAEA,SAAgB,EACZ,IAAuB,GACvB,GACA,GACY;CAEd,OAAO;EAAE,GADI,EAAY,GAAS,CACtB;EAAM,GAAG;CAAO;AAC9B;;;ACbA,IAAa,UACX,kBAAC,OAAD;CAAK,OAAM;CAAK,QAAO;CAAK,SAAQ;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,EAAQ,OACxB,EAAQ,KAAK,EAAQ,IAAI,GACzB,EAAQ,KAAK,CAAkB,GAC/B,KACF;SAEA,OACE,kBAAC,GAAD;UAEW;UACK;UACd,UAAU,IAAc,CAAO;UACnB;UACZ,UAAU,IAAY,IAAI;UACjB;UACD;UACR,WAAW;UACX,UAAU,MAAS;WACjB,EAAe,EAAK,IAAI;UAC1B;UACA,YAAY,MAAO;WACjB,AAAI,IACF,EAAc,QAAQ,IAAI,GAAS,CAAE,IAErC,EAAc,QAAQ,OAAO,CAAO;UAExC;SACD,GAnBM,GAAG,EAAG,GAAG,GAmBf;QAEL,CAAC,CACH;OACG,GAtDE,YAAY,EAAS,MAAM,GAAG,EAAS,MAsDzC;MACF;KAxGE,GAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MAwGhC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAK,cAAc,GAAY,MAAM;IAAI,UAAA;GAAY,CAAA;EAC7E;;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/components/Day.tsx","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n selectMonth?: string;\n selectYear?: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month',\n selectMonth: 'Select month',\n selectYear: 'Select year'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import clsx from 'clsx';\nimport React from 'react';\nimport { Translations } from '../i18n';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args?: Record<string, unknown>) => Record<string, unknown>;\n getForwardProps: (args?: Record<string, unknown>) => Record<string, unknown>;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: Translations;\n classNames?: CalendarClassNames;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n if (calendars.length > 1 && calendars.length < 12) {\n return null;\n }\n\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n\n const isNavHidden = !!(currentView && currentView !== 'days');\n const navButtonClassName = clsx(\n 'rmd-nav-button',\n isNavHidden && 'rmd-nav-button-hidden',\n classNames?.navButton,\n isNavHidden && classNames?.navButtonHidden\n );\n\n const monthYearLabelClassName = clsx(\n 'rmd-month-year-label',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.monthYearLabel\n );\n\n return (\n <div className={clsx(\n 'rmd-header',\n calendars.length > 1 && 'rmd-header-multi-month',\n classNames?.header,\n calendars.length > 1 && classNames?.headerMultiMonth\n )}>\n <button\n {...(getBackProps({ calendars }) as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={navButtonClassName}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={clsx('rmd-month-year-container', classNames?.monthYearContainer)}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={monthYearLabelClassName}>\n <button\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${monthNames[calendars[0].month]}, ${t.selectMonth || 'Select month'}`}\n aria-expanded={currentView === 'months'}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={clsx('rmd-month-year-button', classNames?.monthYearButton)}\n aria-label={`${calendars[0].year}, ${t.selectYear || 'Select year'}`}\n aria-expanded={currentView === 'years'}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={monthYearLabelClassName}>\n <span>\n {first.year === last.year ? first.year : `${first.year} - ${last.year}`}\n </span>\n </div>\n )}\n </div>\n\n <button\n {...(getForwardProps({ calendars }) as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={navButtonClassName}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","import React from 'react';\nimport clsx from 'clsx';\nimport type { CalendarClassNames, DateAdapter, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: unknown }) => Record<string, unknown>;\n dayProps?: Record<string, unknown>;\n classNames?: CalendarClassNames;\n tabIndex?: number;\n adapter?: DateAdapter;\n locale?: string;\n onKeyDown?: (e: React.KeyboardEvent, dateObj: DateObj) => void;\n onFocus?: (dateObj: DateObj) => void;\n buttonRef?: (el: HTMLButtonElement | null) => void;\n}\n\nexport const Day: React.FC<DayProps> = ({\n dateObj,\n getDateProps,\n dayProps,\n classNames,\n tabIndex = -1,\n adapter,\n locale,\n onKeyDown,\n onFocus,\n buttonRef\n}) => {\n if (!dateObj) {\n return <div role=\"gridcell\" aria-hidden=\"true\" className={clsx('rmd-day-empty', classNames?.day?.empty)} />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames?.day;\n\n let semanticStateClass = '';\n let customStateClass = '';\n\n if (isRangeStart && isRangeEnd) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (isRangeStart) {\n semanticStateClass = clsx('rmd-day-range-start', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeStart || '';\n } else if (isRangeEnd) {\n semanticStateClass = clsx('rmd-day-range-end', isRangeActive && 'rmd-day-range-active');\n customStateClass = dayClasses?.rangeEnd || '';\n } else if (isRangeBetween) {\n semanticStateClass = 'rmd-day-range-between';\n customStateClass = dayClasses?.rangeBetween || '';\n } else if (isRangeHovering) {\n semanticStateClass = 'rmd-day-range-hovering';\n customStateClass = dayClasses?.rangeHovering || '';\n } else if (selected) {\n semanticStateClass = 'rmd-day-selected';\n customStateClass = dayClasses?.selected || '';\n } else if (!selectable) {\n semanticStateClass = 'rmd-day-disabled';\n customStateClass = dayClasses?.disabled || '';\n } else {\n semanticStateClass = 'rmd-day-unselected';\n customStateClass = dayClasses?.unselected || '';\n }\n\n const modifierClasses = (dateObj.modifiers || [])\n .map(m => (dayClasses as Record<string, string | undefined> | undefined)?.[m] || m)\n .filter(Boolean);\n\n const formattedDateLabel = adapter\n ? adapter.format(adapter.date(date), 'dddd, MMMM D, YYYY', locale)\n : date.toDateString();\n\n const isSelected = !!(selected || isRangeStart || isRangeEnd);\n\n const baseProps = getDateProps({ dateObj, ...dayProps }) as React.ButtonHTMLAttributes<HTMLButtonElement>;\n\n return (\n <button\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={!selectable}\n aria-label={formattedDateLabel}\n tabIndex={tabIndex}\n {...(baseProps as React.HTMLAttributes<HTMLButtonElement>)}\n ref={buttonRef}\n onKeyDown={(e) => {\n baseProps.onKeyDown?.(e);\n onKeyDown?.(e, dateObj);\n }}\n onFocus={(e) => {\n baseProps.onFocus?.(e);\n onFocus?.(dateObj);\n }}\n className={clsx(\n 'rmd-day',\n dayClasses?.day,\n semanticStateClass,\n customStateClass,\n modifierClasses\n )}\n >\n {date.getDate()}\n </button>\n );\n};\n","import React, { useState, useRef, useEffect } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const [focusedMonth, setFocusedMonth] = useState<number>(month);\n const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n useEffect(() => {\n buttonRefs.current[focusedMonth]?.focus();\n }, [focusedMonth]);\n\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent, idx: number) => {\n let nextIndex = focusedMonth;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextIndex = (idx - 1 + 12) % 12;\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextIndex = (idx + 1) % 12;\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextIndex = (idx - 3 + 12) % 12;\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextIndex = (idx + 3) % 12;\n break;\n case 'Home':\n e.preventDefault();\n nextIndex = 0;\n break;\n case 'End':\n e.preventDefault();\n nextIndex = 11;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!isMonthDisabled(idx)) {\n onMonthSelect(idx);\n }\n return;\n default:\n return;\n }\n\n setFocusedMonth(nextIndex);\n };\n\n const gridClassName = clsx('rmd-months-grid', classNames?.monthsGrid);\n\n return (\n <div\n role=\"grid\"\n aria-label=\"Select month\"\n className={gridClassName}\n >\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n const isSelected = idx === month;\n const isFocused = idx === focusedMonth;\n const buttonClassName = clsx(\n 'rmd-month-button',\n isSelected ? 'rmd-month-button-selected' : 'rmd-month-button-unselected',\n classNames?.monthButton,\n isSelected ? classNames?.monthButtonSelected : classNames?.monthButtonUnselected\n );\n\n return (\n <button\n key={name}\n ref={(el) => {\n buttonRefs.current[idx] = el;\n }}\n role=\"gridcell\"\n aria-selected={isSelected}\n aria-disabled={disabled}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => !disabled && onMonthSelect(idx)}\n onKeyDown={(e) => handleKeyDown(e, idx)}\n onFocus={() => setFocusedMonth(idx)}\n className={buttonClassName}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames?: CalendarClassNames;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n const [focusedYear, setFocusedYear] = useState<number>(year);\n const buttonRefs = useRef<Map<number, HTMLButtonElement>>(new Map());\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years: number[] = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n useEffect(() => {\n if (yearListRef.current) {\n const container = yearListRef.current;\n const selectedYearBtn = container.querySelector('[data-selected=\"true\"]') as HTMLElement | null;\n if (selectedYearBtn) {\n const targetScrollTop =\n selectedYearBtn.offsetTop - container.clientHeight / 2 + selectedYearBtn.clientHeight / 2;\n container.scrollTop = Math.max(0, targetScrollTop);\n }\n }\n }, []);\n\n useEffect(() => {\n const btn = buttonRefs.current.get(focusedYear);\n if (btn) {\n btn.focus();\n }\n }, [focusedYear]);\n\n const handleKeyDown = (e: React.KeyboardEvent, y: number) => {\n let nextYear = focusedYear;\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 1);\n break;\n case 'ArrowRight':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 1);\n break;\n case 'ArrowUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 3);\n break;\n case 'ArrowDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 3);\n break;\n case 'PageUp':\n e.preventDefault();\n nextYear = Math.max(startYear, y - 10);\n break;\n case 'PageDown':\n e.preventDefault();\n nextYear = Math.min(endYear, y + 10);\n break;\n case 'Home':\n e.preventDefault();\n nextYear = startYear;\n break;\n case 'End':\n e.preventDefault();\n nextYear = endYear;\n break;\n case 'Enter':\n case ' ':\n e.preventDefault();\n onYearSelect(y);\n return;\n default:\n return;\n }\n\n setFocusedYear(nextYear);\n };\n\n return (\n <div\n ref={yearListRef}\n role=\"grid\"\n aria-label=\"Select year\"\n className={clsx('rmd-years-grid', classNames?.yearsGrid)}\n >\n {years.map((y) => {\n const isSelected = y === year;\n const isFocused = y === focusedYear;\n const buttonClassName = clsx(\n 'rmd-year-button',\n isSelected ? 'rmd-year-button-selected' : 'rmd-year-button-unselected',\n classNames?.yearButton,\n isSelected ? classNames?.yearButtonSelected : classNames?.yearButtonUnselected\n );\n\n return (\n <button\n key={y}\n ref={(el) => {\n if (el) buttonRefs.current.set(y, el);\n else buttonRefs.current.delete(y);\n }}\n data-selected={isSelected}\n role=\"gridcell\"\n aria-selected={isSelected}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => onYearSelect(y)}\n onKeyDown={(e) => handleKeyDown(e, y)}\n onFocus={() => setFocusedYear(y)}\n className={buttonClassName}\n >\n {y}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useState, useRef, useEffect, useMemo } from 'react';\nimport clsx from 'clsx';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarClassNames, DateObj } from '../types';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { CalendarHeader, ChevronLeftIcon, ChevronRightIcon, HeaderProps } from './CalendarHeader';\nimport { Day } from './Day';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: HeaderProps) => React.ReactNode);\n footer?: React.ReactNode;\n getDayProps?: (dateObj: DateObj) => Record<string, unknown>;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nconst getDateKey = (d: Date): string =>\n `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n getDayProps,\n ...useDatesProps\n } = props;\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n const [daysHeight, setDaysHeight] = useState<number | null>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const [announcement, setAnnouncement] = useState<string>('');\n\n const daysContainerRef = useRef<HTMLDivElement | null>(null);\n const rootRef = useRef<HTMLDivElement | null>(null);\n const dayButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n const isKeyboardNavigating = useRef<boolean>(false);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n useEffect(() => {\n if (view === 'days' && daysContainerRef.current) {\n const el = daysContainerRef.current;\n const updateHeight = () => {\n if (el.offsetHeight > 0) {\n setDaysHeight(el.offsetHeight);\n }\n };\n updateHeight();\n\n if (typeof ResizeObserver !== 'undefined') {\n const observer = new ResizeObserver(() => {\n updateHeight();\n });\n observer.observe(el);\n return () => observer.disconnect();\n }\n }\n }, [view, calendars]);\n\n useEffect(() => {\n if (view === 'days' && calendars.length > 0) {\n if (calendars.length === 1) {\n setAnnouncement(`${monthNames[calendars[0].month]} ${calendars[0].year}`);\n } else {\n setAnnouncement(\n `${monthNames[calendars[0].month]} ${calendars[0].year} to ${\n monthNames[calendars[calendars.length - 1].month]\n } ${calendars[calendars.length - 1].year}`\n );\n }\n } else if (view === 'months') {\n setAnnouncement('Month selection view');\n } else if (view === 'years') {\n setAnnouncement('Year selection view');\n }\n }, [view, calendars, monthNames]);\n\n // Determine default active focused date if focusedDate is not set\n const defaultFocusedDate = useMemo(() => {\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.selected) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && dateObj.today) {\n return dateObj.date;\n }\n }\n }\n }\n for (const cal of calendars) {\n for (const week of cal.weeks) {\n for (const dateObj of week) {\n if (dateObj?.selectable && !dateObj.prevMonth && !dateObj.nextMonth) {\n return dateObj.date;\n }\n }\n }\n }\n return calendars[0]?.weeks[0]?.find((d) => d?.selectable)?.date || new Date();\n }, [calendars]);\n\n const currentFocusedDate = focusedDate || defaultFocusedDate;\n\n useEffect(() => {\n if (view === 'days' && currentFocusedDate && isKeyboardNavigating.current) {\n const key = getDateKey(currentFocusedDate);\n const btn = dayButtonRefs.current.get(key);\n if (btn) {\n btn.focus();\n }\n }\n }, [currentFocusedDate, calendars, view]);\n\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const stepOffset = useDatesProps.monthsToDisplay || 1;\n\n const wrappedGetBackProps = (args?: Record<string, unknown>) => {\n const props = getBackProps({ offset: stepOffset, ...args }) as { onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; [key: string]: unknown };\n return {\n ...props,\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args?: Record<string, unknown>) => {\n const props = getForwardProps({ offset: stepOffset, ...args }) as { onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; [key: string]: unknown };\n return {\n ...props,\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const handleDayKeyDown = (e: React.KeyboardEvent, dateObj: DateObj) => {\n const isRTL = Boolean(\n rootRef.current?.closest('[dir=\"rtl\"]') ||\n (typeof document !== 'undefined' && document.documentElement.dir === 'rtl')\n );\n\n let newDate: Date | null = null;\n const current = adapter.date(dateObj.date);\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? 1 : -1, 'day'));\n break;\n case 'ArrowRight':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, isRTL ? -1 : 1, 'day'));\n break;\n case 'ArrowUp':\n e.preventDefault();\n newDate = adapter.toDate(adapter.subtract(current, 7, 'day'));\n break;\n case 'ArrowDown':\n e.preventDefault();\n newDate = adapter.toDate(adapter.add(current, 7, 'day'));\n break;\n case 'Home': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = (currentDayOfWeek - firstDayOfWeek + 7) % 7;\n newDate = adapter.toDate(adapter.subtract(current, diff, 'day'));\n break;\n }\n case 'End': {\n e.preventDefault();\n const currentDayOfWeek = adapter.toDate(current).getDay();\n const diff = 6 - ((currentDayOfWeek - firstDayOfWeek + 7) % 7);\n newDate = adapter.toDate(adapter.add(current, diff, 'day'));\n break;\n }\n case 'PageUp': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.subtract(current, 1, unit));\n break;\n }\n case 'PageDown': {\n e.preventDefault();\n const unit = e.shiftKey ? 'year' : 'month';\n newDate = adapter.toDate(adapter.add(current, 1, unit));\n break;\n }\n case 'Enter':\n case ' ': {\n // Native button press handles click event\n return;\n }\n default:\n return;\n }\n\n if (newDate) {\n isKeyboardNavigating.current = true;\n setFocusedDate(newDate);\n\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const targetMonth = adapter.startOf(adapter.date(newDate), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setOffset(newOffset);\n }\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div ref={rootRef} className={clsx('rmd', 'rmd-root', classNames?.root)}>\n <div className=\"rmd-sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {announcement}\n </div>\n\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={clsx('rmd-calendars-container', classNames?.calendarsContainer)}>\n {view === 'months' && calendars.map((calendar) => (\n <div\n key={`months-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div\n key={`years-${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n style={daysHeight ? { height: `${daysHeight}px` } : undefined}\n >\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar, index) => (\n <div\n key={`${calendar.month}-${calendar.year}`}\n ref={index === 0 ? daysContainerRef : undefined}\n role=\"grid\"\n aria-label={`${monthNames[calendar.month]} ${calendar.year}`}\n className={clsx('rmd-calendar-container', classNames?.calendarContainer)}\n >\n {calendars.length > 1 && (\n <div className={clsx('rmd-header', classNames?.header)}>\n <div className={clsx('rmd-nav-button-slot-start', classNames?.navButtonSlotStart)}>\n {index === 0 && calendars.length < 12 && (\n <button\n {...(wrappedGetBackProps({ calendars }) as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n )}\n </div>\n <span className={clsx('rmd-header-title-container', classNames?.headerTitleContainer)}>\n {monthNames[calendar.month]}\n {calendars.length < 12 ? ` ${calendar.year}` : ''}\n </span>\n <div className={clsx('rmd-nav-button-slot-end', classNames?.navButtonSlotEnd)}>\n {index === calendars.length - 1 && calendars.length < 12 && (\n <button\n {...(wrappedGetForwardProps({ calendars }) as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n className={clsx('rmd-nav-button', classNames?.navButton)}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n )}\n </div>\n </div>\n )}\n <div role=\"row\" className={clsx('rmd-weekday-grid', classNames?.weekdayGrid)}>\n {sortedWeekdays.map((day) => (\n <div\n key={day}\n role=\"columnheader\"\n aria-label={day}\n className={clsx('rmd-weekday', classNames?.weekday)}\n >\n {day}\n </div>\n ))}\n </div>\n <div\n key={`daysGrid-${calendar.month}-${calendar.year}`}\n role=\"row\"\n className={clsx(\n 'rmd-days-grid',\n slideDirection === 'left' && 'rmd-slide-left',\n slideDirection === 'right' && 'rmd-slide-right',\n classNames?.daysGrid\n )}\n >\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => {\n if (!dateObj) {\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={null}\n getDateProps={getDateProps}\n classNames={classNames}\n />\n );\n }\n\n const dateKey = getDateKey(dateObj.date);\n const isFocused = adapter.isSame(\n adapter.date(dateObj.date),\n adapter.date(currentFocusedDate),\n 'day'\n );\n\n return (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n dayProps={getDayProps?.(dateObj)}\n classNames={classNames}\n tabIndex={isFocused ? 0 : -1}\n adapter={adapter}\n locale={locale}\n onKeyDown={handleDayKeyDown}\n onFocus={(dObj) => {\n setFocusedDate(dObj.date);\n }}\n buttonRef={(el) => {\n if (el) {\n dayButtonRefs.current.set(dateKey, el);\n } else {\n dayButtonRefs.current.delete(dateKey);\n }\n }}\n />\n );\n })\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={clsx('rmd-footer', classNames?.footer)}>{footer}</div>}\n </div>\n );\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAAA,SAAS,EAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;CAAG,IAAa,OAAO,KAAjB,YAA8B,OAAO,KAAjB,UAAmB,KAAG;MAAO,IAAa,OAAO,KAAjB,UAAmB;MAAG,MAAM,QAAQ,CAAC,GAAE;GAAC,IAAI,IAAE,EAAE;GAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;EAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;CAAA;CAAG,OAAO;AAAC;AAAC,SAAgB,IAAM;CAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,IAAE,UAAU,QAAM,IAAE,EAAE,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;CAAG,OAAO;AAAC;;;ACY/W,SAAgB,EAAY,IAAuB,GAAgB,GAA+B;CAChG,OAAO;EACL,QAAQ,EAAQ,UAAU,CAAM;EAChC,UAAU,EAAQ,YAAY,CAAM;E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AW,mBAC9B,GAAY,QACd;QAEC,UAAA,EAAS,MAAM,KAAK,GAAM,MACzB,EAAK,KAAK,GAAS,MAAO;SACxB,IAAI,CAAC,GACH,OACE,kBAAC,GAAD;UAEE,SAAS;UACK;UACF;SACb,GAJM,GAAG,EAAG,GAAG,GAIf;SAIL,IAAM,IAAU,EAAW,EAAQ,IAAI,GACjC,IAAY,EAAQ,OACxB,EAAQ,KAAK,EAAQ,IAAI,GACzB,EAAQ,KAAK,CAAkB,GAC/B,KACF;SAEA,OACE,kBAAC,GAAD;UAEW;UACK;UACd,UAAU,IAAc,CAAO;UACnB;UACZ,UAAU,IAAY,IAAI;UACjB;UACD;UACR,WAAW;UACX,UAAU,MAAS;WACjB,EAAe,EAAK,IAAI;UAC1B;UACA,YAAY,MAAO;WACjB,AAAI,IACF,EAAc,QAAQ,IAAI,GAAS,CAAE,IAErC,EAAc,QAAQ,OAAO,CAAO;UAExC;SACD,GAnBM,GAAG,EAAG,GAAG,GAmBf;QAEL,CAAC,CACH;OACG,GAtDE,YAAY,EAAS,MAAM,GAAG,EAAS,MAsDzC;MACF;KAxGE,GAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MAwGhC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAK,cAAc,GAAY,MAAM;IAAI,UAAA;GAAY,CAAA;EAC7E;;AAET"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CalendarClassNames } from './classNames';
|
|
2
|
-
export interface DateAdapter<T =
|
|
3
|
-
date(value?:
|
|
2
|
+
export interface DateAdapter<T = unknown> {
|
|
3
|
+
date(value?: unknown): T;
|
|
4
4
|
add(date: T, amount: number, unit: 'day' | 'month' | 'year'): T;
|
|
5
5
|
subtract(date: T, amount: number, unit: 'day' | 'month' | 'year'): T;
|
|
6
6
|
startOf(date: T, unit: 'day' | 'month' | 'year'): T;
|
|
@@ -74,7 +74,7 @@ function g(e, { onClick: n, dateObj: r, ...i }) {
|
|
|
74
74
|
...i
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function _({ minDate: e, offsetMonth: n, handleOffsetChanged: i, adapter: o }, { onClick: s, offset: c = 1, calendars: l, ...u }) {
|
|
77
|
+
function _({ minDate: e, offsetMonth: n, handleOffsetChanged: i, adapter: o }, { onClick: s, offset: c = 1, calendars: l = [], ...u } = {}) {
|
|
78
78
|
return {
|
|
79
79
|
onClick: t(s, () => {
|
|
80
80
|
i(n - a({
|
|
@@ -92,7 +92,7 @@ function _({ minDate: e, offsetMonth: n, handleOffsetChanged: i, adapter: o }, {
|
|
|
92
92
|
...u
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
function v({ maxDate: n, offsetMonth: r, handleOffsetChanged: a, adapter: o }, { onClick: s, offset: c = 1, calendars: l, ...u }) {
|
|
95
|
+
function v({ maxDate: n, offsetMonth: r, handleOffsetChanged: a, adapter: o }, { onClick: s, offset: c = 1, calendars: l = [], ...u } = {}) {
|
|
96
96
|
return {
|
|
97
97
|
onClick: t(s, () => {
|
|
98
98
|
a(r + e({
|
|
@@ -110,91 +110,93 @@ function v({ maxDate: n, offsetMonth: r, handleOffsetChanged: a, adapter: o }, {
|
|
|
110
110
|
...u
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disabledDates: a, monthsToDisplay: c = 1, firstDayOfWeek: l = 0, offset: u, onDateSelected: d, onOffsetChanged: f = () => {}, selected: y,
|
|
114
|
-
let [
|
|
115
|
-
m(u) ||
|
|
116
|
-
let n =
|
|
117
|
-
|
|
118
|
-
let i =
|
|
119
|
-
|
|
113
|
+
function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disabledDates: a, monthsToDisplay: c = 1, firstDayOfWeek: l = 0, offset: u, onDateSelected: d, onOffsetChanged: f = () => {}, selected: y, defaultSelected: b, modifiers: x, selectionMode: S = "single", adapter: C = p, onChange: w, onMonthChange: T, onYearChange: E } = {}) {
|
|
114
|
+
let [D, O] = s(0), [k, A] = s(void 0), [j, M] = s(b ?? null), N = y !== void 0, P = N ? y : j, F = h(u, D), I = o((t) => {
|
|
115
|
+
m(u) || O(t), f(t);
|
|
116
|
+
let n = C.add(C.startOf(C.date(e), "month"), t, "month"), r = Array.from({ length: c }, (e, t) => C.toDate(C.startOf(C.add(n, t, "month"), "month")));
|
|
117
|
+
T?.(r);
|
|
118
|
+
let i = C.toDate(n);
|
|
119
|
+
E?.(i);
|
|
120
120
|
}, [
|
|
121
121
|
u,
|
|
122
122
|
f,
|
|
123
123
|
e,
|
|
124
|
-
|
|
124
|
+
C,
|
|
125
125
|
c,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
]),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
126
|
+
T,
|
|
127
|
+
E
|
|
128
|
+
]), L = o((e, t) => {
|
|
129
|
+
d?.(e, t);
|
|
130
|
+
let n = null;
|
|
131
|
+
if (S === "single") n = e.date;
|
|
132
|
+
else if (S === "multiple") {
|
|
133
|
+
let t = Array.isArray(P) ? P : P instanceof Date ? [P] : [];
|
|
134
|
+
n = t.some((t) => C.isSame(C.date(t), C.date(e.date), "day")) ? t.filter((t) => !C.isSame(C.date(t), C.date(e.date), "day")) : [...t, e.date];
|
|
135
|
+
} else if (S === "range") {
|
|
136
|
+
let t = P && typeof P == "object" && !(P instanceof Date) && !Array.isArray(P) ? P : {
|
|
137
|
+
start: void 0,
|
|
138
|
+
end: void 0
|
|
139
|
+
};
|
|
140
|
+
n = !t.start || t.start && t.end ? {
|
|
141
|
+
start: e.date,
|
|
142
|
+
end: void 0
|
|
143
|
+
} : C.isBefore(C.date(e.date), C.date(t.start), "day") ? {
|
|
144
|
+
start: e.date,
|
|
145
|
+
end: t.start
|
|
146
|
+
} : {
|
|
147
|
+
start: t.start,
|
|
148
|
+
end: e.date
|
|
149
|
+
};
|
|
150
150
|
}
|
|
151
|
+
N || M(n), w?.(n);
|
|
151
152
|
}, [
|
|
152
153
|
d,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
w,
|
|
155
|
+
S,
|
|
156
|
+
P,
|
|
157
|
+
N,
|
|
158
|
+
C
|
|
157
159
|
]);
|
|
158
160
|
return {
|
|
159
161
|
calendars: n({
|
|
160
162
|
date: e,
|
|
161
|
-
selected:
|
|
163
|
+
selected: P,
|
|
162
164
|
disabledDates: a,
|
|
163
|
-
modifiers:
|
|
165
|
+
modifiers: x,
|
|
164
166
|
monthsToDisplay: c,
|
|
165
167
|
minDate: i,
|
|
166
168
|
maxDate: r,
|
|
167
|
-
offset:
|
|
169
|
+
offset: F,
|
|
168
170
|
firstDayOfWeek: l,
|
|
169
|
-
adapter:
|
|
170
|
-
selectionMode:
|
|
171
|
-
hoveredDate:
|
|
171
|
+
adapter: C,
|
|
172
|
+
selectionMode: S,
|
|
173
|
+
hoveredDate: k
|
|
172
174
|
}),
|
|
173
175
|
getDateProps: (e) => ({
|
|
174
|
-
...g(
|
|
176
|
+
...g(L, e),
|
|
175
177
|
onMouseEnter: t(e.onMouseEnter, () => {
|
|
176
|
-
|
|
178
|
+
A(e.dateObj.date);
|
|
177
179
|
}),
|
|
178
180
|
onMouseLeave: t(e.onMouseLeave, () => {
|
|
179
|
-
|
|
181
|
+
A(void 0);
|
|
180
182
|
})
|
|
181
183
|
}),
|
|
182
184
|
getBackProps: _.bind(null, {
|
|
183
185
|
minDate: i,
|
|
184
|
-
offsetMonth:
|
|
185
|
-
handleOffsetChanged:
|
|
186
|
-
adapter:
|
|
186
|
+
offsetMonth: F,
|
|
187
|
+
handleOffsetChanged: I,
|
|
188
|
+
adapter: C
|
|
187
189
|
}),
|
|
188
190
|
getForwardProps: v.bind(null, {
|
|
189
191
|
maxDate: r,
|
|
190
|
-
offsetMonth:
|
|
191
|
-
handleOffsetChanged:
|
|
192
|
-
adapter:
|
|
192
|
+
offsetMonth: F,
|
|
193
|
+
handleOffsetChanged: I,
|
|
194
|
+
adapter: C
|
|
193
195
|
}),
|
|
194
|
-
setOffset:
|
|
196
|
+
setOffset: I
|
|
195
197
|
};
|
|
196
198
|
}
|
|
197
199
|
//#endregion
|
|
198
200
|
export { f as n, p as r, y as t };
|
|
199
201
|
|
|
200
|
-
//# sourceMappingURL=useDates-
|
|
202
|
+
//# sourceMappingURL=useDates-BvwdhdUS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDates-BvwdhdUS.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?: unknown): Dayjs {\n return dayjs(value as dayjs.ConfigType);\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 React, { 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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\n onDateSelected: (dateObj: DateObj, event: E) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: E) => void, dateObj: DateObj, [key: string]: unknown }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: E) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\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: E) => void, offset?: number, calendars?: Calendar[], [key: string]: unknown } = {}\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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\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: E) => void, offset?: number, calendars?: Calendar[], [key: string]: unknown } = {}\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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent> {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: E) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date } | null;\n defaultSelected?: Date | Date[] | { start?: Date, end?: Date } | null;\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (dates: Date[]) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n defaultSelected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps<E> = {}) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const [uncontrolledSelected, setUncontrolledSelected] = useState<\n Date | Date[] | { start?: Date; end?: Date } | null | undefined\n >(defaultSelected ?? null);\n\n const isControlled = selected !== undefined;\n const effectiveSelected = isControlled ? selected : uncontrolledSelected;\n\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const startDate = adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month');\n const firstDays = Array.from({ length: monthsToDisplay }, (_, i) =>\n adapter.toDate(adapter.startOf(adapter.add(startDate, i, 'month'), 'month'))\n );\n onMonthChange?.(firstDays);\n\n const newDate = adapter.toDate(startDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, monthsToDisplay, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: E) => {\n onDateSelected?.(dateObj, event);\n\n let nextSelected: Date | Date[] | { start?: Date; end?: Date } | null = null;\n\n if (selectionMode === 'single') {\n nextSelected = dateObj.date;\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(effectiveSelected)\n ? effectiveSelected\n : (effectiveSelected instanceof Date ? [effectiveSelected] : []);\n const isAlreadySelected = currentSelected.some(d =>\n adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')\n );\n if (isAlreadySelected) {\n nextSelected = currentSelected.filter(d =>\n !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')\n );\n } else {\n nextSelected = [...currentSelected, dateObj.date];\n }\n } else if (selectionMode === 'range') {\n const range = (effectiveSelected && typeof effectiveSelected === 'object' && !(effectiveSelected instanceof Date) && !Array.isArray(effectiveSelected))\n ? (effectiveSelected as { start?: Date; end?: Date })\n : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n nextSelected = { start: dateObj.date, end: undefined };\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n nextSelected = { start: dateObj.date, end: range.start };\n } else {\n nextSelected = { start: range.start, end: dateObj.date };\n }\n }\n }\n\n if (!isControlled) {\n setUncontrolledSelected(nextSelected);\n }\n\n onChange?.(nextSelected);\n }, [onDateSelected, onChange, selectionMode, effectiveSelected, isControlled, adapter]);\n\n const calendars = getCalendars({\n date,\n selected: effectiveSelected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: <EventE extends { defaultPrevented?: boolean } = E>(\n args: { onClick?: (event: EventE) => void, onMouseEnter?: (event: EventE) => void, onMouseLeave?: (event: EventE) => void, dateObj: DateObj, [key: string]: unknown }\n ) => {\n const props = getDateProps<EventE>(handleDateSelected as unknown as (dateObj: DateObj, event: EventE) => void, 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,GAAwB;EAC3B,OAAO,EAAM,CAAyB;CACxC;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,IAAI,CAAI;CACtB;CAEA,OAAO,GAAa,GAAmB,GAAyB;EAI9D,OAHI,IACK,EAAK,OAAO,CAAM,CAAC,CAAC,OAAO,CAAS,IAEtC,EAAK,OAAO,CAAS;CAC9B;CAEA,eAAe,GAAqB;EAClC,OAAO,EAAK,YAAY;CAC1B;CAEA,OAAO,GAAmB;EACxB,OAAO,EAAK,OAAO;CACrB;CAE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,EAAK,oBAAoB;IACxD,EAAe,KAAA,CAAS;GAC5B,CAAC;EACL;EAEJ,cAAc,EAAa,KAAK,MAAM;GAClC;GACA;GACA;GACA;EACJ,CAAC;EACD,iBAAiB,EAAgB,KAAK,MAAM;GACxC;GACA;GACA;GACA;EACJ,CAAC;EACD,WAAW;CACf;AACJ"}
|
|
@@ -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.cjs");let l=require("react"),u=require("dayjs");u=s(u,1);let d=require("dayjs/plugin/isBetween");d=s(d,1);let f=require("dayjs/plugin/customParseFormat");f=s(f,1);let p=require("dayjs/plugin/localeData");p=s(p,1),u.default.extend(d.default),u.default.extend(f.default),u.default.extend(p.default);var m=class{date(e){return(0,u.default)(e)}add(e,t,n){return e.add(t,n)}subtract(e,t,n){return e.subtract(t,n)}startOf(e,t){return e.startOf(t)}endOf(e,t){return e.endOf(t)}isBefore(e,t,n){return e.isBefore(t,n)}isAfter(e,t,n){return e.isAfter(t,n)}isSame(e,t,n){return e.isSame(t,n)}set(e,t,n){return t===`day`?e.date(n):e.set(t,n)}get(e,t){return t===`day`?e.date():e.get(t)}format(e,t,n){return n?e.locale(n).format(t):e.format(t)}getDaysInMonth(e){return e.daysInMonth()}toDate(e){return e.toDate()}diff(e,t,n){return e.diff(t,n)}getMonths(e){return e?(0,u.default)().locale(e).localeData().months():u.default.localeData().months()}getWeekdays(e){return e?(0,u.default)().locale(e).localeData().weekdaysShort().map(e=>e.toUpperCase()):u.default.localeData().weekdaysShort().map(e=>e.toUpperCase())}},h=new m;function g(e){return e!==void 0}function _(e,t=0){return g(e)?e:t}function v(e,{onClick:t,dateObj:n,...r}){return{onClick:c.composeEventHandlers(t,t=>{e(n,t)}),disabled:!n.selectable,"aria-pressed":n.selected,role:`button`,...r}}function y({minDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o=[],...s}={}){return{onClick:c.composeEventHandlers(i,()=>{n(t-c.subtractMonth({calendars:o,offset:a,minDate:e,adapter:r}))}),disabled:c.isBackDisabled({calendars:o,minDate:e,adapter:r}),...s}}function b({maxDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o=[],...s}={}){return{onClick:c.composeEventHandlers(i,()=>{n(t+c.addMonth({calendars:o,offset:a,maxDate:e,adapter:r}))}),disabled:c.isForwardDisabled({calendars:o,maxDate:e,adapter:r}),...s}}function x({date:e=new Date,maxDate:t,minDate:n,disabledDates:r,monthsToDisplay:i=1,firstDayOfWeek:a=0,offset:o,onDateSelected:s,onOffsetChanged:u=()=>{},selected:d,defaultSelected: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,A]=(0,l.useState)(f??null),j=d!==void 0,M=j?d:k,N=_(o,T),P=(0,l.useCallback)(t=>{g(o)||E(t),u(t);let n=x.add(x.startOf(x.date(e),`month`),t,`month`),r=Array.from({length:i},(e,t)=>x.toDate(x.startOf(x.add(n,t,`month`),`month`)));C?.(r);let a=x.toDate(n);w?.(a)},[o,u,e,x,i,C,w]),F=(0,l.useCallback)((e,t)=>{s?.(e,t);let n=null;if(m===`single`)n=e.date;else if(m===`multiple`){let t=Array.isArray(M)?M:M instanceof Date?[M]:[];n=t.some(t=>x.isSame(x.date(t),x.date(e.date),`day`))?t.filter(t=>!x.isSame(x.date(t),x.date(e.date),`day`)):[...t,e.date]}else if(m===`range`){let t=M&&typeof M==`object`&&!(M instanceof Date)&&!Array.isArray(M)?M:{start:void 0,end:void 0};n=!t.start||t.start&&t.end?{start:e.date,end:void 0}:x.isBefore(x.date(e.date),x.date(t.start),`day`)?{start:e.date,end:t.start}:{start:t.start,end:e.date}}j||A(n),S?.(n)},[s,S,m,M,j,x]);return{calendars:c.getCalendars({date:e,selected:M,disabledDates:r,modifiers:p,monthsToDisplay:i,minDate:n,maxDate:t,offset:N,firstDayOfWeek:a,adapter:x,selectionMode:m,hoveredDate:D}),getDateProps:e=>({...v(F,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:N,handleOffsetChanged:P,adapter:x}),getForwardProps:b.bind(null,{maxDate:t,offsetMonth:N,handleOffsetChanged:P,adapter:x}),setOffset:P}}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-bLtR7Prk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDates-bLtR7Prk.cjs","names":[],"sources":["../src/adapters/dayjs.ts","../src/useDates.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport type { DateAdapter } from '../types';\n\ndayjs.extend(isBetween);\ndayjs.extend(customParseFormat);\ndayjs.extend(localeData);\n\nexport class DayjsAdapter implements DateAdapter<Dayjs> {\n date(value?: unknown): Dayjs {\n return dayjs(value as dayjs.ConfigType);\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 React, { 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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\n onDateSelected: (dateObj: DateObj, event: E) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: E) => void, dateObj: DateObj, [key: string]: unknown }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: E) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\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: E) => void, offset?: number, calendars?: Calendar[], [key: string]: unknown } = {}\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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>(\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: E) => void, offset?: number, calendars?: Calendar[], [key: string]: unknown } = {}\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<E extends { defaultPrevented?: boolean } = React.SyntheticEvent> {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: E) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date } | null;\n defaultSelected?: Date | Date[] | { start?: Date, end?: Date } | null;\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (dates: Date[]) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates<E extends { defaultPrevented?: boolean } = React.SyntheticEvent>({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n defaultSelected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps<E> = {}) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const [uncontrolledSelected, setUncontrolledSelected] = useState<\n Date | Date[] | { start?: Date; end?: Date } | null | undefined\n >(defaultSelected ?? null);\n\n const isControlled = selected !== undefined;\n const effectiveSelected = isControlled ? selected : uncontrolledSelected;\n\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const startDate = adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month');\n const firstDays = Array.from({ length: monthsToDisplay }, (_, i) =>\n adapter.toDate(adapter.startOf(adapter.add(startDate, i, 'month'), 'month'))\n );\n onMonthChange?.(firstDays);\n\n const newDate = adapter.toDate(startDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, monthsToDisplay, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: E) => {\n onDateSelected?.(dateObj, event);\n\n let nextSelected: Date | Date[] | { start?: Date; end?: Date } | null = null;\n\n if (selectionMode === 'single') {\n nextSelected = dateObj.date;\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(effectiveSelected)\n ? effectiveSelected\n : (effectiveSelected instanceof Date ? [effectiveSelected] : []);\n const isAlreadySelected = currentSelected.some(d =>\n adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')\n );\n if (isAlreadySelected) {\n nextSelected = currentSelected.filter(d =>\n !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')\n );\n } else {\n nextSelected = [...currentSelected, dateObj.date];\n }\n } else if (selectionMode === 'range') {\n const range = (effectiveSelected && typeof effectiveSelected === 'object' && !(effectiveSelected instanceof Date) && !Array.isArray(effectiveSelected))\n ? (effectiveSelected as { start?: Date; end?: Date })\n : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n nextSelected = { start: dateObj.date, end: undefined };\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n nextSelected = { start: dateObj.date, end: range.start };\n } else {\n nextSelected = { start: range.start, end: dateObj.date };\n }\n }\n }\n\n if (!isControlled) {\n setUncontrolledSelected(nextSelected);\n }\n\n onChange?.(nextSelected);\n }, [onDateSelected, onChange, selectionMode, effectiveSelected, isControlled, adapter]);\n\n const calendars = getCalendars({\n date,\n selected: effectiveSelected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: <EventE extends { defaultPrevented?: boolean } = E>(\n args: { onClick?: (event: EventE) => void, onMouseEnter?: (event: EventE) => void, onMouseLeave?: (event: EventE) => void, dateObj: DateObj, [key: string]: unknown }\n ) => {\n const props = getDateProps<EventE>(handleDateSelected as unknown as (dateObj: DateObj, event: EventE) => void, args);\n return {\n ...props,\n onMouseEnter: composeEventHandlers(args.onMouseEnter, () => {\n setHoveredDate(args.dateObj.date);\n }),\n onMouseLeave: composeEventHandlers(args.onMouseLeave, () => {\n setHoveredDate(undefined);\n })\n };\n },\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n setOffset: handleOffsetChanged\n };\n}\n"],"mappings":"kuBAOA,EAAA,QAAM,OAAO,EAAA,OAAS,EACtB,EAAA,QAAM,OAAO,EAAA,OAAiB,EAC9B,EAAA,QAAM,OAAO,EAAA,OAAU,EAEvB,IAAa,EAAb,KAAwD,CACtD,KAAK,EAAwB,CAC3B,OAAA,EAAO,EAAA,QAAA,CAAM,CAAyB,CACxC,CAEA,IAAI,EAAa,EAAgB,EAAuC,CACtE,OAAO,EAAK,IAAI,EAAQ,CAAI,CAC9B,CAEA,SAAS,EAAa,EAAgB,EAAuC,CAC3E,OAAO,EAAK,SAAS,EAAQ,CAAI,CACnC,CAEA,QAAQ,EAAa,EAAuC,CAC1D,OAAO,EAAK,QAAQ,CAAI,CAC1B,CAEA,MAAM,EAAa,EAAuC,CACxD,OAAO,EAAK,MAAM,CAAI,CACxB,CAEA,SAAS,EAAa,EAAmB,EAA0C,CACjF,OAAO,EAAK,SAAS,EAAY,CAAI,CACvC,CAEA,QAAQ,EAAa,EAAmB,EAA0C,CAChF,OAAO,EAAK,QAAQ,EAAY,CAAI,CACtC,CAEA,OAAO,EAAa,EAAmB,EAA0C,CAC/E,OAAO,EAAK,OAAO,EAAY,CAAI,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,KAAM,IAAK,IAAA,EAAU,EAEjD,EAAQ,SAAS,EAAQ,KAAK,EAAQ,IAAI,EAAG,EAAQ,KAAK,EAAM,KAAK,EAAG,KAAK,EAC9D,CAAE,MAAO,EAAQ,KAAM,IAAK,EAAM,KAAM,EAExC,CAAE,MAAO,EAAM,MAAO,IAAK,EAAQ,IAAK,CAGnE,CAEK,GACD,EAAwB,CAAY,EAGxC,IAAW,CAAY,CAC3B,EAAG,CAAC,EAAgB,EAAU,EAAe,EAAmB,EAAc,CAAO,CAAC,EAiBtF,MAAO,CACH,UAhBc,EAAA,aAAa,CAC3B,OACA,SAAU,EACV,gBACA,YACA,kBACA,UACA,UACA,OAAQ,EACR,iBACA,UACA,gBACA,aACJ,CAGI,EACA,aACI,IAGO,CACH,GAFU,EAAqB,EAA4E,CAExG,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"}
|
package/dist/useDates.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-bLtR7Prk.cjs");require("./utils.cjs"),exports.useDates=e.t;
|
package/dist/useDates.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { DateAdapter, DateObj, SelectionMode, Calendar } from './types';
|
|
2
|
-
export interface UseDatesProps {
|
|
3
|
+
export interface UseDatesProps<E extends {
|
|
4
|
+
defaultPrevented?: boolean;
|
|
5
|
+
} = React.SyntheticEvent> {
|
|
3
6
|
date?: Date;
|
|
4
7
|
maxDate?: Date;
|
|
5
8
|
minDate?: Date;
|
|
@@ -7,12 +10,16 @@ export interface UseDatesProps {
|
|
|
7
10
|
monthsToDisplay?: number;
|
|
8
11
|
firstDayOfWeek?: number;
|
|
9
12
|
offset?: number;
|
|
10
|
-
onDateSelected?: (dateObj: DateObj, event:
|
|
13
|
+
onDateSelected?: (dateObj: DateObj, event: E) => void;
|
|
11
14
|
onOffsetChanged?: (newOffset: number) => void;
|
|
12
15
|
selected?: Date | Date[] | {
|
|
13
16
|
start?: Date;
|
|
14
17
|
end?: Date;
|
|
15
|
-
};
|
|
18
|
+
} | null;
|
|
19
|
+
defaultSelected?: Date | Date[] | {
|
|
20
|
+
start?: Date;
|
|
21
|
+
end?: Date;
|
|
22
|
+
} | null;
|
|
16
23
|
modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;
|
|
17
24
|
selectionMode?: SelectionMode;
|
|
18
25
|
adapter?: DateAdapter;
|
|
@@ -23,36 +30,50 @@ export interface UseDatesProps {
|
|
|
23
30
|
onMonthChange?: (dates: Date[]) => void;
|
|
24
31
|
onYearChange?: (date: Date) => void;
|
|
25
32
|
}
|
|
26
|
-
export declare function useDates
|
|
33
|
+
export declare function useDates<E extends {
|
|
34
|
+
defaultPrevented?: boolean;
|
|
35
|
+
} = React.SyntheticEvent>({ date, maxDate, minDate, disabledDates, monthsToDisplay, firstDayOfWeek, offset, onDateSelected, onOffsetChanged, selected, defaultSelected, modifiers, selectionMode, adapter, onChange, onMonthChange, onYearChange }?: UseDatesProps<E>): {
|
|
27
36
|
calendars: Calendar[];
|
|
28
|
-
getDateProps:
|
|
29
|
-
|
|
37
|
+
getDateProps: <EventE extends {
|
|
38
|
+
defaultPrevented?: boolean;
|
|
39
|
+
} = E>(args: {
|
|
40
|
+
onClick?: (event: EventE) => void;
|
|
41
|
+
onMouseEnter?: (event: EventE) => void;
|
|
42
|
+
onMouseLeave?: (event: EventE) => void;
|
|
30
43
|
dateObj: DateObj;
|
|
31
|
-
[key: string]:
|
|
44
|
+
[key: string]: unknown;
|
|
32
45
|
}) => {
|
|
33
|
-
onMouseEnter: (event:
|
|
34
|
-
onMouseLeave: (event:
|
|
35
|
-
onClick: (event:
|
|
46
|
+
onMouseEnter: (event: EventE, ...args: unknown[]) => boolean;
|
|
47
|
+
onMouseLeave: (event: EventE, ...args: unknown[]) => boolean;
|
|
48
|
+
onClick: (event: EventE, ...args: unknown[]) => boolean;
|
|
36
49
|
disabled: boolean;
|
|
37
50
|
'aria-pressed': boolean;
|
|
38
51
|
role: string;
|
|
39
52
|
};
|
|
40
|
-
getBackProps: (args_0
|
|
41
|
-
[key: string]:
|
|
42
|
-
onClick?: (event:
|
|
53
|
+
getBackProps: (args_0?: {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
onClick?: ((event: {
|
|
56
|
+
defaultPrevented?: boolean;
|
|
57
|
+
}) => void) | undefined;
|
|
43
58
|
offset?: number;
|
|
44
|
-
calendars
|
|
45
|
-
}) => {
|
|
46
|
-
onClick: (event:
|
|
59
|
+
calendars?: Calendar[];
|
|
60
|
+
} | undefined) => {
|
|
61
|
+
onClick: (event: {
|
|
62
|
+
defaultPrevented?: boolean;
|
|
63
|
+
}, ...args: unknown[]) => boolean;
|
|
47
64
|
disabled: boolean;
|
|
48
65
|
};
|
|
49
|
-
getForwardProps: (args_0
|
|
50
|
-
[key: string]:
|
|
51
|
-
onClick?: (event:
|
|
66
|
+
getForwardProps: (args_0?: {
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
onClick?: ((event: {
|
|
69
|
+
defaultPrevented?: boolean;
|
|
70
|
+
}) => void) | undefined;
|
|
52
71
|
offset?: number;
|
|
53
|
-
calendars
|
|
54
|
-
}) => {
|
|
55
|
-
onClick: (event:
|
|
72
|
+
calendars?: Calendar[];
|
|
73
|
+
} | undefined) => {
|
|
74
|
+
onClick: (event: {
|
|
75
|
+
defaultPrevented?: boolean;
|
|
76
|
+
}, ...args: unknown[]) => boolean;
|
|
56
77
|
disabled: boolean;
|
|
57
78
|
};
|
|
58
79
|
setOffset: (newOffset: number) => void;
|
package/dist/useDates.js
CHANGED