react-day-picker 9.13.1 → 9.14.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 (115) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/DayPicker.js +1 -1
  3. package/dist/cjs/UI.d.ts +21 -14
  4. package/dist/cjs/UI.js +2 -2
  5. package/dist/cjs/hijri/index.d.ts +28 -0
  6. package/dist/cjs/hijri/index.js +98 -0
  7. package/dist/cjs/hijri/lib/addMonths.d.ts +1 -0
  8. package/dist/cjs/hijri/lib/addMonths.js +9 -0
  9. package/dist/cjs/hijri/lib/addYears.d.ts +1 -0
  10. package/dist/cjs/hijri/lib/addYears.js +9 -0
  11. package/dist/cjs/hijri/lib/differenceInCalendarMonths.d.ts +1 -0
  12. package/dist/cjs/hijri/lib/differenceInCalendarMonths.js +10 -0
  13. package/dist/cjs/hijri/lib/eachMonthOfInterval.d.ts +2 -0
  14. package/dist/cjs/hijri/lib/eachMonthOfInterval.js +29 -0
  15. package/dist/cjs/hijri/lib/eachYearOfInterval.d.ts +2 -0
  16. package/dist/cjs/hijri/lib/eachYearOfInterval.js +19 -0
  17. package/dist/cjs/hijri/lib/endOfMonth.d.ts +1 -0
  18. package/dist/cjs/hijri/lib/endOfMonth.js +14 -0
  19. package/dist/cjs/hijri/lib/endOfYear.d.ts +1 -0
  20. package/dist/cjs/hijri/lib/endOfYear.js +14 -0
  21. package/dist/cjs/hijri/lib/fallbackLocaleData.d.ts +5 -0
  22. package/dist/cjs/hijri/lib/fallbackLocaleData.js +111 -0
  23. package/dist/cjs/hijri/lib/format.d.ts +3 -0
  24. package/dist/cjs/hijri/lib/format.js +149 -0
  25. package/dist/cjs/hijri/lib/getMonth.d.ts +1 -0
  26. package/dist/cjs/hijri/lib/getMonth.js +7 -0
  27. package/dist/cjs/hijri/lib/getYear.d.ts +1 -0
  28. package/dist/cjs/hijri/lib/getYear.js +7 -0
  29. package/dist/cjs/hijri/lib/index.d.ts +17 -0
  30. package/dist/cjs/hijri/lib/index.js +33 -0
  31. package/dist/cjs/hijri/lib/isSameMonth.d.ts +1 -0
  32. package/dist/cjs/hijri/lib/isSameMonth.js +10 -0
  33. package/dist/cjs/hijri/lib/isSameYear.d.ts +1 -0
  34. package/dist/cjs/hijri/lib/isSameYear.js +9 -0
  35. package/dist/cjs/hijri/lib/newDate.d.ts +1 -0
  36. package/dist/cjs/hijri/lib/newDate.js +7 -0
  37. package/dist/cjs/hijri/lib/setMonth.d.ts +1 -0
  38. package/dist/cjs/hijri/lib/setMonth.js +27 -0
  39. package/dist/cjs/hijri/lib/setYear.d.ts +1 -0
  40. package/dist/cjs/hijri/lib/setYear.js +15 -0
  41. package/dist/cjs/hijri/lib/startOfMonth.d.ts +1 -0
  42. package/dist/cjs/hijri/lib/startOfMonth.js +12 -0
  43. package/dist/cjs/hijri/lib/startOfYear.d.ts +1 -0
  44. package/dist/cjs/hijri/lib/startOfYear.js +12 -0
  45. package/dist/cjs/hijri/utils/conversion.d.ts +5 -0
  46. package/dist/cjs/hijri/utils/conversion.js +40 -0
  47. package/dist/cjs/hijri/utils/daysInMonth.d.ts +1 -0
  48. package/dist/cjs/hijri/utils/daysInMonth.js +24 -0
  49. package/dist/cjs/hijri/utils/range.d.ts +21 -0
  50. package/dist/cjs/hijri/utils/range.js +104 -0
  51. package/dist/cjs/hijri/utils/types.d.ts +5 -0
  52. package/dist/cjs/hijri/utils/types.js +2 -0
  53. package/dist/cjs/locale/ja-Hira.js +1 -1
  54. package/dist/cjs/locale/se.js +2 -2
  55. package/dist/cjs/selection/useRange.js +22 -4
  56. package/dist/cjs/types/props.d.ts +27 -3
  57. package/dist/esm/DayPicker.js +1 -1
  58. package/dist/esm/UI.d.ts +21 -14
  59. package/dist/esm/UI.js +2 -2
  60. package/dist/esm/hijri/index.d.ts +28 -0
  61. package/dist/esm/hijri/index.js +55 -0
  62. package/dist/esm/hijri/lib/addMonths.d.ts +1 -0
  63. package/dist/esm/hijri/lib/addMonths.js +6 -0
  64. package/dist/esm/hijri/lib/addYears.d.ts +1 -0
  65. package/dist/esm/hijri/lib/addYears.js +6 -0
  66. package/dist/esm/hijri/lib/differenceInCalendarMonths.d.ts +1 -0
  67. package/dist/esm/hijri/lib/differenceInCalendarMonths.js +7 -0
  68. package/dist/esm/hijri/lib/eachMonthOfInterval.d.ts +2 -0
  69. package/dist/esm/hijri/lib/eachMonthOfInterval.js +26 -0
  70. package/dist/esm/hijri/lib/eachYearOfInterval.d.ts +2 -0
  71. package/dist/esm/hijri/lib/eachYearOfInterval.js +16 -0
  72. package/dist/esm/hijri/lib/endOfMonth.d.ts +1 -0
  73. package/dist/esm/hijri/lib/endOfMonth.js +11 -0
  74. package/dist/esm/hijri/lib/endOfYear.d.ts +1 -0
  75. package/dist/esm/hijri/lib/endOfYear.js +11 -0
  76. package/dist/esm/hijri/lib/fallbackLocaleData.d.ts +5 -0
  77. package/dist/esm/hijri/lib/fallbackLocaleData.js +105 -0
  78. package/dist/esm/hijri/lib/format.d.ts +3 -0
  79. package/dist/esm/hijri/lib/format.js +146 -0
  80. package/dist/esm/hijri/lib/getMonth.d.ts +1 -0
  81. package/dist/esm/hijri/lib/getMonth.js +4 -0
  82. package/dist/esm/hijri/lib/getYear.d.ts +1 -0
  83. package/dist/esm/hijri/lib/getYear.js +4 -0
  84. package/dist/esm/hijri/lib/index.d.ts +17 -0
  85. package/dist/esm/hijri/lib/index.js +17 -0
  86. package/dist/esm/hijri/lib/isSameMonth.d.ts +1 -0
  87. package/dist/esm/hijri/lib/isSameMonth.js +7 -0
  88. package/dist/esm/hijri/lib/isSameYear.d.ts +1 -0
  89. package/dist/esm/hijri/lib/isSameYear.js +6 -0
  90. package/dist/esm/hijri/lib/newDate.d.ts +1 -0
  91. package/dist/esm/hijri/lib/newDate.js +4 -0
  92. package/dist/esm/hijri/lib/setMonth.d.ts +1 -0
  93. package/dist/esm/hijri/lib/setMonth.js +24 -0
  94. package/dist/esm/hijri/lib/setYear.d.ts +1 -0
  95. package/dist/esm/hijri/lib/setYear.js +12 -0
  96. package/dist/esm/hijri/lib/startOfMonth.d.ts +1 -0
  97. package/dist/esm/hijri/lib/startOfMonth.js +9 -0
  98. package/dist/esm/hijri/lib/startOfYear.d.ts +1 -0
  99. package/dist/esm/hijri/lib/startOfYear.js +9 -0
  100. package/dist/esm/hijri/utils/conversion.d.ts +5 -0
  101. package/dist/esm/hijri/utils/conversion.js +36 -0
  102. package/dist/esm/hijri/utils/daysInMonth.d.ts +1 -0
  103. package/dist/esm/hijri/utils/daysInMonth.js +21 -0
  104. package/dist/esm/hijri/utils/range.d.ts +21 -0
  105. package/dist/esm/hijri/utils/range.js +96 -0
  106. package/dist/esm/hijri/utils/types.d.ts +5 -0
  107. package/dist/esm/hijri/utils/types.js +1 -0
  108. package/dist/esm/locale/ja-Hira.js +1 -1
  109. package/dist/esm/locale/se.js +2 -2
  110. package/dist/esm/selection/useRange.js +22 -4
  111. package/dist/esm/types/props.d.ts +27 -3
  112. package/hijri.d.ts +1 -0
  113. package/hijri.js +2 -0
  114. package/package.json +26 -13
  115. package/src/style.css.d.ts +3 -0
