react-day-picker 9.1.1 → 9.1.2
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 +8 -8
- package/dist/cjs/DayPicker.js +10 -10
- package/dist/cjs/DayPicker.js.map +1 -1
- package/dist/cjs/classes/CalendarDay.d.ts +1 -1
- package/dist/cjs/classes/CalendarDay.js.map +1 -1
- package/dist/cjs/components/WeekNumber.d.ts +1 -1
- package/dist/cjs/components/WeekNumber.js +2 -2
- package/dist/cjs/formatters/formatCaption.d.ts +1 -2
- package/dist/cjs/formatters/formatCaption.js.map +1 -1
- package/dist/cjs/formatters/formatDay.d.ts +1 -2
- package/dist/cjs/formatters/formatDay.js.map +1 -1
- package/dist/cjs/formatters/formatWeekdayName.d.ts +1 -2
- package/dist/cjs/formatters/formatWeekdayName.js.map +1 -1
- package/dist/cjs/helpers/getDateLib.d.ts +2 -1
- package/dist/cjs/helpers/getDateLib.js.map +1 -1
- package/dist/cjs/helpers/getDates.js +2 -2
- package/dist/cjs/helpers/getDates.js.map +1 -1
- package/dist/cjs/helpers/getDisplayMonths.d.ts +2 -1
- package/dist/cjs/helpers/getDisplayMonths.js.map +1 -1
- package/dist/cjs/helpers/getFocusableDate.d.ts +2 -1
- package/dist/cjs/helpers/getInitialMonth.js +5 -1
- package/dist/cjs/helpers/getInitialMonth.js.map +1 -1
- package/dist/cjs/helpers/getMonthOptions.d.ts +2 -2
- package/dist/cjs/helpers/getMonthOptions.js +6 -3
- package/dist/cjs/helpers/getMonthOptions.js.map +1 -1
- package/dist/cjs/helpers/getMonths.d.ts +2 -1
- package/dist/cjs/helpers/getMonths.js.map +1 -1
- package/dist/cjs/helpers/getNavMonth.d.ts +3 -2
- package/dist/cjs/helpers/getNavMonth.js +11 -3
- package/dist/cjs/helpers/getNavMonth.js.map +1 -1
- package/dist/cjs/helpers/getNextFocus.d.ts +2 -1
- package/dist/cjs/helpers/getNextMonth.d.ts +2 -1
- package/dist/cjs/helpers/getNextMonth.js.map +1 -1
- package/dist/cjs/helpers/getPreviousMonth.d.ts +2 -1
- package/dist/cjs/helpers/getPreviousMonth.js.map +1 -1
- package/dist/cjs/helpers/getWeekdays.d.ts +1 -2
- package/dist/cjs/helpers/getWeekdays.js +5 -1
- package/dist/cjs/helpers/getWeekdays.js.map +1 -1
- package/dist/cjs/helpers/getYearOptions.d.ts +2 -1
- package/dist/cjs/helpers/getYearOptions.js +6 -5
- package/dist/cjs/helpers/getYearOptions.js.map +1 -1
- package/dist/cjs/labels/labelGrid.d.ts +1 -2
- package/dist/cjs/labels/labelGrid.js.map +1 -1
- package/dist/cjs/labels/labelWeekday.d.ts +1 -2
- package/dist/cjs/labels/labelWeekday.js.map +1 -1
- package/dist/cjs/lib/dateLib.d.ts +66 -3
- package/dist/cjs/lib/dateLib.js +0 -2
- package/dist/cjs/lib/dateLib.js.map +1 -1
- package/dist/cjs/selection/useMulti.d.ts +2 -1
- package/dist/cjs/selection/useRange.d.ts +2 -1
- package/dist/cjs/selection/useSingle.d.ts +2 -1
- package/dist/cjs/types/props.d.ts +15 -5
- package/dist/cjs/types/selection.d.ts +14 -5
- package/dist/cjs/types/shared.d.ts +17 -8
- package/dist/cjs/useCalendar.d.ts +1 -1
- package/dist/cjs/useDayPicker.d.ts +30 -6
- package/dist/cjs/useDayPicker.js +10 -2
- package/dist/cjs/useDayPicker.js.map +1 -1
- package/dist/cjs/useFocus.d.ts +2 -1
- package/dist/cjs/useGetModifiers.d.ts +2 -1
- package/dist/cjs/useGetModifiers.js +6 -1
- package/dist/cjs/useGetModifiers.js.map +1 -1
- package/dist/cjs/useSelection.d.ts +2 -1
- package/dist/cjs/useSelection.js.map +1 -1
- package/dist/cjs/utils/addToRange.d.ts +2 -1
- package/dist/cjs/utils/addToRange.js.map +1 -1
- package/dist/cjs/utils/dateMatchModifiers.d.ts +2 -1
- package/dist/cjs/utils/dateMatchModifiers.js.map +1 -1
- package/dist/cjs/utils/rangeIncludesDate.d.ts +2 -1
- package/dist/cjs/utils/rangeIncludesDate.js.map +1 -1
- package/dist/cjs/utils/typeguards.d.ts +2 -1
- package/dist/esm/DayPicker.js +10 -10
- package/dist/esm/DayPicker.js.map +1 -1
- package/dist/esm/classes/CalendarDay.d.ts +1 -1
- package/dist/esm/classes/CalendarDay.js.map +1 -1
- package/dist/esm/components/WeekNumber.d.ts +1 -1
- package/dist/esm/components/WeekNumber.js +2 -2
- package/dist/esm/formatters/formatCaption.d.ts +1 -2
- package/dist/esm/formatters/formatCaption.js.map +1 -1
- package/dist/esm/formatters/formatDay.d.ts +1 -2
- package/dist/esm/formatters/formatDay.js.map +1 -1
- package/dist/esm/formatters/formatWeekdayName.d.ts +1 -2
- package/dist/esm/formatters/formatWeekdayName.js.map +1 -1
- package/dist/esm/helpers/getDateLib.d.ts +2 -1
- package/dist/esm/helpers/getDateLib.js.map +1 -1
- package/dist/esm/helpers/getDates.js +2 -2
- package/dist/esm/helpers/getDates.js.map +1 -1
- package/dist/esm/helpers/getDisplayMonths.d.ts +2 -1
- package/dist/esm/helpers/getDisplayMonths.js.map +1 -1
- package/dist/esm/helpers/getFocusableDate.d.ts +2 -1
- package/dist/esm/helpers/getInitialMonth.js +5 -1
- package/dist/esm/helpers/getInitialMonth.js.map +1 -1
- package/dist/esm/helpers/getMonthOptions.d.ts +2 -2
- package/dist/esm/helpers/getMonthOptions.js +6 -3
- package/dist/esm/helpers/getMonthOptions.js.map +1 -1
- package/dist/esm/helpers/getMonths.d.ts +2 -1
- package/dist/esm/helpers/getMonths.js.map +1 -1
- package/dist/esm/helpers/getNavMonth.d.ts +3 -2
- package/dist/esm/helpers/getNavMonth.js +11 -3
- package/dist/esm/helpers/getNavMonth.js.map +1 -1
- package/dist/esm/helpers/getNextFocus.d.ts +2 -1
- package/dist/esm/helpers/getNextMonth.d.ts +2 -1
- package/dist/esm/helpers/getNextMonth.js.map +1 -1
- package/dist/esm/helpers/getPreviousMonth.d.ts +2 -1
- package/dist/esm/helpers/getPreviousMonth.js.map +1 -1
- package/dist/esm/helpers/getWeekdays.d.ts +1 -2
- package/dist/esm/helpers/getWeekdays.js +5 -1
- package/dist/esm/helpers/getWeekdays.js.map +1 -1
- package/dist/esm/helpers/getYearOptions.d.ts +2 -1
- package/dist/esm/helpers/getYearOptions.js +6 -5
- package/dist/esm/helpers/getYearOptions.js.map +1 -1
- package/dist/esm/labels/labelGrid.d.ts +1 -2
- package/dist/esm/labels/labelGrid.js.map +1 -1
- package/dist/esm/labels/labelWeekday.d.ts +1 -2
- package/dist/esm/labels/labelWeekday.js.map +1 -1
- package/dist/esm/lib/dateLib.d.ts +66 -3
- package/dist/esm/lib/dateLib.js +0 -2
- package/dist/esm/lib/dateLib.js.map +1 -1
- package/dist/esm/selection/useMulti.d.ts +2 -1
- package/dist/esm/selection/useRange.d.ts +2 -1
- package/dist/esm/selection/useSingle.d.ts +2 -1
- package/dist/esm/types/props.d.ts +15 -5
- package/dist/esm/types/selection.d.ts +14 -5
- package/dist/esm/types/shared.d.ts +17 -8
- package/dist/esm/useCalendar.d.ts +1 -1
- package/dist/esm/useDayPicker.d.ts +30 -6
- package/dist/esm/useDayPicker.js +10 -2
- package/dist/esm/useDayPicker.js.map +1 -1
- package/dist/esm/useFocus.d.ts +2 -1
- package/dist/esm/useGetModifiers.d.ts +2 -1
- package/dist/esm/useGetModifiers.js +6 -1
- package/dist/esm/useGetModifiers.js.map +1 -1
- package/dist/esm/useSelection.d.ts +2 -1
- package/dist/esm/useSelection.js.map +1 -1
- package/dist/esm/utils/addToRange.d.ts +2 -1
- package/dist/esm/utils/addToRange.js.map +1 -1
- package/dist/esm/utils/dateMatchModifiers.d.ts +2 -1
- package/dist/esm/utils/dateMatchModifiers.js.map +1 -1
- package/dist/esm/utils/rangeIncludesDate.d.ts +2 -1
- package/dist/esm/utils/rangeIncludesDate.js.map +1 -1
- package/dist/esm/utils/typeguards.d.ts +2 -1
- package/examples/Input.test.tsx +1 -1
- package/examples/ModifiersHidden.test.tsx +1 -1
- package/examples/Range.test.tsx +1 -1
- package/examples/RangeShiftKey.tsx +1 -1
- package/examples/SingleMockDate.test.tsx +39 -0
- package/examples/WeekStartsOn.tsx +7 -0
- package/examples/Weeknumber.test.tsx +2 -2
- package/examples/WeeknumberCustom.tsx +2 -2
- package/examples/__snapshots__/Range.test.tsx.snap +84 -100
- package/examples/__snapshots__/StylingCssModules.test.tsx.snap +42 -50
- package/examples/index.ts +1 -0
- package/package.json +4 -3
- package/src/DayPicker.test.tsx +13 -0
- package/src/DayPicker.tsx +4 -8
- package/src/classes/CalendarDay.ts +1 -1
- package/src/components/WeekNumber.tsx +3 -3
- package/src/formatters/formatCaption.ts +5 -2
- package/src/formatters/formatDay.ts +1 -2
- package/src/formatters/formatWeekdayName.ts +1 -2
- package/src/helpers/getDateLib.ts +2 -2
- package/src/helpers/getDates.ts +2 -3
- package/src/helpers/getDisplayMonths.ts +2 -1
- package/src/helpers/getFocusableDate.ts +1 -1
- package/src/helpers/getInitialMonth.ts +5 -1
- package/src/helpers/getMonthOptions.ts +8 -5
- package/src/helpers/getMonths.ts +2 -1
- package/src/helpers/getNavMonth.ts +14 -5
- package/src/helpers/getNextFocus.tsx +1 -1
- package/src/helpers/getNextMonth.ts +2 -1
- package/src/helpers/getPreviousMonth.ts +2 -1
- package/src/helpers/getWeekdays.ts +6 -3
- package/src/helpers/getYearOptions.ts +8 -7
- package/src/labels/labelGrid.ts +1 -2
- package/src/labels/labelWeekday.ts +1 -2
- package/src/lib/dateLib.ts +95 -3
- package/src/selection/useMulti.tsx +1 -1
- package/src/selection/useRange.tsx +1 -1
- package/src/selection/useSingle.tsx +1 -1
- package/src/types/props.ts +15 -6
- package/src/types/selection.ts +12 -9
- package/src/types/shared.ts +17 -9
- package/src/useCalendar.ts +1 -1
- package/src/useDayPicker.ts +30 -6
- package/src/useFocus.ts +1 -1
- package/src/useGetModifiers.tsx +8 -2
- package/src/useSelection.ts +2 -1
- package/src/utils/addToRange.ts +2 -2
- package/src/utils/dateMatchModifiers.ts +2 -2
- package/src/utils/rangeIncludesDate.ts +2 -2
- package/src/utils/typeguards.ts +1 -1
- package/website/docs/development/code-of-conduct.md +5 -7
- package/website/docs/development/contributing.md +9 -0
- package/website/docs/docs/localization.mdx +23 -29
- package/website/docs/docs/selection-modes.mdx +21 -21
- package/website/docs/guides/custom-components.mdx +10 -10
- package/website/docs/development/contributing.mdx +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DeprecatedUI } from "../UI.js";
|
|
3
|
-
import type { Locale } from "../lib/dateLib.js";
|
|
4
|
-
import type { ClassNames, ModifiersClassNames, Styles, ModifiersStyles, CustomComponents, Matcher, Labels, Formatters, MonthChangeEventHandler, DayEventHandler, Modifiers, DateRange, Mode
|
|
3
|
+
import type { Locale, DateLib } from "../lib/dateLib.js";
|
|
4
|
+
import type { ClassNames, ModifiersClassNames, Styles, ModifiersStyles, CustomComponents, Matcher, Labels, Formatters, MonthChangeEventHandler, DayEventHandler, Modifiers, DateRange, Mode } from "./shared.js";
|
|
5
5
|
/**
|
|
6
6
|
* The props for the `<DayPicker />` component.
|
|
7
7
|
*
|
|
@@ -325,8 +325,8 @@ export interface PropsBase {
|
|
|
325
325
|
/** Add the language tag to the container element. */
|
|
326
326
|
lang?: HTMLDivElement["lang"];
|
|
327
327
|
/**
|
|
328
|
-
* The locale object used to localize dates. Pass a locale from
|
|
329
|
-
* localize the calendar.
|
|
328
|
+
* The locale object used to localize dates. Pass a locale from
|
|
329
|
+
* `react-day-picker/locale` to localize the calendar.
|
|
330
330
|
*
|
|
331
331
|
* @example
|
|
332
332
|
* import { es } from "react-day-picker/locale";
|
|
@@ -334,6 +334,7 @@ export interface PropsBase {
|
|
|
334
334
|
*
|
|
335
335
|
* @defaultValue enUS - The English locale default of `date-fns`.
|
|
336
336
|
* @see https://daypicker.dev/docs/localization
|
|
337
|
+
* @see https://github.com/date-fns/date-fns/tree/main/src/locale for a list of the supported locales
|
|
337
338
|
*/
|
|
338
339
|
locale?: Partial<Locale> | undefined;
|
|
339
340
|
/**
|
|
@@ -450,7 +451,16 @@ export interface PropsBase {
|
|
|
450
451
|
*/
|
|
451
452
|
onDayTouchStart?: DayEventHandler<React.TouchEvent>;
|
|
452
453
|
}
|
|
453
|
-
/**
|
|
454
|
+
/**
|
|
455
|
+
* Shared handler type for `onSelect` callback when a selection mode is set.
|
|
456
|
+
*
|
|
457
|
+
* @template T - The type of the selected item.
|
|
458
|
+
* @callback OnSelectHandler
|
|
459
|
+
* @param {T} selected - The selected item after the event.
|
|
460
|
+
* @param {Date} triggerDate - The date when the event was triggered.
|
|
461
|
+
* @param {Modifiers} modifiers - The modifiers associated with the event.
|
|
462
|
+
* @param {React.MouseEvent | React.KeyboardEvent} e - The event object.
|
|
463
|
+
*/
|
|
454
464
|
export type OnSelectHandler<T> = (selected: T, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
455
465
|
/**
|
|
456
466
|
* The props when the single selection is required.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DayPickerProps } from "./props.js";
|
|
2
|
-
import type { DateRange, Modifiers } from "./shared.js";
|
|
2
|
+
import type { DateRange, Mode, Modifiers } from "./shared.js";
|
|
3
3
|
export type Selection<T extends DayPickerProps> = {
|
|
4
4
|
/** The selected date(s). */
|
|
5
5
|
selected: SelectedValue<T> | undefined;
|
|
@@ -27,10 +27,19 @@ export type SelectedValue<T> = T extends {
|
|
|
27
27
|
mode: "range";
|
|
28
28
|
required?: boolean;
|
|
29
29
|
} ? SelectedRange<T> : undefined;
|
|
30
|
-
export type SelectHandlerSingle<T extends
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type
|
|
30
|
+
export type SelectHandlerSingle<T extends {
|
|
31
|
+
required?: boolean | undefined;
|
|
32
|
+
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date : Date | undefined;
|
|
33
|
+
export type SelectHandlerMulti<T extends {
|
|
34
|
+
required?: boolean | undefined;
|
|
35
|
+
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? Date[] : Date[] | undefined;
|
|
36
|
+
export type SelectHandlerRange<T extends {
|
|
37
|
+
required?: boolean | undefined;
|
|
38
|
+
}> = (triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => T["required"] extends true ? DateRange : DateRange | undefined;
|
|
39
|
+
export type SelectHandler<T extends {
|
|
40
|
+
mode?: Mode | undefined;
|
|
41
|
+
required?: boolean | undefined;
|
|
42
|
+
}> = T extends {
|
|
34
43
|
mode: "single";
|
|
35
44
|
} ? SelectHandlerSingle<T> : T extends {
|
|
36
45
|
mode: "multiple";
|
|
@@ -3,7 +3,6 @@ import { UI, DayFlag, SelectionState } from "../UI.js";
|
|
|
3
3
|
import * as components from "../components/custom-components.js";
|
|
4
4
|
import { formatCaption, formatDay, formatMonthCaption, formatMonthDropdown, formatWeekdayName, formatWeekNumber, formatWeekNumberHeader, formatYearCaption, formatYearDropdown } from "../formatters/index.js";
|
|
5
5
|
import { labelDayButton, labelNav, labelGrid, labelGridcell, labelMonthDropdown, labelNext, labelPrevious, labelWeekday, labelWeekNumber, labelWeekNumberHeader, labelYearDropdown } from "../labels/index.js";
|
|
6
|
-
import { dateLib } from "../lib/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* Selection modes supported by DayPicker.
|
|
9
8
|
*
|
|
@@ -78,8 +77,6 @@ export type CustomComponents = {
|
|
|
78
77
|
/** Render the dropdown with the years. */
|
|
79
78
|
YearsDropdown: typeof components.YearsDropdown;
|
|
80
79
|
};
|
|
81
|
-
/** @private */
|
|
82
|
-
export type DateLib = typeof dateLib;
|
|
83
80
|
/** Represent a map of formatters used to render localized content. */
|
|
84
81
|
export type Formatters = {
|
|
85
82
|
/** Format the caption of a month grid. */
|
|
@@ -283,15 +280,27 @@ export type Styles = {
|
|
|
283
280
|
[key in UI | SelectionState | DayFlag]: CSSProperties | undefined;
|
|
284
281
|
};
|
|
285
282
|
/**
|
|
286
|
-
*
|
|
283
|
+
* Represents the modifiers that match a specific day in the calendar.
|
|
284
|
+
*
|
|
285
|
+
* - Retrieve modifiers using the {@link OnSelectHandler} via the `onSelect` prop,
|
|
286
|
+
* or within custom components using the {@link useDayPicker} hook.
|
|
287
|
+
* - Includes built-in modifiers from {@link DayFlag} and {@link SelectionState}.
|
|
288
|
+
* - Add custom modifiers using the `modifiers` prop.
|
|
287
289
|
*
|
|
288
290
|
* @example
|
|
289
291
|
* const modifiers: Modifiers = {
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
292
|
+
* today: false, // the day is not today
|
|
293
|
+
* selected: true, // the day is selected
|
|
294
|
+
* disabled: false, // the day is not disabled
|
|
295
|
+
* outside: false, // the day is not outside the month
|
|
296
|
+
* focused: false, // the day is not focused
|
|
297
|
+
*
|
|
298
|
+
* weekend: false // custom modifier example for matching a weekend
|
|
299
|
+
* booked: true // custom modifier example for matching a booked day
|
|
300
|
+
* available: false // custom modifier example for matching an available day
|
|
294
301
|
* };
|
|
302
|
+
*
|
|
303
|
+
* @see https://daypicker.dev/guides/custom-modifiers
|
|
295
304
|
*/
|
|
296
305
|
export type Modifiers = Record<string, boolean>;
|
|
297
306
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CalendarWeek, CalendarDay, CalendarMonth } from "./classes/index.js";
|
|
2
|
+
import type { DateLib } from "./lib/index.js";
|
|
2
3
|
import type { DayPickerProps } from "./types/props.js";
|
|
3
|
-
import type { DateLib } from "./types/shared.js";
|
|
4
4
|
/**
|
|
5
5
|
* Return the calendar object to work with the calendar in custom components.
|
|
6
6
|
*
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { CalendarDay } from "./classes/CalendarDay.js";
|
|
2
2
|
import { CalendarMonth } from "./classes/CalendarMonth.js";
|
|
3
|
-
import type { DayPickerProps } from "./types/props.js";
|
|
4
3
|
import type { SelectedValue, SelectHandler } from "./types/selection.js";
|
|
5
|
-
import { ClassNames, CustomComponents, Formatters, Labels, Modifiers, Styles } from "./types/shared.js";
|
|
4
|
+
import { ClassNames, CustomComponents, Formatters, Labels, Mode, Modifiers, Styles } from "./types/shared.js";
|
|
6
5
|
/** @private */
|
|
7
|
-
export declare const dayPickerContext: import("react").Context<DayPickerContext<
|
|
8
|
-
|
|
6
|
+
export declare const dayPickerContext: import("react").Context<DayPickerContext<{
|
|
7
|
+
mode?: Mode | undefined;
|
|
8
|
+
required?: boolean | undefined;
|
|
9
|
+
}> | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Represents the context for the DayPicker component, providing various
|
|
12
|
+
* properties and methods to interact with the calendar.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type of the DayPicker props, which must optionally include
|
|
15
|
+
* `mode` and `required` properties. This type can be used to refine the type
|
|
16
|
+
* returned by the hook.
|
|
17
|
+
*/
|
|
18
|
+
export type DayPickerContext<T extends {
|
|
19
|
+
mode?: Mode | undefined;
|
|
20
|
+
required?: boolean | undefined;
|
|
21
|
+
}> = {
|
|
9
22
|
/** The months displayed in the calendar. */
|
|
10
23
|
months: CalendarMonth[];
|
|
11
24
|
/** The next month to display. */
|
|
@@ -34,9 +47,20 @@ export type DayPickerContext<T extends DayPickerProps> = {
|
|
|
34
47
|
formatters: Formatters;
|
|
35
48
|
};
|
|
36
49
|
/**
|
|
37
|
-
*
|
|
50
|
+
* Returns the context to work with `<DayPicker />` inside custom components.
|
|
51
|
+
*
|
|
52
|
+
* This hook provides access to the DayPicker context, which includes various
|
|
53
|
+
* properties and methods to interact with the DayPicker component. It must be
|
|
54
|
+
* used within a custom component.
|
|
38
55
|
*
|
|
56
|
+
* @template T - Use this type to refine the returned context type with a
|
|
57
|
+
* specific selection mode.
|
|
58
|
+
* @returns {DayPickerContext<T>} The context to work with DayPicker.
|
|
59
|
+
* @throws {Error} If the hook is used outside of a DayPicker provider.
|
|
39
60
|
* @group Hooks
|
|
40
61
|
* @see https://daypicker.dev/guides/custom-components
|
|
41
62
|
*/
|
|
42
|
-
export declare function useDayPicker<T extends
|
|
63
|
+
export declare function useDayPicker<T extends {
|
|
64
|
+
mode?: Mode | undefined;
|
|
65
|
+
required?: boolean | undefined;
|
|
66
|
+
}>(): DayPickerContext<T>;
|
package/dist/esm/useDayPicker.js
CHANGED
|
@@ -2,12 +2,20 @@ import { createContext, useContext } from "react";
|
|
|
2
2
|
/** @private */
|
|
3
3
|
export const dayPickerContext = createContext(undefined);
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Returns the context to work with `<DayPicker />` inside custom components.
|
|
6
6
|
*
|
|
7
|
+
* This hook provides access to the DayPicker context, which includes various
|
|
8
|
+
* properties and methods to interact with the DayPicker component. It must be
|
|
9
|
+
* used within a custom component.
|
|
10
|
+
*
|
|
11
|
+
* @template T - Use this type to refine the returned context type with a
|
|
12
|
+
* specific selection mode.
|
|
13
|
+
* @returns {DayPickerContext<T>} The context to work with DayPicker.
|
|
14
|
+
* @throws {Error} If the hook is used outside of a DayPicker provider.
|
|
7
15
|
* @group Hooks
|
|
8
16
|
* @see https://daypicker.dev/guides/custom-components
|
|
9
17
|
*/
|
|
10
|
-
export function useDayPicker(
|
|
18
|
+
export function useDayPicker() {
|
|
11
19
|
const context = useContext(dayPickerContext);
|
|
12
20
|
if (context === undefined) {
|
|
13
21
|
throw new Error("useDayPicker() must be used within a custom component.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDayPicker.js","sourceRoot":"","sources":["../../src/useDayPicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAelD,eAAe;AACf,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"useDayPicker.js","sourceRoot":"","sources":["../../src/useDayPicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAelD,eAAe;AACf,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAM3C,SAAS,CAAC,CAAC;AAyCb;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY;IAG1B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/esm/useFocus.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CalendarDay } from "./classes/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DateLib } from "./lib/index.js";
|
|
3
|
+
import type { MoveFocusBy, MoveFocusDir, DayPickerProps, Modifiers } from "./types/index.js";
|
|
3
4
|
import { Calendar } from "./useCalendar.js";
|
|
4
5
|
export type UseFocus = {
|
|
5
6
|
/** The date that is currently focused. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CalendarDay } from "./classes/index.js";
|
|
2
|
-
import type { DateLib
|
|
2
|
+
import type { DateLib } from "./lib/index.js";
|
|
3
|
+
import type { DayPickerProps, Modifiers } from "./types/index.js";
|
|
3
4
|
/**
|
|
4
5
|
* Return a function to get the modifiers for a given day.
|
|
5
6
|
*
|
|
@@ -29,7 +29,12 @@ export function useGetModifiers(days, props, dateLib) {
|
|
|
29
29
|
const isDisabled = Boolean(disabled && dateMatchModifiers(date, disabled, dateLib));
|
|
30
30
|
const isHidden = Boolean(hidden && dateMatchModifiers(date, hidden, dateLib)) ||
|
|
31
31
|
(!showOutsideDays && isOutside);
|
|
32
|
-
const isToday = isSameDay(date, today ??
|
|
32
|
+
const isToday = isSameDay(date, today ??
|
|
33
|
+
(props.timeZone
|
|
34
|
+
? TZDate.tz(props.timeZone)
|
|
35
|
+
: dateLib.Date
|
|
36
|
+
? new dateLib.Date()
|
|
37
|
+
: new Date()));
|
|
33
38
|
if (isOutside)
|
|
34
39
|
internalModifiersMap.outside.push(day);
|
|
35
40
|
if (isDisabled)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetModifiers.js","sourceRoot":"","sources":["../../src/useGetModifiers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useGetModifiers.js","sourceRoot":"","sources":["../../src/useGetModifiers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAmB,EACnB,KAAqB,EACrB,OAAgB;IAEhB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEtE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAE3C,MAAM,oBAAoB,GAAmC;QAC3D,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE;QACrB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE;QACrB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE;QACtB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE;QACpB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE;KACpB,CAAC;IAEF,MAAM,kBAAkB,GAAkC,EAAE,CAAC;IAE7D,MAAM,qBAAqB,GAA0C;QACnE,CAAC,cAAc,CAA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K;SACjC,CAAC;QACF,MAAM,eAAe,GAAc,EAAE,CAAC;QAEtC,uCAAuC;QACvC,KAAK,MAAM,IAAI,IAAI,oBAAoB,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,oBAAoB,CAAC,IAAe,CAAC,CAAC;YACnD,QAAQ,CAAC,IAAe,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAC1D,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,qBAAqB,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,qBAAqB,CAAC,IAAsB,CAAC,CAAC;YAC3D,eAAe,CAAC,IAAsB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QACxE,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE,CAAC;YACtC,eAAe,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO;YACL,GAAG,eAAe;YAClB,GAAG,QAAQ;YACX,yDAAyD;YACzD,GAAG,eAAe;SACN,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DateLib } from "./lib/index.js";
|
|
2
|
+
import type { DayPickerProps } from "./types/index.js";
|
|
2
3
|
import { Selection } from "./types/selection.js";
|
|
3
4
|
export declare function useSelection<T extends DayPickerProps>(props: T, dateLib: DateLib): Selection<T> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelection.js","sourceRoot":"","sources":["../../src/useSelection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSelection.js","sourceRoot":"","sources":["../../src/useSelection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAIrD,MAAM,UAAU,YAAY,CAC1B,KAAQ,EACR,OAAgB;IAEhB,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAEvC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC;QAChB,KAAK,UAAU;YACb,OAAO,KAAK,CAAC;QACf,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addToRange.js","sourceRoot":"","sources":["../../../src/utils/addToRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"addToRange.js","sourceRoot":"","sources":["../../../src/utils/addToRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAG1E;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU;AACxB,oCAAoC;AACpC,IAAU;AACV,qCAAqC;AACrC,YAAmC,EACnC,GAAG,GAAG,CAAC,EACP,GAAG,GAAG,CAAC,EACP,QAAQ,GAAG,KAAK;AAChB,cAAc;AACd,UAAmB,cAAc;IAEjC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,YAAY,IAAI,EAAE,CAAC;IACxC,MAAM,EA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IAAI,GAAG,GAAG,EAAE,CAAC;YAC1B,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;QACxC,CAAC;aAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,GAAG,EAAE,CAAC;YACjC,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateMatchModifiers.js","sourceRoot":"","sources":["../../../src/utils/dateMatchModifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"dateMatchModifiers.js","sourceRoot":"","sources":["../../../src/utils/dateMatchModifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAgB,MAAM,mBAAmB,CAAC;AAG5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAU,EACV,QAA6B,EAC7B,UAAmB,cAAc;IAEjC,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrE,MAAM,EAAE,SAAS,EAAE,wBAAwB,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACjE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,OAAgB,EAAE,EAAE;QAC3C,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE,CAAC;YACjC,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WAAW,IAAI,UAAU,CAAC;YACnC,CAAC;QACH,CAAC;QACD,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,OAAO,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,wBAAwB,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rangeIncludesDate.js","sourceRoot":"","sources":["../../../src/utils/rangeIncludesDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"rangeIncludesDate.js","sourceRoot":"","sources":["../../../src/utils/rangeIncludesDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAG1E;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAgB,EAChB,IAAU;AACV,qDAAqD;AACrD,WAAW,GAAG,KAAK;AACnB,cAAc;AACd,UAAmB,cAAc;IAEjC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IACzB,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACxD,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;QACf,MAAM,eAAe,GAAG,wBAAwB,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,IAAI,eAAe,EAAE,CAAC;YACpB,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1B,CAAC;QACD,MAAM,SAAS,GACb,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,wBAAwB,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAE,IAAU,EAAE,EAAE,CAC5D,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DateLib } from "../lib/index.js";
|
|
2
|
+
import type { DateAfter, DateBefore, DateInterval, DateRange, DayOfWeek } from "../types/index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Returns true if `matcher` is of type {@link DateInterval}.
|
|
4
5
|
*
|
package/examples/Input.test.tsx
CHANGED
|
@@ -18,6 +18,6 @@ afterAll(() => jest.useRealTimers());
|
|
|
18
18
|
test.each(days)("the day %s should be hidden", (day) => {
|
|
19
19
|
render(<ModifiersHidden />);
|
|
20
20
|
expect(
|
|
21
|
-
screen.queryByRole("
|
|
21
|
+
screen.queryByRole("cell", { name: `${day.getDate()}` })
|
|
22
22
|
).not.toBeInTheDocument();
|
|
23
23
|
});
|
package/examples/Range.test.tsx
CHANGED
|
@@ -61,7 +61,7 @@ describe("when a day in the range is clicked", () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
function getAllSelected() {
|
|
64
|
-
const gridcells = screen.getAllByRole("
|
|
64
|
+
const gridcells = screen.getAllByRole("cell");
|
|
65
65
|
|
|
66
66
|
return Array.from(gridcells).filter(
|
|
67
67
|
(gridcell) => gridcell.getAttribute("aria-selected") === "true"
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "react-day-picker";
|
|
10
10
|
|
|
11
11
|
function DayWithShiftKey(props: DayButtonProps) {
|
|
12
|
-
const { selected } = useDayPicker
|
|
12
|
+
const { selected } = useDayPicker<{ mode: "range" }>();
|
|
13
13
|
|
|
14
14
|
const handleClick: MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
15
15
|
const requireShiftKey =
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* This test uses mockdate to ensure date mocking works as it should. */
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
|
+
import MockDate from "mockdate";
|
|
6
|
+
|
|
7
|
+
import { dateButton, gridcell } from "@/test/elements";
|
|
8
|
+
import { user } from "@/test/user";
|
|
9
|
+
|
|
10
|
+
import { Single } from "./Single";
|
|
11
|
+
|
|
12
|
+
const today = new Date(2021, 10, 25);
|
|
13
|
+
|
|
14
|
+
beforeAll(() => MockDate.set(today));
|
|
15
|
+
afterAll(() => MockDate.reset());
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
render(<Single />);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("when a day is clicked", () => {
|
|
22
|
+
const day = new Date(2021, 10, 1);
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
await user.click(dateButton(day));
|
|
25
|
+
});
|
|
26
|
+
test("should appear as selected", () => {
|
|
27
|
+
expect(gridcell(day, true)).toHaveAttribute("aria-selected", "true");
|
|
28
|
+
expect(dateButton(day)).toHaveFocus();
|
|
29
|
+
expect(gridcell(day, true)).toHaveClass("rdp-selected");
|
|
30
|
+
});
|
|
31
|
+
describe("when the day is clicked again", () => {
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
await user.click(dateButton(day));
|
|
34
|
+
});
|
|
35
|
+
test("should not appear as selected", () => {
|
|
36
|
+
expect(gridcell(day, true)).not.toHaveAttribute("aria-selected");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -9,7 +9,7 @@ const today = new Date(2021, 10, 25);
|
|
|
9
9
|
beforeAll(() => jest.setSystemTime(today));
|
|
10
10
|
afterAll(() => jest.useRealTimers());
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function getWeek(week: number) {
|
|
13
13
|
return screen.getByRole("rowheader", {
|
|
14
14
|
name: `Week ${week}`
|
|
15
15
|
});
|
|
@@ -19,6 +19,6 @@ beforeEach(() => render(<Weeknumber />).container);
|
|
|
19
19
|
|
|
20
20
|
describe("when displaying November 2021", () => {
|
|
21
21
|
test("should display the 45th week number", () => {
|
|
22
|
-
expect(
|
|
22
|
+
expect(getWeek(45)).toBeInTheDocument();
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -13,9 +13,9 @@ export function WeeknumberCustom() {
|
|
|
13
13
|
defaultMonth={addMonths(today, -1)}
|
|
14
14
|
components={{
|
|
15
15
|
WeekNumber: ({ week, ...props }: WeekNumberProps) => (
|
|
16
|
-
<
|
|
16
|
+
<th {...props}>
|
|
17
17
|
<button onClick={() => console.log(week)}>{props.children}</button>
|
|
18
|
-
</
|
|
18
|
+
</th>
|
|
19
19
|
)
|
|
20
20
|
}}
|
|
21
21
|
labels={{
|