@golemui/gui-lit 0.12.2 → 0.13.1
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 +16 -0
- package/abstract-calendar-YDgwwbqe.js +528 -0
- package/{accordion.element-81uTv6Ms.js → accordion.element-ChLmV6QT.js} +24 -22
- package/{alert.element-DWrS5ggK.js → alert.element-9QFlqjj9.js} +23 -21
- package/button.element-ATNRRDN3.js +121 -0
- package/calendar-P9DzVryu.js +96 -0
- package/{calendar.element-C1rLK7aY.js → calendar.element-O2of7VBr.js} +25 -22
- package/checkbox.element-DMmer4Jw.js +199 -0
- package/currency.element-C7SZkoPP.js +266 -0
- package/date-CG1562vW.js +786 -0
- package/date-input-VJG8lMVN.js +266 -0
- package/{date-picker.element-GNC8f3Qi.js → date-picker.element-Bcyhc0fb.js} +29 -25
- package/{date.element-Dzw-UJzC.js → date.element-DfXmcgZi.js} +25 -22
- package/{dropdown.element-CebROj9s.js → dropdown.element-DCUI5Y7I.js} +24 -22
- package/errors-QjKhr6mA.js +109 -0
- package/{flex.element-BMqqfxjI.js → flex.element-B0sG0YT1.js} +24 -22
- package/{grid.element-CBMoOuLt.js → grid.element-Bf5aEjkj.js} +24 -22
- package/index.js +2708 -1174
- package/index.umd.cjs +982 -108
- package/lib/components/accordion.element.d.ts +7 -7
- package/lib/components/alert.element.d.ts +6 -6
- package/lib/components/button.element.d.ts +6 -6
- package/lib/components/calendar.element.d.ts +6 -6
- package/lib/components/checkbox.element.d.ts +6 -6
- package/lib/components/currency.element.d.ts +6 -6
- package/lib/components/date-picker.element.d.ts +6 -6
- package/lib/components/date.element.d.ts +6 -6
- package/lib/components/dropdown.element.d.ts +6 -6
- package/lib/components/flex.element.d.ts +6 -6
- package/lib/components/grid.element.d.ts +6 -6
- package/lib/components/list.element.d.ts +6 -6
- package/lib/components/markdown-text.element.d.ts +6 -6
- package/lib/components/markdown.element.d.ts +6 -6
- package/lib/components/number.element.d.ts +6 -6
- package/lib/components/password.element.d.ts +6 -6
- package/lib/components/radiogroup.element.d.ts +6 -6
- package/lib/components/range-calendar.element.d.ts +6 -6
- package/lib/components/range-date-input.element.d.ts +6 -6
- package/lib/components/range-date-picker.element.d.ts +6 -6
- package/lib/components/renderer.element.d.ts +6 -6
- package/lib/components/repeater.element.d.ts +6 -6
- package/lib/components/select.element.d.ts +6 -6
- package/lib/components/tabs.element.d.ts +6 -6
- package/lib/components/textarea.element.d.ts +6 -6
- package/lib/components/textinput.element.d.ts +6 -6
- package/lib/components/toggle.element.d.ts +6 -6
- package/lib/widget.loaders.d.ts +2 -2
- package/list-CtFsv7GB.js +284 -0
- package/{list.element-DIIgN_Ww.js → list.element-G8RNRZXU.js} +30 -27
- package/markdown-text-X-BRJT6K.js +30 -0
- package/{markdown-text.element-DY7b-dU5.js → markdown-text.element-C_1OqrGa.js} +23 -20
- package/markdown.element-CT1JOOM3.js +596 -0
- package/number.element-HaXEg_7U.js +282 -0
- package/one-of-DifUsEYY.js +48 -0
- package/package.json +6 -6
- package/password.element-B4-0SCe4.js +238 -0
- package/radiogroup.element-DzHLgRh1.js +232 -0
- package/range-calendar-qpakwAba.js +326 -0
- package/{range-calendar.element-Bli9UfhN.js → range-calendar.element-C-4qqRGK.js} +20 -17
- package/range-date-input-CrNpOVHt.js +507 -0
- package/{range-date-input.element-BwPvGk5F.js → range-date-input.element-Iq5Y7uLQ.js} +20 -17
- package/{range-date-picker.element-DJQOwDPh.js → range-date-picker.element-4bg4Uraq.js} +29 -25
- package/{renderer.element-B99qD2mz.js → renderer.element-DMsheQGi.js} +19 -17
- package/{repeater.element-AaifWsOB.js → repeater.element-Ry8HyMfW.js} +41 -27
- package/select.element-DuGZjlZY.js +257 -0
- package/tabs-DzSCq_98.js +13 -0
- package/{tabs.element-k8JMNDXi.js → tabs.element-VLrtF1j5.js} +31 -29
- package/templates-Dk1jxLwS.js +75 -0
- package/textarea.element-C8yx2u0o.js +237 -0
- package/textinput.element-DKuplF1A.js +204 -0
- package/toggle.element-NXRrhALB.js +201 -0
- package/button.element-hjhVBamJ.js +0 -56
- package/checkbox.element-bu9_MvED.js +0 -65
- package/currency.element-Bxv2WxAx.js +0 -72
- package/default-list-item-renderer-DNVEjKSX.js +0 -23
- package/markdown.element-ZD_n4ObO.js +0 -73
- package/number.element-B0E7W2TK.js +0 -70
- package/password.element-C4_eLdUO.js +0 -71
- package/radiogroup.element-BD8qBNoO.js +0 -68
- package/select.element-BLxtqB0A.js +0 -74
- package/textarea.element-DgDwfzYP.js +0 -70
- package/textinput.element-DSLFDjfb.js +0 -67
- package/toggle.element-BLu6F99u.js +0 -65
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { LitElement as y, nothing as u, html as d } from "lit";
|
|
2
|
+
import { property as l, state as p, customElement as g } from "lit/decorators.js";
|
|
3
|
+
import { live as m } from "lit/directives/live.js";
|
|
4
|
+
import { repeat as _ } from "lit-html/directives/repeat.js";
|
|
5
|
+
import { classMap as f } from "lit/directives/class-map.js";
|
|
6
|
+
import { G as v, b as A, c as S } from "./templates-Dk1jxLwS.js";
|
|
7
|
+
import { t as b } from "./date-CG1562vW.js";
|
|
8
|
+
import "@golemui/gui-shared";
|
|
9
|
+
var w = Object.defineProperty, I = Object.getOwnPropertyDescriptor, h = (t, e, a, i) => {
|
|
10
|
+
for (var r = i > 1 ? void 0 : i ? I(e, a) : e, n = t.length - 1, s; n >= 0; n--)
|
|
11
|
+
(s = t[n]) && (r = (i ? s(e, a, r) : s(r)) || r);
|
|
12
|
+
return i && r && w(e, a, r), r;
|
|
13
|
+
};
|
|
14
|
+
let o = class extends y {
|
|
15
|
+
constructor() {
|
|
16
|
+
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, {
|
|
17
|
+
getTargets: () => this.querySelectorAll(".gui-date-input"),
|
|
18
|
+
getState: () => ({
|
|
19
|
+
uid: this.uid,
|
|
20
|
+
templateData: {
|
|
21
|
+
hint: this.hint,
|
|
22
|
+
errors: this.errors,
|
|
23
|
+
readonly: this.readOnly,
|
|
24
|
+
disabled: this.disabled,
|
|
25
|
+
touched: this.touched
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
createRenderRoot() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
35
|
+
}
|
|
36
|
+
willUpdate(t) {
|
|
37
|
+
t.has("value") && this.parseValue(this.value ?? "");
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const t = {
|
|
41
|
+
uid: this.uid,
|
|
42
|
+
label: this.label,
|
|
43
|
+
errors: this.errors,
|
|
44
|
+
touched: this.touched,
|
|
45
|
+
required: this.required,
|
|
46
|
+
disabled: this.disabled,
|
|
47
|
+
readonly: this.readOnly,
|
|
48
|
+
value: this.value,
|
|
49
|
+
icon: this.icon,
|
|
50
|
+
hint: this.hint
|
|
51
|
+
}, e = new Intl.DateTimeFormat(this.localeId ?? "en", {
|
|
52
|
+
year: "numeric",
|
|
53
|
+
month: "numeric",
|
|
54
|
+
day: "numeric"
|
|
55
|
+
}).formatToParts(/* @__PURE__ */ new Date()), a = {
|
|
56
|
+
"gui-widget-icon": !0,
|
|
57
|
+
[this.icon]: !0
|
|
58
|
+
};
|
|
59
|
+
return d`
|
|
60
|
+
${this.label ? A(this.uid, t) : u}
|
|
61
|
+
|
|
62
|
+
<div class="gui-widget">
|
|
63
|
+
<div class="gui-date-input ${this.icon ? "gui-calendar--icon" : ""}" role="group">
|
|
64
|
+
${_(
|
|
65
|
+
e,
|
|
66
|
+
(i) => i.type,
|
|
67
|
+
(i, r) => {
|
|
68
|
+
const n = r === 0 ? 0 : -1;
|
|
69
|
+
switch (i.type) {
|
|
70
|
+
case "day":
|
|
71
|
+
return this.renderInput("day", "dd", 2, n, this._day);
|
|
72
|
+
case "month":
|
|
73
|
+
return this.renderInput("month", "mm", 2, n, this._month);
|
|
74
|
+
case "year":
|
|
75
|
+
return this.renderInput("year", "yyyy", 4, n, this._year);
|
|
76
|
+
case "literal":
|
|
77
|
+
return d`<span class="gui-date-input__separator">${i.value}</span>`;
|
|
78
|
+
default:
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
${this.icon ? d`<span class=${f(a)} data-icon=${this.icon}></span>` : u}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
${this.showErrors && this.errors?.length ? S(this.uid, t) : u}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
renderInput(t, e, a, i, r) {
|
|
91
|
+
return d`
|
|
92
|
+
<div class="gui-date-input__touch-target">
|
|
93
|
+
<input
|
|
94
|
+
type="text"
|
|
95
|
+
inputmode="numeric"
|
|
96
|
+
class="gui-date-input__part ${t === "year" ? "gui-date-input__year" : ""}"
|
|
97
|
+
data-type=${t}
|
|
98
|
+
maxlength=${a}
|
|
99
|
+
placeholder=${e}
|
|
100
|
+
tabindex=${i}
|
|
101
|
+
?required=${this.required}
|
|
102
|
+
?disabled=${this.disabled}
|
|
103
|
+
?readonly=${this.readOnly}
|
|
104
|
+
autocomplete="off"
|
|
105
|
+
.value=${m(r)}
|
|
106
|
+
@keydown=${this.handleKeyDown}
|
|
107
|
+
@keyup=${(n) => this.handleKeyUp(n, t)}
|
|
108
|
+
@focus=${this.handleFocus}
|
|
109
|
+
@blur=${(n) => this.handleBlur(n, t)}
|
|
110
|
+
@change=${(n) => this.handleChange(n, t)}
|
|
111
|
+
/>
|
|
112
|
+
<div class="gui-date-input__visual-underline"></div>
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
parseValue(t) {
|
|
117
|
+
if (!t) {
|
|
118
|
+
this._day = "", this._month = "", this._year = "";
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const e = new Date(t);
|
|
122
|
+
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());
|
|
123
|
+
}
|
|
124
|
+
handleKeyDown(t) {
|
|
125
|
+
[
|
|
126
|
+
"Backspace",
|
|
127
|
+
"Tab",
|
|
128
|
+
"ArrowUp",
|
|
129
|
+
"ArrowDown",
|
|
130
|
+
"ArrowLeft",
|
|
131
|
+
"ArrowRight",
|
|
132
|
+
"Delete",
|
|
133
|
+
"Enter"
|
|
134
|
+
].includes(t.key) || t.ctrlKey || t.metaKey || this.readOnly || /^[0-9]$/.test(t.key) || t.preventDefault();
|
|
135
|
+
}
|
|
136
|
+
handleFocus(t) {
|
|
137
|
+
this.dispatchEvent(new CustomEvent("focus", { detail: t }));
|
|
138
|
+
}
|
|
139
|
+
handleKeyUp(t, e) {
|
|
140
|
+
if (this.readOnly) return;
|
|
141
|
+
const a = window.getComputedStyle(this).direction === "rtl", i = t.target, r = Array.from(this.querySelectorAll("input")), n = r.indexOf(i);
|
|
142
|
+
switch (i.value.length === i.maxLength && /^[0-9]$/.test(t.key) && (n === r.length - 1 ? r[0].focus() : r[n + 1].focus()), t.key) {
|
|
143
|
+
case "ArrowUp": {
|
|
144
|
+
const s = isNaN(parseInt(i.value, 10) + 1) ? 1 : parseInt(i.value, 10) + 1;
|
|
145
|
+
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();
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "ArrowDown": {
|
|
149
|
+
const s = isNaN(parseInt(i.value, 10) - 1) ? 1 : parseInt(i.value, 10) - 1;
|
|
150
|
+
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();
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "ArrowLeft": {
|
|
154
|
+
const s = a ? n + 1 : n - 1;
|
|
155
|
+
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "ArrowRight": {
|
|
159
|
+
const s = a ? n - 1 : n + 1;
|
|
160
|
+
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
handleChange(t, e) {
|
|
166
|
+
if (t.stopImmediatePropagation(), this.readOnly) return;
|
|
167
|
+
const i = t.target.value.replace(/[^0-9]/g, "");
|
|
168
|
+
switch (e) {
|
|
169
|
+
case "day":
|
|
170
|
+
this._day = i;
|
|
171
|
+
break;
|
|
172
|
+
case "month":
|
|
173
|
+
this._month = i;
|
|
174
|
+
break;
|
|
175
|
+
case "year":
|
|
176
|
+
this._year = i;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
this.validateAndEmit();
|
|
180
|
+
}
|
|
181
|
+
handleBlur(t, e) {
|
|
182
|
+
const a = t.target, i = parseInt(a.value, 10);
|
|
183
|
+
if (!isNaN(i) && i > 0) {
|
|
184
|
+
const r = e === "year" ? 4 : 2;
|
|
185
|
+
a.value = i.toString().padStart(r, "0");
|
|
186
|
+
} else
|
|
187
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { value: null } }));
|
|
188
|
+
this.dispatchEvent(new CustomEvent("blur"));
|
|
189
|
+
}
|
|
190
|
+
validateAndEmit() {
|
|
191
|
+
let t = parseInt(this._year, 10), e = parseInt(this._month, 10), a = parseInt(this._day, 10);
|
|
192
|
+
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"));
|
|
193
|
+
const i = !isNaN(t) && String(t).length === 4, r = !isNaN(e) && e > 0;
|
|
194
|
+
if (!isNaN(a) && a > 0 && r && i) {
|
|
195
|
+
const s = this.MAX_VALID_DAY(e, t);
|
|
196
|
+
if (a > s)
|
|
197
|
+
this.dispatchEvent(
|
|
198
|
+
new CustomEvent("inputError", {
|
|
199
|
+
detail: {
|
|
200
|
+
message: "Invalid date: day is greater than the maximum valid day for the month and year."
|
|
201
|
+
},
|
|
202
|
+
bubbles: !0
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
else {
|
|
206
|
+
const c = new Date(t, e - 1, a);
|
|
207
|
+
this.value = b(c), this.dispatchEvent(
|
|
208
|
+
new CustomEvent("change", {
|
|
209
|
+
detail: { value: this.value },
|
|
210
|
+
bubbles: !0
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this.requestUpdate();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
h([
|
|
219
|
+
l({ type: String })
|
|
220
|
+
], o.prototype, "uid", 2);
|
|
221
|
+
h([
|
|
222
|
+
l({ type: String })
|
|
223
|
+
], o.prototype, "label", 2);
|
|
224
|
+
h([
|
|
225
|
+
l({ type: String, attribute: "locale-id" })
|
|
226
|
+
], o.prototype, "localeId", 2);
|
|
227
|
+
h([
|
|
228
|
+
l({ type: Array })
|
|
229
|
+
], o.prototype, "errors", 2);
|
|
230
|
+
h([
|
|
231
|
+
l({ type: Boolean })
|
|
232
|
+
], o.prototype, "showErrors", 2);
|
|
233
|
+
h([
|
|
234
|
+
l({ type: Boolean })
|
|
235
|
+
], o.prototype, "touched", 2);
|
|
236
|
+
h([
|
|
237
|
+
l({ type: Boolean })
|
|
238
|
+
], o.prototype, "required", 2);
|
|
239
|
+
h([
|
|
240
|
+
l({ type: Boolean })
|
|
241
|
+
], o.prototype, "disabled", 2);
|
|
242
|
+
h([
|
|
243
|
+
l({ type: Boolean, attribute: "readonly" })
|
|
244
|
+
], o.prototype, "readOnly", 2);
|
|
245
|
+
h([
|
|
246
|
+
l({ type: String })
|
|
247
|
+
], o.prototype, "value", 2);
|
|
248
|
+
h([
|
|
249
|
+
l({ type: String })
|
|
250
|
+
], o.prototype, "icon", 2);
|
|
251
|
+
h([
|
|
252
|
+
l({ type: String })
|
|
253
|
+
], o.prototype, "hint", 2);
|
|
254
|
+
h([
|
|
255
|
+
p()
|
|
256
|
+
], o.prototype, "_day", 2);
|
|
257
|
+
h([
|
|
258
|
+
p()
|
|
259
|
+
], o.prototype, "_month", 2);
|
|
260
|
+
h([
|
|
261
|
+
p()
|
|
262
|
+
], o.prototype, "_year", 2);
|
|
263
|
+
o = h([
|
|
264
|
+
g("gui-date")
|
|
265
|
+
], o);
|
|
266
|
+
typeof customElements < "u" && !customElements.get("gui-date") && customElements.define("gui-date", o);
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 "@golemui/gui-shared";
|
|
4
|
+
import "./date-input-VJG8lMVN.js";
|
|
5
|
+
import "./calendar-P9DzVryu.js";
|
|
6
|
+
import { consume as D, provide as $ } from "@lit/context";
|
|
7
|
+
import { LitElement as v, html as l, nothing as f } from "lit";
|
|
8
|
+
import { property as b, query as o, state as y, customElement as I } from "lit/decorators.js";
|
|
9
|
+
import "rxjs";
|
|
10
|
+
import { classMap as O } from "lit/directives/class-map.js";
|
|
11
|
+
var w = Object.defineProperty, x = Object.getOwnPropertyDescriptor, n = (e, t, a, i) => {
|
|
12
|
+
for (var r = i > 1 ? void 0 : i ? x(t, a) : t, d = e.length - 1, p; d >= 0; d--)
|
|
13
|
+
(p = e[d]) && (r = (i ? p(t, a, r) : p(r)) || r);
|
|
14
|
+
return i && r && w(t, a, r), r;
|
|
11
15
|
};
|
|
12
|
-
let s = class extends
|
|
16
|
+
let s = class extends v {
|
|
13
17
|
constructor() {
|
|
14
|
-
super(...arguments), this.adapter = new
|
|
18
|
+
super(...arguments), this.adapter = new h(), this.isCalendarOpen = !1, this.subscriptions = [], this.onFocusOut = (e) => {
|
|
15
19
|
if (!this.isCalendarOpen) return;
|
|
16
20
|
const t = e.relatedTarget;
|
|
17
21
|
t && this.contains(t) || this.closeCalendar();
|
|
@@ -36,7 +40,7 @@ let s = class extends D {
|
|
|
36
40
|
}
|
|
37
41
|
render() {
|
|
38
42
|
super.render();
|
|
39
|
-
const e =
|
|
43
|
+
const e = m("datePicker", this.adapter.templateData), t = this.isCalendarOpen ? l`<gui-calendar
|
|
40
44
|
id="calendar-input"
|
|
41
45
|
.uid=${this.widget.uid}
|
|
42
46
|
.hint=${this.adapter.templateData.hint}
|
|
@@ -59,9 +63,9 @@ let s = class extends D {
|
|
|
59
63
|
.localeId=${this.adapter.templateData.lang}
|
|
60
64
|
@blur=${this.onBlurCalendar}
|
|
61
65
|
@change=${this.valueChanged}
|
|
62
|
-
></gui-calendar>` :
|
|
63
|
-
return
|
|
64
|
-
${
|
|
66
|
+
></gui-calendar>` : f;
|
|
67
|
+
return l`
|
|
68
|
+
${g(this.widget.uid, {
|
|
65
69
|
...this.adapter.templateData,
|
|
66
70
|
required: this.adapter.templateData.validator?.required
|
|
67
71
|
})}
|
|
@@ -76,7 +80,7 @@ let s = class extends D {
|
|
|
76
80
|
>
|
|
77
81
|
<gui-date
|
|
78
82
|
id="date-input"
|
|
79
|
-
class=${
|
|
83
|
+
class=${O(e.widgetClasses)}
|
|
80
84
|
.uid=${this.widget.uid}
|
|
81
85
|
.hint=${this.adapter.templateData.hint}
|
|
82
86
|
.showErrors=${!1}
|
|
@@ -103,7 +107,7 @@ let s = class extends D {
|
|
|
103
107
|
${t}
|
|
104
108
|
</div>
|
|
105
109
|
|
|
106
|
-
${
|
|
110
|
+
${C(this.widget.uid, this.adapter.templateData)}
|
|
107
111
|
`;
|
|
108
112
|
}
|
|
109
113
|
valueChanged(e) {
|
|
@@ -134,23 +138,23 @@ let s = class extends D {
|
|
|
134
138
|
}
|
|
135
139
|
};
|
|
136
140
|
n([
|
|
137
|
-
|
|
138
|
-
|
|
141
|
+
D({ context: u }),
|
|
142
|
+
b({ attribute: !1 })
|
|
139
143
|
], s.prototype, "formContext", 2);
|
|
140
144
|
n([
|
|
141
|
-
|
|
145
|
+
$({ context: c })
|
|
142
146
|
], s.prototype, "adapter", 2);
|
|
143
147
|
n([
|
|
144
|
-
|
|
148
|
+
o("#date-input")
|
|
145
149
|
], s.prototype, "dateInput", 2);
|
|
146
150
|
n([
|
|
147
|
-
|
|
151
|
+
o("#calendar-input")
|
|
148
152
|
], s.prototype, "calendarInput", 2);
|
|
149
153
|
n([
|
|
150
|
-
|
|
154
|
+
y()
|
|
151
155
|
], s.prototype, "isCalendarOpen", 2);
|
|
152
156
|
s = n([
|
|
153
|
-
|
|
157
|
+
I("gui-date-picker-input")
|
|
154
158
|
], s);
|
|
155
159
|
export {
|
|
156
160
|
s as DatePickerElement
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { InputWidgetAdapter as l, formContext as n, inputContext as u } from "@golemui/lit";
|
|
2
|
+
import { a as h } from "./templates-Dk1jxLwS.js";
|
|
3
|
+
import "@golemui/gui-shared";
|
|
4
|
+
import "./date-input-VJG8lMVN.js";
|
|
5
|
+
import { consume as c, provide as m } from "@lit/context";
|
|
6
|
+
import { LitElement as f, html as b } from "lit";
|
|
7
|
+
import { property as g, customElement as D } from "lit/decorators.js";
|
|
8
|
+
import "rxjs";
|
|
9
|
+
import { classMap as $ } from "lit/directives/class-map.js";
|
|
10
|
+
var v = Object.defineProperty, C = Object.getOwnPropertyDescriptor, o = (t, e, i, r) => {
|
|
11
|
+
for (var a = r > 1 ? void 0 : r ? C(e, i) : e, p = t.length - 1, d; p >= 0; p--)
|
|
12
|
+
(d = t[p]) && (a = (r ? d(e, i, a) : d(a)) || a);
|
|
13
|
+
return r && a && v(e, i, a), a;
|
|
11
14
|
};
|
|
12
|
-
let s = class extends
|
|
15
|
+
let s = class extends f {
|
|
13
16
|
constructor() {
|
|
14
|
-
super(...arguments), this.adapter = new
|
|
17
|
+
super(...arguments), this.adapter = new l(), this.subscriptions = [];
|
|
15
18
|
}
|
|
16
19
|
createRenderRoot() {
|
|
17
20
|
return this;
|
|
@@ -28,10 +31,10 @@ let s = class extends c {
|
|
|
28
31
|
}
|
|
29
32
|
render() {
|
|
30
33
|
super.render();
|
|
31
|
-
const t =
|
|
32
|
-
return
|
|
34
|
+
const t = h("date", this.adapter.templateData);
|
|
35
|
+
return b`
|
|
33
36
|
<gui-date
|
|
34
|
-
class=${
|
|
37
|
+
class=${$(t.widgetClasses)}
|
|
35
38
|
.uid=${this.widget.uid}
|
|
36
39
|
.label=${this.adapter.templateData.label}
|
|
37
40
|
.hint=${this.adapter.templateData.hint}
|
|
@@ -59,15 +62,15 @@ let s = class extends c {
|
|
|
59
62
|
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
o([
|
|
66
|
+
c({ context: n }),
|
|
67
|
+
g({ attribute: !1 })
|
|
65
68
|
], s.prototype, "formContext", 2);
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
o([
|
|
70
|
+
m({ context: u })
|
|
68
71
|
], s.prototype, "adapter", 2);
|
|
69
|
-
s =
|
|
70
|
-
|
|
72
|
+
s = o([
|
|
73
|
+
D("gui-date-input")
|
|
71
74
|
], s);
|
|
72
75
|
export {
|
|
73
76
|
s as DateElement
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { InputWidgetAdapter as v, formContext as w, inputContext as y } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { consume as F, provide as C } from "@lit/context";
|
|
4
|
+
import { LitElement as x, nothing as m, html as f } from "lit";
|
|
5
|
+
import { property as D, state as c, query as I, customElement as L } from "lit/decorators.js";
|
|
6
|
+
import { Subject as R, debounceTime as V } from "rxjs";
|
|
7
|
+
import { d as k } from "./list-CtFsv7GB.js";
|
|
8
|
+
import "./errors-QjKhr6mA.js";
|
|
9
|
+
var O = Object.defineProperty, j = Object.getOwnPropertyDescriptor, l = (e, t, i, s) => {
|
|
10
|
+
for (var n = s > 1 ? void 0 : s ? j(t, i) : t, d = e.length - 1, o; d >= 0; d--)
|
|
9
11
|
(o = e[d]) && (n = (s ? o(t, i, n) : o(n)) || n);
|
|
10
|
-
return s && n &&
|
|
12
|
+
return s && n && O(t, i, n), n;
|
|
11
13
|
};
|
|
12
|
-
let a = class extends
|
|
14
|
+
let a = class extends x {
|
|
13
15
|
constructor() {
|
|
14
|
-
super(...arguments), this.adapter = new
|
|
16
|
+
super(...arguments), this.adapter = new v(), this.debouncer = new R(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._filteredItems = [], this._listItems = [], this._focusedIndex = -1, this._isFiltering = !1, this._isListVisible = !1, this._selectedItem = void 0, this.onDocumentClick = (e) => {
|
|
15
17
|
if (!this._isListVisible) return;
|
|
16
18
|
const t = e.composedPath(), i = this._inputRef && t.includes(this._inputRef), s = this._listRef && t.includes(this._listRef);
|
|
17
19
|
!i && !s && (this._isListVisible = !1);
|
|
@@ -31,7 +33,7 @@ let a = class extends F {
|
|
|
31
33
|
const e = this.adapter.templateData;
|
|
32
34
|
e.items && this._listItems.length === 0 && this._filteredItems.length === 0 && (this._filteredItems = e.items, this._listItems = e.items), this.requestUpdate();
|
|
33
35
|
}),
|
|
34
|
-
this.debouncer.pipe(
|
|
36
|
+
this.debouncer.pipe(V(this.adapter.templateData.inputDebounce ?? 500)).subscribe((e) => {
|
|
35
37
|
this._filterItems(e);
|
|
36
38
|
})
|
|
37
39
|
);
|
|
@@ -107,7 +109,7 @@ let a = class extends F {
|
|
|
107
109
|
render() {
|
|
108
110
|
const e = this.adapter.templateData, t = e.touched && e.errors && e.errors.length > 0, i = this._listItems.slice(this._range.start, this._range.end), s = this.adapter.getItemRenderer(
|
|
109
111
|
e.itemRenderer,
|
|
110
|
-
|
|
112
|
+
k
|
|
111
113
|
), d = this._selectedItem?.template !== null && typeof this._selectedItem?.template == "object" ? e.labelField ?? "label" : null, o = d ? this._selectedItem?.template[d] : this._selectedItem?.template, h = !!this.widget.on?.filter;
|
|
112
114
|
return f`
|
|
113
115
|
<gui-label
|
|
@@ -166,8 +168,8 @@ let a = class extends F {
|
|
|
166
168
|
@blur=${this._onBlur}
|
|
167
169
|
@change=${this._onValueChange}
|
|
168
170
|
>
|
|
169
|
-
${i.map((r,
|
|
170
|
-
const u = this._range.start +
|
|
171
|
+
${i.map((r, g) => {
|
|
172
|
+
const u = this._range.start + g, p = e.value === r.value, _ = this._focusedIndex === u, b = e.labelField ?? "label", $ = r.template !== null && typeof r.template == "object" && b && !e.itemRenderer ? r.template[b] : r.template;
|
|
171
173
|
return f`
|
|
172
174
|
<div
|
|
173
175
|
role="option"
|
|
@@ -179,7 +181,7 @@ let a = class extends F {
|
|
|
179
181
|
@click=${() => this._onClickItem(r, u)}
|
|
180
182
|
>
|
|
181
183
|
${s({
|
|
182
|
-
template:
|
|
184
|
+
template: $,
|
|
183
185
|
value: r.value,
|
|
184
186
|
index: u,
|
|
185
187
|
selected: p,
|
|
@@ -201,11 +203,11 @@ let a = class extends F {
|
|
|
201
203
|
}
|
|
202
204
|
};
|
|
203
205
|
l([
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
F({ context: w }),
|
|
207
|
+
D({ attribute: !1 })
|
|
206
208
|
], a.prototype, "formContext", 2);
|
|
207
209
|
l([
|
|
208
|
-
|
|
210
|
+
C({ context: y })
|
|
209
211
|
], a.prototype, "adapter", 2);
|
|
210
212
|
l([
|
|
211
213
|
c()
|
|
@@ -229,13 +231,13 @@ l([
|
|
|
229
231
|
c()
|
|
230
232
|
], a.prototype, "_selectedItem", 2);
|
|
231
233
|
l([
|
|
232
|
-
|
|
234
|
+
I("input")
|
|
233
235
|
], a.prototype, "_inputRef", 2);
|
|
234
236
|
l([
|
|
235
|
-
|
|
237
|
+
I("gui-list")
|
|
236
238
|
], a.prototype, "_listRef", 2);
|
|
237
239
|
a = l([
|
|
238
|
-
|
|
240
|
+
L("gui-dropdown-input")
|
|
239
241
|
], a);
|
|
240
242
|
export {
|
|
241
243
|
a as DropdownElement
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LitElement as h, html as y } from "lit";
|
|
2
|
+
import { property as r, customElement as c } from "lit/decorators.js";
|
|
3
|
+
import { G as m, b as f, c as g } from "./templates-Dk1jxLwS.js";
|
|
4
|
+
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (u, s, n, i) => {
|
|
5
|
+
for (var e = i > 1 ? void 0 : i ? b(s, n) : s, l = u.length - 1, a; l >= 0; l--)
|
|
6
|
+
(a = u[l]) && (e = (i ? a(s, n, e) : a(e)) || e);
|
|
7
|
+
return i && e && v(s, n, e), e;
|
|
8
|
+
};
|
|
9
|
+
let t = class extends h {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.targetElement = void 0, this.uid = void 0, this.label = void 0, this.hint = void 0, this.required = void 0, this.errors = [], this.disabled = !1, this.readOnly = !1, this.touched = !1, this.native = !0, this.ariaController = new m(this, {
|
|
12
|
+
getTargets: () => Array.isArray(this.targetElement) ? [...this.targetElement] : [this.targetElement],
|
|
13
|
+
getState: () => ({
|
|
14
|
+
uid: this.uid,
|
|
15
|
+
templateData: {
|
|
16
|
+
hint: this.hint,
|
|
17
|
+
errors: this.errors,
|
|
18
|
+
readonly: this.readOnly,
|
|
19
|
+
disabled: this.disabled,
|
|
20
|
+
touched: this.touched
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
createRenderRoot() {
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
return super.render(), y`${f(
|
|
30
|
+
this.uid,
|
|
31
|
+
{
|
|
32
|
+
label: this.label,
|
|
33
|
+
hint: this.hint,
|
|
34
|
+
required: this.required,
|
|
35
|
+
errors: this.errors,
|
|
36
|
+
touched: this.touched
|
|
37
|
+
},
|
|
38
|
+
!1,
|
|
39
|
+
void 0,
|
|
40
|
+
this.native
|
|
41
|
+
)}`;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
o([
|
|
45
|
+
r({ type: Object })
|
|
46
|
+
], t.prototype, "targetElement", 2);
|
|
47
|
+
o([
|
|
48
|
+
r({ type: String })
|
|
49
|
+
], t.prototype, "uid", 2);
|
|
50
|
+
o([
|
|
51
|
+
r({ type: String })
|
|
52
|
+
], t.prototype, "label", 2);
|
|
53
|
+
o([
|
|
54
|
+
r({ type: String })
|
|
55
|
+
], t.prototype, "hint", 2);
|
|
56
|
+
o([
|
|
57
|
+
r({ type: Boolean })
|
|
58
|
+
], t.prototype, "required", 2);
|
|
59
|
+
o([
|
|
60
|
+
r({ type: Array })
|
|
61
|
+
], t.prototype, "errors", 2);
|
|
62
|
+
o([
|
|
63
|
+
r({ type: Boolean })
|
|
64
|
+
], t.prototype, "disabled", 2);
|
|
65
|
+
o([
|
|
66
|
+
r({ type: Boolean, attribute: "readonly" })
|
|
67
|
+
], t.prototype, "readOnly", 2);
|
|
68
|
+
o([
|
|
69
|
+
r({ type: Boolean })
|
|
70
|
+
], t.prototype, "touched", 2);
|
|
71
|
+
o([
|
|
72
|
+
r({ type: Boolean })
|
|
73
|
+
], t.prototype, "native", 2);
|
|
74
|
+
t = o([
|
|
75
|
+
c("gui-label")
|
|
76
|
+
], t);
|
|
77
|
+
typeof customElements < "u" && !customElements.get("gui-label") && customElements.define("gui-label", t);
|
|
78
|
+
var E = Object.defineProperty, O = Object.getOwnPropertyDescriptor, d = (u, s, n, i) => {
|
|
79
|
+
for (var e = i > 1 ? void 0 : i ? O(s, n) : s, l = u.length - 1, a; l >= 0; l--)
|
|
80
|
+
(a = u[l]) && (e = (i ? a(s, n, e) : a(e)) || e);
|
|
81
|
+
return i && e && E(s, n, e), e;
|
|
82
|
+
};
|
|
83
|
+
let p = class extends h {
|
|
84
|
+
constructor() {
|
|
85
|
+
super(...arguments), this.uid = void 0, this.errors = [], this.touched = !1;
|
|
86
|
+
}
|
|
87
|
+
createRenderRoot() {
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
return super.render(), y`${g(this.uid, {
|
|
92
|
+
touched: this.touched,
|
|
93
|
+
errors: this.errors
|
|
94
|
+
})}`;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
d([
|
|
98
|
+
r({ type: String })
|
|
99
|
+
], p.prototype, "uid", 2);
|
|
100
|
+
d([
|
|
101
|
+
r({ type: Array })
|
|
102
|
+
], p.prototype, "errors", 2);
|
|
103
|
+
d([
|
|
104
|
+
r({ type: Boolean })
|
|
105
|
+
], p.prototype, "touched", 2);
|
|
106
|
+
p = d([
|
|
107
|
+
c("gui-errors")
|
|
108
|
+
], p);
|
|
109
|
+
typeof customElements < "u" && !customElements.get("gui-errors") && customElements.define("gui-errors", p);
|