@golemui/gui-lit 2.0.0-rc.0 → 2.0.0-rc.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 +10 -0
- package/default-list-item-renderer-sJeXkSKR.js +15 -0
- package/{default-multi-list-item-renderer-Cv-guvEX.js → default-multi-list-item-renderer-CG3Fuye0.js} +7 -12
- package/{dropdown.element-Djee1u1L.js → dropdown.element-C55MHVq-.js} +95 -115
- package/index.js +4 -4
- package/index.umd.cjs +106 -130
- package/lib/components/dropdown.element.d.ts +2 -5
- package/lib/components/list.element.d.ts +2 -7
- package/lib/components/multi-dropdown.element.d.ts +2 -5
- package/lib/components/multi-list.element.d.ts +2 -7
- package/list.element-CIrv32zU.js +125 -0
- package/{multi-dropdown.element-B1vV4rF-.js → multi-dropdown.element-nOsP8HUx.js} +95 -117
- package/multi-list.element-CZfmTbCf.js +139 -0
- package/package.json +6 -6
- package/default-list-item-renderer-CuPJ9jUD.js +0 -24
- package/list.element-DfLD2X8s.js +0 -147
- package/multi-list.element-CNVHVkj0.js +0 -161
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { html as t } from "lit";
|
|
2
|
+
import { classMap as i } from "lit/directives/class-map.js";
|
|
3
|
+
import "@golemui/core";
|
|
4
|
+
const r = (e) => {
|
|
5
|
+
const s = {
|
|
6
|
+
"gui-list__item": !0,
|
|
7
|
+
"gui-list__item-selected": !!e.selected,
|
|
8
|
+
"gui-list__item-focused": !!e.focused,
|
|
9
|
+
"gui-list__item-disabled": !!e.disabled
|
|
10
|
+
};
|
|
11
|
+
return t` <div class=${i(s)}>${e.template}</div> `;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
r as d
|
|
15
|
+
};
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { html as
|
|
2
|
-
import { classMap as
|
|
1
|
+
import { html as s } from "lit";
|
|
2
|
+
import { classMap as i } from "lit/directives/class-map.js";
|
|
3
3
|
import "@golemui/core";
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const m = (e) => {
|
|
5
|
+
const t = {
|
|
6
6
|
"gui-list__item": !0,
|
|
7
7
|
"gui-list__item-selected": !!e.selected,
|
|
8
8
|
"gui-list__item-focused": !!e.focused,
|
|
9
9
|
"gui-list__item-disabled": !!e.disabled
|
|
10
10
|
};
|
|
11
|
-
return
|
|
12
|
-
<div
|
|
13
|
-
role="option"
|
|
14
|
-
class=${t(s)}
|
|
15
|
-
aria-selected=${e.selected ? "true" : "false"}
|
|
16
|
-
aria-disabled=${e.disabled ? "true" : "false"}
|
|
17
|
-
>
|
|
11
|
+
return s`
|
|
12
|
+
<div class=${i(t)}>
|
|
18
13
|
<span class="gui-list__item-check" aria-hidden="true">
|
|
19
14
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 256 256">
|
|
20
15
|
<path
|
|
@@ -27,5 +22,5 @@ const r = (e) => {
|
|
|
27
22
|
`;
|
|
28
23
|
};
|
|
29
24
|
export {
|
|
30
|
-
|
|
25
|
+
m as d
|
|
31
26
|
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { InputWidgetAdapter as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { InputWidgetAdapter as b, formContext as $, inputContext as I } from "@golemui/lit";
|
|
2
|
+
import { searchItems as w } from "@golemui/gui-components/internals";
|
|
3
|
+
import { consume as v, provide as y } from "@lit/context";
|
|
4
|
+
import { LitElement as F, nothing as n, html as u } from "lit";
|
|
5
|
+
import { classMap as m } from "lit/directives/class-map.js";
|
|
6
|
+
import { property as D, state as d, query as p } from "lit/decorators.js";
|
|
7
|
+
import { unsubscribeAll as x, cspStyleMap as C, safeDefine as R } from "@golemui/lit/internals";
|
|
8
|
+
import { Subject as k, debounceTime as L } from "rxjs";
|
|
9
|
+
import { d as V } from "./default-list-item-renderer-sJeXkSKR.js";
|
|
9
10
|
import "@golemui/gui-components/label";
|
|
10
11
|
import "@golemui/gui-components/list";
|
|
11
12
|
import "@golemui/gui-components/errors";
|
|
12
|
-
import { live as
|
|
13
|
-
var
|
|
14
|
-
for (var
|
|
15
|
-
(h =
|
|
16
|
-
return
|
|
13
|
+
import { live as T } from "lit/directives/live.js";
|
|
14
|
+
var j = Object.defineProperty, o = (c, e, t, l) => {
|
|
15
|
+
for (var a = void 0, r = c.length - 1, h; r >= 0; r--)
|
|
16
|
+
(h = c[r]) && (a = h(e, t, a) || a);
|
|
17
|
+
return a && j(e, t, a), a;
|
|
17
18
|
};
|
|
18
|
-
class
|
|
19
|
+
class s extends F {
|
|
19
20
|
constructor() {
|
|
20
|
-
super(...arguments), this.adapter = new
|
|
21
|
+
super(...arguments), this.adapter = new b(), this.debouncer = new k(), this.subscriptions = [], this._visibleItems = [], this._filteredItems = [], this._listItems = [], this._isFiltering = !1, this._isListVisible = !1, this._selectedItem = void 0, this._ignoreNextFocus = !1, this.onDocumentClick = (e) => {
|
|
21
22
|
if (!this._isListVisible) return;
|
|
22
|
-
const t = e.composedPath(),
|
|
23
|
-
!
|
|
23
|
+
const t = e.composedPath(), l = this._inputRef && t.includes(this._inputRef), a = this._panelRef && t.includes(this._panelRef);
|
|
24
|
+
!l && !a && (this._isListVisible = !1);
|
|
24
25
|
}, this._onToggleMouseDown = (e) => {
|
|
25
26
|
e.preventDefault();
|
|
26
27
|
}, this._onToggleClick = (e) => {
|
|
@@ -38,37 +39,29 @@ class a extends L {
|
|
|
38
39
|
const e = this.adapter.templateData;
|
|
39
40
|
e.items && this._listItems?.length === 0 && this._filteredItems?.length === 0 && (this._filteredItems = e.items, this._listItems = e.items), this.requestUpdate();
|
|
40
41
|
}),
|
|
41
|
-
this.debouncer.pipe(
|
|
42
|
+
this.debouncer.pipe(L(this.adapter.templateData.inputDebounce ?? 500)).subscribe((e) => {
|
|
42
43
|
this._filterItems(e);
|
|
43
44
|
})
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
disconnectedCallback() {
|
|
47
|
-
super.disconnectedCallback(), this.adapter.destroy(),
|
|
48
|
+
super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.adapter.destroy(), x(this.subscriptions);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
this.
|
|
50
|
+
_onVisibleItemsChange(e) {
|
|
51
|
+
this._visibleItems = e.detail;
|
|
51
52
|
}
|
|
52
53
|
_onUpdateItems(e) {
|
|
53
54
|
const t = e.detail || [];
|
|
54
55
|
if (this._listItems = t, !this._selectedItem && this.adapter.templateData.value != null) {
|
|
55
|
-
const
|
|
56
|
-
(
|
|
56
|
+
const l = t.find(
|
|
57
|
+
(a) => a.value === this.adapter.templateData.value
|
|
57
58
|
);
|
|
58
|
-
|
|
59
|
+
l && (this._selectedItem = l);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
_onFocusChange(e) {
|
|
62
|
-
this._focusedIndex = e.detail.index;
|
|
63
|
-
}
|
|
64
|
-
_onClickItem(e, t) {
|
|
65
|
-
if (this.adapter.templateData.readonly || e.disabled) return;
|
|
66
|
-
const s = this.adapter.templateData;
|
|
67
|
-
this.adapter.valueChanged(e.value), this.adapter.filterChanged(""), this._focusedIndex = t, this._selectedItem = e, this._isFiltering = !1, this._isListVisible = !1, this._listRef && (this._listRef.focusItemAtIndex(t), this._inputRef.value = s.valueField ? e.template[s.valueField] : e.template);
|
|
68
|
-
}
|
|
69
62
|
_onValueChange(e) {
|
|
70
63
|
const t = e.detail.value;
|
|
71
|
-
this.adapter.valueChanged(t), this.adapter.filterChanged(""), this._selectedItem = this._listItems.find((
|
|
64
|
+
this.adapter.valueChanged(t), this.adapter.filterChanged(""), this._selectedItem = this._listItems.find((l) => l.value === t), this._isFiltering = !1, this._isListVisible = !1;
|
|
72
65
|
}
|
|
73
66
|
async _onKeyDown(e) {
|
|
74
67
|
switch (e.key) {
|
|
@@ -85,20 +78,12 @@ class a extends L {
|
|
|
85
78
|
this.debouncer.next(t);
|
|
86
79
|
}
|
|
87
80
|
_filterItems(e) {
|
|
88
|
-
const t = this.adapter.templateData,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (o === null || typeof o != "object")
|
|
95
|
-
return o != null && o.toString().toLowerCase().includes(e.toLowerCase());
|
|
96
|
-
const f = Object.keys(o), n = (c, b) => c || o[b].toString().toLowerCase().includes(e.toLowerCase());
|
|
97
|
-
return u ? f.filter((c) => i.includes(c)).reduce(n, !1) : f.reduce(n, !1);
|
|
98
|
-
});
|
|
99
|
-
this._filteredItems = [...m];
|
|
100
|
-
} else
|
|
101
|
-
this._isFiltering = !1, this._filteredItems = [...t.items];
|
|
81
|
+
const t = this.adapter.templateData, l = !!this.widget.on?.filter;
|
|
82
|
+
this.adapter.filterChanged(e), e && !l ? (this._isFiltering = !0, this._isListVisible = !0, this._filteredItems = w(
|
|
83
|
+
t.items || [],
|
|
84
|
+
e,
|
|
85
|
+
t
|
|
86
|
+
)) : (this._isFiltering = !1, this._filteredItems = [...t.items]);
|
|
102
87
|
}
|
|
103
88
|
_onWidgetKeyDown(e) {
|
|
104
89
|
e.key !== "Escape" || !this._isListVisible || (e.preventDefault(), e.stopPropagation(), this._isListVisible = !1, this._isFiltering = !1, this._ignoreNextFocus = !0, this._inputRef?.focus(), setTimeout(() => {
|
|
@@ -117,11 +102,11 @@ class a extends L {
|
|
|
117
102
|
t && this.contains(t) || (this.adapter.onBlur(), this._isListVisible = !1, this._isFiltering = !1);
|
|
118
103
|
}
|
|
119
104
|
render() {
|
|
120
|
-
const e = this.adapter.templateData, t = e.touched && e.errors && e.errors.length > 0,
|
|
105
|
+
const e = this.adapter.templateData, t = e.touched && e.errors && e.errors.length > 0, l = this.adapter.getItemRenderer(
|
|
121
106
|
e.itemRenderer,
|
|
122
|
-
|
|
123
|
-
),
|
|
124
|
-
return
|
|
107
|
+
V
|
|
108
|
+
), r = this._selectedItem?.template !== null && typeof this._selectedItem?.template == "object" ? e.labelField ?? "label" : null, h = r ? this._selectedItem?.template[r] : this._selectedItem?.template, f = !!this.widget.on?.filter;
|
|
109
|
+
return u`
|
|
125
110
|
<gui-label
|
|
126
111
|
.targetElement=${[this._listRef, this._inputRef]}
|
|
127
112
|
.uid=${this.widget.uid}
|
|
@@ -134,34 +119,34 @@ class a extends L {
|
|
|
134
119
|
></gui-label>
|
|
135
120
|
|
|
136
121
|
<div class="gui-widget" @keydown=${this._onWidgetKeyDown} @focusout=${this._onFocusOut}>
|
|
137
|
-
${e.icon ?
|
|
138
|
-
class=${
|
|
122
|
+
${e.icon ? u`<span
|
|
123
|
+
class=${m({ "gui-widget-icon": !0, [e.icon]: !0 })}
|
|
139
124
|
data-icon=${e.icon}
|
|
140
125
|
aria-hidden="true"
|
|
141
|
-
></span>` :
|
|
126
|
+
></span>` : n}
|
|
142
127
|
<input
|
|
143
128
|
type="text"
|
|
144
129
|
role="combobox"
|
|
145
130
|
id=${this.widget.uid}
|
|
146
131
|
data-cy=${`${this.widget.uid}_textinput`}
|
|
147
|
-
class=${
|
|
132
|
+
class=${m({
|
|
148
133
|
"gui-widget-input": !0,
|
|
149
134
|
"gui-dropdown--icon": !!e.icon
|
|
150
135
|
})}
|
|
151
|
-
.value=${
|
|
136
|
+
.value=${h ?? e.value ?? ""}
|
|
152
137
|
?required=${e.validator?.required}
|
|
153
138
|
?disabled=${e.disabled}
|
|
154
139
|
?readonly=${e.readonly}
|
|
155
140
|
placeholder=${e.placeholder ?? ""}
|
|
156
|
-
autocomplete=${e.autocomplete ||
|
|
141
|
+
autocomplete=${e.autocomplete || n}
|
|
157
142
|
@keydown=${this._onKeyDown}
|
|
158
143
|
@input=${this._onInput}
|
|
159
144
|
@focus=${this._onFocus}
|
|
160
145
|
aria-expanded=${this._isListVisible ? "true" : "false"}
|
|
161
146
|
aria-controls=${`${this.widget.uid}-list`}
|
|
162
147
|
aria-autocomplete="list"
|
|
163
|
-
aria-labelledby=${e.label ? `${this.widget.uid}_label` :
|
|
164
|
-
aria-describedby=${e.hint ? `${this.widget.uid}_hint` :
|
|
148
|
+
aria-labelledby=${e.label ? `${this.widget.uid}_label` : n}
|
|
149
|
+
aria-describedby=${e.hint ? `${this.widget.uid}_hint` : n}
|
|
165
150
|
/>
|
|
166
151
|
<button
|
|
167
152
|
type="button"
|
|
@@ -185,9 +170,9 @@ class a extends L {
|
|
|
185
170
|
<gui-list
|
|
186
171
|
id=${`${this.widget.uid}-list`}
|
|
187
172
|
.uid=${this.widget.uid}
|
|
188
|
-
.value=${
|
|
173
|
+
.value=${T(e.value ?? "")}
|
|
189
174
|
.valueField=${e.valueField}
|
|
190
|
-
.items=${this._isFiltering && !
|
|
175
|
+
.items=${this._isFiltering && !f ? this._filteredItems : e.items}
|
|
191
176
|
.itemHeight=${e.itemHeight}
|
|
192
177
|
.height=${e.height}
|
|
193
178
|
?required=${e.validator?.required}
|
|
@@ -195,92 +180,87 @@ class a extends L {
|
|
|
195
180
|
?disabled=${e.disabled}
|
|
196
181
|
?readonly=${e.readonly}
|
|
197
182
|
?hidden=${!this._isListVisible}
|
|
198
|
-
@gui-
|
|
183
|
+
@gui-visible-items-change=${this._onVisibleItemsChange}
|
|
199
184
|
@gui-update-items=${this._onUpdateItems}
|
|
200
|
-
@gui-focus-change=${this._onFocusChange}
|
|
201
185
|
@focus=${this._onFocus}
|
|
202
186
|
@gui-input=${this._onValueChange}
|
|
203
187
|
>
|
|
204
|
-
${
|
|
205
|
-
const
|
|
206
|
-
return
|
|
188
|
+
${this._visibleItems.map((i) => {
|
|
189
|
+
const _ = e.labelField ?? "label", g = i.template !== null && typeof i.template == "object" && _ && !e.itemRenderer ? i.template[_] : i.template;
|
|
190
|
+
return u`
|
|
207
191
|
<div
|
|
208
192
|
role="option"
|
|
209
193
|
tabindex="-1"
|
|
210
194
|
class="gui-list__item-wrapper"
|
|
211
|
-
id
|
|
212
|
-
style=${
|
|
213
|
-
aria-selected=${
|
|
214
|
-
aria-disabled=${
|
|
215
|
-
@click=${() => this._onClickItem(r, n)}
|
|
195
|
+
id=${i.id}
|
|
196
|
+
style=${C({ height: `${e.itemHeight || 40}px` })}
|
|
197
|
+
aria-selected=${i.selected ? "true" : "false"}
|
|
198
|
+
aria-disabled=${i.disabled ? "true" : "false"}
|
|
216
199
|
>
|
|
217
|
-
${
|
|
218
|
-
template:
|
|
219
|
-
value:
|
|
220
|
-
index:
|
|
221
|
-
selected:
|
|
222
|
-
disabled:
|
|
223
|
-
focused:
|
|
200
|
+
${l({
|
|
201
|
+
template: g,
|
|
202
|
+
value: i.value,
|
|
203
|
+
index: i.index,
|
|
204
|
+
selected: i.selected,
|
|
205
|
+
disabled: i.disabled,
|
|
206
|
+
focused: i.focused
|
|
224
207
|
})}
|
|
225
208
|
</div>
|
|
226
209
|
`;
|
|
227
210
|
})}
|
|
228
211
|
</gui-list>
|
|
229
|
-
${t ?
|
|
212
|
+
${t ? u`<gui-errors
|
|
230
213
|
panel
|
|
231
214
|
.uid=${this.widget.uid}
|
|
232
215
|
.errors=${e.errors}
|
|
233
216
|
.touched=${e.touched}
|
|
234
|
-
></gui-errors>` :
|
|
217
|
+
></gui-errors>` : n}
|
|
235
218
|
</div>
|
|
236
219
|
</div>
|
|
237
220
|
|
|
238
|
-
${t ?
|
|
221
|
+
${t ? u`<gui-errors
|
|
239
222
|
.uid=${this.widget.uid}
|
|
240
223
|
.errors=${e.errors}
|
|
241
224
|
.touched=${e.touched}
|
|
242
|
-
></gui-errors>` :
|
|
225
|
+
></gui-errors>` : n}
|
|
243
226
|
`;
|
|
244
227
|
}
|
|
245
228
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
],
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
],
|
|
253
|
-
|
|
254
|
-
d()
|
|
255
|
-
], a.prototype, "_range");
|
|
256
|
-
l([
|
|
229
|
+
o([
|
|
230
|
+
v({ context: $ }),
|
|
231
|
+
D({ attribute: !1 })
|
|
232
|
+
], s.prototype, "formContext");
|
|
233
|
+
o([
|
|
234
|
+
y({ context: I })
|
|
235
|
+
], s.prototype, "adapter");
|
|
236
|
+
o([
|
|
257
237
|
d()
|
|
258
|
-
],
|
|
259
|
-
|
|
238
|
+
], s.prototype, "_visibleItems");
|
|
239
|
+
o([
|
|
260
240
|
d()
|
|
261
|
-
],
|
|
262
|
-
|
|
241
|
+
], s.prototype, "_filteredItems");
|
|
242
|
+
o([
|
|
263
243
|
d()
|
|
264
|
-
],
|
|
265
|
-
|
|
244
|
+
], s.prototype, "_listItems");
|
|
245
|
+
o([
|
|
266
246
|
d()
|
|
267
|
-
],
|
|
268
|
-
|
|
247
|
+
], s.prototype, "_isFiltering");
|
|
248
|
+
o([
|
|
269
249
|
d()
|
|
270
|
-
],
|
|
271
|
-
|
|
250
|
+
], s.prototype, "_isListVisible");
|
|
251
|
+
o([
|
|
272
252
|
d()
|
|
273
|
-
],
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
],
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
],
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
],
|
|
283
|
-
|
|
253
|
+
], s.prototype, "_selectedItem");
|
|
254
|
+
o([
|
|
255
|
+
p("input")
|
|
256
|
+
], s.prototype, "_inputRef");
|
|
257
|
+
o([
|
|
258
|
+
p("gui-list")
|
|
259
|
+
], s.prototype, "_listRef");
|
|
260
|
+
o([
|
|
261
|
+
p(".gui-picker__panel")
|
|
262
|
+
], s.prototype, "_panelRef");
|
|
263
|
+
R("gui-dropdown-input", s);
|
|
284
264
|
export {
|
|
285
|
-
|
|
265
|
+
s as DropdownElement
|
|
286
266
|
};
|
package/index.js
CHANGED
|
@@ -21,13 +21,13 @@ const n = {
|
|
|
21
21
|
dateInput: async () => (await import("./date.element-Ba8wmaNU.js")).DateElement,
|
|
22
22
|
datePicker: async () => (await import("./date-picker.element-X__hfSnj.js")).DatePickerElement,
|
|
23
23
|
dateTimePicker: async () => (await import("./date-time-picker.element-QGn5dEbf.js")).DateTimePickerElement,
|
|
24
|
-
dropdown: async () => (await import("./dropdown.element-
|
|
24
|
+
dropdown: async () => (await import("./dropdown.element-C55MHVq-.js")).DropdownElement,
|
|
25
25
|
fileUpload: async () => (await import("./file-upload.element-B3oBEQ_s.js")).FileUploadElement,
|
|
26
|
-
list: async () => (await import("./list.element-
|
|
26
|
+
list: async () => (await import("./list.element-CIrv32zU.js")).ListElement,
|
|
27
27
|
markdown: async () => (await import("./markdown.element-7tvZ028P.js")).MarkdownElement,
|
|
28
|
-
multiDropdown: async () => (await import("./multi-dropdown.element-
|
|
28
|
+
multiDropdown: async () => (await import("./multi-dropdown.element-nOsP8HUx.js")).MultiDropdownElement,
|
|
29
29
|
multiFileUpload: async () => (await import("./multi-file-upload.element-4h6JQgRF.js")).MultiFileUploadElement,
|
|
30
|
-
multiList: async () => (await import("./multi-list.element-
|
|
30
|
+
multiList: async () => (await import("./multi-list.element-CZfmTbCf.js")).MultiListElement,
|
|
31
31
|
password: async () => (await import("./password.element-DnV_PqKI.js")).PasswordElement,
|
|
32
32
|
textinput: async () => (await import("./textinput.element-CCgsbYTB.js")).TextinputElement,
|
|
33
33
|
timeInput: async () => (await import("./time.element-B0L2sriD.js")).TimeElement,
|