@coreui/vue-pro 5.9.0 → 5.11.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 (198) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/components/accordion/CAccordionBody.js +2 -1
  3. package/dist/cjs/components/accordion/CAccordionBody.js.map +1 -1
  4. package/dist/cjs/components/accordion/CAccordionButton.js +3 -1
  5. package/dist/cjs/components/accordion/CAccordionButton.js.map +1 -1
  6. package/dist/cjs/components/accordion/CAccordionItem.d.ts +8 -0
  7. package/dist/cjs/components/accordion/CAccordionItem.js +10 -2
  8. package/dist/cjs/components/accordion/CAccordionItem.js.map +1 -1
  9. package/dist/cjs/components/button/CButton.js +1 -1
  10. package/dist/cjs/components/button/CButton.js.map +1 -1
  11. package/dist/cjs/components/calendar/CCalendar.d.ts +6 -6
  12. package/dist/cjs/components/calendar/CCalendar.js +44 -39
  13. package/dist/cjs/components/calendar/CCalendar.js.map +1 -1
  14. package/dist/cjs/components/calendar/types.d.ts +3 -0
  15. package/dist/cjs/components/calendar/utils.d.ts +183 -18
  16. package/dist/cjs/components/calendar/utils.js +327 -43
  17. package/dist/cjs/components/calendar/utils.js.map +1 -1
  18. package/dist/cjs/components/date-picker/CDatePicker.d.ts +1 -1
  19. package/dist/cjs/components/date-range-picker/CDateRangePicker.d.ts +1 -1
  20. package/dist/cjs/components/form/CFormControlWrapper.d.ts +2 -0
  21. package/dist/cjs/components/form/CFormControlWrapper.js +9 -1
  22. package/dist/cjs/components/form/CFormControlWrapper.js.map +1 -1
  23. package/dist/cjs/components/index.d.ts +2 -0
  24. package/dist/cjs/components/index.js +44 -36
  25. package/dist/cjs/components/index.js.map +1 -1
  26. package/dist/cjs/components/link/CLink.js.map +1 -1
  27. package/dist/cjs/components/loading-button/CLoadingButton.d.ts +2 -2
  28. package/dist/cjs/components/multi-select/CMultiSelect.d.ts +12 -0
  29. package/dist/cjs/components/multi-select/CMultiSelect.js +28 -2
  30. package/dist/cjs/components/multi-select/CMultiSelect.js.map +1 -1
  31. package/dist/cjs/components/nav/CNav.d.ts +2 -2
  32. package/dist/cjs/components/nav/CNav.js +3 -2
  33. package/dist/cjs/components/nav/CNav.js.map +1 -1
  34. package/dist/cjs/components/nav/CNavGroup.js +6 -2
  35. package/dist/cjs/components/nav/CNavGroup.js.map +1 -1
  36. package/dist/cjs/components/offcanvas/COffcanvas.js.map +1 -1
  37. package/dist/cjs/components/password-input/CPasswordInput.d.ts +190 -0
  38. package/dist/cjs/components/password-input/CPasswordInput.js +178 -0
  39. package/dist/cjs/components/password-input/CPasswordInput.js.map +1 -0
  40. package/dist/cjs/components/password-input/index.d.ts +6 -0
  41. package/dist/cjs/components/password-input/index.js +13 -0
  42. package/dist/cjs/components/password-input/index.js.map +1 -0
  43. package/dist/cjs/components/popover/CPopover.d.ts +1 -1
  44. package/dist/cjs/components/range-slider/CRangeSlider.js +6 -2
  45. package/dist/cjs/components/range-slider/CRangeSlider.js.map +1 -1
  46. package/dist/cjs/components/rating/CRating.d.ts +1 -1
  47. package/dist/cjs/components/smart-table/CSmartTable.js +2 -2
  48. package/dist/cjs/components/smart-table/CSmartTable.js.map +1 -1
  49. package/dist/cjs/components/smart-table/utils.js.map +1 -1
  50. package/dist/cjs/components/stepper/CStepper.d.ts +168 -0
  51. package/dist/cjs/components/stepper/CStepper.js +305 -0
  52. package/dist/cjs/components/stepper/CStepper.js.map +1 -0
  53. package/dist/cjs/components/stepper/index.d.ts +6 -0
  54. package/dist/cjs/components/stepper/index.js +13 -0
  55. package/dist/cjs/components/stepper/index.js.map +1 -0
  56. package/dist/cjs/components/stepper/types.d.ts +15 -0
  57. package/dist/cjs/components/tabs/CTab.js.map +1 -1
  58. package/dist/cjs/components/tabs/CTabList.d.ts +2 -2
  59. package/dist/cjs/components/tabs/CTabList.js +3 -2
  60. package/dist/cjs/components/tabs/CTabList.js.map +1 -1
  61. package/dist/cjs/components/time-picker/utils.d.ts +10 -0
  62. package/dist/cjs/components/time-picker/utils.js +25 -9
  63. package/dist/cjs/components/time-picker/utils.js.map +1 -1
  64. package/dist/cjs/components/tooltip/CTooltip.d.ts +1 -1
  65. package/dist/cjs/components/widgets/CWidgetStatsB.js +2 -2
  66. package/dist/cjs/components/widgets/CWidgetStatsB.js.map +1 -1
  67. package/dist/cjs/components/widgets/CWidgetStatsC.js +2 -2
  68. package/dist/cjs/components/widgets/CWidgetStatsC.js.map +1 -1
  69. package/dist/cjs/index.js +50 -42
  70. package/dist/cjs/index.js.map +1 -1
  71. package/dist/cjs/node_modules/vue-types/dist/index.js +567 -0
  72. package/dist/cjs/node_modules/vue-types/dist/index.js.map +1 -0
  73. package/dist/cjs/node_modules/vue-types/dist/shared/vue-types.8139b772.js +29 -0
  74. package/dist/cjs/node_modules/vue-types/dist/shared/vue-types.8139b772.js.map +1 -0
  75. package/dist/cjs/utils/getNextActiveElement.js.map +1 -1
  76. package/dist/cjs/utils/index.d.ts +2 -1
  77. package/dist/cjs/utils/isEqual.d.ts +2 -0
  78. package/dist/cjs/utils/isEqual.js +78 -0
  79. package/dist/cjs/utils/isEqual.js.map +1 -0
  80. package/dist/esm/components/accordion/CAccordionBody.js +2 -1
  81. package/dist/esm/components/accordion/CAccordionBody.js.map +1 -1
  82. package/dist/esm/components/accordion/CAccordionButton.js +3 -1
  83. package/dist/esm/components/accordion/CAccordionButton.js.map +1 -1
  84. package/dist/esm/components/accordion/CAccordionItem.d.ts +8 -0
  85. package/dist/esm/components/accordion/CAccordionItem.js +11 -3
  86. package/dist/esm/components/accordion/CAccordionItem.js.map +1 -1
  87. package/dist/esm/components/avatar/CAvatar.js +1 -1
  88. package/dist/esm/components/badge/CBadge.js +1 -1
  89. package/dist/esm/components/button/CButton.js +2 -2
  90. package/dist/esm/components/button/CButton.js.map +1 -1
  91. package/dist/esm/components/calendar/CCalendar.d.ts +6 -6
  92. package/dist/esm/components/calendar/CCalendar.js +46 -41
  93. package/dist/esm/components/calendar/CCalendar.js.map +1 -1
  94. package/dist/esm/components/calendar/types.d.ts +3 -0
  95. package/dist/esm/components/calendar/utils.d.ts +183 -18
  96. package/dist/esm/components/calendar/utils.js +320 -44
  97. package/dist/esm/components/calendar/utils.js.map +1 -1
  98. package/dist/esm/components/card/CCard.js +1 -1
  99. package/dist/esm/components/date-picker/CDatePicker.d.ts +1 -1
  100. package/dist/esm/components/date-range-picker/CDateRangePicker.d.ts +1 -1
  101. package/dist/esm/components/dropdown/CDropdownToggle.js +2 -2
  102. package/dist/esm/components/form/CFormControlWrapper.d.ts +2 -0
  103. package/dist/esm/components/form/CFormControlWrapper.js +9 -1
  104. package/dist/esm/components/form/CFormControlWrapper.js.map +1 -1
  105. package/dist/esm/components/index.d.ts +2 -0
  106. package/dist/esm/components/index.js +4 -0
  107. package/dist/esm/components/index.js.map +1 -1
  108. package/dist/esm/components/link/CLink.js.map +1 -1
  109. package/dist/esm/components/loading-button/CLoadingButton.d.ts +2 -2
  110. package/dist/esm/components/multi-select/CMultiSelect.d.ts +12 -0
  111. package/dist/esm/components/multi-select/CMultiSelect.js +29 -3
  112. package/dist/esm/components/multi-select/CMultiSelect.js.map +1 -1
  113. package/dist/esm/components/nav/CNav.d.ts +2 -2
  114. package/dist/esm/components/nav/CNav.js +3 -2
  115. package/dist/esm/components/nav/CNav.js.map +1 -1
  116. package/dist/esm/components/nav/CNavGroup.js +6 -2
  117. package/dist/esm/components/nav/CNavGroup.js.map +1 -1
  118. package/dist/esm/components/offcanvas/COffcanvas.js.map +1 -1
  119. package/dist/esm/components/password-input/CPasswordInput.d.ts +190 -0
  120. package/dist/esm/components/password-input/CPasswordInput.js +176 -0
  121. package/dist/esm/components/password-input/CPasswordInput.js.map +1 -0
  122. package/dist/esm/components/password-input/index.d.ts +6 -0
  123. package/dist/esm/components/password-input/index.js +10 -0
  124. package/dist/esm/components/password-input/index.js.map +1 -0
  125. package/dist/esm/components/popover/CPopover.d.ts +1 -1
  126. package/dist/esm/components/range-slider/CRangeSlider.js +6 -2
  127. package/dist/esm/components/range-slider/CRangeSlider.js.map +1 -1
  128. package/dist/esm/components/rating/CRating.d.ts +1 -1
  129. package/dist/esm/components/smart-table/CSmartTable.js +2 -2
  130. package/dist/esm/components/smart-table/CSmartTable.js.map +1 -1
  131. package/dist/esm/components/smart-table/CSmartTableBody.js +1 -1
  132. package/dist/esm/components/smart-table/utils.js.map +1 -1
  133. package/dist/esm/components/stepper/CStepper.d.ts +168 -0
  134. package/dist/esm/components/stepper/CStepper.js +303 -0
  135. package/dist/esm/components/stepper/CStepper.js.map +1 -0
  136. package/dist/esm/components/stepper/index.d.ts +6 -0
  137. package/dist/esm/components/stepper/index.js +10 -0
  138. package/dist/esm/components/stepper/index.js.map +1 -0
  139. package/dist/esm/components/stepper/types.d.ts +15 -0
  140. package/dist/esm/components/tabs/CTab.js.map +1 -1
  141. package/dist/esm/components/tabs/CTabList.d.ts +2 -2
  142. package/dist/esm/components/tabs/CTabList.js +3 -2
  143. package/dist/esm/components/tabs/CTabList.js.map +1 -1
  144. package/dist/esm/components/time-picker/utils.d.ts +10 -0
  145. package/dist/esm/components/time-picker/utils.js +25 -10
  146. package/dist/esm/components/time-picker/utils.js.map +1 -1
  147. package/dist/esm/components/tooltip/CTooltip.d.ts +1 -1
  148. package/dist/esm/components/widgets/CWidgetStatsB.js +2 -2
  149. package/dist/esm/components/widgets/CWidgetStatsB.js.map +1 -1
  150. package/dist/esm/components/widgets/CWidgetStatsC.js +2 -2
  151. package/dist/esm/components/widgets/CWidgetStatsC.js.map +1 -1
  152. package/dist/esm/index.js +4 -0
  153. package/dist/esm/index.js.map +1 -1
  154. package/dist/esm/node_modules/vue-types/dist/index.js +541 -0
  155. package/dist/esm/node_modules/vue-types/dist/index.js.map +1 -0
  156. package/dist/esm/node_modules/vue-types/dist/shared/vue-types.8139b772.js +25 -0
  157. package/dist/esm/node_modules/vue-types/dist/shared/vue-types.8139b772.js.map +1 -0
  158. package/dist/esm/utils/getNextActiveElement.js.map +1 -1
  159. package/dist/esm/utils/index.d.ts +2 -1
  160. package/dist/esm/utils/isEqual.d.ts +2 -0
  161. package/dist/esm/utils/isEqual.js +74 -0
  162. package/dist/esm/utils/isEqual.js.map +1 -0
  163. package/package.json +10 -10
  164. package/src/components/accordion/CAccordionBody.ts +2 -1
  165. package/src/components/accordion/CAccordionButton.ts +3 -1
  166. package/src/components/accordion/CAccordionItem.ts +11 -3
  167. package/src/components/button/CButton.ts +1 -1
  168. package/src/components/calendar/CCalendar.ts +108 -95
  169. package/src/components/calendar/types.ts +5 -0
  170. package/src/components/calendar/utils.ts +439 -111
  171. package/src/components/date-picker/CDatePicker.ts +1 -1
  172. package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
  173. package/src/components/form/CFormControlWrapper.ts +35 -21
  174. package/src/components/index.ts +2 -0
  175. package/src/components/multi-select/CMultiSelect.ts +57 -26
  176. package/src/components/nav/CNav.ts +3 -2
  177. package/src/components/nav/CNavGroup.ts +7 -2
  178. package/src/components/password-input/CPasswordInput.ts +214 -0
  179. package/src/components/password-input/index.ts +10 -0
  180. package/src/components/range-slider/CRangeSlider.ts +7 -2
  181. package/src/components/stepper/CStepper.ts +384 -0
  182. package/src/components/stepper/__tests__/CStepper.spec.ts +175 -0
  183. package/src/components/stepper/index.ts +10 -0
  184. package/src/components/stepper/types.ts +18 -0
  185. package/src/components/tabs/CTabList.ts +3 -2
  186. package/src/components/time-picker/CTimePicker.ts +22 -22
  187. package/src/components/time-picker/CTimePickerRollCol.ts +3 -3
  188. package/src/components/time-picker/utils.ts +30 -13
  189. package/src/utils/index.ts +10 -1
  190. package/src/utils/isEqual.ts +75 -0
  191. package/dist/cjs/node_modules/is-plain-object/dist/is-plain-object.js +0 -37
  192. package/dist/cjs/node_modules/is-plain-object/dist/is-plain-object.js.map +0 -1
  193. package/dist/cjs/node_modules/vue-types/dist/vue-types.modern.js +0 -33
  194. package/dist/cjs/node_modules/vue-types/dist/vue-types.modern.js.map +0 -1
  195. package/dist/esm/node_modules/is-plain-object/dist/is-plain-object.js +0 -35
  196. package/dist/esm/node_modules/is-plain-object/dist/is-plain-object.js.map +0 -1
  197. package/dist/esm/node_modules/vue-types/dist/vue-types.modern.js +0 -6
  198. package/dist/esm/node_modules/vue-types/dist/vue-types.modern.js.map +0 -1
