@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
package/date-input-BeQvyfln.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 A, c as S } from "./templates-Dk1jxLwS.js";
|
|
7
|
-
import { t as w } from "./date-DTYg8sog.js";
|
|
8
|
-
var b = Object.defineProperty, I = Object.getOwnPropertyDescriptor, h = (t, e, a, i) => {
|
|
9
|
-
for (var r = i > 1 ? void 0 : i ? I(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 && b(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 ? A(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 ? S(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 = new Date(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,166 +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-BeQvyfln.js";
|
|
4
|
-
import "./calendar-DTYKVYc3.js";
|
|
5
|
-
import { consume as D, provide as $ } from "@lit/context";
|
|
6
|
-
import { LitElement as v, html as p, nothing as f } 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 v {
|
|
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>` : f;
|
|
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, a = t.closest(".gui-date-input__part"), i = t.closest("gui-calendar");
|
|
133
|
-
a || i ? this.openCalendar() : (this.isCalendarOpen = !this.isCalendarOpen, this.requestUpdate());
|
|
134
|
-
}
|
|
135
|
-
openCalendar() {
|
|
136
|
-
this.isCalendarOpen || (this.isCalendarOpen = !0, this.requestUpdate());
|
|
137
|
-
}
|
|
138
|
-
closeCalendar() {
|
|
139
|
-
this.isCalendarOpen = !1, this.requestUpdate();
|
|
140
|
-
}
|
|
141
|
-
disconnectedCallback() {
|
|
142
|
-
super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.removeEventListener("focusout", this.onFocusOut), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
n([
|
|
146
|
-
D({ context: u }),
|
|
147
|
-
b({ attribute: !1 })
|
|
148
|
-
], s.prototype, "formContext", 2);
|
|
149
|
-
n([
|
|
150
|
-
$({ context: c })
|
|
151
|
-
], s.prototype, "adapter", 2);
|
|
152
|
-
n([
|
|
153
|
-
o("#date-input")
|
|
154
|
-
], s.prototype, "dateInput", 2);
|
|
155
|
-
n([
|
|
156
|
-
o("#calendar-input")
|
|
157
|
-
], s.prototype, "calendarInput", 2);
|
|
158
|
-
n([
|
|
159
|
-
y()
|
|
160
|
-
], s.prototype, "isCalendarOpen", 2);
|
|
161
|
-
s = n([
|
|
162
|
-
I("gui-date-picker-input")
|
|
163
|
-
], s);
|
|
164
|
-
export {
|
|
165
|
-
s as DatePickerElement
|
|
166
|
-
};
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { html as v, nothing as b } from "lit";
|
|
2
|
-
import { property as D, state as f, customElement as $ } from "lit/decorators.js";
|
|
3
|
-
import { classMap as w } from "lit/directives/class-map.js";
|
|
4
|
-
import { i as g, a as S, b as m, g as M, m as O, c as p } from "./date-DTYg8sog.js";
|
|
5
|
-
import { A } from "./abstract-calendar-BoqKPRmS.js";
|
|
6
|
-
import "./pills-B66qz_KX.js";
|
|
7
|
-
var E = Object.defineProperty, P = Object.getOwnPropertyDescriptor, u = (e, i, s, n) => {
|
|
8
|
-
for (var a = n > 1 ? void 0 : n ? P(i, s) : i, t = e.length - 1, r; t >= 0; t--)
|
|
9
|
-
(r = e[t]) && (a = (n ? r(i, s, a) : r(a)) || a);
|
|
10
|
-
return n && a && E(i, s, a), a;
|
|
11
|
-
};
|
|
12
|
-
let c = class extends A {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments), this.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this._anchorDate = null, this._nextDate = null, this._isSelecting = !1, this._skipValueNavigation = !1, this.onPillRemoveEvent = (e) => {
|
|
15
|
-
if (this.disabled || this.readOnly) return;
|
|
16
|
-
const s = this.getSortedPills().find(
|
|
17
|
-
(a) => `${a.start}-${a.end ?? a.start}` === e.detail.key
|
|
18
|
-
);
|
|
19
|
-
if (!s) return;
|
|
20
|
-
const n = (this.value ?? []).filter(
|
|
21
|
-
(a) => !(a.start === s.start && (a.end ?? null) === (s.end ?? null))
|
|
22
|
-
);
|
|
23
|
-
this.value = n, this.dispatchEvent(
|
|
24
|
-
new CustomEvent("change", {
|
|
25
|
-
detail: { value: this.value },
|
|
26
|
-
bubbles: !0,
|
|
27
|
-
composed: !0
|
|
28
|
-
})
|
|
29
|
-
);
|
|
30
|
-
}, this.onPillClickEvent = (e) => {
|
|
31
|
-
const s = this.getSortedPills().find((n) => `${n.start}-${n.end ?? n.start}` === e.detail.key);
|
|
32
|
-
s && this.navigateToDate(s.start);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
createRenderRoot() {
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
connectedCallback() {
|
|
39
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
40
|
-
}
|
|
41
|
-
willUpdate(e) {
|
|
42
|
-
if (e.has("value") && !e.has("focusDate")) {
|
|
43
|
-
if (this._skipValueNavigation)
|
|
44
|
-
this._skipValueNavigation = !1;
|
|
45
|
-
else if (this.value) {
|
|
46
|
-
const i = Array.isArray(this.value) ? this.value : [{ start: this.value }];
|
|
47
|
-
if (i.length > 0 && i[0].start) {
|
|
48
|
-
const s = new Date(i[0].start);
|
|
49
|
-
!isNaN(s.getTime()) && !g(s, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = s);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (e.has("focusDate") && this.focusDate) {
|
|
54
|
-
const i = new Date(this.focusDate);
|
|
55
|
-
isNaN(i.getTime()) || (g(i, this._currentDate, this.numberOfMonths ?? 1) || (this._currentDate = i), this.focusDate = void 0);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
renderDay(e) {
|
|
59
|
-
const i = {
|
|
60
|
-
"gui-calendar__day-button": !0,
|
|
61
|
-
today: e.isToday,
|
|
62
|
-
"other-month": !e.isCurrentMonth,
|
|
63
|
-
"range-start": e.isRangeStart && !e.isOneDayRange,
|
|
64
|
-
"range-end": e.isRangeEnd && !e.isOneDayRange,
|
|
65
|
-
selected: e.isOneDayRange,
|
|
66
|
-
"in-range": e.isInRange,
|
|
67
|
-
"is-anchor": e.isAnchor,
|
|
68
|
-
"is-selecting": e.isSelecting,
|
|
69
|
-
disabled: e.isDisabled
|
|
70
|
-
};
|
|
71
|
-
return v`
|
|
72
|
-
<button
|
|
73
|
-
type="button"
|
|
74
|
-
role="gridcell"
|
|
75
|
-
class=${w(i)}
|
|
76
|
-
tabindex=${e.isFocusable ? 0 : -1}
|
|
77
|
-
?disabled=${!e.isCurrentMonth || e.isDisabled}
|
|
78
|
-
data-date=${e.date.toISOString()}
|
|
79
|
-
@click=${(s) => this.selectDate(e, s)}
|
|
80
|
-
@mouseover=${() => this.onMouseOver(e)}
|
|
81
|
-
@focus=${() => this.onMouseOver(e)}
|
|
82
|
-
@keydown=${(s) => this.handleKeydown(s, e)}
|
|
83
|
-
aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
|
|
84
|
-
>
|
|
85
|
-
${e.dayLabel}
|
|
86
|
-
</button>
|
|
87
|
-
`;
|
|
88
|
-
}
|
|
89
|
-
getDaysInMonth(e) {
|
|
90
|
-
const i = new Date(this._currentDate);
|
|
91
|
-
i.setDate(1), i.setMonth(i.getMonth() + e);
|
|
92
|
-
const s = this.generateDateGrid(e), n = i.getMonth();
|
|
93
|
-
let a = s.map((t) => {
|
|
94
|
-
const r = t.getMonth() === n, l = this.isDisabled(t), o = S(t), { isRangeStart: h, isRangeEnd: d, isInRange: _, isSelecting: y } = this.checkDateStatus(t), R = o || h, T = this._anchorDate ? m(t, this._anchorDate) : !1;
|
|
95
|
-
return {
|
|
96
|
-
date: t,
|
|
97
|
-
dayLabel: M(this.localeId, t),
|
|
98
|
-
isCurrentMonth: r,
|
|
99
|
-
isToday: o,
|
|
100
|
-
isRangeStart: h,
|
|
101
|
-
isRangeEnd: d,
|
|
102
|
-
isInRange: _,
|
|
103
|
-
isDisabled: l,
|
|
104
|
-
isOneDayRange: h && d,
|
|
105
|
-
isAnchor: T,
|
|
106
|
-
isFocusable: R,
|
|
107
|
-
isSelecting: y && r
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
for (let t = 0; t < 2; t++)
|
|
111
|
-
a.slice(-7).every((l) => !l.isCurrentMonth) && (a = a.slice(0, -7));
|
|
112
|
-
if (e === 0 && !a.some((t) => t.isFocusable)) {
|
|
113
|
-
const t = this.numberOfMonths ?? 1, r = g(/* @__PURE__ */ new Date(), this._currentDate, t), l = this.value?.some(
|
|
114
|
-
(o) => g(new Date(o.start), this._currentDate, t)
|
|
115
|
-
) ?? !1;
|
|
116
|
-
if (!r && !l) {
|
|
117
|
-
const o = a.find((h) => h.isCurrentMonth && !h.isDisabled);
|
|
118
|
-
o && (o.isFocusable = !0);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return a;
|
|
122
|
-
}
|
|
123
|
-
checkDateStatus(e) {
|
|
124
|
-
let i = !1, s = !1, n = !1, a = !1;
|
|
125
|
-
if (this._isSelecting && this._nextDate && this._anchorDate) {
|
|
126
|
-
const t = this._nextDate.date, r = new Date(this._anchorDate);
|
|
127
|
-
t.getTime() > r.getTime() ? a = e.getTime() >= r.getTime() && e.getTime() <= t.getTime() : a = e.getTime() >= t.getTime() && e.getTime() <= r.getTime();
|
|
128
|
-
}
|
|
129
|
-
if (this.value && Array.isArray(this.value))
|
|
130
|
-
for (const t of this.value) {
|
|
131
|
-
const r = new Date(t.start);
|
|
132
|
-
if (m(e, r) && (i = !0, s = !t.end), t.end) {
|
|
133
|
-
const l = new Date(t.end);
|
|
134
|
-
m(e, l) && (s = !0);
|
|
135
|
-
const o = e.getTime(), h = r.getTime(), d = l.getTime();
|
|
136
|
-
o > h && o < d && (n = !0);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return { isRangeStart: i, isRangeEnd: s, isInRange: n, isSelecting: a };
|
|
140
|
-
}
|
|
141
|
-
selectDate(e, i = null) {
|
|
142
|
-
if (!e.isCurrentMonth || this.disabled || this.readOnly) return;
|
|
143
|
-
const s = e.date;
|
|
144
|
-
if (!this._anchorDate) {
|
|
145
|
-
this._isSelecting = !0, this._anchorDate = s;
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
let n = this._anchorDate, a = s;
|
|
149
|
-
s < n && (n = s, a = this._anchorDate);
|
|
150
|
-
const t = this.calculateValidRanges(n, a), r = [...this.value || [], ...t];
|
|
151
|
-
this._skipValueNavigation = !0, this.value = O(r), this._isSelecting = !1, this._nextDate = null, this._anchorDate = null, this.dispatchEvent(
|
|
152
|
-
new CustomEvent("change", {
|
|
153
|
-
detail: { value: this.value },
|
|
154
|
-
bubbles: !0,
|
|
155
|
-
composed: !0
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Calculates and returns an array of valid date ranges between the given start date and end date.
|
|
161
|
-
* A date range is considered valid if no dates within the range are disabled.
|
|
162
|
-
*
|
|
163
|
-
* @param {Date} startDate - The starting date for the range calculation.
|
|
164
|
-
* @param {Date} endDate - The ending date for the range calculation.
|
|
165
|
-
* @return {DateRange[]} An array of valid date ranges where each range defines consecutive, non-disabled dates.
|
|
166
|
-
*/
|
|
167
|
-
calculateValidRanges(e, i) {
|
|
168
|
-
const s = [], n = new Date(e), a = new Date(i);
|
|
169
|
-
n.setHours(0, 0, 0, 0), a.setHours(0, 0, 0, 0);
|
|
170
|
-
let t = null;
|
|
171
|
-
for (; n <= a; ) {
|
|
172
|
-
if (!this.isDisabled(n))
|
|
173
|
-
t || (t = new Date(n));
|
|
174
|
-
else if (t) {
|
|
175
|
-
const l = new Date(n);
|
|
176
|
-
l.setDate(n.getDate() - 1), s.push(p(t, l)), t = null;
|
|
177
|
-
}
|
|
178
|
-
n.setDate(n.getDate() + 1);
|
|
179
|
-
}
|
|
180
|
-
return t && s.push(p(t, i)), s;
|
|
181
|
-
}
|
|
182
|
-
onMouseOver(e) {
|
|
183
|
-
this._isSelecting && (this._nextDate = e);
|
|
184
|
-
}
|
|
185
|
-
// --- Pills ---
|
|
186
|
-
renderAboveCalendar() {
|
|
187
|
-
if (this.hidePills) return b;
|
|
188
|
-
const e = this.getSortedPills();
|
|
189
|
-
if (e.length === 0) return b;
|
|
190
|
-
const i = e.map((s) => {
|
|
191
|
-
const n = this.formatDateForDisplay(s.start), a = s.end ? this.formatDateForDisplay(s.end) : n, t = `${n} - ${a}`;
|
|
192
|
-
return {
|
|
193
|
-
key: `${s.start}-${s.end ?? s.start}`,
|
|
194
|
-
label: t,
|
|
195
|
-
ariaLabel: `${this.removePillAriaLabel ?? "Remove date"} ${t}`
|
|
196
|
-
};
|
|
197
|
-
});
|
|
198
|
-
return v`
|
|
199
|
-
<gui-pills
|
|
200
|
-
class="gui-range-calendar__pills"
|
|
201
|
-
.items=${i}
|
|
202
|
-
.removable=${!0}
|
|
203
|
-
.clickable=${!0}
|
|
204
|
-
.bubble=${!1}
|
|
205
|
-
?disabled=${this.disabled}
|
|
206
|
-
?readonly=${this.readOnly}
|
|
207
|
-
.removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
|
|
208
|
-
@pillremove=${this.onPillRemoveEvent}
|
|
209
|
-
@pillclick=${this.onPillClickEvent}
|
|
210
|
-
></gui-pills>
|
|
211
|
-
`;
|
|
212
|
-
}
|
|
213
|
-
formatDateForDisplay(e) {
|
|
214
|
-
const i = new Date(e);
|
|
215
|
-
return isNaN(i.getTime()) ? e : new Intl.DateTimeFormat(this.localeId ?? "en", {
|
|
216
|
-
year: "numeric",
|
|
217
|
-
month: "2-digit",
|
|
218
|
-
day: "2-digit"
|
|
219
|
-
}).format(i);
|
|
220
|
-
}
|
|
221
|
-
getSortedPills() {
|
|
222
|
-
return !this.value || !Array.isArray(this.value) ? [] : [...this.value].sort(
|
|
223
|
-
(e, i) => new Date(e.start).getTime() - new Date(i.start).getTime()
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
navigateToDate(e) {
|
|
227
|
-
const i = new Date(e);
|
|
228
|
-
!isNaN(i.getTime()) && !g(i, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = i);
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
u([
|
|
232
|
-
D({ type: Array })
|
|
233
|
-
], c.prototype, "value", 2);
|
|
234
|
-
u([
|
|
235
|
-
D({ type: String })
|
|
236
|
-
], c.prototype, "focusDate", 2);
|
|
237
|
-
u([
|
|
238
|
-
D({ type: Boolean })
|
|
239
|
-
], c.prototype, "hidePills", 2);
|
|
240
|
-
u([
|
|
241
|
-
D({ type: String })
|
|
242
|
-
], c.prototype, "removePillAriaLabel", 2);
|
|
243
|
-
u([
|
|
244
|
-
f()
|
|
245
|
-
], c.prototype, "_anchorDate", 2);
|
|
246
|
-
u([
|
|
247
|
-
f()
|
|
248
|
-
], c.prototype, "_nextDate", 2);
|
|
249
|
-
u([
|
|
250
|
-
f()
|
|
251
|
-
], c.prototype, "_isSelecting", 2);
|
|
252
|
-
c = u([
|
|
253
|
-
$("gui-range-calendar")
|
|
254
|
-
], c);
|
|
255
|
-
typeof customElements < "u" && !customElements.get("gui-range-calendar") && customElements.define("gui-range-calendar", c);
|