├── .nvmrc ├── website ├── static │ ├── .nojekill │ ├── CNAME │ └── images │ │ ├── logo.png │ │ ├── favicon.ico │ │ ├── favicon.png │ │ ├── og-image.png │ │ └── sublist-icon.svg ├── examples │ ├── typings.d.ts │ ├── .prettierrc │ ├── disabled.tsx │ ├── outside-days.tsx │ ├── fixedweeks.tsx │ ├── default-month.tsx │ ├── weeknumber-iso.tsx │ ├── multiple-months.tsx │ ├── week-iso.tsx │ ├── multiple-months-paged.tsx │ ├── keyboard.tsx │ ├── spanish.tsx │ ├── dropdown.tsx │ ├── rtl.tsx │ ├── container-attributes.tsx │ ├── spanish-week-starts-on.tsx │ ├── from-to-year.tsx │ ├── dropdown-buttons.tsx │ ├── styling-inline.tsx │ ├── dropdown-multiple-months.tsx │ ├── from-to-month.tsx │ ├── modifiers-hidden.tsx │ ├── custom-day.tsx │ ├── styling-css.tsx │ ├── weeknumber.tsx │ ├── modifiers-disabled.tsx │ ├── weeknumber-custom.tsx │ ├── focus-recursive.tsx │ ├── start.tsx │ ├── useinput.tsx │ ├── modifiers-style.tsx │ ├── single.tsx │ ├── custom-single.tsx │ ├── multiple-min-max.tsx │ ├── modifiers-today.tsx │ ├── controlled.tsx │ ├── multiple.tsx │ ├── single-required.tsx │ ├── styling-css-modules.tsx │ ├── modifiers-classnames.tsx │ ├── custom-disable-row.tsx │ ├── testcase-1567.tsx │ ├── modifiers-custom.tsx │ ├── range-min-max.tsx │ ├── custom-caption.tsx │ ├── numbering-system.tsx │ ├── range.tsx │ ├── formatters.tsx │ ├── styling-modifiers.tsx │ ├── custom-multiple.tsx │ └── range-shift-key.tsx ├── src │ ├── components │ │ ├── index.ts │ │ ├── RenderExample.module.css │ │ └── RenderExample.tsx │ ├── theme │ │ └── CodeBlock │ │ │ └── sandpack-app │ │ │ ├── App.tsx │ │ │ ├── index.html │ │ │ ├── index.tsx │ │ │ ├── light.css │ │ │ └── dark.css │ └── pages │ │ └── render.tsx ├── test │ ├── utils │ │ ├── index.ts │ │ ├── freezeBeforeAll.ts │ │ └── focusDaysGrid.ts │ ├── setup.ts │ ├── user.ts │ └── axe.ts ├── docs │ ├── changelog.md │ ├── development │ │ ├── index.md │ │ └── code-of-conduct.md │ ├── contributing.md │ ├── index.md │ ├── guides │ │ ├── formatters.md │ │ └── input-fields.md │ ├── start.md │ ├── reference.md │ ├── basics │ │ ├── keyboard.md │ │ └── localization.md │ └── license.md ├── .gitignore ├── README.md ├── tsconfig.json ├── docusaurus.typedoc.js ├── test-integration │ └── examples │ │ ├── formatters.test.tsx │ │ ├── default-month.test.tsx │ │ ├── testcase-1567.test.tsx │ │ ├── styling-css.test.tsx │ │ ├── styling-inline.test.tsx │ │ ├── weeknumber-custom.test.tsx │ │ ├── spanish-week-starts-on.test.tsx │ │ ├── custom-day.test.tsx │ │ ├── modifiers-disabled.test.tsx │ │ ├── modifiers-hidden.test.tsx │ │ ├── modifiers-classnames.test.tsx │ │ ├── modifiers-style.test.tsx │ │ ├── fixedweeks.test.tsx │ │ ├── custom-disable-row.test.tsx │ │ ├── spanish.test.tsx │ │ ├── outside-days.test.tsx │ │ ├── container-attributes.test.tsx │ │ ├── numbering-system.test.tsx │ │ ├── modifiers-custom.test.tsx │ │ ├── weeknumber.test.tsx │ │ ├── custom-single.test.tsx │ │ ├── controlled.test.tsx │ │ ├── start.test.tsx │ │ ├── focus-recursive.test.tsx │ │ ├── dropdown.test.tsx │ │ ├── single-required.test.tsx │ │ ├── rtl.test.tsx │ │ ├── from-to-month.test.tsx │ │ ├── single.test.tsx │ │ ├── modifiers-today.test.tsx │ │ ├── dropdown-buttons.test.tsx │ │ ├── from-to-year.test.tsx │ │ ├── multiple.test.tsx │ │ └── multiple-months-paged.test.tsx ├── jest.config.ts ├── plugins │ └── source-map.js ├── docusaurus.sidebars.js └── docusaurus.navbar.js ├── src ├── .eslintignore ├── hooks │ ├── useId │ │ ├── index.ts │ │ └── useIsomorphicLayoutEffect.ts │ ├── useInput │ │ ├── index.ts │ │ └── utils │ │ │ └── isValidDate.tsx │ ├── useDayRender │ │ ├── index.ts │ │ └── utils │ │ │ ├── getDayStyle.ts │ │ │ └── getDayClassNames.ts │ ├── useSelectedDays │ │ ├── index.ts │ │ ├── useSelectedDays.ts │ │ └── useSelectedDays.test.ts │ ├── useActiveModifiers │ │ ├── index.ts │ │ ├── useActiveModifiers.tsx │ │ └── useActiveModifiers.test.tsx │ ├── useControlledValue │ │ ├── index.ts │ │ ├── useControlledValue.ts │ │ └── useControlledValue.test.ts │ └── useDayEventHandlers │ │ └── index.ts ├── components │ ├── Day │ │ ├── index.ts │ │ └── Day.tsx │ ├── Head │ │ ├── index.ts │ │ ├── Head.tsx │ │ └── Head.test.tsx │ ├── Month │ │ └── index.ts │ ├── Root │ │ └── index.ts │ ├── Row │ │ ├── index.ts │ │ └── Row.tsx │ ├── Table │ │ ├── index.ts │ │ └── utils │ │ │ ├── daysToMonthWeeks.ts │ │ │ └── getMonthWeeks.ts │ ├── Button │ │ ├── index.ts │ │ ├── Button.tsx │ │ └── Button.test.tsx │ ├── Caption │ │ └── index.ts │ ├── Footer │ │ ├── index.ts │ │ ├── Footer.tsx │ │ └── Footer.test.tsx │ ├── HeadRow │ │ ├── index.ts │ │ ├── utils │ │ │ ├── index.ts │ │ │ ├── getWeekdays.ts │ │ │ └── getWeekdays.test.ts │ │ └── HeadRow.tsx │ ├── Months │ │ ├── index.ts │ │ ├── Months.tsx │ │ └── Months.test.tsx │ ├── DayContent │ │ ├── index.ts │ │ ├── DayContent.tsx │ │ └── DayContent.test.tsx │ ├── Dropdown │ │ └── index.ts │ ├── IconLeft │ │ ├── index.ts │ │ ├── IconLeft.test.tsx │ │ └── IconLeft.tsx │ ├── IconRight │ │ ├── index.ts │ │ ├── IconRight.test.tsx │ │ └── IconRight.tsx │ ├── Navigation │ │ └── index.ts │ ├── WeekNumber │ │ ├── index.ts │ │ ├── __snapshots__ │ │ │ └── WeekNumber.test.tsx.snap │ │ └── WeekNumber.tsx │ ├── CaptionLabel │ │ ├── index.ts │ │ ├── CaptionLabel.test.tsx │ │ └── CaptionLabel.tsx │ ├── IconDropdown │ │ ├── index.ts │ │ ├── IconDropdown.test.tsx │ │ └── IconDropdown.tsx │ ├── MonthsDropdown │ │ ├── index.ts │ │ └── __snapshots__ │ │ │ └── MonthsDropdown.test.tsx.snap │ ├── YearsDropdown │ │ ├── index.ts │ │ └── __snapshots__ │ │ │ └── YearsDropdown.test.tsx.snap │ ├── CaptionDropdowns │ │ ├── index.ts │ │ └── CaptionDropdowns.tsx │ └── CaptionNavigation │ │ ├── index.ts │ │ └── CaptionNavigation.tsx ├── contexts │ ├── Focus │ │ ├── index.ts │ │ └── utils │ │ │ ├── getInitialFocusTarget.test.ts │ │ │ └── getInitialFocusTarget.ts │ ├── DayPicker │ │ ├── index.ts │ │ ├── utils │ │ │ ├── index.ts │ │ │ └── parseFromToProps.ts │ │ ├── labels │ │ │ ├── labelNext.test.ts │ │ │ ├── labelYearDropdown.ts │ │ │ ├── labelMonthDropdown.ts │ │ │ ├── labelWeekNumber.test.ts │ │ │ ├── labelPrevious.test.ts │ │ │ ├── labelYearDropdown.test.ts │ │ │ ├── labelMonthDropdown.test.ts │ │ │ ├── labelDay.test.ts │ │ │ ├── labelNext.ts │ │ │ ├── labelWeekNumber.ts │ │ │ ├── index.ts │ │ │ ├── labelPrevious.ts │ │ │ ├── labelWeekday.ts │ │ │ ├── labelDay.ts │ │ │ └── labelWeekday.test.ts │ │ ├── formatters │ │ │ ├── formatWeekNumber.ts │ │ │ ├── formatWeekNumber.test.ts │ │ │ ├── formatDay.test.ts │ │ │ ├── index.ts │ │ │ ├── formatDay.ts │ │ │ ├── formatYearCaption.test.ts │ │ │ ├── formatCaption.ts │ │ │ ├── formatMonthCaption.ts │ │ │ ├── formatWeekdayName.ts │ │ │ ├── formatYearCaption.ts │ │ │ ├── formatCaption.test.ts │ │ │ ├── formatWeekdayName.test.ts │ │ │ └── formatMonthCaption.test.ts │ │ ├── defaultContextValues.ts │ │ └── defaultClassNames.ts │ ├── Navigation │ │ ├── index.ts │ │ ├── utils │ │ │ ├── getDisplayMonths.ts │ │ │ ├── getInitialMonth.ts │ │ │ ├── getNextMonth.ts │ │ │ └── getPreviousMonth.ts │ │ ├── useNavigationState.ts │ │ └── useNavigationState.test.ts │ ├── SelectRange │ │ ├── index.ts │ │ └── utils │ │ │ └── addToRange.ts │ ├── SelectSingle │ │ └── index.ts │ ├── SelectMultiple │ │ └── index.ts │ ├── Modifiers │ │ ├── index.ts │ │ ├── utils │ │ │ ├── matcherToArray.ts │ │ │ ├── getCustomModifiers.test.ts │ │ │ ├── getCustomModifiers.ts │ │ │ ├── isDateInRange.ts │ │ │ ├── matcherToArray.test.ts │ │ │ ├── getActiveModifiers.ts │ │ │ ├── isDateInRange.test.ts │ │ │ └── getActiveModifiers.test.ts │ │ └── ModifiersContext.test.ts │ └── RootProvider.tsx ├── types │ ├── DayPickerDefault.ts │ ├── DayPickerSingle.ts │ ├── DayPickerMultiple.ts │ ├── DayPickerRange.ts │ ├── Formatters.ts │ └── Labels.ts ├── style.css.d.ts └── index.ts ├── pnpm-workspace.yaml ├── test ├── setup.ts ├── utils │ ├── index.ts │ ├── freezeBeforeAll.ts │ └── focusDaysGrid.ts ├── render │ ├── index.ts │ └── customRender.tsx ├── user.ts └── mockedContexts.ts ├── .gitignore ├── CHANGELOG.md ├── .prettierrc ├── tsconfig.build.json ├── .editorconfig ├── SECURITY.md ├── jest.config.ts ├── tsconfig.json ├── CONTRIBUTING.md ├── LICENSE ├── .eslintrc.js └── tea.yaml /.nvmrc: -------------------------------------------------------------------------------- 1 | 18 2 | -------------------------------------------------------------------------------- /website/static/.nojekill: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/.eslintignore: -------------------------------------------------------------------------------- 1 | style.css.d.ts 2 | -------------------------------------------------------------------------------- /website/static/CNAME: -------------------------------------------------------------------------------- 1 | react-day-picker.js.org -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "website" 3 | -------------------------------------------------------------------------------- /src/hooks/useId/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useId'; 2 | -------------------------------------------------------------------------------- /test/setup.ts: -------------------------------------------------------------------------------- 1 | import '@testing-library/jest-dom'; 2 | -------------------------------------------------------------------------------- /src/components/Day/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Day'; 2 | -------------------------------------------------------------------------------- /src/components/Head/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Head'; 2 | -------------------------------------------------------------------------------- /src/components/Month/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Month'; 2 | -------------------------------------------------------------------------------- /src/components/Root/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Root'; 2 | -------------------------------------------------------------------------------- /src/components/Row/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Row'; 2 | -------------------------------------------------------------------------------- /src/components/Table/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Table'; 2 | -------------------------------------------------------------------------------- /src/components/Button/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Button'; 2 | -------------------------------------------------------------------------------- /src/components/Caption/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Caption'; 2 | -------------------------------------------------------------------------------- /src/components/Footer/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Footer'; 2 | -------------------------------------------------------------------------------- /src/components/HeadRow/index.ts: -------------------------------------------------------------------------------- 1 | export * from './HeadRow'; 2 | -------------------------------------------------------------------------------- /src/components/Months/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Months'; 2 | -------------------------------------------------------------------------------- /src/contexts/Focus/index.ts: -------------------------------------------------------------------------------- 1 | export * from './FocusContext'; 2 | -------------------------------------------------------------------------------- /src/hooks/useInput/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useInput'; 2 | -------------------------------------------------------------------------------- /src/components/DayContent/index.ts: -------------------------------------------------------------------------------- 1 | export * from './DayContent'; 2 | -------------------------------------------------------------------------------- /src/components/Dropdown/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Dropdown'; 2 | -------------------------------------------------------------------------------- /src/components/IconLeft/index.ts: -------------------------------------------------------------------------------- 1 | export * from './IconLeft'; 2 | -------------------------------------------------------------------------------- /src/components/IconRight/index.ts: -------------------------------------------------------------------------------- 1 | export * from './IconRight'; 2 | -------------------------------------------------------------------------------- /src/components/Navigation/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Navigation'; 2 | -------------------------------------------------------------------------------- /src/components/WeekNumber/index.ts: -------------------------------------------------------------------------------- 1 | export * from './WeekNumber'; 2 | -------------------------------------------------------------------------------- /src/hooks/useDayRender/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useDayRender'; 2 | -------------------------------------------------------------------------------- /website/examples/typings.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.module.css'; 2 | -------------------------------------------------------------------------------- /website/src/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from './RenderExample'; 2 | -------------------------------------------------------------------------------- /website/test/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './freezeBeforeAll'; 2 | -------------------------------------------------------------------------------- /src/components/CaptionLabel/index.ts: -------------------------------------------------------------------------------- 1 | export * from './CaptionLabel'; 2 | -------------------------------------------------------------------------------- /src/components/HeadRow/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './getWeekdays'; 2 | -------------------------------------------------------------------------------- /src/components/IconDropdown/index.ts: -------------------------------------------------------------------------------- 1 | export * from './IconDropdown'; 2 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/index.ts: -------------------------------------------------------------------------------- 1 | export * from './DayPickerContext'; 2 | -------------------------------------------------------------------------------- /src/contexts/Navigation/index.ts: -------------------------------------------------------------------------------- 1 | export * from './NavigationContext'; 2 | -------------------------------------------------------------------------------- /src/hooks/useSelectedDays/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useSelectedDays'; 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules 4 | coverage 5 | build 6 | dist 7 | -------------------------------------------------------------------------------- /src/components/MonthsDropdown/index.ts: -------------------------------------------------------------------------------- 1 | export * from './MonthsDropdown'; 2 | -------------------------------------------------------------------------------- /src/components/YearsDropdown/index.ts: -------------------------------------------------------------------------------- 1 | export * from './YearsDropdown'; 2 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './parseFromToProps'; 2 | -------------------------------------------------------------------------------- /src/contexts/SelectRange/index.ts: -------------------------------------------------------------------------------- 1 | export * from './SelectRangeContext'; 2 | -------------------------------------------------------------------------------- /src/contexts/SelectSingle/index.ts: -------------------------------------------------------------------------------- 1 | export * from './SelectSingleContext'; 2 | -------------------------------------------------------------------------------- /src/components/CaptionDropdowns/index.ts: -------------------------------------------------------------------------------- 1 | export * from './CaptionDropdowns'; 2 | -------------------------------------------------------------------------------- /src/components/CaptionNavigation/index.ts: -------------------------------------------------------------------------------- 1 | export * from './CaptionNavigation'; 2 | -------------------------------------------------------------------------------- /src/contexts/SelectMultiple/index.ts: -------------------------------------------------------------------------------- 1 | export * from './SelectMultipleContext'; 2 | -------------------------------------------------------------------------------- /src/hooks/useActiveModifiers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useActiveModifiers'; 2 | -------------------------------------------------------------------------------- /src/hooks/useControlledValue/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useControlledValue'; 2 | -------------------------------------------------------------------------------- /src/hooks/useDayEventHandlers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './useDayEventHandlers'; 2 | -------------------------------------------------------------------------------- /test/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './freezeBeforeAll'; 2 | export * from './focusDaysGrid'; 3 | -------------------------------------------------------------------------------- /website/test/setup.ts: -------------------------------------------------------------------------------- 1 | import '@testing-library/jest-dom'; 2 | import 'jest-axe/extend-expect'; 3 | -------------------------------------------------------------------------------- /test/render/index.ts: -------------------------------------------------------------------------------- 1 | export * from './customRender'; 2 | export * from './renderDayPickerHook'; 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | Full release notes at https://github.com/gpbl/react-day-picker/releases 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "tabWidth": 2, 4 | "semi": true, 5 | "singleQuote": true 6 | } 7 | -------------------------------------------------------------------------------- /src/contexts/Modifiers/index.ts: -------------------------------------------------------------------------------- 1 | export * from './ModifiersContext'; 2 | export * from './utils/getActiveModifiers'; 3 | -------------------------------------------------------------------------------- /test/user.ts: -------------------------------------------------------------------------------- 1 | import { userEvent } from '@testing-library/user-event'; 2 | 3 | export const user = userEvent.setup(); 4 | -------------------------------------------------------------------------------- /website/static/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x0xGen/react-day-picker-trial/HEAD/website/static/images/logo.png -------------------------------------------------------------------------------- /website/static/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x0xGen/react-day-picker-trial/HEAD/website/static/images/favicon.ico -------------------------------------------------------------------------------- /website/static/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x0xGen/react-day-picker-trial/HEAD/website/static/images/favicon.png -------------------------------------------------------------------------------- /website/test/user.ts: -------------------------------------------------------------------------------- 1 | import { userEvent } from '@testing-library/user-event'; 2 | 3 | export const user = userEvent.setup(); 4 | -------------------------------------------------------------------------------- /website/examples/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "tabWidth": 2, 4 | "semi": true, 5 | "singleQuote": true 6 | } 7 | -------------------------------------------------------------------------------- /website/static/images/og-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0x0xGen/react-day-picker-trial/HEAD/website/static/images/og-image.png -------------------------------------------------------------------------------- /src/hooks/useInput/utils/isValidDate.tsx: -------------------------------------------------------------------------------- 1 | /** @private */ 2 | export function isValidDate(day: Date): boolean { 3 | return !isNaN(day.getTime()); 4 | } 5 | -------------------------------------------------------------------------------- /website/test/axe.ts: -------------------------------------------------------------------------------- 1 | import { configureAxe } from 'jest-axe'; 2 | 3 | export const axe = configureAxe({ 4 | rules: { 5 | 'aria-allowed-role': { enabled: false } 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./src" 5 | }, 6 | "exclude": ["**/*.test.*"], 7 | "include": ["./src/**/*"] 8 | } 9 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelNext.test.ts: -------------------------------------------------------------------------------- 1 | import { labelNext } from './labelNext'; 2 | 3 | test('should return the label', () => { 4 | expect(labelNext()).toEqual('Go to next month'); 5 | }); 6 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelYearDropdown.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The default ARIA label for the WeekNumber element. 3 | */ 4 | export const labelYearDropdown = (): string => { 5 | return 'Year: '; 6 | }; 7 | -------------------------------------------------------------------------------- /website/examples/disabled.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{js,jsx,ts,tsx,json,yml}] 8 | charset = utf-8 9 | indent_style = space 10 | indent_size = 2 11 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelMonthDropdown.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The default ARIA label for the WeekNumber element. 3 | */ 4 | export const labelMonthDropdown = (): string => { 5 | return 'Month: '; 6 | }; 7 | -------------------------------------------------------------------------------- /test/utils/freezeBeforeAll.ts: -------------------------------------------------------------------------------- 1 | import MockDate from 'mockdate'; 2 | 3 | export function freezeBeforeAll(date: Date) { 4 | beforeAll(() => MockDate.set(date)); 5 | afterAll(() => MockDate.reset()); 6 | } 7 | -------------------------------------------------------------------------------- /website/examples/outside-days.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /website/src/theme/CodeBlock/sandpack-app/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | /** Placeholder app replaced by CustomSandpack component. */ 4 | export default function App() { 5 | return <>; 6 | } 7 | -------------------------------------------------------------------------------- /website/examples/fixedweeks.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { DayPicker } from 'react-day-picker'; 3 | 4 | export default function App() { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /website/test/utils/freezeBeforeAll.ts: -------------------------------------------------------------------------------- 1 | import MockDate from 'mockdate'; 2 | 3 | export function freezeBeforeAll(date: Date) { 4 | beforeAll(() => MockDate.set(date)); 5 | afterAll(() => MockDate.reset()); 6 | } 7 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatWeekNumber.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The default formatter for the week number. 3 | */ 4 | export function formatWeekNumber(weekNumber: number): string { 5 | return `${weekNumber}`; 6 | } 7 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelWeekNumber.test.ts: -------------------------------------------------------------------------------- 1 | import { labelWeekNumber } from './labelWeekNumber'; 2 | 3 | test('should return the label', () => { 4 | expect(labelWeekNumber(2)).toEqual('Week n. 2'); 5 | }); 6 | -------------------------------------------------------------------------------- /website/examples/default-month.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { DayPicker } from 'react-day-picker'; 3 | 4 | export default function App() { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /website/examples/weeknumber-iso.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelPrevious.test.ts: -------------------------------------------------------------------------------- 1 | import { labelPrevious } from './labelPrevious'; 2 | 3 | test('should return the label', () => { 4 | expect(labelPrevious()).toEqual('Go to previous month'); 5 | }); 6 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelYearDropdown.test.ts: -------------------------------------------------------------------------------- 1 | import { labelYearDropdown } from './labelYearDropdown'; 2 | 3 | test('should return the label', () => { 4 | expect(labelYearDropdown()).toEqual('Year: '); 5 | }); 6 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelMonthDropdown.test.ts: -------------------------------------------------------------------------------- 1 | import { labelMonthDropdown } from './labelMonthDropdown'; 2 | 3 | test('should return the label', () => { 4 | expect(labelMonthDropdown()).toEqual('Month: '); 5 | }); 6 | -------------------------------------------------------------------------------- /website/examples/multiple-months.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /website/examples/week-iso.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /website/examples/multiple-months-paged.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatWeekNumber.test.ts: -------------------------------------------------------------------------------- 1 | import { formatWeekNumber } from './formatWeekNumber'; 2 | 3 | test('should return the formatted week number', () => { 4 | expect(formatWeekNumber(10)).toEqual('10'); 5 | }); 6 | -------------------------------------------------------------------------------- /website/examples/keyboard.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker, DayPickerProps } from 'react-day-picker'; 4 | 5 | export default function Example(props: DayPickerProps) { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /website/examples/spanish.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { es } from 'date-fns/locale'; 4 | import { DayPicker } from 'react-day-picker'; 5 | 6 | export default function App() { 7 | return ; 8 | } 9 | -------------------------------------------------------------------------------- /website/examples/dropdown.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatDay.test.ts: -------------------------------------------------------------------------------- 1 | import { formatDay } from './formatDay'; 2 | 3 | const date = new Date(2022, 10, 21); 4 | 5 | test('should return the formatted day', () => { 6 | expect(formatDay(date)).toEqual('21'); 7 | }); 8 | -------------------------------------------------------------------------------- /website/examples/rtl.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { arSA } from 'date-fns/locale'; 4 | import { DayPicker } from 'react-day-picker'; 5 | 6 | export default function App() { 7 | return ; 8 | } 9 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelDay.test.ts: -------------------------------------------------------------------------------- 1 | import { labelDay } from './labelDay'; 2 | 3 | const day = new Date(2022, 10, 21); 4 | 5 | test('should return the day label', () => { 6 | expect(labelDay(day, {})).toEqual('21st November (Monday)'); 7 | }); 8 | -------------------------------------------------------------------------------- /website/examples/container-attributes.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function Example() { 6 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/index.ts: -------------------------------------------------------------------------------- 1 | export * from './formatCaption'; 2 | export * from './formatDay'; 3 | export * from './formatMonthCaption'; 4 | export * from './formatWeekNumber'; 5 | export * from './formatWeekdayName'; 6 | export * from './formatYearCaption'; 7 | -------------------------------------------------------------------------------- /website/examples/spanish-week-starts-on.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { es } from 'date-fns/locale'; 4 | import { DayPicker } from 'react-day-picker'; 5 | 6 | export default function App() { 7 | return ; 8 | } 9 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelNext.ts: -------------------------------------------------------------------------------- 1 | import { NavButtonLabel } from 'types/Labels'; 2 | 3 | /** 4 | * The default ARIA label for next month button in navigation 5 | */ 6 | export const labelNext: NavButtonLabel = (): string => { 7 | return 'Go to next month'; 8 | }; 9 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelWeekNumber.ts: -------------------------------------------------------------------------------- 1 | import { WeekNumberLabel } from 'types/Labels'; 2 | 3 | /** 4 | * The default ARIA label for the WeekNumber element. 5 | */ 6 | export const labelWeekNumber: WeekNumberLabel = (n): string => { 7 | return `Week n. ${n}`; 8 | }; 9 | -------------------------------------------------------------------------------- /website/examples/from-to-year.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ( 7 | 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatDay.ts: -------------------------------------------------------------------------------- 1 | import { format, Locale } from 'date-fns'; 2 | 3 | /** 4 | * The default formatter for the Day button. 5 | */ 6 | export function formatDay(day: Date, options?: { locale?: Locale }): string { 7 | return format(day, 'd', options); 8 | } 9 | -------------------------------------------------------------------------------- /website/examples/dropdown-buttons.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ( 7 | 8 | ); 9 | } 10 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatYearCaption.test.ts: -------------------------------------------------------------------------------- 1 | import { formatYearCaption } from './formatYearCaption'; 2 | 3 | const date = new Date(2022, 10, 21); 4 | 5 | test('should return the formatted weekday name', () => { 6 | expect(formatYearCaption(date)).toEqual('2022'); 7 | }); 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/index.ts: -------------------------------------------------------------------------------- 1 | export * from './labelDay'; 2 | export * from './labelMonthDropdown'; 3 | export * from './labelNext'; 4 | export * from './labelPrevious'; 5 | export * from './labelWeekday'; 6 | export * from './labelWeekNumber'; 7 | export * from './labelYearDropdown'; 8 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelPrevious.ts: -------------------------------------------------------------------------------- 1 | import { NavButtonLabel } from 'types/Labels'; 2 | 3 | /** 4 | * The default ARIA label for previous month button in navigation 5 | */ 6 | export const labelPrevious: NavButtonLabel = (): string => { 7 | return 'Go to previous month'; 8 | }; 9 | -------------------------------------------------------------------------------- /website/docs/changelog.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Changelog 3 | hide_title: true 4 | pagination_next: null 5 | pagination_prev: null 6 | --- 7 | 8 | import ChangeLog, { 9 | toc as ChangeLogTOC 10 | } from '@site/../CHANGELOG.md'; 11 | 12 | 13 | 14 | export const toc = ChangeLogTOC; 15 | -------------------------------------------------------------------------------- /website/docs/development/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /development 3 | hide_title: true 4 | sidebar_label: Contributing 5 | --- 6 | 7 | import Contributing, { 8 | toc as ContributingTOC 9 | } from '@site/../CONTRIBUTING.md'; 10 | 11 | 12 | 13 | export const toc = ContributingTOC; 14 | -------------------------------------------------------------------------------- /website/examples/styling-inline.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ( 7 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/contributing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributing 3 | hide_title: true 4 | pagination_next: null 5 | pagination_prev: null 6 | --- 7 | 8 | import Contributing, { toc as ContributingTOC } from '@site/../CONTRIBUTING.md'; 9 | 10 | 11 | 12 | export const toc = ContributingTOC; 13 | -------------------------------------------------------------------------------- /website/docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Date Picker Component 3 | hide_title: true 4 | sidebar_label: Welcome 5 | slug: / 6 | hide_table_of_contents: true 7 | --- 8 | 9 | import Readme, { 10 | toc as ReadmeTOC 11 | } from '@site/../README.md'; 12 | 13 | 14 | 15 | export const toc = ReadmeTOC; 16 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Built 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | /docs/api 11 | 12 | # Misc 13 | .DS_Store 14 | .env.local 15 | .env.development.local 16 | .env.test.local 17 | .env.production.local 18 | 19 | npm-debug.log* 20 | -------------------------------------------------------------------------------- /website/src/components/RenderExample.module.css: -------------------------------------------------------------------------------- 1 | .example { 2 | padding: 1em; 3 | } 4 | .example input { 5 | font-size: 1em; 6 | padding: 0.4em 0.6em; 7 | } 8 | 9 | .example button { 10 | font-size: 1em; 11 | padding: 0.4em 0.6em; 12 | } 13 | .example input + button { 14 | margin-left: 0.5em; 15 | } 16 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatCaption.ts: -------------------------------------------------------------------------------- 1 | import { format, Locale } from 'date-fns'; 2 | 3 | /** 4 | * The default formatter for the caption. 5 | */ 6 | export function formatCaption( 7 | month: Date, 8 | options?: { locale?: Locale } 9 | ): string { 10 | return format(month, 'LLLL y', options); 11 | } 12 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatMonthCaption.ts: -------------------------------------------------------------------------------- 1 | import { format, Locale } from 'date-fns'; 2 | 3 | /** 4 | * The default formatter for the Month caption. 5 | */ 6 | export function formatMonthCaption( 7 | month: Date, 8 | options?: { locale?: Locale } 9 | ): string { 10 | return format(month, 'LLLL', options); 11 | } 12 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelWeekday.ts: -------------------------------------------------------------------------------- 1 | import { format } from 'date-fns'; 2 | 3 | import { WeekdayLabel } from 'types/Labels'; 4 | 5 | /** 6 | * The default ARIA label for the Weekday element. 7 | */ 8 | export const labelWeekday: WeekdayLabel = (day, options): string => { 9 | return format(day, 'cccc', options); 10 | }; 11 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/labels/labelDay.ts: -------------------------------------------------------------------------------- 1 | import { format } from 'date-fns'; 2 | 3 | import { DayLabel } from 'types/Labels'; 4 | 5 | /** 6 | * The default ARIA label for the day button. 7 | */ 8 | export const labelDay: DayLabel = (day, activeModifiers, options): string => { 9 | return format(day, 'do MMMM (EEEE)', options); 10 | }; 11 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatWeekdayName.ts: -------------------------------------------------------------------------------- 1 | import { format, Locale } from 'date-fns'; 2 | 3 | /** 4 | * The default formatter for the name of the weekday. 5 | */ 6 | export function formatWeekdayName( 7 | weekday: Date, 8 | options?: { locale?: Locale } 9 | ): string { 10 | return format(weekday, 'cccccc', options); 11 | } 12 | -------------------------------------------------------------------------------- /src/contexts/DayPicker/formatters/formatYearCaption.ts: -------------------------------------------------------------------------------- 1 | import { format, Locale } from 'date-fns'; 2 | 3 | /** 4 | * The default formatter for the Year caption. 5 | */ 6 | export function formatYearCaption( 7 | year: Date, 8 | options?: { 9 | locale?: Locale; 10 | } 11 | ): string { 12 | return format(year, 'yyyy', options); 13 | } 14 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # DayPicker website 2 | 3 | The website is deployed at this temporary URL: http://react-day-picker-next.netlify.app 4 | 5 | Built using [Docusaurus 2](https://v2.docusaurus.io/) and the [typedoc plugin](https://github.com/tgreyuk/typedoc-plugin-markdown). 6 | 7 | ``` 8 | $ pnpm start # start the development environment 9 | ``` 10 | -------------------------------------------------------------------------------- /website/src/theme/CodeBlock/sandpack-app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | react-day-picker example 7 | 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /website/examples/dropdown-multiple-months.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | return ( 7 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /website/docs/development/code-of-conduct.md: -------------------------------------------------------------------------------- 1 | --- 2 | slug: /development/conduct 3 | hide_title: true 4 | pagination_next: null 5 | pagination_prev: null 6 | sidebar_label: Code of Conduct 7 | --- 8 | 9 | import Conduct, { 10 | toc as ConductTOC 11 | } from '@site/../.github/CODE_OF_CONDUCT.md'; 12 | 13 | 14 | 15 | export const toc = ConductTOC; 16 | -------------------------------------------------------------------------------- /website/examples/from-to-month.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | const defaultMonth = new Date(2015, 5); 7 | return ( 8 | 13 | ); 14 | } 15 | -------------------------------------------------------------------------------- /website/examples/modifiers-hidden.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { DayPicker } from 'react-day-picker'; 4 | 5 | export default function App() { 6 | const hiddenDays = [ 7 | new Date(2022, 5, 10), 8 | new Date(2022, 5, 20), 9 | new Date(2022, 5, 11) 10 | ]; 11 | 12 | return