react-day-picker 9.13.2 → 10.0.0-next.0

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 (180) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/DayPicker.js +85 -83
  3. package/dist/cjs/UI.d.ts +0 -230
  4. package/dist/cjs/classes/DateLib.d.ts +0 -21
  5. package/dist/cjs/classes/DateLib.js +3 -13
  6. package/dist/cjs/components/Dropdown.d.ts +0 -11
  7. package/dist/cjs/components/Dropdown.js +3 -1
  8. package/dist/cjs/components/NextMonthButton.js +1 -3
  9. package/dist/cjs/components/PreviousMonthButton.js +1 -3
  10. package/dist/cjs/components/custom-components.d.ts +0 -1
  11. package/dist/cjs/components/custom-components.js +0 -1
  12. package/dist/cjs/formatters/formatCaption.d.ts +0 -6
  13. package/dist/cjs/formatters/formatCaption.js +0 -7
  14. package/dist/cjs/formatters/formatYearDropdown.d.ts +0 -6
  15. package/dist/cjs/formatters/formatYearDropdown.js +0 -7
  16. package/dist/cjs/helpers/getFormatters.d.ts +0 -2
  17. package/dist/cjs/helpers/getFormatters.js +0 -7
  18. package/dist/cjs/helpers/getInitialMonth.d.ts +1 -1
  19. package/dist/cjs/helpers/getNavMonth.d.ts +1 -1
  20. package/dist/cjs/helpers/getNavMonth.js +1 -21
  21. package/dist/cjs/hijri/index.d.ts +28 -0
  22. package/dist/cjs/hijri/index.js +92 -0
  23. package/dist/cjs/hijri/lib/addMonths.d.ts +1 -0
  24. package/dist/cjs/hijri/lib/addMonths.js +9 -0
  25. package/dist/cjs/hijri/lib/addYears.d.ts +1 -0
  26. package/dist/cjs/hijri/lib/addYears.js +9 -0
  27. package/dist/cjs/hijri/lib/differenceInCalendarMonths.d.ts +1 -0
  28. package/dist/cjs/hijri/lib/differenceInCalendarMonths.js +10 -0
  29. package/dist/cjs/hijri/lib/eachMonthOfInterval.d.ts +2 -0
  30. package/dist/cjs/hijri/lib/eachMonthOfInterval.js +29 -0
  31. package/dist/cjs/hijri/lib/eachYearOfInterval.d.ts +2 -0
  32. package/dist/cjs/hijri/lib/eachYearOfInterval.js +19 -0
  33. package/dist/cjs/hijri/lib/endOfMonth.d.ts +1 -0
  34. package/dist/cjs/hijri/lib/endOfMonth.js +14 -0
  35. package/dist/cjs/hijri/lib/endOfYear.d.ts +1 -0
  36. package/dist/cjs/hijri/lib/endOfYear.js +14 -0
  37. package/dist/cjs/hijri/lib/fallbackLocaleData.d.ts +5 -0
  38. package/dist/cjs/hijri/lib/fallbackLocaleData.js +111 -0
  39. package/dist/cjs/hijri/lib/format.d.ts +3 -0
  40. package/dist/cjs/hijri/lib/format.js +149 -0
  41. package/dist/cjs/hijri/lib/getMonth.d.ts +1 -0
  42. package/dist/cjs/hijri/lib/getMonth.js +7 -0
  43. package/dist/cjs/hijri/lib/getYear.d.ts +1 -0
  44. package/dist/cjs/hijri/lib/getYear.js +7 -0
  45. package/dist/cjs/hijri/lib/index.d.ts +17 -0
  46. package/dist/cjs/hijri/lib/index.js +33 -0
  47. package/dist/cjs/hijri/lib/isSameMonth.d.ts +1 -0
  48. package/dist/cjs/hijri/lib/isSameMonth.js +10 -0
  49. package/dist/cjs/hijri/lib/isSameYear.d.ts +1 -0
  50. package/dist/cjs/hijri/lib/isSameYear.js +9 -0
  51. package/dist/cjs/hijri/lib/newDate.d.ts +1 -0
  52. package/dist/cjs/hijri/lib/newDate.js +7 -0
  53. package/dist/cjs/hijri/lib/setMonth.d.ts +1 -0
  54. package/dist/cjs/hijri/lib/setMonth.js +27 -0
  55. package/dist/cjs/hijri/lib/setYear.d.ts +1 -0
  56. package/dist/cjs/hijri/lib/setYear.js +15 -0
  57. package/dist/cjs/hijri/lib/startOfMonth.d.ts +1 -0
  58. package/dist/cjs/hijri/lib/startOfMonth.js +12 -0
  59. package/dist/cjs/hijri/lib/startOfYear.d.ts +1 -0
  60. package/dist/cjs/hijri/lib/startOfYear.js +12 -0
  61. package/dist/cjs/hijri/utils/conversion.d.ts +5 -0
  62. package/dist/cjs/hijri/utils/conversion.js +40 -0
  63. package/dist/cjs/hijri/utils/daysInMonth.d.ts +1 -0
  64. package/dist/cjs/hijri/utils/daysInMonth.js +24 -0
  65. package/dist/cjs/hijri/utils/range.d.ts +21 -0
  66. package/dist/cjs/hijri/utils/range.js +104 -0
  67. package/dist/cjs/hijri/utils/types.d.ts +5 -0
  68. package/dist/cjs/hijri/utils/types.js +2 -0
  69. package/dist/cjs/labels/labelDayButton.d.ts +0 -5
  70. package/dist/cjs/labels/labelDayButton.js +0 -6
  71. package/dist/cjs/labels/labelGrid.d.ts +0 -5
  72. package/dist/cjs/labels/labelGrid.js +0 -6
  73. package/dist/cjs/selection/useRange.js +22 -4
  74. package/dist/cjs/types/index.d.ts +0 -1
  75. package/dist/cjs/types/index.js +0 -1
  76. package/dist/cjs/types/props.d.ts +30 -100
  77. package/dist/cjs/types/shared.d.ts +1 -45
  78. package/dist/cjs/useCalendar.d.ts +1 -1
  79. package/dist/cjs/utils/dateMatchModifiers.d.ts +0 -5
  80. package/dist/cjs/utils/dateMatchModifiers.js +0 -6
  81. package/dist/cjs/utils/rangeIncludesDate.d.ts +0 -5
  82. package/dist/cjs/utils/rangeIncludesDate.js +0 -7
  83. package/dist/esm/DayPicker.js +85 -83
  84. package/dist/esm/UI.d.ts +0 -230
  85. package/dist/esm/classes/DateLib.d.ts +0 -21
  86. package/dist/esm/classes/DateLib.js +2 -12
  87. package/dist/esm/components/Dropdown.d.ts +0 -11
  88. package/dist/esm/components/Dropdown.js +3 -1
  89. package/dist/esm/components/NextMonthButton.js +1 -3
  90. package/dist/esm/components/PreviousMonthButton.js +1 -3
  91. package/dist/esm/components/custom-components.d.ts +0 -1
  92. package/dist/esm/components/custom-components.js +0 -1
  93. package/dist/esm/formatters/formatCaption.d.ts +0 -6
  94. package/dist/esm/formatters/formatCaption.js +0 -6
  95. package/dist/esm/formatters/formatYearDropdown.d.ts +0 -6
  96. package/dist/esm/formatters/formatYearDropdown.js +0 -6
  97. package/dist/esm/helpers/getFormatters.d.ts +0 -2
  98. package/dist/esm/helpers/getFormatters.js +0 -7
  99. package/dist/esm/helpers/getInitialMonth.d.ts +1 -1
  100. package/dist/esm/helpers/getNavMonth.d.ts +1 -1
  101. package/dist/esm/helpers/getNavMonth.js +1 -21
  102. package/dist/esm/hijri/index.d.ts +28 -0
  103. package/dist/esm/hijri/index.js +49 -0
  104. package/dist/esm/hijri/lib/addMonths.d.ts +1 -0
  105. package/dist/esm/hijri/lib/addMonths.js +6 -0
  106. package/dist/esm/hijri/lib/addYears.d.ts +1 -0
  107. package/dist/esm/hijri/lib/addYears.js +6 -0
  108. package/dist/esm/hijri/lib/differenceInCalendarMonths.d.ts +1 -0
  109. package/dist/esm/hijri/lib/differenceInCalendarMonths.js +7 -0
  110. package/dist/esm/hijri/lib/eachMonthOfInterval.d.ts +2 -0
  111. package/dist/esm/hijri/lib/eachMonthOfInterval.js +26 -0
  112. package/dist/esm/hijri/lib/eachYearOfInterval.d.ts +2 -0
  113. package/dist/esm/hijri/lib/eachYearOfInterval.js +16 -0
  114. package/dist/esm/hijri/lib/endOfMonth.d.ts +1 -0
  115. package/dist/esm/hijri/lib/endOfMonth.js +11 -0
  116. package/dist/esm/hijri/lib/endOfYear.d.ts +1 -0
  117. package/dist/esm/hijri/lib/endOfYear.js +11 -0
  118. package/dist/esm/hijri/lib/fallbackLocaleData.d.ts +5 -0
  119. package/dist/esm/hijri/lib/fallbackLocaleData.js +105 -0
  120. package/dist/esm/hijri/lib/format.d.ts +3 -0
  121. package/dist/esm/hijri/lib/format.js +146 -0
  122. package/dist/esm/hijri/lib/getMonth.d.ts +1 -0
  123. package/dist/esm/hijri/lib/getMonth.js +4 -0
  124. package/dist/esm/hijri/lib/getYear.d.ts +1 -0
  125. package/dist/esm/hijri/lib/getYear.js +4 -0
  126. package/dist/esm/hijri/lib/index.d.ts +17 -0
  127. package/dist/esm/hijri/lib/index.js +17 -0
  128. package/dist/esm/hijri/lib/isSameMonth.d.ts +1 -0
  129. package/dist/esm/hijri/lib/isSameMonth.js +7 -0
  130. package/dist/esm/hijri/lib/isSameYear.d.ts +1 -0
  131. package/dist/esm/hijri/lib/isSameYear.js +6 -0
  132. package/dist/esm/hijri/lib/newDate.d.ts +1 -0
  133. package/dist/esm/hijri/lib/newDate.js +4 -0
  134. package/dist/esm/hijri/lib/setMonth.d.ts +1 -0
  135. package/dist/esm/hijri/lib/setMonth.js +24 -0
  136. package/dist/esm/hijri/lib/setYear.d.ts +1 -0
  137. package/dist/esm/hijri/lib/setYear.js +12 -0
  138. package/dist/esm/hijri/lib/startOfMonth.d.ts +1 -0
  139. package/dist/esm/hijri/lib/startOfMonth.js +9 -0
  140. package/dist/esm/hijri/lib/startOfYear.d.ts +1 -0
  141. package/dist/esm/hijri/lib/startOfYear.js +9 -0
  142. package/dist/esm/hijri/utils/conversion.d.ts +5 -0
  143. package/dist/esm/hijri/utils/conversion.js +36 -0
  144. package/dist/esm/hijri/utils/daysInMonth.d.ts +1 -0
  145. package/dist/esm/hijri/utils/daysInMonth.js +21 -0
  146. package/dist/esm/hijri/utils/range.d.ts +21 -0
  147. package/dist/esm/hijri/utils/range.js +96 -0
  148. package/dist/esm/hijri/utils/types.d.ts +5 -0
  149. package/dist/esm/hijri/utils/types.js +1 -0
  150. package/dist/esm/labels/labelDayButton.d.ts +0 -5
  151. package/dist/esm/labels/labelDayButton.js +0 -5
  152. package/dist/esm/labels/labelGrid.d.ts +0 -5
  153. package/dist/esm/labels/labelGrid.js +0 -5
  154. package/dist/esm/selection/useRange.js +22 -4
  155. package/dist/esm/types/index.d.ts +0 -1
  156. package/dist/esm/types/index.js +0 -1
  157. package/dist/esm/types/props.d.ts +30 -100
  158. package/dist/esm/types/shared.d.ts +1 -45
  159. package/dist/esm/useCalendar.d.ts +1 -1
  160. package/dist/esm/utils/dateMatchModifiers.d.ts +0 -5
  161. package/dist/esm/utils/dateMatchModifiers.js +0 -5
  162. package/dist/esm/utils/rangeIncludesDate.d.ts +0 -5
  163. package/dist/esm/utils/rangeIncludesDate.js +0 -5
  164. package/hijri.d.ts +1 -0
  165. package/hijri.js +2 -0
  166. package/package.json +24 -23
  167. package/dist/cjs/components/Button.d.ts +0 -9
  168. package/dist/cjs/components/Button.js +0 -16
  169. package/dist/cjs/jalali.d.ts +0 -2
  170. package/dist/cjs/jalali.js +0 -18
  171. package/dist/cjs/types/deprecated.d.ts +0 -180
  172. package/dist/cjs/types/deprecated.js +0 -26
  173. package/dist/esm/components/Button.d.ts +0 -9
  174. package/dist/esm/components/Button.js +0 -10
  175. package/dist/esm/jalali.d.ts +0 -2
  176. package/dist/esm/jalali.js +0 -2
  177. package/dist/esm/types/deprecated.d.ts +0 -180
  178. package/dist/esm/types/deprecated.js +0 -23
  179. package/jalali.d.ts +0 -1
  180. package/jalali.js +0 -3
