@golemui/gui-lit 1.2.0 → 1.2.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 +31 -0
- package/{accordion.element-BIgxl5e9.js → accordion.element-C9GzfKrY.js} +29 -30
- package/alert.element-CHn49Yaf.js +55 -0
- package/button.element-C9fHivSw.js +59 -0
- package/{calendar.element-Cv3RBphf.js → calendar.element-XkojKTJk.js} +30 -31
- package/checkbox.element-DU_tVMXu.js +66 -0
- package/currency.element-BmAH5KS_.js +73 -0
- package/date-picker.element-Bg3rF95F.js +94 -0
- package/{date-time-calendar.element-DlbWZjoe.js → date-time-calendar.element-sywQCeQQ.js} +24 -24
- package/date-time-picker.element-HHpwjWTQ.js +107 -0
- package/{date-time.element-CLLxM2nV.js → date-time.element-ucETvSTC.js} +26 -26
- package/{date.element-B8ZHK9KJ.js → date.element-BEHGxRFF.js} +27 -27
- package/default-list-item-renderer-CuPJ9jUD.js +24 -0
- package/{dropdown.element-DMZ7oL5n.js → dropdown.element-DUqG_p1x.js} +85 -84
- package/{flex.element-DG4Uaj_X.js → flex.element-pwba7621.js} +27 -28
- package/{grid.element-DCZsh-3J.js → grid.element-C8K7_Qi3.js} +29 -30
- package/index.js +1316 -3883
- package/index.umd.cjs +117 -2132
- package/{list.element-ADtUK2na.js → list.element-ZtEMKE2x.js} +41 -40
- package/markdown-text.element-DDm36qD0.js +54 -0
- package/markdown.element-DWz3U9rG.js +84 -0
- package/number.element-VkG5wScD.js +71 -0
- package/package.json +6 -6
- package/password.element-C5vQHq5P.js +72 -0
- package/radiogroup.element-CKdO9HwO.js +69 -0
- package/{range-calendar.element-D5eb2f7p.js → range-calendar.element-BznGrej5.js} +23 -24
- package/{range-date-input.element-C35grlYo.js → range-date-input.element-BloTHRDl.js} +24 -24
- package/range-date-picker.element-DKhwFasW.js +98 -0
- package/{range-date-time-calendar.element-BV0J96Gu.js → range-date-time-calendar.element-CZCET-sb.js} +26 -26
- package/{range-date-time-input.element-CzgRbR9F.js → range-date-time-input.element-Dr2VrYhG.js} +24 -24
- package/range-date-time-picker.element-CYeIMWLp.js +109 -0
- package/{range-time-input.element-BOHLUO8z.js → range-time-input.element-7OZhPQqx.js} +23 -23
- package/range-time-picker.element-D0mRFZkK.js +96 -0
- package/renderer.element-DbsFoBba.js +48 -0
- package/{repeater.element-Da8YN1Vy.js → repeater.element-DGEbwvhY.js} +54 -65
- package/select.element-Bb_9jAVB.js +76 -0
- package/{tabs.element-CvcIA8P3.js → tabs.element-BYDNF_pm.js} +49 -50
- package/tags.element-BSN3i9Gx.js +73 -0
- package/textarea.element-Dl1ZEOqO.js +71 -0
- package/textinput.element-C5Vbbkxq.js +68 -0
- package/{time-picker.element-C3oR0EkQ.js → time-picker.element-Crmj9YDy.js} +26 -26
- package/{time.element-X286nthD.js → time.element-DfSeAZp4.js} +29 -29
- package/toggle.element-ORsprZ2M.js +66 -0
- package/alert.element-DPWq9-0F.js +0 -56
- package/button.element-CJay43iR.js +0 -132
- package/calendar-DleRbmvP.js +0 -267
- package/checkbox.element-CpmrzdH0.js +0 -200
- package/currency.element-Cezgzbbs.js +0 -276
- package/date-DBuYpvcO.js +0 -849
- package/date-input-B3yHsn-g.js +0 -204
- package/date-picker.element-ByZefznr.js +0 -357
- package/date-time-calendar-CB5cNoOX.js +0 -374
- package/date-time-input-DrY68YDX.js +0 -246
- package/date-time-picker.element-CYwmumfq.js +0 -440
- package/day-status-ljexnwEO.js +0 -554
- package/errors-Bs_vYN-_.js +0 -110
- package/focus-leave.controller-2gV0pQd5.js +0 -73
- package/list-D730tmGN.js +0 -297
- package/markdown-text-X-BRJT6K.js +0 -30
- package/markdown-text.element-B8TfVLIO.js +0 -55
- package/markdown.element-D5zcxAUS.js +0 -693
- package/number.element-DEY5tR_y.js +0 -291
- package/numeric-jmOOKz30.js +0 -12
- package/one-of-anKkm7mD.js +0 -50
- package/part-templates-VORbpgs2.js +0 -691
- package/password.element-C1aQh_iz.js +0 -240
- package/pill-ranges-DpvWwP-3.js +0 -48
- package/pills-BDMO2NiR.js +0 -348
- package/popup.controller-B33OvX_y.js +0 -86
- package/radiogroup.element-B2G-XyGx.js +0 -235
- package/range-calendar-D7sG24Kx.js +0 -466
- package/range-commit-8-MmYUyo.js +0 -14
- package/range-date-input-BChaoBC1.js +0 -311
- package/range-date-picker.element-Do5YsL5V.js +0 -434
- package/range-date-time-calendar-DulGK2EQ.js +0 -734
- package/range-date-time-input-8ggqckP7.js +0 -353
- package/range-date-time-picker.element-hi5KdopZ.js +0 -472
- package/range-selection-CU3hxLJE.js +0 -25
- package/range-time-input-D7GFdDeA.js +0 -348
- package/range-time-picker.element-DDNQMA_u.js +0 -470
- package/renderer.element-CNyMn2Lu.js +0 -49
- package/select.element-SDxBhGjz.js +0 -266
- package/tabs-DzSCq_98.js +0 -13
- package/tags.element-Bnhfevp3.js +0 -369
- package/templates-Df7abEkB.js +0 -92
- package/textarea.element-Dx7eYEnl.js +0 -239
- package/textinput.element-BnIoDRmY.js +0 -205
- package/time-input-Kk4EX6at.js +0 -201
- package/time-list-DLcq8BAp.js +0 -217
- package/time-picker-DLj1rhOf.js +0 -299
- package/toggle.element-Dokdat_o.js +0 -203
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { InputWidgetAdapter as m, formContext as y, inputContext as P } from "@golemui/lit";
|
|
2
|
-
import { LitElement as w, nothing as n, html as u } from "lit";
|
|
3
|
-
import { property as o, state as g, customElement as b } from "lit/decorators.js";
|
|
4
|
-
import { classMap as v } from "lit/directives/class-map.js";
|
|
5
|
-
import { G as $, a as f, b as I, c as C } from "./templates-Df7abEkB.js";
|
|
6
|
-
import { consume as D, provide as L } from "@lit/context";
|
|
7
|
-
import "rxjs";
|
|
8
|
-
var S = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, s = (t, a, i, d) => {
|
|
9
|
-
for (var r = d > 1 ? void 0 : d ? _(a, i) : a, l = t.length - 1, h; l >= 0; l--)
|
|
10
|
-
(h = t[l]) && (r = (d ? h(a, i, r) : h(r)) || r);
|
|
11
|
-
return d && r && S(a, i, r), r;
|
|
12
|
-
};
|
|
13
|
-
let e = class extends w {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.hint = void 0, this.icon = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.showPasswordIcon = void 0, this.hidePasswordIcon = void 0, this.showPasswordLabel = void 0, this.hidePasswordLabel = void 0, this.showPassword = !1, this.ariaController = new $(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
|
-
readonly: this.readOnly,
|
|
23
|
-
disabled: this.disabled,
|
|
24
|
-
touched: this.touched,
|
|
25
|
-
required: this.required
|
|
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 t = {
|
|
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
|
-
icon: this.icon,
|
|
49
|
-
placeholder: this.placeholder,
|
|
50
|
-
autocomplete: this.autocomplete,
|
|
51
|
-
showPasswordIcon: this.showPasswordIcon,
|
|
52
|
-
hidePasswordIcon: this.hidePasswordIcon,
|
|
53
|
-
showPasswordLabel: this.showPasswordLabel,
|
|
54
|
-
hidePasswordLabel: this.hidePasswordLabel
|
|
55
|
-
}, a = f("password", t), i = {
|
|
56
|
-
"gui-widget-input": !0,
|
|
57
|
-
"gui-password--icon": !!this.icon
|
|
58
|
-
};
|
|
59
|
-
return u`
|
|
60
|
-
${I(this.uid, t)}
|
|
61
|
-
|
|
62
|
-
<div class="gui-widget">
|
|
63
|
-
<input
|
|
64
|
-
type=${this.showPassword ? "text" : "password"}
|
|
65
|
-
id=${this.uid}
|
|
66
|
-
data-cy=${`${this.uid}_password`}
|
|
67
|
-
class=${v(i)}
|
|
68
|
-
value=${this.value}
|
|
69
|
-
?required=${this.required}
|
|
70
|
-
?disabled=${this.disabled}
|
|
71
|
-
?readonly=${this.readOnly}
|
|
72
|
-
placeholder=${this.placeholder || n}
|
|
73
|
-
autocomplete=${this.autocomplete || n}
|
|
74
|
-
@input=${this.valueChanged}
|
|
75
|
-
@blur=${this.onBlur}
|
|
76
|
-
/>
|
|
77
|
-
${a.html}
|
|
78
|
-
<button
|
|
79
|
-
class=${`gui-password__toggle gui-widget-icon ${this.showPassword && t.showPasswordIcon ? t.showPasswordIcon : ""} ${!this.showPassword && t.hidePasswordIcon ? t.hidePasswordIcon : ""}`}
|
|
80
|
-
data-icon=${this.showPassword ? t.showPasswordIcon : t.hidePasswordIcon}
|
|
81
|
-
type="button"
|
|
82
|
-
?disabled=${this.disabled}
|
|
83
|
-
aria-label=${this.showPassword ? t.hidePasswordLabel ?? "Hide password" : t.showPasswordLabel ?? "Show password"}
|
|
84
|
-
@click=${() => this.showPassword = !this.showPassword}
|
|
85
|
-
>
|
|
86
|
-
${t.showPasswordIcon || t.hidePasswordIcon ? n : u`<span aria-hidden="true"
|
|
87
|
-
>${this.showPassword ? t.hidePasswordLabel ?? "Hide" : t.showPasswordLabel ?? "Show"}</span
|
|
88
|
-
>`}
|
|
89
|
-
</button>
|
|
90
|
-
</div>
|
|
91
|
-
|
|
92
|
-
${C(this.uid, t)}
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
valueChanged(t) {
|
|
96
|
-
if (t.stopPropagation(), !this.readOnly) {
|
|
97
|
-
const a = t.target;
|
|
98
|
-
this.dispatchEvent(
|
|
99
|
-
new CustomEvent("input", {
|
|
100
|
-
detail: { value: a.value },
|
|
101
|
-
bubbles: !0,
|
|
102
|
-
composed: !0
|
|
103
|
-
})
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
onBlur() {
|
|
108
|
-
this.dispatchEvent(
|
|
109
|
-
new CustomEvent("blur", {
|
|
110
|
-
bubbles: !0,
|
|
111
|
-
composed: !0
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
s([
|
|
117
|
-
o({ type: String })
|
|
118
|
-
], e.prototype, "uid", 2);
|
|
119
|
-
s([
|
|
120
|
-
o({ type: String })
|
|
121
|
-
], e.prototype, "label", 2);
|
|
122
|
-
s([
|
|
123
|
-
o({ type: String, attribute: "locale-id" })
|
|
124
|
-
], e.prototype, "localeId", 2);
|
|
125
|
-
s([
|
|
126
|
-
o({ type: Array })
|
|
127
|
-
], e.prototype, "errors", 2);
|
|
128
|
-
s([
|
|
129
|
-
o({ type: Boolean })
|
|
130
|
-
], e.prototype, "touched", 2);
|
|
131
|
-
s([
|
|
132
|
-
o({ type: Boolean })
|
|
133
|
-
], e.prototype, "required", 2);
|
|
134
|
-
s([
|
|
135
|
-
o({ type: Boolean })
|
|
136
|
-
], e.prototype, "disabled", 2);
|
|
137
|
-
s([
|
|
138
|
-
o({ type: Boolean, attribute: "readonly" })
|
|
139
|
-
], e.prototype, "readOnly", 2);
|
|
140
|
-
s([
|
|
141
|
-
o({ type: String })
|
|
142
|
-
], e.prototype, "value", 2);
|
|
143
|
-
s([
|
|
144
|
-
o({ type: String })
|
|
145
|
-
], e.prototype, "hint", 2);
|
|
146
|
-
s([
|
|
147
|
-
o({ type: String })
|
|
148
|
-
], e.prototype, "icon", 2);
|
|
149
|
-
s([
|
|
150
|
-
o({ type: String })
|
|
151
|
-
], e.prototype, "placeholder", 2);
|
|
152
|
-
s([
|
|
153
|
-
o({ type: String })
|
|
154
|
-
], e.prototype, "autocomplete", 2);
|
|
155
|
-
s([
|
|
156
|
-
o({ type: String })
|
|
157
|
-
], e.prototype, "showPasswordIcon", 2);
|
|
158
|
-
s([
|
|
159
|
-
o({ type: String })
|
|
160
|
-
], e.prototype, "hidePasswordIcon", 2);
|
|
161
|
-
s([
|
|
162
|
-
o({ type: String })
|
|
163
|
-
], e.prototype, "showPasswordLabel", 2);
|
|
164
|
-
s([
|
|
165
|
-
o({ type: String })
|
|
166
|
-
], e.prototype, "hidePasswordLabel", 2);
|
|
167
|
-
s([
|
|
168
|
-
g()
|
|
169
|
-
], e.prototype, "showPassword", 2);
|
|
170
|
-
e = s([
|
|
171
|
-
b("gui-password")
|
|
172
|
-
], e);
|
|
173
|
-
typeof customElements < "u" && !customElements.get("gui-password") && customElements.define("gui-password", e);
|
|
174
|
-
var O = Object.defineProperty, x = Object.getOwnPropertyDescriptor, c = (t, a, i, d) => {
|
|
175
|
-
for (var r = d > 1 ? void 0 : d ? x(a, i) : a, l = t.length - 1, h; l >= 0; l--)
|
|
176
|
-
(h = t[l]) && (r = (d ? h(a, i, r) : h(r)) || r);
|
|
177
|
-
return d && r && O(a, i, r), r;
|
|
178
|
-
};
|
|
179
|
-
let p = class extends w {
|
|
180
|
-
constructor() {
|
|
181
|
-
super(...arguments), this.adapter = new m(), this.subscriptions = [];
|
|
182
|
-
}
|
|
183
|
-
createRenderRoot() {
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
updated(t) {
|
|
187
|
-
super.updated(t);
|
|
188
|
-
const a = this.adapter.templateData.size;
|
|
189
|
-
a ? this.style.flex = String(a) : this.style.removeProperty("flex");
|
|
190
|
-
}
|
|
191
|
-
connectedCallback() {
|
|
192
|
-
super.connectedCallback(), this.classList.add("gui-password", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
193
|
-
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
render() {
|
|
197
|
-
return super.render(), u`
|
|
198
|
-
<gui-password
|
|
199
|
-
.uid=${this.widget.uid}
|
|
200
|
-
.label=${this.adapter.templateData.label}
|
|
201
|
-
.hint=${this.adapter.templateData.hint}
|
|
202
|
-
.errors=${this.adapter.templateData.errors}
|
|
203
|
-
?touched=${this.adapter.templateData.touched}
|
|
204
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
205
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
206
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
207
|
-
.value=${this.adapter.templateData.value}
|
|
208
|
-
.icon=${this.adapter.templateData.icon}
|
|
209
|
-
.placeholder=${this.adapter.templateData.placeholder}
|
|
210
|
-
.autocomplete=${this.adapter.templateData.autocomplete}
|
|
211
|
-
.showPasswordIcon=${this.adapter.templateData.showPasswordIcon}
|
|
212
|
-
.hidePasswordIcon=${this.adapter.templateData.hidePasswordIcon}
|
|
213
|
-
.showPasswordLabel=${this.adapter.templateData.showPasswordLabel}
|
|
214
|
-
.hidePasswordLabel=${this.adapter.templateData.hidePasswordLabel}
|
|
215
|
-
@input=${this.valueChanged}
|
|
216
|
-
@blur=${() => this.adapter.onBlur()}
|
|
217
|
-
></gui-password>
|
|
218
|
-
`;
|
|
219
|
-
}
|
|
220
|
-
valueChanged(t) {
|
|
221
|
-
const a = t.detail.value;
|
|
222
|
-
this.adapter.valueChanged(a);
|
|
223
|
-
}
|
|
224
|
-
disconnectedCallback() {
|
|
225
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
c([
|
|
229
|
-
D({ context: y }),
|
|
230
|
-
o({ attribute: !1 })
|
|
231
|
-
], p.prototype, "formContext", 2);
|
|
232
|
-
c([
|
|
233
|
-
L({ context: P })
|
|
234
|
-
], p.prototype, "adapter", 2);
|
|
235
|
-
p = c([
|
|
236
|
-
b("gui-password-input")
|
|
237
|
-
], p);
|
|
238
|
-
export {
|
|
239
|
-
p as PasswordElement
|
|
240
|
-
};
|
package/pill-ranges-DpvWwP-3.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { p as o } from "./date-DBuYpvcO.js";
|
|
2
|
-
function s(t) {
|
|
3
|
-
return `${t.start}-${t.end ?? t.start}`;
|
|
4
|
-
}
|
|
5
|
-
function f(t, n) {
|
|
6
|
-
return !t || !Array.isArray(t) ? [] : [...t].sort((r, e) => n(r.start, e.start));
|
|
7
|
-
}
|
|
8
|
-
function u(t, n) {
|
|
9
|
-
return t.find((r) => s(r) === n);
|
|
10
|
-
}
|
|
11
|
-
function c(t, n) {
|
|
12
|
-
const r = t ?? [], e = u(r, n);
|
|
13
|
-
if (!e) return null;
|
|
14
|
-
const i = r.filter(
|
|
15
|
-
(a) => !(a.start === e.start && (a.end ?? null) === (e.end ?? null))
|
|
16
|
-
);
|
|
17
|
-
return { removed: e, next: i };
|
|
18
|
-
}
|
|
19
|
-
function d(t, n) {
|
|
20
|
-
const r = o(t);
|
|
21
|
-
return isNaN(r.getTime()) ? t : new Intl.DateTimeFormat(n ?? "en", {
|
|
22
|
-
year: "numeric",
|
|
23
|
-
month: "2-digit",
|
|
24
|
-
day: "2-digit"
|
|
25
|
-
}).format(r);
|
|
26
|
-
}
|
|
27
|
-
function m(t, n) {
|
|
28
|
-
const r = n(t.start), e = t.end ? n(t.end) : r;
|
|
29
|
-
return `${r} - ${e}`;
|
|
30
|
-
}
|
|
31
|
-
function y(t, n) {
|
|
32
|
-
return t.map((r) => {
|
|
33
|
-
const e = n(r);
|
|
34
|
-
return {
|
|
35
|
-
key: s(r),
|
|
36
|
-
label: e,
|
|
37
|
-
ariaLabel: e
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
m as a,
|
|
43
|
-
y as b,
|
|
44
|
-
d as c,
|
|
45
|
-
u as f,
|
|
46
|
-
c as r,
|
|
47
|
-
f as s
|
|
48
|
-
};
|
package/pills-BDMO2NiR.js
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import { LitElement as m, nothing as d, html as a } from "lit";
|
|
2
|
-
import { property as l, state as u, customElement as w } from "lit/decorators.js";
|
|
3
|
-
import { classMap as c } from "lit/directives/class-map.js";
|
|
4
|
-
import { repeat as b } from "lit/directives/repeat.js";
|
|
5
|
-
import { c as v } from "./tabs-DzSCq_98.js";
|
|
6
|
-
var y = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, o = (e, t, i, r) => {
|
|
7
|
-
for (var n = r > 1 ? void 0 : r ? _(t, i) : t, p = e.length - 1, h; p >= 0; p--)
|
|
8
|
-
(h = e[p]) && (n = (r ? h(t, i, n) : h(n)) || n);
|
|
9
|
-
return r && n && y(t, i, n), n;
|
|
10
|
-
};
|
|
11
|
-
let s = class extends m {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments), this.uid = void 0, this.items = [], this.clickable = !1, this.removable = !0, this.bubble = !0, this.tabbable = !0, this.disabled = !1, this.readOnly = !1, this.removeAriaLabel = "Remove", this.toolbarAriaLabel = "Selected items", this._isStartVisible = !0, this._isEndVisible = !0, this._showDropdown = !1, this._pendingFocusIndex = null, this.handlePillFocus = (e) => {
|
|
14
|
-
e.target.scrollIntoView({
|
|
15
|
-
behavior: "smooth",
|
|
16
|
-
block: "nearest",
|
|
17
|
-
inline: "nearest"
|
|
18
|
-
});
|
|
19
|
-
}, this.toggleDropdown = () => {
|
|
20
|
-
this._showDropdown ? this.closeDropdown() : this.openDropdown();
|
|
21
|
-
}, this.handleOutsideInteraction = (e) => {
|
|
22
|
-
const t = this.querySelector(".gui-pills__compact"), i = this.querySelector(".gui-pills__dropdown"), r = e.composedPath()[0];
|
|
23
|
-
!t?.contains(r) && !i?.contains(r) && this.closeDropdown();
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
createRenderRoot() {
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
updated(e) {
|
|
30
|
-
if (super.updated(e), this.setupObservers(), this._pendingFocusIndex !== null && e.has("items")) {
|
|
31
|
-
const t = this._pendingFocusIndex;
|
|
32
|
-
this._pendingFocusIndex = null;
|
|
33
|
-
const i = this.items.length;
|
|
34
|
-
if (i === 0) {
|
|
35
|
-
this._showDropdown && this.closeDropdown();
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const r = Math.max(0, Math.min(t, i - 1));
|
|
39
|
-
this.focusPillAt(r);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
disconnectedCallback() {
|
|
43
|
-
super.disconnectedCallback(), this.disconnectObservers(), this.removeOutsideListeners();
|
|
44
|
-
}
|
|
45
|
-
render() {
|
|
46
|
-
const e = this.items.length;
|
|
47
|
-
return e === 0 ? d : a`
|
|
48
|
-
${this.renderStrip()} ${this.bubble ? this.renderCompact(e) : d}
|
|
49
|
-
${this.bubble && this._showDropdown ? this.renderDropdown() : d}
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
renderStrip() {
|
|
53
|
-
return a`
|
|
54
|
-
<div
|
|
55
|
-
class=${c({
|
|
56
|
-
"gui-pills__strip-wrapper": !0,
|
|
57
|
-
"gui-pills--start-shadow": !this._isStartVisible,
|
|
58
|
-
"gui-pills--end-shadow": !this._isEndVisible
|
|
59
|
-
})}
|
|
60
|
-
>
|
|
61
|
-
<div
|
|
62
|
-
class="gui-pills__strip"
|
|
63
|
-
role="toolbar"
|
|
64
|
-
aria-label=${this.toolbarAriaLabel}
|
|
65
|
-
tabindex="-1"
|
|
66
|
-
>
|
|
67
|
-
<span class="gui-sentinel gui-sentinel__start"></span>
|
|
68
|
-
${b(
|
|
69
|
-
this.items,
|
|
70
|
-
(e) => e.key,
|
|
71
|
-
(e, t) => this.renderPill(e, t, !1)
|
|
72
|
-
)}
|
|
73
|
-
<span class="gui-sentinel gui-sentinel__end"></span>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
`;
|
|
77
|
-
}
|
|
78
|
-
get dropdownId() {
|
|
79
|
-
return this.uid ? `${this.uid}_pills_dropdown` : void 0;
|
|
80
|
-
}
|
|
81
|
-
renderCompact(e) {
|
|
82
|
-
return a`
|
|
83
|
-
<div class="gui-pills__compact">
|
|
84
|
-
<button
|
|
85
|
-
type="button"
|
|
86
|
-
class="gui-pills__count"
|
|
87
|
-
aria-label=${this.compactAriaLabel ?? `${e} items`}
|
|
88
|
-
aria-haspopup="true"
|
|
89
|
-
aria-expanded=${this._showDropdown}
|
|
90
|
-
aria-controls=${this.dropdownId ?? d}
|
|
91
|
-
?disabled=${this.disabled || this.readOnly}
|
|
92
|
-
@click=${(t) => {
|
|
93
|
-
t.stopPropagation(), this.toggleDropdown();
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
${e}
|
|
97
|
-
</button>
|
|
98
|
-
</div>
|
|
99
|
-
`;
|
|
100
|
-
}
|
|
101
|
-
renderDropdown() {
|
|
102
|
-
return a`
|
|
103
|
-
<div
|
|
104
|
-
id=${this.dropdownId ?? d}
|
|
105
|
-
class="gui-pills__dropdown"
|
|
106
|
-
role="toolbar"
|
|
107
|
-
aria-orientation="vertical"
|
|
108
|
-
aria-label=${this.toolbarAriaLabel}
|
|
109
|
-
>
|
|
110
|
-
${b(
|
|
111
|
-
this.items,
|
|
112
|
-
(e) => `dd-${e.key}`,
|
|
113
|
-
(e, t) => this.renderPill(e, t, !0)
|
|
114
|
-
)}
|
|
115
|
-
</div>
|
|
116
|
-
`;
|
|
117
|
-
}
|
|
118
|
-
renderPill(e, t, i) {
|
|
119
|
-
const r = this.clickable && !this.disabled && !this.readOnly;
|
|
120
|
-
return a`
|
|
121
|
-
<button
|
|
122
|
-
type="button"
|
|
123
|
-
class=${c({
|
|
124
|
-
"gui-pills__pill": !0,
|
|
125
|
-
"gui-pills__pill--clickable": r
|
|
126
|
-
})}
|
|
127
|
-
data-key=${e.key}
|
|
128
|
-
data-index=${t}
|
|
129
|
-
data-in-dropdown=${i}
|
|
130
|
-
tabindex=${this.tabbable && !this.disabled && !this.readOnly ? 0 : -1}
|
|
131
|
-
?disabled=${this.disabled || this.readOnly}
|
|
132
|
-
aria-label=${e.ariaLabel ?? e.label}
|
|
133
|
-
aria-description=${this.removable && !this.disabled && !this.readOnly ? this.removeAriaLabel : d}
|
|
134
|
-
@click=${(n) => this.onPillClick(n, e)}
|
|
135
|
-
@focus=${this.handlePillFocus}
|
|
136
|
-
@keydown=${(n) => this.onPillKeydown(n, e, t)}
|
|
137
|
-
>
|
|
138
|
-
<span class="gui-pills__pill-text">${e.label}</span>
|
|
139
|
-
${this.removable ? this.renderRemoveButton(e) : d}
|
|
140
|
-
</button>
|
|
141
|
-
`;
|
|
142
|
-
}
|
|
143
|
-
renderRemoveButton(e) {
|
|
144
|
-
return a`
|
|
145
|
-
<span
|
|
146
|
-
class="gui-pills__pill-remove"
|
|
147
|
-
aria-hidden="true"
|
|
148
|
-
@mousedown=${(t) => {
|
|
149
|
-
t.stopPropagation(), t.preventDefault();
|
|
150
|
-
}}
|
|
151
|
-
@click=${(t) => {
|
|
152
|
-
t.stopPropagation(), this.emitRemove(e.key, this.items.indexOf(e));
|
|
153
|
-
}}
|
|
154
|
-
>
|
|
155
|
-
${this.removeIcon ? a`<span
|
|
156
|
-
class=${`gui-widget-icon ${this.removeIcon}`}
|
|
157
|
-
data-icon=${this.removeIcon}
|
|
158
|
-
aria-hidden="true"
|
|
159
|
-
></span>` : a`<svg
|
|
160
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
161
|
-
width="16"
|
|
162
|
-
height="16"
|
|
163
|
-
viewBox="0 0 256 256"
|
|
164
|
-
fill="currentColor"
|
|
165
|
-
aria-hidden="true"
|
|
166
|
-
>
|
|
167
|
-
<path
|
|
168
|
-
d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"
|
|
169
|
-
></path>
|
|
170
|
-
</svg>`}
|
|
171
|
-
</span>
|
|
172
|
-
`;
|
|
173
|
-
}
|
|
174
|
-
onPillClick(e, t) {
|
|
175
|
-
!this.clickable || this.disabled || this.readOnly || (e.stopPropagation(), this.dispatchEvent(
|
|
176
|
-
new CustomEvent("pillclick", {
|
|
177
|
-
detail: { key: t.key },
|
|
178
|
-
bubbles: !0,
|
|
179
|
-
composed: !0
|
|
180
|
-
})
|
|
181
|
-
));
|
|
182
|
-
}
|
|
183
|
-
onPillKeydown(e, t, i) {
|
|
184
|
-
if (this.disabled || this.readOnly) {
|
|
185
|
-
this.emitKeydown(t.key, e);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (this.removable && (e.key === "Delete" || e.key === "Backspace")) {
|
|
189
|
-
e.preventDefault(), e.stopPropagation(), this.emitRemove(t.key, i);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if ((e.key === "Enter" || e.key === " ") && this.clickable) {
|
|
193
|
-
e.preventDefault(), this.dispatchEvent(
|
|
194
|
-
new CustomEvent("pillclick", {
|
|
195
|
-
detail: { key: t.key },
|
|
196
|
-
bubbles: !0,
|
|
197
|
-
composed: !0
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const r = this._showDropdown, n = r ? "ArrowUp" : "ArrowLeft", p = r ? "ArrowDown" : "ArrowRight";
|
|
203
|
-
if (e.key === n) {
|
|
204
|
-
i > 0 ? (e.preventDefault(), this.focusPillAt(i - 1)) : this.emitKeydown(t.key, e);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (e.key === p) {
|
|
208
|
-
i < this.items.length - 1 ? (e.preventDefault(), this.focusPillAt(i + 1)) : this.emitKeydown(t.key, e);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (e.key === "Home") {
|
|
212
|
-
e.preventDefault(), this.focusPillAt(0);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (e.key === "End") {
|
|
216
|
-
e.preventDefault(), this.focusPillAt(this.items.length - 1);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (e.key === "Escape" && r) {
|
|
220
|
-
e.preventDefault(), e.stopPropagation(), this.closeDropdown();
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
this.emitKeydown(t.key, e);
|
|
224
|
-
}
|
|
225
|
-
emitRemove(e, t) {
|
|
226
|
-
this._pendingFocusIndex = t, this.dispatchEvent(
|
|
227
|
-
new CustomEvent("pillremove", {
|
|
228
|
-
detail: { key: e },
|
|
229
|
-
bubbles: !0,
|
|
230
|
-
composed: !0
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
emitKeydown(e, t) {
|
|
235
|
-
this.dispatchEvent(
|
|
236
|
-
new CustomEvent("pillkeydown", {
|
|
237
|
-
detail: { key: e, event: t },
|
|
238
|
-
bubbles: !0,
|
|
239
|
-
composed: !0
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
// ─── Focus ───────────────────────────────────────────────────────────────
|
|
244
|
-
/**
|
|
245
|
-
* Programmatically focus the pill at the given index. In dropdown mode,
|
|
246
|
-
* focuses the corresponding pill in the dropdown overlay; otherwise in the
|
|
247
|
-
* strip. Useful for hosts that want to "enter" the pill list from outside
|
|
248
|
-
* (e.g. tags' ArrowLeft from the input).
|
|
249
|
-
*/
|
|
250
|
-
focusPillAt(e) {
|
|
251
|
-
requestAnimationFrame(() => {
|
|
252
|
-
const t = this._showDropdown ? ".gui-pills__dropdown .gui-pills__pill" : ".gui-pills__strip .gui-pills__pill", i = this.querySelectorAll(t);
|
|
253
|
-
if (i.length === 0) return;
|
|
254
|
-
const r = Math.max(0, Math.min(e, i.length - 1));
|
|
255
|
-
i[r].focus();
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
/** Open the dropdown and focus its first pill. No-op if `bubble` is false. */
|
|
259
|
-
openDropdown() {
|
|
260
|
-
!this.bubble || this.disabled || this.readOnly || this._showDropdown || (this._showDropdown = !0, this.dispatchEvent(
|
|
261
|
-
new CustomEvent("dropdowntoggle", {
|
|
262
|
-
detail: { open: !0 },
|
|
263
|
-
bubbles: !0,
|
|
264
|
-
composed: !0
|
|
265
|
-
})
|
|
266
|
-
), requestAnimationFrame(() => {
|
|
267
|
-
this.addOutsideListeners(), this.querySelector(".gui-pills__dropdown .gui-pills__pill")?.focus();
|
|
268
|
-
}));
|
|
269
|
-
}
|
|
270
|
-
closeDropdown() {
|
|
271
|
-
this._showDropdown && (this._showDropdown = !1, this.removeOutsideListeners(), this.dispatchEvent(
|
|
272
|
-
new CustomEvent("dropdowntoggle", {
|
|
273
|
-
detail: { open: !1 },
|
|
274
|
-
bubbles: !0,
|
|
275
|
-
composed: !0
|
|
276
|
-
})
|
|
277
|
-
));
|
|
278
|
-
}
|
|
279
|
-
addOutsideListeners() {
|
|
280
|
-
document.addEventListener("pointerdown", this.handleOutsideInteraction), document.addEventListener("focusin", this.handleOutsideInteraction);
|
|
281
|
-
}
|
|
282
|
-
removeOutsideListeners() {
|
|
283
|
-
document.removeEventListener("pointerdown", this.handleOutsideInteraction), document.removeEventListener("focusin", this.handleOutsideInteraction);
|
|
284
|
-
}
|
|
285
|
-
// ─── Observers ───────────────────────────────────────────────────────────
|
|
286
|
-
setupObservers() {
|
|
287
|
-
const e = this.querySelector(".gui-sentinel__start"), t = this.querySelector(".gui-sentinel__end");
|
|
288
|
-
e && !this.startObserver && (this.startObserver = v(
|
|
289
|
-
e,
|
|
290
|
-
(i) => this._isStartVisible = i
|
|
291
|
-
)), t && !this.endObserver && (this.endObserver = v(
|
|
292
|
-
t,
|
|
293
|
-
(i) => this._isEndVisible = i
|
|
294
|
-
)), !e && this.startObserver && (this.startObserver.disconnect(), this.startObserver = void 0, this._isStartVisible = !0), !t && this.endObserver && (this.endObserver.disconnect(), this.endObserver = void 0, this._isEndVisible = !0);
|
|
295
|
-
}
|
|
296
|
-
disconnectObservers() {
|
|
297
|
-
this.startObserver?.disconnect(), this.endObserver?.disconnect(), this.startObserver = void 0, this.endObserver = void 0;
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
o([
|
|
301
|
-
l({ type: String })
|
|
302
|
-
], s.prototype, "uid", 2);
|
|
303
|
-
o([
|
|
304
|
-
l({ type: Array })
|
|
305
|
-
], s.prototype, "items", 2);
|
|
306
|
-
o([
|
|
307
|
-
l({ type: Boolean })
|
|
308
|
-
], s.prototype, "clickable", 2);
|
|
309
|
-
o([
|
|
310
|
-
l({ type: Boolean })
|
|
311
|
-
], s.prototype, "removable", 2);
|
|
312
|
-
o([
|
|
313
|
-
l({ type: Boolean })
|
|
314
|
-
], s.prototype, "bubble", 2);
|
|
315
|
-
o([
|
|
316
|
-
l({ type: Boolean })
|
|
317
|
-
], s.prototype, "tabbable", 2);
|
|
318
|
-
o([
|
|
319
|
-
l({ type: Boolean })
|
|
320
|
-
], s.prototype, "disabled", 2);
|
|
321
|
-
o([
|
|
322
|
-
l({ type: Boolean, attribute: "readonly" })
|
|
323
|
-
], s.prototype, "readOnly", 2);
|
|
324
|
-
o([
|
|
325
|
-
l({ type: String, attribute: "remove-aria-label" })
|
|
326
|
-
], s.prototype, "removeAriaLabel", 2);
|
|
327
|
-
o([
|
|
328
|
-
l({ type: String, attribute: "remove-icon" })
|
|
329
|
-
], s.prototype, "removeIcon", 2);
|
|
330
|
-
o([
|
|
331
|
-
l({ type: String, attribute: "compact-aria-label" })
|
|
332
|
-
], s.prototype, "compactAriaLabel", 2);
|
|
333
|
-
o([
|
|
334
|
-
l({ type: String, attribute: "toolbar-aria-label" })
|
|
335
|
-
], s.prototype, "toolbarAriaLabel", 2);
|
|
336
|
-
o([
|
|
337
|
-
u()
|
|
338
|
-
], s.prototype, "_isStartVisible", 2);
|
|
339
|
-
o([
|
|
340
|
-
u()
|
|
341
|
-
], s.prototype, "_isEndVisible", 2);
|
|
342
|
-
o([
|
|
343
|
-
u()
|
|
344
|
-
], s.prototype, "_showDropdown", 2);
|
|
345
|
-
s = o([
|
|
346
|
-
w("gui-pills")
|
|
347
|
-
], s);
|
|
348
|
-
typeof customElements < "u" && !customElements.get("gui-pills") && customElements.define("gui-pills", s);
|