@golemui/gui-lit 0.15.1 → 0.16.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.
@@ -1,9 +1,9 @@
1
- import { html as c, LitElement as p, nothing as h } from "lit";
1
+ import { html as c, LitElement as p, nothing as u } from "lit";
2
2
  import { classMap as m } from "lit/directives/class-map.js";
3
3
  import "@golemui/core";
4
4
  import { property as a, state as d, query as f, customElement as v } from "lit/decorators.js";
5
5
  import "@golemui/gui-shared";
6
- const T = (e) => {
6
+ const F = (e) => {
7
7
  const t = {
8
8
  "gui-list__item": !0,
9
9
  "gui-list__item-selected": !!e.selected,
@@ -46,7 +46,7 @@ function w(e, { valueField: t }) {
46
46
  };
47
47
  };
48
48
  }
49
- const I = (e, t) => {
49
+ const _ = (e, t) => {
50
50
  if (Array.isArray(e) && e.length > 0 && !g(e[0])) {
51
51
  if (b(e[0]))
52
52
  return e.map((i) => ({
@@ -61,12 +61,12 @@ const I = (e, t) => {
61
61
  }
62
62
  return e;
63
63
  };
64
- var _ = Object.defineProperty, x = Object.getOwnPropertyDescriptor, r = (e, t, i, o) => {
65
- for (var s = o > 1 ? void 0 : o ? x(t, i) : t, n = e.length - 1, u; n >= 0; n--)
66
- (u = e[n]) && (s = (o ? u(t, i, s) : u(s)) || s);
67
- return o && s && _(t, i, s), s;
64
+ var I = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (e, t, i, o) => {
65
+ for (var s = o > 1 ? void 0 : o ? x(t, i) : t, n = e.length - 1, h; n >= 0; n--)
66
+ (h = e[n]) && (s = (o ? h(t, i, s) : h(s)) || s);
67
+ return o && s && I(t, i, s), s;
68
68
  };
69
- let l = class extends p {
69
+ let r = class extends p {
70
70
  constructor() {
71
71
  super(...arguments), this.uid = void 0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.valueField = void 0, this.label = void 0, this.hint = void 0, this.items = [], this.itemHeight = void 0, this.height = void 0, this._items = [], this._scrollTop = 0, this._viewportHeight = 0, this._focusedIndex = -1, this.buffer = 5;
72
72
  }
@@ -89,11 +89,11 @@ let l = class extends p {
89
89
  @keydown="${this.onKeyDown}"
90
90
  @focus="${this.onFocus}"
91
91
  @focusout="${this.onFocusOut}"
92
- aria-required=${this.required ? "true" : h}
93
- aria-disabled=${this.disabled || this.readOnly ? "true" : h}
94
- aria-activedescendant="${s ?? h}"
95
- aria-label=${this.label ?? h}
96
- aria-description=${this.hint ?? h}
92
+ aria-required=${this.required ? "true" : u}
93
+ aria-disabled=${this.disabled || this.readOnly ? "true" : u}
94
+ aria-activedescendant="${s ?? u}"
95
+ aria-label=${this.label ?? u}
96
+ aria-description=${this.hint ?? u}
97
97
  >
98
98
  <div
99
99
  class="gui-list__spacer"
@@ -116,7 +116,7 @@ let l = class extends p {
116
116
  this._focusedIndex = e;
117
117
  }
118
118
  scrollToSelectedIndex() {
119
- const e = this.items.findIndex((t) => (this.valueField ? t[this.valueField] : t) === this.value);
119
+ const e = this._items.findIndex((t) => t.value === this.value);
120
120
  this.scrollToIndex(e);
121
121
  }
122
122
  onKeyDown(e) {
@@ -144,8 +144,8 @@ let l = class extends p {
144
144
  break;
145
145
  case "Enter":
146
146
  case " ": {
147
- const n = this.items[this._focusedIndex], u = n != null;
148
- this._focusedIndex >= 0 && u && this.selectItem(this.items[this._focusedIndex]), s = !0;
147
+ const n = this._items[this._focusedIndex];
148
+ this._focusedIndex >= 0 && n != null && this.selectItem(n), s = !0;
149
149
  break;
150
150
  }
151
151
  }
@@ -153,7 +153,7 @@ let l = class extends p {
153
153
  }
154
154
  onFocus() {
155
155
  if (!this.value || !this.items.length) return;
156
- const e = this.items.findIndex((t) => (this.valueField ? t[this.valueField] : t) === this.value);
156
+ const e = this._items.findIndex((t) => t.value === this.value);
157
157
  this._focusedIndex = e, this.scrollToIndex(e), this.dispatchEvent(
158
158
  new CustomEvent("gui-focus-change", {
159
159
  detail: { index: e },
@@ -172,13 +172,13 @@ let l = class extends p {
172
172
  ), this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 })));
173
173
  }
174
174
  scrollToIndex(e) {
175
- const t = this.itemHeight ?? 40, i = this.height ?? 300, o = e * t, s = o + t, n = this.viewportElement.scrollTop, u = n + i;
176
- o < n ? this.viewportElement.scrollTop = o : s > u && (this.viewportElement.scrollTop = s - i);
175
+ const t = this.itemHeight ?? 40, i = this.height ?? 300, o = e * t, s = o + t, n = this.viewportElement.scrollTop, h = n + i;
176
+ o < n ? this.viewportElement.scrollTop = o : s > h && (this.viewportElement.scrollTop = s - i);
177
177
  }
178
178
  selectItem(e) {
179
179
  this.dispatchEvent(
180
180
  new CustomEvent("change", {
181
- detail: { value: this.valueField ? e[this.valueField] : e },
181
+ detail: { value: e.value },
182
182
  bubbles: !0,
183
183
  composed: !0
184
184
  })
@@ -194,7 +194,7 @@ let l = class extends p {
194
194
  ));
195
195
  }
196
196
  updateItems() {
197
- this._items = I(this.items, { valueField: this.valueField }), this.dispatchEvent(
197
+ this._items = _(this.items, { valueField: this.valueField }), this.dispatchEvent(
198
198
  new CustomEvent("gui-update-items", {
199
199
  detail: this._items,
200
200
  bubbles: !0,
@@ -220,65 +220,65 @@ let l = class extends p {
220
220
  this._scrollTop = t.scrollTop;
221
221
  }
222
222
  calculateRange() {
223
- const e = this.itemHeight ?? 40, t = this.items?.length ?? 0, i = Math.ceil(this._viewportHeight / e), o = Math.floor(this._scrollTop / e), s = Math.max(0, o - this.buffer), n = Math.min(t, o + i + this.buffer), u = s * e;
224
- return { startIndex: s, endIndex: n, offsetY: u };
223
+ const e = this.itemHeight ?? 40, t = this.items?.length ?? 0, i = Math.ceil(this._viewportHeight / e), o = Math.floor(this._scrollTop / e), s = Math.max(0, o - this.buffer), n = Math.min(t, o + i + this.buffer), h = s * e;
224
+ return { startIndex: s, endIndex: n, offsetY: h };
225
225
  }
226
226
  };
227
- r([
227
+ l([
228
228
  a({ type: String })
229
- ], l.prototype, "uid", 2);
230
- r([
229
+ ], r.prototype, "uid", 2);
230
+ l([
231
231
  a({ type: Boolean })
232
- ], l.prototype, "touched", 2);
233
- r([
232
+ ], r.prototype, "touched", 2);
233
+ l([
234
234
  a({ type: Boolean })
235
- ], l.prototype, "required", 2);
236
- r([
235
+ ], r.prototype, "required", 2);
236
+ l([
237
237
  a({ type: Boolean })
238
- ], l.prototype, "disabled", 2);
239
- r([
238
+ ], r.prototype, "disabled", 2);
239
+ l([
240
240
  a({ type: Boolean, attribute: "readonly" })
241
- ], l.prototype, "readOnly", 2);
242
- r([
241
+ ], r.prototype, "readOnly", 2);
242
+ l([
243
243
  a({ type: String })
244
- ], l.prototype, "value", 2);
245
- r([
244
+ ], r.prototype, "value", 2);
245
+ l([
246
246
  a({ type: String })
247
- ], l.prototype, "valueField", 2);
248
- r([
247
+ ], r.prototype, "valueField", 2);
248
+ l([
249
249
  a({ type: String })
250
- ], l.prototype, "label", 2);
251
- r([
250
+ ], r.prototype, "label", 2);
251
+ l([
252
252
  a({ type: String })
253
- ], l.prototype, "hint", 2);
254
- r([
253
+ ], r.prototype, "hint", 2);
254
+ l([
255
255
  a({ type: Array })
256
- ], l.prototype, "items", 2);
257
- r([
256
+ ], r.prototype, "items", 2);
257
+ l([
258
258
  a({ type: Number })
259
- ], l.prototype, "itemHeight", 2);
260
- r([
259
+ ], r.prototype, "itemHeight", 2);
260
+ l([
261
261
  a({ type: Number })
262
- ], l.prototype, "height", 2);
263
- r([
262
+ ], r.prototype, "height", 2);
263
+ l([
264
264
  d()
265
- ], l.prototype, "_items", 2);
266
- r([
265
+ ], r.prototype, "_items", 2);
266
+ l([
267
267
  d()
268
- ], l.prototype, "_scrollTop", 2);
269
- r([
268
+ ], r.prototype, "_scrollTop", 2);
269
+ l([
270
270
  d()
271
- ], l.prototype, "_viewportHeight", 2);
272
- r([
271
+ ], r.prototype, "_viewportHeight", 2);
272
+ l([
273
273
  d()
274
- ], l.prototype, "_focusedIndex", 2);
275
- r([
274
+ ], r.prototype, "_focusedIndex", 2);
275
+ l([
276
276
  f(".gui-list__scroll-viewport")
277
- ], l.prototype, "viewportElement", 2);
278
- l = r([
277
+ ], r.prototype, "viewportElement", 2);
278
+ r = l([
279
279
  v("gui-list")
280
- ], l);
281
- typeof customElements < "u" && !customElements.get("gui-list") && customElements.define("gui-list", l);
280
+ ], r);
281
+ typeof customElements < "u" && !customElements.get("gui-list") && customElements.define("gui-list", r);
282
282
  export {
283
- T as d
283
+ F as d
284
284
  };
@@ -4,7 +4,7 @@ import { consume as $, provide as v } from "@lit/context";
4
4
  import { LitElement as I, nothing as n, html as u } from "lit";
5
5
  import { property as x, state as h, query as y, customElement as C } from "lit/decorators.js";
6
6
  import "rxjs";
7
- import { d as R } from "./list-CtFsv7GB.js";
7
+ import { d as R } from "./list-CVDHuXKS.js";
8
8
  import "./errors-QjKhr6mA.js";
9
9
  var w = Object.defineProperty, D = Object.getOwnPropertyDescriptor, r = (e, i, l, d) => {
10
10
  for (var t = d > 1 ? void 0 : d ? D(i, l) : i, o = e.length - 1, s; o >= 0; o--)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/gui-lit",
3
- "version": "0.15.1",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "main": "./index.umd.cjs",
6
6
  "module": "./index.js",
@@ -21,11 +21,11 @@
21
21
  "*.md"
22
22
  ],
23
23
  "peerDependencies": {
24
- "@golemui/lit": "0.15.1",
25
- "@golemui/core": "0.15.1",
26
- "@golemui/gui-components": "0.15.1",
27
- "@golemui/gui-shared": "0.15.1",
28
- "@golemui/gui-validators": "0.15.1",
24
+ "@golemui/lit": "0.16.1",
25
+ "@golemui/core": "0.16.1",
26
+ "@golemui/gui-components": "0.16.1",
27
+ "@golemui/gui-shared": "0.16.1",
28
+ "@golemui/gui-validators": "0.16.1",
29
29
  "@lit/context": "^1.1.6",
30
30
  "lit-html": "^3.3.1",
31
31
  "lit": "^3.3.1",