@golemui/gui-react 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/Accordion-BU3skkjb.js +58 -0
  2. package/Alert-DpUiDxQT.js +17 -0
  3. package/Button-BYVR5EKG.js +86 -0
  4. package/CHANGELOG.md +8 -0
  5. package/{Calendar-Dxavv2c7.js → Calendar-BmMkpTcV.js} +13 -11
  6. package/Checkbox-B1Tsf-vi.js +164 -0
  7. package/Currency-D0pOQwU4.js +233 -0
  8. package/{DateInput-CdkyyAhc.js → DateInput-CqFHtc9F.js} +12 -10
  9. package/{DatePicker-TkMCndrw.js → DatePicker-BmW3TO0X.js} +18 -15
  10. package/{Dropdown-jKk4TyOa.js → Dropdown-C-_zDFCe.js} +5 -3
  11. package/Flex-Rs-RvIcq.js +20 -0
  12. package/{Grid-DREMTVQI.js → Grid-BcPUrfRL.js} +3 -2
  13. package/{List-BjMIo577.js → List-YkH8gdMh.js} +5 -3
  14. package/Markdown-DeAW4y3P.js +571 -0
  15. package/MarkdownText-BdISjAsE.js +11 -0
  16. package/Number-GsGZMR5a.js +247 -0
  17. package/Password-B8QjtpUe.js +204 -0
  18. package/RadioGroup-Cd1_Zkkz.js +197 -0
  19. package/{RangeCalendar-u2vxIhna.js → RangeCalendar-9IJoFEXw.js} +10 -8
  20. package/{RangeDateInput-CopLdb6J.js → RangeDateInput-DrVR4T_z.js} +21 -19
  21. package/{RangeDatePicker-DXpV-B_G.js → RangeDatePicker-Cq_Tt6NE.js} +38 -35
  22. package/{Renderer-B6WmwKDv.js → Renderer-CWqudTUu.js} +4 -2
  23. package/Repeater-DE-DAylQ.js +124 -0
  24. package/Select-CCCPYQW6.js +238 -0
  25. package/{Tabs-C2qqi8xO.js → Tabs-BVgVVvnu.js} +4 -3
  26. package/TextArea-BlRaVCon.js +202 -0
  27. package/TextInput-KuHLSN2X.js +169 -0
  28. package/Toggle-D-bglMPv.js +166 -0
  29. package/abstract-calendar-JfbbRwFb.js +528 -0
  30. package/calendar-BgptByan.js +95 -0
  31. package/class-map-DrTVAYz_.js +26 -0
  32. package/date-BS1lA1xg.js +786 -0
  33. package/date-input-Dux0mFJw.js +266 -0
  34. package/directive-1yd1wdny.js +555 -0
  35. package/errors-6UKoJh8Y.js +108 -0
  36. package/index.js +2705 -1171
  37. package/index.umd.cjs +878 -2
  38. package/lib/components/Accordion.d.ts +2 -2
  39. package/lib/components/Alert.d.ts +2 -2
  40. package/lib/components/Button.d.ts +2 -2
  41. package/lib/components/Calendar.d.ts +2 -2
  42. package/lib/components/Checkbox.d.ts +2 -2
  43. package/lib/components/Currency.d.ts +2 -2
  44. package/lib/components/DateInput.d.ts +2 -2
  45. package/lib/components/DatePicker.d.ts +2 -2
  46. package/lib/components/Dropdown.d.ts +2 -2
  47. package/lib/components/Flex.d.ts +2 -2
  48. package/lib/components/Form.d.ts +5 -5
  49. package/lib/components/Grid.d.ts +2 -2
  50. package/lib/components/List.d.ts +2 -2
  51. package/lib/components/Markdown.d.ts +2 -2
  52. package/lib/components/MarkdownText.d.ts +2 -2
  53. package/lib/components/Number.d.ts +2 -2
  54. package/lib/components/Password.d.ts +2 -2
  55. package/lib/components/RadioGroup.d.ts +2 -2
  56. package/lib/components/RangeCalendar.d.ts +2 -2
  57. package/lib/components/RangeDateInput.d.ts +2 -2
  58. package/lib/components/RangeDatePicker.d.ts +2 -2
  59. package/lib/components/Renderer.d.ts +2 -2
  60. package/lib/components/Repeater.d.ts +2 -2
  61. package/lib/components/Select.d.ts +2 -2
  62. package/lib/components/Tabs.d.ts +2 -2
  63. package/lib/components/TextArea.d.ts +2 -2
  64. package/lib/components/TextInput.d.ts +2 -2
  65. package/lib/components/Toggle.d.ts +2 -2
  66. package/lib/widget.loaders.d.ts +2 -2
  67. package/list-DHX7bG4r.js +282 -0
  68. package/live-BfTBpQrp.js +24 -0
  69. package/markdown-text-BUv0K0WF.js +44 -0
  70. package/one-of-DifUsEYY.js +48 -0
  71. package/package.json +6 -6
  72. package/query-h1h36oxg.js +12 -0
  73. package/range-calendar-SAyiW3EF.js +326 -0
  74. package/range-date-input-8WtB1urD.js +507 -0
  75. package/repeat-BucBfSPF.js +79 -0
  76. package/state-DI9ZsB5W.js +7 -0
  77. package/style-map-C_0XzJlx.js +29 -0
  78. package/tabs-DzSCq_98.js +13 -0
  79. package/templates-DBGyvZtc.js +75 -0
  80. package/Accordion-Btp_b0xA.js +0 -59
  81. package/Alert-CBgIsMKO.js +0 -16
  82. package/Button-DN0G-MUb.js +0 -21
  83. package/Checkbox-ViM9MktI.js +0 -30
  84. package/Currency-C4QFWO7Y.js +0 -37
  85. package/DefaultListItemRenderer-lNc9Kk7x.js +0 -18
  86. package/Flex-gD893rrB.js +0 -19
  87. package/Markdown-Ck_88HOR.js +0 -47
  88. package/MarkdownText-kJVkmihW.js +0 -9
  89. package/Number-CnQ95aLO.js +0 -35
  90. package/Password-Bg97DYW3.js +0 -36
  91. package/RadioGroup-Dldom5ja.js +0 -33
  92. package/Repeater-BYgXVfbl.js +0 -111
  93. package/Select-BLUX_W91.js +0 -55
  94. package/TextArea-cw3Q2v97.js +0 -35
  95. package/TextInput-geLoAA0c.js +0 -32
  96. package/Toggle-a7L71GwR.js +0 -30