@@ -1,17 +1,83 @@
1
- import type { DisabledDate } from './CCalendar';
1
+ import type { DisabledDate, SelectionTypes, ViewTypes } from './types';
2
+ /**
3
+ * Converts an ISO week string to a Date object representing the Monday of that week.
4
+ * @param isoWeek - The ISO week string (e.g., "2023W05" or "2023w05").
5
+ * @returns The Date object for the Monday of the specified week, or null if invalid.
6
+ */
2
7
  export declare const convertIsoWeekToDate: (isoWeek: string) => Date;
3
- export declare const convertToDateObject: (date: Date | string, selectionType?: "day" | "week" | "month" | "year") => Date;
4
- export declare const convertToLocalDate: (d: Date, locale: string, options?: {}) => string;
5
- export declare const convertToLocalTime: (d: Date, locale: string, options?: {}) => string;
8
+ /**
9
+ * Converts a date string or Date object to a Date object based on selection type.
10
+ * @param date - The date to convert.
11
+ * @param selectionType - The type of selection ('day', 'week', 'month', 'year').
12
+ * @returns The corresponding Date object or null if invalid.
13
+ */
14
+ export declare const convertToDateObject: (date: Date | string, selectionType?: SelectionTypes) => Date;
15
+ /**
16
+ * Creates groups from an array.
17
+ * @param arr - The array to group.
18
+ * @param numberOfGroups - Number of groups to create.
19
+ * @returns An array of grouped arrays.
20
+ */
6
21
  export declare const createGroupsInArray: <T>(arr: T[], numberOfGroups: number) => T[][];
