react-day-picker 8.8.2 → 8.9.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.
Files changed (90) hide show
  1. package/README.md +3 -3
  2. package/dist/index.d.ts +152 -71
  3. package/dist/index.esm.js +1481 -101
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +1505 -142
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.min.js +10 -1
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/style.css +8 -7
  10. package/dist/style.css.map +1 -1
  11. package/dist/style.module.css +8 -7
  12. package/package.json +27 -27
  13. package/src/DayPicker.tsx +0 -2
  14. package/src/components/Button/Button.test.tsx +0 -2
  15. package/src/components/Button/Button.tsx +1 -1
  16. package/src/components/Caption/Caption.test.tsx +0 -2
  17. package/src/components/Caption/Caption.tsx +0 -2
  18. package/src/components/CaptionDropdowns/CaptionDropdowns.test.tsx +0 -2
  19. package/src/components/CaptionDropdowns/CaptionDropdowns.tsx +0 -2
  20. package/src/components/CaptionLabel/CaptionLabel.test.tsx +0 -2
  21. package/src/components/CaptionLabel/CaptionLabel.tsx +0 -2
  22. package/src/components/CaptionNavigation/CaptionNavigation.test.tsx +0 -2
  23. package/src/components/CaptionNavigation/CaptionNavigation.tsx +3 -3
  24. package/src/components/Day/Day.test.tsx +0 -2
  25. package/src/components/Day/Day.tsx +1 -1
  26. package/src/components/DayContent/DayContent.test.tsx +0 -2
  27. package/src/components/DayContent/DayContent.tsx +0 -2
  28. package/src/components/Dropdown/Dropdown.test.tsx +0 -2
  29. package/src/components/Dropdown/Dropdown.tsx +10 -5
  30. package/src/components/Footer/Footer.test.tsx +0 -2
  31. package/src/components/Footer/Footer.tsx +0 -2
  32. package/src/components/Head/Head.test.tsx +0 -2
  33. package/src/components/Head/Head.tsx +0 -2
  34. package/src/components/HeadRow/HeadRow.test.tsx +0 -2
  35. package/src/components/HeadRow/HeadRow.tsx +0 -2
  36. package/src/components/IconDropdown/IconDropdown.test.tsx +0 -2
  37. package/src/components/IconDropdown/IconDropdown.tsx +0 -2
  38. package/src/components/IconLeft/IconLeft.test.tsx +0 -2
  39. package/src/components/IconLeft/IconLeft.tsx +0 -2
  40. package/src/components/IconRight/IconRight.test.tsx +0 -2
  41. package/src/components/IconRight/IconRight.tsx +0 -2
  42. package/src/components/Month/Month.test.tsx +0 -2
  43. package/src/components/Month/Month.tsx +0 -2
  44. package/src/components/Months/Months.test.tsx +27 -0
  45. package/src/components/Months/Months.tsx +19 -0
  46. package/src/components/Months/index.ts +1 -0
  47. package/src/components/MonthsDropdown/MonthsDropdown.test.tsx +0 -2
  48. package/src/components/MonthsDropdown/MonthsDropdown.tsx +2 -2
  49. package/src/components/Navigation/Navigation.test.tsx +0 -2
  50. package/src/components/Navigation/Navigation.tsx +3 -3
  51. package/src/components/Root/Root.test.tsx +58 -15
  52. package/src/components/Root/Root.tsx +9 -6
  53. package/src/components/Row/Row.test.tsx +0 -2
  54. package/src/components/Row/Row.tsx +0 -2
  55. package/src/components/Table/Table.test.tsx +0 -2
  56. package/src/components/Table/Table.tsx +0 -2
  57. package/src/components/WeekNumber/WeekNumber.test.tsx +1 -3
  58. package/src/components/WeekNumber/WeekNumber.tsx +2 -2
  59. package/src/components/YearsDropdown/YearsDropdown.test.tsx +0 -2
  60. package/src/components/YearsDropdown/YearsDropdown.tsx +2 -2
  61. package/src/contexts/DayPicker/DayPickerContext.tsx +2 -1
  62. package/src/contexts/DayPicker/formatters/formatDay.ts +1 -2
  63. package/src/contexts/DayPicker/formatters/formatMonthCaption.ts +1 -2
  64. package/src/contexts/DayPicker/formatters/formatWeekdayName.ts +1 -2
  65. package/src/contexts/DayPicker/formatters/formatYearCaption.ts +4 -2
  66. package/src/contexts/Focus/FocusContext.tsx +4 -2
  67. package/src/contexts/Modifiers/ModifiersContext.tsx +2 -4
  68. package/src/contexts/Navigation/NavigationContext.tsx +1 -1
  69. package/src/contexts/RootProvider.tsx +4 -5
  70. package/src/contexts/SelectMultiple/SelectMultipleContext.test.ts +6 -4
  71. package/src/contexts/SelectMultiple/SelectMultipleContext.tsx +6 -5
  72. package/src/contexts/SelectRange/SelectRangeContext.test.ts +3 -1
  73. package/src/contexts/SelectRange/SelectRangeContext.tsx +8 -7
  74. package/src/contexts/SelectSingle/SelectSingleContext.test.ts +3 -3
  75. package/src/contexts/SelectSingle/SelectSingleContext.tsx +8 -7
  76. package/src/hooks/useControlledValue/useControlledValue.ts +2 -2
  77. package/src/hooks/useDayRender/useDayRender.tsx +2 -2
  78. package/src/hooks/useDayRender/utils/getDayStyle.ts +4 -2
  79. package/src/hooks/useId/useId.ts +5 -7
  80. package/src/hooks/useId/useIsomorphicLayoutEffect.ts +31 -0
  81. package/src/hooks/useInput/useInput.ts +13 -8
  82. package/src/index.ts +1 -0
  83. package/src/style.css +8 -7
  84. package/src/types/DayPickerBase.ts +85 -11
  85. package/src/types/EventHandlers.ts +18 -10
  86. package/src/types/Formatters.ts +11 -5
  87. package/src/types/Labels.ts +16 -5
  88. package/src/types/Modifiers.ts +4 -2
  89. package/src/types/Styles.ts +5 -5
  90. package/tsconfig.json +5 -3
