react-day-picker 10.0.0-next.6 → 10.0.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/README.md +3 -3
- package/dist/cjs/DayPicker.js +25 -11
- package/dist/cjs/classes/DateLib.d.ts +1 -0
- package/dist/cjs/components/CaptionLabel.d.ts +1 -0
- package/dist/cjs/components/Chevron.d.ts +2 -0
- package/dist/cjs/components/Chevron.js +2 -2
- package/dist/cjs/components/Day.d.ts +1 -0
- package/dist/cjs/components/DayButton.d.ts +1 -0
- package/dist/cjs/components/Dropdown.d.ts +1 -0
- package/dist/cjs/components/Dropdown.js +4 -4
- package/dist/cjs/components/DropdownNav.d.ts +1 -0
- package/dist/cjs/components/Footer.d.ts +1 -0
- package/dist/cjs/components/Month.d.ts +1 -0
- package/dist/cjs/components/MonthCaption.d.ts +1 -0
- package/dist/cjs/components/MonthGrid.d.ts +1 -0
- package/dist/cjs/components/Months.d.ts +1 -0
- package/dist/cjs/components/Nav.d.ts +1 -0
- package/dist/cjs/components/Nav.js +5 -5
- package/dist/cjs/components/NextMonthButton.d.ts +1 -0
- package/dist/cjs/components/Option.d.ts +1 -0
- package/dist/cjs/components/PreviousMonthButton.d.ts +1 -0
- package/dist/cjs/components/Root.d.ts +1 -0
- package/dist/cjs/components/Select.d.ts +1 -0
- package/dist/cjs/components/Week.d.ts +1 -0
- package/dist/cjs/components/WeekNumber.d.ts +1 -0
- package/dist/cjs/components/WeekNumberHeader.d.ts +1 -0
- package/dist/cjs/components/Weekday.d.ts +1 -0
- package/dist/cjs/components/Weekdays.d.ts +1 -0
- package/dist/cjs/components/Weeks.d.ts +1 -0
- package/dist/cjs/types/selection.d.ts +7 -0
- package/dist/esm/DayPicker.js +25 -11
- package/dist/esm/classes/DateLib.d.ts +1 -0
- package/dist/esm/components/CaptionLabel.d.ts +1 -0
- package/dist/esm/components/Chevron.d.ts +2 -0
- package/dist/esm/components/Chevron.js +2 -2
- package/dist/esm/components/Day.d.ts +1 -0
- package/dist/esm/components/DayButton.d.ts +1 -0
- package/dist/esm/components/Dropdown.d.ts +1 -0
- package/dist/esm/components/Dropdown.js +4 -4
- package/dist/esm/components/DropdownNav.d.ts +1 -0
- package/dist/esm/components/Footer.d.ts +1 -0
- package/dist/esm/components/Month.d.ts +1 -0
- package/dist/esm/components/MonthCaption.d.ts +1 -0
- package/dist/esm/components/MonthGrid.d.ts +1 -0
- package/dist/esm/components/Months.d.ts +1 -0
- package/dist/esm/components/Nav.d.ts +1 -0
- package/dist/esm/components/Nav.js +5 -5
- package/dist/esm/components/NextMonthButton.d.ts +1 -0
- package/dist/esm/components/Option.d.ts +1 -0
- package/dist/esm/components/PreviousMonthButton.d.ts +1 -0
- package/dist/esm/components/Root.d.ts +1 -0
- package/dist/esm/components/Select.d.ts +1 -0
- package/dist/esm/components/Week.d.ts +1 -0
- package/dist/esm/components/WeekNumber.d.ts +1 -0
- package/dist/esm/components/WeekNumberHeader.d.ts +1 -0
- package/dist/esm/components/Weekday.d.ts +1 -0
- package/dist/esm/components/Weekdays.d.ts +1 -0
- package/dist/esm/components/Weeks.d.ts +1 -0
- package/dist/esm/types/selection.d.ts +7 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ You are reading the README for `react-day-picker`, the legacy DayPicker package
|
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
|
-
See **[daypicker.dev](https://daypicker.dev)** for guides, examples, and API reference, or read [the v10 docs in the repository](https://github.com/gpbl/react-day-picker/blob/main/apps/website/
|
|
9
|
+
See **[daypicker.dev](https://daypicker.dev)** for guides, examples, and API reference, or read [the v10 docs in the repository](https://github.com/gpbl/react-day-picker/blob/main/apps/website/docs/start.mdx).
|
|
10
10
|
|
|
11
11
|
<picture>
|
|
12
12
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/gpbl/react-day-picker/main/apps/website/static/img/screenshot-dark.png" />
|
|
@@ -32,13 +32,13 @@ DayPicker is written in TypeScript and compiled to CommonJS and ESM. It relies o
|
|
|
32
32
|
Install the legacy DayPicker package name:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
npm install react-day-picker
|
|
35
|
+
npm install react-day-picker
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
For new projects, prefer the `@daypicker/react` package name:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
npm install @daypicker/react
|
|
41
|
+
npm install @daypicker/react
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
<a href="https://www.npmjs.com/package/react-day-picker"><img src="https://img.shields.io/npm/v/react-day-picker" alt="npm version"/></a> <img src="https://img.shields.io/npm/dm/react-day-picker.svg" alt="npm downloads"/> <img src="https://img.shields.io/bundlephobia/minzip/react-day-picker" alt="Min gzipped size"/>
|
package/dist/cjs/DayPicker.js
CHANGED
|
@@ -238,15 +238,15 @@ function DayPicker(initialProps) {
|
|
|
238
238
|
const handleDayMouseLeave = (0, react_1.useCallback)((day, modifiers) => (e) => {
|
|
239
239
|
onDayMouseLeave?.(day.date, modifiers, e);
|
|
240
240
|
}, [onDayMouseLeave]);
|
|
241
|
-
const handleMonthChange = (0, react_1.useCallback)((date) => (e) => {
|
|
241
|
+
const handleMonthChange = (0, react_1.useCallback)((date, monthOffset) => (e) => {
|
|
242
242
|
const selectedMonth = Number(e.target.value);
|
|
243
243
|
const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
|
|
244
|
-
goToMonth(month);
|
|
244
|
+
goToMonth(dateLib.addMonths(month, -monthOffset));
|
|
245
245
|
}, [dateLib, goToMonth]);
|
|
246
|
-
const handleYearChange = (0, react_1.useCallback)((date) => (e) => {
|
|
246
|
+
const handleYearChange = (0, react_1.useCallback)((date, monthOffset) => (e) => {
|
|
247
247
|
const selectedYear = Number(e.target.value);
|
|
248
248
|
const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
|
|
249
|
-
goToMonth(month);
|
|
249
|
+
goToMonth(dateLib.addMonths(month, -monthOffset));
|
|
250
250
|
}, [dateLib, goToMonth]);
|
|
251
251
|
const { className, style } = (0, react_1.useMemo)(() => ({
|
|
252
252
|
className: [classNames[UI_js_1.UI.Root], props.className]
|
|
@@ -255,6 +255,17 @@ function DayPicker(initialProps) {
|
|
|
255
255
|
style: { ...styles?.[UI_js_1.UI.Root], ...props.style },
|
|
256
256
|
}), [classNames, props.className, props.style, styles]);
|
|
257
257
|
const dataAttributes = (0, getDataAttributes_js_1.getDataAttributes)(props);
|
|
258
|
+
const getDropdownStyle = (dropdown) => {
|
|
259
|
+
const dropdownStyle = styles?.[UI_js_1.UI.Dropdown];
|
|
260
|
+
const specificDropdownStyle = styles?.[dropdown];
|
|
261
|
+
if (!dropdownStyle && !specificDropdownStyle) {
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
...dropdownStyle,
|
|
266
|
+
...specificDropdownStyle,
|
|
267
|
+
};
|
|
268
|
+
};
|
|
258
269
|
const rootElRef = (0, react_1.useRef)(null);
|
|
259
270
|
(0, useAnimation_js_1.useAnimation)(rootElRef, Boolean(props.animate), {
|
|
260
271
|
classNames,
|
|
@@ -283,19 +294,22 @@ function DayPicker(initialProps) {
|
|
|
283
294
|
react_1.default.createElement(components.Months, { className: classNames[UI_js_1.UI.Months], style: styles?.[UI_js_1.UI.Months] },
|
|
284
295
|
!props.hideNavigation && !navLayout && (react_1.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Nav], style: styles?.[UI_js_1.UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
|
|
285
296
|
months.map((calendarMonth, displayIndex) => {
|
|
297
|
+
const monthOffset = props.reverseMonths
|
|
298
|
+
? months.length - 1 - displayIndex
|
|
299
|
+
: displayIndex;
|
|
286
300
|
return (react_1.default.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Month], style: styles?.[UI_js_1.UI.Month],
|
|
287
301
|
// biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
|
|
288
302
|
key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
|
|
289
303
|
navLayout === "around" &&
|
|
290
304
|
!props.hideNavigation &&
|
|
291
|
-
displayIndex === 0 && (react_1.default.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI_js_1.UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
292
|
-
react_1.default.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
|
|
305
|
+
displayIndex === 0 && (react_1.default.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI_js_1.UI.PreviousMonthButton], style: styles?.[UI_js_1.UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
306
|
+
react_1.default.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], style: styles?.[UI_js_1.UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
|
|
293
307
|
react_1.default.createElement(components.MonthCaption, { "data-animated-caption": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.MonthCaption], style: styles?.[UI_js_1.UI.MonthCaption], calendarMonth: calendarMonth, displayIndex: displayIndex }, captionLayout?.startsWith("dropdown") ? (react_1.default.createElement(components.DropdownNav, { className: classNames[UI_js_1.UI.Dropdowns], style: styles?.[UI_js_1.UI.Dropdowns] },
|
|
294
308
|
(() => {
|
|
295
309
|
const monthControl = captionLayout === "dropdown" ||
|
|
296
|
-
captionLayout === "dropdown-months" ? (react_1.default.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI_js_1.UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: (0, getMonthOptions_js_1.getMonthOptions)(calendarMonth.date, navStart, navEnd, formatters, dateLib), style:
|
|
310
|
+
captionLayout === "dropdown-months" ? (react_1.default.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI_js_1.UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date, monthOffset), options: (0, getMonthOptions_js_1.getMonthOptions)(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: getDropdownStyle(UI_js_1.UI.MonthsDropdown), value: dateLib.getMonth(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
|
|
297
311
|
const yearControl = captionLayout === "dropdown" ||
|
|
298
|
-
captionLayout === "dropdown-years" ? (react_1.default.createElement(components.YearsDropdown, { key: "year", className: classNames[UI_js_1.UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: (0, getYearOptions_js_1.getYearOptions)(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style:
|
|
312
|
+
captionLayout === "dropdown-years" ? (react_1.default.createElement(components.YearsDropdown, { key: "year", className: classNames[UI_js_1.UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date, monthOffset), options: (0, getYearOptions_js_1.getYearOptions)(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: getDropdownStyle(UI_js_1.UI.YearsDropdown), value: dateLib.getYear(calendarMonth.date) })) : (react_1.default.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
|
|
299
313
|
const controls = dateLib.getMonthYearOrder() === "year-first"
|
|
300
314
|
? [yearControl, monthControl]
|
|
301
315
|
: [monthControl, yearControl];
|
|
@@ -312,11 +326,11 @@ function DayPicker(initialProps) {
|
|
|
312
326
|
width: "1px",
|
|
313
327
|
whiteSpace: "nowrap",
|
|
314
328
|
wordWrap: "normal",
|
|
315
|
-
} }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (react_1.default.createElement(components.CaptionLabel, { className: classNames[UI_js_1.UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
|
|
329
|
+
} }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (react_1.default.createElement(components.CaptionLabel, { className: classNames[UI_js_1.UI.CaptionLabel], style: styles?.[UI_js_1.UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
|
|
316
330
|
navLayout === "around" &&
|
|
317
331
|
!props.hideNavigation &&
|
|
318
|
-
displayIndex === numberOfMonths - 1 && (react_1.default.createElement(components.NextMonthButton, { type: "button", className: classNames[UI_js_1.UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
319
|
-
react_1.default.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
|
|
332
|
+
displayIndex === numberOfMonths - 1 && (react_1.default.createElement(components.NextMonthButton, { type: "button", className: classNames[UI_js_1.UI.NextMonthButton], style: styles?.[UI_js_1.UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
333
|
+
react_1.default.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], style: styles?.[UI_js_1.UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
|
|
320
334
|
displayIndex === numberOfMonths - 1 &&
|
|
321
335
|
navLayout === "after" &&
|
|
322
336
|
!props.hideNavigation && (react_1.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Nav], style: styles?.[UI_js_1.UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
|
|
@@ -19,6 +19,7 @@ export interface DayPickerLocale extends DateFnsLocale {
|
|
|
19
19
|
/** Localized DayPicker-specific labels. */
|
|
20
20
|
labels?: DayPickerLocaleLabels;
|
|
21
21
|
}
|
|
22
|
+
/** Alias for the locale shape accepted by DayPicker APIs. */
|
|
22
23
|
export type Locale = DayPickerLocale;
|
|
23
24
|
/** Indicates the preferred ordering of month and year for localized labels. */
|
|
24
25
|
export type MonthYearOrder = "month-first" | "year-first";
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function CaptionLabel(props: HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link CaptionLabel} component. */
|
|
9
10
|
export type CaptionLabelProps = Parameters<typeof CaptionLabel>[0];
|
|
@@ -7,6 +7,7 @@ import React from "react";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function Chevron(props: {
|
|
9
9
|
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
10
11
|
/**
|
|
11
12
|
* The size of the chevron.
|
|
12
13
|
*
|
|
@@ -18,4 +19,5 @@ export declare function Chevron(props: {
|
|
|
18
19
|
/** The orientation of the chevron. */
|
|
19
20
|
orientation?: "up" | "down" | "left" | "right";
|
|
20
21
|
}): React.JSX.Element;
|
|
22
|
+
/** Props accepted by the {@link Chevron} component. */
|
|
21
23
|
export type ChevronProps = Parameters<typeof Chevron>[0];
|
|
@@ -12,8 +12,8 @@ const react_1 = __importDefault(require("react"));
|
|
|
12
12
|
* @see https://daypicker.dev/guides/custom-components
|
|
13
13
|
*/
|
|
14
14
|
function Chevron(props) {
|
|
15
|
-
const { size = 24, orientation = "left", className } = props;
|
|
16
|
-
return (react_1.default.createElement("svg", { className: className, width: size, height: size, viewBox: "0 0 24 24" },
|
|
15
|
+
const { size = 24, orientation = "left", className, style } = props;
|
|
16
|
+
return (react_1.default.createElement("svg", { className: className, style: style, width: size, height: size, viewBox: "0 0 24 24" },
|
|
17
17
|
orientation === "up" && (react_1.default.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" })),
|
|
18
18
|
orientation === "down" && (react_1.default.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" })),
|
|
19
19
|
orientation === "left" && (react_1.default.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" })),
|
|
@@ -17,4 +17,5 @@ export declare function Day(props: {
|
|
|
17
17
|
/** The modifiers to apply to the day. */
|
|
18
18
|
modifiers: Modifiers;
|
|
19
19
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
20
|
+
/** Props accepted by the {@link Day} component. */
|
|
20
21
|
export type DayProps = Parameters<typeof Day>[0];
|
|
@@ -13,4 +13,5 @@ export declare function DayButton(props: {
|
|
|
13
13
|
/** The modifiers to apply to the day. */
|
|
14
14
|
modifiers: Modifiers;
|
|
15
15
|
} & ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
16
|
+
/** Props accepted by the {@link DayButton} component. */
|
|
16
17
|
export type DayButtonProps = Parameters<typeof DayButton>[0];
|
|
@@ -18,4 +18,5 @@ export declare function Dropdown(props: {
|
|
|
18
18
|
/** The options to display in the dropdown. */
|
|
19
19
|
options?: DropdownOption[] | undefined;
|
|
20
20
|
} & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
|
|
21
|
+
/** Props accepted by the {@link Dropdown} component. */
|
|
21
22
|
export type DropdownProps = Parameters<typeof Dropdown>[0];
|
|
@@ -15,12 +15,12 @@ const useDayPicker_js_1 = require("../useDayPicker.js");
|
|
|
15
15
|
*/
|
|
16
16
|
function Dropdown(props) {
|
|
17
17
|
const { options, className, ...selectProps } = props;
|
|
18
|
-
const { classNames, components } = (0, useDayPicker_js_1.useDayPicker)();
|
|
18
|
+
const { classNames, components, styles } = (0, useDayPicker_js_1.useDayPicker)();
|
|
19
19
|
const cssClassSelect = [classNames[UI_js_1.UI.Dropdown], className].join(" ");
|
|
20
20
|
const selectedOption = options?.find(({ value }) => value === selectProps.value);
|
|
21
|
-
return (react_1.default.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI_js_1.UI.DropdownRoot] },
|
|
21
|
+
return (react_1.default.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI_js_1.UI.DropdownRoot], style: styles?.[UI_js_1.UI.DropdownRoot] },
|
|
22
22
|
react_1.default.createElement(components.Select, { className: cssClassSelect, ...selectProps }, options?.map(({ value, label, disabled }) => (react_1.default.createElement(components.Option, { key: value, value: value, disabled: disabled }, label)))),
|
|
23
|
-
react_1.default.createElement("span", { className: classNames[UI_js_1.UI.CaptionLabel], "aria-hidden": true },
|
|
23
|
+
react_1.default.createElement("span", { className: classNames[UI_js_1.UI.CaptionLabel], style: styles?.[UI_js_1.UI.CaptionLabel], "aria-hidden": true },
|
|
24
24
|
selectedOption?.label,
|
|
25
|
-
react_1.default.createElement(components.Chevron, { orientation: "down", size: 18, className: classNames[UI_js_1.UI.Chevron] }))));
|
|
25
|
+
react_1.default.createElement(components.Chevron, { orientation: "down", size: 18, className: classNames[UI_js_1.UI.Chevron], style: styles?.[UI_js_1.UI.Chevron] }))));
|
|
26
26
|
}
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function DropdownNav(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link DropdownNav} component. */
|
|
9
10
|
export type DropdownNavProps = Parameters<typeof DropdownNav>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Footer(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Footer} component. */
|
|
9
10
|
export type FooterProps = Parameters<typeof Footer>[0];
|
|
@@ -13,4 +13,5 @@ export declare function Month(props: {
|
|
|
13
13
|
/** The index of the month being displayed. */
|
|
14
14
|
displayIndex: number;
|
|
15
15
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
16
|
+
/** Props accepted by the {@link Month} component. */
|
|
16
17
|
export type MonthProps = Parameters<typeof Month>[0];
|
|
@@ -12,4 +12,5 @@ export declare function MonthCaption(props: {
|
|
|
12
12
|
/** The index of the month being displayed. */
|
|
13
13
|
displayIndex: number;
|
|
14
14
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
15
|
+
/** Props accepted by the {@link MonthCaption} component. */
|
|
15
16
|
export type MonthCaptionProps = Parameters<typeof MonthCaption>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type TableHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function MonthGrid(props: TableHTMLAttributes<HTMLTableElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link MonthGrid} component. */
|
|
9
10
|
export type MonthGridProps = Parameters<typeof MonthGrid>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Months(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Months} component. */
|
|
9
10
|
export type MonthsProps = Parameters<typeof Months>[0];
|
|
@@ -15,4 +15,5 @@ export declare function Nav(props: {
|
|
|
15
15
|
/** The date of the next month, if available. */
|
|
16
16
|
nextMonth?: Date | undefined;
|
|
17
17
|
} & HTMLAttributes<HTMLElement>): React.JSX.Element;
|
|
18
|
+
/** Props accepted by the {@link Nav} component. */
|
|
18
19
|
export type NavProps = Parameters<typeof Nav>[0];
|
|
@@ -45,7 +45,7 @@ const useDayPicker_js_1 = require("../useDayPicker.js");
|
|
|
45
45
|
*/
|
|
46
46
|
function Nav(props) {
|
|
47
47
|
const { onPreviousClick, onNextClick, previousMonth, nextMonth, ...navProps } = props;
|
|
48
|
-
const { components, classNames, labels: { labelPrevious, labelNext }, } = (0, useDayPicker_js_1.useDayPicker)();
|
|
48
|
+
const { components, classNames, styles, labels: { labelPrevious, labelNext }, } = (0, useDayPicker_js_1.useDayPicker)();
|
|
49
49
|
const handleNextClick = (0, react_1.useCallback)((e) => {
|
|
50
50
|
if (nextMonth) {
|
|
51
51
|
onNextClick?.(e);
|
|
@@ -57,8 +57,8 @@ function Nav(props) {
|
|
|
57
57
|
}
|
|
58
58
|
}, [previousMonth, onPreviousClick]);
|
|
59
59
|
return (react_1.default.createElement("nav", { ...navProps },
|
|
60
|
-
react_1.default.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI_js_1.UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick },
|
|
61
|
-
react_1.default.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], orientation: "left" })),
|
|
62
|
-
react_1.default.createElement(components.NextMonthButton, { type: "button", className: classNames[UI_js_1.UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick },
|
|
63
|
-
react_1.default.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, orientation: "right", className: classNames[UI_js_1.UI.Chevron] }))));
|
|
60
|
+
react_1.default.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI_js_1.UI.PreviousMonthButton], style: styles?.[UI_js_1.UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick },
|
|
61
|
+
react_1.default.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI_js_1.UI.Chevron], style: styles?.[UI_js_1.UI.Chevron], orientation: "left" })),
|
|
62
|
+
react_1.default.createElement(components.NextMonthButton, { type: "button", className: classNames[UI_js_1.UI.NextMonthButton], style: styles?.[UI_js_1.UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick },
|
|
63
|
+
react_1.default.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, orientation: "right", className: classNames[UI_js_1.UI.Chevron], style: styles?.[UI_js_1.UI.Chevron] }))));
|
|
64
64
|
}
|
|
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function NextMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link NextMonthButton} component. */
|
|
9
10
|
export type NextMonthButtonProps = Parameters<typeof NextMonthButton>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type OptionHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Option(props: OptionHTMLAttributes<HTMLOptionElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Option} component. */
|
|
9
10
|
export type OptionProps = Parameters<typeof Option>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function PreviousMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link PreviousMonthButton} component. */
|
|
9
10
|
export type PreviousMonthButtonProps = Parameters<typeof PreviousMonthButton>[0];
|
|
@@ -9,4 +9,5 @@ export declare function Root(props: {
|
|
|
9
9
|
/** Ref for the root element, used when `animate` is `true`. */
|
|
10
10
|
rootRef?: Ref<HTMLDivElement>;
|
|
11
11
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
12
|
+
/** Props accepted by the {@link Root} component. */
|
|
12
13
|
export type RootProps = Parameters<typeof Root>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type SelectHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Select(props: SelectHTMLAttributes<HTMLSelectElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Select} component. */
|
|
9
10
|
export type SelectProps = Parameters<typeof Select>[0];
|
|
@@ -10,4 +10,5 @@ export declare function WeekNumber(props: {
|
|
|
10
10
|
/** The week to display. */
|
|
11
11
|
week: CalendarWeek;
|
|
12
12
|
} & ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
13
|
+
/** Props accepted by the {@link WeekNumber} component. */
|
|
13
14
|
export type WeekNumberProps = Parameters<typeof WeekNumber>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function WeekNumberHeader(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link WeekNumberHeader} component. */
|
|
9
10
|
export type WeekNumberHeaderProps = Parameters<typeof WeekNumberHeader>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weekday(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weekday} component. */
|
|
9
10
|
export type WeekdayProps = Parameters<typeof Weekday>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weekdays(props: HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weekdays} component. */
|
|
9
10
|
export type WeekdaysProps = Parameters<typeof Weekdays>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weeks(props: HTMLAttributes<HTMLTableSectionElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weeks} component. */
|
|
9
10
|
export type WeeksProps = Parameters<typeof Weeks>[0];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DayPickerProps } from "./props.js";
|
|
2
2
|
import type { DateRange, Mode, Modifiers } from "./shared.js";
|
|
3
|
+
/** Selection state and helpers for the active selection mode. */
|
|
3
4
|
export type Selection<T extends DayPickerProps> = {
|
|
4
5
|
/** The selected date(s). */
|
|
5
6
|
selected: SelectedValue<T> | undefined;
|
|
@@ -8,12 +9,15 @@ export type Selection<T extends DayPickerProps> = {
|
|
|
8
9
|
/** Whether the given date is selected. */
|
|
9
10
|
isSelected: (date: Date) => boolean;
|
|
10
11
|
};
|
|
12
|
+
/** Selected value for single selection mode, respecting required selections. */
|
|
11
13
|
export type SelectedSingle<T extends {
|
|
12
14
|
required?: boolean;
|
|
13
15
|
}> = T["required"] extends true ? Date : Date | undefined;
|
|
16
|
+
/** Selected value for multiple selection mode, respecting required selections. */
|
|
14
17
|
export type SelectedMulti<T extends {
|
|
15
18
|
required?: boolean;
|
|
16
19
|
}> = T["required"] extends true ? Date[] : Date[] | undefined;
|
|
20
|
+
/** Selected value for range selection mode, respecting required selections. */
|
|
17
21
|
export type SelectedRange<T extends {
|
|
18
22
|
required?: boolean;
|
|
19
23
|
}> = T["required"] extends true ? DateRange : DateRange | undefined;
|
|
@@ -46,12 +50,15 @@ export type SelectedValue<T> = T extends {
|
|
|
46
50
|
mode: "range";
|
|
47
51
|
required?: boolean;
|
|
48
52
|
} ? SelectedRange<T> : undefined;
|
|
53
|
+
/** Selection handler for single selection mode. */
|
|
49
54
|
export type SelectHandlerSingle<T extends {
|
|
50
55
|
required?: boolean | undefined;
|
|
51
56
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined;
|
|
57
|
+
/** Selection handler for multiple selection mode. */
|
|
52
58
|
export type SelectHandlerMulti<T extends {
|
|
53
59
|
required?: boolean | undefined;
|
|
54
60
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined;
|
|
61
|
+
/** Selection handler for range selection mode. */
|
|
55
62
|
export type SelectHandlerRange<T extends {
|
|
56
63
|
required?: boolean | undefined;
|
|
57
64
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined;
|
package/dist/esm/DayPicker.js
CHANGED
|
@@ -202,15 +202,15 @@ export function DayPicker(initialProps) {
|
|
|
202
202
|
const handleDayMouseLeave = useCallback((day, modifiers) => (e) => {
|
|
203
203
|
onDayMouseLeave?.(day.date, modifiers, e);
|
|
204
204
|
}, [onDayMouseLeave]);
|
|
205
|
-
const handleMonthChange = useCallback((date) => (e) => {
|
|
205
|
+
const handleMonthChange = useCallback((date, monthOffset) => (e) => {
|
|
206
206
|
const selectedMonth = Number(e.target.value);
|
|
207
207
|
const month = dateLib.setMonth(dateLib.startOfMonth(date), selectedMonth);
|
|
208
|
-
goToMonth(month);
|
|
208
|
+
goToMonth(dateLib.addMonths(month, -monthOffset));
|
|
209
209
|
}, [dateLib, goToMonth]);
|
|
210
|
-
const handleYearChange = useCallback((date) => (e) => {
|
|
210
|
+
const handleYearChange = useCallback((date, monthOffset) => (e) => {
|
|
211
211
|
const selectedYear = Number(e.target.value);
|
|
212
212
|
const month = dateLib.setYear(dateLib.startOfMonth(date), selectedYear);
|
|
213
|
-
goToMonth(month);
|
|
213
|
+
goToMonth(dateLib.addMonths(month, -monthOffset));
|
|
214
214
|
}, [dateLib, goToMonth]);
|
|
215
215
|
const { className, style } = useMemo(() => ({
|
|
216
216
|
className: [classNames[UI.Root], props.className]
|
|
@@ -219,6 +219,17 @@ export function DayPicker(initialProps) {
|
|
|
219
219
|
style: { ...styles?.[UI.Root], ...props.style },
|
|
220
220
|
}), [classNames, props.className, props.style, styles]);
|
|
221
221
|
const dataAttributes = getDataAttributes(props);
|
|
222
|
+
const getDropdownStyle = (dropdown) => {
|
|
223
|
+
const dropdownStyle = styles?.[UI.Dropdown];
|
|
224
|
+
const specificDropdownStyle = styles?.[dropdown];
|
|
225
|
+
if (!dropdownStyle && !specificDropdownStyle) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
...dropdownStyle,
|
|
230
|
+
...specificDropdownStyle,
|
|
231
|
+
};
|
|
232
|
+
};
|
|
222
233
|
const rootElRef = useRef(null);
|
|
223
234
|
useAnimation(rootElRef, Boolean(props.animate), {
|
|
224
235
|
classNames,
|
|
@@ -247,19 +258,22 @@ export function DayPicker(initialProps) {
|
|
|
247
258
|
React.createElement(components.Months, { className: classNames[UI.Months], style: styles?.[UI.Months] },
|
|
248
259
|
!props.hideNavigation && !navLayout && (React.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
|
|
249
260
|
months.map((calendarMonth, displayIndex) => {
|
|
261
|
+
const monthOffset = props.reverseMonths
|
|
262
|
+
? months.length - 1 - displayIndex
|
|
263
|
+
: displayIndex;
|
|
250
264
|
return (React.createElement(components.Month, { "data-animated-month": props.animate ? "true" : undefined, className: classNames[UI.Month], style: styles?.[UI.Month],
|
|
251
265
|
// biome-ignore lint/suspicious/noArrayIndexKey: breaks animation
|
|
252
266
|
key: displayIndex, displayIndex: displayIndex, calendarMonth: calendarMonth },
|
|
253
267
|
navLayout === "around" &&
|
|
254
268
|
!props.hideNavigation &&
|
|
255
|
-
displayIndex === 0 && (React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
256
|
-
React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
|
|
269
|
+
displayIndex === 0 && (React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], style: styles?.[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
270
|
+
React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: props.dir === "rtl" ? "right" : "left" }))),
|
|
257
271
|
React.createElement(components.MonthCaption, { "data-animated-caption": props.animate ? "true" : undefined, className: classNames[UI.MonthCaption], style: styles?.[UI.MonthCaption], calendarMonth: calendarMonth, displayIndex: displayIndex }, captionLayout?.startsWith("dropdown") ? (React.createElement(components.DropdownNav, { className: classNames[UI.Dropdowns], style: styles?.[UI.Dropdowns] },
|
|
258
272
|
(() => {
|
|
259
273
|
const monthControl = captionLayout === "dropdown" ||
|
|
260
|
-
captionLayout === "dropdown-months" ? (React.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters, dateLib), style:
|
|
274
|
+
captionLayout === "dropdown-months" ? (React.createElement(components.MonthsDropdown, { key: "month", className: classNames[UI.MonthsDropdown], "aria-label": labelMonthDropdown(), disabled: Boolean(props.disableNavigation), onChange: handleMonthChange(calendarMonth.date, monthOffset), options: getMonthOptions(calendarMonth.date, navStart, navEnd, formatters, dateLib), style: getDropdownStyle(UI.MonthsDropdown), value: dateLib.getMonth(calendarMonth.date) })) : (React.createElement("span", { key: "month" }, formatMonthDropdown(calendarMonth.date, dateLib)));
|
|
261
275
|
const yearControl = captionLayout === "dropdown" ||
|
|
262
|
-
captionLayout === "dropdown-years" ? (React.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date), options: getYearOptions(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style:
|
|
276
|
+
captionLayout === "dropdown-years" ? (React.createElement(components.YearsDropdown, { key: "year", className: classNames[UI.YearsDropdown], "aria-label": labelYearDropdown(dateLib.options), disabled: Boolean(props.disableNavigation), onChange: handleYearChange(calendarMonth.date, monthOffset), options: getYearOptions(navStart, navEnd, formatters, dateLib, Boolean(props.reverseYears)), style: getDropdownStyle(UI.YearsDropdown), value: dateLib.getYear(calendarMonth.date) })) : (React.createElement("span", { key: "year" }, formatYearDropdown(calendarMonth.date, dateLib)));
|
|
263
277
|
const controls = dateLib.getMonthYearOrder() === "year-first"
|
|
264
278
|
? [yearControl, monthControl]
|
|
265
279
|
: [monthControl, yearControl];
|
|
@@ -276,11 +290,11 @@ export function DayPicker(initialProps) {
|
|
|
276
290
|
width: "1px",
|
|
277
291
|
whiteSpace: "nowrap",
|
|
278
292
|
wordWrap: "normal",
|
|
279
|
-
} }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (React.createElement(components.CaptionLabel, { className: classNames[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
|
|
293
|
+
} }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))) : (React.createElement(components.CaptionLabel, { className: classNames[UI.CaptionLabel], style: styles?.[UI.CaptionLabel], role: "status", "aria-live": "polite" }, formatCaption(calendarMonth.date, dateLib.options, dateLib)))),
|
|
280
294
|
navLayout === "around" &&
|
|
281
295
|
!props.hideNavigation &&
|
|
282
|
-
displayIndex === numberOfMonths - 1 && (React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
283
|
-
React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
|
|
296
|
+
displayIndex === numberOfMonths - 1 && (React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], style: styles?.[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick, "data-animated-button": props.animate ? "true" : undefined },
|
|
297
|
+
React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: props.dir === "rtl" ? "left" : "right" }))),
|
|
284
298
|
displayIndex === numberOfMonths - 1 &&
|
|
285
299
|
navLayout === "after" &&
|
|
286
300
|
!props.hideNavigation && (React.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI.Nav], style: styles?.[UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
|
|
@@ -19,6 +19,7 @@ export interface DayPickerLocale extends DateFnsLocale {
|
|
|
19
19
|
/** Localized DayPicker-specific labels. */
|
|
20
20
|
labels?: DayPickerLocaleLabels;
|
|
21
21
|
}
|
|
22
|
+
/** Alias for the locale shape accepted by DayPicker APIs. */
|
|
22
23
|
export type Locale = DayPickerLocale;
|
|
23
24
|
/** Indicates the preferred ordering of month and year for localized labels. */
|
|
24
25
|
export type MonthYearOrder = "month-first" | "year-first";
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function CaptionLabel(props: HTMLAttributes<HTMLSpanElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link CaptionLabel} component. */
|
|
9
10
|
export type CaptionLabelProps = Parameters<typeof CaptionLabel>[0];
|
|
@@ -7,6 +7,7 @@ import React from "react";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function Chevron(props: {
|
|
9
9
|
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
10
11
|
/**
|
|
11
12
|
* The size of the chevron.
|
|
12
13
|
*
|
|
@@ -18,4 +19,5 @@ export declare function Chevron(props: {
|
|
|
18
19
|
/** The orientation of the chevron. */
|
|
19
20
|
orientation?: "up" | "down" | "left" | "right";
|
|
20
21
|
}): React.JSX.Element;
|
|
22
|
+
/** Props accepted by the {@link Chevron} component. */
|
|
21
23
|
export type ChevronProps = Parameters<typeof Chevron>[0];
|
|
@@ -6,8 +6,8 @@ import React from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export function Chevron(props) {
|
|
9
|
-
const { size = 24, orientation = "left", className } = props;
|
|
10
|
-
return (React.createElement("svg", { className: className, width: size, height: size, viewBox: "0 0 24 24" },
|
|
9
|
+
const { size = 24, orientation = "left", className, style } = props;
|
|
10
|
+
return (React.createElement("svg", { className: className, style: style, width: size, height: size, viewBox: "0 0 24 24" },
|
|
11
11
|
orientation === "up" && (React.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" })),
|
|
12
12
|
orientation === "down" && (React.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" })),
|
|
13
13
|
orientation === "left" && (React.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" })),
|
|
@@ -17,4 +17,5 @@ export declare function Day(props: {
|
|
|
17
17
|
/** The modifiers to apply to the day. */
|
|
18
18
|
modifiers: Modifiers;
|
|
19
19
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
20
|
+
/** Props accepted by the {@link Day} component. */
|
|
20
21
|
export type DayProps = Parameters<typeof Day>[0];
|
|
@@ -13,4 +13,5 @@ export declare function DayButton(props: {
|
|
|
13
13
|
/** The modifiers to apply to the day. */
|
|
14
14
|
modifiers: Modifiers;
|
|
15
15
|
} & ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
16
|
+
/** Props accepted by the {@link DayButton} component. */
|
|
16
17
|
export type DayButtonProps = Parameters<typeof DayButton>[0];
|
|
@@ -18,4 +18,5 @@ export declare function Dropdown(props: {
|
|
|
18
18
|
/** The options to display in the dropdown. */
|
|
19
19
|
options?: DropdownOption[] | undefined;
|
|
20
20
|
} & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
|
|
21
|
+
/** Props accepted by the {@link Dropdown} component. */
|
|
21
22
|
export type DropdownProps = Parameters<typeof Dropdown>[0];
|
|
@@ -9,12 +9,12 @@ import { useDayPicker } from "../useDayPicker.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export function Dropdown(props) {
|
|
11
11
|
const { options, className, ...selectProps } = props;
|
|
12
|
-
const { classNames, components } = useDayPicker();
|
|
12
|
+
const { classNames, components, styles } = useDayPicker();
|
|
13
13
|
const cssClassSelect = [classNames[UI.Dropdown], className].join(" ");
|
|
14
14
|
const selectedOption = options?.find(({ value }) => value === selectProps.value);
|
|
15
|
-
return (React.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI.DropdownRoot] },
|
|
15
|
+
return (React.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI.DropdownRoot], style: styles?.[UI.DropdownRoot] },
|
|
16
16
|
React.createElement(components.Select, { className: cssClassSelect, ...selectProps }, options?.map(({ value, label, disabled }) => (React.createElement(components.Option, { key: value, value: value, disabled: disabled }, label)))),
|
|
17
|
-
React.createElement("span", { className: classNames[UI.CaptionLabel], "aria-hidden": true },
|
|
17
|
+
React.createElement("span", { className: classNames[UI.CaptionLabel], style: styles?.[UI.CaptionLabel], "aria-hidden": true },
|
|
18
18
|
selectedOption?.label,
|
|
19
|
-
React.createElement(components.Chevron, { orientation: "down", size: 18, className: classNames[UI.Chevron] }))));
|
|
19
|
+
React.createElement(components.Chevron, { orientation: "down", size: 18, className: classNames[UI.Chevron], style: styles?.[UI.Chevron] }))));
|
|
20
20
|
}
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function DropdownNav(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link DropdownNav} component. */
|
|
9
10
|
export type DropdownNavProps = Parameters<typeof DropdownNav>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Footer(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Footer} component. */
|
|
9
10
|
export type FooterProps = Parameters<typeof Footer>[0];
|
|
@@ -13,4 +13,5 @@ export declare function Month(props: {
|
|
|
13
13
|
/** The index of the month being displayed. */
|
|
14
14
|
displayIndex: number;
|
|
15
15
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
16
|
+
/** Props accepted by the {@link Month} component. */
|
|
16
17
|
export type MonthProps = Parameters<typeof Month>[0];
|
|
@@ -12,4 +12,5 @@ export declare function MonthCaption(props: {
|
|
|
12
12
|
/** The index of the month being displayed. */
|
|
13
13
|
displayIndex: number;
|
|
14
14
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
15
|
+
/** Props accepted by the {@link MonthCaption} component. */
|
|
15
16
|
export type MonthCaptionProps = Parameters<typeof MonthCaption>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type TableHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function MonthGrid(props: TableHTMLAttributes<HTMLTableElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link MonthGrid} component. */
|
|
9
10
|
export type MonthGridProps = Parameters<typeof MonthGrid>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Months(props: HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Months} component. */
|
|
9
10
|
export type MonthsProps = Parameters<typeof Months>[0];
|
|
@@ -15,4 +15,5 @@ export declare function Nav(props: {
|
|
|
15
15
|
/** The date of the next month, if available. */
|
|
16
16
|
nextMonth?: Date | undefined;
|
|
17
17
|
} & HTMLAttributes<HTMLElement>): React.JSX.Element;
|
|
18
|
+
/** Props accepted by the {@link Nav} component. */
|
|
18
19
|
export type NavProps = Parameters<typeof Nav>[0];
|
|
@@ -9,7 +9,7 @@ import { useDayPicker } from "../useDayPicker.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export function Nav(props) {
|
|
11
11
|
const { onPreviousClick, onNextClick, previousMonth, nextMonth, ...navProps } = props;
|
|
12
|
-
const { components, classNames, labels: { labelPrevious, labelNext }, } = useDayPicker();
|
|
12
|
+
const { components, classNames, styles, labels: { labelPrevious, labelNext }, } = useDayPicker();
|
|
13
13
|
const handleNextClick = useCallback((e) => {
|
|
14
14
|
if (nextMonth) {
|
|
15
15
|
onNextClick?.(e);
|
|
@@ -21,8 +21,8 @@ export function Nav(props) {
|
|
|
21
21
|
}
|
|
22
22
|
}, [previousMonth, onPreviousClick]);
|
|
23
23
|
return (React.createElement("nav", { ...navProps },
|
|
24
|
-
React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick },
|
|
25
|
-
React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], orientation: "left" })),
|
|
26
|
-
React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick },
|
|
27
|
-
React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, orientation: "right", className: classNames[UI.Chevron] }))));
|
|
24
|
+
React.createElement(components.PreviousMonthButton, { type: "button", className: classNames[UI.PreviousMonthButton], style: styles?.[UI.PreviousMonthButton], tabIndex: previousMonth ? undefined : -1, "aria-disabled": previousMonth ? undefined : true, "aria-label": labelPrevious(previousMonth), onClick: handlePreviousClick },
|
|
25
|
+
React.createElement(components.Chevron, { disabled: previousMonth ? undefined : true, className: classNames[UI.Chevron], style: styles?.[UI.Chevron], orientation: "left" })),
|
|
26
|
+
React.createElement(components.NextMonthButton, { type: "button", className: classNames[UI.NextMonthButton], style: styles?.[UI.NextMonthButton], tabIndex: nextMonth ? undefined : -1, "aria-disabled": nextMonth ? undefined : true, "aria-label": labelNext(nextMonth), onClick: handleNextClick },
|
|
27
|
+
React.createElement(components.Chevron, { disabled: nextMonth ? undefined : true, orientation: "right", className: classNames[UI.Chevron], style: styles?.[UI.Chevron] }))));
|
|
28
28
|
}
|
|
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function NextMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link NextMonthButton} component. */
|
|
9
10
|
export type NextMonthButtonProps = Parameters<typeof NextMonthButton>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type OptionHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Option(props: OptionHTMLAttributes<HTMLOptionElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Option} component. */
|
|
9
10
|
export type OptionProps = Parameters<typeof Option>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ButtonHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function PreviousMonthButton(props: ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link PreviousMonthButton} component. */
|
|
9
10
|
export type PreviousMonthButtonProps = Parameters<typeof PreviousMonthButton>[0];
|
|
@@ -9,4 +9,5 @@ export declare function Root(props: {
|
|
|
9
9
|
/** Ref for the root element, used when `animate` is `true`. */
|
|
10
10
|
rootRef?: Ref<HTMLDivElement>;
|
|
11
11
|
} & HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
12
|
+
/** Props accepted by the {@link Root} component. */
|
|
12
13
|
export type RootProps = Parameters<typeof Root>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type SelectHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Select(props: SelectHTMLAttributes<HTMLSelectElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Select} component. */
|
|
9
10
|
export type SelectProps = Parameters<typeof Select>[0];
|
|
@@ -10,4 +10,5 @@ export declare function WeekNumber(props: {
|
|
|
10
10
|
/** The week to display. */
|
|
11
11
|
week: CalendarWeek;
|
|
12
12
|
} & ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
13
|
+
/** Props accepted by the {@link WeekNumber} component. */
|
|
13
14
|
export type WeekNumberProps = Parameters<typeof WeekNumber>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function WeekNumberHeader(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link WeekNumberHeader} component. */
|
|
9
10
|
export type WeekNumberHeaderProps = Parameters<typeof WeekNumberHeader>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type ThHTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weekday(props: ThHTMLAttributes<HTMLTableCellElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weekday} component. */
|
|
9
10
|
export type WeekdayProps = Parameters<typeof Weekday>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weekdays(props: HTMLAttributes<HTMLTableRowElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weekdays} component. */
|
|
9
10
|
export type WeekdaysProps = Parameters<typeof Weekdays>[0];
|
|
@@ -6,4 +6,5 @@ import React, { type HTMLAttributes } from "react";
|
|
|
6
6
|
* @see https://daypicker.dev/guides/custom-components
|
|
7
7
|
*/
|
|
8
8
|
export declare function Weeks(props: HTMLAttributes<HTMLTableSectionElement>): React.JSX.Element;
|
|
9
|
+
/** Props accepted by the {@link Weeks} component. */
|
|
9
10
|
export type WeeksProps = Parameters<typeof Weeks>[0];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DayPickerProps } from "./props.js";
|
|
2
2
|
import type { DateRange, Mode, Modifiers } from "./shared.js";
|
|
3
|
+
/** Selection state and helpers for the active selection mode. */
|
|
3
4
|
export type Selection<T extends DayPickerProps> = {
|
|
4
5
|
/** The selected date(s). */
|
|
5
6
|
selected: SelectedValue<T> | undefined;
|
|
@@ -8,12 +9,15 @@ export type Selection<T extends DayPickerProps> = {
|
|
|
8
9
|
/** Whether the given date is selected. */
|
|
9
10
|
isSelected: (date: Date) => boolean;
|
|
10
11
|
};
|
|
12
|
+
/** Selected value for single selection mode, respecting required selections. */
|
|
11
13
|
export type SelectedSingle<T extends {
|
|
12
14
|
required?: boolean;
|
|
13
15
|
}> = T["required"] extends true ? Date : Date | undefined;
|
|
16
|
+
/** Selected value for multiple selection mode, respecting required selections. */
|
|
14
17
|
export type SelectedMulti<T extends {
|
|
15
18
|
required?: boolean;
|
|
16
19
|
}> = T["required"] extends true ? Date[] : Date[] | undefined;
|
|
20
|
+
/** Selected value for range selection mode, respecting required selections. */
|
|
17
21
|
export type SelectedRange<T extends {
|
|
18
22
|
required?: boolean;
|
|
19
23
|
}> = T["required"] extends true ? DateRange : DateRange | undefined;
|
|
@@ -46,12 +50,15 @@ export type SelectedValue<T> = T extends {
|
|
|
46
50
|
mode: "range";
|
|
47
51
|
required?: boolean;
|
|
48
52
|
} ? SelectedRange<T> : undefined;
|
|
53
|
+
/** Selection handler for single selection mode. */
|
|
49
54
|
export type SelectHandlerSingle<T extends {
|
|
50
55
|
required?: boolean | undefined;
|
|
51
56
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined;
|
|
57
|
+
/** Selection handler for multiple selection mode. */
|
|
52
58
|
export type SelectHandlerMulti<T extends {
|
|
53
59
|
required?: boolean | undefined;
|
|
54
60
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined;
|
|
61
|
+
/** Selection handler for range selection mode. */
|
|
55
62
|
export type SelectHandlerRange<T extends {
|
|
56
63
|
required?: boolean | undefined;
|
|
57
64
|
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-day-picker",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "Customizable Date Picker for React",
|
|
5
5
|
"author": "Giampaolo Bellavite <io@gpbl.dev>",
|
|
6
6
|
"homepage": "https://daypicker.dev",
|
|
@@ -168,7 +168,13 @@
|
|
|
168
168
|
"date-fns": "^4.1.0"
|
|
169
169
|
},
|
|
170
170
|
"peerDependencies": {
|
|
171
|
-
"react": ">=16.8.0"
|
|
171
|
+
"react": ">=16.8.0",
|
|
172
|
+
"@types/react": ">=16.8.0"
|
|
173
|
+
},
|
|
174
|
+
"peerDependenciesMeta": {
|
|
175
|
+
"@types/react": {
|
|
176
|
+
"optional": true
|
|
177
|
+
}
|
|
172
178
|
},
|
|
173
179
|
"funding": {
|
|
174
180
|
"type": "individual",
|