react-day-picker 9.0.0 → 9.0.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/dist/esm/UI.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CSSProperties } from "react";
1
2
  /**
2
3
  * The UI elements composing DayPicker. These elements are mapped to
3
4
  * {@link CustomComponents}, the {@link ClassNames} and the {@link Styles} used by
@@ -45,15 +46,15 @@ export declare enum UI {
45
46
  Nav = "nav",
46
47
  /** The row containing the week. */
47
48
  Week = "week",
48
- /** The group of row weeks in a month. */
49
+ /** The group of row weeks in a month (`tbody`). */
49
50
  Weeks = "weeks",
50
51
  /** The column header with the weekday. */
51
52
  Weekday = "weekday",
52
53
  /** The row grouping the weekdays in the column headers. */
53
54
  Weekdays = "weekdays",
54
- /** The row header containing the week number. */
55
+ /** The cell containing the week number. */
55
56
  WeekNumber = "week_number",
56
- /** The row header containing the week number. */
57
+ /** The cell header of the week numbers column. */
57
58
  WeekNumberHeader = "week_number_header",
58
59
  /** The dropdown with the years. */
59
60
  YearsDropdown = "years_dropdown"
@@ -85,3 +86,242 @@ export declare enum SelectionState {
85
86
  /** The day is selected. */
86
87
  selected = "selected"
87
88
  }
