@golemui/gui-lit 0.12.2 → 0.13.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 +4 -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,121 @@
|
|
|
1
|
+
import { ActionWidgetAdapter as f, formContext as g, actionContext as v } from "@golemui/lit";
|
|
2
|
+
import { consume as $, provide as y } from "@lit/context";
|
|
3
|
+
import { LitElement as b, html as u, nothing as c } from "lit";
|
|
4
|
+
import { property as p, customElement as m } from "lit/decorators.js";
|
|
5
|
+
import "rxjs";
|
|
6
|
+
import "@golemui/gui-shared";
|
|
7
|
+
import { classMap as P } from "lit/directives/class-map.js";
|
|
8
|
+
var C = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (i, t, s, o) => {
|
|
9
|
+
for (var e = o > 1 ? void 0 : o ? x(t, s) : t, a = i.length - 1, r; a >= 0; a--)
|
|
10
|
+
(r = i[a]) && (e = (o ? r(t, s, e) : r(e)) || e);
|
|
11
|
+
return o && e && C(t, s, e), e;
|
|
12
|
+
};
|
|
13
|
+
let n = class extends b {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.disabled = !1, this.icon = void 0, this.variant = "filled", this.iconPosition = "left";
|
|
16
|
+
}
|
|
17
|
+
createRenderRoot() {
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
const i = this.icon, t = this.iconPosition || "left", s = {
|
|
25
|
+
"gui-button-with-icon": !!i,
|
|
26
|
+
[`gui-button-icon-${t}`]: !0,
|
|
27
|
+
"gui-button--outlined": this.variant === "outlined",
|
|
28
|
+
"gui-button--link": this.variant === "link"
|
|
29
|
+
}, o = i ? u`<span class="gui-widget-icon gui-button-icon ${i}" data-icon=${i}></span>` : c;
|
|
30
|
+
return u`
|
|
31
|
+
<div class="gui-widget">
|
|
32
|
+
<button
|
|
33
|
+
type="button"
|
|
34
|
+
tabindex="0"
|
|
35
|
+
id=${this.uid}
|
|
36
|
+
class=${P(s)}
|
|
37
|
+
data-cy=${`${this.uid}_button`}
|
|
38
|
+
?disabled=${this.disabled}
|
|
39
|
+
>
|
|
40
|
+
${t === "left" ? o : c}
|
|
41
|
+
${this.label ? u`<span>${this.label}</span>` : c}
|
|
42
|
+
${t === "right" ? o : c}
|
|
43
|
+
</button>
|
|
44
|
+
</div>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
l([
|
|
49
|
+
p({ type: String })
|
|
50
|
+
], n.prototype, "uid", 2);
|
|
51
|
+
l([
|
|
52
|
+
p({ type: String })
|
|
53
|
+
], n.prototype, "label", 2);
|
|
54
|
+
l([
|
|
55
|
+
p({ type: Boolean })
|
|
56
|
+
], n.prototype, "disabled", 2);
|
|
57
|
+
l([
|
|
58
|
+
p({ type: String })
|
|
59
|
+
], n.prototype, "icon", 2);
|
|
60
|
+
l([
|
|
61
|
+
p({ type: String })
|
|
62
|
+
], n.prototype, "variant", 2);
|
|
63
|
+
l([
|
|
64
|
+
p({ type: String })
|
|
65
|
+
], n.prototype, "iconPosition", 2);
|
|
66
|
+
n = l([
|
|
67
|
+
m("gui-button")
|
|
68
|
+
], n);
|
|
69
|
+
typeof customElements < "u" && !customElements.get("gui-button") && customElements.define("gui-button", n);
|
|
70
|
+
var _ = Object.defineProperty, D = Object.getOwnPropertyDescriptor, h = (i, t, s, o) => {
|
|
71
|
+
for (var e = o > 1 ? void 0 : o ? D(t, s) : t, a = i.length - 1, r; a >= 0; a--)
|
|
72
|
+
(r = i[a]) && (e = (o ? r(t, s, e) : r(e)) || e);
|
|
73
|
+
return o && e && _(t, s, e), e;
|
|
74
|
+
};
|
|
75
|
+
let d = class extends b {
|
|
76
|
+
constructor() {
|
|
77
|
+
super(...arguments), this.adapter = new f(), this.subscriptions = [];
|
|
78
|
+
}
|
|
79
|
+
createRenderRoot() {
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
updated(i) {
|
|
83
|
+
super.updated(i);
|
|
84
|
+
const t = this.adapter.templateData.size;
|
|
85
|
+
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
86
|
+
}
|
|
87
|
+
connectedCallback() {
|
|
88
|
+
super.connectedCallback(), this.classList.add("gui-button", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
89
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
return u`
|
|
94
|
+
<gui-button
|
|
95
|
+
.uid=${this.widget.uid}
|
|
96
|
+
.label=${this.adapter.templateData.label}
|
|
97
|
+
?disabled=${this.adapter.templateData.disabled === !0}
|
|
98
|
+
.variant=${this.adapter.templateData.variant}
|
|
99
|
+
.icon=${this.adapter.templateData.icon}
|
|
100
|
+
.iconPosition=${this.adapter.templateData.iconPosition}
|
|
101
|
+
@click=${() => this.adapter.click()}
|
|
102
|
+
></gui-button>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((i) => i.unsubscribe());
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
h([
|
|
110
|
+
$({ context: g }),
|
|
111
|
+
p({ attribute: !1 })
|
|
112
|
+
], d.prototype, "formContext", 2);
|
|
113
|
+
h([
|
|
114
|
+
y({ context: v })
|
|
115
|
+
], d.prototype, "adapter", 2);
|
|
116
|
+
d = h([
|
|
117
|
+
m("gui-button-interactive")
|
|
118
|
+
], d);
|
|
119
|
+
export {
|
|
120
|
+
d as ButtonElement
|
|
121
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { html as D } from "lit";
|
|
2
|
+
import { property as m, customElement as f } from "lit/decorators.js";
|
|
3
|
+
import { classMap as p } from "lit/directives/class-map.js";
|
|
4
|
+
import { i as h, b as g, a as v, g as M, t as w } from "./date-CG1562vW.js";
|
|
5
|
+
import { A as C } from "./abstract-calendar-YDgwwbqe.js";
|
|
6
|
+
var _ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, d = (e, t, n, r) => {
|
|
7
|
+
for (var i = r > 1 ? void 0 : r ? y(t, n) : t, s = e.length - 1, a; s >= 0; s--)
|
|
8
|
+
(a = e[s]) && (i = (r ? a(t, n, i) : a(i)) || i);
|
|
9
|
+
return r && i && _(t, n, i), i;
|
|
10
|
+
};
|
|
11
|
+
let l = class extends C {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.value = void 0;
|
|
14
|
+
}
|
|
15
|
+
createRenderRoot() {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
20
|
+
}
|
|
21
|
+
willUpdate(e) {
|
|
22
|
+
if (e.has("value") && this.value) {
|
|
23
|
+
const t = new Date(this.value);
|
|
24
|
+
!isNaN(t.getTime()) && !h(t, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = t);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
renderDay(e) {
|
|
28
|
+
const t = {
|
|
29
|
+
"gui-calendar__day-button": !0,
|
|
30
|
+
today: e.isToday,
|
|
31
|
+
selected: e.isSelected,
|
|
32
|
+
disabled: e.isDisabled,
|
|
33
|
+
"other-month": !e.isCurrentMonth
|
|
34
|
+
};
|
|
35
|
+
return D`
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
role="gridcell"
|
|
39
|
+
class=${p(t)}
|
|
40
|
+
tabindex=${e.isFocusable ? 0 : -1}
|
|
41
|
+
?disabled=${!e.isCurrentMonth || e.isDisabled}
|
|
42
|
+
data-date=${e.date.toISOString()}
|
|
43
|
+
@click=${() => this.selectDate(e)}
|
|
44
|
+
@keydown=${(n) => this.handleKeydown(n, e)}
|
|
45
|
+
aria-selected=${e.isSelected}
|
|
46
|
+
>
|
|
47
|
+
${e.dayLabel}
|
|
48
|
+
</button>
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
getDaysInMonth(e) {
|
|
52
|
+
const t = new Date(this._currentDate);
|
|
53
|
+
t.setDate(1), t.setMonth(t.getMonth() + e);
|
|
54
|
+
const n = this.generateDateGrid(e), r = t.getMonth();
|
|
55
|
+
let i = n.map((s) => {
|
|
56
|
+
const a = s.getMonth() === r, o = this.isDisabled(s), c = !!this.value && g(s, new Date(this.value)), u = v(s), b = (c || u) && a;
|
|
57
|
+
return {
|
|
58
|
+
date: s,
|
|
59
|
+
dayLabel: M(this.localeId, s),
|
|
60
|
+
isCurrentMonth: a,
|
|
61
|
+
isToday: u,
|
|
62
|
+
isDisabled: o,
|
|
63
|
+
isSelected: c,
|
|
64
|
+
isFocusable: b
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
for (let s = 0; s < 2; s++)
|
|
68
|
+
i.slice(-7).every((o) => !o.isCurrentMonth) && (i = i.slice(0, -7));
|
|
69
|
+
if (e === 0 && !i.some((s) => s.isFocusable)) {
|
|
70
|
+
const s = this.value ? new Date(this.value) : /* @__PURE__ */ new Date();
|
|
71
|
+
if (!h(s, this._currentDate, this.numberOfMonths ?? 1)) {
|
|
72
|
+
const a = i.find((o) => o.isCurrentMonth && !o.isDisabled);
|
|
73
|
+
a && (a.isFocusable = !0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return i;
|
|
77
|
+
}
|
|
78
|
+
selectDate(e) {
|
|
79
|
+
if (!e.isCurrentMonth || e.isDisabled || this.disabled || this.readOnly) return;
|
|
80
|
+
const t = w(e.date);
|
|
81
|
+
this.value = t, this.dispatchEvent(
|
|
82
|
+
new CustomEvent("change", {
|
|
83
|
+
detail: { value: t },
|
|
84
|
+
bubbles: !0,
|
|
85
|
+
composed: !0
|
|
86
|
+
})
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
d([
|
|
91
|
+
m({ type: String })
|
|
92
|
+
], l.prototype, "value", 2);
|
|
93
|
+
l = d([
|
|
94
|
+
f("gui-calendar")
|
|
95
|
+
], l);
|
|
96
|
+
typeof customElements < "u" && !customElements.get("gui-calendar") && customElements.define("gui-calendar", l);
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { InputWidgetAdapter as o, formContext as l, inputContext as h } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import "./calendar-P9DzVryu.js";
|
|
4
|
+
import { consume as m, provide as u } from "@lit/context";
|
|
5
|
+
import { LitElement as c, html as D } from "lit";
|
|
6
|
+
import { property as b, customElement as $ } from "lit/decorators.js";
|
|
7
|
+
import "rxjs";
|
|
8
|
+
var f = Object.defineProperty, g = Object.getOwnPropertyDescriptor, d = (e, t, s, r) => {
|
|
9
|
+
for (var a = r > 1 ? void 0 : r ? g(t, s) : t, p = e.length - 1, n; p >= 0; p--)
|
|
10
|
+
(n = e[p]) && (a = (r ? n(t, s, a) : n(a)) || a);
|
|
11
|
+
return r && a && f(t, s, a), a;
|
|
9
12
|
};
|
|
10
|
-
let
|
|
13
|
+
let i = class extends c {
|
|
11
14
|
constructor() {
|
|
12
|
-
super(...arguments), this.adapter = new
|
|
15
|
+
super(...arguments), this.adapter = new o(), this.subscriptions = [];
|
|
13
16
|
}
|
|
14
17
|
createRenderRoot() {
|
|
15
18
|
return this;
|
|
@@ -25,7 +28,7 @@ let s = class extends m {
|
|
|
25
28
|
);
|
|
26
29
|
}
|
|
27
30
|
render() {
|
|
28
|
-
return super.render(),
|
|
31
|
+
return super.render(), D`
|
|
29
32
|
<gui-calendar
|
|
30
33
|
.uid=${this.widget.uid}
|
|
31
34
|
.label=${this.adapter.templateData.label}
|
|
@@ -61,16 +64,16 @@ let s = class extends m {
|
|
|
61
64
|
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
],
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
],
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
],
|
|
67
|
+
d([
|
|
68
|
+
m({ context: l }),
|
|
69
|
+
b({ attribute: !1 })
|
|
70
|
+
], i.prototype, "formContext", 2);
|
|
71
|
+
d([
|
|
72
|
+
u({ context: h })
|
|
73
|
+
], i.prototype, "adapter", 2);
|
|
74
|
+
i = d([
|
|
75
|
+
$("gui-calendar-input")
|
|
76
|
+
], i);
|
|
74
77
|
export {
|
|
75
|
-
|
|
78
|
+
i as CalendarElement
|
|
76
79
|
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { InputWidgetAdapter as g, formContext as m, inputContext as y } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { G as v, c as f } from "./templates-Dk1jxLwS.js";
|
|
4
|
+
import { LitElement as u, nothing as $, html as p } from "lit";
|
|
5
|
+
import { property as r, customElement as b } from "lit/decorators.js";
|
|
6
|
+
import { consume as x, provide as C } from "@lit/context";
|
|
7
|
+
import "rxjs";
|
|
8
|
+
var k = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, s = (e, t, l, o) => {
|
|
9
|
+
for (var i = o > 1 ? void 0 : o ? _(t, l) : t, d = e.length - 1, h; d >= 0; d--)
|
|
10
|
+
(h = e[d]) && (i = (o ? h(t, l, i) : h(i)) || i);
|
|
11
|
+
return o && i && k(t, l, i), i;
|
|
12
|
+
};
|
|
13
|
+
let a = class extends u {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = "en", this.errors = [], this.touched = void 0, this.required = void 0, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.hint = void 0, this.checkboxPosition = "left", this.ariaController = new v(this, {
|
|
16
|
+
getTargets: () => this.querySelectorAll(`input[id="${this.uid}"]`),
|
|
17
|
+
getState: () => ({
|
|
18
|
+
uid: this.uid,
|
|
19
|
+
templateData: {
|
|
20
|
+
hint: this.hint,
|
|
21
|
+
errors: this.errors,
|
|
22
|
+
touched: this.touched,
|
|
23
|
+
// Checkboxes can't have aria-readonly
|
|
24
|
+
readonly: !1,
|
|
25
|
+
disabled: !1
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
createRenderRoot() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
super.render();
|
|
38
|
+
const e = {
|
|
39
|
+
uid: this.uid,
|
|
40
|
+
label: this.label,
|
|
41
|
+
hint: this.hint,
|
|
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
|
+
checkboxPosition: this.checkboxPosition
|
|
49
|
+
};
|
|
50
|
+
return e.checkboxPosition === "right" ? this.classList.add("gui-checkbox--right") : this.classList.contains("gui-checkbox--right") && this.classList.remove("gui-checkbox--right"), p`
|
|
51
|
+
<label
|
|
52
|
+
class="gui-label"
|
|
53
|
+
for=${this.uid}
|
|
54
|
+
data-cy=${`${this.uid}_label`}
|
|
55
|
+
id=${`${this.uid}_label`}
|
|
56
|
+
>
|
|
57
|
+
<div class="gui-widget gui-widget--horizontal">
|
|
58
|
+
<input
|
|
59
|
+
type="checkbox"
|
|
60
|
+
tabindex="0"
|
|
61
|
+
id=${this.uid}
|
|
62
|
+
data-cy=${`${this.uid}_checkbox`}
|
|
63
|
+
?checked=${this.value}
|
|
64
|
+
?required=${this.required}
|
|
65
|
+
?disabled=${this.disabled || this.readOnly}
|
|
66
|
+
@change=${this.valueChanged}
|
|
67
|
+
@blur=${this.onBlur}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<span class="gui-label__container">
|
|
72
|
+
${e.label + (e.required ? " *" : "")}
|
|
73
|
+
</span>
|
|
74
|
+
</label>
|
|
75
|
+
|
|
76
|
+
<div class="gui-widget-hint" id=${`${e.uid}_hint`}>
|
|
77
|
+
${e.hint ?? $} ${f(this.uid, e)}
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
valueChanged(e) {
|
|
82
|
+
if (e.stopPropagation(), !this.readOnly) {
|
|
83
|
+
const t = e.target;
|
|
84
|
+
this.dispatchEvent(
|
|
85
|
+
new CustomEvent("change", {
|
|
86
|
+
detail: { value: t.checked },
|
|
87
|
+
bubbles: !0,
|
|
88
|
+
composed: !0
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
onBlur() {
|
|
94
|
+
this.dispatchEvent(
|
|
95
|
+
new CustomEvent("blur", {
|
|
96
|
+
bubbles: !0,
|
|
97
|
+
composed: !0
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
s([
|
|
103
|
+
r({ type: String })
|
|
104
|
+
], a.prototype, "uid", 2);
|
|
105
|
+
s([
|
|
106
|
+
r({ type: String })
|
|
107
|
+
], a.prototype, "label", 2);
|
|
108
|
+
s([
|
|
109
|
+
r({ type: String, attribute: "locale-id" })
|
|
110
|
+
], a.prototype, "localeId", 2);
|
|
111
|
+
s([
|
|
112
|
+
r({ type: Array })
|
|
113
|
+
], a.prototype, "errors", 2);
|
|
114
|
+
s([
|
|
115
|
+
r({ type: Boolean })
|
|
116
|
+
], a.prototype, "touched", 2);
|
|
117
|
+
s([
|
|
118
|
+
r({ type: Boolean })
|
|
119
|
+
], a.prototype, "required", 2);
|
|
120
|
+
s([
|
|
121
|
+
r({ type: Boolean })
|
|
122
|
+
], a.prototype, "disabled", 2);
|
|
123
|
+
s([
|
|
124
|
+
r({ type: Boolean, attribute: "readonly" })
|
|
125
|
+
], a.prototype, "readOnly", 2);
|
|
126
|
+
s([
|
|
127
|
+
r({ type: String })
|
|
128
|
+
], a.prototype, "value", 2);
|
|
129
|
+
s([
|
|
130
|
+
r({ type: String })
|
|
131
|
+
], a.prototype, "hint", 2);
|
|
132
|
+
s([
|
|
133
|
+
r({ type: String })
|
|
134
|
+
], a.prototype, "checkboxPosition", 2);
|
|
135
|
+
a = s([
|
|
136
|
+
b("gui-checkbox")
|
|
137
|
+
], a);
|
|
138
|
+
typeof customElements < "u" && !customElements.get("gui-checkbox") && customElements.define("gui-checkbox", a);
|
|
139
|
+
var D = Object.defineProperty, P = Object.getOwnPropertyDescriptor, c = (e, t, l, o) => {
|
|
140
|
+
for (var i = o > 1 ? void 0 : o ? P(t, l) : t, d = e.length - 1, h; d >= 0; d--)
|
|
141
|
+
(h = e[d]) && (i = (o ? h(t, l, i) : h(i)) || i);
|
|
142
|
+
return o && i && D(t, l, i), i;
|
|
143
|
+
};
|
|
144
|
+
let n = class extends u {
|
|
145
|
+
constructor() {
|
|
146
|
+
super(...arguments), this.adapter = new g(), this.subscriptions = [];
|
|
147
|
+
}
|
|
148
|
+
createRenderRoot() {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
updated(e) {
|
|
152
|
+
super.updated(e);
|
|
153
|
+
const t = this.adapter.templateData.size;
|
|
154
|
+
t ? this.style.flex = String(t) : this.style.removeProperty("flex");
|
|
155
|
+
}
|
|
156
|
+
connectedCallback() {
|
|
157
|
+
super.connectedCallback(), this.classList.add("gui-checkbox", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
158
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
render() {
|
|
162
|
+
return super.render(), p`
|
|
163
|
+
<gui-checkbox
|
|
164
|
+
.uid=${this.widget.uid}
|
|
165
|
+
.label=${this.adapter.templateData.label}
|
|
166
|
+
.errors=${this.adapter.templateData.errors}
|
|
167
|
+
?touched=${this.adapter.templateData.touched}
|
|
168
|
+
?required=${this.adapter.templateData.validator?.required}
|
|
169
|
+
?disabled=${this.adapter.templateData.disabled}
|
|
170
|
+
?readonly=${this.adapter.templateData.readonly}
|
|
171
|
+
.value=${this.adapter.templateData.value}
|
|
172
|
+
.hint=${this.adapter.templateData.hint}
|
|
173
|
+
.checkboxPosition=${this.adapter.templateData.checkboxPosition}
|
|
174
|
+
@change=${this.valueChanged}
|
|
175
|
+
@blur=${() => this.adapter.onBlur()}
|
|
176
|
+
></gui-checkbox>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
valueChanged(e) {
|
|
180
|
+
const t = e.detail.value;
|
|
181
|
+
this.adapter.valueChanged(t);
|
|
182
|
+
}
|
|
183
|
+
disconnectedCallback() {
|
|
184
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
c([
|
|
188
|
+
x({ context: m }),
|
|
189
|
+
r({ attribute: !1 })
|
|
190
|
+
], n.prototype, "formContext", 2);
|
|
191
|
+
c([
|
|
192
|
+
C({ context: y })
|
|
193
|
+
], n.prototype, "adapter", 2);
|
|
194
|
+
n = c([
|
|
195
|
+
b("gui-checkbox-input")
|
|
196
|
+
], n);
|
|
197
|
+
export {
|
|
198
|
+
n as CheckboxElement
|
|
199
|
+
};
|