monobill-mintui 0.6.650 → 0.6.652

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 (122) hide show
  1. package/bin/component-dependencies.json +13 -1
  2. package/dist/components/chunks/ScrollFade-D1FPF6ZS.js +82 -0
  3. package/dist/components/chunks/ScrollFade-DT2Br2g7.js +1 -0
  4. package/dist/components/chunks/date-picker-BQsCoKaK.js +1282 -0
  5. package/dist/components/chunks/date-picker-tm5Oc92c.js +1 -0
  6. package/dist/components/chunks/{input-CYv5hraJ.js → input-DcglGwsR.js} +13 -6
  7. package/dist/components/chunks/input-awdYlp-G.js +1 -0
  8. package/dist/components/chunks/{popover-DB1OaYVe.js → popover-FdMS4yAD.js} +54 -14
  9. package/dist/components/chunks/popover-wGdggZ-a.js +1 -0
  10. package/dist/components/chunks/{table-DRdsVUJL.js → table-B9e-cnAC.js} +7 -6
  11. package/dist/components/chunks/table-vjF3q3J5.js +1 -0
  12. package/dist/components/chunks/time-picker-Cq3qzkDb.js +1 -0
  13. package/dist/components/chunks/time-picker-S0bc0BPU.js +360 -0
  14. package/dist/components/date-picker/DatePicker.d.ts +5 -0
  15. package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
  16. package/dist/components/date-picker/browser.js +2 -1270
  17. package/dist/components/date-picker/index.cjs +1 -1
  18. package/dist/components/date-picker/index.js +2 -1270
  19. package/dist/components/datetime-picker/DateTimePicker.d.ts +44 -0
  20. package/dist/components/datetime-picker/DateTimePicker.d.ts.map +1 -0
  21. package/dist/components/datetime-picker/browser.js +255 -0
  22. package/dist/components/datetime-picker/index.cjs +1 -0
  23. package/dist/components/datetime-picker/index.d.ts +4 -0
  24. package/dist/components/datetime-picker/index.d.ts.map +1 -0
  25. package/dist/components/datetime-picker/index.js +243 -0
  26. package/dist/components/form/Form.d.ts.map +1 -1
  27. package/dist/components/form/browser.js +9 -8
  28. package/dist/components/form/index.cjs +1 -1
  29. package/dist/components/form/index.js +9 -8
  30. package/dist/components/input/browser.js +1 -1
  31. package/dist/components/input/index.cjs +1 -1
  32. package/dist/components/input/index.js +1 -1
  33. package/dist/components/link/browser.js +1 -1
  34. package/dist/components/link/index.cjs +1 -1
  35. package/dist/components/link/index.js +1 -1
  36. package/dist/components/navigation/browser.js +2 -2
  37. package/dist/components/navigation/index.cjs +1 -1
  38. package/dist/components/navigation/index.js +2 -2
  39. package/dist/components/popover/Popover.d.ts.map +1 -1
  40. package/dist/components/popover/browser.js +1 -1
  41. package/dist/components/popover/index.cjs +1 -1
  42. package/dist/components/popover/index.js +1 -1
  43. package/dist/components/resource-table/ResourceTable.d.ts +1 -0
  44. package/dist/components/resource-table/ResourceTable.d.ts.map +1 -1
  45. package/dist/components/resource-table/browser.js +22 -22
  46. package/dist/components/resource-table/index.cjs +2 -2
  47. package/dist/components/resource-table/index.js +22 -22
  48. package/dist/components/scroll-fade/ScrollFade.d.ts +15 -0
  49. package/dist/components/scroll-fade/ScrollFade.d.ts.map +1 -0
  50. package/dist/components/scroll-fade/browser.js +16 -0
  51. package/dist/components/scroll-fade/index.cjs +1 -0
  52. package/dist/components/scroll-fade/index.d.ts +6 -0
  53. package/dist/components/scroll-fade/index.d.ts.map +1 -0
  54. package/dist/components/scroll-fade/index.js +4 -0
  55. package/dist/components/search/Search.d.ts.map +1 -1
  56. package/dist/components/search/browser.js +3 -3
  57. package/dist/components/search/index.cjs +1 -1
  58. package/dist/components/search/index.js +3 -3
  59. package/dist/components/select/NativeSelect.d.ts +38 -0
  60. package/dist/components/select/NativeSelect.d.ts.map +1 -0
  61. package/dist/components/select/Select.d.ts +36 -29
  62. package/dist/components/select/Select.d.ts.map +1 -1
  63. package/dist/components/select/browser.js +313 -19
  64. package/dist/components/select/index.cjs +1 -1
  65. package/dist/components/select/index.d.ts +3 -2
  66. package/dist/components/select/index.d.ts.map +1 -1
  67. package/dist/components/select/index.js +313 -19
  68. package/dist/components/side-navigation/SideNavigation.d.ts +1 -0
  69. package/dist/components/side-navigation/SideNavigation.d.ts.map +1 -1
  70. package/dist/components/side-navigation/browser.js +24 -23
  71. package/dist/components/side-navigation/index.cjs +1 -1
  72. package/dist/components/side-navigation/index.js +24 -23
  73. package/dist/components/sortable/browser.js +1 -1
  74. package/dist/components/sortable/index.cjs +1 -1
  75. package/dist/components/sortable/index.js +1 -1
  76. package/dist/components/table/Table.d.ts +1 -0
  77. package/dist/components/table/Table.d.ts.map +1 -1
  78. package/dist/components/table/browser.js +1 -1
  79. package/dist/components/table/index.cjs +1 -1
  80. package/dist/components/table/index.js +1 -1
  81. package/dist/components/tags/browser.js +1 -1
  82. package/dist/components/tags/index.cjs +1 -1
  83. package/dist/components/tags/index.js +1 -1
  84. package/dist/components/time-picker/TimePicker.d.ts +1 -0
  85. package/dist/components/time-picker/TimePicker.d.ts.map +1 -1
  86. package/dist/components/time-picker/browser.js +2 -347
  87. package/dist/components/time-picker/index.cjs +1 -1
  88. package/dist/components/time-picker/index.js +2 -347
  89. package/dist/components/tree/Tree.d.ts +2 -0
  90. package/dist/components/tree/Tree.d.ts.map +1 -1
  91. package/dist/components/tree/browser.js +15 -7
  92. package/dist/components/tree/index.cjs +1 -1
  93. package/dist/components/tree/index.js +15 -7
  94. package/dist/datetime-picker.css +3 -0
  95. package/dist/index.cjs +4 -4
  96. package/dist/index.css +22 -9
  97. package/dist/index.d.ts +3 -1
  98. package/dist/index.js +1413 -739
  99. package/dist/modal.css +1 -1
  100. package/dist/navigation-search.json +15 -1
  101. package/dist/navigation.css +1 -1
  102. package/dist/off-canvas.css +1 -1
  103. package/dist/popover.css +1 -1
  104. package/dist/scroll-fade.css +3 -0
  105. package/dist/select.css +1 -1
  106. package/dist/side-navigation.css +1 -1
  107. package/dist/theme.css +7 -2
  108. package/dist/time-picker.css +1 -1
  109. package/package.json +19 -1
  110. package/dist/components/chunks/caret-up-DzrY-bTy.js +0 -1
  111. package/dist/components/chunks/caret-up-ZK3v_oWQ.js +0 -9
  112. package/dist/components/chunks/input-Du8C2LW8.js +0 -1
  113. package/dist/components/chunks/popover-CNZ5u-MA.js +0 -1
  114. package/dist/components/chunks/table-2-0iNQJy.js +0 -1
  115. /package/dist/components/chunks/{caret-right-BzeJ0Fw3.js → caret-right-BcZ9bOhS.js} +0 -0
  116. /package/dist/components/chunks/{caret-right-Bh7uMg-Y.js → caret-right-CgIVfus7.js} +0 -0
  117. /package/dist/components/chunks/{link-BsC3zT_I.js → link-BjbBJpI6.js} +0 -0
  118. /package/dist/components/chunks/{link-dTjSvr4E.js → link-CU-gTgir.js} +0 -0
  119. /package/dist/components/chunks/{search-v06eZL4m.js → search--bcFMYMP.js} +0 -0
  120. /package/dist/components/chunks/{search-CTAGy5ab.js → search-Cixhf7hA.js} +0 -0
  121. /package/dist/components/chunks/{sortable-B1nMJBah.js → sortable-CNlF0_gv.js} +0 -0
  122. /package/dist/components/chunks/{sortable-CXM-7eyL.js → sortable-CVK48xj1.js} +0 -0
@@ -4,1273 +4,5 @@ import '../../icon.css'
4
4
  import '../../popover.css'
5
5
  import '../../stack.css'
6
6
  import '../../date-picker.css'