package/dist/esm/UI.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { CSSProperties } from "react";
2
1
  /**
3
2
  * Enum representing the UI elements composing DayPicker. These elements are
4
3
  * mapped to {@link CustomComponents}, {@link ClassNames}, and {@link Styles}.
@@ -115,232 +114,3 @@ export declare enum Animation {
115
114
  /** The exiting caption when it disappears before the entering month. */
116
115
  caption_before_exit = "caption_before_exit"
117
116
  }
118
- /**
119
- * Deprecated UI elements and flags from previous versions of DayPicker.
120
- *
121
- * These elements are kept for backward compatibility and to assist in
122
- * transitioning to the new {@link UI} elements.
123
- *
124
- * @deprecated
125
- * @since 9.0.1
126
- * @template T - The type of the deprecated UI element (e.g., CSS class or
127
- * style).
128
- * @see https://daypicker.dev/upgrading
129
- * @see https://daypicker.dev/docs/styling
130
- */
131
- export type DeprecatedUI<T extends CSSProperties | string> = {
132
- /**
133
- * This element was applied to the style of any button in DayPicker and it is
134
- * replaced by {@link UI | UI.PreviousMonthButton} and {@link UI | UI.NextMonthButton}.
135
- *
136
- * @deprecated
137
- */
138
- button: T;
139
- /**
140
- * This element was resetting the style of any button in DayPicker and it is
141
- * replaced by {@link UI | UI.PreviousMonthButton} and {@link UI | UI.NextMonthButton}.
142
- *
143
- * @deprecated
144
- */
145
- button_reset: T;
146
- /**
147
- * This element has been renamed to {@link UI | UI.MonthCaption}.
148
- *
149
- * @deprecated
150
- */
151
- caption: T;
152
- /**
153
- * This element has been removed. Captions are styled via
154
- * {@link UI | UI.MonthCaption}.
155
- *
156
- * @deprecated
157
- */
158
- caption_between: T;
159
- /**
160
- * This element has been renamed to {@link UI | UI.Dropdowns}.
161
- *
162
- * @deprecated
163
- */
164
- caption_dropdowns: T;
165
- /**
166
- * This element has been removed. Captions are styled via
167
- * {@link UI | UI.MonthCaption}.
168
- *
169
- * @deprecated
170
- */
171
- caption_end: T;
172
- /**
173
- * This element has been removed.
174
- *
175
- * @deprecated
176
- */
177
- caption_start: T;
178
- /**
179
- * This element has been renamed to {@link UI | UI.Day}.
180
- *
181
- * @deprecated
182
- */
183
- cell: T;
184
- /**
185
- * This element has been renamed to {@link DayFlag | DayFlag.disabled}.
186
- *
187
- * @deprecated
188
- */
189
- day_disabled: T;
190
- /**
191
- * This element has been renamed to {@link DayFlag | DayFlag.hidden}.
192
- *
193
- * @deprecated
194
- */
195
- day_hidden: T;
196
- /**
197
- * This element has been renamed to {@link DayFlag | DayFlag.outside}.
198
- *
199
- * @deprecated
200
- */
201
- day_outside: T;
202
- /**
203
- * This element has been renamed to {@link SelectionState | SelectionState.range_end}.
204
- *
205
- * @deprecated
206
- */
207
- day_range_end: T;
208
- /**
209
- * This element has been renamed to {@link SelectionState | SelectionState.range_middle}.
210
- *
211
- * @deprecated
212
- */
213
- day_range_middle: T;
214
- /**
215
- * This element has been renamed to {@link SelectionState | SelectionState.range_start}.
216
- *
217
- * @deprecated
218
- */
219
- day_range_start: T;
220
- /**
221
- * This element has been renamed to {@link SelectionState | SelectionState.selected}.
222
- *
223
- * @deprecated
224
- */
225
- day_selected: T;
226
- /**
227
- * This element has been renamed to {@link DayFlag | DayFlag.today}.
228
- *
229
- * @deprecated
230
- */
231
- day_today: T;
232
- /**
233
- * This element has been removed. The dropdown icon is now {@link UI | UI.Chevron}
234
- * inside a {@link UI | UI.CaptionLabel}.
235
- *
236
- * @deprecated
237
- */
238
- dropdown_icon: T;
239
- /**
240
- * This element has been renamed to {@link UI | UI.MonthsDropdown}.
241
- *
242
- * @deprecated
243
- */
244
- dropdown_month: T;
245
- /**
246
- * This element has been renamed to {@link UI | UI.YearsDropdown}.
247
- *
248
- * @deprecated
249
- */
250
- dropdown_year: T;
251
- /**
252
- * This element has been removed.
253
- *
254
- * @deprecated
255
- */
256
- head: T;
257
- /**
258
- * This element has been renamed to {@link UI | UI.Weekday}.
259
- *
260
- * @deprecated
261
- */
262
- head_cell: T;
263
- /**
264
- * This element has been renamed to {@link UI | UI.Weekdays}.
265
- *
266
- * @deprecated
267
- */
268
- head_row: T;
269
- /**
270
- * This flag has been removed. Use `data-multiple-months` in your CSS
271
- * selectors.
272
- *
273
- * @deprecated
274
- */
275
- multiple_months: T;
276
- /**
277
- * This element has been removed. To style the navigation buttons, use
278
- * {@link UI | UI.PreviousMonthButton} and {@link UI | UI.NextMonthButton}.
279
- *
280
- * @deprecated
281
- */
282
- nav_button: T;
283
- /**
284
- * This element has been renamed to {@link UI | UI.NextMonthButton}.
285
- *
286
- * @deprecated
287
- */
288
- nav_button_next: T;
289
- /**
290
- * This element has been renamed to {@link UI | UI.PreviousMonthButton}.
291
- *
292
- * @deprecated
293
- */
294
- nav_button_previous: T;
295
- /**
296
- * This element has been removed. The dropdown icon is now {@link UI | UI.Chevron}
297
- * inside a {@link UI | UI.NextMonthButton} or a {@link UI | UI.PreviousMonthButton}.
298
- *
299
- * @deprecated
300
- */
301
- nav_icon: T;
302
- /**
303
- * This element has been renamed to {@link UI | UI.Week}.
304
- *
305
- * @deprecated
306
- */
307
- row: T;
308
- /**
309
- * This element has been renamed to {@link UI | UI.MonthGrid}.
310
- *
311
- * @deprecated
312
- */
313
- table: T;
314
- /**
315
- * This element has been renamed to {@link UI | UI.Weeks}.
316
- *
317
- * @deprecated
318
- */
319
- tbody: T;
320
- /**
321
- * This element has been removed. The {@link UI | UI.Footer} is now a single element
322
- * below the months.
323
- *
324
- * @deprecated
325
- */
326
- tfoot: T;
327
- /**
328
- * This flag has been removed. There are no "visually hidden" elements in
329
- * DayPicker 9.
330
- *
331
- * @deprecated
332
- */
333
- vhidden: T;
334
- /**
335
- * This element has been renamed. Use {@link UI | UI.WeekNumber} instead.
336
- *
337
- * @deprecated
338
- */
339
- weeknumber: T;
340
- /**
341
- * This flag has been removed. Use `data-week-numbers` in your CSS.
342
- *
343
- * @deprecated
344
- */
345
- with_weeknumber: T;
346
- };
@@ -20,16 +20,6 @@ export interface DayPickerLocale extends DateFnsLocale {
20
20
  labels?: DayPickerLocaleLabels;
21
21
  }
