@golemui/gui-lit 1.0.3 → 1.1.1-rc.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.
- package/CHANGELOG.md +26 -0
- package/{button.element-3a7rRHbA.js → button.element-CJay43iR.js} +16 -13
- package/calendar-D31xNsxx.js +267 -0
- package/{range-calendar.element-_1bHW_c1.js → calendar.element-BhFrCsns.js} +16 -16
- package/{checkbox.element-CVskoXEc.js → checkbox.element-DAAVB651.js} +49 -49
- package/{currency.element-5GSakkxF.js → currency.element-D8A2ObpM.js} +15 -11
- package/{date-CDUlLuYy.js → date-DBuYpvcO.js} +88 -29
- package/date-input-DLiMreSS.js +204 -0
- package/date-picker.element-DeUQtbLg.js +357 -0
- package/date-time-calendar-DzU-FtVl.js +374 -0
- package/date-time-calendar.element-BLBcVsFu.js +95 -0
- package/date-time-input-DZaz2heD.js +246 -0
- package/date-time-picker.element-BUbLdV6i.js +440 -0
- package/date-time.element-B5onfSBG.js +93 -0
- package/{date.element-BZO0UQez.js → date.element-BsKhLrEc.js} +27 -19
- package/day-status-CsWStVQV.js +554 -0
- package/{dropdown.element-CyJbVAA5.js → dropdown.element-CXpMwJsU.js} +53 -37
- package/{errors-QjKhr6mA.js → errors-Byb2dIhK.js} +3 -2
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1635 -948
- package/index.umd.cjs +2046 -601
- package/lib/components/date-picker.element.d.ts +0 -11
- package/lib/components/date-time-calendar.element.d.ts +18 -0
- package/lib/components/date-time-picker.element.d.ts +18 -0
- package/lib/components/date-time.element.d.ts +18 -0
- package/lib/components/dropdown.element.d.ts +2 -0
- package/lib/components/range-calendar.element.d.ts +2 -1
- package/lib/components/range-date-picker.element.d.ts +0 -15
- package/lib/components/range-date-time-calendar.element.d.ts +18 -0
- package/lib/components/range-date-time-input.element.d.ts +18 -0
- package/lib/components/range-date-time-picker.element.d.ts +18 -0
- package/lib/components/range-time-input.element.d.ts +18 -0
- package/lib/components/range-time-picker.element.d.ts +18 -0
- package/lib/components/time-picker.element.d.ts +18 -0
- package/lib/components/time.element.d.ts +18 -0
- package/list-D730tmGN.js +297 -0
- package/{list.element-Co3V3Cn5.js → list.element-eo3DIOrp.js} +23 -23
- package/{markdown.element-p-kC47D7.js → markdown.element-FbtwdnAv.js} +310 -218
- package/{number.element-CBr47IiY.js → number.element-BEpOCzXy.js} +76 -61
- package/package.json +6 -6
- package/part-templates-VORbpgs2.js +691 -0
- package/{password.element-n-R9RbkB.js → password.element-CBaB8h5b.js} +19 -17
- package/pill-ranges-DpvWwP-3.js +48 -0
- package/{pills-B66qz_KX.js → pills-BDMO2NiR.js} +84 -59
- package/popup.controller-B33OvX_y.js +86 -0
- package/{radiogroup.element-CeQn623u.js → radiogroup.element-KWzBx8mx.js} +55 -51
- package/range-calendar-DO_woqcF.js +466 -0
- package/{calendar.element-DcnTyvfg.js → range-calendar.element-DHLZhpnj.js} +37 -29
- package/range-commit-8-MmYUyo.js +14 -0
- package/range-date-input-Br7XqQPK.js +311 -0
- package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-BdD4SlB4.js} +12 -8
- package/range-date-picker.element-DWRHiAoC.js +434 -0
- package/range-date-time-calendar-B3EMgN1E.js +734 -0
- package/range-date-time-calendar.element-Coea6RF4.js +97 -0
- package/range-date-time-input-Cu-T_nuC.js +353 -0
- package/range-date-time-input.element-Cti44iuW.js +87 -0
- package/range-date-time-picker.element-CDN2RL1y.js +472 -0
- package/range-selection-CU3hxLJE.js +25 -0
- package/range-time-input-BP9ZL9O8.js +348 -0
- package/range-time-input.element-B7wtHJoQ.js +84 -0
- package/range-time-picker.element-CPIAiQPC.js +470 -0
- package/{repeater.element-CtNgB4F5.js → repeater.element-BM1Keckd.js} +1 -1
- package/{select.element-jcDF1h-g.js → select.element-eepcXTpL.js} +117 -107
- package/{tabs.element-BvAyI71N.js → tabs.element-CvcIA8P3.js} +1 -0
- package/{tags.element-CX3vQL8L.js → tags.element-CPHgotb0.js} +21 -14
- package/templates-Dmr34nwp.js +88 -0
- package/{textarea.element-HThYqdR_.js → textarea.element-CiNEy9uq.js} +8 -7
- package/{textinput.element-CkXNzMUg.js → textinput.element-AL2Nr768.js} +10 -9
- package/time-input-5dkSm8UW.js +201 -0
- package/time-list-DLcq8BAp.js +217 -0
- package/time-picker-g337F8d0.js +299 -0
- package/time-picker.element-DLihegjg.js +89 -0
- package/time.element-BneqgMlQ.js +85 -0
- package/{toggle.element-C1kCw5H8.js → toggle.element-Cz91CRdp.js} +44 -43
- package/abstract-calendar-D0-077XJ.js +0 -545
- package/calendar-BclCC9VJ.js +0 -96
- package/date-input-DCdGWRio.js +0 -268
- package/date-picker.element-k7AJFQ5W.js +0 -168
- package/list-D1oKnH89.js +0 -283
- package/range-calendar-CBINu84w.js +0 -255
- package/range-date-input-BYXzqnr1.js +0 -395
- package/range-date-picker.element-BCBefgvY.js +0 -182
- package/templates-Dk1jxLwS.js +0 -75
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
import { LitElement as S, nothing as _, html as d } from "lit";
|
|
2
|
-
import { property as o, state as x } from "lit/decorators.js";
|
|
3
|
-
import { G as A, b as $, c as I } from "./templates-Dk1jxLwS.js";
|
|
4
|
-
import { repeat as D } from "lit-html/directives/repeat.js";
|
|
5
|
-
import { d as k, e as B, p as w, t as v, w as Y } from "./date-CDUlLuYy.js";
|
|
6
|
-
var O = Object.defineProperty, s = (m, t, r, a) => {
|
|
7
|
-
for (var e = void 0, n = m.length - 1, l; n >= 0; n--)
|
|
8
|
-
(l = m[n]) && (e = l(t, r, e) || e);
|
|
9
|
-
return e && O(t, r, e), e;
|
|
10
|
-
};
|
|
11
|
-
class i extends S {
|
|
12
|
-
constructor() {
|
|
13
|
-
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 A(this, {
|
|
14
|
-
getTargets: () => this.querySelectorAll(".gui-calendar-input"),
|
|
15
|
-
getState: () => ({
|
|
16
|
-
uid: this.uid,
|
|
17
|
-
templateData: {
|
|
18
|
-
hint: this.hint,
|
|
19
|
-
errors: this.errors,
|
|
20
|
-
readonly: this.readOnly,
|
|
21
|
-
disabled: this.disabled,
|
|
22
|
-
touched: this.touched
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
renderAboveCalendar() {
|
|
28
|
-
return _;
|
|
29
|
-
}
|
|
30
|
-
render() {
|
|
31
|
-
const t = {
|
|
32
|
-
uid: this.uid,
|
|
33
|
-
label: this.label,
|
|
34
|
-
hint: this.hint,
|
|
35
|
-
errors: this.errors,
|
|
36
|
-
touched: this.touched,
|
|
37
|
-
required: this.required
|
|
38
|
-
}, r = Array.from({ length: this.numberOfMonths ?? 1 }, (a, e) => e);
|
|
39
|
-
return d`
|
|
40
|
-
${this.label ? $(this.uid, t, !1, "calendar") : _}
|
|
41
|
-
|
|
42
|
-
<div class="gui-widget" @focusout=${this.onFocusOut}>
|
|
43
|
-
<div
|
|
44
|
-
id=${this.uid}
|
|
45
|
-
class="gui-calendar-input"
|
|
46
|
-
role="group"
|
|
47
|
-
aria-labelledby=${this.label ? `${this.uid}_calendar_label` : _}
|
|
48
|
-
?aria-disabled=${this.disabled}
|
|
49
|
-
>
|
|
50
|
-
${this.renderAboveCalendar()}
|
|
51
|
-
<div class="gui-calendar__container">
|
|
52
|
-
<button
|
|
53
|
-
type="button"
|
|
54
|
-
tabindex="0"
|
|
55
|
-
class="gui-button gui-calendar__month-button gui-calendar__month-button--prev"
|
|
56
|
-
?disabled=${!this.canGoPrev()}
|
|
57
|
-
@click=${this.prevMonth}
|
|
58
|
-
aria-label=${this.prevMonthAriaLabel ?? "Previous month"}
|
|
59
|
-
>
|
|
60
|
-
${this.prevMonthIcon ? d`<span
|
|
61
|
-
class=${`gui-widget-icon ${this.prevMonthIcon}`}
|
|
62
|
-
data-icon=${this.prevMonthIcon}
|
|
63
|
-
></span>` : d`<svg
|
|
64
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
65
|
-
width="16"
|
|
66
|
-
height="16"
|
|
67
|
-
viewBox="0 0 256 256"
|
|
68
|
-
>
|
|
69
|
-
<path
|
|
70
|
-
d="M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z"
|
|
71
|
-
></path>
|
|
72
|
-
</svg>`}
|
|
73
|
-
</button>
|
|
74
|
-
|
|
75
|
-
<div class="gui-calendar__months-grid">
|
|
76
|
-
${r.map((a) => this.renderMonthPanel(a))}
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<button
|
|
80
|
-
type="button"
|
|
81
|
-
tabindex="0"
|
|
82
|
-
class="gui-button gui-calendar__month-button gui-calendar__month-button--next"
|
|
83
|
-
?disabled=${!this.canGoNext()}
|
|
84
|
-
@click=${this.nextMonth}
|
|
85
|
-
aria-label=${this.nextMonthAriaLabel ?? "Next month"}
|
|
86
|
-
>
|
|
87
|
-
${this.nextMonthIcon ? d`<span
|
|
88
|
-
class=${`gui-widget-icon ${this.nextMonthIcon}`}
|
|
89
|
-
data-icon=${this.nextMonthIcon}
|
|
90
|
-
></span>` : d`<svg
|
|
91
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
92
|
-
width="16"
|
|
93
|
-
height="16"
|
|
94
|
-
viewBox="0 0 256 256"
|
|
95
|
-
>
|
|
96
|
-
<path
|
|
97
|
-
d="M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z"
|
|
98
|
-
></path>
|
|
99
|
-
</svg>`}
|
|
100
|
-
</button>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
|
|
105
|
-
${this.errors?.length ? I(this.uid, t) : _}
|
|
106
|
-
`;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Render a month panel
|
|
110
|
-
*/
|
|
111
|
-
renderMonthPanel(t) {
|
|
112
|
-
const r = this.getDaysInMonth(t), a = this.chunkDays(r), e = k(this.localeId), n = new Date(this._currentDate);
|
|
113
|
-
return n.setDate(1), n.setMonth(n.getMonth() + t), d`
|
|
114
|
-
<div class="gui-calendar__panel">
|
|
115
|
-
${this.renderHeader(n)}
|
|
116
|
-
${this._yearSelectorOpen && t === 0 ? this.renderYearGrid() : d`
|
|
117
|
-
<div class="gui-calendar__days-grid" role="grid">
|
|
118
|
-
<div role="row" class="gui-calendar__rows">
|
|
119
|
-
${D(
|
|
120
|
-
e,
|
|
121
|
-
(l, c) => c,
|
|
122
|
-
(l) => d`<span class="gui-calendar__weekday" role="gridcell">${l}</span>`
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
|
|
126
|
-
${D(
|
|
127
|
-
a,
|
|
128
|
-
(l) => d`
|
|
129
|
-
<div role="row" class="gui-calendar__rows">
|
|
130
|
-
${D(
|
|
131
|
-
l,
|
|
132
|
-
(c) => c.date.toISOString(),
|
|
133
|
-
(c) => this.renderDay(c)
|
|
134
|
-
)}
|
|
135
|
-
</div>
|
|
136
|
-
`
|
|
137
|
-
)}
|
|
138
|
-
</div>
|
|
139
|
-
`}
|
|
140
|
-
</div>
|
|
141
|
-
`;
|
|
142
|
-
}
|
|
143
|
-
renderHeader(t) {
|
|
144
|
-
const r = B(this.localeId, t, this.monthFormat);
|
|
145
|
-
return d`
|
|
146
|
-
<header class="gui-calendar__header">
|
|
147
|
-
<h2>
|
|
148
|
-
${r.map(
|
|
149
|
-
(a) => a.type === "year" ? d`<button
|
|
150
|
-
type="button"
|
|
151
|
-
tabindex="0"
|
|
152
|
-
class="gui-calendar__year-selector"
|
|
153
|
-
@click=${this.toggleYearSelector}
|
|
154
|
-
aria-expanded=${this._yearSelectorOpen}
|
|
155
|
-
aria-label="Select year"
|
|
156
|
-
>
|
|
157
|
-
<span class="gui-calendar__year-value">${a.value}</span>
|
|
158
|
-
<span class="gui-calendar__year-arrow" aria-hidden="true">
|
|
159
|
-
<svg
|
|
160
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
161
|
-
width="16"
|
|
162
|
-
height="16"
|
|
163
|
-
viewBox="0 0 256 256"
|
|
164
|
-
>
|
|
165
|
-
<path
|
|
166
|
-
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"
|
|
167
|
-
></path>
|
|
168
|
-
</svg>
|
|
169
|
-
</span>
|
|
170
|
-
</button>` : d`<span class="gui-calendar__month-name">${a.value}</span>`
|
|
171
|
-
)}
|
|
172
|
-
</h2>
|
|
173
|
-
</header>
|
|
174
|
-
`;
|
|
175
|
-
}
|
|
176
|
-
renderYearGrid() {
|
|
177
|
-
const t = this._currentDate.getFullYear(), r = this._yearList;
|
|
178
|
-
return d`
|
|
179
|
-
<div
|
|
180
|
-
class="gui-calendar__year-grid"
|
|
181
|
-
role="grid"
|
|
182
|
-
aria-label="Year selection"
|
|
183
|
-
@keydown=${this.handleYearKeydown}
|
|
184
|
-
>
|
|
185
|
-
${this.chunkYears(r).map(
|
|
186
|
-
(a) => d`
|
|
187
|
-
<div role="row" class="gui-calendar__year-row">
|
|
188
|
-
${a.map(
|
|
189
|
-
(e) => d`
|
|
190
|
-
<button
|
|
191
|
-
type="button"
|
|
192
|
-
role="gridcell"
|
|
193
|
-
class="gui-calendar__year-button ${e === t ? "current" : ""}"
|
|
194
|
-
tabindex=${e === t ? 0 : -1}
|
|
195
|
-
data-year=${e}
|
|
196
|
-
@click=${(n) => {
|
|
197
|
-
n.stopPropagation(), this.selectYear(e);
|
|
198
|
-
}}
|
|
199
|
-
aria-selected=${e === t}
|
|
200
|
-
>
|
|
201
|
-
${e}
|
|
202
|
-
</button>
|
|
203
|
-
`
|
|
204
|
-
)}
|
|
205
|
-
</div>
|
|
206
|
-
`
|
|
207
|
-
)}
|
|
208
|
-
</div>
|
|
209
|
-
`;
|
|
210
|
-
}
|
|
211
|
-
chunkYears(t) {
|
|
212
|
-
const r = [];
|
|
213
|
-
for (let a = 0; a < t.length; a += 4)
|
|
214
|
-
r.push(t.slice(a, a + 4));
|
|
215
|
-
return r;
|
|
216
|
-
}
|
|
217
|
-
toggleYearSelector() {
|
|
218
|
-
this._yearSelectorOpen = !this._yearSelectorOpen, this._yearSelectorOpen && this.updateComplete.then(() => {
|
|
219
|
-
this.scrollToCurrentYear(), this.focusCurrentYearButton();
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
selectYear(t) {
|
|
223
|
-
this.querySelector(".gui-calendar__year-selector")?.focus();
|
|
224
|
-
const a = this._currentDate;
|
|
225
|
-
this._currentDate = new Date(t, a.getMonth(), 1), this._yearSelectorOpen = !1, this.updateComplete.then(() => {
|
|
226
|
-
this.querySelector(
|
|
227
|
-
'.gui-calendar__day-button[tabindex="0"]'
|
|
228
|
-
)?.focus();
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
scrollToCurrentYear() {
|
|
232
|
-
const t = this.querySelector(".gui-calendar__year-grid"), r = this.querySelector(".gui-calendar__year-button.current");
|
|
233
|
-
if (t && r) {
|
|
234
|
-
const a = t.getBoundingClientRect(), e = r.getBoundingClientRect(), n = t.scrollTop + (e.top - a.top) - a.height / 2 + e.height / 2;
|
|
235
|
-
t.scrollTop = Math.max(0, n);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
focusCurrentYearButton() {
|
|
239
|
-
this.querySelector(
|
|
240
|
-
".gui-calendar__year-button.current"
|
|
241
|
-
)?.focus();
|
|
242
|
-
}
|
|
243
|
-
handleYearKeydown(t) {
|
|
244
|
-
const r = t.target;
|
|
245
|
-
if (!r.classList.contains("gui-calendar__year-button")) return;
|
|
246
|
-
const a = Array.from(
|
|
247
|
-
this.querySelectorAll(".gui-calendar__year-button")
|
|
248
|
-
), e = a.indexOf(r), n = window.getComputedStyle(this).direction === "rtl";
|
|
249
|
-
let l = 0;
|
|
250
|
-
switch (t.key) {
|
|
251
|
-
case "ArrowLeft":
|
|
252
|
-
l = n ? 1 : -1;
|
|
253
|
-
break;
|
|
254
|
-
case "ArrowRight":
|
|
255
|
-
l = n ? -1 : 1;
|
|
256
|
-
break;
|
|
257
|
-
case "ArrowUp":
|
|
258
|
-
l = -4;
|
|
259
|
-
break;
|
|
260
|
-
case "ArrowDown":
|
|
261
|
-
l = 4;
|
|
262
|
-
break;
|
|
263
|
-
case "Enter":
|
|
264
|
-
case " ": {
|
|
265
|
-
t.preventDefault();
|
|
266
|
-
const u = parseInt(r.dataset.year ?? "", 10);
|
|
267
|
-
isNaN(u) || this.selectYear(u);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
case "Escape": {
|
|
271
|
-
t.preventDefault(), this.querySelector(".gui-calendar__year-selector")?.focus(), this._yearSelectorOpen = !1;
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
default:
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
t.preventDefault();
|
|
278
|
-
const c = e + l;
|
|
279
|
-
c >= 0 && c < a.length && a[c].focus();
|
|
280
|
-
}
|
|
281
|
-
get _effectiveMinYear() {
|
|
282
|
-
return this.minDate ? w(this.minDate).getFullYear() : 1900;
|
|
283
|
-
}
|
|
284
|
-
get _effectiveMaxYear() {
|
|
285
|
-
return this.maxDate ? w(this.maxDate).getFullYear() : 2099;
|
|
286
|
-
}
|
|
287
|
-
get _yearList() {
|
|
288
|
-
const t = [];
|
|
289
|
-
for (let r = this._effectiveMinYear; r <= this._effectiveMaxYear; r++)
|
|
290
|
-
t.push(r);
|
|
291
|
-
return t;
|
|
292
|
-
}
|
|
293
|
-
async handleKeydown(t, r) {
|
|
294
|
-
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && t.key !== " " && t.key !== "Enter") return;
|
|
295
|
-
const e = Array.from(
|
|
296
|
-
this.querySelectorAll(".gui-calendar__day-button:not(.other-month)")
|
|
297
|
-
), n = e.indexOf(t.target), l = window.getComputedStyle(this).direction === "rtl";
|
|
298
|
-
let c = 0;
|
|
299
|
-
switch (t.key) {
|
|
300
|
-
case "ArrowLeft":
|
|
301
|
-
c = l ? 1 : -1;
|
|
302
|
-
break;
|
|
303
|
-
case "ArrowRight":
|
|
304
|
-
c = l ? -1 : 1;
|
|
305
|
-
break;
|
|
306
|
-
case "ArrowUp":
|
|
307
|
-
c = -7;
|
|
308
|
-
break;
|
|
309
|
-
case "ArrowDown":
|
|
310
|
-
c = 7;
|
|
311
|
-
break;
|
|
312
|
-
case " ":
|
|
313
|
-
case "Enter":
|
|
314
|
-
t.preventDefault(), this.selectDate(r, t);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
t.preventDefault();
|
|
318
|
-
const u = this.findNextFocusableIndex(n, c, e);
|
|
319
|
-
let b = !1;
|
|
320
|
-
if (u < 0)
|
|
321
|
-
if (this.canGoPrev())
|
|
322
|
-
this.prevMonth(), b = !0;
|
|
323
|
-
else {
|
|
324
|
-
e.find((p) => !this.isButtonDisabled(p))?.focus();
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
else if (u >= e.length)
|
|
328
|
-
if (this.canGoNext())
|
|
329
|
-
this.nextMonth(), b = !0;
|
|
330
|
-
else {
|
|
331
|
-
[...e].reverse().find((g) => !this.isButtonDisabled(g))?.focus();
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if (b) {
|
|
335
|
-
await this.updateComplete;
|
|
336
|
-
const h = Array.from(
|
|
337
|
-
this.querySelectorAll(".gui-calendar__day-button:not(.other-month)")
|
|
338
|
-
), p = Array.from(this.querySelectorAll(".gui-calendar__panel"));
|
|
339
|
-
let g;
|
|
340
|
-
if (u < 0)
|
|
341
|
-
g = p[0].querySelectorAll(
|
|
342
|
-
".gui-calendar__day-button:not(.other-month)"
|
|
343
|
-
).length + u;
|
|
344
|
-
else {
|
|
345
|
-
const f = p[p.length - 1].querySelectorAll(
|
|
346
|
-
".gui-calendar__day-button:not(.other-month)"
|
|
347
|
-
).length;
|
|
348
|
-
g = h.length - f + (u - e.length);
|
|
349
|
-
}
|
|
350
|
-
if (this.isButtonDisabled(h[g])) {
|
|
351
|
-
const y = this.findNextFocusableIndex(g, c, h);
|
|
352
|
-
if (y < 0 || y >= h.length) {
|
|
353
|
-
const f = h.findIndex((M) => !this.isButtonDisabled(M));
|
|
354
|
-
f > -1 && h[f].focus();
|
|
355
|
-
} else
|
|
356
|
-
h[y]?.focus();
|
|
357
|
-
} else {
|
|
358
|
-
const y = Math.max(0, Math.min(g, h.length - 1));
|
|
359
|
-
h[y]?.focus();
|
|
360
|
-
}
|
|
361
|
-
} else
|
|
362
|
-
e[u]?.focus();
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Splits an array of calendar days into chunks of weeks, with each week consisting of up to 7 days.
|
|
366
|
-
*
|
|
367
|
-
* @param {AbstractCalendarDay[]} days - An array of calendar day objects to be grouped into weeks.
|
|
368
|
-
* @return {AbstractCalendarDay[][]} A two-dimensional array where each inner array represents a week of up to 7 days.
|
|
369
|
-
*/
|
|
370
|
-
chunkDays(t) {
|
|
371
|
-
const r = [];
|
|
372
|
-
for (let a = 0; a < t.length; a += 7)
|
|
373
|
-
r.push(t.slice(a, a + 7));
|
|
374
|
-
return r;
|
|
375
|
-
}
|
|
376
|
-
onFocusOut(t) {
|
|
377
|
-
t.relatedTarget && this.contains(t.relatedTarget) || (this._blurRafId !== void 0 && cancelAnimationFrame(this._blurRafId), this._blurRafId = requestAnimationFrame(() => {
|
|
378
|
-
this._blurRafId = void 0, this.contains(document.activeElement) || this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }));
|
|
379
|
-
}));
|
|
380
|
-
}
|
|
381
|
-
disconnectedCallback() {
|
|
382
|
-
super.disconnectedCallback(), this._blurRafId !== void 0 && cancelAnimationFrame(this._blurRafId);
|
|
383
|
-
}
|
|
384
|
-
isDisabled(t) {
|
|
385
|
-
const r = v(t);
|
|
386
|
-
if (this.minDate && r < this.minDate || this.maxDate && r > this.maxDate) return !0;
|
|
387
|
-
if (this.disabledRanges && this.disabledRanges.length > 0)
|
|
388
|
-
for (const a of this.disabledRanges) {
|
|
389
|
-
const e = a.start.split("T")[0], n = a.end ? a.end.split("T")[0] : e;
|
|
390
|
-
if (r >= e && r <= n)
|
|
391
|
-
return !0;
|
|
392
|
-
}
|
|
393
|
-
return !1;
|
|
394
|
-
}
|
|
395
|
-
prevMonth() {
|
|
396
|
-
const t = this._currentDate;
|
|
397
|
-
this._currentDate = new Date(t.getFullYear(), t.getMonth() - 1, 1);
|
|
398
|
-
}
|
|
399
|
-
nextMonth() {
|
|
400
|
-
const t = this._currentDate;
|
|
401
|
-
this._currentDate = new Date(t.getFullYear(), t.getMonth() + 1, 1);
|
|
402
|
-
}
|
|
403
|
-
generateDateGrid(t = 0) {
|
|
404
|
-
const r = this._currentDate.getFullYear(), a = this._currentDate.getMonth() + t, e = new Date(r, a, 1), n = e.getDay(), l = Y(this.localeId)[0], c = (n - l + 7) % 7, u = new Date(e);
|
|
405
|
-
u.setDate(e.getDate() - c);
|
|
406
|
-
const b = [];
|
|
407
|
-
for (let h = 0; h < 42; h++) {
|
|
408
|
-
const p = new Date(u);
|
|
409
|
-
p.setDate(u.getDate() + h), b.push(p);
|
|
410
|
-
}
|
|
411
|
-
return b;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Finds the next focusable button index based on the current index and step value.
|
|
415
|
-
* This method skips disabled buttons and continues until it either finds
|
|
416
|
-
* a focusable button or goes out of bounds of the given button list.
|
|
417
|
-
*
|
|
418
|
-
* @param {number} currentIndex - The index of the currently focused button.
|
|
419
|
-
* @param {number} step - The step size to move. Can be positive or negative.
|
|
420
|
-
* @param {HTMLButtonElement[]} buttons - The list of button elements to navigate through.
|
|
421
|
-
* @return {number} - The index of the next focusable button if found; otherwise, returns out-of-bounds index.
|
|
422
|
-
*/
|
|
423
|
-
findNextFocusableIndex(t, r, a) {
|
|
424
|
-
let e = t + r;
|
|
425
|
-
for (; e >= 0 && e < a.length; ) {
|
|
426
|
-
const n = a[e];
|
|
427
|
-
if (!this.isButtonDisabled(n))
|
|
428
|
-
return e;
|
|
429
|
-
e += r;
|
|
430
|
-
}
|
|
431
|
-
return e;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Determines if a button element is disabled based on its attributes.
|
|
435
|
-
*
|
|
436
|
-
* @param {HTMLButtonElement | undefined} button - The button element to check. If undefined, the button is considered disabled.
|
|
437
|
-
* @return {boolean} Returns true if the button is disabled or if no button element is provided, otherwise false.
|
|
438
|
-
*/
|
|
439
|
-
isButtonDisabled(t) {
|
|
440
|
-
return t ? t.hasAttribute("disabled") : !0;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Determines whether navigation to the previous month is allowed.
|
|
444
|
-
*
|
|
445
|
-
* This method checks if the last day of the previous month exceeds the allowed minimum date.
|
|
446
|
-
* If there is no minimum date defined, navigation is always allowed.
|
|
447
|
-
*
|
|
448
|
-
* @return {boolean} Returns true if navigation to the previous month is permitted; otherwise, returns false.
|
|
449
|
-
*/
|
|
450
|
-
canGoPrev() {
|
|
451
|
-
if (!this.minDate) return !0;
|
|
452
|
-
const t = new Date(
|
|
453
|
-
this._currentDate.getFullYear(),
|
|
454
|
-
this._currentDate.getMonth(),
|
|
455
|
-
0
|
|
456
|
-
);
|
|
457
|
-
return v(t) >= this.minDate;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Determines whether navigation to the next month is allowed.
|
|
461
|
-
*
|
|
462
|
-
* This method checks if the first day of the next month exceeds the allowed maximum date.
|
|
463
|
-
* If there is no maximum date defined, navigation is always allowed.
|
|
464
|
-
*
|
|
465
|
-
* @return {boolean} Returns true if navigation to the next month is permitted; otherwise, returns false.
|
|
466
|
-
*/
|
|
467
|
-
canGoNext() {
|
|
468
|
-
if (!this.maxDate) return !0;
|
|
469
|
-
const t = (this.numberOfMonths ?? 1) - 1, r = new Date(
|
|
470
|
-
this._currentDate.getFullYear(),
|
|
471
|
-
this._currentDate.getMonth() + t + 1,
|
|
472
|
-
1
|
|
473
|
-
);
|
|
474
|
-
return v(r) <= this.maxDate;
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
s([
|
|
478
|
-
o({ type: String })
|
|
479
|
-
], i.prototype, "uid");
|
|
480
|
-
s([
|
|
481
|
-
o({ type: String })
|
|
482
|
-
], i.prototype, "label");
|
|
483
|
-
s([
|
|
484
|
-
o({ type: String })
|
|
485
|
-
], i.prototype, "hint");
|
|
486
|
-
s([
|
|
487
|
-
o({ type: String, attribute: "locale-id" })
|
|
488
|
-
], i.prototype, "localeId");
|
|
489
|
-
s([
|
|
490
|
-
o({ type: Array })
|
|
491
|
-
], i.prototype, "errors");
|
|
492
|
-
s([
|
|
493
|
-
o({ type: Boolean })
|
|
494
|
-
], i.prototype, "touched");
|
|
495
|
-
s([
|
|
496
|
-
o({ type: Boolean })
|
|
497
|
-
], i.prototype, "required");
|
|
498
|
-
s([
|
|
499
|
-
o({ type: Boolean })
|
|
500
|
-
], i.prototype, "disabled");
|
|
501
|
-
s([
|
|
502
|
-
o({ type: Boolean, attribute: "readonly" })
|
|
503
|
-
], i.prototype, "readOnly");
|
|
504
|
-
s([
|
|
505
|
-
o({ type: String, attribute: "prev-month-icon" })
|
|
506
|
-
], i.prototype, "prevMonthIcon");
|
|
507
|
-
s([
|
|
508
|
-
o({ type: String, attribute: "next-month-icon" })
|
|
509
|
-
], i.prototype, "nextMonthIcon");
|
|
510
|
-
s([
|
|
511
|
-
o({ type: String, attribute: "prev-month-aria-label" })
|
|
512
|
-
], i.prototype, "prevMonthAriaLabel");
|
|
513
|
-
s([
|
|
514
|
-
o({ type: String, attribute: "next-month-aria-label" })
|
|
515
|
-
], i.prototype, "nextMonthAriaLabel");
|
|
516
|
-
s([
|
|
517
|
-
o({ type: String })
|
|
518
|
-
], i.prototype, "dayFormat");
|
|
519
|
-
s([
|
|
520
|
-
o({ type: String })
|
|
521
|
-
], i.prototype, "weekdayFormat");
|
|
522
|
-
s([
|
|
523
|
-
o({ type: String })
|
|
524
|
-
], i.prototype, "monthFormat");
|
|
525
|
-
s([
|
|
526
|
-
o({ type: String })
|
|
527
|
-
], i.prototype, "minDate");
|
|
528
|
-
s([
|
|
529
|
-
o({ type: String })
|
|
530
|
-
], i.prototype, "maxDate");
|
|
531
|
-
s([
|
|
532
|
-
o({ type: Array })
|
|
533
|
-
], i.prototype, "disabledRanges");
|
|
534
|
-
s([
|
|
535
|
-
o({ type: Number })
|
|
536
|
-
], i.prototype, "numberOfMonths");
|
|
537
|
-
s([
|
|
538
|
-
x()
|
|
539
|
-
], i.prototype, "_currentDate");
|
|
540
|
-
s([
|
|
541
|
-
x()
|
|
542
|
-
], i.prototype, "_yearSelectorOpen");
|
|
543
|
-
export {
|
|
544
|
-
i as A
|
|
545
|
-
};
|
package/calendar-BclCC9VJ.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { html as p } from "lit";
|
|
2
|
-
import { property as f, customElement as g } from "lit/decorators.js";
|
|
3
|
-
import { classMap as v } from "lit/directives/class-map.js";
|
|
4
|
-
import { p as c, i as d, t as b, b as M, a as C, g as _ } from "./date-CDUlLuYy.js";
|
|
5
|
-
import { A as y } from "./abstract-calendar-D0-077XJ.js";
|
|
6
|
-
var w = Object.defineProperty, O = Object.getOwnPropertyDescriptor, D = (e, t, n, r) => {
|
|
7
|
-
for (var i = r > 1 ? void 0 : r ? O(t, n) : t, s = e.length - 1, a; s >= 0; s--)
|
|
8
|
-
(a = e[s]) && (i = (r ? a(t, n, i) : a(i)) || i);
|
|
9
|
-
return r && i && w(t, n, i), i;
|
|
10
|
-
};
|
|
11
|
-
let l = class extends y {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments), this.value = void 0;
|
|
14
|
-
}
|
|
15
|
-
createRenderRoot() {
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
connectedCallback() {
|
|
19
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
20
|
-
}
|
|
21
|
-
willUpdate(e) {
|
|
22
|
-
if (e.has("value") && this.value) {
|
|
23
|
-
const t = c(this.value);
|
|
24
|
-
!isNaN(t.getTime()) && !d(t, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = t);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
renderDay(e) {
|
|
28
|
-
const t = {
|
|
29
|
-
"gui-calendar__day-button": !0,
|
|
30
|
-
today: e.isToday,
|
|
31
|
-
selected: e.isSelected,
|
|
32
|
-
disabled: e.isDisabled,
|
|
33
|
-
"other-month": !e.isCurrentMonth
|
|
34
|
-
};
|
|
35
|
-
return p`
|
|
36
|
-
<button
|
|
37
|
-
type="button"
|
|
38
|
-
role="gridcell"
|
|
39
|
-
class=${v(t)}
|
|
40
|
-
tabindex=${e.isFocusable ? 0 : -1}
|
|
41
|
-
?disabled=${!e.isCurrentMonth || e.isDisabled}
|
|
42
|
-
data-date=${b(e.date)}
|
|
43
|
-
@click=${() => this.selectDate(e)}
|
|
44
|
-
@keydown=${(n) => this.handleKeydown(n, e)}
|
|
45
|
-
aria-selected=${e.isSelected}
|
|
46
|
-
>
|
|
47
|
-
${e.dayLabel}
|
|
48
|
-
</button>
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
getDaysInMonth(e) {
|
|
52
|
-
const t = new Date(this._currentDate);
|
|
53
|
-
t.setDate(1), t.setMonth(t.getMonth() + e);
|
|
54
|
-
const n = this.generateDateGrid(e), r = t.getMonth();
|
|
55
|
-
let i = n.map((s) => {
|
|
56
|
-
const a = s.getMonth() === r, o = this.isDisabled(s), u = !!this.value && M(s, c(this.value)), h = C(s), m = (u || h) && a;
|
|
57
|
-
return {
|
|
58
|
-
date: s,
|
|
59
|
-
dayLabel: _(this.localeId, s),
|
|
60
|
-
isCurrentMonth: a,
|
|
61
|
-
isToday: h,
|
|
62
|
-
isDisabled: o,
|
|
63
|
-
isSelected: u,
|
|
64
|
-
isFocusable: m
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
for (let s = 0; s < 2; s++)
|
|
68
|
-
i.slice(-7).every((o) => !o.isCurrentMonth) && (i = i.slice(0, -7));
|
|
69
|
-
if (e === 0 && !i.some((s) => s.isFocusable)) {
|
|
70
|
-
const s = this.value ? c(this.value) : /* @__PURE__ */ new Date();
|
|
71
|
-
if (!d(s, this._currentDate, this.numberOfMonths ?? 1)) {
|
|
72
|
-
const a = i.find((o) => o.isCurrentMonth && !o.isDisabled);
|
|
73
|
-
a && (a.isFocusable = !0);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return i;
|
|
77
|
-
}
|
|
78
|
-
selectDate(e) {
|
|
79
|
-
if (!e.isCurrentMonth || e.isDisabled || this.disabled || this.readOnly) return;
|
|
80
|
-
const t = b(e.date);
|
|
81
|
-
this.value = t, this.dispatchEvent(
|
|
82
|
-
new CustomEvent("change", {
|
|
83
|
-
detail: { value: t },
|
|
84
|
-
bubbles: !0,
|
|
85
|
-
composed: !0
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
D([
|
|
91
|
-
f({ type: String })
|
|
92
|
-
], l.prototype, "value", 2);
|
|
93
|
-
l = D([
|
|
94
|
-
g("gui-calendar")
|
|
95
|
-
], l);
|
|
96
|
-
typeof customElements < "u" && !customElements.get("gui-calendar") && customElements.define("gui-calendar", l);
|