7
- import { a as e } from "../chunks/icon-Cxv9k3CY.js";
8
- import { t } from "../chunks/register-element-BFYmIynH.js";
9
- import "../chunks/icon-DMa6Oo80.js";
10
- import "../chunks/caret-right-Bh7uMg-Y.js";
11
- import "../chunks/input-CYv5hraJ.js";
12
- import "../chunks/popover-DB1OaYVe.js";
13
- e({
14
- name: "calendar",
15
- viewBox: "0 0 24 24",
16
- path: "M8 7V3m8 4V3M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2zM6 11h12M6 14h12M6 17h12",
17
- strokeLinecap: "round",
18
- strokeLinejoin: "round"
19
- }), e({
20
- name: "caret-left",
21
- viewBox: "0 0 24 24",
22
- path: "M15 19l-7-7 7-7",
23
- strokeLinecap: "round",
24
- strokeLinejoin: "round"
25
- });
26
- //#endregion
27
- //#region src/components/date-picker/DatePicker.ts
28
- var n = class extends HTMLElement {
29
- static get observedAttributes() {
30
- return [
31
- "value",
32
- "label",
33
- "info",
34
- "disabled",
35
- "id",
36
- "name",
37
- "required",
38
- "readonly",
39
- "format",
40
- "min",
41
- "max",
42
- "range",
43
- "shortcuts",
44
- "display-format",
45
- "error",
46
- "error-message",
47
- "loading",
48
- "selection-mode",
49
- "week-start-day",
50
- "mode",
51
- "disabled-dates"
52
- ];
53
- }
54
- constructor() {
55
- super(), this._input = null, this._textInput = null, this._popover = null, this._calendarContainer = null, this._iconButton = null, this._hiddenInput = null, this._startPartInputs = [], this._endPartInputs = [], this._displayEl = null, this._inputsWrapperEl = null, this._fieldsContainer = null, this._resetHandler = null, this._isInputMode = !1, this._currentMonth = (/* @__PURE__ */ new Date()).getMonth(), this._currentYear = (/* @__PURE__ */ new Date()).getFullYear(), this._viewMode = "calendar", this._selectedStartDate = null, this._selectedEndDate = null, this._isRange = !1, this._hoveredDate = null, this._isHandlingClick = !1, this._touchStartDate = null, this._touchStartElement = null, this._isTouchActive = !1, this._resizeObserver = null, this._popoverObserver = null, this._focusTrapHandler = null, this._escapeHandler = null, this._a11yId = `mint-date-picker-${Math.random().toString(36).slice(2, 10)}`;
56
- }
57
- connectedCallback() {
58
- this.classList.add("mint-date-picker"), this.render(), this._setupPopoverWithRetry(), this._attachFormResetListener();
59
- }
60
- disconnectedCallback() {
61
- if (this._popoverObserver &&= (this._popoverObserver.disconnect(), null), this._resizeObserver &&= (this._resizeObserver.disconnect(), null), this._removeFocusTrap(), this._resetHandler) {
62
- let e = this.closest("form");
63
- e && e.removeEventListener("reset", this._resetHandler), this._resetHandler = null;
64
- }
65
- }
66
- isLoading() {
67
- return this.getAttribute("loading") === "true";
68
- }
69
- attributeChangedCallback(e, t, n) {
70
- if (t !== n) {
71
- if (e === "error" || e === "error-message") {
72
- let e = this.hasError(), t = this.getErrorMessage();
73
- this._applyErrorVisuals(e, t, this.isDisabled());
74
- return;
75
- }
76
- if (e === "loading") {
77
- this.render();
78
- return;
79
- }
80
- if (e === "mode" || e === "format") {
81
- let e = this.getMode();
82
- e === "month" ? this._viewMode = "month" : e === "year" ? this._viewMode = "year" : this._viewMode = "calendar", this._popover && this._calendarContainer && this._buildCalendar();
83
- }
84
- this.render(), this._input && this._setupPopoverWithRetry();
85
- }
86
- }
87
- getValue() {
88
- return this.getAttribute("value") || "";
89
- }
90
- setValue(e) {
91
- e ? (this.setAttribute("value", e), this._textInput && (this._textInput.value = e), this._parseValue(e)) : (this.removeAttribute("value"), this._textInput && (this._textInput.value = ""), this._selectedStartDate = null, this._selectedEndDate = null), this._buildCalendar(), this._updateDisplayText();
92
- }
93
- get value() {
94
- try {
95
- return this.getValue() || "";
96
- } catch {
97
- return "";
98
- }
99
- }
100
- set value(e) {
101
- try {
102
- this.setValue(e || "");
103
- } catch {}
104
- }
105
- getFormat() {
106
- return this.getAttribute("format") || "mm/dd/yyyy";
107
- }
108
- getLabel() {
109
- return this.getAttribute("label") || "";
110
- }
111
- getInfo() {
112
- return this.getAttribute("info") || "";
113
- }
114
- isDisabled() {
115
- return this.getAttribute("disabled") === "true";
116
- }
117
- isReadonly() {
118
- return this.getAttribute("readonly") === "true";
119
- }
120
- isRequired() {
121
- return this.getAttribute("required") === "true";
122
- }
123
- hasError() {
124
- return this.getAttribute("error") === "true";
125
- }
126
- getErrorMessage() {
127
- return this.getAttribute("error-message") || "";
128
- }
129
- isRange() {
130
- return this.getAttribute("range") === "true";
131
- }
132
- getId() {
133
- return this.getAttribute("id") || "";
134
- }
135
- getName() {
136
- return this.getAttribute("name") || "";
137
- }
138
- getMin() {
139
- return this.getAttribute("min") || "";
140
- }
141
- getMax() {
142
- return this.getAttribute("max") || "";
143
- }
144
- getDisabledDates() {
145
- let e = this.getAttribute("disabled-dates");
146
- if (!e) return [];
147
- try {
148
- let t = JSON.parse(e), n = this.getFormat();
149
- return t.map((e) => this._parseDateString(e, n)).filter((e) => e !== null);
150
- } catch {
151
- return [];
152
- }
153
- }
154
- getDisabledDateStrings() {
155
- let e = this.getAttribute("disabled-dates");
156
- if (!e) return [];
157
- try {
158
- return JSON.parse(e);
159
- } catch {
160
- return [];
161
- }
162
- }
163
- disableDate(e) {
164
- let t = this.getFormat(), n = this.getDisabledDateStrings(), r = Array.isArray(e) ? e : [e], i = [];
165
- for (let e of r) {
166
- let r = this._parseDateString(e, t);
167
- if (r) {
168
- let e = this._formatDate(r, t);
169
- n.includes(e) || i.push(e);
170
- }
171
- }
172
- if (i.length > 0) {
173
- let e = [...n, ...i];
174
- this.setAttribute("disabled-dates", JSON.stringify(e)), this._buildCalendar();
175
- }
176
- }
177
- enableDate(e) {
178
- let t = this.getFormat(), n = this.getDisabledDateStrings(), r = Array.isArray(e) ? e : [e], i = [];
179
- for (let e of r) {
180
- let n = this._parseDateString(e, t);
181
- if (n) {
182
- let e = this._formatDate(n, t);
183
- i.push(e);
184
- }
185
- }
186
- if (i.length > 0) {
187
- let e = n.filter((e) => !i.includes(e));
188
- e.length === 0 ? this.removeAttribute("disabled-dates") : this.setAttribute("disabled-dates", JSON.stringify(e)), this._buildCalendar();
189
- }
190
- }
191
- getSelectionMode() {
192
- let e = this.getAttribute("selection-mode");
193
- return e === "week" || e === "month" ? e : "day";
194
- }
195
- getMode() {
196
- let e = this.getAttribute("mode");
197
- if (e === "month" || e === "year") return e;
198
- let t = this.getFormat().toLowerCase(), n = t.includes("d"), r = t.includes("m");
199
- return !n && !r ? "year" : !n && r ? "month" : "default";
200
- }
201
- getWeekStartDay() {
202
- return {
203
- sunday: 0,
204
- monday: 1,
205
- tuesday: 2,
206
- wednesday: 3,
207
- thursday: 4,
208
- friday: 5,
209
- saturday: 6
210
- }[this.getAttribute("week-start-day")?.toLowerCase() || "sunday"] ?? 0;
211
- }
212
- getDisplayFormat() {
213
- return this.getAttribute("display-format") || "F j, Y";
214
- }
215
- getShortcuts() {
216
- let e = this.getAttribute("shortcuts");
217
- if (!e) return [];
218
- try {
219
- let t = JSON.parse(e);
220
- if (Array.isArray(t)) return t.map((e) => ({
221
- label: e.label,
222
- action: this._createShortcutAction(e.action)
223
- }));
224
- } catch {
225
- let t = e.trim();
226
- if (t && typeof window[t] == "function") {
227
- let e = window[t]();
228
- if (Array.isArray(e)) return e.map((e) => ({
229
- label: e.label,
230
- action: typeof e.action == "function" ? e.action : this._createShortcutAction(e.action)
231
- }));
232
- }
233
- }
234
- return [];
235
- }
236
- _createShortcutAction(e) {
237
- return typeof e == "function" ? e : typeof e == "string" && typeof window[e] == "function" ? window[e] : () => null;
238
- }
239
- _getDefaultShortcuts() {
240
- let e = [{
241
- label: "Today",
242
- action: () => /* @__PURE__ */ new Date()
243
- }];
244
- return this._isRange && e.push({
245
- label: "This Week",
246
- action: () => {
247
- let e = /* @__PURE__ */ new Date(), t = e.getDay(), n = new Date(e);
248
- n.setDate(e.getDate() - t), n.setHours(0, 0, 0, 0);
249
- let r = new Date(n);
250
- return r.setDate(n.getDate() + 6), r.setHours(23, 59, 59, 999), {
251
- start: n,
252
- end: r
253
- };
254
- }
255
- }, {
256
- label: "This Month",
257
- action: () => {
258
- let e = /* @__PURE__ */ new Date(), t = new Date(e.getFullYear(), e.getMonth(), 1), n = new Date(e.getFullYear(), e.getMonth() + 1, 0);
259
- return n.setHours(23, 59, 59, 999), {
260
- start: t,
261
- end: n
262
- };
263
- }
264
- }), e;
265
- }
266
- _getFormatTokens(e) {
267
- let t = [], n = 0, r = e.toLowerCase();
268
- for (; n < r.length;) {
269
- let i = r[n];
270
- if (i === "d" || i === "m" || i === "y") {
271
- let e = 1, a = n + 1;
272
- for (; a < r.length && r[a] === i;) e++, a++;
273
- t.push({
274
- type: "part",
275
- part: i,
276
- len: e
277
- }), n = a;
278
- } else t.push({
279
- type: "sep",
280
- value: e[n]
281
- }), n++;
282
- }
283
- return t;
284
- }
285
- _createPartInput(e, t, n, r, i) {
286
- let a = document.createElement("input");
287
- return a.type = "text", a.inputMode = "numeric", a.pattern = "\\d*", a.maxLength = e, a.placeholder = t, a.className = "mint-date-picker-part-input", a.disabled = n || r, a.readOnly = r, a.required = i, e === 4 ? a.classList.add("is-year-part") : e === 2 && a.classList.add("is-short-part"), a;
288
- }
289
- _buildValueFromParts(e, t) {
290
- let n = 0;
291
- return t.map((t) => {
292
- if (t.type === "sep") return t.value;
293
- let r = e[n]?.value || "";
294
- return n++, r;
295
- }).join("");
296
- }
297
- _applyDateToParts(e, t, n, r) {
298
- if (!t.length) return;
299
- if (!e) {
300
- t.forEach((e) => e.value = "");
301
- return;
302
- }
303
- let i = this._formatDate(e, r), a = 0, o = 0;
304
- n.forEach((e) => {
305
- if (e.type === "sep") a += e.value.length;
306
- else {
307
- let n = i.substr(a, e.len);
308
- t[o] && (t[o].value = n), o++, a += e.len;
309
- }
310
- });
311
- }
312
- _syncHiddenInput() {
313
- if (!this._hiddenInput) return;
314
- let e = this.getFormat(), t = this._getFormatTokens(e), n = this._buildValueFromParts(this._startPartInputs, t);
315
- if (this._isRange) {
316
- let e = this._buildValueFromParts(this._endPartInputs, t);
317
- this._hiddenInput.value = e ? `${n} - ${e}` : n;
318
- } else this._hiddenInput.value = n;
319
- }
320
- _focusNext(e, t) {
321
- if (t + 1 < e.length) {
322
- let n = e[t + 1];
323
- n.focus(), n.setSelectionRange(0, n.value.length);
324
- }
325
- }
326
- _focusPrev(e, t) {
327
- if (t - 1 >= 0) {
328
- let n = e[t - 1];
329
- n.focus(), n.setSelectionRange(n.value.length, n.value.length);
330
- }
331
- }
332
- _attachPartInputHandlers(e, t, n) {
333
- e.forEach((t, n) => {
334
- let r = t.maxLength || 2;
335
- t.addEventListener("input", () => {
336
- t.value = t.value.replace(/\D/g, "").slice(0, r), t.value.length >= r && this._focusNext(e, n), this._syncHiddenInput();
337
- }), t.addEventListener("keydown", (r) => {
338
- r.key === "Backspace" && t.selectionStart === 0 && t.selectionEnd === 0 && this._focusPrev(e, n), r.key === "ArrowLeft" && t.selectionStart === 0 && t.selectionEnd === 0 && (this._focusPrev(e, n), r.preventDefault()), r.key === "ArrowRight" && t.selectionStart === t.value.length && t.selectionEnd === t.value.length && (this._focusNext(e, n), r.preventDefault());
339
- }), t.addEventListener("blur", (e) => {
340
- this._syncHiddenInput();
341
- let t = e.relatedTarget, n = t && (this._startPartInputs.includes(t) || this._endPartInputs.includes(t));
342
- setTimeout(() => {
343
- if (!(this._startPartInputs.some((e) => e === document.activeElement) || this._endPartInputs.some((e) => e === document.activeElement)) && (n || this._handleBlur(this._hiddenInput?.value || ""), this._exitInputMode(), !n && this._hiddenInput)) {
344
- let t = new FocusEvent("blur", {
345
- bubbles: !0,
346
- cancelable: !0,
347
- relatedTarget: e.relatedTarget
348
- });
349
- this._hiddenInput.dispatchEvent(t);
350
- }
351
- }, 0);
352
- });
353
- });
354
- }
355
- _splitRangeInput(e, t) {
356
- let n = e.split(/\s*-\s*/);
357
- return n.length >= 2 ? [n[0], n.slice(1).join("-")] : [e];
358
- }
359
- _parseValue(e) {
360
- let t = this.getFormat(), n = this._getFormatTokens(t), r = this.getSelectionMode();
361
- if (this._isRange || r === "week" || r === "month") {
362
- let [r, i] = this._splitRangeInput(e, t), a = r ? this._parseDateString(r, t) : null, o = i ? this._parseDateString(i, t) : null;
363
- if (a && o) {
364
- let [e, t] = a <= o ? [a, o] : [o, a];
365
- this._selectedStartDate = e, this._selectedEndDate = t, this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
366
- } else a && (this._selectedStartDate = a, this._selectedEndDate = null, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear());
367
- this._applyDateToParts(this._selectedStartDate, this._startPartInputs, n, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, n, t);
368
- } else {
369
- let r = this._parseDateString(e, t);
370
- r && !isNaN(r.getTime()) ? (this._selectedStartDate = r, this._selectedEndDate = null, this._currentMonth = r.getMonth(), this._currentYear = r.getFullYear(), this._applyDateToParts(r, this._startPartInputs, n, t)) : this._applyDateToParts(null, this._startPartInputs, n, t);
371
- }
372
- this._syncHiddenInput(), this._updateDisplayText();
373
- }
374
- _parseDateString(e, t) {
375
- let n = /[\/\-\.\s]+/;
376
- if (n.test(e)) {
377
- let r = e.split(n).filter((e) => e.length > 0), i = t.split(/[\/\-\.\s]+/).filter((e) => e.length > 0);
378
- if (r.length === i.length) {
379
- let e = 0, t = 0, n = 0;
380
- for (let a = 0; a < i.length; a++) {
381
- let o = i[a].toLowerCase(), s = r[a];
382
- if (o.includes("d")) e = parseInt(s, 10);
383
- else if (o.includes("m")) t = parseInt(s, 10) - 1;
384
- else if (o.includes("y")) {
385
- let e = parseInt(s, 10), t = o.length, r = s.length;
386
- (r === 2 && t === 4 || r === 2 && t === 2) && (e = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + e), n = e;
387
- }
388
- }
389
- let a = i.some((e) => e.toLowerCase().includes("d")), o = i.some((e) => e.toLowerCase().includes("m"));
390
- if (a || (e = 1), o || (t = 0), t >= 0 && t <= 11 && n) {
391
- let r = new Date(n, t, e);
392
- if (!isNaN(r.getTime())) return a && r.getDate() !== e || r.getMonth() !== t || r.getFullYear() !== n ? null : r;
393
- }
394
- }
395
- }
396
- let r = e.replace(/[\/\-\.]/g, ""), i = t.replace(/[\/\-\.]/g, "").toLowerCase(), a = i.indexOf("d"), o = i.indexOf("m"), s = i.indexOf("y"), c = [
397
- {
398
- char: "d",
399
- index: a
400
- },
401
- {
402
- char: "m",
403
- index: o
404
- },
405
- {
406
- char: "y",
407
- index: s
408
- }
409
- ].sort((e, t) => e.index - t.index), l = 0, u = 0, d = 0, f = 0;
410
- i.length, r.length;
411
- for (let e of c) if (e.char === "d") {
412
- let e = i.lastIndexOf("d") - i.indexOf("d") + 1, t = r.substr(f, e);
413
- if (t.length === 0) return null;
414
- l = parseInt(t, 10), f += t.length;
415
- } else if (e.char === "m") {
416
- let e = i.lastIndexOf("m") - i.indexOf("m") + 1, t = r.substr(f, e);
417
- if (t.length === 0) return null;
418
- u = parseInt(t, 10) - 1, f += t.length;
419
- } else if (e.char === "y") {
420
- let e = i.lastIndexOf("y") - i.indexOf("y") + 1, t = r.substr(f), n = Math.min(e, t.length), a = t.substr(0, n);
421
- if (a.length === 0) return null;
422
- let o = parseInt(a, 10);
423
- (n === 2 && e === 4 || n === 2 && e === 2) && (o = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + o), d = o, f += n;
424
- }
425
- let p = t.toLowerCase(), m = p.includes("d"), h = p.includes("m");
426
- if (m || (l = 1), h || (u = 0), u < 0 || u > 11 || !d) return null;
427
- let g = new Date(d, u, l);
428
- return isNaN(g.getTime()) || m && g.getDate() !== l || g.getMonth() !== u || g.getFullYear() !== d ? null : g;
429
- }
430
- _formatDate(e, t) {
431
- let n = e.getDate(), r = e.getMonth() + 1, i = e.getFullYear(), a = t.toLowerCase(), o = t;
432
- return a.includes("dd") ? o = o.replace(/dd/gi, String(n).padStart(2, "0")) : a.includes("d") && (o = o.replace(/d/gi, String(n))), a.includes("mm") ? o = o.replace(/mm/gi, String(r).padStart(2, "0")) : a.includes("m") && (o = o.replace(/m/gi, String(r))), a.includes("yyyy") ? o = o.replace(/yyyy/gi, String(i)) : a.includes("yy") && (o = o.replace(/yy/gi, String(i).substr(2))), o;
433
- }
434
- _formatDatePhp(e, t) {
435
- let n = e.getDate(), r = e.getMonth() + 1, i = e.getFullYear(), a = [
436
- "Sunday",
437
- "Monday",
438
- "Tuesday",
439
- "Wednesday",
440
- "Thursday",
441
- "Friday",
442
- "Saturday"
443
- ], o = [
444
- "Sun",
445
- "Mon",
446
- "Tue",
447
- "Wed",
448
- "Thu",
449
- "Fri",
450
- "Sat"
451
- ], s = [
452
- "January",
453
- "February",
454
- "March",
455
- "April",
456
- "May",
457
- "June",
458
- "July",
459
- "August",
460
- "September",
461
- "October",
462
- "November",
463
- "December"
464
- ], c = [
465
- "Jan",
466
- "Feb",
467
- "Mar",
468
- "Apr",
469
- "May",
470
- "Jun",
471
- "Jul",
472
- "Aug",
473
- "Sep",
474
- "Oct",
475
- "Nov",
476
- "Dec"
477
- ], l = (e, t = 2) => e.toString().padStart(t, "0"), u = (e) => {
478
- let t = e % 10, n = e % 100;
479
- return t === 1 && n !== 11 ? "st" : t === 2 && n !== 12 ? "nd" : t === 3 && n !== 13 ? "rd" : "th";
480
- }, d = "";
481
- for (let f = 0; f < t.length; f++) {
482
- let p = t[f];
483
- if (p === "\\" && f + 1 < t.length) {
484
- d += t[f + 1], f++;
485
- continue;
486
- }
487
- switch (p) {
488
- case "Y":
489
- d += i.toString();
490
- break;
491
- case "y":
492
- d += i.toString().slice(-2);
493
- break;
494
- case "m":
495
- d += l(r);
496
- break;
497
- case "n":
498
- d += r.toString();
499
- break;
500
- case "M":
501
- d += c[r - 1];
502
- break;
503
- case "F":
504
- d += s[r - 1];
505
- break;
506
- case "d":
507
- d += l(n);
508
- break;
509
- case "j":
510
- d += n.toString();
511
- break;
512
- case "D":
513
- d += o[e.getDay()];
514
- break;
515
- case "l":
516
- d += a[e.getDay()];
517
- break;
518
- case "S":
519
- d += u(n);
520
- break;
521
- default:
522
- d += p;
523
- break;
524
- }
525
- }
526
- return d;
527
- }
528
- _validateDateString(e, t) {
529
- let n = this._parseDateString(e, t);
530
- return n !== null && !isNaN(n.getTime());
531
- }
532
- render() {
533
- let e = this.isLoading(), t = this.getLabel(), n = this.getInfo(), r = this.getValue(), i = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), s = this.getId() || this._a11yId, c = this.getName(), l = this.getFormat(), u = this.hasError(), d = this.getErrorMessage(), f = this.getSelectionMode();
534
- this._isRange = this.isRange() || f === "week" || f === "month", this._input || (this._input = document.createElement("div"), this._input.className = "mint-date-picker-field", this.appendChild(this._input));
535
- let p = this.querySelector(".mint-date-picker-label-container");
536
- if (t || n) {
537
- p || (p = document.createElement("div"), p.className = "mint-date-picker-label-container", this.contains(this._input) ? this.insertBefore(p, this._input) : this.appendChild(p));
538
- let e = p.querySelector(".mint-date-picker-label");
539
- t ? (e || (e = document.createElement("label"), e.className = "mint-date-picker-label", p.insertBefore(e, p.firstChild)), e.textContent = t, s && this._textInput && e.setAttribute("for", s)) : e && e.remove();
540
- let r = p.querySelector(".mint-date-picker-info");
541
- n ? (r || (r = document.createElement("span"), r.className = "mint-date-picker-info", p.appendChild(r)), r.textContent = n) : r && r.remove();
542
- } else p && p.remove();
543
- this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = r || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), s && (this._hiddenInput.id = s), c && (this._hiddenInput.name = c), this._hiddenInput.value = r || "", this._hiddenInput.setAttribute("aria-invalid", u ? "true" : "false");
544
- let m = this._input.querySelector(".mint-date-fields");
545
- m || (m = document.createElement("div"), this._input.appendChild(m)), this._fieldsContainer = m, this._applyErrorVisuals(u, d, i), m.innerHTML = "", this._displayEl = document.createElement("div"), this._displayEl.className = `mint-date-picker-display${a ? " is-readonly" : ""}`, this._displayEl.tabIndex = i || a ? -1 : 0, this._displayEl.setAttribute("role", "button"), this._displayEl.setAttribute("aria-label", `${this.getLabel() || "Date"}: ${r || "Select date"}`), this._displayEl.addEventListener("click", () => {
546
- i || a || this._enterInputMode();
547
- }), this._displayEl.addEventListener("keydown", (e) => {
548
- i || a || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._enterInputMode());
549
- }), this._inputsWrapperEl = document.createElement("div"), this._isRange, this._inputsWrapperEl.className = "mint-date-picker-inputs";
550
- let h = this._getFormatTokens(l);
551
- this._startPartInputs = [], this._endPartInputs = [];
552
- let g = (e) => {
553
- let t = document.createDocumentFragment();
554
- return h.forEach((n) => {
555
- if (n.type === "sep") {
556
- let e = document.createElement("span");
557
- e.textContent = n.value, e.className = "mint-date-picker-separator", t.appendChild(e);
558
- } else {
559
- let r = n.part === "d" ? "dd" : n.part === "m" ? "mm" : n.len === 2 ? "yy" : "yyyy", s = this._createPartInput(n.len, r, i, a, o), c = n.part === "d" ? "day" : n.part === "m" ? "month" : "year", l = this.getLabel() || "Date";
560
- s.setAttribute("aria-label", `${e === "end" ? `End ${l.toLowerCase()}` : l} ${c}`), e === "start" ? this._startPartInputs.push(s) : this._endPartInputs.push(s), t.appendChild(s);
561
- }
562
- }), t;
563
- };
564
- if (this._isRange) {
565
- let e = document.createElement("div");
566
- e.className = "mint-date-picker-range-part", e.appendChild(g("start")), this._inputsWrapperEl.appendChild(e);
567
- let t = document.createElement("span");
568
- t.textContent = " - ", t.className = "mint-date-picker-range-dash", this._inputsWrapperEl.appendChild(t);
569
- let n = document.createElement("div");
570
- n.className = "mint-date-picker-range-part", n.appendChild(g("end")), this._inputsWrapperEl.appendChild(n);
571
- } else this._inputsWrapperEl.appendChild(g("start"));
572
- let _ = document.createElement("div");
573
- if (_.className = "mint-date-picker-stacked", this.classList.toggle("is-input-mode", this._isInputMode), _.appendChild(this._displayEl), _.appendChild(this._inputsWrapperEl), m.appendChild(_), this._isRange && this._inputsWrapperEl && this._setupContainerObserver(), m.addEventListener("click", () => {
574
- this._isInputMode || i || a || this._enterInputMode();
575
- }), this._attachPartInputHandlers(this._startPartInputs, h, m), this._isRange && this._attachPartInputHandlers(this._endPartInputs, h, m), this._parseValue(r), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton) this._iconButton.disabled = i || a, !i && !a ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
576
- else {
577
- this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "mint-date-picker-icon-button", this._iconButton.setAttribute("aria-label", "Open calendar"), this._iconButton.setAttribute("aria-haspopup", "dialog"), this._iconButton.setAttribute("aria-expanded", "false");
578
- let e = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
579
- this._iconButton.id = e;
580
- let t = document.createElement("mint-icon");
581
- t.setAttribute("name", "calendar"), t.className = "mint-date-picker-icon", this._iconButton.appendChild(t), this._input.prepend(this._iconButton), this._iconButton.disabled = i || a;
582
- }
583
- this._renderErrorState(u, d), this._syncDateFieldDescriptions(), this._renderSkeleton(e);
584
- }
585
- _renderErrorState(e, t) {
586
- let n = this.querySelector(".mint-date-picker-error");
587
- e && t ? (n || (n = document.createElement("div"), n.className = "mint-date-picker-error", this.appendChild(n)), n.textContent = t) : n && n.remove();
588
- }
589
- _syncDateFieldDescriptions() {
590
- let e = Array.from(this.querySelectorAll(".mint-date-fields input"));
591
- if (!e.length) return;
592
- let t = (this.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean), n = this.querySelector(".mint-date-picker-info"), r = this.querySelector(".mint-date-picker-error"), i = this.getAttribute("id") || this._a11yId;
593
- n && (n.id = `${i}-info`, t.push(n.id)), r && (r.id = `${i}-error`, t.push(r.id));
594
- let a = Array.from(new Set(t)).join(" ");
595
- e.forEach((e) => {
596
- e.setAttribute("aria-invalid", String(this._hiddenInput?.getAttribute("aria-invalid") === "true")), a ? e.setAttribute("aria-describedby", a) : e.removeAttribute("aria-describedby");
597
- });
598
- }
599
- _applyErrorVisuals(e, t, n) {
600
- if (this._renderErrorState(e, t), this._fieldsContainer) {
601
- let t = this._getFieldContainerClass(e, n);
602
- this._fieldsContainer.className = t;
603
- }
604
- this._hiddenInput && this._hiddenInput.setAttribute("aria-invalid", e ? "true" : "false"), this._syncDateFieldDescriptions();
605
- }
606
- _attachFormResetListener() {
607
- let e = this.closest("form");
608
- !e || this._resetHandler || (this._resetHandler = () => {
609
- this.setValue(""), this._clearPartInputs(this._startPartInputs), this._clearPartInputs(this._endPartInputs), this._isInputMode = !1, this._updateDisplayText(), this._applyErrorVisuals(!1, "", this.isDisabled());
610
- }, e.addEventListener("reset", this._resetHandler));
611
- }
612
- _clearPartInputs(e) {
613
- e.forEach((e) => {
614
- e.value = "";
615
- });
616
- }
617
- _getFieldContainerClass(e, t) {
618
- return `mint-date-fields${e ? " has-error" : ""}${t ? " is-disabled" : ""}`;
619
- }
620
- _handleInputChange(e) {}
621
- _cleanInputValue(e, t) {
622
- return e;
623
- }
624
- _handleBlur(e) {
625
- let t = this.getFormat(), n = this.getSelectionMode(), r = this._isRange || n === "week" || n === "month";
626
- if (!e) {
627
- this.setValue(""), this._updateDisplayText();
628
- return;
629
- }
630
- if (r) {
631
- let [n, r] = this._splitRangeInput(e, t), i = n ? this._parseDateString(n, t) : null, a = r ? this._parseDateString(r, t) : null;
632
- if (i && a) {
633
- let [e, n] = i <= a ? [i, a] : [a, i], r = `${this._formatDate(e, t)} - ${this._formatDate(n, t)}`;
634
- this.setValue(r), this._applyDateToParts(e, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(n, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = e, this._selectedEndDate = n, this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
635
- } else if (i) {
636
- let e = this._formatDate(i, t);
637
- this.setValue(e), this._applyDateToParts(i, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = i, this._selectedEndDate = null, this._currentMonth = i.getMonth(), this._currentYear = i.getFullYear();
638
- } else this.setValue(""), this._applyDateToParts(null, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = null, this._selectedEndDate = null;
639
- } else if (this._validateDateString(e, t)) {
640
- let n = this._parseDateString(e, t);
641
- if (n) {
642
- let e = this._formatDate(n, t);
643
- this.setValue(e), this._applyDateToParts(n, this._startPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear();
644
- }
645
- } else this.setValue(""), this._applyDateToParts(null, this._startPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = null, this._selectedEndDate = null;
646
- }
647
- _setupPopoverWithRetry(e = 0) {
648
- if (!this._iconButton) {
649
- e < 10 && requestAnimationFrame(() => {
650
- this._setupPopoverWithRetry(e + 1);
651
- });
652
- return;
653
- }
654
- let t = this._iconButton.id;
655
- t && this._iconButton.isConnected && document.getElementById(t) ? this._createPopover(t) : e < 10 && requestAnimationFrame(() => {
656
- this._setupPopoverWithRetry(e + 1);
657
- });
658
- }
659
- _createPopover(e) {
660
- if (e) {
661
- if (!document.getElementById(e)) {
662
- setTimeout(() => {
663
- this._createPopover(e);
664
- }, 50);
665
- return;
666
- }
667
- if (this._popover) {
668
- if (this._popover.getAttribute("trigger-id") !== e) {
669
- this._popover.setAttribute("trigger-id", e);
670
- let t = this._popover;
671
- typeof t._setupTrigger == "function" && t._setupTrigger();
672
- }
673
- this._buildCalendar();
674
- } else {
675
- this._popover = document.createElement("mint-popover"), this._popover.classList.add("mint-date-picker-popover"), this._popover.setAttribute("direction", "down"), this._popover.setAttribute("padding", "0");
676
- let t = this.closest("mint-modal"), n = this.closest("mint-off-canvas");
677
- t || n ? document.body.appendChild(this._popover) : this.parentNode ? this.parentNode.insertBefore(this._popover, this.nextSibling) : document.body.appendChild(this._popover), requestAnimationFrame(() => {
678
- requestAnimationFrame(() => {
679
- this._popover && this._popover.isConnected && (this._popover.setAttribute("trigger-id", e), this._popoverObserver || (this._popoverObserver = new MutationObserver((e) => {
680
- e.forEach((e) => {
681
- if (e.type === "attributes" && e.attributeName === "open") if (this._popover?.hasAttribute("open")) requestAnimationFrame(() => {
682
- this._buildCalendar();
683
- let e = this._popover;
684
- typeof e.render == "function" && e.render(), this._setupFocusTrap();
685
- });
686
- else {
687
- if (this._removeFocusTrap(), this._iconButton && !this._iconButton.disabled && requestAnimationFrame(() => {
688
- this._iconButton?.focus();
689
- }), this._viewMode = "calendar", this._selectedStartDate) this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
690
- else {
691
- let e = /* @__PURE__ */ new Date();
692
- this._currentMonth = e.getMonth(), this._currentYear = e.getFullYear();
693
- }
694
- requestAnimationFrame(() => {
695
- this._buildCalendar();
696
- }), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
697
- let e = new FocusEvent("blur", {
698
- bubbles: !0,
699
- cancelable: !0,
700
- relatedTarget: null
701
- });
702
- this._hiddenInput?.dispatchEvent(e);
703
- }, 0));
704
- }
705
- });
706
- }), this._popoverObserver.observe(this._popover, {
707
- attributes: !0,
708
- attributeFilter: ["open"]
709
- })), requestAnimationFrame(() => {
710
- this._buildCalendar();
711
- }));
712
- });
713
- });
714
- }
715
- }
716
- }
717
- _buildCalendar() {
718
- if (!this._popover) return;
719
- this._calendarContainer && this._calendarContainer.parentNode && this._calendarContainer.remove(), this._calendarContainer = document.createElement("div"), this._calendarContainer.className = "mint-date-calendar";
720
- let e = this.getMode();
721
- e === "month" && this._viewMode === "calendar" ? this._viewMode = "month" : e === "year" && this._viewMode === "calendar" ? this._viewMode = "year" : e === "default" && this._viewMode !== "month" && this._viewMode !== "year" && (this._viewMode = "calendar"), this._viewMode === "calendar" ? this._buildCalendarView() : this._viewMode === "month" ? this._buildMonthView() : this._viewMode === "year" && this._buildYearView(), this._popover.replaceChildren(this._calendarContainer);
722
- }
723
- _buildCalendarView() {
724
- if (!this._calendarContainer) return;
725
- let e = this._getDaysInMonth(this._currentMonth, this._currentYear), t = this._getFirstDayOfMonth(this._currentMonth, this._currentYear), n = [
726
- "January",
727
- "February",
728
- "March",
729
- "April",
730
- "May",
731
- "June",
732
- "July",
733
- "August",
734
- "September",
735
- "October",
736
- "November",
737
- "December"
738
- ], r = this.getWeekStartDay(), i = [
739
- "Sun",
740
- "Mon",
741
- "Tue",
742
- "Wed",
743
- "Thu",
744
- "Fri",
745
- "Sat"
746
- ], a = [...i.slice(r), ...i.slice(0, r)], o = this.getShortcuts(), s = o.length > 0;
747
- this._calendarContainer.className = `mint-date-calendar${s ? " has-shortcuts" : ""}`;
748
- let c = document.createElement("div");
749
- c.className = "mint-date-calendar-layout";
750
- let l = document.createElement("div");
751
- l.className = "mint-date-calendar-content";
752
- let u = document.createElement("div");
753
- u.className = "mint-date-calendar-header";
754
- let d = document.createElement("button");
755
- d.type = "button", d.tabIndex = 0, d.className = "mint-date-calendar-nav-button", d.setAttribute("aria-label", "Previous month"), d.setAttribute("data-keep-popover-open", "true");
756
- let f = document.createElement("mint-icon");
757
- f.setAttribute("name", "caret-left"), f.className = "mint-date-calendar-icon", d.appendChild(f), d.addEventListener("click", () => {
758
- let e = this._currentMonth, t = this._currentYear;
759
- this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
760
- }), u.appendChild(d);
761
- let p = document.createElement("div");
762
- p.className = "mint-date-calendar-month-year";
763
- let m = document.createElement("button");
764
- m.type = "button", m.tabIndex = 0, m.className = "mint-date-calendar-title-button", m.setAttribute("data-keep-popover-open", "true"), m.textContent = n[this._currentMonth], m.setAttribute("aria-label", `Choose month, ${n[this._currentMonth]}`);
765
- let h = () => {
766
- let e = this.getMode();
767
- e !== "month" && e !== "year" && (this._viewMode = "month", this._buildCalendar());
768
- };
769
- m.addEventListener("click", h), m.addEventListener("touchend", (e) => {
770
- e.preventDefault(), h();
771
- }, { passive: !1 }), p.appendChild(m);
772
- let g = document.createElement("button");
773
- g.type = "button", g.tabIndex = 0, g.className = "mint-date-calendar-title-button", g.setAttribute("data-keep-popover-open", "true"), g.textContent = String(this._currentYear), g.setAttribute("aria-label", `Choose year, ${this._currentYear}`), g.addEventListener("click", () => {
774
- this.getMode() !== "year" && (this._viewMode = "year", this._buildCalendar());
775
- }), p.appendChild(g), u.appendChild(p);
776
- let _ = document.createElement("button");
777
- _.type = "button", _.tabIndex = 0, _.className = "mint-date-calendar-nav-button", _.setAttribute("aria-label", "Next month"), _.setAttribute("data-keep-popover-open", "true");
778
- let v = document.createElement("mint-icon");
779
- v.setAttribute("name", "caret-right"), v.className = "mint-date-calendar-icon", _.appendChild(v);
780
- let y = () => {
781
- let e = this._currentMonth, t = this._currentYear;
782
- this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
783
- };
784
- _.addEventListener("click", y), _.addEventListener("touchend", (e) => {
785
- e.preventDefault(), y();
786
- }, { passive: !1 }), u.appendChild(_);
787
- let b = document.createElement("div");
788
- b.className = "mint-date-calendar-day-names", a.forEach((e) => {
789
- let t = document.createElement("div");
790
- t.className = "mint-date-calendar-day-name", t.textContent = e, b.appendChild(t);
791
- });
792
- let x = document.createElement("div");
793
- x.className = "mint-date-calendar-grid", x.setAttribute("role", "group"), x.setAttribute("aria-label", `${n[this._currentMonth]} ${this._currentYear}`);
794
- let S = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, C = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
795
- this.getDisabledDates();
796
- let w = this._currentMonth === 0 ? 11 : this._currentMonth - 1, T = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, E = this._getDaysInMonth(w, T), D = this._currentMonth === 11 ? 0 : this._currentMonth + 1, O = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, k = t + e, A = Math.ceil(k / 7) * 7 - k, j = (e, t, n) => {
797
- let r = this._isToday(e), i = this._isDateSelected(e), a = this._isDateInRange(e), o = S && e < S || C && e > C || this._isDateDisabled(e), s = "is-fully-rounded", c = this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate, l = c && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : c && this._hoveredDate ? this._hoveredDate : null, u = c && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._hoveredDate : c && this._selectedStartDate ? this._selectedStartDate : null, d = l !== null && this._isSameDate(e, l), f = u !== null && this._isSameDate(e, u), p = this._hoveredDate !== null && this._isSameDate(e, this._hoveredDate), m = c && this._hoveredDate && this._selectedStartDate ? !this._rangeIncludesDisabledDates(this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : this._hoveredDate, this._selectedStartDate < this._hoveredDate ? this._hoveredDate : this._selectedStartDate) : !1;
798
- if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
799
- let t = this._isSameDate(e, this._selectedStartDate), n = this._isSameDate(e, this._selectedEndDate);
800
- t && n ? s = "is-fully-rounded" : t ? s = "is-range-start" : n ? s = "is-range-end" : a && (s = "is-range-middle");
801
- } else c && (d || f) && m ? d && f ? s = "is-fully-rounded" : d ? s = "is-range-start" : f && (s = "is-range-end") : i && !this._isRange || i && this._isRange && !this._selectedEndDate ? s = "is-fully-rounded" : a && c && m && (s = "is-range-middle");
802
- let h = document.createElement("button");
803
- h.type = "button", h.disabled = !!o, h.tabIndex = o ? -1 : 0;
804
- let g = ["mint-date-picker-day", s], _ = i || c && p && m;
805
- return n || g.push("is-outside-month"), _ && g.push("is-selected"), a && !_ && g.push("is-in-range"), r && !_ && g.push("is-today"), o && g.push("is-disabled"), h.className = g.join(" "), h.textContent = t.toString(), h.setAttribute("aria-label", e.toLocaleDateString(void 0, {
806
- weekday: "long",
807
- year: "numeric",
808
- month: "long",
809
- day: "numeric"
810
- })), h.setAttribute("aria-pressed", String(i)), r && h.setAttribute("aria-current", "date"), o || (h.addEventListener("click", (t) => {
811
- t.preventDefault(), t.stopPropagation(), this._handleDateClick(e);
812
- }), h.addEventListener("touchstart", (t) => {
813
- t.preventDefault(), t.stopPropagation(), this._isTouchActive = !0, this._touchStartDate = e, this._touchStartElement = h, h.classList.add("is-touch-active");
814
- }, { passive: !1 }), h.addEventListener("touchend", (t) => {
815
- t.preventDefault(), t.stopPropagation(), this._isTouchActive && this._touchStartDate && this._isSameDate(this._touchStartDate, e) && this._handleDateClick(e), this._touchStartElement && this._touchStartElement.classList.remove("is-touch-active"), this._isTouchActive = !1, this._touchStartDate = null, this._touchStartElement = null;
816
- }, { passive: !1 }), h.addEventListener("touchcancel", () => {
817
- this._touchStartElement && this._touchStartElement.classList.remove("is-touch-active"), this._isTouchActive = !1, this._touchStartDate = null, this._touchStartElement = null;
818
- }), this._isRange && this._selectedStartDate && !this._selectedEndDate && !o && (h.addEventListener("mouseenter", () => {
819
- this._isHandlingClick || this._isTouchActive || this._isDateDisabled(e) || (!this._hoveredDate || !this._isSameDate(this._hoveredDate, e)) && (this._hoveredDate = e, this._buildCalendar());
820
- }), h.addEventListener("touchmove", (e) => {
821
- if (!this._isTouchActive || !this._touchStartDate) return;
822
- let t = e.touches[0], n = document.elementFromPoint(t.clientX, t.clientY);
823
- for (; n && !n.classList.contains("mint-date-picker-day");) n = n.parentElement;
824
- if (n && n !== h) {
825
- let e = n.getAttribute("data-date");
826
- if (e) {
827
- let t = new Date(e);
828
- this._isDateDisabled(t) || (!this._hoveredDate || !this._isSameDate(this._hoveredDate, t)) && (this._hoveredDate = t, this._buildCalendar());
829
- }
830
- }
831
- }, { passive: !0 }))), h;
832
- };
833
- for (let e = t - 1; e >= 0; e--) {
834
- let t = E - e, n = j(new Date(T, w, t), t, !1);
835
- x.appendChild(n);
836
- }
837
- for (let t = 1; t <= e; t++) {
838
- let e = j(new Date(this._currentYear, this._currentMonth, t), t, !0);
839
- x.appendChild(e);
840
- }
841
- for (let e = 1; e <= A; e++) {
842
- let t = j(new Date(O, D, e), e, !1);
843
- x.appendChild(t);
844
- }
845
- if (this._isRange && this._selectedStartDate && !this._selectedEndDate && (x.addEventListener("mouseleave", () => {
846
- this._isTouchActive || (this._hoveredDate = null, this._buildCalendar());
847
- }), x.addEventListener("touchend", (e) => {
848
- let t = e.changedTouches[0], n = document.elementFromPoint(t.clientX, t.clientY);
849
- n && !x.contains(n) && (this._hoveredDate = null, this._buildCalendar());
850
- }, { passive: !0 })), s) {
851
- let e = document.createElement("div");
852
- e.className = "mint-date-shortcuts";
853
- let t = document.createElement("div");
854
- t.className = "mint-date-shortcuts-wrapper";
855
- let n = document.createElement("div");
856
- n.className = "mint-date-shortcuts-row";
857
- let r = document.createElement("div");
858
- r.className = "mint-date-shortcuts-fade is-horizontal is-left", t.appendChild(r);
859
- let i = document.createElement("div");
860
- i.className = "mint-date-shortcuts-fade is-horizontal is-right is-visible", t.appendChild(i);
861
- let a = document.createElement("div");
862
- a.className = "mint-date-shortcuts-fade is-vertical is-top", t.appendChild(a);
863
- let s = document.createElement("div");
864
- s.className = "mint-date-shortcuts-fade is-vertical is-bottom is-visible", t.appendChild(s);
865
- let l = () => {
866
- if (window.innerWidth >= 768) {
867
- let e = n.scrollTop, t = n.scrollHeight, o = n.clientHeight;
868
- e > 0 ? a.classList.add("is-visible") : a.classList.remove("is-visible"), e + o < t - 1 ? s.classList.add("is-visible") : s.classList.remove("is-visible"), r.classList.remove("is-visible"), i.classList.remove("is-visible");
869
- } else {
870
- let e = n.scrollLeft, t = n.scrollWidth, o = n.clientWidth;
871
- e > 0 ? r.classList.add("is-visible") : r.classList.remove("is-visible"), e + o < t - 1 ? i.classList.add("is-visible") : i.classList.remove("is-visible"), a.classList.remove("is-visible"), s.classList.remove("is-visible");
872
- }
873
- };
874
- n.addEventListener("scroll", l), window.addEventListener("resize", l), setTimeout(l, 0), o.forEach((e) => {
875
- let t = document.createElement("button");
876
- t.type = "button", t.tabIndex = 0, t.className = "mint-date-shortcut-button", t.textContent = e.label;
877
- let r = () => {
878
- let t = e.action();
879
- if (t) {
880
- if (this._isRange && "start" in t && "end" in t) {
881
- this._selectedStartDate = t.start, this._selectedEndDate = t.end;
882
- let e = this.getFormat(), n = `${this._formatDate(t.start, e)} - ${this._formatDate(t.end, e)}`;
883
- this.setValue(n), this._currentMonth = t.start.getMonth(), this._currentYear = t.start.getFullYear();
884
- } else if (t instanceof Date) {
885
- this._selectedStartDate = t, this._selectedEndDate = null;
886
- let e = this.getFormat(), n = this._formatDate(t, e);
887
- this.setValue(n), this._currentMonth = t.getMonth(), this._currentYear = t.getFullYear();
888
- }
889
- this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
890
- detail: { value: this.getValue() },
891
- bubbles: !0,
892
- cancelable: !0
893
- })), this.dispatchEvent(new CustomEvent("change", {
894
- detail: { value: this.getValue() },
895
- bubbles: !0,
896
- cancelable: !0
897
- }));
898
- }
899
- };
900
- t.addEventListener("click", r), t.addEventListener("touchend", (e) => {
901
- e.preventDefault(), r();
902
- }, { passive: !1 }), n.appendChild(t);
903
- }), t.appendChild(n), e.appendChild(t), c.appendChild(e);
904
- }
905
- l.appendChild(u), l.appendChild(b), l.appendChild(x), c.appendChild(l), this._calendarContainer.appendChild(c);
906
- }
907
- _buildMonthView() {
908
- if (!this._calendarContainer) return;
909
- let e = [
910
- "January",
911
- "February",
912
- "March",
913
- "April",
914
- "May",
915
- "June",
916
- "July",
917
- "August",
918
- "September",
919
- "October",
920
- "November",
921
- "December"
922
- ], t = document.createElement("div");
923
- t.className = "mint-date-calendar-header";
924
- let n = document.createElement("button");
925
- n.type = "button", n.tabIndex = 0, n.className = "mint-date-calendar-nav-button", n.setAttribute("data-keep-popover-open", "true");
926
- let r = document.createElement("mint-icon");
927
- r.setAttribute("name", "caret-left"), r.className = "mint-date-calendar-icon", n.appendChild(r);
928
- let i = () => {
929
- let e = this._currentMonth, t = this._currentYear;
930
- this._currentYear--, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
931
- };
932
- n.addEventListener("click", i), n.addEventListener("touchend", (e) => {
933
- e.preventDefault(), i();
934
- }, { passive: !1 }), t.appendChild(n);
935
- let a = document.createElement("button");
936
- a.type = "button", a.tabIndex = 0, a.className = "mint-date-calendar-title-button", a.setAttribute("data-keep-popover-open", "true"), a.textContent = String(this._currentYear);
937
- let o = () => {
938
- this.getMode() !== "year" && (this._viewMode = "year", this._buildCalendar());
939
- };
940
- a.addEventListener("click", o), a.addEventListener("touchend", (e) => {
941
- e.preventDefault(), o();
942
- }, { passive: !1 }), t.appendChild(a);
943
- let s = document.createElement("button");
944
- s.type = "button", s.tabIndex = 0, s.className = "mint-date-calendar-nav-button", s.setAttribute("data-keep-popover-open", "true");
945
- let c = document.createElement("mint-icon");
946
- c.setAttribute("name", "caret-right"), c.className = "mint-date-calendar-icon", s.appendChild(c);
947
- let l = () => {
948
- let e = this._currentMonth, t = this._currentYear;
949
- this._currentYear++, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
950
- };
951
- s.addEventListener("click", l), s.addEventListener("touchend", (e) => {
952
- e.preventDefault(), l();
953
- }, { passive: !1 }), t.appendChild(s);
954
- let u = document.createElement("div");
955
- u.className = "mint-date-calendar-option-grid", e.forEach((e, t) => {
956
- let n = document.createElement("button");
957
- n.type = "button", n.tabIndex = 0, this.getMode() !== "month" && n.setAttribute("data-keep-popover-open", "true"), n.className = `mint-date-calendar-option${this._currentMonth === t ? " is-selected" : ""}`, n.textContent = e;
958
- let r = () => {
959
- if (this.getMode() === "month") {
960
- let e = new Date(this._currentYear, t, 1), n = this.getFormat(), r = this._formatDate(e, n);
961
- this.setValue(r), this._selectedStartDate = e, this._selectedEndDate = null;
962
- let i = this._currentMonth, a = this._currentYear;
963
- this._currentMonth = t, this._dispatchMonthChangeEvent(i, a, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
964
- detail: { value: this.getValue() },
965
- bubbles: !0,
966
- cancelable: !0
967
- })), this.dispatchEvent(new CustomEvent("change", {
968
- detail: { value: this.getValue() },
969
- bubbles: !0,
970
- cancelable: !0
971
- })), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
972
- } else {
973
- let e = this._currentMonth, n = this._currentYear;
974
- this._currentMonth = t, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(e, n, this._currentMonth, this._currentYear);
975
- }
976
- };
977
- n.addEventListener("click", r), n.addEventListener("touchend", (e) => {
978
- e.preventDefault(), r();
979
- }, { passive: !1 }), u.appendChild(n);
980
- }), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(u);
981
- }
982
- _buildYearView() {
983
- if (!this._calendarContainer) return;
984
- let e = this._currentYear - 6, t = this._currentYear + 6, n = document.createElement("div");
985
- n.className = "mint-date-calendar-header";
986
- let r = document.createElement("button");
987
- r.type = "button", r.tabIndex = 0, r.className = "mint-date-calendar-nav-button", r.setAttribute("data-keep-popover-open", "true");
988
- let i = document.createElement("mint-icon");
989
- i.setAttribute("name", "caret-left"), i.className = "mint-date-calendar-icon", r.appendChild(i);
990
- let a = () => {
991
- let e = this._currentMonth, t = this._currentYear;
992
- this._currentYear -= 12, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
993
- };
994
- r.addEventListener("click", a), r.addEventListener("touchend", (e) => {
995
- e.preventDefault(), a();
996
- }, { passive: !1 }), n.appendChild(r);
997
- let o = document.createElement("div");
998
- o.className = "mint-date-calendar-title", o.textContent = `${e} - ${t}`, n.appendChild(o);
999
- let s = document.createElement("button");
1000
- s.type = "button", s.tabIndex = 0, s.className = "mint-date-calendar-nav-button", s.setAttribute("data-keep-popover-open", "true");
1001
- let c = document.createElement("mint-icon");
1002
- c.setAttribute("name", "caret-right"), c.className = "mint-date-calendar-icon", s.appendChild(c);
1003
- let l = () => {
1004
- let e = this._currentMonth, t = this._currentYear;
1005
- this._currentYear += 12, this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1006
- };
1007
- s.addEventListener("click", l), s.addEventListener("touchend", (e) => {
1008
- e.preventDefault(), l();
1009
- }, { passive: !1 }), n.appendChild(s);
1010
- let u = document.createElement("div");
1011
- u.className = "mint-date-calendar-option-grid";
1012
- for (let n = e; n <= t; n++) {
1013
- let e = document.createElement("button");
1014
- e.type = "button", e.tabIndex = 0, this.getMode() !== "year" && e.setAttribute("data-keep-popover-open", "true"), e.className = `mint-date-calendar-option${this._currentYear === n ? " is-selected" : ""}`, e.textContent = String(n), e.addEventListener("click", () => {
1015
- let e = this.getMode();
1016
- if (e === "year") {
1017
- let e = new Date(n, 0, 1), t = this.getFormat(), r = this._formatDate(e, t);
1018
- this.setValue(r), this._selectedStartDate = e, this._selectedEndDate = null;
1019
- let i = this._currentMonth, a = this._currentYear;
1020
- this._currentYear = n, this._currentMonth = 0, this._dispatchMonthChangeEvent(i, a, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
1021
- detail: { value: this.getValue() },
1022
- bubbles: !0,
1023
- cancelable: !0
1024
- })), this.dispatchEvent(new CustomEvent("change", {
1025
- detail: { value: this.getValue() },
1026
- bubbles: !0,
1027
- cancelable: !0
1028
- })), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
1029
- } else if (e === "month") {
1030
- let e = this._currentMonth, t = this._currentYear;
1031
- this._currentYear = n, this._viewMode = "month", this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1032
- } else {
1033
- let e = this._currentMonth, t = this._currentYear;
1034
- this._currentYear = n, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(e, t, this._currentMonth, this._currentYear);
1035
- }
1036
- }), u.appendChild(e);
1037
- }
1038
- this._calendarContainer.appendChild(n), this._calendarContainer.appendChild(u);
1039
- }
1040
- _getDaysInMonth(e, t) {
1041
- return new Date(t, e + 1, 0).getDate();
1042
- }
1043
- _getFirstDayOfMonth(e, t) {
1044
- let n = this.getWeekStartDay(), r = new Date(t, e, 1).getDay();
1045
- return r >= n ? r - n : 7 - (n - r);
1046
- }
1047
- _isToday(e) {
1048
- let t = /* @__PURE__ */ new Date();
1049
- return e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear();
1050
- }
1051
- _isDateSelected(e) {
1052
- let t = this.getSelectionMode();
1053
- return this._isRange || t === "week" || t === "month" ? this._selectedStartDate && this._selectedEndDate ? this._isSameDate(e, this._selectedStartDate) || this._isSameDate(e, this._selectedEndDate) : this._isRange && this._selectedStartDate && !this._selectedEndDate ? this._isSameDate(e, this._selectedStartDate) : !1 : this._selectedStartDate !== null && this._isSameDate(e, this._selectedStartDate);
1054
- }
1055
- _isDateInRange(e) {
1056
- let t = this.getSelectionMode();
1057
- if ((this._isRange || t === "week" || t === "month") && this._selectedStartDate && this._selectedEndDate) return this._rangeIncludesDisabledDates(this._selectedStartDate, this._selectedEndDate) ? !1 : e >= this._selectedStartDate && e <= this._selectedEndDate;
1058
- if (this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate) {
1059
- let t = this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : this._hoveredDate, n = this._selectedStartDate < this._hoveredDate ? this._hoveredDate : this._selectedStartDate;
1060
- if (this._rangeIncludesDisabledDates(t, n)) {
1061
- let r = this._findFirstDisabledDateInRange(t, n);
1062
- return r ? this._selectedStartDate < this._hoveredDate ? e >= t && e < r && !this._isSameDate(e, t) : e > r && e <= n && !this._isSameDate(e, n) : !1;
1063
- }
1064
- return e >= t && e <= n && !this._isSameDate(e, t) && !this._isSameDate(e, n);
1065
- }
1066
- return !1;
1067
- }
1068
- _rangeIncludesDisabledDates(e, t) {
1069
- let n = this.getDisabledDates(), r = new Date(e.getFullYear(), e.getMonth(), e.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate());
1070
- return n.some((e) => {
1071
- let t = new Date(e.getFullYear(), e.getMonth(), e.getDate());
1072
- return t >= r && t <= i;
1073
- });
1074
- }
1075
- _findFirstDisabledDateInRange(e, t) {
1076
- let n = this.getDisabledDates(), r = new Date(e.getFullYear(), e.getMonth(), e.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate()), a = n.map((e) => new Date(e.getFullYear(), e.getMonth(), e.getDate())).filter((e) => e >= r && e <= i).sort((e, t) => e.getTime() - t.getTime());
1077
- return a.length > 0 ? a[0] : null;
1078
- }
1079
- _hasIncompleteRange() {
1080
- return this._isRange && this._selectedStartDate !== null && this._selectedEndDate === null;
1081
- }
1082
- _isSameDate(e, t) {
1083
- return e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear();
1084
- }
1085
- _isDateDisabled(e) {
1086
- return this.getDisabledDates().some((t) => this._isSameDate(e, t));
1087
- }
1088
- _dispatchMonthChangeEvent(e, t, n, r) {
1089
- (e !== n || t !== r) && this.dispatchEvent(new CustomEvent("month-change", {
1090
- detail: {
1091
- month: n,
1092
- year: r,
1093
- oldMonth: e,
1094
- oldYear: t
1095
- },
1096
- bubbles: !0,
1097
- cancelable: !0,
1098
- composed: !0
1099
- }));
1100
- }
1101
- _dispatchDateChangeEvent() {
1102
- let e = this.getFormat(), t = { value: this.getValue() };
1103
- this._selectedStartDate && (t.startDate = this._selectedStartDate, t.startDateFormatted = this._formatDate(this._selectedStartDate, e)), this._selectedEndDate && (t.endDate = this._selectedEndDate, t.endDateFormatted = this._formatDate(this._selectedEndDate, e)), this.dispatchEvent(new CustomEvent("date-change", {
1104
- detail: t,
1105
- bubbles: !0,
1106
- cancelable: !0,
1107
- composed: !0
1108
- }));
1109
- }
1110
- _setupContainerObserver() {
1111
- if (this._resizeObserver &&= (this._resizeObserver.disconnect(), null), !this._inputsWrapperEl) return;
1112
- let e = (e) => {
1113
- this._inputsWrapperEl && (e < 400 ? (this._inputsWrapperEl.classList.add("is-wrapping"), this._inputsWrapperEl.classList.remove("is-nowrap")) : (this._inputsWrapperEl.classList.remove("is-wrapping"), this._inputsWrapperEl.classList.add("is-nowrap")));
1114
- };
1115
- e(this._inputsWrapperEl.offsetWidth || this.offsetWidth), this._resizeObserver = new ResizeObserver((t) => {
1116
- for (let n of t) {
1117
- let t = n.contentRect.width;
1118
- e(t);
1119
- }
1120
- }), this._resizeObserver.observe(this);
1121
- }
1122
- _getWeekStart(e) {
1123
- let t = this.getWeekStartDay(), n = e.getDay(), r;
1124
- r = n >= t ? n - t : 7 - (t - n);
1125
- let i = new Date(e);
1126
- return i.setDate(e.getDate() - r), i.setHours(0, 0, 0, 0), i;
1127
- }
1128
- _getWeekEnd(e) {
1129
- let t = this._getWeekStart(e), n = new Date(t);
1130
- return n.setDate(t.getDate() + 6), n.setHours(23, 59, 59, 999), n;
1131
- }
1132
- _getMonthStart(e) {
1133
- let t = new Date(e.getFullYear(), e.getMonth(), 1);
1134
- return t.setHours(0, 0, 0, 0), t;
1135
- }
1136
- _getMonthEnd(e) {
1137
- let t = new Date(e.getFullYear(), e.getMonth() + 1, 0);
1138
- return t.setHours(23, 59, 59, 999), t;
1139
- }
1140
- _handleDateClick(e) {
1141
- this._isHandlingClick = !0;
1142
- try {
1143
- let t = this.getFormat(), n = this.getSelectionMode(), r, i;
1144
- if (n === "week" ? (r = this._getWeekStart(e), i = this._getWeekEnd(e)) : n === "month" ? (r = this._getMonthStart(e), i = this._getMonthEnd(e)) : (r = e, i = e), this.isRange() || n === "week" || n === "month") if (n === "week" || n === "month") {
1145
- if (this._rangeIncludesDisabledDates(r, i)) {
1146
- this._buildCalendar();
1147
- return;
1148
- }
1149
- this._selectedStartDate = r, this._selectedEndDate = i;
1150
- let e = `${this._formatDate(this._selectedStartDate, t)} - ${this._formatDate(this._selectedEndDate, t)}`;
1151
- this.setValue(e), this._textInput && (this._textInput.value = e), this._popover && typeof this._popover.close == "function" && this._popover.close();
1152
- } else if (this._hoveredDate = null, this._selectedStartDate === null) {
1153
- if (this._isDateDisabled(r)) {
1154
- this._buildCalendar();
1155
- return;
1156
- }
1157
- this._selectedStartDate = new Date(r.getFullYear(), r.getMonth(), r.getDate()), this._selectedEndDate = null, this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear(), this._hoveredDate = null, this._buildCalendar();
1158
- } else if (this._selectedEndDate === null) {
1159
- let n = new Date(e.getFullYear(), e.getMonth(), e.getDate()), r = this._selectedStartDate ? new Date(this._selectedStartDate.getFullYear(), this._selectedStartDate.getMonth(), this._selectedStartDate.getDate()) : null, i, a;
1160
- if (r && n < r ? (i = n, a = r) : (i = r, a = n), this._rangeIncludesDisabledDates(i, a)) {
1161
- this._buildCalendar();
1162
- return;
1163
- }
1164
- r && n < r ? (this._selectedEndDate = r, this._selectedStartDate = n) : (this._selectedEndDate = n, r && (this._selectedStartDate = r)), this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
1165
- let o = `${this._formatDate(this._selectedStartDate, t)} - ${this._formatDate(this._selectedEndDate, t)}`;
1166
- this.setAttribute("value", o), this._textInput && (this._textInput.value = o), this._hiddenInput && (this._hiddenInput.value = o), this._updateDisplayText(), this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close();
1167
- } else this._selectedStartDate = r, this._selectedEndDate = null;
1168
- else {
1169
- this._selectedStartDate = r, this._selectedEndDate = null;
1170
- let e = this._formatDate(r, t);
1171
- this.setValue(e), this._textInput && (this._textInput.value = e), this._popover && typeof this._popover.close == "function" && this._popover.close();
1172
- }
1173
- this._buildCalendar(), this._updateDisplayText(), this._exitInputMode();
1174
- let a = new Event("input", {
1175
- bubbles: !0,
1176
- cancelable: !0,
1177
- composed: !0
1178
- });
1179
- this.dispatchEvent(a), this.dispatchEvent(new CustomEvent("input", {
1180
- detail: { value: this.getValue() },
1181
- bubbles: !0,
1182
- cancelable: !0,
1183
- composed: !0
1184
- })), this.dispatchEvent(new CustomEvent("change", {
1185
- detail: { value: this.getValue() },
1186
- bubbles: !0,
1187
- cancelable: !0,
1188
- composed: !0
1189
- })), this._dispatchDateChangeEvent();
1190
- } finally {
1191
- this._isHandlingClick = !1;
1192
- }
1193
- }
1194
- _updateDisplayText() {
1195
- if (!this._displayEl) return;
1196
- let e = this.getDisplayFormat(), t = this.getSelectionMode(), n = this._isRange || t === "week" || t === "month", r = "";
1197
- n && this._selectedStartDate && this._selectedEndDate ? r = `${this._formatDatePhp(this._selectedStartDate, e)} - ${this._formatDatePhp(this._selectedEndDate, e)}` : this._selectedStartDate && (r = this._formatDatePhp(this._selectedStartDate, e)), r ? (this._displayEl.textContent = r, this._displayEl.classList.remove("is-empty")) : (this._displayEl.textContent = "Select date", this._displayEl.classList.add("is-empty")), this._displayEl && this._inputsWrapperEl && this.classList.toggle("is-input-mode", this._isInputMode);
1198
- }
1199
- _enterInputMode() {
1200
- if (!this._isInputMode && !(this.isReadonly() || this.isDisabled()) && (this._isInputMode = !0, this._displayEl && this._inputsWrapperEl && this.classList.add("is-input-mode"), this._startPartInputs.length > 0)) {
1201
- let e = this._startPartInputs[0];
1202
- requestAnimationFrame(() => {
1203
- e.focus();
1204
- try {
1205
- e.setSelectionRange(0, e.value.length);
1206
- } catch {}
1207
- });
1208
- }
1209
- }
1210
- _exitInputMode() {
1211
- this._isInputMode && (this._isInputMode = !1, this._displayEl && this._inputsWrapperEl && this.classList.remove("is-input-mode"), this._updateDisplayText());
1212
- }
1213
- _renderSkeleton(e) {
1214
- let t = this.querySelector(".mint-date-picker-skeleton-container");
1215
- this._fieldsContainer;
1216
- let n = this._input;
1217
- if (e) {
1218
- t || (t = document.createElement("div"), t.className = "mint-date-picker-skeleton-container", n ? n.appendChild(t) : (this.classList.add("is-positioned"), this.appendChild(t)));
1219
- let e = t.querySelector(".mint-date-picker-skeleton");
1220
- e || (e = document.createElement("div"), e.className = "mint-date-picker-skeleton", t.appendChild(e)), this.classList.add("is-loading");
1221
- } else t?.remove(), this.classList.remove("is-loading", "is-positioned");
1222
- }
1223
- _getFocusableElements() {
1224
- if (!this._calendarContainer) return [];
1225
- let e = [
1226
- "button:not([disabled])",
1227
- "a[href]",
1228
- "input:not([disabled]):not([type=\"hidden\"])",
1229
- "select:not([disabled])",
1230
- "textarea:not([disabled])",
1231
- "[tabindex]:not([tabindex=\"-1\"])"
1232
- ].join(", ");
1233
- return Array.from(this._calendarContainer.querySelectorAll(e)).filter((e) => {
1234
- let t = window.getComputedStyle(e);
1235
- return t.display !== "none" && t.visibility !== "hidden";
1236
- });
1237
- }
1238
- _setupFocusTrap() {
1239
- if (!this._popover || !this._popover.hasAttribute("open")) return;
1240
- this._removeFocusTrap();
1241
- let e = this;
1242
- this._focusTrapHandler = function(t) {
1243
- if (t.key !== "Tab") return;
1244
- if (!e._popover || !e._popover.hasAttribute("open")) {
1245
- e._removeFocusTrap();
1246
- return;
1247
- }
1248
- let n = e._getFocusableElements();
1249
- if (n.length === 0) return;
1250
- let r = n[0], i = n[n.length - 1], a = document.activeElement;
1251
- if (!e._calendarContainer?.contains(a)) {
1252
- t.preventDefault(), r.focus();
1253
- return;
1254
- }
1255
- if (t.shiftKey && a === r) {
1256
- t.preventDefault(), i.focus();
1257
- return;
1258
- }
1259
- if (!t.shiftKey && a === i) {
1260
- t.preventDefault(), r.focus();
1261
- return;
1262
- }
1263
- }, this._escapeHandler = function(t) {
1264
- (t.key === "Escape" || t.key === "Esc") && e._popover && e._popover.hasAttribute("open") && (t.preventDefault(), t.stopPropagation(), typeof e._popover.close == "function" && e._popover.close());
1265
- }, document.addEventListener("keydown", this._focusTrapHandler, !0), document.addEventListener("keydown", this._escapeHandler, !0), requestAnimationFrame(() => {
1266
- let e = this._getFocusableElements();
1267
- e.length > 0 && e[0].focus();
1268
- });
1269
- }
1270
- _removeFocusTrap() {
1271
- this._focusTrapHandler &&= (document.removeEventListener("keydown", this._focusTrapHandler, !0), null), this._escapeHandler &&= (document.removeEventListener("keydown", this._escapeHandler, !0), null);
1272
- }
1273
- };
1274
- customElements.get("mint-date-picker") || t("mint-date-picker", n);
1275
- //#endregion
1276
- export { n as default };
7
+ import { t as e } from "../chunks/date-picker-BQsCoKaK.js";
8
+ export { e as default };