package/README.md CHANGED
@@ -18,7 +18,7 @@ See **[daypicker.dev](https://daypicker.dev)** for guides, examples and API refe
18
18
  - 🎨 Minimal design that can be [easily styled](https://daypicker.dev/docs/styling) with CSS or any CSS framework.
19
19
  - 📅 Supports [selections](https://daypicker.dev/docs/selection-modes) of single days, multiple days, ranges of days, or [custom selections](https://daypicker.dev/guides/custom-selections).
20
20
  - 🌍 Can be [localized](https://daypicker.dev/docs/localization) into any language and [time zones](https://daypicker.dev/docs/time-zone).
21
- - 🌐 Support for [ISO 8601](http://daypicker.dev/localization/iso-and-broadcast#iso-8601-calendar), [Persian](http://daypicker.dev/localization/persian), [Buddhist (Thai)](http://daypicker.dev/localization/buddhist), [Ethiopic](http://daypicker.dev/localization/ethiopic), [Hebrew](http://daypicker.dev/localization/hebrew) and [broadcast](http://daypicker.dev/localization/iso-and-broadcast#broadcast-calendar) calendar.
21
+ - 🌐 Support for [ISO 8601](http://daypicker.dev/localization/iso-and-broadcast#iso-8601-calendar), [Persian](http://daypicker.dev/localization/persian), [Hijri](http://daypicker.dev/localization/hijri), [Buddhist (Thai)](http://daypicker.dev/localization/buddhist), [Ethiopic](http://daypicker.dev/localization/ethiopic), [Hebrew](http://daypicker.dev/localization/hebrew) and [broadcast](http://daypicker.dev/localization/iso-and-broadcast#broadcast-calendar) calendar.
22
22
  - 🦮 Complies with WCAG 2.1 AA requirements for [accessibility](https://daypicker.dev/guides/accessibility).
23
23
  - ⚙️ [Customizable components](https://daypicker.dev/guides/custom-components) to extend the rendered elements.
24
24
  - 🔤 Easy integration [with input fields](https://daypicker.dev/guides/input-fields).
@@ -279,7 +279,7 @@ function DayPicker(initialProps) {
279
279
  formatters,
280
280
  };
281
281
  return (react_1.default.createElement(useDayPicker_js_1.dayPickerContext.Provider, { value: contextValue },
282
- react_1.default.createElement(components.Root, { rootRef: props.animate ? rootElRef : undefined, className: className, style: style, dir: props.dir, id: props.id, lang: props.lang, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
282
+ react_1.default.createElement(components.Root, { rootRef: props.animate ? rootElRef : undefined, className: className, style: style, dir: props.dir, id: props.id, lang: props.lang ?? locale.code, nonce: props.nonce, title: props.title, role: props.role, "aria-label": props["aria-label"], "aria-labelledby": props["aria-labelledby"], ...dataAttributes },
283
283
  react_1.default.createElement(components.Months, { className: classNames[UI_js_1.UI.Months], style: styles?.[UI_js_1.UI.Months] },
284
284
  !props.hideNavigation && !navLayout && (react_1.default.createElement(components.Nav, { "data-animated-nav": props.animate ? "true" : undefined, className: classNames[UI_js_1.UI.Nav], style: styles?.[UI_js_1.UI.Nav], "aria-label": labelNav(), onPreviousClick: handlePreviousClick, onNextClick: handleNextClick, previousMonth: previousMonth, nextMonth: nextMonth })),
285
285
  months.map((calendarMonth, displayIndex) => {
package/dist/cjs/UI.d.ts CHANGED
@@ -80,8 +80,8 @@ export declare enum DayFlag {
80
80
  today = "today"
81
81
  }
82
82
  /**
83
- * Enum representing selection states that can be applied to the {@link UI | UI.Day}
84
- * element in selection mode.
83
+ * Enum representing selection states that can be applied to the
84
+ * {@link UI | UI.Day} element in selection mode.
85
85
  */
86
86
  export declare enum SelectionState {
87
87
  /** The day is at the end of a selected range. */
@@ -131,14 +131,16 @@ export declare enum Animation {
131
131
  export type DeprecatedUI<T extends CSSProperties | string> = {
132
132
  /**
133
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}.
134
+ * replaced by {@link UI | UI.PreviousMonthButton} and
135
+ * {@link UI | UI.NextMonthButton}.
135
136
  *
136
137
  * @deprecated
137
138
  */
138
139
  button: T;
139
140
  /**
140
141
  * 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
+ * replaced by {@link UI | UI.PreviousMonthButton} and
143
+ * {@link UI | UI.NextMonthButton}.
142
144
  *
143
145
  * @deprecated
144
146
  */
@@ -200,25 +202,29 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
200
202
  */
201
203
  day_outside: T;
202
204
  /**
203
- * This element has been renamed to {@link SelectionState | SelectionState.range_end}.
205
+ * This element has been renamed to
206
+ * {@link SelectionState | SelectionState.range_end}.
204
207
  *
205
208
  * @deprecated
206
209
  */
207
210
  day_range_end: T;
208
211
  /**
209
- * This element has been renamed to {@link SelectionState | SelectionState.range_middle}.
212
+ * This element has been renamed to
213
+ * {@link SelectionState | SelectionState.range_middle}.
210
214
  *
211
215
  * @deprecated
212
216
  */
213
217
  day_range_middle: T;
214
218
  /**
215
- * This element has been renamed to {@link SelectionState | SelectionState.range_start}.
219
+ * This element has been renamed to
220
+ * {@link SelectionState | SelectionState.range_start}.
216
221
  *
217
222
  * @deprecated
218
223
  */
219
224
  day_range_start: T;
220
225
  /**
221
- * This element has been renamed to {@link SelectionState | SelectionState.selected}.
226
+ * This element has been renamed to
227
+ * {@link SelectionState | SelectionState.selected}.
222
228
  *
223
229
  * @deprecated
224
230
  */
@@ -230,8 +236,8 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
230
236
  */
231
237
  day_today: T;
232
238
  /**
233
- * This element has been removed. The dropdown icon is now {@link UI | UI.Chevron}
234
- * inside a {@link UI | UI.CaptionLabel}.
239
+ * This element has been removed. The dropdown icon is now
240
+ * {@link UI | UI.Chevron} inside a {@link UI | UI.CaptionLabel}.
235
241
  *
236
242
  * @deprecated
237
243
  */
@@ -293,8 +299,9 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
293
299
  */
294
300
  nav_button_previous: T;
295
301
  /**
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}.
302
+ * This element has been removed. The dropdown icon is now
303
+ * {@link UI | UI.Chevron} inside a {@link UI | UI.NextMonthButton} or a
304
+ * {@link UI | UI.PreviousMonthButton}.
298
305
  *
299
306
  * @deprecated
300
307
  */
@@ -318,8 +325,8 @@ export type DeprecatedUI<T extends CSSProperties | string> = {
318
325
  */
319
326
  tbody: T;
320
327
  /**
321
- * This element has been removed. The {@link UI | UI.Footer} is now a single element
322
- * below the months.
328
+ * This element has been removed. The {@link UI | UI.Footer} is now a single
329
+ * element below the months.
323
330
  *
324
331
  * @deprecated
325
332
  */
package/dist/cjs/UI.js CHANGED
@@ -84,8 +84,8 @@ var DayFlag;
84
84
  DayFlag["today"] = "today";
85
85
  })(DayFlag || (exports.DayFlag = DayFlag = {}));
86
86
  /**
87
- * Enum representing selection states that can be applied to the {@link UI | UI.Day}
88
- * element in selection mode.
87
+ * Enum representing selection states that can be applied to the
88
+ * {@link UI | UI.Day} element in selection mode.
89
89
  */
90
90
  var SelectionState;
91
91
  (function (SelectionState) {
@@ -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,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.enUS = exports.arSA = exports.getDateLib = void 0;
40
+ exports.DayPicker = DayPicker;
41
+ const react_1 = __importDefault(require("react"));
42
+ const index_js_1 = require("../index.js");
43
+ const ar_SA_js_1 = require("../locale/ar-SA.js");
44
+ const hijriDateLib = __importStar(require("./lib/index.js"));
45
+ const range_js_1 = require("./utils/range.js");
46
+ function clampDateProp(date) {
47
+ if (!date) {
48
+ return undefined;
49
+ }
50
+ return (0, range_js_1.clampGregorianDate)(date);
51
+ }
52
+ /**
53
+ * Render the Hijri (Umm al-Qura) calendar.
54
+ *
55
+ * Defaults:
56
+ *
57
+ * - `locale`: `ar-SA`
58
+ * - `dir`: `rtl`
59
+ * - `numerals`: `arab`
60
+ * - `startMonth`: `1924-08-01`
61
+ * - `endMonth`: `2077-11-16`
62
+ *
63
+ * Out-of-range date props are clamped to the supported Umm al-Qura conversion
64
+ * range, preventing runtime conversion errors.
65
+ */
66
+ function DayPicker(props) {
67
+ const { dateLib: dateLibProp, ...dayPickerProps } = props;
68
+ const hasStartBound = props.startMonth !== undefined ||
69
+ props.fromMonth !== undefined ||
70
+ props.fromYear !== undefined;
71
+ const hasEndBound = props.endMonth !== undefined ||
72
+ props.toMonth !== undefined ||
73
+ props.toYear !== undefined;
74
+ const clampedProps = {
75
+ ...dayPickerProps,
76
+ month: clampDateProp(props.month),
77
+ defaultMonth: clampDateProp(props.defaultMonth),
78
+ today: clampDateProp(props.today),
79
+ startMonth: hasStartBound
80
+ ? clampDateProp(props.startMonth)
81
+ : new Date(range_js_1.GREGORIAN_MIN_DATE),
82
+ endMonth: hasEndBound
83
+ ? clampDateProp(props.endMonth)
84
+ : new Date(range_js_1.GREGORIAN_MAX_DATE),
85
+ fromMonth: clampDateProp(props.fromMonth),
86
+ toMonth: clampDateProp(props.toMonth),
87
+ };
88
+ return (react_1.default.createElement(index_js_1.DayPicker, { ...clampedProps, locale: props.locale ?? ar_SA_js_1.arSA, numerals: props.numerals ?? "arab", dir: props.dir ?? "rtl", dateLib: { ...hijriDateLib, ...dateLibProp } }));
89
+ }
90
+ /** Returns the date library used in the Hijri calendar. */
91
+ const getDateLib = (options) => {
92
+ return new index_js_1.DateLib(options, hijriDateLib);
93
+ };
94
+ exports.getDateLib = getDateLib;
95
+ var ar_SA_js_2 = require("../locale/ar-SA.js");
96
+ Object.defineProperty(exports, "arSA", { enumerable: true, get: function () { return ar_SA_js_2.arSA; } });
97
+ var en_US_js_1 = require("../locale/en-US.js");
98
+ Object.defineProperty(exports, "enUS", { enumerable: true, get: function () { return en_US_js_1.enUS; } });
@@ -0,0 +1 @@
1
+ export declare function addMonths(date: Date, amount: number): Date;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMonths = addMonths;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ const setMonth_js_1 = require("./setMonth.js");
6
+ function addMonths(date, amount) {
7
+ const hijri = (0, conversion_js_1.toHijriDate)(date);
8
+ return (0, setMonth_js_1.setMonth)(date, hijri.monthIndex + amount);
9
+ }
@@ -0,0 +1 @@
1
+ export declare function addYears(date: Date, amount: number): Date;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addYears = addYears;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ const setYear_js_1 = require("./setYear.js");
6
+ function addYears(date, amount) {
7
+ const hijri = (0, conversion_js_1.toHijriDate)(date);
8
+ return (0, setYear_js_1.setYear)(date, hijri.year + amount);
9
+ }
@@ -0,0 +1 @@
1
+ export declare function differenceInCalendarMonths(dateLeft: Date, dateRight: Date): number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.differenceInCalendarMonths = differenceInCalendarMonths;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ function differenceInCalendarMonths(dateLeft, dateRight) {
6
+ const hijriLeft = (0, conversion_js_1.toHijriDate)(dateLeft);
7
+ const hijriRight = (0, conversion_js_1.toHijriDate)(dateRight);
8
+ return ((hijriLeft.year - hijriRight.year) * 12 +
9
+ (hijriLeft.monthIndex - hijriRight.monthIndex));
10
+ }
@@ -0,0 +1,2 @@
1
+ import { type Interval } from "date-fns";
2
+ export declare function eachMonthOfInterval(interval: Interval): Date[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eachMonthOfInterval = eachMonthOfInterval;
4
+ const date_fns_1 = require("date-fns");
5
+ const conversion_js_1 = require("../utils/conversion.js");
6
+ function eachMonthOfInterval(interval) {
7
+ const start = (0, date_fns_1.toDate)(interval.start);
8
+ const end = (0, date_fns_1.toDate)(interval.end);
9
+ if (end.getTime() < start.getTime()) {
10
+ throw new RangeError("Invalid interval");
11
+ }
12
+ const startDate = (0, conversion_js_1.toHijriDate)(start);
13
+ const endDate = (0, conversion_js_1.toHijriDate)(end);
14
+ const months = [];
15
+ let currentYear = startDate.year;
16
+ let currentMonth = startDate.monthIndex;
17
+ const endYear = endDate.year;
18
+ const endMonth = endDate.monthIndex;
19
+ while (currentYear < endYear ||
20
+ (currentYear === endYear && currentMonth <= endMonth)) {
21
+ months.push((0, conversion_js_1.toGregorianDate)({ year: currentYear, monthIndex: currentMonth, day: 1 }));
22
+ currentMonth += 1;
23
+ if (currentMonth > 11) {
24
+ currentMonth = 0;
25
+ currentYear += 1;
26
+ }
27
+ }
28
+ return months;
29
+ }
@@ -0,0 +1,2 @@
1
+ import { type Interval } from "date-fns";
2
+ export declare function eachYearOfInterval(interval: Interval): Date[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eachYearOfInterval = eachYearOfInterval;
4
+ const date_fns_1 = require("date-fns");
5
+ const conversion_js_1 = require("../utils/conversion.js");
6
+ function eachYearOfInterval(interval) {
7
+ const start = (0, date_fns_1.toDate)(interval.start);
8
+ const end = (0, date_fns_1.toDate)(interval.end);
9
+ if (end.getTime() < start.getTime()) {
10
+ return [];
11
+ }
12
+ const startYear = (0, conversion_js_1.toHijriDate)(start).year;
13
+ const endYear = (0, conversion_js_1.toHijriDate)(end).year;
14
+ const years = [];
15
+ for (let year = startYear; year <= endYear; year += 1) {
16
+ years.push((0, conversion_js_1.toGregorianDate)({ year, monthIndex: 0, day: 1 }));
17
+ }
18
+ return years;
19
+ }
@@ -0,0 +1 @@
1
+ export declare function endOfMonth(date: Date): Date;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.endOfMonth = endOfMonth;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ const daysInMonth_js_1 = require("../utils/daysInMonth.js");
6
+ function endOfMonth(date) {
7
+ const hijri = (0, conversion_js_1.toHijriDate)(date);
8
+ const day = (0, daysInMonth_js_1.getDaysInMonth)(hijri.year, hijri.monthIndex);
9
+ return (0, conversion_js_1.toGregorianDate)({
10
+ year: hijri.year,
11
+ monthIndex: hijri.monthIndex,
12
+ day,
13
+ });
14
+ }
@@ -0,0 +1 @@
1
+ export declare function endOfYear(date: Date): Date;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.endOfYear = endOfYear;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ const daysInMonth_js_1 = require("../utils/daysInMonth.js");
6
+ function endOfYear(date) {
7
+ const hijri = (0, conversion_js_1.toHijriDate)(date);
8
+ const day = (0, daysInMonth_js_1.getDaysInMonth)(hijri.year, 11);
9
+ return (0, conversion_js_1.toGregorianDate)({
10
+ year: hijri.year,
11
+ monthIndex: 11,
12
+ day,
13
+ });
14
+ }
@@ -0,0 +1,5 @@
1
+ export type FallbackLocaleCode = "ar" | "en";
2
+ export type IntlNameWidth = "long" | "short" | "narrow";
3
+ export declare const getFallbackLocaleCode: (localeCode: string) => FallbackLocaleCode;
4
+ export declare const getFallbackMonthName: (date: Date, localeCode: string, width: IntlNameWidth) => string;
5
+ export declare const getFallbackWeekdayName: (date: Date, localeCode: string, width: IntlNameWidth) => string;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFallbackWeekdayName = exports.getFallbackMonthName = exports.getFallbackLocaleCode = void 0;
4
+ const conversion_js_1 = require("../utils/conversion.js");
5
+ const fallbackMonthNames = {
6
+ en: {
7
+ long: [
8
+ "Muharram",
9
+ "Safar",
10
+ "Rabi I",
11
+ "Rabi II",
12
+ "Jumada I",
13
+ "Jumada II",
14
+ "Rajab",
15
+ "Shaban",
16
+ "Ramadan",
17
+ "Shawwal",
18
+ "Dhu al-Qadah",
19
+ "Dhu al-Hijjah",
20
+ ],
21
+ short: [
22
+ "Muh",
23
+ "Saf",
24
+ "Rab-I",
25
+ "Rab-II",
26
+ "Jum-I",
27
+ "Jum-II",
28
+ "Raj",
29
+ "Sha",
30
+ "Ram",
31
+ "Shw",
32
+ "Dhu-Q",
33
+ "Dhu-H",
34
+ ],
35
+ narrow: ["M", "S", "R", "R", "J", "J", "R", "S", "R", "S", "D", "D"],
36
+ },
37
+ ar: {
38
+ long: [
39
+ "محرم",
40
+ "صفر",
41
+ "ربيع الأول",
42
+ "ربيع الآخر",
43
+ "جمادى الأولى",
44
+ "جمادى الآخرة",
45
+ "رجب",
46
+ "شعبان",
47
+ "رمضان",
48
+ "شوال",
49
+ "ذو القعدة",
50
+ "ذو الحجة",
51
+ ],
52
+ short: [
53
+ "محرم",
54
+ "صفر",
55
+ "ربيع ١",
56
+ "ربيع ٢",
57
+ "جمادى ١",
58
+ "جمادى ٢",
59
+ "رجب",
60
+ "شعبان",
61
+ "رمضان",
62
+ "شوال",
63
+ "ذو القعدة",
64
+ "ذو الحجة",
65
+ ],
66
+ narrow: ["م", "ص", "ر", "ر", "ج", "ج", "ر", "ش", "ر", "ش", "ذ", "ذ"],
67
+ },
68
+ };
69
+ const fallbackWeekdayNames = {
70
+ en: {
71
+ long: [
72
+ "Sunday",
73
+ "Monday",
74
+ "Tuesday",
75
+ "Wednesday",
76
+ "Thursday",
77
+ "Friday",
78
+ "Saturday",
79
+ ],
80
+ short: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
81
+ narrow: ["S", "M", "T", "W", "T", "F", "S"],
82
+ },
83
+ ar: {
84
+ long: [
85
+ "الأحد",
86
+ "الاثنين",
87
+ "الثلاثاء",
88
+ "الأربعاء",
89
+ "الخميس",
90
+ "الجمعة",
91
+ "السبت",
92
+ ],
93
+ short: ["أحد", "اثن", "ثلا", "أرب", "خمي", "جمع", "سبت"],
94
+ narrow: ["ح", "ن", "ث", "ر", "خ", "ج", "س"],
95
+ },
96
+ };
97
+ const getFallbackLocaleCode = (localeCode) => {
98
+ return localeCode.toLowerCase().startsWith("ar") ? "ar" : "en";
99
+ };
100
+ exports.getFallbackLocaleCode = getFallbackLocaleCode;
101
+ const getFallbackMonthName = (date, localeCode, width) => {
102
+ const hijri = (0, conversion_js_1.toHijriDate)(date);
103
+ const locale = (0, exports.getFallbackLocaleCode)(localeCode);
104
+ return fallbackMonthNames[locale][width][hijri.monthIndex];
105
+ };
106
+ exports.getFallbackMonthName = getFallbackMonthName;
107
+ const getFallbackWeekdayName = (date, localeCode, width) => {
108
+ const locale = (0, exports.getFallbackLocaleCode)(localeCode);
109
+ return fallbackWeekdayNames[locale][width][date.getDay()];
110
+ };
111
+ exports.getFallbackWeekdayName = getFallbackWeekdayName;
@@ -0,0 +1,3 @@
1
+ import type { FormatOptions as DateFnsFormatOptions } from "date-fns";
2
+ /** Hijri calendar formatting override. */
3
+ export declare function format(date: Date, formatStr: string, options?: DateFnsFormatOptions): string;