@ck-ui/component-library 1.0.13 → 1.0.15

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.
@@ -1,6 +1,7 @@
1
1
  import { DateRange, DefinedRange } from 'mui-daterange-picker';
2
2
  import { ButtonSize } from '../../CKButton/_types/button.types';
3
- export type { DateRange, DefinedRange };
3
+ import { DefinedRangesInput, DefinedRangeDateLike } from '../helper/util';
4
+ export type { DateRange, DefinedRange, DefinedRangesInput, DefinedRangeDateLike };
4
5
  export interface DateRangePickerProps {
5
6
  /** Handler called when the date range changes */
6
7
  onChange: (range: DateRange) => void;
@@ -24,18 +25,10 @@ export interface DateRangePickerProps {
24
25
  disabled?: boolean;
25
26
  /** Shows error styling */
26
27
  error?: boolean;
27
- /** Custom defined ranges shown in the sidebar. When provided, replaces the default ranges. */
28
- definedRanges?: DefinedRange[];
28
+ definedRanges?: DefinedRangesInput;
29
29
  size?: ButtonSize;
30
30
  /** Horizontal alignment of the popup relative to the trigger button */
31
31
  popupAlign?: "left" | "right";
32
- /**
33
- * Date display format string. Tokens: DD, MM, MMM, MMMM, YYYY, YY.
34
- * @default "MMM D, YYYY" (e.g. "Jan 1, 2025")
35
- * @example "DD-MM-YYYY" → "01-01-2025"
36
- * @example "MM/DD/YYYY" → "01/01/2025"
37
- * @example "YYYY-MM-DD" → "2025-01-01"
38
- */
39
32
  dateFormat?: string;
40
33
  }
41
34
  export interface RangeSidebarProps {
@@ -48,4 +41,10 @@ export type PickerPosition = {
48
41
  left?: number;
49
42
  right?: number;
50
43
  };
44
+ export interface PanelMonths {
45
+ leftMonth: number;
46
+ leftYear: number;
47
+ rightMonth: number;
48
+ rightYear: number;
49
+ }
51
50
  //# sourceMappingURL=dateRangePicker.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateRangePicker.types.d.ts","sourceRoot":"","sources":["../../../../lib/components/DateRangePicker/_types/dateRangePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,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AM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"dateRangePicker.types.d.ts","sourceRoot":"","sources":["../../../../lib/components/DateRangePicker/_types/dateRangePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,CAAC;AAElF,MAAM,WAAW,oBAAoB;IACnC,iDAAiD;IACjD,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,oCAAoC;IACpC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,iEAAiE;IACjE,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,wDAAwD;IACxD,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAE9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,4 @@
1
+ export declare const MONTHS: string[];
2
+ export declare const MONTH_MAP: Record<string, string>;
3
+ export declare const MONTHS_SHORT: string[];
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../lib/components/DateRangePicker/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,UAahB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAa5C,CAAC;AAEF,eAAO,MAAM,YAAY,UAaxB,CAAC"}
@@ -0,0 +1,45 @@
1
+ const e = [
2
+ "January",
3
+ "February",
4
+ "March",
5
+ "April",
6
+ "May",
7
+ "June",
8
+ "July",
9
+ "August",
10
+ "September",
11
+ "October",
12
+ "November",
13
+ "December"
14
+ ], r = {
15
+ Jan: "January",
16
+ Feb: "February",
17
+ Mar: "March",
18
+ Apr: "April",
19
+ May: "May",
20
+ Jun: "June",
21
+ Jul: "July",
22
+ Aug: "August",
23
+ Sep: "September",
24
+ Oct: "October",
25
+ Nov: "November",
26
+ Dec: "December"
27
+ }, u = [
28
+ "Jan",
29
+ "Feb",
30
+ "Mar",
31
+ "Apr",
32
+ "May",
33
+ "Jun",
34
+ "Jul",
35
+ "Aug",
36
+ "Sep",
37
+ "Oct",
38
+ "Nov",
39
+ "Dec"
40
+ ];
41
+ export {
42
+ e as MONTHS,
43
+ u as MONTHS_SHORT,
44
+ r as MONTH_MAP
45
+ };
@@ -1,26 +1,28 @@
1
- import { DefinedRange } from 'mui-daterange-picker';
2
- /**
3
- * Formats a date to "Jan 7, 2026" format
4
- * @param date - Date object, timestamp (number), or date string
5
- * @returns Formatted date string like "Jan 7, 2026" or empty string if invalid
6
- */
1
+ import { DefinedRange, DateRange } from 'mui-daterange-picker';
7
2
  export declare const formatToMonthDayYear: (date?: Date | number | string) => string;
8
- /**
9
- * Normalizes a date value to a Date object for MUI DateRangePicker
10
- * Strips time component to local midnight to avoid timezone/time mismatch issues.
11
- * @param date - Date object, timestamp (number), or date string
12
- * @returns Date object or undefined if invalid
13
- */
14
3
  export declare const normalizeDateForMUI: (date?: Date | number | string) => Date | undefined;
15
- /**
16
- * Computes a sensible end date for the custom range sidebar
17
- * based on the picker's min/max boundaries.
18
- */
19
4
  export declare const customEndDateHandler: (minDate?: Date | string, maxDate?: Date | string) => Date;
20
- /**
21
- * Builds the default set of quick-select ranges shown in the sidebar.
22
- * All sidebar filters end at today's date, not maxDate.
23
- * Only "Custom" allows selection within the full min/max range.
24
- */
25
- export declare const getDefaultDefinedRanges: (_maxDate?: Date | string) => DefinedRange[];
5
+ export declare const getDefaultDefinedRanges: () => DefinedRange[];
6
+ export type DefinedRangeDateLike = Date | string | number | {
7
+ toDate: () => Date;
8
+ };
9
+ export type DefinedRangesInput = DefinedRange[] | Record<string, [
10
+ DefinedRangeDateLike,
11
+ DefinedRangeDateLike
12
+ ] | "" | null | undefined>;
13
+ export declare const normalizeDefinedRanges: (input?: DefinedRangesInput) => DefinedRange[] | undefined;
14
+ export declare const isSameDay: (a: Date, b: Date) => boolean;
15
+ export declare const getEffectiveEnd: (maxDate?: Date) => Date;
16
+ export declare const getPresetStartDate: (label: string, effectiveEnd: Date) => Date | null;
17
+ export declare const detectMatchingPreset: (range: DateRange, normalizedMinDate?: Date, normalizedMaxDate?: Date) => string | null;
18
+ export declare const clampDefinedRange: (definedRange: DefinedRange, normalizedMinDate?: Date, normalizedMaxDate?: Date) => {
19
+ startDate: Date;
20
+ endDate: Date;
21
+ };
22
+ export declare const detectMatchingDefinedRange: (range: DateRange, definedRanges: DefinedRange[], normalizedMinDate?: Date, normalizedMaxDate?: Date) => string | null;
23
+ export declare const formatWithPattern: (date: Date, dateFormat: string) => string;
24
+ export declare const getListboxPanelSide: (listbox: Element) => "left" | "right" | null;
25
+ export declare const enforceDateLimits: (normalizedMinDate?: Date, normalizedMaxDate?: Date, normalizedStartDate?: Date) => void;
26
+ export declare const navigateToYear: (side: "left" | "right", targetYear: number) => Promise<void>;
27
+ export declare const ensureSingleMonthLayout: (_minDate: Date, maxDate: Date) => Promise<void>;
26
28
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../lib/components/DateRangePicker/helper/util.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAWzD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,IAAI,GAAG,MAAM,GAAG,MAAM,KAAG,MA+BpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,IAAI,GAAG,MAAM,GAAG,MAAM,KAAG,IAAI,GAAG,SAuB1E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,IAAI,GAAG,MAAM,EACvB,UAAU,IAAI,GAAG,MAAM,KACtB,IA4BF,CAAC;AAEF;;;;G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ChB,oBAAoB,IAAI,EACxB,oBAAoB,IAAI,KACvB,MAAM,GAAG,IAuBX,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,cAAc,YAAY,EAC1B,oBAAoB,IAAI,EACxB,oBAAoB,IAAI,KACvB;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAQlC,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,OAAO,SAAS,EAChB,eAAe,YAAY,EAAE,EAC7B,oBAAoB,IAAI,EACxB,oBAAoB,IAAI,KACvB,MAAM,GAAG,IAaX,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,IAAI,EAAE,YAAY,MAAM,KAAG,MAYlE,CAAC;AAsEF,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,MAAM,GAAG,OAAO,GAAG,IAUzE,CAAC;AAoKF,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,IAAI,EACxB,oBAAoB,IAAI,EACxB,sBAAsB,IAAI,KACzB,IAiBF,CAAC;AAoCF,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,GAAG,OAAO,EACtB,YAAY,MAAM,KACjB,OAAO,CAAC,IAAI,CA4Cd,CAAC;AAiCF,eAAO,MAAM,uBAAuB,GAClC,UAAU,IAAI,EACd,SAAS,IAAI,KACZ,OAAO,CAAC,IAAI,CA6Cd,CAAC"}
@@ -1,54 +1,361 @@
1
- const i = (t) => new Date(t.getFullYear(), t.getMonth(), 1), D = (t) => new Date(t.getFullYear(), t.getMonth() + 1, 0), u = (t, e) => new Date(t.getFullYear(), t.getMonth(), t.getDate() + e), f = (t) => {
1
+ import { MONTHS as q, MONTHS_SHORT as R } from "../constants.js";
2
+ const B = (t) => new Date(t.getFullYear(), t.getMonth(), 1), F = (t) => new Date(t.getFullYear(), t.getMonth() + 1, 0), k = (t, e) => new Date(t.getFullYear(), t.getMonth(), t.getDate() + e), Z = (t) => {
2
3
  if (!t) return "";
3
4
  let e;
4
- if (t instanceof Date)
5
- e = t;
6
- else if (typeof t == "number")
7
- e = new Date(t);
5
+ if (t instanceof Date) e = t;
6
+ else if (typeof t == "number") e = new Date(t);
8
7
  else if (typeof t == "string") {
9
- if (/^[A-Z][a-z]{2}\s+\d{1,2},\s+\d{4}$/.test(t))
10
- return t;
8
+ if (/^[A-Z][a-z]{2}\s+\d{1,2},\s+\d{4}$/.test(t)) return t;
11
9
  e = new Date(t);
12
- } else
13
- return "";
10
+ } else return "";
14
11
  return isNaN(e.getTime()) ? "" : e.toLocaleDateString("en-US", {
15
12
  month: "short",
16
13
  day: "numeric",
17
14
  year: "numeric"
18
15
  });
19
- }, h = (t) => {
16
+ }, $ = (t) => {
20
17
  if (!t) return;
21
18
  let e;
22
- if (t instanceof Date)
23
- e = t;
24
- else if (typeof t == "number")
25
- e = new Date(t);
26
- else if (typeof t == "string")
27
- e = new Date(t);
28
- else
29
- return;
19
+ if (t instanceof Date) e = t;
20
+ else if (typeof t == "number") e = new Date(t);
21
+ else if (typeof t == "string") e = new Date(t);
22
+ else return;
30
23
  if (!isNaN(e.getTime()))
31
24
  return new Date(e.getFullYear(), e.getMonth(), e.getDate());
32
- }, M = (t, e) => {
33
- const a = t ? new Date(t) : /* @__PURE__ */ new Date(), n = e ? new Date(e) : /* @__PURE__ */ new Date(), o = Math.floor(
34
- (n.getTime() - a.getTime()) / (1e3 * 60 * 60 * 24)
35
- ), s = a.getMonth() === n.getMonth() && a.getFullYear() === n.getFullYear(), l = /* @__PURE__ */ new Date(), r = new Date(l.getFullYear(), l.getMonth() - 1, 1), g = n.getMonth() === r.getMonth() && n.getFullYear() === r.getFullYear();
36
- return o < 31 ? o < 2 || s ? n : D(a) : g ? n : D(r);
37
- }, c = (t) => {
38
- const e = /* @__PURE__ */ new Date();
25
+ }, E = (t, e) => {
26
+ const o = t ? new Date(t) : /* @__PURE__ */ new Date(), n = e ? new Date(e) : /* @__PURE__ */ new Date(), r = Math.floor(
27
+ (n.getTime() - o.getTime()) / (1e3 * 60 * 60 * 24)
28
+ ), i = o.getMonth() === n.getMonth() && o.getFullYear() === n.getFullYear(), a = /* @__PURE__ */ new Date(), l = new Date(a.getFullYear(), a.getMonth() - 1, 1), s = n.getMonth() === l.getMonth() && n.getFullYear() === l.getFullYear();
29
+ return r < 31 ? r < 2 || i ? n : F(o) : s ? n : F(l);
30
+ }, J = () => {
31
+ const t = /* @__PURE__ */ new Date();
39
32
  return [
40
- { label: "Custom", startDate: e, endDate: e },
41
- { label: "7 Days", startDate: u(e, -6), endDate: e },
42
- { label: "3 Months", startDate: new Date(e.getFullYear(), e.getMonth() - 3, e.getDate()), endDate: e },
43
- { label: "6 Months", startDate: new Date(e.getFullYear(), e.getMonth() - 6, e.getDate()), endDate: e },
44
- { label: "1 Year", startDate: new Date(e.getFullYear() - 1, e.getMonth(), e.getDate()), endDate: e },
45
- { label: "Month to Date", startDate: i(e), endDate: e },
46
- { label: "Year to Date", startDate: new Date(e.getFullYear(), 0, 1), endDate: e }
33
+ { label: "Custom", startDate: t, endDate: t },
34
+ { label: "7 Days", startDate: k(t, -6), endDate: t },
35
+ {
36
+ label: "3 Months",
37
+ startDate: new Date(
38
+ t.getFullYear(),
39
+ t.getMonth() - 3,
40
+ t.getDate()
41
+ ),
42
+ endDate: t
43
+ },
44
+ {
45
+ label: "6 Months",
46
+ startDate: new Date(
47
+ t.getFullYear(),
48
+ t.getMonth() - 6,
49
+ t.getDate()
50
+ ),
51
+ endDate: t
52
+ },
53
+ {
54
+ label: "1 Year",
55
+ startDate: new Date(
56
+ t.getFullYear() - 1,
57
+ t.getMonth(),
58
+ t.getDate()
59
+ ),
60
+ endDate: t
61
+ },
62
+ { label: "Month to Date", startDate: B(t), endDate: t },
63
+ {
64
+ label: "Year to Date",
65
+ startDate: new Date(t.getFullYear(), 0, 1),
66
+ endDate: t
67
+ }
47
68
  ];
69
+ }, P = (t) => {
70
+ if (t == null || t === "") return;
71
+ if (t instanceof Date)
72
+ return isNaN(t.getTime()) ? void 0 : t;
73
+ if (typeof t == "object" && typeof t.toDate == "function") {
74
+ const o = t.toDate();
75
+ return o instanceof Date && !isNaN(o.getTime()) ? o : void 0;
76
+ }
77
+ const e = new Date(t);
78
+ return isNaN(e.getTime()) ? void 0 : e;
79
+ }, K = (t) => {
80
+ if (!t) return;
81
+ if (Array.isArray(t)) return t;
82
+ const e = [];
83
+ return Object.entries(t).forEach(([o, n]) => {
84
+ if (!Array.isArray(n)) return;
85
+ const r = P(n[0]), i = P(n[1]);
86
+ r && i && e.push({ label: o, startDate: r, endDate: i });
87
+ }), e.length ? e : void 0;
88
+ }, m = (t, e) => t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate(), x = (t) => {
89
+ const e = /* @__PURE__ */ new Date();
90
+ return t && t.getTime() < e.getTime() ? new Date(t) : new Date(e);
91
+ }, _ = (t, e) => {
92
+ switch (t) {
93
+ case "7 Days":
94
+ return new Date(
95
+ e.getFullYear(),
96
+ e.getMonth(),
97
+ e.getDate() - 6
98
+ );
99
+ case "3 Months":
100
+ return new Date(
101
+ e.getFullYear(),
102
+ e.getMonth() - 3,
103
+ e.getDate()
104
+ );
105
+ case "6 Months":
106
+ return new Date(
107
+ e.getFullYear(),
108
+ e.getMonth() - 6,
109
+ e.getDate()
110
+ );
111
+ case "1 Year":
112
+ return new Date(
113
+ e.getFullYear() - 1,
114
+ e.getMonth(),
115
+ e.getDate()
116
+ );
117
+ case "Month to Date":
118
+ return new Date(e.getFullYear(), e.getMonth(), 1);
119
+ case "Year to Date":
120
+ return new Date(e.getFullYear(), 0, 1);
121
+ default:
122
+ return null;
123
+ }
124
+ }, Q = (t, e, o) => {
125
+ if (!t.startDate || !t.endDate) return null;
126
+ const n = x(o), r = [
127
+ "7 Days",
128
+ "3 Months",
129
+ "6 Months",
130
+ "1 Year",
131
+ "Month to Date",
132
+ "Year to Date"
133
+ ];
134
+ for (const i of r) {
135
+ let a = _(i, n);
136
+ if (a && (e && a.getTime() < e.getTime() && (a = new Date(e)), m(t.startDate, a) && m(t.endDate, n)))
137
+ return i;
138
+ }
139
+ return null;
140
+ }, O = (t, e, o) => {
141
+ let n = new Date(t.startDate), r = new Date(t.endDate);
142
+ return e && n.getTime() < e.getTime() && (n = new Date(e)), o && r.getTime() > o.getTime() && (r = new Date(o)), { startDate: n, endDate: r };
143
+ }, z = (t, e, o, n) => {
144
+ if (!t.startDate || !t.endDate) return null;
145
+ for (const r of e) {
146
+ if (r.label === "Custom") continue;
147
+ const { startDate: i, endDate: a } = O(
148
+ r,
149
+ o,
150
+ n
151
+ );
152
+ if (m(t.startDate, i) && m(t.endDate, a))
153
+ return r.label;
154
+ }
155
+ return null;
156
+ }, tt = (t, e) => {
157
+ const o = t.getDate(), n = t.getMonth(), r = t.getFullYear();
158
+ return e.replace("DD", String(o).padStart(2, "0")).replace("D", String(o)).replace("MMMM", q[n]).replace("MMM", R[n]).replace("MM", String(n + 1).padStart(2, "0")).replace("YYYY", String(r)).replace("YY", String(r).slice(-2));
159
+ }, y = (t) => {
160
+ const e = t.toLowerCase().trim();
161
+ if (!e) return -1;
162
+ for (let o = 0; o < 12; o++) {
163
+ const n = q[o].toLowerCase(), r = R[o].toLowerCase();
164
+ if (e === n || e === r || e.startsWith(r) || n.startsWith(e))
165
+ return o;
166
+ }
167
+ return -1;
168
+ }, I = (t) => {
169
+ const e = t.querySelector("li.Mui-selected"), o = y(
170
+ e?.textContent?.trim() ?? ""
171
+ ), n = Array.from(
172
+ document.querySelectorAll('.MuiSelect-select[role="combobox"]')
173
+ ).filter((r) => r.getBoundingClientRect().width > 0);
174
+ for (let r = 0; r < n.length; r += 2)
175
+ if (o !== -1 && y(n[r]?.textContent?.trim() ?? "") === o) {
176
+ const i = Number(n[r + 1]?.textContent?.trim());
177
+ if (!isNaN(i)) return i;
178
+ }
179
+ for (let r = 0; r < n.length; r += 2) {
180
+ const i = n[r];
181
+ if ((i.getAttribute("aria-expanded") === "true" || i.closest(".MuiInputBase-root")?.querySelector('[aria-expanded="true"]')) && y(i.textContent?.trim() ?? "") !== -1) {
182
+ const l = Number(n[r + 1]?.textContent?.trim());
183
+ if (!isNaN(l)) return l;
184
+ }
185
+ }
186
+ return null;
187
+ }, L = (t, e) => {
188
+ t.style.setProperty("display", "", "important"), t.style.opacity = e ? "0.4" : "", t.style.pointerEvents = e ? "none" : "", t.style.cursor = e ? "not-allowed" : "", e ? t.setAttribute("aria-disabled", "true") : t.removeAttribute("aria-disabled");
189
+ }, G = (t, e) => {
190
+ t.style.setProperty("display", e ? "none" : "", "important"), e ? t.setAttribute("aria-hidden", "true") : t.removeAttribute("aria-hidden");
191
+ }, V = (t) => {
192
+ const e = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
193
+ if (!e) return null;
194
+ const o = e.getBoundingClientRect(), n = o.left + o.width / 2, r = t.getBoundingClientRect();
195
+ return r.left + r.width / 2 < n ? "left" : "right";
196
+ }, j = (t, e, o, n, r, i) => e < n || e > i ? !0 : e === n && e === i ? t < o || t > r : e === n ? t < o : e === i ? t > r : !1;
197
+ function H(t, e, o, n, r, i) {
198
+ document.querySelectorAll('ul[role="listbox"]').forEach((a) => {
199
+ const l = a.querySelectorAll('li[role="option"]');
200
+ if (!l.length) return;
201
+ const s = a.closest(
202
+ ".MuiMenu-paper, .MuiPaper-root"
203
+ );
204
+ if (!s || !s.getBoundingClientRect().width) return;
205
+ const g = l[0].getAttribute("data-value") ?? "", f = l[l.length - 1].getAttribute("data-value") ?? "", d = l.length === 12 && g === "0" && f === "11", c = !d && Number(g) > 1900 && Number(f) > 1900, Y = V(a);
206
+ let h = e, D = t;
207
+ if (Y === "right" && i !== void 0 && (i > e ? (h = i, D = r ?? 0) : i === e && (D = Math.max(t, r ?? t)), r === 11 && (h = (i ?? e) + 1, D = 0)), c)
208
+ l.forEach((u) => {
209
+ const M = Number(u.getAttribute("data-value"));
210
+ isNaN(M) || G(
211
+ u,
212
+ M < h || M > n
213
+ );
214
+ });
215
+ else if (d) {
216
+ let u = I(s);
217
+ u === null && h === n && (u = h), l.forEach((M) => {
218
+ const b = Number(
219
+ M.getAttribute("data-value")
220
+ );
221
+ if (isNaN(b) || b < 0 || b > 11) return;
222
+ const T = u !== null && j(
223
+ b,
224
+ u,
225
+ D,
226
+ h,
227
+ o,
228
+ n
229
+ );
230
+ L(M, T);
231
+ });
232
+ }
233
+ });
234
+ }
235
+ function S(t) {
236
+ const e = [];
237
+ return t.querySelectorAll(".MuiGrid-root > .MuiGrid-root").forEach((o) => {
238
+ o.querySelectorAll(
239
+ ":scope > button.MuiIconButton-root, :scope > .MuiGrid-root > button.MuiIconButton-root"
240
+ ).forEach((n) => {
241
+ const r = n.getBoundingClientRect();
242
+ r.width > 0 && r.width < 50 && e.push(n);
243
+ });
244
+ }), [...new Set(e)].sort(
245
+ (o, n) => o.getBoundingClientRect().left - n.getBoundingClientRect().left
246
+ );
247
+ }
248
+ function U(t, e, o, n) {
249
+ const r = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
250
+ if (!r) return;
251
+ const i = Array.from(
252
+ r.querySelectorAll('.MuiSelect-select[role="combobox"]')
253
+ ).filter((u) => u.getBoundingClientRect().width > 0).map((u) => u.textContent?.trim() ?? "");
254
+ if (i.length < 4) return;
255
+ const a = y(i[0]), l = Number(i[1]), s = y(i[2]), g = Number(i[3]), f = l < e || l === e && a <= t, d = g > n || g === n && s >= o, c = S(r), Y = a === 11 ? 0 : a + 1, h = a === 11 ? l + 1 : l, D = Y === s && h === g;
256
+ c.length >= 4 ? (c[0].style.visibility = f ? "hidden" : "visible", c[1].style.visibility = D ? "hidden" : "visible", c[2].style.visibility = D ? "hidden" : "visible", c[3].style.visibility = d ? "hidden" : "visible") : c.length >= 2 && (c[0].style.visibility = f ? "hidden" : "visible", c[c.length - 1].style.visibility = d ? "hidden" : "visible");
257
+ }
258
+ const et = (t, e, o) => {
259
+ if (!t || !e) return;
260
+ const n = t.getMonth(), r = t.getFullYear(), i = e.getMonth(), a = e.getFullYear(), l = o?.getMonth(), s = o?.getFullYear();
261
+ H(
262
+ n,
263
+ r,
264
+ i,
265
+ a,
266
+ l,
267
+ s
268
+ ), U(n, r, i, a);
269
+ }, w = () => {
270
+ const t = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
271
+ if (!t) return null;
272
+ const e = Array.from(
273
+ t.querySelectorAll('.MuiSelect-select[role="combobox"]')
274
+ ).filter((r) => r.getBoundingClientRect().width > 0).map((r) => r.textContent?.trim() ?? "");
275
+ if (e.length < 4) return null;
276
+ const o = Number(e[1]), n = Number(e[3]);
277
+ return isNaN(o) || isNaN(n) ? null : {
278
+ leftMonth: y(e[0]),
279
+ leftYear: o,
280
+ rightMonth: y(e[2]),
281
+ rightYear: n
282
+ };
283
+ }, N = (t) => !t || t.disabled || t.classList.contains("Mui-disabled") || t.getAttribute("aria-disabled") === "true", A = () => new Promise((t) => requestAnimationFrame(() => t())), nt = async (t, e) => {
284
+ for (let o = 0; o < 60; o += 1) {
285
+ const n = w();
286
+ if (!n) return;
287
+ const r = t === "left" ? n.leftYear : n.rightYear;
288
+ if (r === e) return;
289
+ const i = e > r, a = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
290
+ if (!a) return;
291
+ const [l, s, g, f] = S(a), d = t === "left" ? i ? s : l : i ? f : g;
292
+ if (!N(d))
293
+ d.click();
294
+ else {
295
+ const c = t === "left" ? i ? f : g : i ? s : l;
296
+ if (N(c)) return;
297
+ c.click();
298
+ }
299
+ await A();
300
+ }
301
+ }, v = (t, e) => {
302
+ const n = Array.from(
303
+ t.querySelectorAll(".MuiPaper-elevation0")
304
+ ).filter((r) => r.querySelector('[role="combobox"]'))[0]?.parentElement;
305
+ n && (n.style.visibility = e ? "" : "hidden");
306
+ }, W = async (t) => {
307
+ let e = S(t);
308
+ const o = e[0];
309
+ if (!o || N(o)) return;
310
+ o.click(), await A(), e = S(t);
311
+ const n = e[2];
312
+ n && !N(n) && (n.click(), await A());
313
+ };
314
+ let p = 0;
315
+ const C = (t) => t.rightYear * 12 + t.rightMonth, rt = async (t, e) => {
316
+ const o = e.getFullYear() * 12 + e.getMonth(), n = p += 1, r = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
317
+ if (!r) return;
318
+ const i = w();
319
+ if (i && C(i) <= o) {
320
+ v(r, !0);
321
+ return;
322
+ }
323
+ v(r, !1);
324
+ try {
325
+ let a = i;
326
+ for (let l = 0; l < 15 && !a; l += 1) {
327
+ if (await A(), n !== p) return;
328
+ a = w();
329
+ }
330
+ if (!a) return;
331
+ for (let l = 0; l < 24; l += 1) {
332
+ if (n !== p) return;
333
+ const s = w();
334
+ if (!s || C(s) <= o) break;
335
+ await W(r);
336
+ }
337
+ } finally {
338
+ if (n === p) {
339
+ const a = document.querySelector(".ckds-date-range-picker__calendar") || document.querySelector(".MuiPaper-elevation5");
340
+ a && v(a, !0);
341
+ }
342
+ }
48
343
  };
49
344
  export {
50
- M as customEndDateHandler,
51
- f as formatToMonthDayYear,
52
- c as getDefaultDefinedRanges,
53
- h as normalizeDateForMUI
345
+ O as clampDefinedRange,
346
+ E as customEndDateHandler,
347
+ z as detectMatchingDefinedRange,
348
+ Q as detectMatchingPreset,
349
+ et as enforceDateLimits,
350
+ rt as ensureSingleMonthLayout,
351
+ Z as formatToMonthDayYear,
352
+ tt as formatWithPattern,
353
+ J as getDefaultDefinedRanges,
354
+ x as getEffectiveEnd,
355
+ V as getListboxPanelSide,
356
+ _ as getPresetStartDate,
357
+ m as isSameDay,
358
+ nt as navigateToYear,
359
+ $ as normalizeDateForMUI,
360
+ K as normalizeDefinedRanges
54
361
  };