@@ -0,0 +1,31 @@
1
+ import { useEffect, useLayoutEffect } from 'react';
2
+
3
+ import { canUseDOM } from './useId';
4
+
5
+ /**
6
+ * React currently throws a warning when using useLayoutEffect on the server. To
7
+ * get around it, we can conditionally useEffect on the server (no-op) and
8
+ * useLayoutEffect in the browser. We occasionally need useLayoutEffect to
9
+ * ensure we don't get a render flash for certain operations, but we may also
10
+ * need affected components to render on the server. One example is when setting
11
+ * a component's descendants to retrieve their index values.
12
+ *
13
+ * Important to note that using this hook as an escape hatch will break the
14
+ * eslint dependency warnings unless you rename the import to `useLayoutEffect`.
15
+ * Use sparingly only when the effect won't effect the rendered HTML to avoid
16
+ * any server/client mismatch.
17
+ *
18
+ * If a useLayoutEffect is needed and the result would create a mismatch, it's
19
+ * likely that the component in question shouldn't be rendered on the server at
20
+ * all, so a better approach would be to lazily render those in a parent
21
+ * component after client-side hydration.
22
+ *
23
+ * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
24
+ * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
25
+ *
26
+ * @param effect
27
+ * @param deps
28
+ */
29
+ export const useIsomorphicLayoutEffect = canUseDOM()
30
+ ? useLayoutEffect
31
+ : useEffect;
@@ -1,4 +1,9 @@
1
- import React, { useState } from 'react';
1
+ import {
2
+ ChangeEventHandler,
3
+ FocusEventHandler,
4
+ InputHTMLAttributes,
5
+ useState
6
+ } from 'react';
2
7
 
3
8
  import { differenceInCalendarDays, format as _format, parse } from 'date-fns';
4
9
  import { enUS } from 'date-fns/locale';
