@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 CHANGED
@@ -1,3 +1,13 @@
1
+ ## 2.0.0-rc.1 (2026-10-09)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **gui-components:** simplify list api ([#421](https://github.com/golemui/golemui/pull/421))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Raúl Jiménez @Elecash
10
+
1
11
  ## 2.0.0-rc.0 (2026-10-08)
2
12
 
3
13
  ### 🚀 Features
@@ -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 i } from "lit";
2
- import { classMap as t } from "lit/directives/class-map.js";
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 r = (e) => {
5
- const s = {
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 i`
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
- r as d
25
+ m as d
31
26
  };
@@ -1,26 +1,27 @@
1
- import { InputWidgetAdapter as F, formContext as x, inputContext as C } from "@golemui/lit";
2
- import { consume as D, provide as R } from "@lit/context";
3
- import { LitElement as L, nothing as p, html as _ } from "lit";
4
- import { classMap as v } from "lit/directives/class-map.js";
5
- import { property as k, state as d, query as $ } from "lit/decorators.js";
6
- import { unsubscribeAll as V, cspStyleMap as S, safeDefine as T } from "@golemui/lit/internals";
7
- import { Subject as j, debounceTime as P } from "rxjs";
8
- import { d as q } from "./default-list-item-renderer-CuPJ9jUD.js";
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 O } from "lit/directives/live.js";
13
- var E = Object.defineProperty, l = (g, e, t, s) => {
14
- for (var i = void 0, u = g.length - 1, h; u >= 0; u--)
15
- (h = g[u]) && (i = h(e, t, i) || i);
16
- return i && E(e, t, i), i;
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 a extends L {
19
+ class s extends F {
19
20
  constructor() {
20
- super(...arguments), this.adapter = new F(), this.debouncer = new j(), this.subscriptions = [], this._range = { start: 0, end: 10 }, this._filteredItems = [], this._listItems = [], this._focusedIndex = -1, this._isFiltering = !1, this._isListVisible = !1, this._selectedItem = void 0, this._ignoreNextFocus = !1, this.onDocumentClick = (e) => {
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(), s = this._inputRef && t.includes(this._inputRef), i = this._panelRef && t.includes(this._panelRef);
23
- !s && !i && (this._isListVisible = !1);
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(P(this.adapter.templateData.inputDebounce ?? 500)).subscribe((e) => {
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(), V(this.subscriptions);
48
+ super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.adapter.destroy(), x(this.subscriptions);
48
49
  }
49
- _onRangeChange(e) {
50
- this._range = { start: e.detail.startIndex, end: e.detail.endIndex };
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 s = t.find(
56
- (i) => i.value === this.adapter.templateData.value
56
+ const l = t.find(
57
+ (a) => a.value === this.adapter.templateData.value
57
58
  );
58
- s && (this._selectedItem = s);
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((s) => s.value === t), this._isFiltering = !1, this._isListVisible = !1;
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, s = !!this.widget.on?.filter;
89
- if (this.adapter.filterChanged(e), e && !s) {
90
- this._isFiltering = !0, this._isListVisible = !0;
91
- const i = t.searchFields ?? [t.labelField, t.valueField].filter(
92
- (o) => !!o
93
- ), u = i.length > 0, m = (t.items || []).filter((o) => {
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, s = this._listItems.slice(this._range.start, this._range.end), i = this.adapter.getItemRenderer(
105
+ const e = this.adapter.templateData, t = e.touched && e.errors && e.errors.length > 0, l = this.adapter.getItemRenderer(
121
106
  e.itemRenderer,
122
- q
123
- ), h = this._selectedItem?.template !== null && typeof this._selectedItem?.template == "object" ? e.labelField ?? "label" : null, m = h ? this._selectedItem?.template[h] : this._selectedItem?.template, o = !!this.widget.on?.filter;
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 ? _`<span
138
- class=${v({ "gui-widget-icon": !0, [e.icon]: !0 })}
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>` : p}
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=${v({
132
+ class=${m({
148
133
  "gui-widget-input": !0,
149
134
  "gui-dropdown--icon": !!e.icon
150
135
  })}
151
- .value=${m ?? e.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 || p}
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` : p}
164
- aria-describedby=${e.hint ? `${this.widget.uid}_hint` : p}
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=${O(e.value ?? "")}
173
+ .value=${T(e.value ?? "")}
189
174
  .valueField=${e.valueField}
190
- .items=${this._isFiltering && !o ? this._filteredItems : e.items}
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-range-change=${this._onRangeChange}
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
- ${s.map((r, f) => {
205
- const n = this._range.start + f, c = e.value === r.value, b = this._focusedIndex === n, I = !!e.disabled || !!r.disabled, w = e.labelField ?? "label", y = r.template !== null && typeof r.template == "object" && w && !e.itemRenderer ? r.template[w] : r.template;
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="${this.widget.uid}-item-${n}"
212
- style=${S({ height: `${e.itemHeight || 40}px` })}
213
- aria-selected=${c ? "true" : "false"}
214
- aria-disabled=${I ? "true" : "false"}
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
- ${i({
218
- template: y,
219
- value: r.value,
220
- index: n,
221
- selected: c,
222
- disabled: I,
223
- focused: b
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 ? _`<gui-errors
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>` : p}
217
+ ></gui-errors>` : n}
235
218
  </div>
236
219
  </div>
237
220
 
238
- ${t ? _`<gui-errors
221
+ ${t ? u`<gui-errors
239
222
  .uid=${this.widget.uid}
240
223
  .errors=${e.errors}
241
224
  .touched=${e.touched}
242
- ></gui-errors>` : p}
225
+ ></gui-errors>` : n}
243
226
  `;
244
227
  }
245
228
  }
246
- l([
247
- D({ context: x }),
248
- k({ attribute: !1 })
249
- ], a.prototype, "formContext");
250
- l([
251
- R({ context: C })
252
- ], a.prototype, "adapter");
253
- l([
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
- ], a.prototype, "_filteredItems");
259
- l([
238
+ ], s.prototype, "_visibleItems");
239
+ o([
260
240
  d()
261
- ], a.prototype, "_listItems");
262
- l([
241
+ ], s.prototype, "_filteredItems");
242
+ o([
263
243
  d()
264
- ], a.prototype, "_focusedIndex");
265
- l([
244
+ ], s.prototype, "_listItems");
245
+ o([
266
246
  d()
267
- ], a.prototype, "_isFiltering");
268
- l([
247
+ ], s.prototype, "_isFiltering");
248
+ o([
269
249
  d()
270
- ], a.prototype, "_isListVisible");
271
- l([
250
+ ], s.prototype, "_isListVisible");
251
+ o([
272
252
  d()
273
- ], a.prototype, "_selectedItem");
274
- l([
275
- $("input")
276
- ], a.prototype, "_inputRef");
277
- l([
278
- $("gui-list")
279
- ], a.prototype, "_listRef");
280
- l([
281
- $(".gui-picker__panel")
282
- ], a.prototype, "_panelRef");
283
- T("gui-dropdown-input", a);
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
- a as DropdownElement
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-Djee1u1L.js")).DropdownElement,
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-DfLD2X8s.js")).ListElement,
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-B1vV4rF-.js")).MultiDropdownElement,
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-CNVHVkj0.js")).MultiListElement,
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,