@golemui/gui-lit 0.14.0 → 0.15.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/{button.element-ATNRRDN3.js → button.element-DxwYDdu6.js} +49 -45
- package/{currency.element-C7SZkoPP.js → currency.element-ybKzwXEh.js} +11 -10
- package/{date-input-e0k3oBof.js → date-input-D_Swskk4.js} +5 -5
- package/{date-picker.element-D6v6aHR5.js → date-picker.element-CP2_u_ZE.js} +1 -1
- package/{date.element-COU_mEUt.js → date.element-p6aB6OGd.js} +1 -1
- package/{dropdown.element-DCUI5Y7I.js → dropdown.element-8OaBgk7F.js} +1 -0
- package/index.js +271 -279
- package/index.umd.cjs +268 -195
- package/lib/components/range-date-picker.element.d.ts +3 -0
- package/lib/components/tags.element.d.ts +17 -0
- package/{markdown.element-CT1JOOM3.js → markdown.element-1IF3G5KX.js} +1 -0
- package/{number.element-HaXEg_7U.js → number.element-zgd4L5hn.js} +7 -6
- package/package.json +6 -6
- package/{password.element-B4-0SCe4.js → password.element-BT65mDsp.js} +1 -0
- package/pills-D0yyi-op.js +323 -0
- package/range-calendar-CZGBBOzO.js +258 -0
- package/{range-calendar.element-C-4qqRGK.js → range-calendar.element-DQZXvd-L.js} +1 -1
- package/range-date-input-CcPYH7P3.js +398 -0
- package/{range-date-input.element-D3xRMAaY.js → range-date-input.element-v71P-oUp.js} +1 -1
- package/{range-date-picker.element-Vgj3tFlQ.js → range-date-picker.element-CA-KcQhA.js} +60 -51
- package/{select.element-DuGZjlZY.js → select.element-CjWqp9dd.js} +1 -1
- package/tags.element-ed1_51GA.js +365 -0
- package/{textarea.element-C8yx2u0o.js → textarea.element-BTJLqnnI.js} +6 -5
- package/{textinput.element-DKuplF1A.js → textinput.element-zI0iG-Cq.js} +4 -3
- package/range-calendar-qpakwAba.js +0 -326
- package/range-date-input-DFnvo-KK.js +0 -507
|
@@ -1,46 +1,52 @@
|
|
|
1
1
|
import { InputWidgetAdapter as c, formContext as u, inputContext as m } from "@golemui/lit";
|
|
2
2
|
import { a as g, b as D, c as C } from "./templates-Dk1jxLwS.js";
|
|
3
3
|
import "@golemui/gui-shared";
|
|
4
|
-
import "./range-calendar-
|
|
5
|
-
import "./range-date-input-
|
|
4
|
+
import "./range-calendar-CZGBBOzO.js";
|
|
5
|
+
import "./range-date-input-CcPYH7P3.js";
|
|
6
6
|
import { consume as $, provide as f } from "@lit/context";
|
|
7
|
-
import { LitElement as v, html as
|
|
8
|
-
import { property as
|
|
7
|
+
import { LitElement as v, html as d, nothing as b } from "lit";
|
|
8
|
+
import { property as w, query as p, state as h, customElement as y } from "lit/decorators.js";
|
|
9
9
|
import "rxjs";
|
|
10
|
-
import { classMap as
|
|
11
|
-
var
|
|
12
|
-
for (var
|
|
13
|
-
(
|
|
14
|
-
return
|
|
10
|
+
import { classMap as O } from "lit/directives/class-map.js";
|
|
11
|
+
var x = Object.defineProperty, k = Object.getOwnPropertyDescriptor, n = (t, e, a, i) => {
|
|
12
|
+
for (var s = i > 1 ? void 0 : i ? k(e, a) : e, l = t.length - 1, o; l >= 0; l--)
|
|
13
|
+
(o = t[l]) && (s = (i ? o(e, a, s) : o(s)) || s);
|
|
14
|
+
return i && s && x(e, a, s), s;
|
|
15
15
|
};
|
|
16
|
-
let
|
|
16
|
+
let r = class extends v {
|
|
17
17
|
constructor() {
|
|
18
|
-
super(...arguments), this.adapter = new c(), this.isCalendarOpen = !1, this.focusDate = void 0, this.subscriptions = [], this.onFocusOut = (
|
|
18
|
+
super(...arguments), this.adapter = new c(), this.isCalendarOpen = !1, this.focusDate = void 0, this.subscriptions = [], this._ignoreNextFocusOut = !1, this.onFocusOut = (t) => {
|
|
19
|
+
if (this._ignoreNextFocusOut) {
|
|
20
|
+
this._ignoreNextFocusOut = !1;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
if (!this.isCalendarOpen) return;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
}, this.onDocumentClick = (
|
|
24
|
+
const e = t.relatedTarget;
|
|
25
|
+
e && this.contains(e) || this.closeCalendar();
|
|
26
|
+
}, this.onDocumentClick = (t) => {
|
|
23
27
|
if (!this.isCalendarOpen) return;
|
|
24
|
-
const
|
|
25
|
-
!a && !
|
|
28
|
+
const e = t.composedPath(), a = this.dateInput && e.includes(this.dateInput), i = this.calendarInput && e.includes(this.calendarInput);
|
|
29
|
+
!a && !i && this.closeCalendar();
|
|
30
|
+
}, this.onDropdownToggle = (t) => {
|
|
31
|
+
t.detail?.open && this.isCalendarOpen && this.closeCalendar();
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
createRenderRoot() {
|
|
29
35
|
return this;
|
|
30
36
|
}
|
|
31
|
-
updated(
|
|
32
|
-
super.updated(
|
|
33
|
-
const
|
|
34
|
-
|
|
37
|
+
updated(t) {
|
|
38
|
+
super.updated(t);
|
|
39
|
+
const e = this.adapter.templateData.size;
|
|
40
|
+
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
35
41
|
}
|
|
36
42
|
connectedCallback() {
|
|
37
|
-
super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.addEventListener("focusout", this.onFocusOut), this.classList.add("gui-range-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
43
|
+
super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.addEventListener("focusout", this.onFocusOut), this.addEventListener("dropdowntoggle", this.onDropdownToggle), this.classList.add("gui-range-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
38
44
|
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
39
45
|
);
|
|
40
46
|
}
|
|
41
47
|
render() {
|
|
42
48
|
super.render();
|
|
43
|
-
const
|
|
49
|
+
const t = g("datePicker", this.adapter.templateData), e = this.isCalendarOpen ? d`<gui-range-calendar
|
|
44
50
|
id="calendar-input"
|
|
45
51
|
.uid=${this.widget.uid}
|
|
46
52
|
.hint=${this.adapter.templateData.hint}
|
|
@@ -66,7 +72,7 @@ let s = class extends v {
|
|
|
66
72
|
@blur=${this.onBlurCalendar}
|
|
67
73
|
@change=${this.valueChanged}
|
|
68
74
|
></gui-range-calendar>` : b;
|
|
69
|
-
return
|
|
75
|
+
return d`
|
|
70
76
|
${D(this.widget.uid, {
|
|
71
77
|
...this.adapter.templateData,
|
|
72
78
|
required: this.adapter.templateData.validator?.required
|
|
@@ -82,7 +88,7 @@ let s = class extends v {
|
|
|
82
88
|
>
|
|
83
89
|
<gui-range-date
|
|
84
90
|
id="date-input"
|
|
85
|
-
class=${
|
|
91
|
+
class=${O(t.widgetClasses)}
|
|
86
92
|
.uid=${this.widget.uid}
|
|
87
93
|
.hint=${this.adapter.templateData.hint}
|
|
88
94
|
.showErrors=${!1}
|
|
@@ -111,64 +117,67 @@ let s = class extends v {
|
|
|
111
117
|
></path></svg
|
|
112
118
|
></span>
|
|
113
119
|
|
|
114
|
-
${
|
|
120
|
+
${e}
|
|
115
121
|
</div>
|
|
116
122
|
|
|
117
123
|
${C(this.widget.uid, this.adapter.templateData)}
|
|
118
124
|
`;
|
|
119
125
|
}
|
|
120
|
-
valueChanged(
|
|
121
|
-
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(
|
|
126
|
+
valueChanged(t) {
|
|
127
|
+
this.adapter.injectValidationIssues(null), this.adapter.valueChanged(t.detail.value);
|
|
122
128
|
}
|
|
123
129
|
onBlurCalendar() {
|
|
124
130
|
this.adapter.onBlur(), this.closeCalendar();
|
|
125
131
|
}
|
|
126
|
-
onInputError(
|
|
127
|
-
this.adapter.injectValidationIssues([
|
|
132
|
+
onInputError(t) {
|
|
133
|
+
this.adapter.injectValidationIssues([t.detail.message]);
|
|
128
134
|
}
|
|
129
|
-
onPillClick(
|
|
130
|
-
this.focusDate =
|
|
135
|
+
onPillClick(t) {
|
|
136
|
+
this.focusDate = t.detail.range.start, this.openCalendar();
|
|
131
137
|
}
|
|
132
|
-
onKeyUp(
|
|
133
|
-
const
|
|
134
|
-
|
|
138
|
+
onKeyUp(t) {
|
|
139
|
+
const e = t;
|
|
140
|
+
e.target === e.currentTarget && (e?.key === "Enter" || e?.key === " ") && (this.isCalendarOpen ? this.closeCalendar() : this.openCalendar());
|
|
135
141
|
}
|
|
136
|
-
toggleCalendar(
|
|
137
|
-
const
|
|
138
|
-
a ||
|
|
142
|
+
toggleCalendar(t) {
|
|
143
|
+
const e = t.target, a = e.closest(".gui-range-date-input__part"), i = e.closest("gui-range-calendar");
|
|
144
|
+
a || i ? this.openCalendar() : this.isCalendarOpen ? this.closeCalendar() : this.openCalendar();
|
|
139
145
|
}
|
|
140
146
|
openCalendar() {
|
|
141
|
-
this.isCalendarOpen || (this.isCalendarOpen = !0, this.requestUpdate());
|
|
147
|
+
!!this.querySelector(".gui-pills__dropdown") && (this._ignoreNextFocusOut = !0), this.closePillsDropdown(), this.isCalendarOpen || (this.isCalendarOpen = !0, this.requestUpdate());
|
|
142
148
|
}
|
|
143
149
|
closeCalendar() {
|
|
144
150
|
this.isCalendarOpen = !1, this.requestUpdate();
|
|
145
151
|
}
|
|
152
|
+
closePillsDropdown() {
|
|
153
|
+
this.querySelector("gui-pills")?.closeDropdown?.();
|
|
154
|
+
}
|
|
146
155
|
disconnectedCallback() {
|
|
147
|
-
super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.removeEventListener("focusout", this.onFocusOut), this.adapter.destroy(), this.subscriptions.forEach((
|
|
156
|
+
super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.removeEventListener("focusout", this.onFocusOut), this.removeEventListener("dropdowntoggle", this.onDropdownToggle), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
148
157
|
}
|
|
149
158
|
};
|
|
150
159
|
n([
|
|
151
160
|
$({ context: u }),
|
|
152
|
-
|
|
153
|
-
],
|
|
161
|
+
w({ attribute: !1 })
|
|
162
|
+
], r.prototype, "formContext", 2);
|
|
154
163
|
n([
|
|
155
164
|
f({ context: m })
|
|
156
|
-
],
|
|
165
|
+
], r.prototype, "adapter", 2);
|
|
157
166
|
n([
|
|
158
|
-
|
|
159
|
-
],
|
|
167
|
+
p("#date-input")
|
|
168
|
+
], r.prototype, "dateInput", 2);
|
|
160
169
|
n([
|
|
161
|
-
|
|
162
|
-
],
|
|
170
|
+
p("#calendar-input")
|
|
171
|
+
], r.prototype, "calendarInput", 2);
|
|
163
172
|
n([
|
|
164
173
|
h()
|
|
165
|
-
],
|
|
174
|
+
], r.prototype, "isCalendarOpen", 2);
|
|
166
175
|
n([
|
|
167
176
|
h()
|
|
168
|
-
],
|
|
169
|
-
|
|
177
|
+
], r.prototype, "focusDate", 2);
|
|
178
|
+
r = n([
|
|
170
179
|
y("gui-range-date-picker-input")
|
|
171
|
-
],
|
|
180
|
+
], r);
|
|
172
181
|
export {
|
|
173
|
-
|
|
182
|
+
r as RangeDatePickerElement
|
|
174
183
|
};
|
|
@@ -81,7 +81,7 @@ let a = class extends m {
|
|
|
81
81
|
id=${this.uid}
|
|
82
82
|
tabindex="0"
|
|
83
83
|
data-cy=${`${this.uid}_select`}
|
|
84
|
-
class=${$(e.widgetClasses)}
|
|
84
|
+
class=${$({ "gui-widget-input": !0, ...e.widgetClasses })}
|
|
85
85
|
?required=${t.required}
|
|
86
86
|
?disabled=${t.disabled || t.readonly}
|
|
87
87
|
autocomplete=${this.autocomplete || u}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { InputWidgetAdapter as D, formContext as w, inputContext as C } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { LitElement as y, nothing as c, html as m } from "lit";
|
|
4
|
+
import { property as o, customElement as v } from "lit/decorators.js";
|
|
5
|
+
import { classMap as f } from "lit/directives/class-map.js";
|
|
6
|
+
import { G as A, b as P, c as S } from "./templates-Dk1jxLwS.js";
|
|
7
|
+
import "./pills-D0yyi-op.js";
|
|
8
|
+
import { styleMap as _ } from "lit-html/directives/style-map.js";
|
|
9
|
+
import { consume as E, provide as O } from "@lit/context";
|
|
10
|
+
import "rxjs";
|
|
11
|
+
var I = Object.defineProperty, L = Object.getOwnPropertyDescriptor, n = (t, e, r, a) => {
|
|
12
|
+
for (var i = a > 1 ? void 0 : a ? L(e, r) : e, s = t.length - 1, p; s >= 0; s--)
|
|
13
|
+
(p = t[s]) && (i = (a ? p(e, r, i) : p(i)) || i);
|
|
14
|
+
return a && i && I(e, r, i), i;
|
|
15
|
+
};
|
|
16
|
+
const x = ["Enter", ",", "Tab", "blur"];
|
|
17
|
+
let l = class extends y {
|
|
18
|
+
constructor() {
|
|
19
|
+
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, {
|
|
20
|
+
getTargets: () => this.querySelectorAll(".gui-tags-input"),
|
|
21
|
+
getState: () => ({
|
|
22
|
+
uid: this.uid,
|
|
23
|
+
templateData: {
|
|
24
|
+
hint: this.hint,
|
|
25
|
+
errors: this.errors,
|
|
26
|
+
readonly: this.readOnly,
|
|
27
|
+
disabled: this.disabled,
|
|
28
|
+
touched: this.touched
|
|
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 class=${f(r)} data-icon=${this.icon}></span>` : c}
|
|
92
|
+
|
|
93
|
+
<gui-pills
|
|
94
|
+
class="gui-tags__pills"
|
|
95
|
+
style=${_(a.length ? {} : { "min-width": 0 })}
|
|
96
|
+
.items=${a}
|
|
97
|
+
.removable=${!0}
|
|
98
|
+
.clickable=${!1}
|
|
99
|
+
.bubble=${!0}
|
|
100
|
+
.tabbable=${!1}
|
|
101
|
+
?disabled=${this.disabled}
|
|
102
|
+
?readonly=${this.readOnly}
|
|
103
|
+
.removeAriaLabel=${this.getRemoveAriaLabel()}
|
|
104
|
+
.removeIcon=${this.removeIcon}
|
|
105
|
+
.compactAriaLabel=${`${t.length} tags`}
|
|
106
|
+
@pillremove=${this.onPillRemove}
|
|
107
|
+
@pillkeydown=${this.onPillKeydown}
|
|
108
|
+
></gui-pills>
|
|
109
|
+
|
|
110
|
+
<input
|
|
111
|
+
type="text"
|
|
112
|
+
id=${this.uid}
|
|
113
|
+
data-cy=${`${this.uid}_tags-input`}
|
|
114
|
+
class="gui-tags__input"
|
|
115
|
+
?disabled=${this.disabled}
|
|
116
|
+
?readonly=${this.readOnly}
|
|
117
|
+
placeholder=${this.placeholder || c}
|
|
118
|
+
@keydown=${this.onInputKeydown}
|
|
119
|
+
@blur=${this.onInputBlur}
|
|
120
|
+
@paste=${this.onPaste}
|
|
121
|
+
@change=${(i) => i.stopPropagation()}
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
${S(this.uid, e)}
|
|
126
|
+
</div>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
onInputKeydown(t) {
|
|
130
|
+
if (this.disabled || this.readOnly) return;
|
|
131
|
+
const e = t.target, r = this.getSeparators(), a = e.value, i = e.selectionStart === 0 && e.selectionEnd === 0;
|
|
132
|
+
if (t.key === "Enter" && r.includes("Enter")) {
|
|
133
|
+
t.preventDefault(), this.commitDraft(a) && (e.value = "");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (t.key === "," && r.includes(",")) {
|
|
137
|
+
t.preventDefault(), this.commitDraft(a) && (e.value = "");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (t.key === "Tab" && r.includes("Tab") && a.length > 0) {
|
|
141
|
+
this.commitDraft(a) && (e.value = "");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (t.key === "Escape") {
|
|
145
|
+
t.preventDefault(), e.value = "";
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const s = this.getValue(), p = this.isCompactMode();
|
|
149
|
+
if (t.key === "ArrowDown" && p && s.length > 0) {
|
|
150
|
+
t.preventDefault(), this.enterPillList(0);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (t.key === "ArrowLeft" && !p && i && s.length > 0) {
|
|
154
|
+
t.preventDefault(), this.enterPillList(s.length - 1);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (t.key === "Backspace" && a === "" && s.length > 0) {
|
|
158
|
+
t.preventDefault(), this.enterPillList(s.length - 1);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
onInputBlur(t) {
|
|
163
|
+
const e = t.target, r = this.getSeparators(), a = e.value;
|
|
164
|
+
a.length > 0 && r.includes("blur") && !this.disabled && !this.readOnly && this.commitDraft(a) && (e.value = ""), this.dispatchEvent(
|
|
165
|
+
new CustomEvent("blur", {
|
|
166
|
+
bubbles: !0,
|
|
167
|
+
composed: !0
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
onPaste(t) {
|
|
172
|
+
if (this.disabled || this.readOnly) return;
|
|
173
|
+
const e = t.clipboardData?.getData("text") ?? "";
|
|
174
|
+
if (!e) return;
|
|
175
|
+
const a = this.getSeparators().filter(
|
|
176
|
+
(u) => u !== "Enter" && u !== "Tab" && u !== "blur"
|
|
177
|
+
);
|
|
178
|
+
if (a.length === 0) return;
|
|
179
|
+
const i = new RegExp(
|
|
180
|
+
`[${a.map((u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("")}
|
|
181
|
+
]`
|
|
182
|
+
);
|
|
183
|
+
if (!i.test(e)) return;
|
|
184
|
+
t.preventDefault();
|
|
185
|
+
const s = t.target instanceof HTMLInputElement ? t.target : null, d = ((s?.value ?? "") + e).split(i), b = d.slice(0, -1), $ = d[d.length - 1] ?? "";
|
|
186
|
+
this.commitDraftBatch(b) && s && (s.value = $);
|
|
187
|
+
}
|
|
188
|
+
commitDraft(t) {
|
|
189
|
+
const e = this.trim ? t.trim() : t;
|
|
190
|
+
if (e.length === 0) return !1;
|
|
191
|
+
const r = this.getValue();
|
|
192
|
+
return this.allowDuplicates === !1 && r.includes(e) ? !0 : this.limit !== void 0 && r.length >= this.limit ? !1 : (this.emitChange([...r, e]), !0);
|
|
193
|
+
}
|
|
194
|
+
commitDraftBatch(t) {
|
|
195
|
+
const e = this.getValue(), r = [...e];
|
|
196
|
+
for (const a of t) {
|
|
197
|
+
const i = this.trim ? a.trim() : a;
|
|
198
|
+
if (i.length !== 0 && !(this.allowDuplicates === !1 && r.includes(i))) {
|
|
199
|
+
if (this.limit !== void 0 && r.length >= this.limit) break;
|
|
200
|
+
r.push(i);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return r.length === e.length ? !1 : (this.emitChange(r), !0);
|
|
204
|
+
}
|
|
205
|
+
emitChange(t) {
|
|
206
|
+
this.value = t, this.dispatchEvent(
|
|
207
|
+
new CustomEvent("change", {
|
|
208
|
+
detail: { value: t },
|
|
209
|
+
bubbles: !0,
|
|
210
|
+
composed: !0
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
focusInput() {
|
|
215
|
+
this.querySelector(`input[id="${this.uid}"]`)?.focus();
|
|
216
|
+
}
|
|
217
|
+
getPills() {
|
|
218
|
+
return this.querySelector("gui-pills");
|
|
219
|
+
}
|
|
220
|
+
isDropdownOpen() {
|
|
221
|
+
return !!this.getPills()?.querySelector(".gui-pills__dropdown");
|
|
222
|
+
}
|
|
223
|
+
/** True when the host wrapper has shrunk past the compact threshold and
|
|
224
|
+
* gui-pills is displaying the bubble instead of the strip. */
|
|
225
|
+
isCompactMode() {
|
|
226
|
+
const t = this.getPills();
|
|
227
|
+
if (!t) return !1;
|
|
228
|
+
const e = t.querySelector(".gui-pills__strip-wrapper");
|
|
229
|
+
return e ? getComputedStyle(e).display === "none" : !1;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Enter the pill list at `index`. In compact mode the strip is hidden, so
|
|
233
|
+
* we open the dropdown overlay first so the user can see the focused pill.
|
|
234
|
+
*/
|
|
235
|
+
enterPillList(t) {
|
|
236
|
+
const e = this.getPills();
|
|
237
|
+
e && (this.isCompactMode() ? (e.openDropdown(), requestAnimationFrame(() => e.focusPillAt(t))) : e.focusPillAt(t));
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
n([
|
|
241
|
+
o({ type: String })
|
|
242
|
+
], l.prototype, "uid", 2);
|
|
243
|
+
n([
|
|
244
|
+
o({ type: String })
|
|
245
|
+
], l.prototype, "label", 2);
|
|
246
|
+
n([
|
|
247
|
+
o({ type: String, attribute: "locale-id" })
|
|
248
|
+
], l.prototype, "localeId", 2);
|
|
249
|
+
n([
|
|
250
|
+
o({ type: Array })
|
|
251
|
+
], l.prototype, "errors", 2);
|
|
252
|
+
n([
|
|
253
|
+
o({ type: Boolean })
|
|
254
|
+
], l.prototype, "touched", 2);
|
|
255
|
+
n([
|
|
256
|
+
o({ type: Boolean })
|
|
257
|
+
], l.prototype, "required", 2);
|
|
258
|
+
n([
|
|
259
|
+
o({ type: Boolean })
|
|
260
|
+
], l.prototype, "disabled", 2);
|
|
261
|
+
n([
|
|
262
|
+
o({ type: Boolean, attribute: "readonly" })
|
|
263
|
+
], l.prototype, "readOnly", 2);
|
|
264
|
+
n([
|
|
265
|
+
o({ type: Array })
|
|
266
|
+
], l.prototype, "value", 2);
|
|
267
|
+
n([
|
|
268
|
+
o({ type: String })
|
|
269
|
+
], l.prototype, "hint", 2);
|
|
270
|
+
n([
|
|
271
|
+
o({ type: String })
|
|
272
|
+
], l.prototype, "placeholder", 2);
|
|
273
|
+
n([
|
|
274
|
+
o({ type: String })
|
|
275
|
+
], l.prototype, "icon", 2);
|
|
276
|
+
n([
|
|
277
|
+
o({ type: Array })
|
|
278
|
+
], l.prototype, "separators", 2);
|
|
279
|
+
n([
|
|
280
|
+
o({ type: Boolean })
|
|
281
|
+
], l.prototype, "allowDuplicates", 2);
|
|
282
|
+
n([
|
|
283
|
+
o({ type: Boolean })
|
|
284
|
+
], l.prototype, "trim", 2);
|
|
285
|
+
n([
|
|
286
|
+
o({ type: Number })
|
|
287
|
+
], l.prototype, "limit", 2);
|
|
288
|
+
n([
|
|
289
|
+
o({ type: String, attribute: "remove-aria-label" })
|
|
290
|
+
], l.prototype, "removeAriaLabel", 2);
|
|
291
|
+
n([
|
|
292
|
+
o({ type: String, attribute: "remove-icon" })
|
|
293
|
+
], l.prototype, "removeIcon", 2);
|
|
294
|
+
l = n([
|
|
295
|
+
v("gui-tags")
|
|
296
|
+
], l);
|
|
297
|
+
typeof customElements < "u" && !customElements.get("gui-tags") && customElements.define("gui-tags", l);
|
|
298
|
+
var q = Object.defineProperty, R = Object.getOwnPropertyDescriptor, g = (t, e, r, a) => {
|
|
299
|
+
for (var i = a > 1 ? void 0 : a ? R(e, r) : e, s = t.length - 1, p; s >= 0; s--)
|
|
300
|
+
(p = t[s]) && (i = (a ? p(e, r, i) : p(i)) || i);
|
|
301
|
+
return a && i && q(e, r, i), i;
|
|
302
|
+
};
|
|
303
|
+
let h = class extends y {
|
|
304
|
+
constructor() {
|
|
305
|
+
super(...arguments), this.adapter = new D(), this.subscriptions = [];
|
|
306
|
+
}
|
|
307
|
+
createRenderRoot() {
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
updated(t) {
|
|
311
|
+
super.updated(t);
|
|
312
|
+
const e = this.adapter.templateData.size;
|
|
313
|
+
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
314
|
+
}
|
|
315
|
+
connectedCallback() {
|
|
316
|
+
super.connectedCallback(), this.classList.add("gui-tags", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
317
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
render() {
|
|
321
|
+
return super.render(), m`
|
|
322
|
+
<gui-tags
|
|
323
|
+
.uid=${this.widget.uid}
|
|
324
|
+
.label=${this.adapter.templateData.label}
|
|
325
|
+
.hint=${this.adapter.templateData.hint}
|
|
326
|
+
.errors=${this.adapter.templateData.errors}
|
|
327
|
+
?touched=${this.adapter.templateData.touched}
|
|
328
|
+
?required=${this.adapter.templateData.validator?.required}
|
|
329
|
+
?disabled=${this.adapter.templateData.disabled}
|
|
330
|
+
?readonly=${this.adapter.templateData.readonly}
|
|
331
|
+
.value=${this.adapter.templateData.value}
|
|
332
|
+
.placeholder=${this.adapter.templateData.placeholder}
|
|
333
|
+
.icon=${this.adapter.templateData.icon}
|
|
334
|
+
.separators=${this.adapter.templateData.separators}
|
|
335
|
+
.allowDuplicates=${this.adapter.templateData.allowDuplicates ?? !0}
|
|
336
|
+
.trim=${this.adapter.templateData.trim ?? !0}
|
|
337
|
+
.limit=${this.adapter.templateData.limit}
|
|
338
|
+
.removeAriaLabel=${this.adapter.templateData.removeAriaLabel}
|
|
339
|
+
.removeIcon=${this.adapter.templateData.removeIcon}
|
|
340
|
+
@change=${this.valueChanged}
|
|
341
|
+
@blur=${() => this.adapter.onBlur()}
|
|
342
|
+
></gui-tags>
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
valueChanged(t) {
|
|
346
|
+
const e = t.detail.value;
|
|
347
|
+
this.adapter.valueChanged(e);
|
|
348
|
+
}
|
|
349
|
+
disconnectedCallback() {
|
|
350
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
g([
|
|
354
|
+
E({ context: w }),
|
|
355
|
+
o({ attribute: !1 })
|
|
356
|
+
], h.prototype, "formContext", 2);
|
|
357
|
+
g([
|
|
358
|
+
O({ context: C })
|
|
359
|
+
], h.prototype, "adapter", 2);
|
|
360
|
+
h = g([
|
|
361
|
+
v("gui-tags-input")
|
|
362
|
+
], h);
|
|
363
|
+
export {
|
|
364
|
+
h as TagsElement
|
|
365
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InputWidgetAdapter as v, formContext as b, inputContext as x } from "@golemui/lit";
|
|
2
2
|
import "@golemui/gui-shared";
|
|
3
|
-
import { LitElement as
|
|
3
|
+
import { LitElement as m, html as n, nothing as c } from "lit";
|
|
4
4
|
import { property as i, customElement as g } from "lit/decorators.js";
|
|
5
5
|
import { classMap as $ } from "lit/directives/class-map.js";
|
|
6
6
|
import { G as f, b as C, c as w } from "./templates-Dk1jxLwS.js";
|
|
@@ -12,7 +12,7 @@ var S = Object.defineProperty, O = Object.getOwnPropertyDescriptor, o = (t, a, d
|
|
|
12
12
|
(p = t[l]) && (e = (s ? p(a, d, e) : p(e)) || e);
|
|
13
13
|
return s && e && S(a, d, e), e;
|
|
14
14
|
};
|
|
15
|
-
let r = class extends
|
|
15
|
+
let r = class extends m {
|
|
16
16
|
constructor() {
|
|
17
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.placeholder = void 0, this.autocomplete = void 0, this.minimumHeight = void 0, this.autoGrow = !1, this.maxLength = void 0, this.ariaController = new f(this, {
|
|
18
18
|
getTargets: () => this.querySelectorAll(`textarea[id="${this.uid}"]`),
|
|
@@ -79,12 +79,13 @@ let r = class extends c {
|
|
|
79
79
|
<textarea
|
|
80
80
|
id=${this.uid}
|
|
81
81
|
data-cy=${`${this.uid}_textarea`}
|
|
82
|
+
class="gui-widget-input"
|
|
82
83
|
style=${D(d)}
|
|
83
84
|
?required=${t.required}
|
|
84
85
|
?disabled=${t.disabled}
|
|
85
86
|
?readonly=${t.readonly}
|
|
86
|
-
placeholder=${t.placeholder ||
|
|
87
|
-
autocomplete=${this.autocomplete ||
|
|
87
|
+
placeholder=${t.placeholder || c}
|
|
88
|
+
autocomplete=${this.autocomplete || c}
|
|
88
89
|
@input=${this.valueChanged}
|
|
89
90
|
@blur=${this.onBlur}
|
|
90
91
|
></textarea>
|
|
@@ -174,7 +175,7 @@ var E = Object.defineProperty, q = Object.getOwnPropertyDescriptor, h = (t, a, d
|
|
|
174
175
|
(p = t[l]) && (e = (s ? p(a, d, e) : p(e)) || e);
|
|
175
176
|
return s && e && E(a, d, e), e;
|
|
176
177
|
};
|
|
177
|
-
let u = class extends
|
|
178
|
+
let u = class extends m {
|
|
178
179
|
constructor() {
|
|
179
180
|
super(...arguments), this.adapter = new v(), this.subscriptions = [];
|
|
180
181
|
}
|
|
@@ -6,10 +6,10 @@ import { classMap as f } from "lit/directives/class-map.js";
|
|
|
6
6
|
import { G as $, a as x, b as C, c as D } from "./templates-Dk1jxLwS.js";
|
|
7
7
|
import { consume as O, provide as _ } from "@lit/context";
|
|
8
8
|
import "rxjs";
|
|
9
|
-
var
|
|
10
|
-
for (var a = l > 1 ? void 0 : l ?
|
|
9
|
+
var w = Object.defineProperty, E = Object.getOwnPropertyDescriptor, s = (t, e, o, l) => {
|
|
10
|
+
for (var a = l > 1 ? void 0 : l ? E(e, o) : e, p = t.length - 1, d; p >= 0; p--)
|
|
11
11
|
(d = t[p]) && (a = (l ? d(e, o, a) : d(a)) || a);
|
|
12
|
-
return l && a &&
|
|
12
|
+
return l && a && w(e, o, a), a;
|
|
13
13
|
};
|
|
14
14
|
let i = class extends c {
|
|
15
15
|
constructor() {
|
|
@@ -49,6 +49,7 @@ let i = class extends c {
|
|
|
49
49
|
placeholder: this.placeholder,
|
|
50
50
|
autocomplete: this.autocomplete
|
|
51
51
|
}, e = x("textinput", t), o = {
|
|
52
|
+
"gui-widget-input": !0,
|
|
52
53
|
"gui-textinput--icon": !!this.icon
|
|
53
54
|
};
|
|
54
55
|
return m`
|