@golemui/gui-lit 0.12.2 → 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.
- package/CHANGELOG.md +4 -0
- package/abstract-calendar-YDgwwbqe.js +528 -0
- package/{accordion.element-81uTv6Ms.js → accordion.element-ChLmV6QT.js} +24 -22
- package/{alert.element-DWrS5ggK.js → alert.element-9QFlqjj9.js} +23 -21
- package/button.element-ATNRRDN3.js +121 -0
- package/calendar-P9DzVryu.js +96 -0
- package/{calendar.element-C1rLK7aY.js → calendar.element-O2of7VBr.js} +25 -22
- package/checkbox.element-DMmer4Jw.js +199 -0
- package/currency.element-C7SZkoPP.js +266 -0
- package/date-CG1562vW.js +786 -0
- package/date-input-VJG8lMVN.js +266 -0
- package/{date-picker.element-GNC8f3Qi.js → date-picker.element-Bcyhc0fb.js} +29 -25
- package/{date.element-Dzw-UJzC.js → date.element-DfXmcgZi.js} +25 -22
- package/{dropdown.element-CebROj9s.js → dropdown.element-DCUI5Y7I.js} +24 -22
- package/errors-QjKhr6mA.js +109 -0
- package/{flex.element-BMqqfxjI.js → flex.element-B0sG0YT1.js} +24 -22
- package/{grid.element-CBMoOuLt.js → grid.element-Bf5aEjkj.js} +24 -22
- package/index.js +2708 -1174
- package/index.umd.cjs +982 -108
- package/lib/components/accordion.element.d.ts +7 -7
- package/lib/components/alert.element.d.ts +6 -6
- package/lib/components/button.element.d.ts +6 -6
- package/lib/components/calendar.element.d.ts +6 -6
- package/lib/components/checkbox.element.d.ts +6 -6
- package/lib/components/currency.element.d.ts +6 -6
- package/lib/components/date-picker.element.d.ts +6 -6
- package/lib/components/date.element.d.ts +6 -6
- package/lib/components/dropdown.element.d.ts +6 -6
- package/lib/components/flex.element.d.ts +6 -6
- package/lib/components/grid.element.d.ts +6 -6
- package/lib/components/list.element.d.ts +6 -6
- package/lib/components/markdown-text.element.d.ts +6 -6
- package/lib/components/markdown.element.d.ts +6 -6
- package/lib/components/number.element.d.ts +6 -6
- package/lib/components/password.element.d.ts +6 -6
- package/lib/components/radiogroup.element.d.ts +6 -6
- package/lib/components/range-calendar.element.d.ts +6 -6
- package/lib/components/range-date-input.element.d.ts +6 -6
- package/lib/components/range-date-picker.element.d.ts +6 -6
- package/lib/components/renderer.element.d.ts +6 -6
- package/lib/components/repeater.element.d.ts +6 -6
- package/lib/components/select.element.d.ts +6 -6
- package/lib/components/tabs.element.d.ts +6 -6
- package/lib/components/textarea.element.d.ts +6 -6
- package/lib/components/textinput.element.d.ts +6 -6
- package/lib/components/toggle.element.d.ts +6 -6
- package/lib/widget.loaders.d.ts +2 -2
- package/list-CtFsv7GB.js +284 -0
- package/{list.element-DIIgN_Ww.js → list.element-G8RNRZXU.js} +30 -27
- package/markdown-text-X-BRJT6K.js +30 -0
- package/{markdown-text.element-DY7b-dU5.js → markdown-text.element-C_1OqrGa.js} +23 -20
- package/markdown.element-CT1JOOM3.js +596 -0
- package/number.element-HaXEg_7U.js +282 -0
- package/one-of-DifUsEYY.js +48 -0
- package/package.json +6 -6
- package/password.element-B4-0SCe4.js +238 -0
- package/radiogroup.element-DzHLgRh1.js +232 -0
- package/range-calendar-qpakwAba.js +326 -0
- package/{range-calendar.element-Bli9UfhN.js → range-calendar.element-C-4qqRGK.js} +20 -17
- package/range-date-input-CrNpOVHt.js +507 -0
- package/{range-date-input.element-BwPvGk5F.js → range-date-input.element-Iq5Y7uLQ.js} +20 -17
- package/{range-date-picker.element-DJQOwDPh.js → range-date-picker.element-4bg4Uraq.js} +29 -25
- package/{renderer.element-B99qD2mz.js → renderer.element-DMsheQGi.js} +19 -17
- package/{repeater.element-AaifWsOB.js → repeater.element-Ry8HyMfW.js} +41 -27
- package/select.element-DuGZjlZY.js +257 -0
- package/tabs-DzSCq_98.js +13 -0
- package/{tabs.element-k8JMNDXi.js → tabs.element-VLrtF1j5.js} +31 -29
- package/templates-Dk1jxLwS.js +75 -0
- package/textarea.element-C8yx2u0o.js +237 -0
- package/textinput.element-DKuplF1A.js +204 -0
- package/toggle.element-NXRrhALB.js +201 -0
- package/button.element-hjhVBamJ.js +0 -56
- package/checkbox.element-bu9_MvED.js +0 -65
- package/currency.element-Bxv2WxAx.js +0 -72
- package/default-list-item-renderer-DNVEjKSX.js +0 -23
- package/markdown.element-ZD_n4ObO.js +0 -73
- package/number.element-B0E7W2TK.js +0 -70
- package/password.element-C4_eLdUO.js +0 -71
- package/radiogroup.element-BD8qBNoO.js +0 -68
- package/select.element-BLxtqB0A.js +0 -74
- package/textarea.element-DgDwfzYP.js +0 -70
- package/textinput.element-DSLFDjfb.js +0 -67
- package/toggle.element-BLu6F99u.js +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
import { LitElement as M, nothing as _, html as u } from "lit";
|
|
2
|
+
import { property as o, state as w } from "lit/decorators.js";
|
|
3
|
+
import { G as S, b as $, c as A } from "./templates-Dk1jxLwS.js";
|
|
4
|
+
import { repeat as D } from "lit-html/directives/repeat.js";
|
|
5
|
+
import { d as I, e as k, t as v, w as B } from "./date-CG1562vW.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 ? $(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 ? A(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
|
+
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { LayoutWidgetAdapter as l, formContext as u, layoutContext as h } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { consume as g, provide as m } from "@lit/context";
|
|
4
|
+
import { LitElement as v, html as r, nothing as p } from "lit";
|
|
5
|
+
import { property as f, customElement as b } from "lit/decorators.js";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
import { repeat as w } from "lit-html/directives/repeat.js";
|
|
8
|
+
import { classMap as _ } from "lit/directives/class-map.js";
|
|
9
|
+
var $ = Object.defineProperty, x = Object.getOwnPropertyDescriptor, d = (t, e, i, a) => {
|
|
10
|
+
for (var s = a > 1 ? void 0 : a ? x(e, i) : e, n = t.length - 1, c; n >= 0; n--)
|
|
9
11
|
(c = t[n]) && (s = (a ? c(e, i, s) : c(s)) || s);
|
|
10
|
-
return a && s &&
|
|
12
|
+
return a && s && $(e, i, s), s;
|
|
11
13
|
};
|
|
12
|
-
let o = class extends
|
|
14
|
+
let o = class extends v {
|
|
13
15
|
constructor() {
|
|
14
|
-
super(...arguments), this.activeSections = {}, this.adapter = new
|
|
16
|
+
super(...arguments), this.activeSections = {}, this.adapter = new l(), this.subscriptions = [];
|
|
15
17
|
}
|
|
16
18
|
createRenderRoot() {
|
|
17
19
|
return this;
|
|
@@ -39,7 +41,7 @@ let o = class extends g {
|
|
|
39
41
|
render() {
|
|
40
42
|
return this.adapter.templateData ? r`
|
|
41
43
|
<div class="gui-widget" id=${this.widget.uid}>
|
|
42
|
-
${this.adapter.templateData.sections ?
|
|
44
|
+
${this.adapter.templateData.sections ? w(
|
|
43
45
|
this.adapter.templateData.sections,
|
|
44
46
|
(t) => t.uid,
|
|
45
47
|
(t) => {
|
|
@@ -51,12 +53,12 @@ let o = class extends g {
|
|
|
51
53
|
aria-labelledby=${`accordion_button_${t.uid}`}
|
|
52
54
|
>
|
|
53
55
|
<gui-widget .widget=${this.getChild(t.uid)}></gui-widget>
|
|
54
|
-
</section>` :
|
|
56
|
+
</section>` : p;
|
|
55
57
|
return r`<div class="gui-accordion__section">
|
|
56
58
|
<button
|
|
57
59
|
type="button"
|
|
58
60
|
tabindex="0"
|
|
59
|
-
class=${
|
|
61
|
+
class=${_({
|
|
60
62
|
active: this.activeSections[t.uid]
|
|
61
63
|
})}
|
|
62
64
|
id=${`accordion_button_${t.uid}`}
|
|
@@ -80,7 +82,7 @@ let o = class extends g {
|
|
|
80
82
|
${e}
|
|
81
83
|
</div>`;
|
|
82
84
|
}
|
|
83
|
-
) :
|
|
85
|
+
) : p}
|
|
84
86
|
</div>
|
|
85
87
|
` : r``;
|
|
86
88
|
}
|
|
@@ -88,15 +90,15 @@ let o = class extends g {
|
|
|
88
90
|
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
89
91
|
}
|
|
90
92
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
d([
|
|
94
|
+
g({ context: u }),
|
|
95
|
+
f({ attribute: !1 })
|
|
94
96
|
], o.prototype, "formContext", 2);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
d([
|
|
98
|
+
m({ context: h })
|
|
97
99
|
], o.prototype, "adapter", 2);
|
|
98
|
-
o =
|
|
99
|
-
|
|
100
|
+
o = d([
|
|
101
|
+
b("gui-accordion-layout")
|
|
100
102
|
], o);
|
|
101
103
|
export {
|
|
102
104
|
o as AccordionElement
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as
|
|
3
|
-
import { consume as m, provide as
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { LitElement as d, html as n } from "lit";
|
|
2
|
+
import { property as c, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import { consume as m, provide as h } from "@lit/context";
|
|
4
|
+
import { DisplayWidgetAdapter as f, formContext as b, displayWidgetContext as g } from "@golemui/lit";
|
|
5
|
+
import "@golemui/gui-shared";
|
|
6
|
+
import "rxjs";
|
|
7
|
+
var v = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (r, t, a, i) => {
|
|
8
|
+
for (var e = i > 1 ? void 0 : i ? x(t, a) : t, o = r.length - 1, p; o >= 0; o--)
|
|
9
|
+
(p = r[o]) && (e = (i ? p(t, a, e) : p(e)) || e);
|
|
10
|
+
return i && e && v(t, a, e), e;
|
|
9
11
|
};
|
|
10
|
-
let s = class extends
|
|
12
|
+
let s = class extends d {
|
|
11
13
|
constructor() {
|
|
12
|
-
super(...arguments), this.adapter = new
|
|
14
|
+
super(...arguments), this.adapter = new f(), this.subscriptions = [];
|
|
13
15
|
}
|
|
14
16
|
createRenderRoot() {
|
|
15
17
|
return this;
|
|
16
18
|
}
|
|
17
|
-
updated(
|
|
18
|
-
super.updated(
|
|
19
|
+
updated(r) {
|
|
20
|
+
super.updated(r);
|
|
19
21
|
const t = this.adapter.templateData.size;
|
|
20
22
|
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
21
23
|
}
|
|
@@ -25,7 +27,7 @@ let s = class extends n {
|
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
render() {
|
|
28
|
-
return
|
|
30
|
+
return n`
|
|
29
31
|
<div class="gui-widget" id=${this.widget.uid}>
|
|
30
32
|
<div
|
|
31
33
|
role="alert"
|
|
@@ -37,18 +39,18 @@ let s = class extends n {
|
|
|
37
39
|
`;
|
|
38
40
|
}
|
|
39
41
|
disconnectedCallback() {
|
|
40
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((
|
|
42
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((r) => r.unsubscribe());
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
|
-
|
|
44
|
-
m({ context:
|
|
45
|
-
|
|
45
|
+
l([
|
|
46
|
+
m({ context: b }),
|
|
47
|
+
c({ attribute: !1 })
|
|
46
48
|
], s.prototype, "formContext", 2);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
l([
|
|
50
|
+
h({ context: g })
|
|
49
51
|
], s.prototype, "adapter", 2);
|
|
50
|
-
s =
|
|
51
|
-
|
|
52
|
+
s = l([
|
|
53
|
+
u("gui-alert-display")
|
|
52
54
|
], s);
|
|
53
55
|
export {
|
|
54
56
|
s as AlertElement
|