@@ -14,8 +19,8 @@ import {
14
19
  import { isValidDate } from './utils/isValidDate';
15
20
 
16
21
  /** The props to attach to the input field when using {@link useInput}. */
17
- export type InputHTMLAttributes = Pick<
18
- React.InputHTMLAttributes<HTMLInputElement>,
22
+ export type InputProps = Pick<
23
+ InputHTMLAttributes<HTMLInputElement>,
19
24
  'onBlur' | 'onChange' | 'onFocus' | 'value' | 'placeholder'
20
25
  >;
21
26
 
@@ -62,7 +67,7 @@ export interface UseInputValue {
62
67
  /** The props to pass to a DayPicker component. */
63
68
  dayPickerProps: InputDayPickerProps;
64
69
  /** The props to pass to an input field. */
65
- inputProps: InputHTMLAttributes;
70
+ inputProps: InputProps;
66
71
  /** A function to reset to the initial state. */
67
72
  reset: () => void;
68
73
  /** A function to set the selected day. */
@@ -120,7 +125,7 @@ export function useInput(options: UseInputOptions = {}): UseInputValue {
120
125
  // When changing the input field, save its value in state and check if the
121
126
  // string is a valid date. If it is a valid day, set it as selected and update
122
127
  // the calendar’s month.
123
- const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
128
+ const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {
124
129
  setInputValue(e.target.value);
125
130
  const day = parseValue(e.target.value);
126
131
  const isBefore = fromDate && differenceInCalendarDays(fromDate, day) > 0;
@@ -135,7 +140,7 @@ export function useInput(options: UseInputOptions = {}): UseInputValue {
135
140
 
136
141
  // Special case for _required_ fields: on blur, if the value of the input is not
137
142
  // a valid date, reset the calendar and the input value.
138
- const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {
143
+ const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {
139
144
  const day = parseValue(e.target.value);
140
145
  if (!isValidDate(day)) {
141
146
  reset();
@@ -144,7 +149,7 @@ export function useInput(options: UseInputOptions = {}): UseInputValue {
144
149
 
145
150
  // When focusing, make sure DayPicker visualizes the month of the date in the
146
151
  // input field.
147
- const handleFocus: React.FocusEventHandler<HTMLInputElement> = (e) => {
152
+ const handleFocus: FocusEventHandler<HTMLInputElement> = (e) => {
148
153
  if (!e.target.value) {
149
154
  reset();
150
155
  return;
@@ -166,7 +171,7 @@ export function useInput(options: UseInputOptions = {}): UseInputValue {
166
171
  today
167
172
  };
168
173
 
169
- const inputProps: InputHTMLAttributes = {
174
+ const inputProps: InputProps = {
170
175
  onBlur: handleBlur,
171
176
  onChange: handleChange,
172
177
  onFocus: handleFocus,
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export * from 'components/HeadRow';
15
15
  export * from 'components/IconDropdown';
16
16
  export * from 'components/IconRight';
17
17
  export * from 'components/IconLeft';
18
+ export * from 'components/Months';
18
19
  export * from 'components/Row';
19
20
  export * from 'components/WeekNumber';
20
21
 
package/src/style.css CHANGED
@@ -1,12 +1,13 @@
1
1
  .rdp {
2
- --rdp-cell-size: 40px;
3
- --rdp-caption-font-size: 18px;
4
- --rdp-accent-color: #0000ff;
5
- --rdp-background-color: #e7edff;
6
- --rdp-accent-color-dark: #3003e1;
7
- --rdp-background-color-dark: #180270;
2
+ --rdp-cell-size: 40px; /* Size of the day cells. */
3
+ --rdp-caption-font-size: 18px; /* Font size for the caption labels. */
4
+ --rdp-accent-color: #0000ff; /* Accent color for the background of selected days. */
5
+ --rdp-background-color: #e7edff; /* Background color for the hovered/focused elements. */
6
+ --rdp-accent-color-dark: #3003e1; /* Accent color for the background of selected days (to use in dark-mode). */
7
+ --rdp-background-color-dark: #180270; /* Background color for the hovered/focused elements (to use in dark-mode). */
8
8
  --rdp-outline: 2px solid var(--rdp-accent-color); /* Outline border for focused elements */
9
9
  --rdp-outline-selected: 3px solid var(--rdp-accent-color); /* Outline border for focused _and_ selected elements */
10
+ --rdp-selected-color: #fff; /* Color of selected day text */
10
11
 
11
12
  margin: 1em;
12
13
  }
@@ -270,7 +271,7 @@
270
271
  .rdp-day_selected,
271
272
  .rdp-day_selected:focus-visible,
272
273
  .rdp-day_selected:hover {
273
- color: white;
274
+ color: var(--rdp-selected-color);
274
275
  opacity: 1;
275
276
  background-color: var(--rdp-accent-color);
276
277
  }
@@ -1,4 +1,6 @@
1
- import type { Locale } from 'date-fns';
1
+ import { CSSProperties, ReactNode } from 'react';
2
+
3
+ import { Locale } from 'date-fns';
2
4
 
3
5
  import { CaptionLayout, CaptionProps } from 'components/Caption';
4
6
  import { CaptionLabelProps } from 'components/CaptionLabel';
@@ -6,6 +8,7 @@ import { DayProps } from 'components/Day';
6
8
  import { DayContentProps } from 'components/DayContent';
7
9
  import { DropdownProps } from 'components/Dropdown';
8
10
  import { FooterProps } from 'components/Footer';
11
+ import { MonthsProps } from 'components/Months';
9
12
  import { RowProps } from 'components/Row';
10
13
  import { WeekNumberProps } from 'components/WeekNumber';
11
14
 
@@ -64,7 +67,7 @@ export interface DayPickerBase {
64
67
  /**
65
68
  * Style to apply to the container element.
66
69
  */
67
- style?: React.CSSProperties;
70
+ style?: CSSProperties;
68
71
  /**
69
72
  * Change the inline styles of the HTML elements.
70
73
  */
@@ -226,7 +229,7 @@ export interface DayPickerBase {
226
229
  /**
227
230
  * Content to add to the table footer element.
228
231
  */
229
- footer?: React.ReactNode;
232
+ footer?: ReactNode;
230
233
 
231
234
  /**
232
235
  * When a selection mode is set, DayPicker will focus the first selected day
@@ -275,35 +278,104 @@ export interface DayPickerBase {
275
278
  */
276
279
  labels?: Partial<Labels>;
277
280
 
281
+ /**
282
+ * A map of formatters. Use the formatters to override the default formatting
283
+ * functions.
284
+ */
285
+ formatters?: Partial<Formatters>;
286
+
278
287
  /**
279
288
  * The text direction of the calendar. Use `ltr` for left-to-right (default)
280
289
  * or `rtl` for right-to-left.
281
290
  */
282
- dir?: string;
291
+ dir?: HTMLDivElement['dir'];
283
292
 
284
293
  /**
285
- * A map of formatters. Use the formatters to override the default formatting
286
- * functions.
294
+ * A cryptographic nonce ("number used once") which can be used by Content
295
+ * Security Policy for the inline `style` attributes.
296
+ **/
297
+ nonce?: HTMLDivElement['nonce'];
298
+
299
+ /**
300
+ * Add a `title` attribute to the container element.
301
+ **/
302
+ title?: HTMLDivElement['title'];
303
+
304
+ /**
305
+ * Add the language tag to the container element.
306
+ **/
307
+ lang?: HTMLDivElement['lang'];
308
+
309
+ /**
310
+ * Event callback fired when the next month button is clicked.
287
311
  */
288
- formatters?: Partial<Formatters>;
312
+ onNextClick?: MonthChangeEventHandler;
313
+ /**
314
+ * Event callback fired when the previous month button is clicked.
315
+ */
316
+ onPrevClick?: MonthChangeEventHandler;
317
+ /**
318
+ * Event callback fired when the week number is clicked. Requires
319
+ * `showWeekNumbers` set.
320
+ */
321
+ onWeekNumberClick?: WeekNumberClickEventHandler;
289
322
 
323
+ /**
324
+ * Event callback fired when the user clicks on a day.
325
+ */
290
326
  onDayClick?: DayClickEventHandler;
327
+ /**
328
+ * Event callback fired when the user focuses on a day.
329
+ */
291
330
  onDayFocus?: DayFocusEventHandler;
331
+ /**
332
+ * Event callback fired when the user blurs from a day.
333
+ */
292
334
  onDayBlur?: DayFocusEventHandler;
335
+ /**
336
+ * Event callback fired when the user hovers on a day.
337
+ */
293
338
  onDayMouseEnter?: DayMouseEventHandler;
339
+ /**
340
+ * Event callback fired when the user hovers away from a day.
341
+ */
294
342
  onDayMouseLeave?: DayMouseEventHandler;
343
+ /**
344
+ * Event callback fired when the user presses a key on a day.
345
+ */
295
346
  onDayKeyDown?: DayKeyboardEventHandler;
347
+ /**
348
+ * Event callback fired when the user presses a key on a day.
349
+ */
296
350
  onDayKeyUp?: DayKeyboardEventHandler;
351
+ /**
352
+ * Event callback fired when the user presses a key on a day.
353
+ */
297
354
  onDayKeyPress?: DayKeyboardEventHandler;
355
+ /**
356
+ * Event callback fired when the pointer enters a day.
357
+ */
298
358
  onDayPointerEnter?: DayPointerEventHandler;
359
+ /**
360
+ * Event callback fired when the pointer leaves a day.
361
+ */
299
362
  onDayPointerLeave?: DayPointerEventHandler;
363
+ /**
364
+ * Event callback when a day touch event is canceled.
365
+ */
300
366
  onDayTouchCancel?: DayTouchEventHandler;
367
+ /**
368
+ * Event callback when a day touch event ends.
369
+ */
301
370
  onDayTouchEnd?: DayTouchEventHandler;
371
+ /**
372
+ * Event callback when a day touch event moves.
373
+ */
302
374
  onDayTouchMove?: DayTouchEventHandler;
375
+ /**
376
+ * Event callback when a day touch event starts.
377
+ */
303
378
  onDayTouchStart?: DayTouchEventHandler;
304
- onNextClick?: MonthChangeEventHandler;
305
- onPrevClick?: MonthChangeEventHandler;
306
- onWeekNumberClick?: WeekNumberClickEventHandler;
307
379
  }
308
380
 
309
381
  /**
@@ -324,7 +396,7 @@ export interface CustomComponents {
324
396
  * Each `Day` in DayPicker should render one of the following, according to
325
397
  * the return value of {@link useDayRender}.
326
398
  *
327
- * - an empty `React.Fragment`, to render if `isHidden` is true
399
+ * - an empty `Fragment`, to render if `isHidden` is true
328
400
  * - a `button` element, when the day is interactive, e.g. is selectable
329
401
  * - a `div` or a `span` element, when the day is not interactive
330
402
  *
@@ -346,6 +418,8 @@ export interface CustomComponents {
346
418
  IconRight?: (props: StyledComponent) => JSX.Element | null;
347
419
  /** The arrow left icon (used for the Navigation buttons). */
348
420
  IconLeft?: (props: StyledComponent) => JSX.Element | null;
421
+ /** The component wrapping the month grids. */
422
+ Months?: (props: MonthsProps) => JSX.Element | null;
349
423
  /** The component for the table rows. */
350
424
  Row?: (props: RowProps) => JSX.Element | null;
351
425
  /** The component for the week number in the table rows. */
@@ -1,3 +1,11 @@
1
+ import {
2
+ FocusEvent,
3
+ KeyboardEvent,
4
+ MouseEvent,
5
+ PointerEvent,
6
+ TouchEvent
7
+ } from 'react';
8
+
1
9
  import { DateRange } from 'types/Matchers';
2
10
 
3
11
  import { ActiveModifiers } from './Modifiers';
@@ -6,35 +14,35 @@ import { ActiveModifiers } from './Modifiers';
6
14
  export type DayClickEventHandler = (
7
15
  day: Date,
8
16
  activeModifiers: ActiveModifiers,
9
- e: React.MouseEvent
17
+ e: MouseEvent
10
18
  ) => void;
11
19
 
12
20
  /** The event handler when a day is focused. */
13
21
  export type DayFocusEventHandler = (
14
22
  day: Date,
15
23
  activeModifiers: ActiveModifiers,
16
- e: React.FocusEvent | React.KeyboardEvent
24
+ e: FocusEvent | KeyboardEvent
17
25
  ) => void;
18
26
 
19
27
  /** The event handler when a day gets a keyboard event. */
20
28
  export type DayKeyboardEventHandler = (
21
29
  day: Date,
22
30
  activeModifiers: ActiveModifiers,
23
- e: React.KeyboardEvent
31
+ e: KeyboardEvent
24
32
  ) => void;
25
33
 
26
34
  /** The event handler when a day gets a mouse event. */
27
35
  export type DayMouseEventHandler = (
28
36
  day: Date,
29
37
  activeModifiers: ActiveModifiers,
30
- e: React.MouseEvent
38
+ e: MouseEvent
31
39
  ) => void;
32
40
 
33
41
  /** The event handler when a day gets a pointer event. */
34
42
  export type DayPointerEventHandler = (
35
43
  day: Date,
36
44
  activeModifiers: ActiveModifiers,
37
- e: React.PointerEvent
45
+ e: PointerEvent
38
46
  ) => void;
39
47
 
40
48
  /** The event handler when a month is changed in the calendar. */
@@ -49,7 +57,7 @@ export type SelectMultipleEventHandler = (
49
57
  /** The day that was clicked */
50
58
  activeModifiers: ActiveModifiers,
51
59
  /** The mouse event that triggered this event. */
52
- e: React.MouseEvent
60
+ e: MouseEvent
53
61
  ) => void;
54
62
 
55
63
  /** The event handler when selecting a range of days. */
@@ -60,7 +68,7 @@ export type SelectRangeEventHandler = (
60
68
  selectedDay: Date,
61
69
  /** The modifiers of the selected day. */
62
70
  activeModifiers: ActiveModifiers,
63
- e: React.MouseEvent
71
+ e: MouseEvent
64
72
  ) => void;
65
73
 
66
74
  /** The event handler when selecting a single day. */
@@ -71,7 +79,7 @@ export type SelectSingleEventHandler = (
71
79
  selectedDay: Date,
72
80
  /** The modifiers of the selected day. */
73
81
  activeModifiers: ActiveModifiers,
74
- e: React.MouseEvent
82
+ e: MouseEvent
75
83
  ) => void;
76
84
 
77
85
  /**The event handler when the week number is clicked. */
@@ -81,12 +89,12 @@ export type WeekNumberClickEventHandler = (
81
89
  /** The dates in the clicked week. */
82
90
  dates: Date[],
83
91
  /** The mouse event that triggered this event. */
84
- e: React.MouseEvent
92
+ e: MouseEvent
85
93
  ) => void;
86
94
 
87
95
  /** The event handler when a day gets a touch event. */
88
96
  export type DayTouchEventHandler = (
89
97
  day: Date,
90
98
  activeModifiers: ActiveModifiers,
91
- e: React.TouchEvent
99
+ e: TouchEvent
92
100
  ) => void;
@@ -1,10 +1,14 @@
1
- import React from 'react';
1
+ import { ReactNode } from 'react';
2
+
3
+ import { Locale } from 'date-fns';
2
4
 
3
5
  /** Represents a function to format a date. */
4
6
  export type DateFormatter = (
5
7
  date: Date,
6
- options?: { locale?: Locale }
7
- ) => React.ReactNode;
8
+ options?: {
9
+ locale?: Locale;
10
+ }
11
+ ) => ReactNode;
8
12
 
9
13
  /** Represent a map of formatters used to render localized content. */
10
14
  export type Formatters = {
@@ -25,5 +29,7 @@ export type Formatters = {
25
29
  /** Represent a function to format the week number. */
26
30
  export type WeekNumberFormatter = (
27
31
  weekNumber: number,
28
- options?: { locale?: Locale }
29
- ) => React.ReactNode;
32
+ options?: {
33
+ locale?: Locale;
34
+ }
35
+ ) => ReactNode;
@@ -1,4 +1,4 @@
1
- import type { Locale } from 'date-fns';
1
+ import { Locale } from 'date-fns';
2
2
 
3
3
  import { ActiveModifiers } from 'types/Modifiers';
4
4
 
@@ -18,20 +18,31 @@ export type Labels = {
18
18
  export type DayLabel = (
19
19
  day: Date,
20
20
  activeModifiers: ActiveModifiers,
21
- options?: { locale?: Locale }
21
+ options?: {
22
+ locale?: Locale;
23
+ }
22
24
  ) => string;
23
25
 
24
26
  /** Return the ARIA label for the "next month" / "prev month" buttons in the navigation.*/
25
27
  export type NavButtonLabel = (
26
28
  month?: Date,
27
- options?: { locale?: Locale }
29
+ options?: {
30
+ locale?: Locale;
31
+ }
28
32
  ) => string;
29
33
 
30
34
  /** Return the ARIA label for the Head component.*/
31
- export type WeekdayLabel = (day: Date, options?: { locale?: Locale }) => string;
35
+ export type WeekdayLabel = (
36
+ day: Date,
37
+ options?: {
38
+ locale?: Locale;
39
+ }
40
+ ) => string;
32
41
 
33
42
  /** Return the ARIA label of the week number.*/
34
43
  export type WeekNumberLabel = (
35
44
  n: number,
36
- options?: { locale?: Locale }
45
+ options?: {
46
+ locale?: Locale;
47
+ }
37
48
  ) => string;
@@ -1,3 +1,5 @@
1
+ import { CSSProperties } from 'react';
2
+
1
3
  import { Matcher } from './Matchers';
2
4
 
3
5
  /** A _modifier_ represents different styles or states of a day displayed in the calendar. */
@@ -43,8 +45,8 @@ export type ActiveModifiers = Record<Modifier, true> &
43
45
  Partial<Record<InternalModifier, true>>;
44
46
 
45
47
  /** The style to apply to each day element matching a modifier. */
46
- export type ModifiersStyles = Record<Modifier, React.CSSProperties> &
47
- Partial<Record<InternalModifier, React.CSSProperties>>;
48
+ export type ModifiersStyles = Record<Modifier, CSSProperties> &
49
+ Partial<Record<InternalModifier, CSSProperties>>;
48
50
 
49
51
  /** The classnames to assign to each day element matching a modifier. */
50
52
  export type ModifiersClassNames = Record<Modifier, string> &
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
 
3
3
  /** The style (either via class names or via in-line styles) of an element. */
4
- export type StyledElement<T = string | React.CSSProperties> = {
4
+ export type StyledElement<T = string | CSSProperties> = {
5
5
  /** The root element. */
6
6
  readonly root: T;
7
7
  /** The root element when `numberOfMonths > 1`. */
@@ -114,12 +114,12 @@ export type ClassNames = Partial<StyledElement<string>>;
114
114
  * `modifiersStyles` prop.
115
115
  */
116
116
  export type Styles = Partial<
117
- Omit<StyledElement<React.CSSProperties>, InternalModifiersElement>
117
+ Omit<StyledElement<CSSProperties>, InternalModifiersElement>
118
118
  >;
119
119
 
120
120
  /** Props of a component that can be styled via classNames or inline-styles. */
121
121
  export type StyledComponent = {
122
122
  className?: string;
123
- style?: React.CSSProperties;
124
- children?: React.ReactNode;
123
+ style?: CSSProperties;
124
+ children?: ReactNode;
125
125
  };
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es5",
4
- "jsx": "react",
4
+ "jsx": "react-jsx",
5
5
  "module": "es6",
6
6
  "moduleResolution": "node",
7
7
  "rootDir": "./",
@@ -14,11 +14,13 @@
14
14
  "sourceMap": true,
15
15
  "outDir": "./dist",
16
16
  "importHelpers": true,
17
- "esModuleInterop": true,
17
+ "esModuleInterop": false,
18
+ "allowSyntheticDefaultImports": false,
18
19
  "forceConsistentCasingInFileNames": true,
19
20
  "strict": true,
20
21
  "skipLibCheck": true,
21
- "resolveJsonModule": true
22
+ "resolveJsonModule": true,
23
+ "isolatedModules": false
22
24
  },
23
25
  "include": ["test", "src"]
24
26
  }