@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,17 +1,17 @@
|
|
|
1
1
|
import { InputWidgetAdapter as m, formContext as y, inputContext as $ } from "@golemui/lit";
|
|
2
|
-
import { LitElement as
|
|
2
|
+
import { LitElement as g, html as u, nothing as p } from "lit";
|
|
3
3
|
import { repeat as f } from "lit-html/directives/repeat.js";
|
|
4
|
-
import { property as s, customElement as
|
|
5
|
-
import { G as C, b as D, c as _ } from "./templates-
|
|
6
|
-
import { u as F, i as
|
|
7
|
-
import { consume as
|
|
4
|
+
import { property as s, customElement as b } from "lit/decorators.js";
|
|
5
|
+
import { G as C, b as D, c as _ } from "./templates-Dmr34nwp.js";
|
|
6
|
+
import { u as F, i as q } from "./one-of-C0ur6b_n.js";
|
|
7
|
+
import { consume as O, provide as w } from "@lit/context";
|
|
8
8
|
import "rxjs";
|
|
9
|
-
var
|
|
10
|
-
for (var
|
|
11
|
-
(n =
|
|
12
|
-
return a &&
|
|
9
|
+
var E = Object.defineProperty, S = Object.getOwnPropertyDescriptor, o = (e, i, d, a) => {
|
|
10
|
+
for (var t = a > 1 ? void 0 : a ? S(i, d) : i, l = e.length - 1, n; l >= 0; l--)
|
|
11
|
+
(n = e[l]) && (t = (a ? n(i, d, t) : n(t)) || t);
|
|
12
|
+
return a && t && E(i, d, t), t;
|
|
13
13
|
};
|
|
14
|
-
let r = class extends
|
|
14
|
+
let r = class extends g {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.hint = void 0, this.options = [], this.labelField = void 0, this.valueField = void 0, this.direction = "column", this.optionsLoading = !1, this.hasMatchingValue = !1, this.ariaController = new C(this, {
|
|
17
17
|
getTargets: () => this.querySelectorAll(`input[name="${this.uid}"]`),
|
|
@@ -23,7 +23,8 @@ let r = class extends b {
|
|
|
23
23
|
touched: this.touched,
|
|
24
24
|
// Radiogroup inputs can't be readonly
|
|
25
25
|
readonly: !1,
|
|
26
|
-
disabled: !1
|
|
26
|
+
disabled: !1,
|
|
27
|
+
required: this.required
|
|
27
28
|
}
|
|
28
29
|
})
|
|
29
30
|
});
|
|
@@ -36,7 +37,7 @@ let r = class extends b {
|
|
|
36
37
|
}
|
|
37
38
|
render() {
|
|
38
39
|
super.render();
|
|
39
|
-
const
|
|
40
|
+
const e = {
|
|
40
41
|
uid: this.uid,
|
|
41
42
|
label: this.label,
|
|
42
43
|
errors: this.errors,
|
|
@@ -57,23 +58,23 @@ let r = class extends b {
|
|
|
57
58
|
});
|
|
58
59
|
const i = this.value;
|
|
59
60
|
this.hasMatchingValue = this.options?.length ? this.options.find(({ value: a }) => a === i) !== void 0 : !1;
|
|
60
|
-
const d = this.optionsLoading ?
|
|
61
|
+
const d = this.optionsLoading ? u`<span>Loading...</span>` : u`
|
|
61
62
|
${f(
|
|
62
63
|
this.options || [],
|
|
63
64
|
(a) => a?.value,
|
|
64
|
-
(a,
|
|
65
|
-
const l = this.hasMatchingValue && a.value ===
|
|
66
|
-
return
|
|
65
|
+
(a, t) => {
|
|
66
|
+
const l = this.hasMatchingValue && a.value === e.value, n = !this.hasMatchingValue && t === 0, v = l || n;
|
|
67
|
+
return u`<label for=${`${this.uid}_${t}`}>
|
|
67
68
|
<input
|
|
68
69
|
type="radio"
|
|
69
70
|
tabindex=${v ? "0" : "-1"}
|
|
70
|
-
id=${`${this.uid}_${
|
|
71
|
-
data-cy=${`${this.uid}_radiogroup_${
|
|
71
|
+
id=${`${this.uid}_${t}`}
|
|
72
|
+
data-cy=${`${this.uid}_radiogroup_${t}`}
|
|
72
73
|
name=${this.uid}
|
|
73
74
|
value=${a.value}
|
|
74
75
|
?checked=${l}
|
|
75
|
-
?required=${
|
|
76
|
-
?disabled=${
|
|
76
|
+
?required=${e.required}
|
|
77
|
+
?disabled=${e.disabled || e.readonly}
|
|
77
78
|
@change=${this.valueChanged}
|
|
78
79
|
@blur=${this.onBlur}
|
|
79
80
|
/>
|
|
@@ -82,28 +83,31 @@ let r = class extends b {
|
|
|
82
83
|
}
|
|
83
84
|
)}
|
|
84
85
|
`;
|
|
85
|
-
return
|
|
86
|
-
${D(this.uid,
|
|
86
|
+
return u`
|
|
87
|
+
${D(this.uid, e, !1, void 0, !1)}
|
|
87
88
|
|
|
88
89
|
<div
|
|
89
90
|
class="gui-widget${this.direction === "row" ? " gui-widget--horizontal" : ""}"
|
|
90
91
|
role="radiogroup"
|
|
91
92
|
id=${this.uid}
|
|
92
|
-
aria-labelledby=${
|
|
93
|
-
aria-describedby=${
|
|
93
|
+
aria-labelledby=${e.label ? `${this.uid}_label` : p}
|
|
94
|
+
aria-describedby=${e.hint ? `${this.uid}_hint` : p}
|
|
95
|
+
aria-required=${this.required ? "true" : p}
|
|
96
|
+
aria-invalid=${this.touched && this.errors?.length ? "true" : p}
|
|
97
|
+
aria-errormessage=${this.touched && this.errors?.length ? `${this.uid}_errors` : p}
|
|
94
98
|
>
|
|
95
99
|
${d}
|
|
96
100
|
</div>
|
|
97
101
|
|
|
98
|
-
${_(this.uid,
|
|
102
|
+
${_(this.uid, e)}
|
|
99
103
|
`;
|
|
100
104
|
}
|
|
101
|
-
valueChanged(
|
|
102
|
-
if (
|
|
103
|
-
const i =
|
|
105
|
+
valueChanged(e) {
|
|
106
|
+
if (e.stopPropagation(), !this.readOnly) {
|
|
107
|
+
const i = e.target;
|
|
104
108
|
this.dispatchEvent(
|
|
105
109
|
new CustomEvent("change", {
|
|
106
|
-
detail: { value:
|
|
110
|
+
detail: { value: q(i.value, this.options) },
|
|
107
111
|
bubbles: !0,
|
|
108
112
|
composed: !0
|
|
109
113
|
})
|
|
@@ -162,23 +166,23 @@ o([
|
|
|
162
166
|
s({ type: String })
|
|
163
167
|
], r.prototype, "direction", 2);
|
|
164
168
|
r = o([
|
|
165
|
-
|
|
169
|
+
b("gui-radiogroup")
|
|
166
170
|
], r);
|
|
167
171
|
typeof customElements < "u" && !customElements.get("gui-radiogroup") && customElements.define("gui-radiogroup", r);
|
|
168
|
-
var x = Object.defineProperty, P = Object.getOwnPropertyDescriptor,
|
|
169
|
-
for (var
|
|
170
|
-
(n =
|
|
171
|
-
return a &&
|
|
172
|
+
var x = Object.defineProperty, P = Object.getOwnPropertyDescriptor, c = (e, i, d, a) => {
|
|
173
|
+
for (var t = a > 1 ? void 0 : a ? P(i, d) : i, l = e.length - 1, n; l >= 0; l--)
|
|
174
|
+
(n = e[l]) && (t = (a ? n(i, d, t) : n(t)) || t);
|
|
175
|
+
return a && t && x(i, d, t), t;
|
|
172
176
|
};
|
|
173
|
-
let
|
|
177
|
+
let h = class extends g {
|
|
174
178
|
constructor() {
|
|
175
179
|
super(...arguments), this.adapter = new m(), this.subscriptions = [];
|
|
176
180
|
}
|
|
177
181
|
createRenderRoot() {
|
|
178
182
|
return this;
|
|
179
183
|
}
|
|
180
|
-
updated(
|
|
181
|
-
super.updated(
|
|
184
|
+
updated(e) {
|
|
185
|
+
super.updated(e);
|
|
182
186
|
const i = this.adapter.templateData.size;
|
|
183
187
|
i ? this.style.flex = String(i) : this.style.removeProperty("flex");
|
|
184
188
|
}
|
|
@@ -188,7 +192,7 @@ let u = class extends b {
|
|
|
188
192
|
);
|
|
189
193
|
}
|
|
190
194
|
render() {
|
|
191
|
-
return super.render(),
|
|
195
|
+
return super.render(), u`
|
|
192
196
|
<gui-radiogroup
|
|
193
197
|
.uid=${this.widget.uid}
|
|
194
198
|
.label=${this.adapter.templateData.label}
|
|
@@ -208,24 +212,24 @@ let u = class extends b {
|
|
|
208
212
|
></gui-radiogroup>
|
|
209
213
|
`;
|
|
210
214
|
}
|
|
211
|
-
valueChanged(
|
|
212
|
-
const i =
|
|
215
|
+
valueChanged(e) {
|
|
216
|
+
const i = e.detail.value;
|
|
213
217
|
this.adapter.valueChanged(i);
|
|
214
218
|
}
|
|
215
219
|
disconnectedCallback() {
|
|
216
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((
|
|
220
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
217
221
|
}
|
|
218
222
|
};
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
c([
|
|
224
|
+
O({ context: y }),
|
|
221
225
|
s({ attribute: !1 })
|
|
222
|
-
],
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
],
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
],
|
|
226
|
+
], h.prototype, "formContext", 2);
|
|
227
|
+
c([
|
|
228
|
+
w({ context: $ })
|
|
229
|
+
], h.prototype, "adapter", 2);
|
|
230
|
+
h = c([
|
|
231
|
+
b("gui-radiogroup-input")
|
|
232
|
+
], h);
|
|
229
233
|
export {
|
|
230
|
-
|
|
234
|
+
h as RadiogroupElement
|
|
231
235
|
};
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { LitElement as b, html as p, nothing as l } from "lit";
|
|
2
|
+
import { property as r, state as v, customElement as y } from "lit/decorators.js";
|
|
3
|
+
import { classMap as m } from "lit/directives/class-map.js";
|
|
4
|
+
import { G as D } from "./templates-Dmr34nwp.js";
|
|
5
|
+
import { G as f, a as _, r as S, b as R, c as M, d as I, e as C } from "./day-status-CsWStVQV.js";
|
|
6
|
+
import { G as A } from "./focus-leave.controller-2gV0pQd5.js";
|
|
7
|
+
import { p as d, g as O, t as h, r as L, D as E, m as P, c as x } from "./date-DBuYpvcO.js";
|
|
8
|
+
import { r as G, f as $, a as k, b as w, s as N, c as T } from "./pill-ranges-DpvWwP-3.js";
|
|
9
|
+
import { i as Y, s as F, r as g } from "./range-selection-CU3hxLJE.js";
|
|
10
|
+
import "./pills-BDMO2NiR.js";
|
|
11
|
+
var B = Object.defineProperty, q = Object.getOwnPropertyDescriptor, n = (e, t, o, a) => {
|
|
12
|
+
for (var s = a > 1 ? void 0 : a ? q(t, o) : t, u = e.length - 1, c; u >= 0; u--)
|
|
13
|
+
(c = e[u]) && (s = (a ? c(t, o, s) : c(s)) || s);
|
|
14
|
+
return a && s && B(t, o, s), s;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends b {
|
|
17
|
+
constructor() {
|
|
18
|
+
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.selectYearAriaLabel = void 0, this.yearGridAriaLabel = void 0, 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.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this.disabledDateRangeMessage = void 0, this.invalidRange = null, this._selection = Y(), this._invalidRange = null, this._skipValueNavigation = !1, this._nav = new f(this, {
|
|
19
|
+
getMinDate: () => this.minDate,
|
|
20
|
+
getMaxDate: () => this.maxDate,
|
|
21
|
+
getNumberOfMonths: () => this.numberOfMonths,
|
|
22
|
+
getDisabledRanges: () => this.disabledRanges,
|
|
23
|
+
onYearSelectorToggled: () => this._keyboard.onYearGridToggled()
|
|
24
|
+
}), this.ariaController = new D(this, {
|
|
25
|
+
getTargets: () => this.querySelectorAll(".gui-calendar-input"),
|
|
26
|
+
getState: () => ({
|
|
27
|
+
uid: this.uid,
|
|
28
|
+
templateData: {
|
|
29
|
+
hint: this.hint,
|
|
30
|
+
errors: this.errors,
|
|
31
|
+
readonly: this.readOnly,
|
|
32
|
+
disabled: this.disabled,
|
|
33
|
+
touched: this.touched,
|
|
34
|
+
required: this.required
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
}), this._keyboard = new _(this, {
|
|
38
|
+
canGoPrev: () => this._nav.canGoPrev(),
|
|
39
|
+
canGoNext: () => this._nav.canGoNext(),
|
|
40
|
+
goPrev: () => this._nav.prevMonth(),
|
|
41
|
+
goNext: () => this._nav.nextMonth(),
|
|
42
|
+
onActivateDay: (e, t) => this.selectDate(this.activationDay(e), t),
|
|
43
|
+
onSelectYear: (e) => this._nav.selectYear(e),
|
|
44
|
+
onCloseYearGrid: () => this._nav.closeYearSelector(),
|
|
45
|
+
isYearGridOpen: () => this._nav.yearSelectorOpen
|
|
46
|
+
}), this._focusLeave = new A(this, {
|
|
47
|
+
onLeave: () => this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }))
|
|
48
|
+
}), this.onPillRemoveEvent = (e) => {
|
|
49
|
+
if (this.disabled || this.readOnly) return;
|
|
50
|
+
const t = G(this.value, e.detail.key);
|
|
51
|
+
t && (this.value = t.next, this.dispatchEvent(
|
|
52
|
+
new CustomEvent("change", {
|
|
53
|
+
detail: { value: this.value },
|
|
54
|
+
bubbles: !0,
|
|
55
|
+
composed: !0
|
|
56
|
+
})
|
|
57
|
+
));
|
|
58
|
+
}, this.onPillClickEvent = (e) => {
|
|
59
|
+
const t = $(this.getSortedPills(), e.detail.key);
|
|
60
|
+
t && this.navigateToDate(t.start);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** The nav controller's month cursor, kept under its historical name. */
|
|
64
|
+
get _currentDate() {
|
|
65
|
+
return this._nav.currentDate;
|
|
66
|
+
}
|
|
67
|
+
set _currentDate(e) {
|
|
68
|
+
this._nav.currentDate = e;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Full instant of an endpoint, used to order the pills. Date-only here; a
|
|
72
|
+
* subclass whose endpoints carry a time overrides it so two ranges on the
|
|
73
|
+
* same day still sort by time.
|
|
74
|
+
*/
|
|
75
|
+
parseEndpoint(e) {
|
|
76
|
+
return d(e);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Midnight-truncated calendar day of an endpoint, used to highlight the day
|
|
80
|
+
* grid.
|
|
81
|
+
*/
|
|
82
|
+
endpointDay(e) {
|
|
83
|
+
return d(e);
|
|
84
|
+
}
|
|
85
|
+
/** Pill text for one committed range. */
|
|
86
|
+
formatPillLabel(e) {
|
|
87
|
+
return k(e, (t) => T(t, this.localeId));
|
|
88
|
+
}
|
|
89
|
+
/** Day-button inner content. */
|
|
90
|
+
renderDayContent(e) {
|
|
91
|
+
return p`${e.dayLabel}`;
|
|
92
|
+
}
|
|
93
|
+
createRenderRoot() {
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
connectedCallback() {
|
|
97
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
98
|
+
}
|
|
99
|
+
willUpdate(e) {
|
|
100
|
+
if (e.has("invalidRange"))
|
|
101
|
+
if (this.invalidRange) {
|
|
102
|
+
const t = this.endpointDay(this.invalidRange.start), o = this.endpointDay(this.invalidRange.end);
|
|
103
|
+
this._invalidRange = isNaN(t.getTime()) || isNaN(o.getTime()) ? null : { start: t, end: o };
|
|
104
|
+
} else
|
|
105
|
+
this._invalidRange = null;
|
|
106
|
+
if (e.has("value") && !e.has("focusDate")) {
|
|
107
|
+
if (this._skipValueNavigation)
|
|
108
|
+
this._skipValueNavigation = !1;
|
|
109
|
+
else if (this.value) {
|
|
110
|
+
const t = Array.isArray(this.value) ? this.value : [{ start: this.value }];
|
|
111
|
+
t.length > 0 && t[0].start && this._nav.navigateToDate(this.endpointDay(t[0].start));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (e.has("focusDate") && this.focusDate) {
|
|
115
|
+
const t = d(this.focusDate);
|
|
116
|
+
isNaN(t.getTime()) || (this._nav.navigateToDate(t), this.focusDate = void 0);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
return S({
|
|
121
|
+
uid: this.uid,
|
|
122
|
+
label: this.label,
|
|
123
|
+
hint: this.hint,
|
|
124
|
+
errors: this.errors,
|
|
125
|
+
touched: this.touched,
|
|
126
|
+
required: this.required,
|
|
127
|
+
disabled: this.disabled,
|
|
128
|
+
numberOfMonths: this.numberOfMonths,
|
|
129
|
+
localeId: this.localeId,
|
|
130
|
+
currentDate: this._nav.currentDate,
|
|
131
|
+
prevMonthIcon: this.prevMonthIcon,
|
|
132
|
+
nextMonthIcon: this.nextMonthIcon,
|
|
133
|
+
prevMonthAriaLabel: this.prevMonthAriaLabel,
|
|
134
|
+
nextMonthAriaLabel: this.nextMonthAriaLabel,
|
|
135
|
+
canGoPrev: this._nav.canGoPrev(),
|
|
136
|
+
canGoNext: this._nav.canGoNext(),
|
|
137
|
+
onPrevMonthClick: this._keyboard.onPrevMonthClick,
|
|
138
|
+
onNextMonthClick: this._keyboard.onNextMonthClick,
|
|
139
|
+
onFocusOut: this._focusLeave.onFocusOut,
|
|
140
|
+
renderAboveCalendar: () => this.renderAboveCalendar(),
|
|
141
|
+
renderMonthPanel: (e) => R({
|
|
142
|
+
currentDate: this._nav.currentDate,
|
|
143
|
+
offset: e,
|
|
144
|
+
localeId: this.localeId,
|
|
145
|
+
monthFormat: this.monthFormat,
|
|
146
|
+
yearSelectorOpen: this._nav.yearSelectorOpen,
|
|
147
|
+
selectYearAriaLabel: this.selectYearAriaLabel,
|
|
148
|
+
onToggleYearSelector: () => this.toggleYearSelector(),
|
|
149
|
+
renderBelowHeader: (t) => this.renderBelowHeader(t),
|
|
150
|
+
renderPanelBody: (t) => this.renderPanelBody(t)
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/** Hook rendered between the header and the panel body. Default: nothing. */
|
|
155
|
+
renderBelowHeader(e) {
|
|
156
|
+
return l;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The panel content below the header: the year grid replaces the days grid
|
|
160
|
+
* of the first panel while the year selector is open. Subclasses can swap
|
|
161
|
+
* in other bodies (e.g. the date-time calendar's time grid).
|
|
162
|
+
*/
|
|
163
|
+
renderPanelBody(e) {
|
|
164
|
+
return M({
|
|
165
|
+
offset: e,
|
|
166
|
+
yearSelectorOpen: this._nav.yearSelectorOpen,
|
|
167
|
+
years: this._nav.yearList,
|
|
168
|
+
currentYear: this._nav.currentDate.getFullYear(),
|
|
169
|
+
onSelectYear: (t) => this._keyboard.selectYear(t),
|
|
170
|
+
onYearKeydown: this._keyboard.handleYearKeydown,
|
|
171
|
+
localeId: this.localeId,
|
|
172
|
+
currentDate: this._nav.currentDate,
|
|
173
|
+
yearGridAriaLabel: this.yearGridAriaLabel,
|
|
174
|
+
getDays: (t) => this.getDaysInMonth(t),
|
|
175
|
+
renderDay: (t) => this.renderDay(t)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Kept as a thin override point — the range date-time subclass closes its
|
|
180
|
+
* time pickers before delegating to the nav controller.
|
|
181
|
+
*/
|
|
182
|
+
toggleYearSelector() {
|
|
183
|
+
this._nav.toggleYearSelector();
|
|
184
|
+
}
|
|
185
|
+
isDisabled(e) {
|
|
186
|
+
return this._nav.isDisabled(e);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Rebuilds the day context for an Enter/Space activation from the button's
|
|
190
|
+
* `data-date`. Legitimate because a day button can only be focused when it
|
|
191
|
+
* is enabled and in-month; the `disabled`/`readOnly` guards stay in
|
|
192
|
+
* `selectDate`.
|
|
193
|
+
*/
|
|
194
|
+
activationDay(e) {
|
|
195
|
+
const t = d(e);
|
|
196
|
+
return {
|
|
197
|
+
date: t,
|
|
198
|
+
isCurrentMonth: !0,
|
|
199
|
+
isDisabled: this.isDisabled(t),
|
|
200
|
+
isFocusable: !0,
|
|
201
|
+
dayLabel: "",
|
|
202
|
+
isToday: !1,
|
|
203
|
+
isRangeStart: !1,
|
|
204
|
+
isRangeEnd: !1,
|
|
205
|
+
isInRange: !1,
|
|
206
|
+
isOneDayRange: !1,
|
|
207
|
+
isAnchor: !1,
|
|
208
|
+
isSelecting: !1,
|
|
209
|
+
isInvalidStart: !1,
|
|
210
|
+
isInvalidEnd: !1,
|
|
211
|
+
isInvalidInRange: !1
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
renderDay(e) {
|
|
215
|
+
const t = e.isInvalidStart && e.isInvalidEnd, o = {
|
|
216
|
+
"gui-calendar__day-button": !0,
|
|
217
|
+
today: e.isToday,
|
|
218
|
+
"other-month": !e.isCurrentMonth,
|
|
219
|
+
"range-start": e.isRangeStart && !e.isOneDayRange,
|
|
220
|
+
"range-end": e.isRangeEnd && !e.isOneDayRange,
|
|
221
|
+
selected: e.isOneDayRange,
|
|
222
|
+
"in-range": e.isInRange,
|
|
223
|
+
"invalid-range-start": e.isInvalidStart && !t,
|
|
224
|
+
"invalid-range-end": e.isInvalidEnd && !t,
|
|
225
|
+
"invalid-range-single": t,
|
|
226
|
+
"invalid-in-range": e.isInvalidInRange,
|
|
227
|
+
"is-anchor": e.isAnchor,
|
|
228
|
+
"is-selecting": e.isSelecting,
|
|
229
|
+
disabled: e.isDisabled
|
|
230
|
+
};
|
|
231
|
+
return p`
|
|
232
|
+
<button
|
|
233
|
+
type="button"
|
|
234
|
+
role="gridcell"
|
|
235
|
+
class=${m(o)}
|
|
236
|
+
tabindex=${e.isFocusable ? 0 : -1}
|
|
237
|
+
?disabled=${!e.isCurrentMonth}
|
|
238
|
+
aria-disabled=${e.isCurrentMonth && e.isDisabled ? "true" : l}
|
|
239
|
+
aria-label=${O(this.localeId, e.date)}
|
|
240
|
+
aria-current=${e.isToday ? "date" : l}
|
|
241
|
+
data-date=${h(e.date)}
|
|
242
|
+
@click=${(a) => this.selectDate(e, a)}
|
|
243
|
+
@mouseover=${() => this.onMouseOver(e)}
|
|
244
|
+
@focus=${() => this.onMouseOver(e)}
|
|
245
|
+
@keydown=${(a) => this._keyboard.handleDayKeydown(a)}
|
|
246
|
+
aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
|
|
247
|
+
>
|
|
248
|
+
${this.renderDayContent(e)}
|
|
249
|
+
</button>
|
|
250
|
+
`;
|
|
251
|
+
}
|
|
252
|
+
getDaysInMonth(e) {
|
|
253
|
+
const t = (this.value ?? []).map((a) => ({
|
|
254
|
+
start: this.endpointDay(a.start),
|
|
255
|
+
end: a.end ? this.endpointDay(a.end) : void 0
|
|
256
|
+
})), o = F(this._selection);
|
|
257
|
+
return I({
|
|
258
|
+
currentDate: this._currentDate,
|
|
259
|
+
offset: e,
|
|
260
|
+
localeId: this.localeId,
|
|
261
|
+
numberOfMonths: this.numberOfMonths ?? 1,
|
|
262
|
+
isDisabled: (a) => this.isDisabled(a),
|
|
263
|
+
toDay: (a) => {
|
|
264
|
+
const s = C(a.date, {
|
|
265
|
+
ranges: t,
|
|
266
|
+
anchor: this._selection.anchor,
|
|
267
|
+
selectingSpan: o,
|
|
268
|
+
invalidRange: this._invalidRange
|
|
269
|
+
});
|
|
270
|
+
return {
|
|
271
|
+
date: a.date,
|
|
272
|
+
dayLabel: a.dayLabel,
|
|
273
|
+
isCurrentMonth: a.isCurrentMonth,
|
|
274
|
+
isToday: a.isToday,
|
|
275
|
+
isRangeStart: s.isRangeStart,
|
|
276
|
+
isRangeEnd: s.isRangeEnd,
|
|
277
|
+
isInRange: s.isInRange,
|
|
278
|
+
isInvalidStart: s.isInvalidStart && a.isCurrentMonth,
|
|
279
|
+
isInvalidEnd: s.isInvalidEnd && a.isCurrentMonth,
|
|
280
|
+
isInvalidInRange: s.isInvalidInRange && a.isCurrentMonth,
|
|
281
|
+
isDisabled: a.isDisabled,
|
|
282
|
+
isOneDayRange: s.isOneDayRange,
|
|
283
|
+
isAnchor: s.isAnchor,
|
|
284
|
+
isFocusable: a.isToday || s.isRangeStart,
|
|
285
|
+
isSelecting: s.isSelecting && a.isCurrentMonth
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
focusFallbackDates: [
|
|
289
|
+
/* @__PURE__ */ new Date(),
|
|
290
|
+
...(this.value ?? []).map((a) => this.endpointDay(a.start))
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
selectDate(e, t = null) {
|
|
295
|
+
if (!e.isCurrentMonth || e.isDisabled || this.disabled || this.readOnly) return;
|
|
296
|
+
const { state: o, commit: a } = g(this._selection, {
|
|
297
|
+
type: "pick",
|
|
298
|
+
date: e.date
|
|
299
|
+
});
|
|
300
|
+
if (this._selection = o, !a) {
|
|
301
|
+
this._invalidRange = null;
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (L(
|
|
305
|
+
h(a.start),
|
|
306
|
+
h(a.end),
|
|
307
|
+
this.disabledRanges,
|
|
308
|
+
this.minDate,
|
|
309
|
+
this.maxDate
|
|
310
|
+
)) {
|
|
311
|
+
this._invalidRange = { start: a.start, end: a.end }, this.dispatchEvent(
|
|
312
|
+
new CustomEvent("inputError", {
|
|
313
|
+
detail: {
|
|
314
|
+
message: this.disabledDateRangeMessage ?? E,
|
|
315
|
+
range: { start: h(a.start), end: h(a.end) }
|
|
316
|
+
},
|
|
317
|
+
bubbles: !0,
|
|
318
|
+
composed: !0
|
|
319
|
+
})
|
|
320
|
+
), this.requestUpdate();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
this._invalidRange = null, this._skipValueNavigation = !0, this.value = P([
|
|
324
|
+
...this.value || [],
|
|
325
|
+
x(a.start, a.end)
|
|
326
|
+
]), this.dispatchEvent(
|
|
327
|
+
new CustomEvent("change", {
|
|
328
|
+
detail: { value: this.value },
|
|
329
|
+
bubbles: !0,
|
|
330
|
+
composed: !0
|
|
331
|
+
})
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
onMouseOver(e) {
|
|
335
|
+
e.isDisabled || (this._selection = g(this._selection, {
|
|
336
|
+
type: "hover",
|
|
337
|
+
date: e.date
|
|
338
|
+
}).state);
|
|
339
|
+
}
|
|
340
|
+
// --- Pills ---
|
|
341
|
+
renderAboveCalendar() {
|
|
342
|
+
if (this.hidePills) return l;
|
|
343
|
+
const e = this.getSortedPills();
|
|
344
|
+
if (e.length === 0) return l;
|
|
345
|
+
const t = w(e, (o) => this.formatPillLabel(o));
|
|
346
|
+
return p`
|
|
347
|
+
<gui-pills
|
|
348
|
+
class="gui-range-calendar__pills"
|
|
349
|
+
.uid=${this.uid}
|
|
350
|
+
.toolbarAriaLabel=${"Selected date ranges"}
|
|
351
|
+
.items=${t}
|
|
352
|
+
.removable=${!0}
|
|
353
|
+
.clickable=${!0}
|
|
354
|
+
.bubble=${!1}
|
|
355
|
+
?disabled=${this.disabled}
|
|
356
|
+
?readonly=${this.readOnly}
|
|
357
|
+
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
|
|
358
|
+
@pillremove=${this.onPillRemoveEvent}
|
|
359
|
+
@pillclick=${this.onPillClickEvent}
|
|
360
|
+
></gui-pills>
|
|
361
|
+
`;
|
|
362
|
+
}
|
|
363
|
+
getSortedPills() {
|
|
364
|
+
return N(
|
|
365
|
+
this.value,
|
|
366
|
+
(e, t) => this.parseEndpoint(e).getTime() - this.parseEndpoint(t).getTime()
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
navigateToDate(e) {
|
|
370
|
+
this._nav.navigateToDate(this.endpointDay(e));
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
n([
|
|
374
|
+
r({ type: String })
|
|
375
|
+
], i.prototype, "uid", 2);
|
|
376
|
+
n([
|
|
377
|
+
r({ type: String })
|
|
378
|
+
], i.prototype, "label", 2);
|
|
379
|
+
n([
|
|
380
|
+
r({ type: String })
|
|
381
|
+
], i.prototype, "hint", 2);
|
|
382
|
+
n([
|
|
383
|
+
r({ type: String, attribute: "locale-id" })
|
|
384
|
+
], i.prototype, "localeId", 2);
|
|
385
|
+
n([
|
|
386
|
+
r({ type: Array })
|
|
387
|
+
], i.prototype, "errors", 2);
|
|
388
|
+
n([
|
|
389
|
+
r({ type: Boolean })
|
|
390
|
+
], i.prototype, "touched", 2);
|
|
391
|
+
n([
|
|
392
|
+
r({ type: Boolean })
|
|
393
|
+
], i.prototype, "required", 2);
|
|
394
|
+
n([
|
|
395
|
+
r({ type: Boolean })
|
|
396
|
+
], i.prototype, "disabled", 2);
|
|
397
|
+
n([
|
|
398
|
+
r({ type: Boolean, attribute: "readonly" })
|
|
399
|
+
], i.prototype, "readOnly", 2);
|
|
400
|
+
n([
|
|
401
|
+
r({ type: String, attribute: "prev-month-icon" })
|
|
402
|
+
], i.prototype, "prevMonthIcon", 2);
|
|
403
|
+
n([
|
|
404
|
+
r({ type: String, attribute: "next-month-icon" })
|
|
405
|
+
], i.prototype, "nextMonthIcon", 2);
|
|
406
|
+
n([
|
|
407
|
+
r({ type: String, attribute: "prev-month-aria-label" })
|
|
408
|
+
], i.prototype, "prevMonthAriaLabel", 2);
|
|
409
|
+
n([
|
|
410
|
+
r({ type: String, attribute: "next-month-aria-label" })
|
|
411
|
+
], i.prototype, "nextMonthAriaLabel", 2);
|
|
412
|
+
n([
|
|
413
|
+
r({ type: String, attribute: "select-year-aria-label" })
|
|
414
|
+
], i.prototype, "selectYearAriaLabel", 2);
|
|
415
|
+
n([
|
|
416
|
+
r({ type: String, attribute: "year-grid-aria-label" })
|
|
417
|
+
], i.prototype, "yearGridAriaLabel", 2);
|
|
418
|
+
n([
|
|
419
|
+
r({ type: String })
|
|
420
|
+
], i.prototype, "dayFormat", 2);
|
|
421
|
+
n([
|
|
422
|
+
r({ type: String })
|
|
423
|
+
], i.prototype, "weekdayFormat", 2);
|
|
424
|
+
n([
|
|
425
|
+
r({ type: String })
|
|
426
|
+
], i.prototype, "monthFormat", 2);
|
|
427
|
+
n([
|
|
428
|
+
r({ type: String })
|
|
429
|
+
], i.prototype, "minDate", 2);
|
|
430
|
+
n([
|
|
431
|
+
r({ type: String })
|
|
432
|
+
], i.prototype, "maxDate", 2);
|
|
433
|
+
n([
|
|
434
|
+
r({ type: Array })
|
|
435
|
+
], i.prototype, "disabledRanges", 2);
|
|
436
|
+
n([
|
|
437
|
+
r({ type: Number })
|
|
438
|
+
], i.prototype, "numberOfMonths", 2);
|
|
439
|
+
n([
|
|
440
|
+
r({ type: Array })
|
|
441
|
+
], i.prototype, "value", 2);
|
|
442
|
+
n([
|
|
443
|
+
r({ type: String })
|
|
444
|
+
], i.prototype, "focusDate", 2);
|
|
445
|
+
n([
|
|
446
|
+
r({ type: Boolean })
|
|
447
|
+
], i.prototype, "hidePills", 2);
|
|
448
|
+
n([
|
|
449
|
+
r({ type: String })
|
|
450
|
+
], i.prototype, "removePillAriaLabel", 2);
|
|
451
|
+
n([
|
|
452
|
+
r({ type: String, attribute: "disabled-date-range-message" })
|
|
453
|
+
], i.prototype, "disabledDateRangeMessage", 2);
|
|
454
|
+
n([
|
|
455
|
+
r({ attribute: !1 })
|
|
456
|
+
], i.prototype, "invalidRange", 2);
|
|
457
|
+
n([
|
|
458
|
+
v()
|
|
459
|
+
], i.prototype, "_selection", 2);
|
|
460
|
+
n([
|
|
461
|
+
v()
|
|
462
|
+
], i.prototype, "_invalidRange", 2);
|
|
463
|
+
i = n([
|
|
464
|
+
y("gui-range-calendar")
|
|
465
|
+
], i);
|
|
466
|
+
typeof customElements < "u" && !customElements.get("gui-range-calendar") && customElements.define("gui-range-calendar", i);
|