89
+ /**
90
+ * Deprecated UI elements and flags.
91
+ *
92
+ * These elements were used in previous version of DayPicker and are kept here
93
+ * to help the transition to the new {@link UI | UI elements}.
94
+ *
95
+ * ```diff
96
+ * <DayPicker classNames={{
97
+ * - cell: "my-cell",
98
+ * + day: "my-cell",
99
+ * - day: "my-day",
100
+ * + day_button: "my-day",
101
+ * - day_disabled: "my-day_disabled",
102
+ * + disabled: "my-day_disabled",
103
+ * // etc.
104
+ * }}/>
105
+ * ```
106
+ *
107
+ * @deprecated
108
+ * @since 9.0.1
109
+ * @see https://daypicker.dev/upgrading
110
+ * @see https://daypicker.dev/docs/styling
111
+ */
112
+ export type DeprecatedUI<T extends CSSProperties | string> = {
113
+ /**
114
+ * This element was applied to the style of any button in DayPicker and it is
115
+ * replaced by {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
116
+ *
117
+ * @deprecated
118
+ */
119
+ button: T;
120
+ /**
121
+ * This element was resetting the style of any button in DayPicker and it is
122
+ * replaced by {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
123
+ *
124
+ * @deprecated
125
+ */
126
+ button_reset: T;
127
+ /**
128
+ * This element has been renamed to {@link UI.MonthCaption}.
129
+ *
130
+ * @deprecated
131
+ */
132
+ caption: T;
133
+ /**
134
+ * This element has been removed. Captions are styled via
135
+ * {@link UI.MonthCaption}.
136
+ *
137
+ * @deprecated
138
+ */
139
+ caption_between: T;
140
+ /**
141
+ * This element has been renamed to {@link UI.Dropdowns}.
142
+ *
143
+ * @deprecated
144
+ */
145
+ caption_dropdowns: T;
146
+ /**
147
+ * This element has been removed. Captions are styled via
148
+ * {@link UI.MonthCaption}.
149
+ *
150
+ * @deprecated
151
+ */
152
+ caption_end: T;
153
+ /**
154
+ * This element has been removed.
155
+ *
156
+ * @deprecated
157
+ */
158
+ caption_start: T;
159
+ /**
160
+ * This element has been renamed to {@link UI.Day}.
161
+ *
162
+ * @deprecated
163
+ */
164
+ cell: T;
165
+ /**
166
+ * This element has been renamed to {@link DayFlag.disabled}.
167
+ *
168
+ * @deprecated
169
+ */
170
+ day_disabled: T;
171
+ /**
172
+ * This element has been renamed to {@link DayFlag.hidden}.
173
+ *
174
+ * @deprecated
175
+ */
176
+ day_hidden: T;
177
+ /**
178
+ * This element has been renamed to {@link DayFlag.outside}.
179
+ *
180
+ * @deprecated
181
+ */
182
+ day_outside: T;
183
+ /**
184
+ * This element has been renamed to {@link SelectionState.range_end}.
185
+ *
186
+ * @deprecated
187
+ */
188
+ day_range_end: T;
189
+ /**
190
+ * This element has been renamed to {@link SelectionState.range_middle}.
191
+ *
192
+ * @deprecated
193
+ */
194
+ day_range_middle: T;
195
+ /**
196
+ * This element has been renamed to {@link SelectionState.range_start}.
197
+ *
198
+ * @deprecated
199
+ */
200
+ day_range_start: T;
201
+ /**
202
+ * This element has been renamed to {@link SelectionState.selected}.
203
+ *
204
+ * @deprecated
205
+ */
206
+ day_selected: T;
207
+ /**
208
+ * This element has been renamed to {@link DayFlag.today}.
209
+ *
210
+ * @deprecated
211
+ */
212
+ day_today: T;
213
+ /**
214
+ * This element has been removed. The dropdown icon is now {@link UI.Chevron}
215
+ * inside a {@link UI.CaptionLabel}.
216
+ *
217
+ * @deprecated
218
+ */
219
+ dropdown_icon: T;
220
+ /**
221
+ * This element has been renamed to {@link UI.MonthsDropdown}.
222
+ *
223
+ * @deprecated
224
+ */
225
+ dropdown_month: T;
226
+ /**
227
+ * This element has been renamed to {@link UI.YearsDropdown}.
228
+ *
229
+ * @deprecated
230
+ */
231
+ dropdown_year: T;
232
+ /**
233
+ * This element has been removed.
234
+ *
235
+ * @deprecated
236
+ */
237
+ head: T;
238
+ /**
239
+ * This element has been renamed to {@link UI.Weekday}.
240
+ *
241
+ * @deprecated
242
+ */
243
+ head_cell: T;
244
+ /**
245
+ * This element has been renamed to {@link UI.Weekdays}.
246
+ *
247
+ * @deprecated
248
+ */
249
+ head_row: T;
250
+ /**
251
+ * This flag has been removed. Use `data-multiple-months` in your CSS
252
+ * selectors.
253
+ *
254
+ * @deprecated
255
+ */
256
+ multiple_months: T;
257
+ /**
258
+ * This element has been removed. To style the navigation buttons, use
259
+ * {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
260
+ *
261
+ * @deprecated
262
+ */
263
+ nav_button: T;
264
+ /**
265
+ * This element has been renamed to {@link UI.ButtonNext}.
266
+ *
267
+ * @deprecated
268
+ */
269
+ nav_button_next: T;
270
+ /**
271
+ * This element has been renamed to {@link UI.ButtonPrevious}.
272
+ *
273
+ * @deprecated
274
+ */
275
+ nav_button_previous: T;
276
+ /**
277
+ * This element has been removed. The dropdown icon is now {@link UI.Chevron}
278
+ * inside a {@link UI.ButtonNext} or a {@link UI.ButtonPrevious}.
279
+ *
280
+ * @deprecated
281
+ */
282
+ nav_icon: T;
283
+ /**
284
+ * This element has been renamed to {@link UI.Week}.
285
+ *
286
+ * @deprecated
287
+ */
288
+ row: T;
289
+ /**
290
+ * This element has been renamed to {@link UI.MonthGrid}.
291
+ *
292
+ * @deprecated
293
+ */
294
+ table: T;
295
+ /**
296
+ * This element has been renamed to {@link UI.Weeks}.
297
+ *
298
+ * @deprecated
299
+ */
300
+ tbody: T;
301
+ /**
302
+ * This element has been removed. The {@link UI.Footer} is now a single element
303
+ * below the months.
304
+ *
305
+ * @deprecated
306
+ */
307
+ tfoot: T;
308
+ /**
309
+ * This flag has been removed. There are no "visually hidden" elements in
310
+ * DayPicker 9.
311
+ *
312
+ * @deprecated
313
+ */
314
+ vhidden: T;
315
+ /**
316
+ * This element has been renamed. Use {@link UI.WeekNumber} instead.
317
+ *
318
+ * @deprecated
319
+ */
320
+ weeknumber: T;
321
+ /**
322
+ * This flag has been removed. Use `data-week-numbers` in your CSS.
323
+ *
324
+ * @deprecated
325
+ */
326
+ with_weeknumber: T;
327
+ };
package/dist/esm/UI.js CHANGED
@@ -46,15 +46,15 @@ export var UI;
46
46
  UI["Nav"] = "nav";
47
47
  /** The row containing the week. */
48
48
  UI["Week"] = "week";
