@golemui/gui-lit 1.0.2 → 1.1.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 +15 -0
- package/calendar-BuJgwvZx.js +254 -0
- package/{calendar.element-MubSE1bx.js → calendar.element-M5MPJmap.js} +1 -1
- package/{currency.element-BHXWcOEu.js → currency.element-CfFrAtrr.js} +20 -14
- package/{date-DTYg8sog.js → date-Bj9mI3GU.js} +106 -50
- package/date-input-cJDkNnVw.js +184 -0
- package/date-picker.element-va_-LGZD.js +312 -0
- package/date-time-calendar-BzRfkLKU.js +361 -0
- package/date-time-calendar.element-DC4NK0y1.js +93 -0
- package/date-time-input-BXxsfuyZ.js +214 -0
- package/date-time-picker.element-Dy-8cb-_.js +380 -0
- package/date-time.element-Bv4XdzMi.js +87 -0
- package/{date.element-BtVJSIRk.js → date.element-Consgsbb.js} +32 -27
- package/day-status-0-hJHrI7.js +530 -0
- package/{dropdown.element-DqzC6aXR.js → dropdown.element-WsD61Qel.js} +57 -48
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1209 -981
- package/index.umd.cjs +1574 -519
- 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-D1oKnH89.js → list-CrLIL4by.js} +76 -61
- package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
- package/{number.element-BhEyoOtc.js → number.element-CBr47IiY.js} +18 -16
- package/numeric-jmOOKz30.js +12 -0
- package/package.json +6 -6
- package/part-templates-Db871PS3.js +677 -0
- package/pill-ranges-DCqDmpkk.js +48 -0
- package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
- package/popup.controller-eUDxE6jD.js +71 -0
- package/range-calendar-CKPYeSGt.js +452 -0
- package/{range-calendar.element-QTE6vGNP.js → range-calendar.element-D6KYq18B.js} +24 -20
- package/range-commit-8-MmYUyo.js +14 -0
- package/range-date-input-D--AqBMv.js +292 -0
- package/{range-date-input.element-Dj29D_OQ.js → range-date-input.element-D4nIXJbw.js} +8 -7
- package/range-date-picker.element-dhxPAAE6.js +386 -0
- package/range-date-time-calendar-yksWrR7b.js +720 -0
- package/range-date-time-calendar.element-C00aDefZ.js +95 -0
- package/range-date-time-input-B37TUoM3.js +322 -0
- package/range-date-time-input.element-DUnbv4ed.js +81 -0
- package/range-date-time-picker.element-Cbps6s_G.js +412 -0
- package/range-selection-CU3hxLJE.js +25 -0
- package/range-time-input-3lhqR1Ku.js +329 -0
- package/range-time-input.element-dU2iBdmJ.js +81 -0
- package/range-time-picker.element-v6nQsIPw.js +429 -0
- package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
- package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
- package/time-input-BOhlBGJZ.js +181 -0
- package/time-list-Czo48bZm.js +217 -0
- package/time-picker-bFJ63ky8.js +261 -0
- package/time-picker.element-CYZVXgRS.js +85 -0
- package/time.element-fK3oLi49.js +82 -0
- package/abstract-calendar-BoqKPRmS.js +0 -545
- package/calendar-DTYKVYc3.js +0 -96
- package/date-input-BeQvyfln.js +0 -268
- package/date-picker.element-DabW_-0-.js +0 -166
- package/range-calendar-9skwbwlB.js +0 -255
- package/range-date-input-Uy8134vi.js +0 -395
- package/range-date-picker.element-CuKIBkIO.js +0 -182
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { nothing as S, html as c } from "lit";
|
|
2
|
+
import { g as C, n as O, c as T } from "./focus-leave.controller-2gV0pQd5.js";
|
|
3
|
+
import { t as v, p as M, j as k, i as E, k as R, l as I, w as A, f as L, h as N, n as y } from "./date-Bj9mI3GU.js";
|
|
4
|
+
import { repeat as w } from "lit-html/directives/repeat.js";
|
|
5
|
+
import { b as P, c as q } from "./templates-Dk1jxLwS.js";
|
|
6
|
+
const m = ".gui-calendar__day-button:not(.other-month)", F = ".gui-calendar__panel", G = "gui-calendar__year-button", U = ".gui-calendar__year-button", $ = ".gui-calendar__year-button.current", K = ".gui-calendar__year-grid", Y = ".gui-calendar__year-selector", H = '.gui-calendar__day-button[tabindex="0"]';
|
|
7
|
+
class te {
|
|
8
|
+
constructor(e, r) {
|
|
9
|
+
this.handleDayKeydown = async (n) => {
|
|
10
|
+
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(n.key) && n.key !== " " && n.key !== "Enter") return;
|
|
11
|
+
const a = n.target, u = Array.from(this.host.querySelectorAll(m)), p = u.indexOf(a), f = window.getComputedStyle(this.host).direction === "rtl";
|
|
12
|
+
if (n.key === " " || n.key === "Enter") {
|
|
13
|
+
n.preventDefault(), this.options.onActivateDay(a.dataset.date ?? "", n);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const d = C(n.key, { columns: 7, isRTL: f });
|
|
17
|
+
if (d.kind !== "delta") return;
|
|
18
|
+
const h = d.delta;
|
|
19
|
+
n.preventDefault();
|
|
20
|
+
const s = O(
|
|
21
|
+
p,
|
|
22
|
+
h,
|
|
23
|
+
u.length,
|
|
24
|
+
(o) => this.isButtonDisabled(u[o])
|
|
25
|
+
);
|
|
26
|
+
let l = !1;
|
|
27
|
+
if (s < 0)
|
|
28
|
+
if (this.options.canGoPrev())
|
|
29
|
+
this.options.goPrev(), l = !0;
|
|
30
|
+
else {
|
|
31
|
+
u.find((g) => !this.isButtonDisabled(g))?.focus();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
else if (s >= u.length)
|
|
35
|
+
if (this.options.canGoNext())
|
|
36
|
+
this.options.goNext(), l = !0;
|
|
37
|
+
else {
|
|
38
|
+
[...u].reverse().find((b) => !this.isButtonDisabled(b))?.focus();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (l) {
|
|
42
|
+
await this.host.updateComplete;
|
|
43
|
+
const o = Array.from(
|
|
44
|
+
this.host.querySelectorAll(m)
|
|
45
|
+
), g = Array.from(this.host.querySelectorAll(F));
|
|
46
|
+
let b;
|
|
47
|
+
if (s < 0)
|
|
48
|
+
b = g[0].querySelectorAll(m).length + s;
|
|
49
|
+
else {
|
|
50
|
+
const _ = g[g.length - 1].querySelectorAll(m).length;
|
|
51
|
+
b = o.length - _ + (s - u.length);
|
|
52
|
+
}
|
|
53
|
+
if (this.isButtonDisabled(o[b])) {
|
|
54
|
+
const D = O(
|
|
55
|
+
b,
|
|
56
|
+
h,
|
|
57
|
+
o.length,
|
|
58
|
+
(_) => this.isButtonDisabled(o[_])
|
|
59
|
+
);
|
|
60
|
+
if (D < 0 || D >= o.length) {
|
|
61
|
+
const _ = o.findIndex((x) => !this.isButtonDisabled(x));
|
|
62
|
+
_ > -1 && o[_].focus();
|
|
63
|
+
} else
|
|
64
|
+
o[D]?.focus();
|
|
65
|
+
} else {
|
|
66
|
+
const D = Math.max(0, Math.min(b, o.length - 1));
|
|
67
|
+
o[D]?.focus();
|
|
68
|
+
}
|
|
69
|
+
} else
|
|
70
|
+
u[s]?.focus();
|
|
71
|
+
}, this.handleYearKeydown = (n) => {
|
|
72
|
+
const i = n.target;
|
|
73
|
+
if (!i.classList.contains(G)) return;
|
|
74
|
+
const a = Array.from(this.host.querySelectorAll(U)), u = a.indexOf(i), p = window.getComputedStyle(this.host).direction === "rtl";
|
|
75
|
+
if (n.key === "Enter" || n.key === " ") {
|
|
76
|
+
n.preventDefault();
|
|
77
|
+
const h = parseInt(i.dataset.year ?? "", 10);
|
|
78
|
+
isNaN(h) || this.selectYear(h);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (n.key === "Escape") {
|
|
82
|
+
n.preventDefault(), n.stopPropagation(), this.host.querySelector(Y)?.focus(), this.options.onCloseYearGrid();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const f = C(n.key, { columns: 4, isRTL: p });
|
|
86
|
+
if (f.kind !== "delta") return;
|
|
87
|
+
n.preventDefault();
|
|
88
|
+
const d = u + f.delta;
|
|
89
|
+
d >= 0 && d < a.length && a[d].focus();
|
|
90
|
+
}, this.onPrevMonthClick = () => {
|
|
91
|
+
this.options.goPrev(), this.keepNavFocusInside("prev", "next");
|
|
92
|
+
}, this.onNextMonthClick = () => {
|
|
93
|
+
this.options.goNext(), this.keepNavFocusInside("next", "prev");
|
|
94
|
+
}, this.host = e, this.options = r, e.addController(this);
|
|
95
|
+
}
|
|
96
|
+
hostConnected() {
|
|
97
|
+
}
|
|
98
|
+
selectYear(e) {
|
|
99
|
+
this.host.querySelector(
|
|
100
|
+
Y
|
|
101
|
+
)?.focus(), this.options.onSelectYear(e), this.host.updateComplete.then(() => {
|
|
102
|
+
this.host.querySelector(H)?.focus();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* When the grid just opened, waits for the update, then scrolls the current year
|
|
107
|
+
* button into the middle of the grid viewport and focuses it. A close is a no-op.
|
|
108
|
+
*/
|
|
109
|
+
onYearGridToggled() {
|
|
110
|
+
this.options.isYearGridOpen() && this.host.updateComplete.then(() => {
|
|
111
|
+
this.scrollToCurrentYear(), this.focusCurrentYearButton();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
scrollToCurrentYear() {
|
|
115
|
+
const e = this.host.querySelector(K), r = this.host.querySelector($);
|
|
116
|
+
if (e && r) {
|
|
117
|
+
const n = e.getBoundingClientRect(), i = r.getBoundingClientRect(), a = e.scrollTop + (i.top - n.top) - n.height / 2 + i.height / 2;
|
|
118
|
+
e.scrollTop = Math.max(0, a);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
focusCurrentYearButton() {
|
|
122
|
+
this.host.querySelector($)?.focus();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* After a nav click lands on a min/max boundary, the clicked button renders
|
|
126
|
+
* disabled and would drop focus to the body; refocus the opposite nav
|
|
127
|
+
* button, falling back to any enabled day button.
|
|
128
|
+
*/
|
|
129
|
+
async keepNavFocusInside(e, r) {
|
|
130
|
+
await this.host.updateComplete;
|
|
131
|
+
const n = this.host.querySelector(
|
|
132
|
+
`.gui-calendar__month-button--${e}`
|
|
133
|
+
);
|
|
134
|
+
if (!n || !n.disabled) return;
|
|
135
|
+
(this.host.querySelector(
|
|
136
|
+
`.gui-calendar__month-button--${r}:not([disabled])`
|
|
137
|
+
) ?? this.host.querySelector(".gui-calendar__day-button:not([disabled])"))?.focus();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether a queried button is disabled; a missing button counts as disabled
|
|
141
|
+
*/
|
|
142
|
+
isButtonDisabled(e) {
|
|
143
|
+
return e ? e.hasAttribute("disabled") : !0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
class ne {
|
|
147
|
+
constructor(e, r) {
|
|
148
|
+
this._currentDate = /* @__PURE__ */ new Date(), this._yearSelectorOpen = !1, this.host = e, this.options = r, e.addController(this);
|
|
149
|
+
}
|
|
150
|
+
hostConnected() {
|
|
151
|
+
}
|
|
152
|
+
/** The first visible month. */
|
|
153
|
+
get currentDate() {
|
|
154
|
+
return this._currentDate;
|
|
155
|
+
}
|
|
156
|
+
set currentDate(e) {
|
|
157
|
+
Object.is(e, this._currentDate) || (this._currentDate = e, this.host.requestUpdate());
|
|
158
|
+
}
|
|
159
|
+
/** Whether the year grid is open. */
|
|
160
|
+
get yearSelectorOpen() {
|
|
161
|
+
return this._yearSelectorOpen;
|
|
162
|
+
}
|
|
163
|
+
set yearSelectorOpen(e) {
|
|
164
|
+
Object.is(e, this._yearSelectorOpen) || (this._yearSelectorOpen = e, this.host.requestUpdate());
|
|
165
|
+
}
|
|
166
|
+
prevMonth() {
|
|
167
|
+
const e = this._currentDate;
|
|
168
|
+
this.currentDate = new Date(e.getFullYear(), e.getMonth() - 1, 1);
|
|
169
|
+
}
|
|
170
|
+
nextMonth() {
|
|
171
|
+
const e = this._currentDate;
|
|
172
|
+
this.currentDate = new Date(e.getFullYear(), e.getMonth() + 1, 1);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Determines whether navigation to the previous month is allowed.
|
|
176
|
+
*
|
|
177
|
+
* This method checks if the last day of the previous month exceeds the allowed minimum date.
|
|
178
|
+
* If there is no minimum date defined, navigation is always allowed.
|
|
179
|
+
*
|
|
180
|
+
* @return {boolean} Returns true if navigation to the previous month is permitted; otherwise, returns false.
|
|
181
|
+
*/
|
|
182
|
+
canGoPrev() {
|
|
183
|
+
const e = this.options.getMinDate();
|
|
184
|
+
if (!e) return !0;
|
|
185
|
+
const r = new Date(
|
|
186
|
+
this._currentDate.getFullYear(),
|
|
187
|
+
this._currentDate.getMonth(),
|
|
188
|
+
0
|
|
189
|
+
);
|
|
190
|
+
return v(r) >= e;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Determines whether navigation to the next month is allowed.
|
|
194
|
+
*
|
|
195
|
+
* This method checks if the first day of the next month exceeds the allowed maximum date.
|
|
196
|
+
* If there is no maximum date defined, navigation is always allowed.
|
|
197
|
+
*
|
|
198
|
+
* @return {boolean} Returns true if navigation to the next month is permitted; otherwise, returns false.
|
|
199
|
+
*/
|
|
200
|
+
canGoNext() {
|
|
201
|
+
const e = this.options.getMaxDate();
|
|
202
|
+
if (!e) return !0;
|
|
203
|
+
const r = (this.options.getNumberOfMonths() ?? 1) - 1, n = new Date(
|
|
204
|
+
this._currentDate.getFullYear(),
|
|
205
|
+
this._currentDate.getMonth() + r + 1,
|
|
206
|
+
1
|
|
207
|
+
);
|
|
208
|
+
return v(n) <= e;
|
|
209
|
+
}
|
|
210
|
+
/** First selectable year: `minDate`'s year, or the 1900 floor. */
|
|
211
|
+
get effectiveMinYear() {
|
|
212
|
+
const e = this.options.getMinDate();
|
|
213
|
+
return e ? M(e).getFullYear() : 1900;
|
|
214
|
+
}
|
|
215
|
+
/** Last selectable year: `maxDate`'s year, or the 2099 ceiling. */
|
|
216
|
+
get effectiveMaxYear() {
|
|
217
|
+
const e = this.options.getMaxDate();
|
|
218
|
+
return e ? M(e).getFullYear() : 2099;
|
|
219
|
+
}
|
|
220
|
+
/** The year-grid entries, min..max inclusive. */
|
|
221
|
+
get yearList() {
|
|
222
|
+
const e = [];
|
|
223
|
+
for (let r = this.effectiveMinYear; r <= this.effectiveMaxYear; r++)
|
|
224
|
+
e.push(r);
|
|
225
|
+
return e;
|
|
226
|
+
}
|
|
227
|
+
/** Flips the year grid and fires `onYearSelectorToggled` */
|
|
228
|
+
toggleYearSelector() {
|
|
229
|
+
this.yearSelectorOpen = !this._yearSelectorOpen, this.options.onYearSelectorToggled?.();
|
|
230
|
+
}
|
|
231
|
+
/** Applies a picked year: jump to the same month of `year` and close the year grid. */
|
|
232
|
+
selectYear(e) {
|
|
233
|
+
this.currentDate = new Date(e, this._currentDate.getMonth(), 1), this.yearSelectorOpen = !1;
|
|
234
|
+
}
|
|
235
|
+
/** Closes the year grid. */
|
|
236
|
+
closeYearSelector() {
|
|
237
|
+
this.yearSelectorOpen = !1;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Navigates so `date` becomes visible — a no-op for invalid dates and for
|
|
241
|
+
* dates already inside the visible months.
|
|
242
|
+
*/
|
|
243
|
+
navigateToDate(e) {
|
|
244
|
+
!isNaN(e.getTime()) && !k(e, this._currentDate, this.options.getNumberOfMonths() ?? 1) && (this.currentDate = e);
|
|
245
|
+
}
|
|
246
|
+
/** Whether a day is outside min/max or inside a disabled range. */
|
|
247
|
+
isDisabled(e) {
|
|
248
|
+
return E(
|
|
249
|
+
v(e),
|
|
250
|
+
this.options.getMinDate(),
|
|
251
|
+
this.options.getMaxDate(),
|
|
252
|
+
this.options.getDisabledRanges()
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function re(t) {
|
|
257
|
+
const e = {
|
|
258
|
+
uid: t.uid,
|
|
259
|
+
label: t.label,
|
|
260
|
+
hint: t.hint,
|
|
261
|
+
errors: t.errors,
|
|
262
|
+
touched: t.touched,
|
|
263
|
+
required: t.required
|
|
264
|
+
}, r = Array.from({ length: t.numberOfMonths ?? 1 }, (n, i) => i);
|
|
265
|
+
return c`
|
|
266
|
+
${t.label ? P(t.uid, e, !1, "calendar") : S}
|
|
267
|
+
|
|
268
|
+
<div class="gui-widget" @focusout=${t.onFocusOut}>
|
|
269
|
+
<div
|
|
270
|
+
id=${t.uid}
|
|
271
|
+
class="gui-calendar-input"
|
|
272
|
+
role="group"
|
|
273
|
+
aria-labelledby=${t.label ? `${t.uid}_calendar_label` : S}
|
|
274
|
+
?aria-disabled=${t.disabled}
|
|
275
|
+
>
|
|
276
|
+
${t.renderAboveCalendar()}
|
|
277
|
+
<div class="gui-calendar__container">
|
|
278
|
+
${B("prev", {
|
|
279
|
+
icon: t.prevMonthIcon,
|
|
280
|
+
ariaLabel: t.prevMonthAriaLabel,
|
|
281
|
+
disabled: !t.canGoPrev,
|
|
282
|
+
onClick: t.onPrevMonthClick
|
|
283
|
+
})}
|
|
284
|
+
|
|
285
|
+
<div class="gui-calendar__months-grid">
|
|
286
|
+
${r.map((n) => t.renderMonthPanel(n))}
|
|
287
|
+
</div>
|
|
288
|
+
|
|
289
|
+
${B("next", {
|
|
290
|
+
icon: t.nextMonthIcon,
|
|
291
|
+
ariaLabel: t.nextMonthAriaLabel,
|
|
292
|
+
disabled: !t.canGoNext,
|
|
293
|
+
onClick: t.onNextMonthClick
|
|
294
|
+
})}
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
${t.errors?.length ? q(t.uid, e) : S}
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
function B(t, e) {
|
|
303
|
+
return t === "prev" ? c`
|
|
304
|
+
<button
|
|
305
|
+
type="button"
|
|
306
|
+
tabindex="0"
|
|
307
|
+
class="gui-button gui-calendar__month-button gui-calendar__month-button--prev"
|
|
308
|
+
?disabled=${e.disabled}
|
|
309
|
+
@click=${e.onClick}
|
|
310
|
+
aria-label=${e.ariaLabel ?? "Previous month"}
|
|
311
|
+
>
|
|
312
|
+
${e.icon ? c`<span class=${`gui-widget-icon ${e.icon}`} data-icon=${e.icon}></span>` : c`<svg
|
|
313
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
314
|
+
width="16"
|
|
315
|
+
height="16"
|
|
316
|
+
viewBox="0 0 256 256"
|
|
317
|
+
>
|
|
318
|
+
<path
|
|
319
|
+
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"
|
|
320
|
+
></path>
|
|
321
|
+
</svg>`}
|
|
322
|
+
</button>
|
|
323
|
+
` : c`
|
|
324
|
+
<button
|
|
325
|
+
type="button"
|
|
326
|
+
tabindex="0"
|
|
327
|
+
class="gui-button gui-calendar__month-button gui-calendar__month-button--next"
|
|
328
|
+
?disabled=${e.disabled}
|
|
329
|
+
@click=${e.onClick}
|
|
330
|
+
aria-label=${e.ariaLabel ?? "Next month"}
|
|
331
|
+
>
|
|
332
|
+
${e.icon ? c`<span class=${`gui-widget-icon ${e.icon}`} data-icon=${e.icon}></span>` : c`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
|
|
333
|
+
<path
|
|
334
|
+
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"
|
|
335
|
+
></path>
|
|
336
|
+
</svg>`}
|
|
337
|
+
</button>
|
|
338
|
+
`;
|
|
339
|
+
}
|
|
340
|
+
function V(t) {
|
|
341
|
+
const e = new Date(t.currentDate);
|
|
342
|
+
return e.setDate(1), e.setMonth(e.getMonth() + t.offset), c`
|
|
343
|
+
<div class="gui-calendar__panel">
|
|
344
|
+
${t.renderHeader(e)} ${t.renderBelowHeader(t.offset)}
|
|
345
|
+
${t.renderPanelBody(t.offset)}
|
|
346
|
+
</div>
|
|
347
|
+
`;
|
|
348
|
+
}
|
|
349
|
+
function se(t) {
|
|
350
|
+
return V({
|
|
351
|
+
currentDate: t.currentDate,
|
|
352
|
+
offset: t.offset,
|
|
353
|
+
renderHeader: (e) => W(e, {
|
|
354
|
+
localeId: t.localeId,
|
|
355
|
+
monthFormat: t.monthFormat,
|
|
356
|
+
yearSelectorOpen: t.yearSelectorOpen,
|
|
357
|
+
onToggleYearSelector: t.onToggleYearSelector
|
|
358
|
+
}),
|
|
359
|
+
renderBelowHeader: t.renderBelowHeader ?? (() => S),
|
|
360
|
+
renderPanelBody: t.renderPanelBody
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function oe(t) {
|
|
364
|
+
return t.yearSelectorOpen && t.offset === 0 ? Z({
|
|
365
|
+
years: t.years,
|
|
366
|
+
currentYear: t.currentYear,
|
|
367
|
+
onSelectYear: t.onSelectYear,
|
|
368
|
+
onKeydown: t.onYearKeydown
|
|
369
|
+
}) : j(
|
|
370
|
+
T(t.getDays(t.offset), 7),
|
|
371
|
+
R(t.localeId),
|
|
372
|
+
(e) => t.renderDay(e)
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
function W(t, e) {
|
|
376
|
+
const r = I(e.localeId, t, e.monthFormat);
|
|
377
|
+
return c`
|
|
378
|
+
<header class="gui-calendar__header">
|
|
379
|
+
<h2>
|
|
380
|
+
${r.map(
|
|
381
|
+
(n) => n.type === "year" ? c`<button
|
|
382
|
+
type="button"
|
|
383
|
+
tabindex="0"
|
|
384
|
+
class="gui-calendar__year-selector"
|
|
385
|
+
@click=${e.onToggleYearSelector}
|
|
386
|
+
aria-expanded=${e.yearSelectorOpen}
|
|
387
|
+
aria-label="Select year"
|
|
388
|
+
>
|
|
389
|
+
<span class="gui-calendar__year-value">${n.value}</span>
|
|
390
|
+
<span class="gui-calendar__year-arrow" aria-hidden="true">
|
|
391
|
+
<svg
|
|
392
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
393
|
+
width="16"
|
|
394
|
+
height="16"
|
|
395
|
+
viewBox="0 0 256 256"
|
|
396
|
+
>
|
|
397
|
+
<path
|
|
398
|
+
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"
|
|
399
|
+
></path>
|
|
400
|
+
</svg>
|
|
401
|
+
</span>
|
|
402
|
+
</button>` : c`<span class="gui-calendar__month-name">${n.value}</span>`
|
|
403
|
+
)}
|
|
404
|
+
</h2>
|
|
405
|
+
</header>
|
|
406
|
+
`;
|
|
407
|
+
}
|
|
408
|
+
function j(t, e, r) {
|
|
409
|
+
return c`
|
|
410
|
+
<div class="gui-calendar__days-grid" role="grid">
|
|
411
|
+
<div role="row" class="gui-calendar__rows">
|
|
412
|
+
${w(
|
|
413
|
+
e,
|
|
414
|
+
(n, i) => i,
|
|
415
|
+
(n) => c`<span class="gui-calendar__weekday" role="gridcell">${n}</span>`
|
|
416
|
+
)}
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
${w(
|
|
420
|
+
t,
|
|
421
|
+
(n) => c`
|
|
422
|
+
<div role="row" class="gui-calendar__rows">
|
|
423
|
+
${w(
|
|
424
|
+
n,
|
|
425
|
+
(i) => i.date.toISOString(),
|
|
426
|
+
(i) => r(i)
|
|
427
|
+
)}
|
|
428
|
+
</div>
|
|
429
|
+
`
|
|
430
|
+
)}
|
|
431
|
+
</div>
|
|
432
|
+
`;
|
|
433
|
+
}
|
|
434
|
+
function Z(t) {
|
|
435
|
+
const e = t.currentYear;
|
|
436
|
+
return c`
|
|
437
|
+
<div
|
|
438
|
+
class="gui-calendar__year-grid"
|
|
439
|
+
role="grid"
|
|
440
|
+
aria-label="Year selection"
|
|
441
|
+
@keydown=${t.onKeydown}
|
|
442
|
+
>
|
|
443
|
+
${T(t.years, 4).map(
|
|
444
|
+
(r) => c`
|
|
445
|
+
<div role="row" class="gui-calendar__year-row">
|
|
446
|
+
${r.map(
|
|
447
|
+
(n) => c`
|
|
448
|
+
<button
|
|
449
|
+
type="button"
|
|
450
|
+
role="gridcell"
|
|
451
|
+
class="gui-calendar__year-button ${n === e ? "current" : ""}"
|
|
452
|
+
tabindex=${n === e ? 0 : -1}
|
|
453
|
+
data-year=${n}
|
|
454
|
+
@click=${(i) => {
|
|
455
|
+
i.stopPropagation(), t.onSelectYear(n);
|
|
456
|
+
}}
|
|
457
|
+
aria-selected=${n === e}
|
|
458
|
+
>
|
|
459
|
+
${n}
|
|
460
|
+
</button>
|
|
461
|
+
`
|
|
462
|
+
)}
|
|
463
|
+
</div>
|
|
464
|
+
`
|
|
465
|
+
)}
|
|
466
|
+
</div>
|
|
467
|
+
`;
|
|
468
|
+
}
|
|
469
|
+
function ie(t, e) {
|
|
470
|
+
const r = t.getTime();
|
|
471
|
+
let n = !1, i = !1, a = !1, u = !1, p = !1, f = !1, d = !1, h = !1;
|
|
472
|
+
if (e.selectedISO && (n = y(t, M(e.selectedISO))), e.invalidRange) {
|
|
473
|
+
const s = e.invalidRange.start, l = e.invalidRange.end;
|
|
474
|
+
f = y(t, s), d = y(t, l), r > s.getTime() && r < l.getTime() && (h = !0);
|
|
475
|
+
}
|
|
476
|
+
if (e.selectingSpan && (p = r >= e.selectingSpan.start.getTime() && r <= e.selectingSpan.end.getTime()), e.ranges)
|
|
477
|
+
for (const s of e.ranges)
|
|
478
|
+
y(t, s.start) && (i = !0, a = !s.end), s.end && (y(t, s.end) && (a = !0), r > s.start.getTime() && r < s.end.getTime() && (u = !0));
|
|
479
|
+
if (e.workingRange) {
|
|
480
|
+
const { start: s, end: l } = e.workingRange;
|
|
481
|
+
y(t, s) && (i = !0), y(t, l) && (a = !0), r > s.getTime() && r < l.getTime() && (u = !0);
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
isSelected: n,
|
|
485
|
+
isRangeStart: i,
|
|
486
|
+
isRangeEnd: a,
|
|
487
|
+
isInRange: u,
|
|
488
|
+
isOneDayRange: i && a,
|
|
489
|
+
isAnchor: e.anchor ? y(t, e.anchor) : !1,
|
|
490
|
+
isSelecting: p,
|
|
491
|
+
isInvalidStart: f,
|
|
492
|
+
isInvalidEnd: d,
|
|
493
|
+
isInvalidInRange: h
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function ae(t) {
|
|
497
|
+
const { currentDate: e, offset: r = 0, localeId: n, numberOfMonths: i = 1 } = t, a = new Date(e.getFullYear(), e.getMonth() + r, 1), u = a.getMonth(), p = a.getDay(), f = A(n)[0], d = (p - f + 7) % 7, h = new Date(a);
|
|
498
|
+
h.setDate(a.getDate() - d);
|
|
499
|
+
let s = [];
|
|
500
|
+
for (let l = 0; l < 42; l++) {
|
|
501
|
+
const o = new Date(h);
|
|
502
|
+
o.setDate(h.getDate() + l), s.push(
|
|
503
|
+
t.toDay({
|
|
504
|
+
date: o,
|
|
505
|
+
dayLabel: N(n, o),
|
|
506
|
+
isCurrentMonth: o.getMonth() === u,
|
|
507
|
+
isToday: L(o),
|
|
508
|
+
isDisabled: t.isDisabled(o)
|
|
509
|
+
})
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
for (let l = 0; l < 2; l++)
|
|
513
|
+
s.slice(-7).every((g) => !g.isCurrentMonth) && (s = s.slice(0, -7));
|
|
514
|
+
if (r === 0 && !s.some((l) => l.isFocusable) && !(t.focusFallbackDates ?? []).some(
|
|
515
|
+
(o) => k(o, e, i)
|
|
516
|
+
)) {
|
|
517
|
+
const o = s.find((g) => g.isCurrentMonth && !g.isDisabled);
|
|
518
|
+
o && (o.isFocusable = !0);
|
|
519
|
+
}
|
|
520
|
+
return s;
|
|
521
|
+
}
|
|
522
|
+
export {
|
|
523
|
+
ne as G,
|
|
524
|
+
te as a,
|
|
525
|
+
se as b,
|
|
526
|
+
oe as c,
|
|
527
|
+
ae as d,
|
|
528
|
+
ie as e,
|
|
529
|
+
re as r
|
|
530
|
+
};
|