@golemui/gui-lit 1.2.0 → 1.2.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -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,266 +0,0 @@
|
|
|
1
|
-
import { InputWidgetAdapter as m, formContext as b, inputContext as y } from "@golemui/lit";
|
|
2
|
-
import { LitElement as v, html as n, nothing as u } from "lit";
|
|
3
|
-
import { repeat as f } from "lit-html/directives/repeat.js";
|
|
4
|
-
import { property as a, customElement as g } from "lit/decorators.js";
|
|
5
|
-
import { classMap as $ } from "lit/directives/class-map.js";
|
|
6
|
-
import { G as C, a as D, b as w, c as O } from "./templates-Df7abEkB.js";
|
|
7
|
-
import { u as E, i as S } from "./one-of-anKkm7mD.js";
|
|
8
|
-
import { consume as F, provide as _ } from "@lit/context";
|
|
9
|
-
import "rxjs";
|
|
10
|
-
var x = Object.defineProperty, q = Object.getOwnPropertyDescriptor, s = (e, i, r, l) => {
|
|
11
|
-
for (var o = l > 1 ? void 0 : l ? q(i, r) : i, d = e.length - 1, p; d >= 0; d--)
|
|
12
|
-
(p = e[d]) && (o = (l ? p(i, r, o) : p(o)) || o);
|
|
13
|
-
return l && o && x(i, r, o), o;
|
|
14
|
-
};
|
|
15
|
-
let t = class extends v {
|
|
16
|
-
constructor() {
|
|
17
|
-
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.autocomplete = void 0, this.options = [], this.placeholder = void 0, this.invalidOptionMessage = void 0, this.labelField = void 0, this.valueField = void 0, this.optionsLoading = !1, this.hasMatchingValue = !1, this.ariaController = new C(this, {
|
|
18
|
-
getTargets: () => this.querySelectorAll(`select[id="${this.uid}"]`),
|
|
19
|
-
getState: () => ({
|
|
20
|
-
uid: this.uid,
|
|
21
|
-
templateData: {
|
|
22
|
-
hint: this.hint,
|
|
23
|
-
errors: this.errors,
|
|
24
|
-
readonly: this.readOnly,
|
|
25
|
-
disabled: this.disabled,
|
|
26
|
-
touched: this.touched,
|
|
27
|
-
required: this.required
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
createRenderRoot() {
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
connectedCallback() {
|
|
36
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
37
|
-
}
|
|
38
|
-
render() {
|
|
39
|
-
super.render();
|
|
40
|
-
const e = {
|
|
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
|
-
hint: this.hint,
|
|
50
|
-
icon: this.icon,
|
|
51
|
-
autocomplete: this.autocomplete,
|
|
52
|
-
options: this.options,
|
|
53
|
-
placeholder: this.placeholder,
|
|
54
|
-
labelField: this.labelField,
|
|
55
|
-
valueField: this.valueField
|
|
56
|
-
}, i = D("select", e);
|
|
57
|
-
this.options = E(this.options, {
|
|
58
|
-
labelField: this.labelField,
|
|
59
|
-
valueField: this.valueField
|
|
60
|
-
}), this.hasMatchingValue = this.options?.length ? this.options.find(({ value: l }) => l === this.value) !== void 0 : !1;
|
|
61
|
-
const r = this.optionsLoading ? n`<span>Loading...</span>` : n`
|
|
62
|
-
<option value="" disabled selected=${this.hasMatchingValue ? u : ""}>
|
|
63
|
-
${this.placeholder ?? "Select an option"}
|
|
64
|
-
</option>
|
|
65
|
-
${f(
|
|
66
|
-
this.options || [],
|
|
67
|
-
(l) => l?.value,
|
|
68
|
-
(l) => n`<option
|
|
69
|
-
value=${l.value}
|
|
70
|
-
selected=${this.hasMatchingValue && l.value === this.value ? "" : u}
|
|
71
|
-
>
|
|
72
|
-
${l.label}
|
|
73
|
-
</option>`
|
|
74
|
-
)}
|
|
75
|
-
`;
|
|
76
|
-
return n`
|
|
77
|
-
${w(this.uid, e)}
|
|
78
|
-
|
|
79
|
-
<div class="gui-widget">
|
|
80
|
-
<select
|
|
81
|
-
id=${this.uid}
|
|
82
|
-
data-cy=${`${this.uid}_select`}
|
|
83
|
-
class=${$({ "gui-widget-input": !0, ...i.widgetClasses })}
|
|
84
|
-
?required=${e.required}
|
|
85
|
-
?disabled=${e.disabled || e.readonly}
|
|
86
|
-
autocomplete=${this.autocomplete || u}
|
|
87
|
-
@change=${this.valueChanged}
|
|
88
|
-
@blur=${this.onBlur}
|
|
89
|
-
>
|
|
90
|
-
${r}
|
|
91
|
-
</select>
|
|
92
|
-
<span class="gui-select__arrow"
|
|
93
|
-
><svg
|
|
94
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
95
|
-
width="16"
|
|
96
|
-
height="16"
|
|
97
|
-
viewBox="0 0 256 256"
|
|
98
|
-
aria-hidden="true"
|
|
99
|
-
>
|
|
100
|
-
<path
|
|
101
|
-
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"
|
|
102
|
-
></path></svg
|
|
103
|
-
></span>
|
|
104
|
-
${i.html}
|
|
105
|
-
</div>
|
|
106
|
-
|
|
107
|
-
${O(this.uid, e)}
|
|
108
|
-
`;
|
|
109
|
-
}
|
|
110
|
-
updated(e) {
|
|
111
|
-
e.has("value") && !this.hasMatchingValue && this.value && this.dispatchEvent(
|
|
112
|
-
new CustomEvent("inputError", {
|
|
113
|
-
detail: {
|
|
114
|
-
message: (this.invalidOptionMessage ?? "Invalid selection: '{value}' is not a valid option.").replace("{value}", String(this.value))
|
|
115
|
-
},
|
|
116
|
-
bubbles: !0
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
valueChanged(e) {
|
|
121
|
-
if (e.stopPropagation(), !this.readOnly) {
|
|
122
|
-
const i = e.target;
|
|
123
|
-
this.dispatchEvent(
|
|
124
|
-
new CustomEvent("change", {
|
|
125
|
-
detail: { value: S(i.value, this.options) },
|
|
126
|
-
bubbles: !0,
|
|
127
|
-
composed: !0
|
|
128
|
-
})
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
onBlur() {
|
|
133
|
-
this.dispatchEvent(
|
|
134
|
-
new CustomEvent("blur", {
|
|
135
|
-
bubbles: !0,
|
|
136
|
-
composed: !0
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
s([
|
|
142
|
-
a({ type: String })
|
|
143
|
-
], t.prototype, "uid", 2);
|
|
144
|
-
s([
|
|
145
|
-
a({ type: String })
|
|
146
|
-
], t.prototype, "label", 2);
|
|
147
|
-
s([
|
|
148
|
-
a({ type: String, attribute: "locale-id" })
|
|
149
|
-
], t.prototype, "localeId", 2);
|
|
150
|
-
s([
|
|
151
|
-
a({ type: Array })
|
|
152
|
-
], t.prototype, "errors", 2);
|
|
153
|
-
s([
|
|
154
|
-
a({ type: Boolean })
|
|
155
|
-
], t.prototype, "touched", 2);
|
|
156
|
-
s([
|
|
157
|
-
a({ type: Boolean })
|
|
158
|
-
], t.prototype, "required", 2);
|
|
159
|
-
s([
|
|
160
|
-
a({ type: Boolean })
|
|
161
|
-
], t.prototype, "disabled", 2);
|
|
162
|
-
s([
|
|
163
|
-
a({ type: Boolean, attribute: "readonly" })
|
|
164
|
-
], t.prototype, "readOnly", 2);
|
|
165
|
-
s([
|
|
166
|
-
a({ type: String })
|
|
167
|
-
], t.prototype, "value", 2);
|
|
168
|
-
s([
|
|
169
|
-
a({ type: String })
|
|
170
|
-
], t.prototype, "hint", 2);
|
|
171
|
-
s([
|
|
172
|
-
a({ type: String })
|
|
173
|
-
], t.prototype, "icon", 2);
|
|
174
|
-
s([
|
|
175
|
-
a({ type: String })
|
|
176
|
-
], t.prototype, "autocomplete", 2);
|
|
177
|
-
s([
|
|
178
|
-
a({ type: Array })
|
|
179
|
-
], t.prototype, "options", 2);
|
|
180
|
-
s([
|
|
181
|
-
a({ type: String })
|
|
182
|
-
], t.prototype, "placeholder", 2);
|
|
183
|
-
s([
|
|
184
|
-
a({ type: String, attribute: "invalid-option-message" })
|
|
185
|
-
], t.prototype, "invalidOptionMessage", 2);
|
|
186
|
-
s([
|
|
187
|
-
a({ type: String })
|
|
188
|
-
], t.prototype, "labelField", 2);
|
|
189
|
-
s([
|
|
190
|
-
a({ type: String })
|
|
191
|
-
], t.prototype, "valueField", 2);
|
|
192
|
-
t = s([
|
|
193
|
-
g("gui-select")
|
|
194
|
-
], t);
|
|
195
|
-
typeof customElements < "u" && !customElements.get("gui-select") && customElements.define("gui-select", t);
|
|
196
|
-
var M = Object.defineProperty, I = Object.getOwnPropertyDescriptor, c = (e, i, r, l) => {
|
|
197
|
-
for (var o = l > 1 ? void 0 : l ? I(i, r) : i, d = e.length - 1, p; d >= 0; d--)
|
|
198
|
-
(p = e[d]) && (o = (l ? p(i, r, o) : p(o)) || o);
|
|
199
|
-
return l && o && M(i, r, o), o;
|
|
200
|
-
};
|
|
201
|
-
let h = class extends v {
|
|
202
|
-
constructor() {
|
|
203
|
-
super(...arguments), this.adapter = new m(), this.subscriptions = [];
|
|
204
|
-
}
|
|
205
|
-
createRenderRoot() {
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
updated(e) {
|
|
209
|
-
super.updated(e);
|
|
210
|
-
const i = this.adapter.templateData.size;
|
|
211
|
-
i ? this.style.flex = String(i) : this.style.removeProperty("flex");
|
|
212
|
-
}
|
|
213
|
-
connectedCallback() {
|
|
214
|
-
super.connectedCallback(), this.classList.add("gui-select", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
215
|
-
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
render() {
|
|
219
|
-
return super.render(), n`
|
|
220
|
-
<gui-select
|
|
221
|
-
.uid=${this.widget.uid}
|
|
222
|
-
.label=${this.adapter.templateData.label}
|
|
223
|
-
.errors=${this.adapter.templateData.errors}
|
|
224
|
-
?touched=${this.adapter.templateData.touched}
|
|
225
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
226
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
227
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
228
|
-
.value=${this.adapter.templateData.value}
|
|
229
|
-
.hint=${this.adapter.templateData.hint}
|
|
230
|
-
.icon=${this.adapter.templateData.icon}
|
|
231
|
-
.placeholder=${this.adapter.templateData.placeholder}
|
|
232
|
-
.autocomplete=${this.adapter.templateData.autocomplete}
|
|
233
|
-
.options=${this.adapter.templateData.options}
|
|
234
|
-
.labelField=${this.adapter.templateData.labelField}
|
|
235
|
-
.valueField=${this.adapter.templateData.valueField}
|
|
236
|
-
.invalidOptionMessage=${this.adapter.templateData.invalidOptionMessage}
|
|
237
|
-
@change=${this.valueChanged}
|
|
238
|
-
@inputError=${this.onInputError}
|
|
239
|
-
@blur=${() => this.adapter.onBlur()}
|
|
240
|
-
></gui-select>
|
|
241
|
-
`;
|
|
242
|
-
}
|
|
243
|
-
valueChanged(e) {
|
|
244
|
-
const i = e.detail.value;
|
|
245
|
-
this.adapter.valueChanged(i);
|
|
246
|
-
}
|
|
247
|
-
onInputError(e) {
|
|
248
|
-
this.adapter.injectValidationIssues([e.detail.message]);
|
|
249
|
-
}
|
|
250
|
-
disconnectedCallback() {
|
|
251
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
c([
|
|
255
|
-
F({ context: b }),
|
|
256
|
-
a({ attribute: !1 })
|
|
257
|
-
], h.prototype, "formContext", 2);
|
|
258
|
-
c([
|
|
259
|
-
_({ context: y })
|
|
260
|
-
], h.prototype, "adapter", 2);
|
|
261
|
-
h = c([
|
|
262
|
-
g("gui-select-input")
|
|
263
|
-
], h);
|
|
264
|
-
export {
|
|
265
|
-
h as SelectElement
|
|
266
|
-
};
|
package/tabs-DzSCq_98.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function c(e, t, n) {
|
|
2
|
-
if (!e)
|
|
3
|
-
throw new TypeError("The element provided to the IntersectionObserver must exist");
|
|
4
|
-
const r = new IntersectionObserver((s) => {
|
|
5
|
-
s.forEach((o) => {
|
|
6
|
-
t(o.isIntersecting);
|
|
7
|
-
});
|
|
8
|
-
}, n);
|
|
9
|
-
return r.observe(e), r;
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
c
|
|
13
|
-
};
|
package/tags.element-Bnhfevp3.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import { InputWidgetAdapter as D, formContext as w, inputContext as C } from "@golemui/lit";
|
|
2
|
-
import { LitElement as y, nothing as c, html as m } from "lit";
|
|
3
|
-
import { property as o, customElement as b } from "lit/decorators.js";
|
|
4
|
-
import { classMap as f } from "lit/directives/class-map.js";
|
|
5
|
-
import { G as A, b as P, c as S } from "./templates-Df7abEkB.js";
|
|
6
|
-
import "./pills-BDMO2NiR.js";
|
|
7
|
-
import { styleMap as _ } from "lit-html/directives/style-map.js";
|
|
8
|
-
import { consume as E, provide as L } from "@lit/context";
|
|
9
|
-
import "rxjs";
|
|
10
|
-
var O = Object.defineProperty, I = Object.getOwnPropertyDescriptor, n = (t, e, r, a) => {
|
|
11
|
-
for (var i = a > 1 ? void 0 : a ? I(e, r) : e, s = t.length - 1, p; s >= 0; s--)
|
|
12
|
-
(p = t[s]) && (i = (a ? p(e, r, i) : p(i)) || i);
|
|
13
|
-
return a && i && O(e, r, i), i;
|
|
14
|
-
};
|
|
15
|
-
const x = ["Enter", ",", "Tab", "blur"];
|
|
16
|
-
let l = class extends y {
|
|
17
|
-
constructor() {
|
|
18
|
-
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 = [], this.hint = void 0, this.placeholder = void 0, this.icon = void 0, this.separators = void 0, this.allowDuplicates = !0, this.trim = !0, this.limit = void 0, this.removeAriaLabel = void 0, this.removeIcon = void 0, this.ariaController = new A(this, {
|
|
19
|
-
getTargets: () => this.querySelectorAll(".gui-tags-input"),
|
|
20
|
-
getState: () => ({
|
|
21
|
-
uid: this.uid,
|
|
22
|
-
templateData: {
|
|
23
|
-
hint: this.hint,
|
|
24
|
-
errors: this.errors,
|
|
25
|
-
readonly: this.readOnly,
|
|
26
|
-
disabled: this.disabled,
|
|
27
|
-
touched: this.touched,
|
|
28
|
-
required: this.required
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
}), this.onPillRemove = (t) => {
|
|
32
|
-
if (this.disabled || this.readOnly) return;
|
|
33
|
-
const e = this.getValue(), r = e.findIndex((i, s) => this.pillKey(i, s) === t.detail.key);
|
|
34
|
-
if (r < 0) return;
|
|
35
|
-
const a = e.filter((i, s) => s !== r);
|
|
36
|
-
this.emitChange(a), a.length === 0 && requestAnimationFrame(() => this.focusInput());
|
|
37
|
-
}, this.onPillKeydown = (t) => {
|
|
38
|
-
t.detail.event.key === "ArrowRight" && !this.isDropdownOpen() && this.focusInput();
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
createRenderRoot() {
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
connectedCallback() {
|
|
45
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
46
|
-
}
|
|
47
|
-
getSeparators() {
|
|
48
|
-
return this.separators && this.separators.length > 0 ? this.separators : x;
|
|
49
|
-
}
|
|
50
|
-
getValue() {
|
|
51
|
-
return Array.isArray(this.value) ? this.value : [];
|
|
52
|
-
}
|
|
53
|
-
getRemoveAriaLabel() {
|
|
54
|
-
return this.removeAriaLabel ?? "Remove tag";
|
|
55
|
-
}
|
|
56
|
-
pillKey(t, e) {
|
|
57
|
-
return `${e}-${t}`;
|
|
58
|
-
}
|
|
59
|
-
render() {
|
|
60
|
-
const t = this.getValue(), e = {
|
|
61
|
-
uid: this.uid,
|
|
62
|
-
label: this.label,
|
|
63
|
-
hint: this.hint,
|
|
64
|
-
errors: this.errors,
|
|
65
|
-
touched: this.touched,
|
|
66
|
-
required: this.required,
|
|
67
|
-
disabled: this.disabled,
|
|
68
|
-
readonly: this.readOnly,
|
|
69
|
-
placeholder: this.placeholder,
|
|
70
|
-
icon: this.icon
|
|
71
|
-
}, r = {
|
|
72
|
-
"gui-widget-icon": !0,
|
|
73
|
-
[this.icon]: !!this.icon
|
|
74
|
-
}, a = t.map((i, s) => ({
|
|
75
|
-
key: this.pillKey(i, s),
|
|
76
|
-
label: i
|
|
77
|
-
}));
|
|
78
|
-
return m`
|
|
79
|
-
${this.label ? P(this.uid, e, !1, void 0, !1) : c}
|
|
80
|
-
|
|
81
|
-
<div class="gui-widget">
|
|
82
|
-
<div
|
|
83
|
-
class=${f({
|
|
84
|
-
"gui-widget-input": !0,
|
|
85
|
-
"gui-tags-input": !0,
|
|
86
|
-
"gui-tags-input--icon": !!this.icon
|
|
87
|
-
})}
|
|
88
|
-
role="group"
|
|
89
|
-
aria-label=${this.label ?? "Tags input"}
|
|
90
|
-
>
|
|
91
|
-
${this.icon ? m`<span
|
|
92
|
-
class=${f(r)}
|
|
93
|
-
data-icon=${this.icon}
|
|
94
|
-
aria-hidden="true"
|
|
95
|
-
></span>` : c}
|
|
96
|
-
|
|
97
|
-
<gui-pills
|
|
98
|
-
class="gui-tags__pills"
|
|
99
|
-
style=${_(a.length ? {} : { "min-width": 0 })}
|
|
100
|
-
.uid=${this.uid}
|
|
101
|
-
.toolbarAriaLabel=${"Selected tags"}
|
|
102
|
-
.items=${a}
|
|
103
|
-
.removable=${!0}
|
|
104
|
-
.clickable=${!1}
|
|
105
|
-
.bubble=${!0}
|
|
106
|
-
.tabbable=${!1}
|
|
107
|
-
?disabled=${this.disabled}
|
|
108
|
-
?readonly=${this.readOnly}
|
|
109
|
-
.removeAriaLabel=${this.getRemoveAriaLabel()}
|
|
110
|
-
.removeIcon=${this.removeIcon}
|
|
111
|
-
.compactAriaLabel=${`${t.length} tags`}
|
|
112
|
-
@pillremove=${this.onPillRemove}
|
|
113
|
-
@pillkeydown=${this.onPillKeydown}
|
|
114
|
-
></gui-pills>
|
|
115
|
-
|
|
116
|
-
<input
|
|
117
|
-
type="text"
|
|
118
|
-
id=${this.uid}
|
|
119
|
-
data-cy=${`${this.uid}_tags-input`}
|
|
120
|
-
class="gui-tags__input"
|
|
121
|
-
?disabled=${this.disabled}
|
|
122
|
-
?readonly=${this.readOnly}
|
|
123
|
-
placeholder=${this.placeholder || c}
|
|
124
|
-
@keydown=${this.onInputKeydown}
|
|
125
|
-
@blur=${this.onInputBlur}
|
|
126
|
-
@paste=${this.onPaste}
|
|
127
|
-
@change=${(i) => i.stopPropagation()}
|
|
128
|
-
/>
|
|
129
|
-
</div>
|
|
130
|
-
|
|
131
|
-
${S(this.uid, e)}
|
|
132
|
-
</div>
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
onInputKeydown(t) {
|
|
136
|
-
if (this.disabled || this.readOnly) return;
|
|
137
|
-
const e = t.target, r = this.getSeparators(), a = e.value, i = e.selectionStart === 0 && e.selectionEnd === 0;
|
|
138
|
-
if (t.key === "Enter" && r.includes("Enter")) {
|
|
139
|
-
t.preventDefault(), this.commitDraft(a) && (e.value = "");
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (t.key === "," && r.includes(",")) {
|
|
143
|
-
t.preventDefault(), this.commitDraft(a) && (e.value = "");
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (t.key === "Tab" && r.includes("Tab") && a.length > 0) {
|
|
147
|
-
this.commitDraft(a) && (e.value = "");
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (t.key === "Escape") {
|
|
151
|
-
t.preventDefault(), e.value = "";
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const s = this.getValue(), p = this.isCompactMode();
|
|
155
|
-
if (t.key === "ArrowDown" && p && s.length > 0) {
|
|
156
|
-
t.preventDefault(), this.enterPillList(0);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (t.key === "ArrowLeft" && !p && i && s.length > 0) {
|
|
160
|
-
t.preventDefault(), this.enterPillList(s.length - 1);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (t.key === "Backspace" && a === "" && s.length > 0) {
|
|
164
|
-
t.preventDefault(), this.enterPillList(s.length - 1);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
onInputBlur(t) {
|
|
169
|
-
const e = t.target, r = this.getSeparators(), a = e.value;
|
|
170
|
-
a.length > 0 && r.includes("blur") && !this.disabled && !this.readOnly && this.commitDraft(a) && (e.value = ""), this.dispatchEvent(
|
|
171
|
-
new CustomEvent("blur", {
|
|
172
|
-
bubbles: !0,
|
|
173
|
-
composed: !0
|
|
174
|
-
})
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
onPaste(t) {
|
|
178
|
-
if (this.disabled || this.readOnly) return;
|
|
179
|
-
const e = t.clipboardData?.getData("text") ?? "";
|
|
180
|
-
if (!e) return;
|
|
181
|
-
const a = this.getSeparators().filter((u) => u !== "Enter" && u !== "Tab" && u !== "blur");
|
|
182
|
-
if (a.length === 0) return;
|
|
183
|
-
const i = new RegExp(
|
|
184
|
-
`[${a.map((u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}
|
|
185
|
-
]`
|
|
186
|
-
);
|
|
187
|
-
if (!i.test(e)) return;
|
|
188
|
-
t.preventDefault();
|
|
189
|
-
const s = t.target instanceof HTMLInputElement ? t.target : null, d = ((s?.value ?? "") + e).split(i), v = d.slice(0, -1), $ = d[d.length - 1] ?? "";
|
|
190
|
-
this.commitDraftBatch(v) && s && (s.value = $);
|
|
191
|
-
}
|
|
192
|
-
commitDraft(t) {
|
|
193
|
-
const e = this.trim ? t.trim() : t;
|
|
194
|
-
if (e.length === 0) return !1;
|
|
195
|
-
const r = this.getValue();
|
|
196
|
-
return this.allowDuplicates === !1 && r.includes(e) ? !0 : this.limit !== void 0 && r.length >= this.limit ? !1 : (this.emitChange([...r, e]), !0);
|
|
197
|
-
}
|
|
198
|
-
commitDraftBatch(t) {
|
|
199
|
-
const e = this.getValue(), r = [...e];
|
|
200
|
-
for (const a of t) {
|
|
201
|
-
const i = this.trim ? a.trim() : a;
|
|
202
|
-
if (i.length !== 0 && !(this.allowDuplicates === !1 && r.includes(i))) {
|
|
203
|
-
if (this.limit !== void 0 && r.length >= this.limit) break;
|
|
204
|
-
r.push(i);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return r.length === e.length ? !1 : (this.emitChange(r), !0);
|
|
208
|
-
}
|
|
209
|
-
emitChange(t) {
|
|
210
|
-
this.value = t, this.dispatchEvent(
|
|
211
|
-
new CustomEvent("change", {
|
|
212
|
-
detail: { value: t },
|
|
213
|
-
bubbles: !0,
|
|
214
|
-
composed: !0
|
|
215
|
-
})
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
focusInput() {
|
|
219
|
-
this.querySelector(`input[id="${this.uid}"]`)?.focus();
|
|
220
|
-
}
|
|
221
|
-
getPills() {
|
|
222
|
-
return this.querySelector("gui-pills");
|
|
223
|
-
}
|
|
224
|
-
isDropdownOpen() {
|
|
225
|
-
return !!this.getPills()?.querySelector(".gui-pills__dropdown");
|
|
226
|
-
}
|
|
227
|
-
/** True when the host wrapper has shrunk past the compact threshold and
|
|
228
|
-
* gui-pills is displaying the bubble instead of the strip. */
|
|
229
|
-
isCompactMode() {
|
|
230
|
-
const t = this.getPills();
|
|
231
|
-
if (!t) return !1;
|
|
232
|
-
const e = t.querySelector(".gui-pills__strip-wrapper");
|
|
233
|
-
return e ? getComputedStyle(e).display === "none" : !1;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Enter the pill list at `index`. In compact mode the strip is hidden, so
|
|
237
|
-
* we open the dropdown overlay first so the user can see the focused pill.
|
|
238
|
-
*/
|
|
239
|
-
enterPillList(t) {
|
|
240
|
-
const e = this.getPills();
|
|
241
|
-
e && (this.isCompactMode() ? (e.openDropdown(), requestAnimationFrame(() => e.focusPillAt(t))) : e.focusPillAt(t));
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
n([
|
|
245
|
-
o({ type: String })
|
|
246
|
-
], l.prototype, "uid", 2);
|
|
247
|
-
n([
|
|
248
|
-
o({ type: String })
|
|
249
|
-
], l.prototype, "label", 2);
|
|
250
|
-
n([
|
|
251
|
-
o({ type: String, attribute: "locale-id" })
|
|
252
|
-
], l.prototype, "localeId", 2);
|
|
253
|
-
n([
|
|
254
|
-
o({ type: Array })
|
|
255
|
-
], l.prototype, "errors", 2);
|
|
256
|
-
n([
|
|
257
|
-
o({ type: Boolean })
|
|
258
|
-
], l.prototype, "touched", 2);
|
|
259
|
-
n([
|
|
260
|
-
o({ type: Boolean })
|
|
261
|
-
], l.prototype, "required", 2);
|
|
262
|
-
n([
|
|
263
|
-
o({ type: Boolean })
|
|
264
|
-
], l.prototype, "disabled", 2);
|
|
265
|
-
n([
|
|
266
|
-
o({ type: Boolean, attribute: "readonly" })
|
|
267
|
-
], l.prototype, "readOnly", 2);
|
|
268
|
-
n([
|
|
269
|
-
o({ type: Array })
|
|
270
|
-
], l.prototype, "value", 2);
|
|
271
|
-
n([
|
|
272
|
-
o({ type: String })
|
|
273
|
-
], l.prototype, "hint", 2);
|
|
274
|
-
n([
|
|
275
|
-
o({ type: String })
|
|
276
|
-
], l.prototype, "placeholder", 2);
|
|
277
|
-
n([
|
|
278
|
-
o({ type: String })
|
|
279
|
-
], l.prototype, "icon", 2);
|
|
280
|
-
n([
|
|
281
|
-
o({ type: Array })
|
|
282
|
-
], l.prototype, "separators", 2);
|
|
283
|
-
n([
|
|
284
|
-
o({ type: Boolean })
|
|
285
|
-
], l.prototype, "allowDuplicates", 2);
|
|
286
|
-
n([
|
|
287
|
-
o({ type: Boolean })
|
|
288
|
-
], l.prototype, "trim", 2);
|
|
289
|
-
n([
|
|
290
|
-
o({ type: Number })
|
|
291
|
-
], l.prototype, "limit", 2);
|
|
292
|
-
n([
|
|
293
|
-
o({ type: String, attribute: "remove-aria-label" })
|
|
294
|
-
], l.prototype, "removeAriaLabel", 2);
|
|
295
|
-
n([
|
|
296
|
-
o({ type: String, attribute: "remove-icon" })
|
|
297
|
-
], l.prototype, "removeIcon", 2);
|
|
298
|
-
l = n([
|
|
299
|
-
b("gui-tags")
|
|
300
|
-
], l);
|
|
301
|
-
typeof customElements < "u" && !customElements.get("gui-tags") && customElements.define("gui-tags", l);
|
|
302
|
-
var q = Object.defineProperty, R = Object.getOwnPropertyDescriptor, g = (t, e, r, a) => {
|
|
303
|
-
for (var i = a > 1 ? void 0 : a ? R(e, r) : e, s = t.length - 1, p; s >= 0; s--)
|
|
304
|
-
(p = t[s]) && (i = (a ? p(e, r, i) : p(i)) || i);
|
|
305
|
-
return a && i && q(e, r, i), i;
|
|
306
|
-
};
|
|
307
|
-
let h = class extends y {
|
|
308
|
-
constructor() {
|
|
309
|
-
super(...arguments), this.adapter = new D(), this.subscriptions = [];
|
|
310
|
-
}
|
|
311
|
-
createRenderRoot() {
|
|
312
|
-
return this;
|
|
313
|
-
}
|
|
314
|
-
updated(t) {
|
|
315
|
-
super.updated(t);
|
|
316
|
-
const e = this.adapter.templateData.size;
|
|
317
|
-
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
318
|
-
}
|
|
319
|
-
connectedCallback() {
|
|
320
|
-
super.connectedCallback(), this.classList.add("gui-tags", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
321
|
-
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
render() {
|
|
325
|
-
return super.render(), m`
|
|
326
|
-
<gui-tags
|
|
327
|
-
.uid=${this.widget.uid}
|
|
328
|
-
.label=${this.adapter.templateData.label}
|
|
329
|
-
.hint=${this.adapter.templateData.hint}
|
|
330
|
-
.errors=${this.adapter.templateData.errors}
|
|
331
|
-
?touched=${this.adapter.templateData.touched}
|
|
332
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
333
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
334
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
335
|
-
.value=${this.adapter.templateData.value}
|
|
336
|
-
.placeholder=${this.adapter.templateData.placeholder}
|
|
337
|
-
.icon=${this.adapter.templateData.icon}
|
|
338
|
-
.separators=${this.adapter.templateData.separators}
|
|
339
|
-
.allowDuplicates=${this.adapter.templateData.allowDuplicates ?? !0}
|
|
340
|
-
.trim=${this.adapter.templateData.trim ?? !0}
|
|
341
|
-
.limit=${this.adapter.templateData.limit}
|
|
342
|
-
.removeAriaLabel=${this.adapter.templateData.removeAriaLabel}
|
|
343
|
-
.removeIcon=${this.adapter.templateData.removeIcon}
|
|
344
|
-
@change=${this.valueChanged}
|
|
345
|
-
@blur=${() => this.adapter.onBlur()}
|
|
346
|
-
></gui-tags>
|
|
347
|
-
`;
|
|
348
|
-
}
|
|
349
|
-
valueChanged(t) {
|
|
350
|
-
const e = t.detail.value;
|
|
351
|
-
this.adapter.valueChanged(e);
|
|
352
|
-
}
|
|
353
|
-
disconnectedCallback() {
|
|
354
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
g([
|
|
358
|
-
E({ context: w }),
|
|
359
|
-
o({ attribute: !1 })
|
|
360
|
-
], h.prototype, "formContext", 2);
|
|
361
|
-
g([
|
|
362
|
-
L({ context: C })
|
|
363
|
-
], h.prototype, "adapter", 2);
|
|
364
|
-
h = g([
|
|
365
|
-
b("gui-tags-input")
|
|
366
|
-
], h);
|
|
367
|
-
export {
|
|
368
|
-
h as TagsElement
|
|
369
|
-
};
|