7
- export declare const getCalendarDate: (calendarDate: Date, order: number, view: "days" | "months" | "years") => Date;
8
- export declare const getCurrentYear: () => number;
9
- export declare const getCurrentMonth: () => number;
10
- export declare const getDateBySelectionType: (date: Date | null, selectionType: "day" | "week" | "month" | "year") => string | Date | null;
11
- export declare const getMonthName: (month: number, locale: string) => string;
12
- export declare const getMonthsNames: (locale: string) => string[];
13
- export declare const getYears: (year: number) => number[];
22
+ /**
23
+ * Adjusts the calendar date based on order and view type.
24
+ * @param calendarDate - The current calendar date.
25
+ * @param order - The order to adjust by.
26
+ * @param view - The current view type.
27
+ * @returns The adjusted Date object.
28
+ */
29
+ export declare const getCalendarDate: (calendarDate: Date, order: number, view: ViewTypes) => Date;
30
+ /**
31
+ * Formats a date based on the selection type.
32
+ * @param date - The date to format.
33
+ * @param selectionType - The type of selection ('day', 'week', 'month', 'year').
34
+ * @returns A formatted date string or the original Date object.
35
+ */
36
+ export declare const getDateBySelectionType: (date: Date | null, selectionType: SelectionTypes) => string | Date | null;
37
+ /**
38
+ * Retrieves the first available date within a range that is not disabled.
39
+ * @param startDate - Start date of the range.
40
+ * @param endDate - End date of the range.
41
+ * @param min - Minimum allowed date.
42
+ * @param max - Maximum allowed date.
43
+ * @param disabledDates - Criteria for disabled dates.
44
+ * @returns The first available Date object or null if none found.
45
+ */
46
+ export declare const getFirstAvailableDateInRange: (startDate: Date, endDate: Date, min?: Date | null, max?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => Date | null;
47
+ /**
48
+ * Retrieves an array of month names based on locale and format.
49
+ * @param locale - The locale string (e.g., 'en-US').
50
+ * @param format - The format of the month names ('short' or 'long').
51
+ * @returns An array of month names.
52
+ */
53
+ export declare const getMonthsNames: (locale: string, format?: "short" | "long") => string[];
54
+ /**
55
+ * Retrieves an array of selectable dates from the given element.
56
+ * @param element - The HTML element to search for selectable dates.
57
+ * @param selector - The CSS selector used to identify selectable dates. Defaults to 'tr[tabindex="0"], td[tabindex="0"]'.
58
+ * @returns An array of HTMLElements representing the selectable dates.
59
+ */
60
+ export declare const getSelectableDates: (element: HTMLElement, selector?: string) => HTMLElement[];
61
+ /**
62
+ * Generates an array of years centered around a given year.
63
+ * @param year - The central year.
64
+ * @param range - The number of years before and after the central year.
65
+ * @returns An array of years.
66
+ */
67
+ export declare const getYears: (year: number, range?: number) => number[];
68
+ /**
69
+ * Calculates the ISO week number for a given date.
70
+ * @param date - The date to calculate the week number for.
71
+ * @returns The ISO week number.
72
+ */
14
73
  export declare const getWeekNumber: (date: Date) => number;
74
+ /**
75
+ * Retrieves detailed information about each week in a month for calendar rendering.
76
+ * @param year - The year.
77
+ * @param month - The month (0-11).
78
+ * @param firstDayOfWeek - The first day of the week (0-6, where 0 is Sunday).
79
+ * @returns An array of week objects containing week numbers and day details.
80
+ */
15
81
  export declare const getMonthDetails: (year: number, month: number, firstDayOfWeek: number) => {
16
82
  weekNumber?: number;
17
83
  days: {
@@ -19,14 +85,113 @@ export declare const getMonthDetails: (year: number, month: number, firstDayOfWe
19
85
  month: string;
20
86
  }[];
21
87
  }[];
22
- export declare const isDisableDateInRange: (startDate?: Date | null, endDate?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => boolean;
88
+ /**
89
+ * Checks if a date is disabled based on the 'date' period type.
90
+ * @param date - The date to check.
91
+ * @param min - Minimum allowed date.
92
+ * @param max - Maximum allowed date.
93
+ * @param disabledDates - Criteria for disabled dates.
94
+ * @returns True if the date is disabled, false otherwise.
95
+ */
23
96
  export declare const isDateDisabled: (date: Date, min?: Date | null, max?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => boolean;
24
- export declare const isDateInRange: (date: Date, start: Date | null, end: Date | null) => boolean | null;
25
- export declare const isDateSelected: (date: Date, start: Date | null, end: Date | null) => boolean | null;
26
- export declare const isEndDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
27
- export declare const isLastDayOfMonth: (date: Date) => boolean;
97
+ /**
98
+ * Checks if a date is within a specified range.
99
+ * @param date - The date to check.
100
+ * @param start - Start date of the range.
101
+ * @param end - End date of the range.
102
+ * @returns True if the date is within the range, false otherwise.
103
+ */
104
+ export declare const isDateInRange: (date: Date, start: Date | null, end: Date | null) => boolean;
105
+ /**
106
+ * Checks if a date is selected based on start and end dates.
107
+ * @param date - The date to check.
108
+ * @param start - Start date.
109
+ * @param end - End date.
110
+ * @returns True if the date is selected, false otherwise.
111
+ */
112
+ export declare const isDateSelected: (date: Date, start: Date | null, end: Date | null) => boolean;
113
+ /**
114
+ * Determines if any date within a range is disabled.
115
+ * @param startDate - Start date of the range.
116
+ * @param endDate - End date of the range.
117
+ * @param disabledDates - Criteria for disabled dates.
118
+ * @returns True if any date in the range is disabled, false otherwise.
119
+ */
120
+ export declare const isDisableDateInRange: (startDate?: Date | null, endDate?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => boolean;
121
+ /**
122
+ * Checks if a month is disabled based on the 'month' period type.
123
+ * @param date - The date representing the month to check.
124
+ * @param min - Minimum allowed date.
125
+ * @param max - Maximum allowed date.
126
+ * @param disabledDates - Criteria for disabled dates.
127
+ * @returns True if the month is disabled, false otherwise.
128
+ */
129
+ export declare const isMonthDisabled: (date: Date, min?: Date | null, max?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => boolean;
130
+ /**
131
+ * Checks if a month is selected based on start and end dates.
132
+ * @param date - The date representing the month.
133
+ * @param start - Start date.
134
+ * @param end - End date.
135
+ * @returns True if the month is selected, false otherwise.
136
+ */
137
+ export declare const isMonthSelected: (date: Date, start: Date | null, end: Date | null) => boolean;
138
+ /**
139
+ * Checks if a month is within a specified range.
140
+ * @param date - The date representing the month.
141
+ * @param start - Start date.
142
+ * @param end - End date.
143
+ * @returns True if the month is within the range, false otherwise.
144
+ */
145
+ export declare const isMonthInRange: (date: Date, start: Date | null, end: Date | null) => boolean;
146
+ /**
147
+ * Checks if two dates are the same calendar date.
148
+ * @param date - First date.
149
+ * @param date2 - Second date.
150
+ * @returns True if both dates are the same, false otherwise.
151
+ */
28
152
  export declare const isSameDateAs: (date: Date | null, date2: Date | null) => boolean;
29
- export declare const isStartDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
153
+ /**
154
+ * Checks if a date is today.
155
+ * @param date - The date to check.
156
+ * @returns True if the date is today, false otherwise.
157
+ */
30
158
  export declare const isToday: (date: Date) => boolean;
31
- export declare const isValidDate: (date: string) => number | false;
159
+ /**
160
+ * Checks if a year is disabled based on the 'year' period type.
161
+ * @param date - The date representing the year to check.
162
+ * @param min - Minimum allowed date.
163
+ * @param max - Maximum allowed date.
164
+ * @param disabledDates - Criteria for disabled dates.
165
+ * @returns True if the year is disabled, false otherwise.
166
+ */
167
+ export declare const isYearDisabled: (date: Date, min?: Date | null, max?: Date | null, disabledDates?: DisabledDate | DisabledDate[]) => boolean;
168
+ /**
169
+ * Checks if a year is selected based on start and end dates.
170
+ * @param date - The date representing the year.
171
+ * @param start - Start date.
172
+ * @param end - End date.
173
+ * @returns True if the year matches the start's or end's year, false otherwise.
174
+ */
175
+ export declare const isYearSelected: (date: Date, start: Date | null, end: Date | null) => boolean;
176
+ /**
177
+ * Checks if a year is within a specified range.
178
+ * @param date - The date representing the year.
179
+ * @param start - Start date.
180
+ * @param end - End date.
181
+ * @returns True if the year's value lies between start's year and end's year, false otherwise.
182
+ */
183
+ export declare const isYearInRange: (date: Date, start: Date | null, end: Date | null) => boolean;
184
+ /**
185
+ * Removes the time component from a Date object.
186
+ * @param date - The original date.
187
+ * @returns A new Date object with the time set to 00:00:00.
188
+ */
32
189
  export declare const removeTimeFromDate: (date: Date) => Date;
190
+ /**
191
+ * Copies the time (hours, minutes, seconds, milliseconds) from one Date to another.
192
+ *
193
+ * @param {Date} target - The date whose time will be updated.
194
+ * @param {Date | null} source - The date to copy the time from.
195
+ * @returns {Date} A new Date instance with the date from `target` and time from `source`.
196
+ */
197
+ export declare const setTimeFromDate: (target: Date, source: Date | null) => Date;
@@ -1,11 +1,20 @@
1
+ /**
2
+ * Converts an ISO week string to a Date object representing the Monday of that week.
3
+ * @param isoWeek - The ISO week string (e.g., "2023W05" or "2023w05").
4
+ * @returns The Date object for the Monday of the specified week, or null if invalid.
5
+ */
1
6
  const convertIsoWeekToDate = (isoWeek) => {
2
- const [year, week] = isoWeek.split(/w/i);
3
- // Get date for 4th of January for year
4
- const date = new Date(Number(year), 0, 4);
5
- // Get previous Monday, add 7 days for each week after first
7
+ const [year, week] = isoWeek.split(/[Ww]/);
8
+ const date = new Date(Number(year), 0, 4); // 4th Jan is always in week 1
6
9
  date.setDate(date.getDate() - (date.getDay() || 7) + 1 + (Number(week) - 1) * 7);
7
10
  return date;
8
11
  };
12
+ /**
13
+ * Converts a date string or Date object to a Date object based on selection type.
14
+ * @param date - The date to convert.
15
+ * @param selectionType - The type of selection ('day', 'week', 'month', 'year').
16
+ * @returns The corresponding Date object or null if invalid.
17
+ */
9
18
  const convertToDateObject = (date, selectionType) => {
10
19
  if (date instanceof Date) {
11
20
  return date;
@@ -20,12 +29,25 @@ const convertToDateObject = (date, selectionType) => {
20
29
  }
21
30
  return new Date(Date.parse(date));
22
31
  };
32
+ /**
33
+ * Creates groups from an array.
34
+ * @param arr - The array to group.
35
+ * @param numberOfGroups - Number of groups to create.
36
+ * @returns An array of grouped arrays.
37
+ */
23
38
  const createGroupsInArray = (arr, numberOfGroups) => {
24
39
  const perGroup = Math.ceil(arr.length / numberOfGroups);
25
40
  return Array.from({ length: numberOfGroups })
26
41
  .fill('')
27
42
  .map((_, i) => arr.slice(i * perGroup, (i + 1) * perGroup));
28
43
  };
44
+ /**
45
+ * Adjusts the calendar date based on order and view type.
46
+ * @param calendarDate - The current calendar date.
47
+ * @param order - The order to adjust by.
48
+ * @param view - The current view type.
49
+ * @returns The adjusted Date object.
50
+ */
29
51
  const getCalendarDate = (calendarDate, order, view) => {
30
52
  if (order !== 0 && view === 'days') {
31
53
  return new Date(calendarDate.getFullYear(), calendarDate.getMonth() + order, 1);
@@ -38,6 +60,12 @@ const getCalendarDate = (calendarDate, order, view) => {
38
60
  }
39
61
  return calendarDate;
40
62
  };
63
+ /**
64
+ * Formats a date based on the selection type.
65
+ * @param date - The date to format.
66
+ * @param selectionType - The type of selection ('day', 'week', 'month', 'year').
67
+ * @returns A formatted date string or the original Date object.
68
+ */
41
69
  const getDateBySelectionType = (date, selectionType) => {
42
70
  if (date === null) {
43
71
  return null;
@@ -54,23 +82,42 @@ const getDateBySelectionType = (date, selectionType) => {
54
82
  }
55
83
  return date;
56
84
  };
57
- const getMonthsNames = (locale) => {
58
- const months = [];
59
- const d = new Date();
60
- d.setDate(1);
61
- for (let i = 0; i < 12; i++) {
62
- d.setMonth(i);
63
- months.push(d.toLocaleString(locale, { month: 'short' }));
64
- }
65
- return months;
85
+ /**
86
+ * Retrieves an array of month names based on locale and format.
87
+ * @param locale - The locale string (e.g., 'en-US').
88
+ * @param format - The format of the month names ('short' or 'long').
89
+ * @returns An array of month names.
90
+ */
91
+ const getMonthsNames = (locale, format = 'short') => {
92
+ return Array.from({ length: 12 }, (_, i) => {
93
+ return new Date(2000, i, 1).toLocaleString(locale, { month: format });
94
+ });
66
95
  };
67
- const getYears = (year) => {
68
- const years = [];
69
- for (let _year = year - 6; _year < year + 6; _year++) {
70
- years.push(_year);
71
- }
72
- return years;
96
+ /**
97
+ * Retrieves an array of selectable dates from the given element.
98
+ * @param element - The HTML element to search for selectable dates.
99
+ * @param selector - The CSS selector used to identify selectable dates. Defaults to 'tr[tabindex="0"], td[tabindex="0"]'.
100
+ * @returns An array of HTMLElements representing the selectable dates.
101
+ */
102
+ const getSelectableDates = (element, selector = 'tr[tabindex="0"], td[tabindex="0"]') => {
103
+ return [...Element.prototype.querySelectorAll.call(element, selector)];
73
104
  };
105
+ /**
106
+ * Generates an array of years centered around a given year.
107
+ * @param year - The central year.
108
+ * @param range - The number of years before and after the central year.
109
+ * @returns An array of years.
110
+ */
111
+ const getYears = (year, range = 6) => {
112
+ return Array.from({ length: range * 2 }, (_, i) => year - range + i);
113
+ };
114
+ /**
115
+ * Retrieves leading days (from the previous month) for a calendar view.
116
+ * @param year - The year.
117
+ * @param month - The month (0-11).
118
+ * @param firstDayOfWeek - The first day of the week (0-6, where 0 is Sunday).
119
+ * @returns An array of leading day objects.
120
+ */
74
121
  const getLeadingDays = (year, month, firstDayOfWeek) => {
75
122
  // 0: sunday
76
123
  // 1: monday
@@ -91,6 +138,12 @@ const getLeadingDays = (year, month, firstDayOfWeek) => {
91
138
  }
92
139
  return dates;
93
140
  };
141
+ /**
142
+ * Retrieves all days within a specific month.
143
+ * @param year - The year.
144
+ * @param month - The month (0-11).
145
+ * @returns An array of day objects.
146
+ */
94
147
  const getMonthDays = (year, month) => {
95
148
  const dates = [];
96
149
  const lastDay = new Date(year, month + 1, 0).getDate();
@@ -102,6 +155,14 @@ const getMonthDays = (year, month) => {
102
155
  }
103
156
  return dates;
104
157
  };
158
+ /**
159
+ * Retrieves trailing days (from the next month) for a calendar view.
160
+ * @param year - The year.
161
+ * @param month - The month (0-11).
162
+ * @param leadingDays - Array of leading day objects.
163
+ * @param monthDays - Array of current month day objects.
164
+ * @returns An array of trailing day objects.
165
+ */
105
166
  const getTrailingDays = (year, month, leadingDays, monthDays) => {
106
167
  const dates = [];
107
168
  const days = 42 - (leadingDays.length + monthDays.length);
@@ -113,11 +174,28 @@ const getTrailingDays = (year, month, leadingDays, monthDays) => {
113
174
  }
114
175
  return dates;
115
176
  };
177
+ /**
178
+ * Calculates the ISO week number for a given date.
179
+ * @param date - The date to calculate the week number for.
180
+ * @returns The ISO week number.
181
+ */
116
182
  const getWeekNumber = (date) => {
117
- const week1 = new Date(date.getFullYear(), 0, 4);
118
- return (1 +
119
- Math.round(((date.getTime() - week1.getTime()) / 86_400_000 - 3 + ((week1.getDay() + 6) % 7)) / 7));
183
+ const tempDate = new Date(date.getTime());
184
+ tempDate.setHours(0, 0, 0, 0);
185
+ // Thursday in current week decides the year
186
+ tempDate.setDate(tempDate.getDate() + 3 - ((tempDate.getDay() + 6) % 7));
187
+ const week1 = new Date(tempDate.getFullYear(), 0, 4);
188
+ // Calculate full weeks to the date
189
+ const weekNumber = 1 + Math.round((tempDate.getTime() - week1.getTime()) / 86_400_000 / 7);
190
+ return weekNumber;
120
191
  };
192
+ /**
193
+ * Retrieves detailed information about each week in a month for calendar rendering.
194
+ * @param year - The year.
195
+ * @param month - The month (0-11).
196
+ * @param firstDayOfWeek - The first day of the week (0-6, where 0 is Sunday).
197
+ * @returns An array of week objects containing week numbers and day details.
198
+ */
121
199
  const getMonthDetails = (year, month, firstDayOfWeek) => {
122
200
  const daysPrevMonth = getLeadingDays(year, month, firstDayOfWeek);
123
201
  const daysThisMonth = getMonthDays(year, month);
@@ -137,21 +215,14 @@ const getMonthDetails = (year, month, firstDayOfWeek) => {
137
215
  });
138
216
  return weeks;
139
217
  };
140
- const isDisableDateInRange = (startDate, endDate, disabledDates) => {
141
- if (startDate && endDate) {
142
- const date = new Date(startDate);
143
- let disabled = false;
144
- while (date < endDate) {
145
- date.setDate(date.getDate() + 1);
146
- if (isDateDisabled(date, null, null, disabledDates)) {
147
- disabled = true;
148
- break;
149
- }
150
- }
151
- return disabled;
152
- }
153
- return false;
154
- };
218
+ /**
219
+ * Checks if a date is disabled based on the 'date' period type.
220
+ * @param date - The date to check.
221
+ * @param min - Minimum allowed date.
222
+ * @param max - Maximum allowed date.
223
+ * @param disabledDates - Criteria for disabled dates.
224
+ * @returns True if the date is disabled, false otherwise.
225
+ */
155
226
  const isDateDisabled = (date, min, max, disabledDates) => {
156
227
  if (min && date < min) {
157
228
  return true;
@@ -159,6 +230,9 @@ const isDateDisabled = (date, min, max, disabledDates) => {
159
230
  if (max && date > max) {
160
231
  return true;
161
232
  }
233
+ if (disabledDates === undefined) {
234
+ return false;
235
+ }
162
236
  if (typeof disabledDates === 'function') {
163
237
  return disabledDates(date);
164
238
  }
@@ -180,15 +254,128 @@ const isDateDisabled = (date, min, max, disabledDates) => {
180
254
  }
181
255
  return false;
182
256
  };
257
+ /**
258
+ * Checks if a date is within a specified range.
259
+ * @param date - The date to check.
260
+ * @param start - Start date of the range.
261
+ * @param end - End date of the range.
262
+ * @returns True if the date is within the range, false otherwise.
263
+ */
183
264
  const isDateInRange = (date, start, end) => {
184
265
  const _date = removeTimeFromDate(date);
185
266
  const _start = start ? removeTimeFromDate(start) : null;
186
267
  const _end = end ? removeTimeFromDate(end) : null;
187
- return _start && _end && _start <= _date && _date <= _end;
268
+ return !!(_start && _end && _start <= _date && _date <= _end);
188
269
  };
270
+ /**
271
+ * Checks if a date is selected based on start and end dates.
272
+ * @param date - The date to check.
273
+ * @param start - Start date.
274
+ * @param end - End date.
275
+ * @returns True if the date is selected, false otherwise.
276
+ */
189
277
  const isDateSelected = (date, start, end) => {
190
- return (start && isSameDateAs(start, date)) || (end && isSameDateAs(end, date));
278
+ if (start !== null && isSameDateAs(start, date)) {
279
+ return true;
280
+ }
281
+ if (end !== null && isSameDateAs(end, date)) {
282
+ return true;
283
+ }
284
+ return false;
191
285
  };
286
+ /**
287
+ * Determines if any date within a range is disabled.
288
+ * @param startDate - Start date of the range.
289
+ * @param endDate - End date of the range.
290
+ * @param disabledDates - Criteria for disabled dates.
291
+ * @returns True if any date in the range is disabled, false otherwise.
292
+ */
293
+ const isDisableDateInRange = (startDate, endDate, disabledDates) => {
294
+ if (startDate && endDate) {
295
+ const date = new Date(startDate);
296
+ let disabled = false;
297
+ while (date < endDate) {
298
+ date.setDate(date.getDate() + 1);
299
+ if (isDateDisabled(date, null, null, disabledDates)) {
300
+ disabled = true;
301
+ break;
302
+ }
303
+ }
304
+ return disabled;
305
+ }
306
+ return false;
307
+ };
308
+ /**
309
+ * Checks if a month is disabled based on the 'month' period type.
310
+ * @param date - The date representing the month to check.
311
+ * @param min - Minimum allowed date.
312
+ * @param max - Maximum allowed date.
313
+ * @param disabledDates - Criteria for disabled dates.
314
+ * @returns True if the month is disabled, false otherwise.
315
+ */
316
+ const isMonthDisabled = (date, min, max, disabledDates) => {
317
+ const current = date.getFullYear() * 12 + date.getMonth();
318
+ const _min = min ? min.getFullYear() * 12 + min.getMonth() : null;
319
+ const _max = max ? max.getFullYear() * 12 + max.getMonth() : null;
320
+ if (_min && current < _min) {
321
+ return true;
322
+ }
323
+ if (_max && current > _max) {
324
+ return true;
325
+ }
326
+ if (disabledDates === undefined) {
327
+ return false;
328
+ }
329
+ const start = min ? Math.max(date.getTime(), min.getTime()) : date;
330
+ const end = max
331
+ ? Math.min(date.getTime(), max.getTime())
332
+ : new Date(new Date().getFullYear(), 11, 31);
333
+ for (const currentDate = new Date(start); currentDate <= end; currentDate.setDate(currentDate.getDate() + 1)) {
334
+ if (!isDateDisabled(currentDate, min, max, disabledDates)) {
335
+ return false;
336
+ }
337
+ }
338
+ return false;
339
+ };
340
+ /**
341
+ * Checks if a month is selected based on start and end dates.
342
+ * @param date - The date representing the month.
343
+ * @param start - Start date.
344
+ * @param end - End date.
345
+ * @returns True if the month is selected, false otherwise.
346
+ */
347
+ const isMonthSelected = (date, start, end) => {
348
+ const year = date.getFullYear();
349
+ const month = date.getMonth();
350
+ if (start !== null && year === start.getFullYear() && month === start.getMonth()) {
351
+ return true;
352
+ }
353
+ if (end !== null && year === end.getFullYear() && month === end.getMonth()) {
354
+ return true;
355
+ }
356
+ return false;
357
+ };
358
+ /**
359
+ * Checks if a month is within a specified range.
360
+ * @param date - The date representing the month.
361
+ * @param start - Start date.
362
+ * @param end - End date.
363
+ * @returns True if the month is within the range, false otherwise.
364
+ */
365
+ const isMonthInRange = (date, start, end) => {
366
+ const year = date.getFullYear();
367
+ const month = date.getMonth();
368
+ const _start = start ? start.getFullYear() * 12 + start.getMonth() : null;
369
+ const _end = end ? end.getFullYear() * 12 + end.getMonth() : null;
370
+ const _date = year * 12 + month;
371
+ return !!(_start && _end && _start <= _date && _date <= _end);
372
+ };
373
+ /**
374
+ * Checks if two dates are the same calendar date.
375
+ * @param date - First date.
376
+ * @param date2 - Second date.
377
+ * @returns True if both dates are the same, false otherwise.
378
+ */
192
379
  const isSameDateAs = (date, date2) => {
193
380
  if (date instanceof Date && date2 instanceof Date) {
194
381
  return (date.getDate() === date2.getDate() &&
@@ -200,13 +387,102 @@ const isSameDateAs = (date, date2) => {
200
387
  }
201
388
  return false;
202
389
  };
390
+ /**
391
+ * Checks if a date is today.
392
+ * @param date - The date to check.
393
+ * @returns True if the date is today, false otherwise.
394
+ */
203
395
  const isToday = (date) => {
204
396
  const today = new Date();
205
- return (date.getDate() === today.getDate() &&
206
- date.getMonth() === today.getMonth() &&
207
- date.getFullYear() === today.getFullYear());
397
+ return isSameDateAs(date, today);
398
+ };
399
+ /**
400
+ * Checks if a year is disabled based on the 'year' period type.
401
+ * @param date - The date representing the year to check.
402
+ * @param min - Minimum allowed date.
403
+ * @param max - Maximum allowed date.
404
+ * @param disabledDates - Criteria for disabled dates.
405
+ * @returns True if the year is disabled, false otherwise.
406
+ */
407
+ const isYearDisabled = (date, min, max, disabledDates) => {
408
+ const year = date.getFullYear();
409
+ const minYear = min ? min.getFullYear() : null;
410
+ const maxYear = max ? max.getFullYear() : null;
411
+ if (minYear && year < minYear) {
412
+ return true;
413
+ }
414
+ if (maxYear && year > maxYear) {
415
+ return true;
416
+ }
417
+ if (disabledDates === undefined) {
418
+ return false;
419
+ }
420
+ const start = min ? Math.max(date.getTime(), min.getTime()) : date;
421
+ const end = max
422
+ ? Math.min(date.getTime(), max.getTime())
423
+ : new Date(new Date().getFullYear(), 11, 31);
424
+ for (const currentDate = new Date(start); currentDate <= end; currentDate.setDate(currentDate.getDate() + 1)) {
425
+ if (!isDateDisabled(currentDate, min, max, disabledDates)) {
426
+ return false;
427
+ }
428
+ }
429
+ return false;
430
+ };
431
+ /**
432
+ * Checks if a year is selected based on start and end dates.
433
+ * @param date - The date representing the year.
434
+ * @param start - Start date.
435
+ * @param end - End date.
436
+ * @returns True if the year matches the start's or end's year, false otherwise.
437
+ */
438
+ const isYearSelected = (date, start, end) => {
439
+ const year = date.getFullYear();
440
+ if (start !== null && year === start.getFullYear()) {
441
+ return true;
442
+ }
443
+ if (end !== null && year === end.getFullYear()) {
444
+ return true;
445
+ }
446
+ return false;
447
+ };
448
+ /**
449
+ * Checks if a year is within a specified range.
450
+ * @param date - The date representing the year.
451
+ * @param start - Start date.
452
+ * @param end - End date.
453
+ * @returns True if the year's value lies between start's year and end's year, false otherwise.
454
+ */
455
+ const isYearInRange = (date, start, end) => {
456
+ const year = date.getFullYear();
457
+ const _start = start ? start.getFullYear() : null;
458
+ const _end = end ? end.getFullYear() : null;
459
+ return !!(_start && _end && _start <= year && year <= _end);
460
+ };
461
+ /**
462
+ * Removes the time component from a Date object.
463
+ * @param date - The original date.
464
+ * @returns A new Date object with the time set to 00:00:00.
465
+ */
466
+ const removeTimeFromDate = (date) => {
467
+ const clearedDate = new Date(date);
468
+ clearedDate.setHours(0, 0, 0, 0);
469
+ return clearedDate;
470
+ };
471
+ /**
472
+ * Copies the time (hours, minutes, seconds, milliseconds) from one Date to another.
473
+ *
474
+ * @param {Date} target - The date whose time will be updated.
475
+ * @param {Date | null} source - The date to copy the time from.
476
+ * @returns {Date} A new Date instance with the date from `target` and time from `source`.
477
+ */
478
+ const setTimeFromDate = (target, source) => {
479
+ if (!(source instanceof Date)) {
480
+ return target;
481
+ }
482
+ const result = new Date(target); // create a copy to avoid mutation
483
+ result.setHours(source.getHours(), source.getMinutes(), source.getSeconds(), source.getMilliseconds());
484
+ return result;
208
485
  };
209
- const removeTimeFromDate = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate());
210
486
 
211
- export { convertIsoWeekToDate, convertToDateObject, createGroupsInArray, getCalendarDate, getDateBySelectionType, getMonthDetails, getMonthsNames, getWeekNumber, getYears, isDateDisabled, isDateInRange, isDateSelected, isDisableDateInRange, isSameDateAs, isToday, removeTimeFromDate };
487
+ export { convertIsoWeekToDate, convertToDateObject, createGroupsInArray, getCalendarDate, getDateBySelectionType, getMonthDetails, getMonthsNames, getSelectableDates, getWeekNumber, getYears, isDateDisabled, isDateInRange, isDateSelected, isDisableDateInRange, isMonthDisabled, isMonthInRange, isMonthSelected, isSameDateAs, isToday, isYearDisabled, isYearInRange, isYearSelected, removeTimeFromDate, setTimeFromDate };
212
488
  //# sourceMappingURL=utils.js.map