@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
package/date-input-DCdGWRio.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { LitElement as y, nothing as u, html as d } from "lit";
|
|
2
|
-
import { repeat as g } from "lit-html/directives/repeat.js";
|
|
3
|
-
import { property as l, state as p, customElement as m } from "lit/decorators.js";
|
|
4
|
-
import { classMap as _ } from "lit/directives/class-map.js";
|
|
5
|
-
import { live as f } from "lit/directives/live.js";
|
|
6
|
-
import { G as v, b as S, c as A } from "./templates-Dk1jxLwS.js";
|
|
7
|
-
import { p as b, t as w } from "./date-CDUlLuYy.js";
|
|
8
|
-
var I = Object.defineProperty, D = Object.getOwnPropertyDescriptor, h = (t, e, a, i) => {
|
|
9
|
-
for (var r = i > 1 ? void 0 : i ? D(e, a) : e, n = t.length - 1, s; n >= 0; n--)
|
|
10
|
-
(s = t[n]) && (r = (i ? s(e, a, r) : s(r)) || r);
|
|
11
|
-
return i && r && I(e, a, r), r;
|
|
12
|
-
};
|
|
13
|
-
let o = class extends y {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = void 0, this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.icon = "", this.hint = void 0, this._day = "", this._month = "", this._year = "", this.MIN_DAY = 1, this.MAX_DAY = 31, this.MAX_VALID_DAY = (t, e) => t === 2 ? new Date(e, 1, 29).getDate() === 29 || !e ? 29 : 28 : t === 4 || t === 6 || t === 9 || t === 11 ? 30 : 31, this.MIN_MONTH = 1, this.MAX_MONTH = 12, this.MIN_YEAR = 1e3, this.MAX_YEAR = 9999, this.ariaController = new v(this, {
|
|
16
|
-
getTargets: () => this.querySelectorAll(".gui-date-input"),
|
|
17
|
-
getState: () => ({
|
|
18
|
-
uid: this.uid,
|
|
19
|
-
templateData: {
|
|
20
|
-
hint: this.hint,
|
|
21
|
-
errors: this.errors,
|
|
22
|
-
readonly: this.readOnly,
|
|
23
|
-
disabled: this.disabled,
|
|
24
|
-
touched: this.touched
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
createRenderRoot() {
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
connectedCallback() {
|
|
33
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
34
|
-
}
|
|
35
|
-
willUpdate(t) {
|
|
36
|
-
t.has("value") && this.parseValue(this.value ?? "");
|
|
37
|
-
}
|
|
38
|
-
render() {
|
|
39
|
-
const t = {
|
|
40
|
-
uid: this.uid,
|
|
41
|
-
label: this.label,
|
|
42
|
-
errors: this.errors,
|
|
43
|
-
touched: this.touched,
|
|
44
|
-
required: this.required,
|
|
45
|
-
disabled: this.disabled,
|
|
46
|
-
readonly: this.readOnly,
|
|
47
|
-
value: this.value,
|
|
48
|
-
icon: this.icon,
|
|
49
|
-
hint: this.hint
|
|
50
|
-
}, e = new Intl.DateTimeFormat(this.localeId ?? "en", {
|
|
51
|
-
year: "numeric",
|
|
52
|
-
month: "numeric",
|
|
53
|
-
day: "numeric"
|
|
54
|
-
}).formatToParts(/* @__PURE__ */ new Date()), a = {
|
|
55
|
-
"gui-widget-icon": !0,
|
|
56
|
-
[this.icon]: !0
|
|
57
|
-
};
|
|
58
|
-
return d`
|
|
59
|
-
${this.label ? S(this.uid, t) : u}
|
|
60
|
-
|
|
61
|
-
<div class="gui-widget">
|
|
62
|
-
<div
|
|
63
|
-
class="gui-widget-input gui-date-input ${this.icon ? "gui-calendar--icon" : ""}"
|
|
64
|
-
role="group"
|
|
65
|
-
>
|
|
66
|
-
${g(
|
|
67
|
-
e,
|
|
68
|
-
(i) => i.type,
|
|
69
|
-
(i, r) => {
|
|
70
|
-
const n = r === 0 ? 0 : -1;
|
|
71
|
-
switch (i.type) {
|
|
72
|
-
case "day":
|
|
73
|
-
return this.renderInput("day", "dd", 2, n, this._day);
|
|
74
|
-
case "month":
|
|
75
|
-
return this.renderInput("month", "mm", 2, n, this._month);
|
|
76
|
-
case "year":
|
|
77
|
-
return this.renderInput("year", "yyyy", 4, n, this._year);
|
|
78
|
-
case "literal":
|
|
79
|
-
return d`<span class="gui-date-input__separator">${i.value}</span>`;
|
|
80
|
-
default:
|
|
81
|
-
return "";
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
)}
|
|
85
|
-
</div>
|
|
86
|
-
${this.icon ? d`<span class=${_(a)} data-icon=${this.icon}></span>` : u}
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
${this.showErrors && this.errors?.length ? A(this.uid, t) : u}
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
renderInput(t, e, a, i, r) {
|
|
93
|
-
return d`
|
|
94
|
-
<div class="gui-date-input__touch-target">
|
|
95
|
-
<input
|
|
96
|
-
type="text"
|
|
97
|
-
inputmode="numeric"
|
|
98
|
-
class="gui-date-input__part ${t === "year" ? "gui-date-input__year" : ""}"
|
|
99
|
-
data-type=${t}
|
|
100
|
-
maxlength=${a}
|
|
101
|
-
placeholder=${e}
|
|
102
|
-
tabindex=${i}
|
|
103
|
-
?required=${this.required}
|
|
104
|
-
?disabled=${this.disabled}
|
|
105
|
-
?readonly=${this.readOnly}
|
|
106
|
-
autocomplete="off"
|
|
107
|
-
.value=${f(r)}
|
|
108
|
-
@keydown=${this.handleKeyDown}
|
|
109
|
-
@keyup=${(n) => this.handleKeyUp(n, t)}
|
|
110
|
-
@focus=${this.handleFocus}
|
|
111
|
-
@blur=${(n) => this.handleBlur(n, t)}
|
|
112
|
-
@change=${(n) => this.handleChange(n, t)}
|
|
113
|
-
/>
|
|
114
|
-
<div class="gui-date-input__visual-underline"></div>
|
|
115
|
-
</div>
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
118
|
-
parseValue(t) {
|
|
119
|
-
if (!t) {
|
|
120
|
-
this._day = "", this._month = "", this._year = "";
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const e = b(t);
|
|
124
|
-
isNaN(e.getTime()) || (this._day = e.getDate().toString().padStart(2, "0"), this._month = (e.getMonth() + 1).toString().padStart(2, "0"), this._year = e.getFullYear().toString());
|
|
125
|
-
}
|
|
126
|
-
handleKeyDown(t) {
|
|
127
|
-
[
|
|
128
|
-
"Backspace",
|
|
129
|
-
"Tab",
|
|
130
|
-
"ArrowUp",
|
|
131
|
-
"ArrowDown",
|
|
132
|
-
"ArrowLeft",
|
|
133
|
-
"ArrowRight",
|
|
134
|
-
"Delete",
|
|
135
|
-
"Enter"
|
|
136
|
-
].includes(t.key) || t.ctrlKey || t.metaKey || this.readOnly || /^[0-9]$/.test(t.key) || t.preventDefault();
|
|
137
|
-
}
|
|
138
|
-
handleFocus(t) {
|
|
139
|
-
this.dispatchEvent(new CustomEvent("focus", { detail: t }));
|
|
140
|
-
}
|
|
141
|
-
handleKeyUp(t, e) {
|
|
142
|
-
if (this.readOnly) return;
|
|
143
|
-
const a = window.getComputedStyle(this).direction === "rtl", i = t.target, r = Array.from(this.querySelectorAll("input")), n = r.indexOf(i);
|
|
144
|
-
switch (i.value.length === i.maxLength && /^[0-9]$/.test(t.key) && (n === r.length - 1 ? r[0].focus() : r[n + 1].focus()), t.key) {
|
|
145
|
-
case "ArrowUp": {
|
|
146
|
-
const s = isNaN(parseInt(i.value, 10) + 1) ? 1 : parseInt(i.value, 10) + 1;
|
|
147
|
-
e === "year" && (this._year = s.toString().padStart(4, "0")), e === "month" && (this._month = s.toString().padStart(2, "0")), e === "day" && (this._day = s.toString().padStart(2, "0")), i.select(), this.validateAndEmit();
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
case "ArrowDown": {
|
|
151
|
-
const s = isNaN(parseInt(i.value, 10) - 1) ? 1 : parseInt(i.value, 10) - 1;
|
|
152
|
-
e === "year" && (this._year = s.toString().padStart(4, "0")), e === "month" && (this._month = s.toString().padStart(2, "0")), e === "day" && (this._day = s.toString().padStart(2, "0")), i.select(), this.validateAndEmit();
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
case "ArrowLeft": {
|
|
156
|
-
const s = a ? n + 1 : n - 1;
|
|
157
|
-
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
case "ArrowRight": {
|
|
161
|
-
const s = a ? n - 1 : n + 1;
|
|
162
|
-
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
handleChange(t, e) {
|
|
168
|
-
if (t.stopImmediatePropagation(), this.readOnly) return;
|
|
169
|
-
const i = t.target.value.replace(/[^0-9]/g, "");
|
|
170
|
-
switch (e) {
|
|
171
|
-
case "day":
|
|
172
|
-
this._day = i;
|
|
173
|
-
break;
|
|
174
|
-
case "month":
|
|
175
|
-
this._month = i;
|
|
176
|
-
break;
|
|
177
|
-
case "year":
|
|
178
|
-
this._year = i;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
this.validateAndEmit();
|
|
182
|
-
}
|
|
183
|
-
handleBlur(t, e) {
|
|
184
|
-
const a = t.target, i = parseInt(a.value, 10);
|
|
185
|
-
if (!isNaN(i) && i > 0) {
|
|
186
|
-
const r = e === "year" ? 4 : 2;
|
|
187
|
-
a.value = i.toString().padStart(r, "0");
|
|
188
|
-
} else
|
|
189
|
-
this.dispatchEvent(new CustomEvent("change", { detail: { value: null } }));
|
|
190
|
-
this.dispatchEvent(new CustomEvent("blur"));
|
|
191
|
-
}
|
|
192
|
-
validateAndEmit() {
|
|
193
|
-
let t = parseInt(this._year, 10), e = parseInt(this._month, 10), a = parseInt(this._day, 10);
|
|
194
|
-
t > this.MAX_YEAR && (t = this.MAX_YEAR, this._year = t.toString().padStart(4, "0")), t < this.MIN_YEAR && (t = this.MIN_YEAR, this._year = t.toString().padStart(4, "0")), e > this.MAX_MONTH && (e = this.MAX_MONTH, this._month = e.toString().padStart(2, "0")), e < this.MIN_MONTH && (e = this.MIN_MONTH, this._month = e.toString().padStart(2, "0")), a > this.MAX_DAY && (a = this.MAX_DAY, this._day = a.toString().padStart(2, "0")), a < this.MIN_DAY && (a = this.MIN_DAY, this._day = a.toString().padStart(2, "0"));
|
|
195
|
-
const i = !isNaN(t) && String(t).length === 4, r = !isNaN(e) && e > 0;
|
|
196
|
-
if (!isNaN(a) && a > 0 && r && i) {
|
|
197
|
-
const s = this.MAX_VALID_DAY(e, t);
|
|
198
|
-
if (a > s)
|
|
199
|
-
this.dispatchEvent(
|
|
200
|
-
new CustomEvent("inputError", {
|
|
201
|
-
detail: {
|
|
202
|
-
message: "Invalid date: day is greater than the maximum valid day for the month and year."
|
|
203
|
-
},
|
|
204
|
-
bubbles: !0
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
else {
|
|
208
|
-
const c = new Date(t, e - 1, a);
|
|
209
|
-
this.value = w(c), this.dispatchEvent(
|
|
210
|
-
new CustomEvent("change", {
|
|
211
|
-
detail: { value: this.value },
|
|
212
|
-
bubbles: !0
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this.requestUpdate();
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
h([
|
|
221
|
-
l({ type: String })
|
|
222
|
-
], o.prototype, "uid", 2);
|
|
223
|
-
h([
|
|
224
|
-
l({ type: String })
|
|
225
|
-
], o.prototype, "label", 2);
|
|
226
|
-
h([
|
|
227
|
-
l({ type: String, attribute: "locale-id" })
|
|
228
|
-
], o.prototype, "localeId", 2);
|
|
229
|
-
h([
|
|
230
|
-
l({ type: Array })
|
|
231
|
-
], o.prototype, "errors", 2);
|
|
232
|
-
h([
|
|
233
|
-
l({ type: Boolean })
|
|
234
|
-
], o.prototype, "showErrors", 2);
|
|
235
|
-
h([
|
|
236
|
-
l({ type: Boolean })
|
|
237
|
-
], o.prototype, "touched", 2);
|
|
238
|
-
h([
|
|
239
|
-
l({ type: Boolean })
|
|
240
|
-
], o.prototype, "required", 2);
|
|
241
|
-
h([
|
|
242
|
-
l({ type: Boolean })
|
|
243
|
-
], o.prototype, "disabled", 2);
|
|
244
|
-
h([
|
|
245
|
-
l({ type: Boolean, attribute: "readonly" })
|
|
246
|
-
], o.prototype, "readOnly", 2);
|
|
247
|
-
h([
|
|
248
|
-
l({ type: String })
|
|
249
|
-
], o.prototype, "value", 2);
|
|
250
|
-
h([
|
|
251
|
-
l({ type: String })
|
|
252
|
-
], o.prototype, "icon", 2);
|
|
253
|
-
h([
|
|
254
|
-
l({ type: String })
|
|
255
|
-
], o.prototype, "hint", 2);
|
|
256
|
-
h([
|
|
257
|
-
p()
|
|
258
|
-
], o.prototype, "_day", 2);
|
|
259
|
-
h([
|
|
260
|
-
p()
|
|
261
|
-
], o.prototype, "_month", 2);
|
|
262
|
-
h([
|
|
263
|
-
p()
|
|
264
|
-
], o.prototype, "_year", 2);
|
|
265
|
-
o = h([
|
|
266
|
-
m("gui-date")
|
|
267
|
-
], o);
|
|
268
|
-
typeof customElements < "u" && !customElements.get("gui-date") && customElements.define("gui-date", o);
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { InputWidgetAdapter as h, formContext as u, inputContext as c } from "@golemui/lit";
|
|
2
|
-
import { a as m, b as g, c as C } from "./templates-Dk1jxLwS.js";
|
|
3
|
-
import "./date-input-DCdGWRio.js";
|
|
4
|
-
import "./calendar-BclCC9VJ.js";
|
|
5
|
-
import { consume as D, provide as $ } from "@lit/context";
|
|
6
|
-
import { LitElement as f, html as p, nothing as v } from "lit";
|
|
7
|
-
import { property as b, query as o, state as y, customElement as I } from "lit/decorators.js";
|
|
8
|
-
import "rxjs";
|
|
9
|
-
import { classMap as O } from "lit/directives/class-map.js";
|
|
10
|
-
var w = Object.defineProperty, x = Object.getOwnPropertyDescriptor, n = (e, t, a, i) => {
|
|
11
|
-
for (var r = i > 1 ? void 0 : i ? x(t, a) : t, d = e.length - 1, l; d >= 0; d--)
|
|
12
|
-
(l = e[d]) && (r = (i ? l(t, a, r) : l(r)) || r);
|
|
13
|
-
return i && r && w(t, a, r), r;
|
|
14
|
-
};
|
|
15
|
-
let s = class extends f {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments), this.adapter = new h(), this.isCalendarOpen = !1, this.subscriptions = [], this.onFocusOut = (e) => {
|
|
18
|
-
if (!this.isCalendarOpen) return;
|
|
19
|
-
const t = e.relatedTarget;
|
|
20
|
-
t && this.contains(t) || this.closeCalendar();
|
|
21
|
-
}, this.onDocumentClick = (e) => {
|
|
22
|
-
if (!this.isCalendarOpen) return;
|
|
23
|
-
const t = e.composedPath(), a = this.dateInput && t.includes(this.dateInput), i = this.calendarInput && t.includes(this.calendarInput);
|
|
24
|
-
!a && !i && this.closeCalendar();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
createRenderRoot() {
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
updated(e) {
|
|
31
|
-
super.updated(e);
|
|
32
|
-
const t = this.adapter.templateData.size;
|
|
33
|
-
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
34
|
-
}
|
|
35
|
-
connectedCallback() {
|
|
36
|
-
super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.addEventListener("focusout", this.onFocusOut), this.classList.add("gui-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
37
|
-
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
render() {
|
|
41
|
-
super.render();
|
|
42
|
-
const e = m("datePicker", this.adapter.templateData), t = this.isCalendarOpen ? p`<gui-calendar
|
|
43
|
-
id="calendar-input"
|
|
44
|
-
.uid=${this.widget.uid}
|
|
45
|
-
.hint=${this.adapter.templateData.hint}
|
|
46
|
-
?touched=${this.adapter.templateData.touched}
|
|
47
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
48
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
49
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
50
|
-
.value=${this.adapter.templateData.value}
|
|
51
|
-
.prevMonthIcon=${this.adapter.templateData.prevMonthIcon}
|
|
52
|
-
.nextMonthIcon=${this.adapter.templateData.nextMonthIcon}
|
|
53
|
-
.prevMonthAriaLabel=${this.adapter.templateData.prevMonthAriaLabel}
|
|
54
|
-
.nextMonthAriaLabel=${this.adapter.templateData.nextMonthAriaLabel}
|
|
55
|
-
.dayFormat=${this.adapter.templateData.dayFormat}
|
|
56
|
-
.weekdayFormat=${this.adapter.templateData.weekdayFormat}
|
|
57
|
-
.monthFormat=${this.adapter.templateData.monthFormat}
|
|
58
|
-
.minDate=${this.adapter.templateData.minDate}
|
|
59
|
-
.maxDate=${this.adapter.templateData.maxDate}
|
|
60
|
-
.disabledRanges=${this.adapter.templateData.disabledRanges}
|
|
61
|
-
.numberOfMonths=${this.adapter.templateData.numberOfMonths}
|
|
62
|
-
.localeId=${this.adapter.templateData.lang}
|
|
63
|
-
@blur=${this.onBlurCalendar}
|
|
64
|
-
@change=${this.onCalendarChange}
|
|
65
|
-
></gui-calendar>` : v;
|
|
66
|
-
return p`
|
|
67
|
-
${g(this.widget.uid, {
|
|
68
|
-
...this.adapter.templateData,
|
|
69
|
-
required: this.adapter.templateData.validator?.required
|
|
70
|
-
})}
|
|
71
|
-
|
|
72
|
-
<div
|
|
73
|
-
role="button"
|
|
74
|
-
tabindex="-1"
|
|
75
|
-
class="gui-widget"
|
|
76
|
-
aria-expanded=${this.isCalendarOpen}
|
|
77
|
-
@keyup=${(a) => this.onKeyUp(a)}
|
|
78
|
-
@click=${(a) => this.toggleCalendar(a)}
|
|
79
|
-
>
|
|
80
|
-
<gui-date
|
|
81
|
-
id="date-input"
|
|
82
|
-
class=${O(e.widgetClasses)}
|
|
83
|
-
.uid=${this.widget.uid}
|
|
84
|
-
.hint=${this.adapter.templateData.hint}
|
|
85
|
-
.showErrors=${!1}
|
|
86
|
-
.errors=${this.adapter.templateData.errors}
|
|
87
|
-
?touched=${this.adapter.templateData.touched}
|
|
88
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
89
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
90
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
91
|
-
.value=${this.adapter.templateData.value}
|
|
92
|
-
.icon=${this.adapter.templateData.icon}
|
|
93
|
-
.localeId=${this.adapter.templateData.lang}
|
|
94
|
-
@inputError=${this.onInputError}
|
|
95
|
-
@blur=${() => this.adapter.onBlur()}
|
|
96
|
-
@focus=${this.openCalendar}
|
|
97
|
-
@change=${this.valueChanged}
|
|
98
|
-
></gui-date>
|
|
99
|
-
<span class="gui-date-picker__arrow"
|
|
100
|
-
><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
|
|
101
|
-
<path
|
|
102
|
-
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"
|
|
103
|
-
></path></svg
|
|
104
|
-
></span>
|
|
105
|
-
|
|
106
|
-
${t}
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
${C(this.widget.uid, this.adapter.templateData)}
|
|
110
|
-
`;
|
|
111
|
-
}
|
|
112
|
-
valueChanged(e) {
|
|
113
|
-
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
|
|
114
|
-
}
|
|
115
|
-
// Selecting a day in the calendar commits a single date, so close the
|
|
116
|
-
// calendar afterwards. The range picker intentionally stays open so the user
|
|
117
|
-
// can select multiple ranges and closes it themselves.
|
|
118
|
-
onCalendarChange(e) {
|
|
119
|
-
this.valueChanged(e), this.closeCalendar();
|
|
120
|
-
}
|
|
121
|
-
onBlurCalendar() {
|
|
122
|
-
this.adapter.onBlur(), this.closeCalendar();
|
|
123
|
-
}
|
|
124
|
-
onInputError(e) {
|
|
125
|
-
this.adapter.injectValidationIssues([e.detail.message]);
|
|
126
|
-
}
|
|
127
|
-
onKeyUp(e) {
|
|
128
|
-
const t = e;
|
|
129
|
-
t.target === t.currentTarget && (t?.key === "Enter" || t?.key === " ") && (this.isCalendarOpen = !this.isCalendarOpen, this.requestUpdate());
|
|
130
|
-
}
|
|
131
|
-
toggleCalendar(e) {
|
|
132
|
-
const t = e.target;
|
|
133
|
-
if (t.closest(".gui-calendar__day-button")) return;
|
|
134
|
-
const a = t.closest(".gui-date-input__part"), i = t.closest("gui-calendar");
|
|
135
|
-
a || i ? this.openCalendar() : (this.isCalendarOpen = !this.isCalendarOpen, this.requestUpdate());
|
|
136
|
-
}
|
|
137
|
-
openCalendar() {
|
|
138
|
-
this.isCalendarOpen || (this.isCalendarOpen = !0, this.requestUpdate());
|
|
139
|
-
}
|
|
140
|
-
closeCalendar() {
|
|
141
|
-
this.isCalendarOpen = !1, this.requestUpdate();
|
|
142
|
-
}
|
|
143
|
-
disconnectedCallback() {
|
|
144
|
-
super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.removeEventListener("focusout", this.onFocusOut), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
n([
|
|
148
|
-
D({ context: u }),
|
|
149
|
-
b({ attribute: !1 })
|
|
150
|
-
], s.prototype, "formContext", 2);
|
|
151
|
-
n([
|
|
152
|
-
$({ context: c })
|
|
153
|
-
], s.prototype, "adapter", 2);
|
|
154
|
-
n([
|
|
155
|
-
o("#date-input")
|
|
156
|
-
], s.prototype, "dateInput", 2);
|
|
157
|
-
n([
|
|
158
|
-
o("#calendar-input")
|
|
159
|
-
], s.prototype, "calendarInput", 2);
|
|
160
|
-
n([
|
|
161
|
-
y()
|
|
162
|
-
], s.prototype, "isCalendarOpen", 2);
|
|
163
|
-
s = n([
|
|
164
|
-
I("gui-date-picker-input")
|
|
165
|
-
], s);
|
|
166
|
-
export {
|
|
167
|
-
s as DatePickerElement
|
|
168
|
-
};
|