22
22
  export type Locale = DayPickerLocale;
23
- /**
24
- * @ignore
25
- * @deprecated Use {@link DateLibOptions} instead.
26
- */
27
- export type FormatOptions = DateLibOptions;
28
- /**
29
- * @ignore
30
- * @deprecated Use {@link DateLibOptions} instead.
31
- */
32
- export type LabelOptions = DateLibOptions;
33
23
  /** Indicates the preferred ordering of month and year for localized labels. */
34
24
  export type MonthYearOrder = "month-first" | "year-first";
35
25
  /**
@@ -116,12 +106,6 @@ export declare class DateLib {
116
106
  */
117
107
  formatMonthYear(date: Date): string;
118
108
  private static readonly yearFirstLocales;
119
- /**
120
- * Reference to the built-in Date constructor.
121
- *
122
- * @deprecated Use `newDate()` or `today()`.
123
- */
124
- Date: typeof Date;
125
109
  /**
126
110
  * Creates a new `Date` object representing today's date.
127
111
  *
@@ -400,8 +384,3 @@ export { enUS as defaultLocale } from "../locale/en-US.js";
400
384
  * @since 9.2.0
401
385
  */
402
386
  export declare const defaultDateLib: DateLib;
403
- /**
404
- * @ignore
405
- * @deprecated Use `defaultDateLib`.
406
- */
407
- export declare const dateLib: DateLib;
@@ -20,12 +20,6 @@ export class DateLib {
20
20
  * @param overrides Custom overrides for the date library functions.
21
21
  */
22
22
  constructor(options, overrides) {
23
- /**
24
- * Reference to the built-in Date constructor.
25
- *
26
- * @deprecated Use `newDate()` or `today()`.
27
- */
28
- this.Date = Date;
29
23
  /**
30
24
  * Creates a new `Date` object representing today's date.
31
25
  *
@@ -39,7 +33,8 @@ export class DateLib {
39
33
  if (this.options.timeZone) {
40
34
  return TZDate.tz(this.options.timeZone);
41
35
  }
42
- return new this.Date();
36
+ const DateCtor = this.options.Date ?? Date;
37
+ return new DateCtor();
43
38
  };
44
39
  /**
45
40
  * Creates a new `Date` object with the specified year, month, and day.
@@ -569,8 +564,3 @@ export { enUS as defaultLocale } from "../locale/en-US.js";
569
564
  * @since 9.2.0
570
565
  */
571
566
  export const defaultDateLib = new DateLib();
572
- /**
573
- * @ignore
574
- * @deprecated Use `defaultDateLib`.
575
- */
576
- export const dateLib = defaultDateLib;
@@ -1,5 +1,4 @@
1
1
  import React, { type SelectHTMLAttributes } from "react";
2
- import type { ClassNames, CustomComponents } from "../types/index.js";
3
2
  /** An option to use in the dropdown. Maps to the `<option>` HTML element. */
4
3
  export type DropdownOption = {
5
4
  /** The value of the option. */
@@ -16,16 +15,6 @@ export type DropdownOption = {
16
15
  * @see https://daypicker.dev/guides/custom-components
17
16
  */
18
17
  export declare function Dropdown(props: {
19
- /**
20
- * @deprecated Use {@link useDayPicker} hook to get the list of internal
21
- * components.
22
- */
23
- components: CustomComponents;
24
- /**
25
- * @deprecated Use {@link useDayPicker} hook to get the list of internal
26
- * class names.
27
- */
28
- classNames: ClassNames;
29
18
  /** The options to display in the dropdown. */
30
19
  options?: DropdownOption[] | undefined;
31
20
  } & Omit<SelectHTMLAttributes<HTMLSelectElement>, "children">): React.JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { UI } from "../UI.js";
3
+ import { useDayPicker } from "../useDayPicker.js";
3
4
  /**
4
5
  * Render a dropdown component for navigation in the calendar.
5
6
  *
@@ -7,7 +8,8 @@ import { UI } from "../UI.js";
7
8
  * @see https://daypicker.dev/guides/custom-components
8
9
  */
9
10
  export function Dropdown(props) {
10
- const { options, className, components, classNames, ...selectProps } = props;
11
+ const { options, className, ...selectProps } = props;
12
+ const { classNames, components } = useDayPicker();
11
13
  const cssClassSelect = [classNames[UI.Dropdown], className].join(" ");
12
14
  const selectedOption = options?.find(({ value }) => value === selectProps.value);
13
15
  return (React.createElement("span", { "data-disabled": selectProps.disabled, className: classNames[UI.DropdownRoot] },
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { useDayPicker } from "../useDayPicker.js";
3
2
  /**
4
3
  * Render the button to navigate to the next month in the calendar.
5
4
  *
@@ -7,6 +6,5 @@ import { useDayPicker } from "../useDayPicker.js";
7
6
  * @see https://daypicker.dev/guides/custom-components
8
7
  */
9
8
  export function NextMonthButton(props) {
10
- const { components } = useDayPicker();
11
- return React.createElement(components.Button, { ...props });
9
+ return React.createElement("button", { ...props });
12
10
  }
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { useDayPicker } from "../useDayPicker.js";
3
2
  /**
4
3
  * Render the button to navigate to the previous month in the calendar.
5
4
  *
@@ -7,6 +6,5 @@ import { useDayPicker } from "../useDayPicker.js";
7
6
  * @see https://daypicker.dev/guides/custom-components
8
7
  */
9
8
  export function PreviousMonthButton(props) {
10
- const { components } = useDayPicker();
11
- return React.createElement(components.Button, { ...props });
9
+ return React.createElement("button", { ...props });
12
10
  }
@@ -1,4 +1,3 @@
1
- export * from "./Button.js";
2
1
  export * from "./CaptionLabel.js";
3
2
  export * from "./Chevron.js";
4
3
  export * from "./Day.js";
@@ -1,4 +1,3 @@
1
- export * from "./Button.js";
2
1
  export * from "./CaptionLabel.js";
3
2
  export * from "./Chevron.js";
4
3
  export * from "./Day.js";
@@ -12,9 +12,3 @@ import { DateLib, type DateLibOptions } from "../classes/DateLib.js";
12
12
  * @see https://daypicker.dev/docs/translation#custom-formatters
13
13
  */
14
14
  export declare function formatCaption(month: Date, options?: DateLibOptions, dateLib?: DateLib): string;
15
- /**
16
- * @private
17
- * @deprecated Use {@link formatCaption} instead.
18
- * @group Formatters
19
- */
20
- export declare const formatMonthCaption: typeof formatCaption;
@@ -15,9 +15,3 @@ export function formatCaption(month, options, dateLib) {
15
15
  const lib = dateLib ?? new DateLib(options);
16
16
  return lib.formatMonthYear(month);
17
17
  }
18
- /**
19
- * @private
20
- * @deprecated Use {@link formatCaption} instead.
21
- * @group Formatters
22
- */
23
- export const formatMonthCaption = formatCaption;
@@ -10,9 +10,3 @@ import { type DateLib } from "../classes/DateLib.js";
10
10
  * @see https://daypicker.dev/docs/translation#custom-formatters
11
11
  */
12
12
  export declare function formatYearDropdown(year: Date, dateLib?: DateLib): string;
13
- /**
14
- * @private
15
- * @deprecated Use `formatYearDropdown` instead.
16
- * @group Formatters
17
- */
18
- export declare const formatYearCaption: typeof formatYearDropdown;
@@ -12,9 +12,3 @@ import { defaultDateLib } from "../classes/DateLib.js";
12
12
  export function formatYearDropdown(year, dateLib = defaultDateLib) {
13
13
  return dateLib.format(year, "yyyy");
14
14
  }
15
- /**
16
- * @private
17
- * @deprecated Use `formatYearDropdown` instead.
18
- * @group Formatters
19
- */
20
- export const formatYearCaption = formatYearDropdown;
@@ -11,10 +11,8 @@ export declare function getFormatters(customFormatters: DayPickerProps["formatte
11
11
  formatCaption: typeof defaultFormatters.formatCaption;
12
12
  formatDay: typeof defaultFormatters.formatDay;
13
13
  formatMonthDropdown: typeof defaultFormatters.formatMonthDropdown;
14
- formatMonthCaption: typeof defaultFormatters.formatMonthCaption;
15
14
  formatWeekNumber: typeof defaultFormatters.formatWeekNumber;
16
15
  formatWeekNumberHeader: typeof defaultFormatters.formatWeekNumberHeader;
17
16
  formatWeekdayName: typeof defaultFormatters.formatWeekdayName;
18
17
  formatYearDropdown: typeof defaultFormatters.formatYearDropdown;
19
- formatYearCaption: typeof defaultFormatters.formatYearCaption;
20
18
  };
@@ -7,13 +7,6 @@ import * as defaultFormatters from "../formatters/index.js";
7
7
  * @returns The merged formatters object.
8
8
  */
9
9
  export function getFormatters(customFormatters) {
10
- if (customFormatters?.formatMonthCaption && !customFormatters.formatCaption) {
11
- customFormatters.formatCaption = customFormatters.formatMonthCaption;
12
- }
13
- if (customFormatters?.formatYearCaption &&
14
- !customFormatters.formatYearDropdown) {
15
- customFormatters.formatYearDropdown = customFormatters.formatYearCaption;
16
- }
17
10
  return {
18
11
  ...defaultFormatters,
19
12
  ...customFormatters,
@@ -11,4 +11,4 @@ import type { DayPickerProps } from "../types/props.js";
11
11
  * @param dateLib The date library to use for date manipulation.
12
12
  * @returns The initial month to display.
13
13
  */
14
- export declare function getInitialMonth(props: Pick<DayPickerProps, "fromYear" | "toYear" | "month" | "defaultMonth" | "today" | "numberOfMonths" | "timeZone">, navStart: Date | undefined, navEnd: Date | undefined, dateLib: DateLib): Date;
14
+ export declare function getInitialMonth(props: Pick<DayPickerProps, "month" | "defaultMonth" | "today" | "numberOfMonths" | "timeZone">, navStart: Date | undefined, navEnd: Date | undefined, dateLib: DateLib): Date;
@@ -7,4 +7,4 @@ import type { DayPickerProps } from "../types/index.js";
7
7
  * @param dateLib The date library to use for date manipulation.
8
8
  * @returns A tuple containing the start and end months for navigation.
9
9
  */
10
- export declare function getNavMonths(props: Pick<DayPickerProps, "captionLayout" | "endMonth" | "startMonth" | "today" | "timeZone" | "fromMonth" | "fromYear" | "toMonth" | "toYear">, dateLib: DateLib): [start: Date | undefined, end: Date | undefined];
10
+ export declare function getNavMonths(props: Pick<DayPickerProps, "captionLayout" | "endMonth" | "startMonth" | "today" | "timeZone">, dateLib: DateLib): [start: Date | undefined, end: Date | undefined];
@@ -7,38 +7,18 @@
7
7
  */
8
8
  export function getNavMonths(props, dateLib) {
9
9
  let { startMonth, endMonth } = props;
10
- const { startOfYear, startOfDay, startOfMonth, endOfMonth, addYears, endOfYear, newDate, today, } = dateLib;
11
- // Handle deprecated code
12
- const { fromYear, toYear, fromMonth, toMonth } = props;
13
- if (!startMonth && fromMonth) {
14
- startMonth = fromMonth;
15
- }
16
- if (!startMonth && fromYear) {
17
- startMonth = dateLib.newDate(fromYear, 0, 1);
18
- }
19
- if (!endMonth && toMonth) {
20
- endMonth = toMonth;
21
- }
22
- if (!endMonth && toYear) {
23
- endMonth = newDate(toYear, 11, 31);
24
- }
10
+ const { startOfYear, startOfDay, startOfMonth, endOfMonth, addYears, endOfYear, today, } = dateLib;
25
11
  const hasYearDropdown = props.captionLayout === "dropdown" ||
26
12
  props.captionLayout === "dropdown-years";
27
13
  if (startMonth) {
28
14
  startMonth = startOfMonth(startMonth);
29
15
  }
30
- else if (fromYear) {
31
- startMonth = newDate(fromYear, 0, 1);
32
- }
33
16
  else if (!startMonth && hasYearDropdown) {
34
17
  startMonth = startOfYear(addYears(props.today ?? today(), -100));
35
18
  }
36
19
  if (endMonth) {
37
20
  endMonth = endOfMonth(endMonth);
38
21
  }
39
- else if (toYear) {
40
- endMonth = newDate(toYear, 11, 31);
41
- }
42
22
  else if (!endMonth && hasYearDropdown) {
43
23
  endMonth = endOfYear(props.today ?? today());
44
24
  }
@@ -0,0 +1,28 @@
1
+ import type { Locale } from "date-fns";
2
+ import React from "react";
3
+ import { DateLib, type DateLibOptions } from "../index.js";
4
+ import type { DayPickerProps } from "../types/props.js";
5
+ /**
6
+ * Render the Hijri (Umm al-Qura) calendar.
7
+ *
8
+ * Defaults:
9
+ *
10
+ * - `locale`: `ar-SA`
11
+ * - `dir`: `rtl`
12
+ * - `numerals`: `arab`
13
+ * - `startMonth`: `1924-08-01`
14
+ * - `endMonth`: `2077-11-16`
15
+ *
16
+ * Out-of-range date props are clamped to the supported Umm al-Qura conversion
17
+ * range, preventing runtime conversion errors.
18
+ */
19
+ export declare function DayPicker(props: DayPickerProps & {
20
+ locale?: Locale;
21
+ dir?: DayPickerProps["dir"];
22
+ numerals?: DayPickerProps["numerals"];
23
+ dateLib?: DayPickerProps["dateLib"];
24
+ }): React.JSX.Element;
25
+ /** Returns the date library used in the Hijri calendar. */
26
+ export declare const getDateLib: (options?: DateLibOptions) => DateLib;
27
+ export { arSA } from "../locale/ar-SA.js";
28
+ export { enUS } from "../locale/en-US.js";
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import { DateLib, DayPicker as DayPickerComponent, } from "../index.js";
3
+ import { arSA } from "../locale/ar-SA.js";
4
+ import * as hijriDateLib from "./lib/index.js";
5
+ import { clampGregorianDate, GREGORIAN_MAX_DATE, GREGORIAN_MIN_DATE, } from "./utils/range.js";
6
+ function clampDateProp(date) {
7
+ if (!date) {
8
+ return undefined;
9
+ }
10
+ return clampGregorianDate(date);
11
+ }
12
+ /**
13
+ * Render the Hijri (Umm al-Qura) calendar.
14
+ *
15
+ * Defaults:
16
+ *
17
+ * - `locale`: `ar-SA`
18
+ * - `dir`: `rtl`
19
+ * - `numerals`: `arab`
20
+ * - `startMonth`: `1924-08-01`
21
+ * - `endMonth`: `2077-11-16`
22
+ *
23
+ * Out-of-range date props are clamped to the supported Umm al-Qura conversion
24
+ * range, preventing runtime conversion errors.
25
+ */
26
+ export function DayPicker(props) {
27
+ const { dateLib: dateLibProp, ...dayPickerProps } = props;
28
+ const hasStartBound = props.startMonth !== undefined;
29
+ const hasEndBound = props.endMonth !== undefined;
30
+ const clampedProps = {
31
+ ...dayPickerProps,
32
+ month: clampDateProp(props.month),
33
+ defaultMonth: clampDateProp(props.defaultMonth),
34
+ today: clampDateProp(props.today),
35
+ startMonth: hasStartBound
36
+ ? clampDateProp(props.startMonth)
37
+ : new Date(GREGORIAN_MIN_DATE),
38
+ endMonth: hasEndBound
39
+ ? clampDateProp(props.endMonth)
40
+ : new Date(GREGORIAN_MAX_DATE),
41
+ };
42
+ return (React.createElement(DayPickerComponent, { ...clampedProps, locale: props.locale ?? arSA, numerals: props.numerals ?? "arab", dir: props.dir ?? "rtl", dateLib: { ...hijriDateLib, ...dateLibProp } }));
43
+ }
44
+ /** Returns the date library used in the Hijri calendar. */
45
+ export const getDateLib = (options) => {
46
+ return new DateLib(options, hijriDateLib);
47
+ };
48
+ export { arSA } from "../locale/ar-SA.js";
49
+ export { enUS } from "../locale/en-US.js";
@@ -0,0 +1 @@
1
+ export declare function addMonths(date: Date, amount: number): Date;
@@ -0,0 +1,6 @@
1
+ import { toHijriDate } from "../utils/conversion.js";
2
+ import { setMonth } from "./setMonth.js";
3
+ export function addMonths(date, amount) {
4
+ const hijri = toHijriDate(date);
5
+ return setMonth(date, hijri.monthIndex + amount);
6
+ }
@@ -0,0 +1 @@
1
+ export declare function addYears(date: Date, amount: number): Date;
@@ -0,0 +1,6 @@
1
+ import { toHijriDate } from "../utils/conversion.js";
2
+ import { setYear } from "./setYear.js";
3
+ export function addYears(date, amount) {
4
+ const hijri = toHijriDate(date);
5
+ return setYear(date, hijri.year + amount);
6
+ }
@@ -0,0 +1 @@
1
+ export declare function differenceInCalendarMonths(dateLeft: Date, dateRight: Date): number;
@@ -0,0 +1,7 @@
1
+ import { toHijriDate } from "../utils/conversion.js";
2
+ export function differenceInCalendarMonths(dateLeft, dateRight) {
3
+ const hijriLeft = toHijriDate(dateLeft);
4
+ const hijriRight = toHijriDate(dateRight);
5
+ return ((hijriLeft.year - hijriRight.year) * 12 +
6
+ (hijriLeft.monthIndex - hijriRight.monthIndex));
7
+ }
@@ -0,0 +1,2 @@
1
+ import { type Interval } from "date-fns";
2
+ export declare function eachMonthOfInterval(interval: Interval): Date[];
@@ -0,0 +1,26 @@
1
+ import { toDate } from "date-fns";
2
+ import { toGregorianDate, toHijriDate } from "../utils/conversion.js";
3
+ export function eachMonthOfInterval(interval) {
4
+ const start = toDate(interval.start);
5
+ const end = toDate(interval.end);
6
+ if (end.getTime() < start.getTime()) {
7
+ throw new RangeError("Invalid interval");
8
+ }
9
+ const startDate = toHijriDate(start);
10
+ const endDate = toHijriDate(end);
11
+ const months = [];
12
+ let currentYear = startDate.year;
13
+ let currentMonth = startDate.monthIndex;
14
+ const endYear = endDate.year;
15
+ const endMonth = endDate.monthIndex;
16
+ while (currentYear < endYear ||
17
+ (currentYear === endYear && currentMonth <= endMonth)) {
18
+ months.push(toGregorianDate({ year: currentYear, monthIndex: currentMonth, day: 1 }));
19
+ currentMonth += 1;
20
+ if (currentMonth > 11) {
21
+ currentMonth = 0;
22
+ currentYear += 1;
23
+ }
24
+ }
25
+ return months;
26
+ }
@@ -0,0 +1,2 @@
1
+ import { type Interval } from "date-fns";
2
+ export declare function eachYearOfInterval(interval: Interval): Date[];