49
- /** The group of row weeks in a month. */
49
+ /** The group of row weeks in a month (`tbody`). */
50
50
  UI["Weeks"] = "weeks";
51
51
  /** The column header with the weekday. */
52
52
  UI["Weekday"] = "weekday";
53
53
  /** The row grouping the weekdays in the column headers. */
54
54
  UI["Weekdays"] = "weekdays";
55
- /** The row header containing the week number. */
55
+ /** The cell containing the week number. */
56
56
  UI["WeekNumber"] = "week_number";
57
- /** The row header containing the week number. */
57
+ /** The cell header of the week numbers column. */
58
58
  UI["WeekNumberHeader"] = "week_number_header";
59
59
  /** The dropdown with the years. */
60
60
  UI["YearsDropdown"] = "years_dropdown";
@@ -1 +1 @@
1
- {"version":3,"file":"UI.js","sourceRoot":"","sources":["../../src/UI.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,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ED,wCAAwC;AACxC,MAAM,CAAN,IAAY,OAWX;AAXD,WAAY,OAAO;IACjB,2BAA2B;IAC3B,gCAAqB,CAAA;IACrB,yBAAyB;IACzB,4BAAiB,CAAA;IACjB,4CAA4C;IAC5C,8BAAmB,CAAA;IACnB,0BAA0B;IAC1B,8BAAmB,CAAA;IACnB,wBAAwB;IACxB,0BAAe,CAAA;AACjB,CAAC,EAXW,OAAO,KAAP,OAAO,QAWlB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB,iDAAiD;IACjD,yCAAuB,CAAA;IACvB,oDAAoD;IACpD,+CAA6B,CAAA;IAC7B,mDAAmD;IACnD,6CAA2B,CAAA;IAC3B,2BAA2B;IAC3B,uCAAqB,CAAA;AACvB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB"}
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { addToRange, dateMatchModifiers } from "../utils/index.js";
3
3
  import { rangeIncludesDate } from "../utils/rangeIncludesDate.js";
4
4
  export function useRange(props, dateLib) {
5
- const { mode, disabled, selected: initiallySelected, required, onSelect } = props;
5
+ const { mode, disabled, excludeDisabled, selected: initiallySelected, required, onSelect } = props;
6
6
  const { differenceInCalendarDays } = dateLib;
7
7
  const [selected, setSelected] = React.useState(initiallySelected);
8
8
  // Update the selected date if the required flag is set.
@@ -37,7 +37,9 @@ export function useRange(props, dateLib) {
37
37
  let newDate = newRange.from;
38
38
  while (dateLib.differenceInCalendarDays(newRange.to, newDate) > 0) {
39
39
  newDate = dateLib.addDays(newDate, 1);
40
- if (disabled && dateMatchModifiers(newDate, disabled, dateLib)) {
40
+ if (excludeDisabled &&
41
+ disabled &&
42
+ dateMatchModifiers(newDate, disabled, dateLib)) {
41
43
  newRange.from = triggerDate;
42
44
  newRange.to = undefined;
43
45
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"useRange.js","sourceRoot":"","sources":["../../../src/selection/useRange.tsx"],"names":[],"mappings":"AAAA,OAAO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AAQ,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,MAAM;QACN,UAAU;KACK,CAAC;AACpB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import type { DeprecatedUI } from "../UI.js";
2
3
  import type { Locale } from "../lib/dateLib.js";
3
4
  import type { ClassNames, ModifiersClassNames, Styles, ModifiersStyles, CustomComponents, Matcher, Labels, Formatters, MonthChangeEventHandler, DayEventHandler, Modifiers, DateRange, Mode, DateLib } from "./shared.js";
4
5
  /**
@@ -37,7 +38,7 @@ export interface PropsBase {
37
38
  *
38
39
  * @see https://daypicker.dev/docs/styling
39
40
  */
40
- classNames?: Partial<ClassNames>;
41
+ classNames?: Partial<ClassNames> & Partial<DeprecatedUI<string>>;
41
42
  /**
42
43
  * Change the class name for the day matching the `modifiers`.
43
44
  *
@@ -51,7 +52,7 @@ export interface PropsBase {
51
52
  *
52
53
  * @see https://daypicker.dev/docs/styling
53
54
  */
54
- styles?: Partial<Styles>;
55
+ styles?: Partial<Styles> & Partial<DeprecatedUI<React.CSSProperties>>;
55
56
  /**
56
57
  * Change the class name for the day matching the {@link modifiers}.
57
58
  *
@@ -430,7 +431,9 @@ export interface PropsBase {
430
431
  export interface PropsSingleRequired {
431
432
  mode: "single";
432
433
  required: true;
434
+ /** The selected date. */
433
435
  selected: Date;
436
+ /** Event handler when a day is selected. */
434
437
  onSelect?: (selected: Date, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void | undefined;
435
438
  }
436
439
  /**
@@ -441,7 +444,9 @@ export interface PropsSingleRequired {
441
444
  export interface PropsSingle {
442
445
  mode: "single";
443
446
  required?: false | undefined;
447
+ /** The selected date. */
444
448
  selected?: Date | undefined;
449
+ /** Event handler when a day is selected. */
445
450
  onSelect?: (selected: Date | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void;
446
451
  }
447
452
  /**
@@ -452,9 +457,13 @@ export interface PropsSingle {
452
457
  export interface PropsMultiRequired {
453
458
  mode: "multiple";
454
459
  required: true;
460
+ /** The selected dates. */
455
461
  selected: Date[];
462
+ /** Event handler when days are selected. */
456
463
  onSelect?: (selected: Date[], triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void;
464
+ /** The minimum number of selectable days. */
457
465
  min?: number;
466
+ /** The maximum number of selectable days. */
458
467
  max?: number;
459
468
  }
460
469
  /**
@@ -465,9 +474,13 @@ export interface PropsMultiRequired {
465
474
  export interface PropsMulti {
466
475
  mode: "multiple";
467
476
  required?: false | undefined;
477
+ /** The selected dates. */
468
478
  selected?: Date[] | undefined;
479
+ /** Event handler when days are selected. */
469
480
  onSelect?: (selected: Date[] | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void;
481
+ /** The minimum number of selectable days. */
470
482
  min?: number;
483
+ /** The maximum number of selectable days. */
471
484
  max?: number;
472
485
  }
473
486
  /**
@@ -478,9 +491,20 @@ export interface PropsMulti {
478
491
  export interface PropsRangeRequired {
479
492
  mode: "range";
480
493
  required: true;
494
+ disabled?: Matcher | Matcher[] | undefined;
495
+ /**
496
+ * When `true`, the range will reset when including a disabled day.
497
+ *
498
+ * @since V9.0.2
499
+ */
500
+ excludeDisabled?: boolean | undefined;
501
+ /** The selected range. */
481
502
  selected: DateRange;
503
+ /** Event handler when a range is selected. */
482
504
  onSelect?: (selected: DateRange, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void;
505
+ /** The minimum number of days to include in the range. */
483
506
  min?: number;
507
+ /** The maximum number of days to include in the range. */
484
508
  max?: number;
485
509
  }
486
510
  /**
@@ -491,9 +515,19 @@ export interface PropsRangeRequired {
491
515
  export interface PropsRange {
492
516
  mode: "range";
493
517
  required?: false | undefined;
494
- selected?: DateRange | undefined;
495
518
  disabled?: Matcher | Matcher[] | undefined;
519
+ /**
520
+ * When `true`, the range will reset when including a disabled day.
521
+ *
522
+ * @since V9.0.2
523
+ */
524
+ excludeDisabled?: boolean | undefined;
525
+ /** The selected range. */
526
+ selected?: DateRange | undefined;
527
+ /** Event handler when the selection changes. */
496
528
  onSelect?: (selected: DateRange | undefined, triggerDate: Date, modifiers: Modifiers, e: React.MouseEvent | React.KeyboardEvent) => void | undefined;
529
+ /** The minimum number of days to include in the range. */
497
530
  min?: number;
531
+ /** The maximum number of days to include in the range. */
498
532
  max?: number;
499
533
  }
@@ -5,13 +5,20 @@ import { render } from "@/test/render";
5
5
 
6
6
  import { ModifiersDisabled } from "./ModifiersDisabled";
7
7
 
8
+ const today = new Date(2024, 6, 22);
9
+
10
+ beforeAll(() => jest.setSystemTime(today));
11
+ afterAll(() => jest.useRealTimers());
12
+
8
13
  const days = [
9
- new Date(2024, 5, 2),
10
- new Date(2024, 5, 9),
11
- new Date(2024, 5, 29)
14
+ new Date(2024, 6, 6),
15
+ new Date(2024, 6, 13),
16
+ new Date(2024, 6, 20),
17
+ new Date(2024, 6, 27)
12
18
  ];
13
19
 
14
20
  test.each(days)("the day %s should be disabled", (day) => {
15
21
  render(<ModifiersDisabled />);
22
+ // return all month's
16
23
  expect(dateButton(day)).toBeDisabled();
17
24
  });
@@ -3,11 +3,5 @@ import React from "react";
3
3
  import { DayPicker } from "react-day-picker";
4
4
 
5
5
  export function ModifiersDisabled() {
6
- return (
7
- <DayPicker
8
- defaultMonth={new Date(2024, 5, 10)}
9
- mode="range"
10
- disabled={{ dayOfWeek: [0, 6] }}
11
- />
12
- );
6
+ return <DayPicker mode="range" disabled={{ dayOfWeek: [0, 6] }} />;
13
7
  }
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ import { DayPicker } from "react-day-picker";
4
+
5
+ export function RangeExcludeDisabled() {
6
+ return (
7
+ <DayPicker mode="range" disabled={{ dayOfWeek: [0, 6] }} excludeDisabled />
8
+ );
9
+ }
package/examples/index.ts CHANGED
@@ -43,6 +43,7 @@ export * from "./MultipleMonthsPaged";
43
43
  export * from "./NumberingSystem";
44
44
  export * from "./OutsideDays";
45
45
  export * from "./Range";
46
+ export * from "./RangeExcludeDisabled";
46
47
  export * from "./RangeMinMax";
47
48
  export * from "./RangeShiftKey";
48
49
  export * from "./Rtl";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-day-picker",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "Customizable Date Picker for React",
5
5
  "author": "Giampaolo Bellavite <io@gpbl.dev>",
6
6
  "homepage": "https://daypicker.dev",
@@ -135,7 +135,7 @@
135
135
  "devDependencies": {
136
136
  "@date-fns/utc": "^1.2.0",
137
137
  "@jest/types": "^29.6.3",
138
- "@testing-library/dom": "^10.3.1",
138
+ "@testing-library/dom": "^10.4.0",
139
139
  "@testing-library/jest-dom": "^6.4.5",
140
140
  "@testing-library/react": "^16.0.0",
141
141
  "@testing-library/user-event": "^14.5.2",
@@ -154,7 +154,7 @@
154
154
  "eslint-plugin-import": "^2.29.1",
155
155
  "eslint-plugin-jest": "^28.6.0",
156
156
  "eslint-plugin-prettier": "^5.1.3",
157
- "eslint-plugin-react": "^7.34.4",
157
+ "eslint-plugin-react": "^7.35.0",
158
158
  "eslint-plugin-react-hooks": "^4.6.2",
159
159
  "eslint-plugin-require-extensions": "^0.1.3",
160
160
  "eslint-plugin-testing-library": "^6.2.2",
package/src/DayPicker.tsx CHANGED
@@ -42,7 +42,7 @@ import { isDateRange } from "./utils/typeguards.js";
42
42
  * @group DayPicker
43
43
  * @see https://daypicker.dev
44
44
  */
45
- export function DayPicker<T extends DayPickerProps>(props: T) {
45
+ export function DayPicker(props: DayPickerProps) {
46
46
  const { components, formatters, labels, dateLib, classNames } = useMemo(
47
47
  () => ({
48
48
  dateLib: getDateLib(props.dateLib),
@@ -116,9 +116,9 @@ export function DayPicker<T extends DayPickerProps>(props: T) {
116
116
  isSelected,
117
117
  select,
118
118
  selected: selectedValue
119
- } = useSelection<T>(props, dateLib) ?? {};
119
+ } = useSelection(props, dateLib) ?? {};
120
120
 
121
- const { blur, focused, isFocusTarget, moveFocus, setFocused } = useFocus<T>(
121
+ const { blur, focused, isFocusTarget, moveFocus, setFocused } = useFocus(
122
122
  props,
123
123
  calendar,
124
124
  getModifiers,
@@ -221,9 +221,9 @@ export function DayPicker<T extends DayPickerProps>(props: T) {
221
221
 
222
222
  const dataAttributes = getDataAttributes(props);
223
223
 
224
- const contextValue: DayPickerContext<T> = {
225
- selected: selectedValue as SelectedValue<T>,
226
- select: select as SelectHandler<T>,
224
+ const contextValue: DayPickerContext<DayPickerProps> = {
225
+ selected: selectedValue as SelectedValue<DayPickerProps>,
226
+ select: select as SelectHandler<DayPickerProps>,
227
227
  isSelected,
228
228
  months,
229
229
  nextMonth,