@@ -0,0 +1,528 @@
1
+ import { i as M, A as _, b as u, n as o } from "./directive-1yd1wdny.js";
2
+ import { r as w } from "./state-DI9ZsB5W.js";
3
+ import { G as S, b as A, c as $ } from "./templates-DBGyvZtc.js";
4
+ import { c as D } from "./repeat-BucBfSPF.js";
5
+ import { d as I, e as k, t as v, w as B } from "./date-BS1lA1xg.js";
6
+ import "@golemui/gui-shared";
7
+ var Y = Object.defineProperty, s = (m, t, r, a) => {
8
+ for (var e = void 0, n = m.length - 1, l; n >= 0; n--)
9
+ (l = m[n]) && (e = l(t, r, e) || e);
10
+ return e && Y(t, r, e), e;
11
+ };
12
+ class i extends M {
13
+ constructor() {
14
+ super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = void 0, this.errors = [], this.touched = void 0, this.required = !1, this.disabled = !1, this.readOnly = !1, this.prevMonthIcon = "", this.nextMonthIcon = "", this.prevMonthAriaLabel = "", this.nextMonthAriaLabel = "", this.dayFormat = "numeric", this.weekdayFormat = "narrow", this.monthFormat = "long", this.minDate = void 0, this.maxDate = void 0, this.disabledRanges = void 0, this.numberOfMonths = 1, this._currentDate = /* @__PURE__ */ new Date(), this._yearSelectorOpen = !1, this.ariaController = new S(this, {
15
+ getTargets: () => this.querySelectorAll(".gui-calendar-input"),
16
+ getState: () => ({
17
+ uid: this.uid,
18
+ templateData: {
19
+ hint: this.hint,
20
+ errors: this.errors,
21
+ readonly: this.readOnly,
22
+ disabled: this.disabled,
23
+ touched: this.touched
24
+ }
25
+ })
26
+ });
27
+ }
28
+ renderAboveCalendar() {
29
+ return _;
30
+ }
31
+ render() {
32
+ const t = {
33
+ uid: this.uid,
34
+ label: this.label,
35
+ hint: this.hint,
36
+ errors: this.errors,
37
+ touched: this.touched,
38
+ required: this.required
39
+ }, r = Array.from({ length: this.numberOfMonths ?? 1 }, (a, e) => e);
40
+ return u`
41
+ ${this.label ? A(this.uid, t, !1, "calendar") : _}
42
+
43
+ <div class="gui-widget" @focusout=${this.onFocusOut}>
44
+ <div
45
+ id=${this.uid}
46
+ class="gui-calendar-input"
47
+ role="group"
48
+ aria-labelledby=${this.label ? `${this.uid}_calendar_label` : _}
49
+ ?aria-disabled=${this.disabled}
50
+ >
51
+ ${this.renderAboveCalendar()}
52
+ <div class="gui-calendar__container">
53
+ <button
54
+ type="button"
55
+ tabindex="0"
56
+ class="gui-button gui-calendar__month-button gui-calendar__month-button--prev"
57
+ ?disabled=${!this.canGoPrev()}
58
+ @click=${this.prevMonth}
59
+ aria-label=${this.prevMonthAriaLabel ?? "Previous month"}
60
+ >
61
+ ${this.prevMonthIcon ? u`<span
62
+ class=${`gui-widget-icon ${this.prevMonthIcon}`}
63
+ data-icon=${this.prevMonthIcon}
64
+ ></span>` : "<"}
65
+ </button>
66
+
67
+ <div class="gui-calendar__months-grid">
68
+ ${r.map((a) => this.renderMonthPanel(a))}
69
+ </div>
70
+
71
+ <button
72
+ type="button"
73
+ tabindex="0"
74
+ class="gui-button gui-calendar__month-button gui-calendar__month-button--next"
75
+ ?disabled=${!this.canGoNext()}
76
+ @click=${this.nextMonth}
77
+ aria-label=${this.nextMonthAriaLabel ?? "Next month"}
78
+ >
79
+ ${this.nextMonthIcon ? u`<span
80
+ class=${`gui-widget-icon ${this.nextMonthIcon}`}
81
+ data-icon=${this.nextMonthIcon}
82
+ ></span>` : ">"}
83
+ </button>
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ ${this.errors?.length ? $(this.uid, t) : _}
89
+ `;
90
+ }
91
+ /**
92
+ * Render a month panel
93
+ */
94
+ renderMonthPanel(t) {
95
+ const r = this.getDaysInMonth(t), a = this.chunkDays(r), e = I(this.localeId), n = new Date(this._currentDate);
96
+ return n.setDate(1), n.setMonth(n.getMonth() + t), u`
97
+ <div class="gui-calendar__panel">
98
+ ${this.renderHeader(n)}
99
+ ${this._yearSelectorOpen && t === 0 ? this.renderYearGrid() : u`
100
+ <div class="gui-calendar__days-grid" role="grid">
101
+ <div role="row" class="gui-calendar__rows">
102
+ ${D(
103
+ e,
104
+ (l, c) => c,
105
+ (l) => u`<span class="gui-calendar__weekday" role="gridcell">${l}</span>`
106
+ )}
107
+ </div>
108
+
109
+ ${D(
110
+ a,
111
+ (l) => u`
112
+ <div role="row" class="gui-calendar__rows">
113
+ ${D(
114
+ l,
115
+ (c) => c.date.toISOString(),
116
+ (c) => this.renderDay(c)
117
+ )}
118
+ </div>
119
+ `
120
+ )}
121
+ </div>
122
+ `}
123
+ </div>
124
+ `;
125
+ }
126
+ renderHeader(t) {
127
+ const r = k(this.localeId, t, this.monthFormat);
128
+ return u`
129
+ <header class="gui-calendar__header">
130
+ <h2>
131
+ ${r.map(
132
+ (a) => a.type === "year" ? u`<button
133
+ type="button"
134
+ tabindex="0"
135
+ class="gui-calendar__year-selector"
136
+ @click=${this.toggleYearSelector}
137
+ aria-expanded=${this._yearSelectorOpen}
138
+ aria-label="Select year"
139
+ >
140
+ <span class="gui-calendar__year-value">${a.value}</span>
141
+ <span class="gui-calendar__year-arrow" aria-hidden="true">
142
+ <svg
143
+ xmlns="http://www.w3.org/2000/svg"
144
+ width="16"
145
+ height="16"
146
+ viewBox="0 0 256 256"
147
+ >
148
+ <path
149
+ d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"
150
+ ></path>
151
+ </svg>
152
+ </span>
153
+ </button>` : u`<span class="gui-calendar__month-name">${a.value}</span>`
154
+ )}
155
+ </h2>
156
+ </header>
157
+ `;
158
+ }
159
+ renderYearGrid() {
160
+ const t = this._currentDate.getFullYear(), r = this._yearList;
161
+ return u`
162
+ <div
163
+ class="gui-calendar__year-grid"
164
+ role="grid"
165
+ aria-label="Year selection"
166
+ @keydown=${this.handleYearKeydown}
167
+ >
168
+ ${this.chunkYears(r).map(
169
+ (a) => u`
170
+ <div role="row" class="gui-calendar__year-row">
171
+ ${a.map(
172
+ (e) => u`
173
+ <button
174
+ type="button"
175
+ role="gridcell"
176
+ class="gui-calendar__year-button ${e === t ? "current" : ""}"
177
+ tabindex=${e === t ? 0 : -1}
178
+ data-year=${e}
179
+ @click=${(n) => {
180
+ n.stopPropagation(), this.selectYear(e);
181
+ }}
182
+ aria-selected=${e === t}
183
+ >
184
+ ${e}
185
+ </button>
186
+ `
187
+ )}
188
+ </div>
189
+ `
190
+ )}
191
+ </div>
192
+ `;
193
+ }
194
+ chunkYears(t) {
195
+ const r = [];
196
+ for (let a = 0; a < t.length; a += 4)
197
+ r.push(t.slice(a, a + 4));
198
+ return r;
199
+ }
200
+ toggleYearSelector() {
201
+ this._yearSelectorOpen = !this._yearSelectorOpen, this._yearSelectorOpen && this.updateComplete.then(() => {
202
+ this.scrollToCurrentYear(), this.focusCurrentYearButton();
203
+ });
204
+ }
205
+ selectYear(t) {
206
+ this.querySelector(".gui-calendar__year-selector")?.focus();
207
+ const a = this._currentDate;
208
+ this._currentDate = new Date(t, a.getMonth(), 1), this._yearSelectorOpen = !1, this.updateComplete.then(() => {
209
+ this.querySelector(
210
+ '.gui-calendar__day-button[tabindex="0"]'
211
+ )?.focus();
212
+ });
213
+ }
214
+ scrollToCurrentYear() {
215
+ const t = this.querySelector(".gui-calendar__year-grid"), r = this.querySelector(".gui-calendar__year-button.current");
216
+ if (t && r) {
217
+ const a = t.getBoundingClientRect(), e = r.getBoundingClientRect(), n = t.scrollTop + (e.top - a.top) - a.height / 2 + e.height / 2;
218
+ t.scrollTop = Math.max(0, n);
219
+ }
220
+ }
221
+ focusCurrentYearButton() {
222
+ this.querySelector(
223
+ ".gui-calendar__year-button.current"
224
+ )?.focus();
225
+ }
226
+ handleYearKeydown(t) {
227
+ const r = t.target;
228
+ if (!r.classList.contains("gui-calendar__year-button")) return;
229
+ const a = Array.from(
230
+ this.querySelectorAll(".gui-calendar__year-button")
231
+ ), e = a.indexOf(r), n = window.getComputedStyle(this).direction === "rtl";
232
+ let l = 0;
233
+ switch (t.key) {
234
+ case "ArrowLeft":
235
+ l = n ? 1 : -1;
236
+ break;
237
+ case "ArrowRight":
238
+ l = n ? -1 : 1;
239
+ break;
240
+ case "ArrowUp":
241
+ l = -4;
242
+ break;
243
+ case "ArrowDown":
244
+ l = 4;
245
+ break;
246
+ case "Enter":
247
+ case " ": {
248
+ t.preventDefault();
249
+ const d = parseInt(r.dataset.year ?? "", 10);
250
+ isNaN(d) || this.selectYear(d);
251
+ return;
252
+ }
253
+ case "Escape": {
254
+ t.preventDefault(), this.querySelector(".gui-calendar__year-selector")?.focus(), this._yearSelectorOpen = !1;
255
+ return;
256
+ }
257
+ default:
258
+ return;
259
+ }
260
+ t.preventDefault();
261
+ const c = e + l;
262
+ c >= 0 && c < a.length && a[c].focus();
263
+ }
264
+ get _effectiveMinYear() {
265
+ return this.minDate ? new Date(this.minDate).getFullYear() : 1900;
266
+ }
267
+ get _effectiveMaxYear() {
268
+ return this.maxDate ? new Date(this.maxDate).getFullYear() : 2099;
269
+ }
270
+ get _yearList() {
271
+ const t = [];
272
+ for (let r = this._effectiveMinYear; r <= this._effectiveMaxYear; r++)
273
+ t.push(r);
274
+ return t;
275
+ }
276
+ async handleKeydown(t, r) {
277
+ if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && t.key !== " " && t.key !== "Enter") return;
278
+ const e = Array.from(
279
+ this.querySelectorAll(".gui-calendar__day-button:not(.other-month)")
280
+ ), n = e.indexOf(t.target), l = window.getComputedStyle(this).direction === "rtl";
281
+ let c = 0;
282
+ switch (t.key) {
283
+ case "ArrowLeft":
284
+ c = l ? 1 : -1;
285
+ break;
286
+ case "ArrowRight":
287
+ c = l ? -1 : 1;
288
+ break;
289
+ case "ArrowUp":
290
+ c = -7;
291
+ break;
292
+ case "ArrowDown":
293
+ c = 7;
294
+ break;
295
+ case " ":
296
+ case "Enter":
297
+ t.preventDefault(), this.selectDate(r, t);
298
+ return;
299
+ }
300
+ t.preventDefault();
301
+ const d = this.findNextFocusableIndex(n, c, e);
302
+ let b = !1;
303
+ if (d < 0)
304
+ if (this.canGoPrev())
305
+ this.prevMonth(), b = !0;
306
+ else {
307
+ e.find((p) => !this.isButtonDisabled(p))?.focus();
308
+ return;
309
+ }
310
+ else if (d >= e.length)
311
+ if (this.canGoNext())
312
+ this.nextMonth(), b = !0;
313
+ else {
314
+ [...e].reverse().find((g) => !this.isButtonDisabled(g))?.focus();
315
+ return;
316
+ }
317
+ if (b) {
318
+ await this.updateComplete;
319
+ const h = Array.from(
320
+ this.querySelectorAll(".gui-calendar__day-button:not(.other-month)")
321
+ ), p = Array.from(this.querySelectorAll(".gui-calendar__panel"));
322
+ let g;
323
+ if (d < 0)
324
+ g = p[0].querySelectorAll(
325
+ ".gui-calendar__day-button:not(.other-month)"
326
+ ).length + d;
327
+ else {
328
+ const f = p[p.length - 1].querySelectorAll(
329
+ ".gui-calendar__day-button:not(.other-month)"
330
+ ).length;
331
+ g = h.length - f + (d - e.length);
332
+ }
333
+ if (this.isButtonDisabled(h[g])) {
334
+ const y = this.findNextFocusableIndex(g, c, h);
335
+ if (y < 0 || y >= h.length) {
336
+ const f = h.findIndex((x) => !this.isButtonDisabled(x));
337
+ f > -1 && h[f].focus();
338
+ } else
339
+ h[y]?.focus();
340
+ } else {
341
+ const y = Math.max(0, Math.min(g, h.length - 1));
342
+ h[y]?.focus();
343
+ }
344
+ } else
345
+ e[d]?.focus();
346
+ }
347
+ /**
348
+ * Splits an array of calendar days into chunks of weeks, with each week consisting of up to 7 days.
349
+ *
350
+ * @param {AbstractCalendarDay[]} days - An array of calendar day objects to be grouped into weeks.
351
+ * @return {AbstractCalendarDay[][]} A two-dimensional array where each inner array represents a week of up to 7 days.
352
+ */
353
+ chunkDays(t) {
354
+ const r = [];
355
+ for (let a = 0; a < t.length; a += 7)
356
+ r.push(t.slice(a, a + 7));
357
+ return r;
358
+ }
359
+ onFocusOut(t) {
360
+ t.relatedTarget && this.contains(t.relatedTarget) || (this._blurRafId !== void 0 && cancelAnimationFrame(this._blurRafId), this._blurRafId = requestAnimationFrame(() => {
361
+ this._blurRafId = void 0, this.contains(document.activeElement) || this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }));
362
+ }));
363
+ }
364
+ disconnectedCallback() {
365
+ super.disconnectedCallback(), this._blurRafId !== void 0 && cancelAnimationFrame(this._blurRafId);
366
+ }
367
+ isDisabled(t) {
368
+ const r = v(t);
369
+ if (this.minDate && r < this.minDate || this.maxDate && r > this.maxDate) return !0;
370
+ if (this.disabledRanges && this.disabledRanges.length > 0)
371
+ for (const a of this.disabledRanges) {
372
+ const e = a.start.split("T")[0], n = a.end ? a.end.split("T")[0] : e;
373
+ if (r >= e && r <= n)
374
+ return !0;
375
+ }
376
+ return !1;
377
+ }
378
+ prevMonth() {
379
+ const t = this._currentDate;
380
+ this._currentDate = new Date(t.getFullYear(), t.getMonth() - 1, 1);
381
+ }
382
+ nextMonth() {
383
+ const t = this._currentDate;
384
+ this._currentDate = new Date(t.getFullYear(), t.getMonth() + 1, 1);
385
+ }
386
+ generateDateGrid(t = 0) {
387
+ const r = this._currentDate.getFullYear(), a = this._currentDate.getMonth() + t, e = new Date(r, a, 1), n = e.getDay(), l = B(this.localeId)[0], c = (n - l + 7) % 7, d = new Date(e);
388
+ d.setDate(e.getDate() - c);
389
+ const b = [];
390
+ for (let h = 0; h < 42; h++) {
391
+ const p = new Date(d);
392
+ p.setDate(d.getDate() + h), b.push(p);
393
+ }
394
+ return b;
395
+ }
396
+ /**
397
+ * Finds the next focusable button index based on the current index and step value.
398
+ * This method skips disabled buttons and continues until it either finds
399
+ * a focusable button or goes out of bounds of the given button list.
400
+ *
401
+ * @param {number} currentIndex - The index of the currently focused button.
402
+ * @param {number} step - The step size to move. Can be positive or negative.
403
+ * @param {HTMLButtonElement[]} buttons - The list of button elements to navigate through.
404
+ * @return {number} - The index of the next focusable button if found; otherwise, returns out-of-bounds index.
405
+ */
406
+ findNextFocusableIndex(t, r, a) {
407
+ let e = t + r;
408
+ for (; e >= 0 && e < a.length; ) {
409
+ const n = a[e];
410
+ if (!this.isButtonDisabled(n))
411
+ return e;
412
+ e += r;
413
+ }
414
+ return e;
415
+ }
416
+ /**
417
+ * Determines if a button element is disabled based on its attributes.
418
+ *
419
+ * @param {HTMLButtonElement | undefined} button - The button element to check. If undefined, the button is considered disabled.
420
+ * @return {boolean} Returns true if the button is disabled or if no button element is provided, otherwise false.
421
+ */
422
+ isButtonDisabled(t) {
423
+ return t ? t.hasAttribute("disabled") : !0;
424
+ }
425
+ /**
426
+ * Determines whether navigation to the previous month is allowed.
427
+ *
428
+ * This method checks if the last day of the previous month exceeds the allowed minimum date.
429
+ * If there is no minimum date defined, navigation is always allowed.
430
+ *
431
+ * @return {boolean} Returns true if navigation to the previous month is permitted; otherwise, returns false.
432
+ */
433
+ canGoPrev() {
434
+ if (!this.minDate) return !0;
435
+ const t = new Date(
436
+ this._currentDate.getFullYear(),
437
+ this._currentDate.getMonth(),
438
+ 0
439
+ );
440
+ return v(t) >= this.minDate;
441
+ }
442
+ /**
443
+ * Determines whether navigation to the next month is allowed.
444
+ *
445
+ * This method checks if the first day of the next month exceeds the allowed maximum date.
446
+ * If there is no maximum date defined, navigation is always allowed.
447
+ *
448
+ * @return {boolean} Returns true if navigation to the next month is permitted; otherwise, returns false.
449
+ */
450
+ canGoNext() {
451
+ if (!this.maxDate) return !0;
452
+ const t = (this.numberOfMonths ?? 1) - 1, r = new Date(
453
+ this._currentDate.getFullYear(),
454
+ this._currentDate.getMonth() + t + 1,
455
+ 1
456
+ );
457
+ return v(r) <= this.maxDate;
458
+ }
459
+ }
460
+ s([
461
+ o({ type: String })
462
+ ], i.prototype, "uid");
463
+ s([
464
+ o({ type: String })
465
+ ], i.prototype, "label");
466
+ s([
467
+ o({ type: String })
468
+ ], i.prototype, "hint");
469
+ s([
470
+ o({ type: String, attribute: "locale-id" })
471
+ ], i.prototype, "localeId");
472
+ s([
473
+ o({ type: Array })
474
+ ], i.prototype, "errors");
475
+ s([
476
+ o({ type: Boolean })
477
+ ], i.prototype, "touched");
478
+ s([
479
+ o({ type: Boolean })
480
+ ], i.prototype, "required");
481
+ s([
482
+ o({ type: Boolean })
483
+ ], i.prototype, "disabled");
484
+ s([
485
+ o({ type: Boolean, attribute: "readonly" })
486
+ ], i.prototype, "readOnly");
487
+ s([
488
+ o({ type: String, attribute: "prev-month-icon" })
489
+ ], i.prototype, "prevMonthIcon");
490
+ s([
491
+ o({ type: String, attribute: "next-month-icon" })
492
+ ], i.prototype, "nextMonthIcon");
493
+ s([
494
+ o({ type: String, attribute: "prev-month-aria-label" })
495
+ ], i.prototype, "prevMonthAriaLabel");
496
+ s([
497
+ o({ type: String, attribute: "next-month-aria-label" })
498
+ ], i.prototype, "nextMonthAriaLabel");
499
+ s([
500
+ o({ type: String })
501
+ ], i.prototype, "dayFormat");
502
+ s([
503
+ o({ type: String })
504
+ ], i.prototype, "weekdayFormat");
505
+ s([
506
+ o({ type: String })
507
+ ], i.prototype, "monthFormat");
508
+ s([
509
+ o({ type: String })
510
+ ], i.prototype, "minDate");
511
+ s([
512
+ o({ type: String })
513
+ ], i.prototype, "maxDate");
514
+ s([
515
+ o({ type: Array })
516
+ ], i.prototype, "disabledRanges");
517
+ s([
518
+ o({ type: Number })
519
+ ], i.prototype, "numberOfMonths");
520
+ s([
521
+ w()
522
+ ], i.prototype, "_currentDate");
523
+ s([
524
+ w()
525
+ ], i.prototype, "_yearSelectorOpen");
526
+ export {
527
+ i as A
528
+ };
@@ -0,0 +1,95 @@
1
+ import { b as D, n as f, t as m } from "./directive-1yd1wdny.js";
2
+ import { e as g } from "./class-map-DrTVAYz_.js";
3
+ import { i as h, a as p, b as v, g as M, t as w } from "./date-BS1lA1xg.js";
4
+ import { A as C } from "./abstract-calendar-JfbbRwFb.js";
5
+ var _ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, d = (e, t, n, r) => {
6
+ for (var i = r > 1 ? void 0 : r ? y(t, n) : t, s = e.length - 1, a; s >= 0; s--)
7
+ (a = e[s]) && (i = (r ? a(t, n, i) : a(i)) || i);
8
+ return r && i && _(t, n, i), i;
9
+ };
10
+ let l = class extends C {
11
+ constructor() {
12
+ super(...arguments), this.value = void 0;
13
+ }
14
+ createRenderRoot() {
15
+ return this;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), this.classList.add("gui-field");
19
+ }
20
+ willUpdate(e) {
21
+ if (e.has("value") && this.value) {
22
+ const t = new Date(this.value);
23
+ !isNaN(t.getTime()) && !h(t, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = t);
24
+ }
25
+ }
26
+ renderDay(e) {
27
+ const t = {
28
+ "gui-calendar__day-button": !0,
29
+ today: e.isToday,
30
+ selected: e.isSelected,
31
+ disabled: e.isDisabled,
32
+ "other-month": !e.isCurrentMonth
33
+ };
34
+ return D`
35
+ <button
36
+ type="button"
37
+ role="gridcell"
38
+ class=${g(t)}
39
+ tabindex=${e.isFocusable ? 0 : -1}
40
+ ?disabled=${!e.isCurrentMonth || e.isDisabled}
41
+ data-date=${e.date.toISOString()}
42
+ @click=${() => this.selectDate(e)}
43
+ @keydown=${(n) => this.handleKeydown(n, e)}
44
+ aria-selected=${e.isSelected}
45
+ >
46
+ ${e.dayLabel}
47
+ </button>
48
+ `;
49
+ }
50
+ getDaysInMonth(e) {
51
+ const t = new Date(this._currentDate);
52
+ t.setDate(1), t.setMonth(t.getMonth() + e);
53
+ const n = this.generateDateGrid(e), r = t.getMonth();
54
+ let i = n.map((s) => {
55
+ const a = s.getMonth() === r, o = this.isDisabled(s), c = !!this.value && p(s, new Date(this.value)), u = v(s), b = (c || u) && a;
56
+ return {
57
+ date: s,
58
+ dayLabel: M(this.localeId, s),
59
+ isCurrentMonth: a,
60
+ isToday: u,
61
+ isDisabled: o,
62
+ isSelected: c,
63
+ isFocusable: b
64
+ };
65
+ });
66
+ for (let s = 0; s < 2; s++)
67
+ i.slice(-7).every((o) => !o.isCurrentMonth) && (i = i.slice(0, -7));
68
+ if (e === 0 && !i.some((s) => s.isFocusable)) {
69
+ const s = this.value ? new Date(this.value) : /* @__PURE__ */ new Date();
70
+ if (!h(s, this._currentDate, this.numberOfMonths ?? 1)) {
71
+ const a = i.find((o) => o.isCurrentMonth && !o.isDisabled);
72
+ a && (a.isFocusable = !0);
73
+ }
74
+ }
75
+ return i;
76
+ }
77
+ selectDate(e) {
78
+ if (!e.isCurrentMonth || e.isDisabled || this.disabled || this.readOnly) return;
79
+ const t = w(e.date);
80
+ this.value = t, this.dispatchEvent(
81
+ new CustomEvent("change", {
82
+ detail: { value: t },
83
+ bubbles: !0,
84
+ composed: !0
85
+ })
86
+ );
87
+ }
88
+ };
89
+ d([
90
+ f({ type: String })
91
+ ], l.prototype, "value", 2);
92
+ l = d([
93
+ m("gui-calendar")
94
+ ], l);
95
+ typeof customElements < "u" && !customElements.get("gui-calendar") && customElements.define("gui-calendar", l);
@@ -0,0 +1,26 @@
1
+ import { e as i, a as o, c as a, E as h } from "./directive-1yd1wdny.js";
2
+ const d = i(class extends o {
3
+ constructor(s) {
4
+ if (super(s), s.type !== a.ATTRIBUTE || s.name !== "class" || s.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
5
+ }
6
+ render(s) {
7
+ return " " + Object.keys(s).filter((e) => s[e]).join(" ") + " ";
8
+ }
9
+ update(s, [e]) {
10
+ if (this.st === void 0) {
11
+ this.st = /* @__PURE__ */ new Set(), s.strings !== void 0 && (this.nt = new Set(s.strings.join(" ").split(/\s/).filter((t) => t !== "")));
12
+ for (const t in e) e[t] && !this.nt?.has(t) && this.st.add(t);
13
+ return this.render(e);
14
+ }
15
+ const n = s.element.classList;
16
+ for (const t of this.st) t in e || (n.remove(t), this.st.delete(t));
17
+ for (const t in e) {
18
+ const r = !!e[t];
19
+ r === this.st.has(t) || this.nt?.has(t) || (r ? (n.add(t), this.st.add(t)) : (n.remove(t), this.st.delete(t)));
20
+ }
21
+ return h;
22
+ }
23
+ });
24
+ export {
25
+ d as e
26
+ };