@cas-smartdesign/virtual-list 6.2.2

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.
@@ -0,0 +1,97 @@
1
+ import { LitElement, TemplateResult, PropertyValues } from "lit";
2
+ import { ScrollToAlignment } from "./list-util";
3
+ export { ListDataProvider } from "./data-provider";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [VirtualList.ID]: VirtualList;
7
+ }
8
+ }
9
+ export type ItemGenerator = (data: unknown, index: number) => HTMLElement;
10
+ export declare enum SelectionType {
11
+ TriggerOnly = "trigger-only",
12
+ Single = "single",
13
+ Multi = "multi"
14
+ }
15
+ export interface IDataRequestEvent {
16
+ startIndex: number;
17
+ stopIndex: number;
18
+ }
19
+ export interface ISelectionEvent {
20
+ index: number;
21
+ selected: boolean;
22
+ hasModifier: boolean;
23
+ }
24
+ export interface CustomEventMap extends HTMLElementEventMap {
25
+ "data-request": CustomEvent<IDataRequestEvent>;
26
+ selection: CustomEvent<ISelectionEvent>;
27
+ }
28
+ export default interface VirtualList {
29
+ addEventListener<K extends keyof CustomEventMap>(event: K, listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null, options?: AddEventListenerOptions | boolean): void;
30
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
31
+ removeEventListener<K extends keyof CustomEventMap>(type: K, listener: (this: this, ev: CustomEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
32
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
33
+ dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;
34
+ }
35
+ export default class VirtualList extends LitElement {
36
+ static readonly ID = "sd-virtual-list";
37
+ static ensureDefined: () => void;
38
+ itemHeight: number;
39
+ itemCount: number;
40
+ items: unknown[];
41
+ selectionType: SelectionType;
42
+ id: string;
43
+ role: string;
44
+ itemGenerator: ItemGenerator;
45
+ finalSizeIsKnown: boolean;
46
+ private _lastKnownScrollTop;
47
+ private _lastRenderedScrollTop;
48
+ private _itemsRenderData;
49
+ private _elementCache;
50
+ private _firstVisibleIndex;
51
+ private _lastVisibleIndex;
52
+ private _visibleItemsNum;
53
+ private _selectedIndices;
54
+ private _focusIndex;
55
+ private _resizeObserver;
56
+ private _lastKnownHeight;
57
+ private _increaseWidthOnNextRenderIfNeeded;
58
+ private _reachedMaxWidth;
59
+ get focusTarget(): boolean;
60
+ set focusTarget(value: boolean);
61
+ get focusIndex(): number;
62
+ set focusIndex(index: number);
63
+ get selectedIndices(): number[];
64
+ set selectedIndices(selectedIndices: number[]);
65
+ scrollToItem(index: number, alignment?: ScrollToAlignment): void;
66
+ getListItem(index: number): HTMLElement;
67
+ constructor();
68
+ connectedCallback(): void;
69
+ disconnectedCallback(): void;
70
+ firstUpdated(_changedProperties: PropertyValues): void;
71
+ private updateFocusedItemAttributes;
72
+ static get styles(): import("lit").CSSResult[];
73
+ render(): TemplateResult;
74
+ updated(_changedProperties: PropertyValues): void;
75
+ private adjustWidthIfNeeded;
76
+ private enableLineClampOnItemsIfNeeded;
77
+ /**
78
+ * Searches for list-items where there is a need for an additional width (ellipsis maybe shown) and increases the width of the list,
79
+ * therefore all the content is visible without tooltips. As it can be an expensive task to retrieve the required details, calling
80
+ * this function has an effect only on the very next render. Note that it only works if the virtual-list works with sd-list-item elements.
81
+ * If the maximum width is reached, line clamp is enabled on list items as a last resort approach to show the content if possible.
82
+ */
83
+ increaseWidthOnNextRenderIfNeeded(): void;
84
+ private updateItems;
85
+ private renderItem;
86
+ private onScroll;
87
+ private updateFocusedAttribute;
88
+ private updateSelectedAttribute;
89
+ private updateItemsRenderData;
90
+ private normalizeIndex;
91
+ private get height();
92
+ private requestData;
93
+ private handleKeyDown;
94
+ private handleSelection;
95
+ private dispatchSelectionEvent;
96
+ private handleClick;
97
+ }
@@ -0,0 +1,370 @@
1
+ import { LitElement as p, css as b, unsafeCSS as _, html as x } from "lit";
2
+ import { property as d } from "lit/decorators/property.js";
3
+ import f, { generator as g } from "@cas-smartdesign/list-item";
4
+ class C {
5
+ getOffsetForIndexAndAlignment(e, t, i, n, s, a) {
6
+ const m = Math.max(0, a * n), u = Math.min(m, e * n), c = Math.max(0, e * n - s + n);
7
+ switch (t) {
8
+ case "start":
9
+ return u;
10
+ case "end":
11
+ return c;
12
+ case "center": {
13
+ const I = Math.round(c + (u - c) / 2);
14
+ return I < Math.ceil(s / 2) ? 0 : I > m + Math.floor(s / 2) ? m : I;
15
+ }
16
+ case "auto":
17
+ default:
18
+ return i >= c && i <= u ? i : i < c ? c : u;
19
+ }
20
+ }
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ debounce(e) {
23
+ let t;
24
+ return (...i) => {
25
+ t && window.cancelAnimationFrame(t), t = window.requestAnimationFrame(() => {
26
+ e(...i), t = null;
27
+ });
28
+ };
29
+ }
30
+ }
31
+ const w = new C();
32
+ class T {
33
+ constructor(e = 100, t = 5) {
34
+ this.pageSize = e, this.preloadedItemsCount = t, this._finalSizeIsKnown = !1, this._itemCache = [], this._lastRequestedFirstIndex = 0, this._lastRequestedLastIndex = 0, this._lastLoadedIndex = 0, this.handleListDataRequest = (i) => {
35
+ const { startIndex: n, stopIndex: s } = i.detail;
36
+ this._lastRequestedFirstIndex = n, this._lastRequestedLastIndex = s, this._list.items = this._itemCache.slice(n, s + 1), !this.finalSizeIsKnown && this._lastLoadedIndex < s + this.preloadedItemsCount && this.requestData();
37
+ }, this.itemCount = e;
38
+ }
39
+ get currentPage() {
40
+ return this.items.length == 0 && this.finalSizeIsKnown ? 0 : Math.floor((this.items.length - 1) / this.pageSize);
41
+ }
42
+ get finalSizeIsKnown() {
43
+ return this._finalSizeIsKnown;
44
+ }
45
+ set finalSizeIsKnown(e) {
46
+ this._finalSizeIsKnown = e, e && (this.itemCount = this._itemCache.length), this._list && (this._list.finalSizeIsKnown = e);
47
+ }
48
+ get itemCount() {
49
+ return this._itemCount;
50
+ }
51
+ set itemCount(e) {
52
+ this._itemCount = e, this._list && (this._list.itemCount = e);
53
+ }
54
+ get items() {
55
+ return this._itemCache;
56
+ }
57
+ set items(e) {
58
+ this._itemCache = e, this.onItemsChange();
59
+ }
60
+ addItems(e) {
61
+ this._itemCache = this._itemCache.concat(e), this.onItemsChange();
62
+ }
63
+ connectList(e) {
64
+ this._list && this._list.removeEventListener("data-request", this.handleListDataRequest), this._list = e, e.itemCount = this.itemCount, e.addEventListener("data-request", this.handleListDataRequest), e.finalSizeIsKnown = this._finalSizeIsKnown;
65
+ }
66
+ onItemsChange() {
67
+ this._pendingDataRequest = !1, this._lastLoadedIndex = this._itemCache.length - 1, this.finalSizeIsKnown ? this.itemCount = this._itemCache.length : this._lastLoadedIndex > this.itemCount && (this.itemCount = this._lastLoadedIndex), this._list && (this._list.items = this._itemCache.slice(this._lastRequestedFirstIndex, this._lastRequestedLastIndex + 1));
68
+ }
69
+ requestData() {
70
+ if (!this._pendingDataRequest)
71
+ if (this.onDataRequest)
72
+ this._pendingDataRequest = !0, this.onDataRequest(this.currentPage + 1), this._lastLoadedIndex += this.pageSize - 1, this._lastLoadedIndex > this.itemCount && (this.itemCount = this._lastLoadedIndex);
73
+ else
74
+ throw Error(
75
+ "The final size is not yet known and the list would require item data from index " + this._lastRequestedFirstIndex + ". to " + this._lastRequestedLastIndex + ". which is not possible to load without a configured onDataRequest"
76
+ );
77
+ }
78
+ }
79
+ const y = ":host{display:block;position:relative;contain:layout}:host(:focus){outline:none}:host(:focus-visible) ::slotted([focused]){box-shadow:0 0 0 1px #1467ba inset}.container{width:100%}.container>::slotted(*){width:100%;position:absolute;box-sizing:border-box}.container>::slotted(:not([last])){border-bottom:1px solid #d9d9d9}";
80
+ var S = Object.defineProperty, v = Object.getOwnPropertyDescriptor, l = (h, e, t, i) => {
81
+ for (var n = i > 1 ? void 0 : i ? v(e, t) : e, s = h.length - 1, a; s >= 0; s--)
82
+ (a = h[s]) && (n = (i ? a(e, t, n) : a(n)) || n);
83
+ return i && n && S(e, t, n), n;
84
+ }, A = /* @__PURE__ */ ((h) => (h.TriggerOnly = "trigger-only", h.Single = "single", h.Multi = "multi", h))(A || {});
85
+ let L = 0;
86
+ var r;
87
+ const o = (r = class extends p {
88
+ constructor() {
89
+ super(), this.items = [], this.selectionType = "trigger-only", this.id = r.ID + "_" + L++, this.role = "listbox", this.itemGenerator = g, this._lastKnownScrollTop = 0, this._lastRenderedScrollTop = 0, this._itemsRenderData = [], this._elementCache = /* @__PURE__ */ new Map(), this._visibleItemsNum = 0, this._selectedIndices = [], this._focusIndex = -1, this._lastKnownHeight = 0, this.onScroll = () => {
90
+ this._lastKnownScrollTop = this.scrollTop;
91
+ const e = this._lastRenderedScrollTop - this._lastKnownScrollTop;
92
+ Math.abs(e) >= this.itemHeight && (this._lastRenderedScrollTop = this._lastKnownScrollTop, this.requestUpdate());
93
+ }, this.handleKeyDown = (e) => {
94
+ let t = !0;
95
+ switch (e.key) {
96
+ case "Down":
97
+ case "ArrowDown":
98
+ this.focusIndex = this.normalizeIndex(this.focusIndex + 1);
99
+ break;
100
+ case "Up":
101
+ case "ArrowUp":
102
+ this.focusIndex = this.normalizeIndex(this.focusIndex - 1);
103
+ break;
104
+ case "Enter":
105
+ this.handleSelection(this.focusIndex, e.metaKey || e.ctrlKey);
106
+ break;
107
+ case "End":
108
+ this.focusIndex = this.itemCount - 1;
109
+ break;
110
+ case "PageDown":
111
+ this.focusIndex = this.normalizeIndex(this.focusIndex + this._visibleItemsNum - 1);
112
+ break;
113
+ case "Home":
114
+ this.focusIndex = 0;
115
+ break;
116
+ case "PageUp":
117
+ this.focusIndex = this.normalizeIndex(this.focusIndex - this._visibleItemsNum + 1);
118
+ break;
119
+ default:
120
+ t = !1;
121
+ break;
122
+ }
123
+ t && (e.preventDefault(), e.stopPropagation());
124
+ }, this._resizeObserver = new ResizeObserver(() => {
125
+ this._lastKnownHeight !== this.offsetHeight && (this._lastKnownHeight = this.offsetHeight, this.requestUpdate());
126
+ });
127
+ }
128
+ get focusTarget() {
129
+ return this.hasAttribute("focus-target");
130
+ }
131
+ set focusTarget(e) {
132
+ this.toggleAttribute("focus-target", e);
133
+ }
134
+ get focusIndex() {
135
+ return this._focusIndex;
136
+ }
137
+ set focusIndex(e) {
138
+ if (e >= -1 && e < this.itemCount) {
139
+ const t = this._focusIndex;
140
+ this._focusIndex = e, (e <= this._firstVisibleIndex || this._lastVisibleIndex <= e) && this.scrollToItem(e), t != e && (e == -1 && this.removeAttribute("aria-activedescendant"), this.requestUpdate("focusIndex", t));
141
+ }
142
+ }
143
+ get selectedIndices() {
144
+ return this._selectedIndices;
145
+ }
146
+ set selectedIndices(e) {
147
+ e ? this._selectedIndices = e.map((t) => Number(t)) : this._selectedIndices = [], this.requestUpdate("selectedIndices");
148
+ }
149
+ scrollToItem(e, t = "auto") {
150
+ this.scrollTop = w.getOffsetForIndexAndAlignment(
151
+ this.normalizeIndex(e),
152
+ t,
153
+ this.scrollTop,
154
+ this.itemHeight,
155
+ this.height,
156
+ this.itemCount
157
+ ), this._lastKnownScrollTop = this.scrollTop;
158
+ }
159
+ getListItem(e) {
160
+ return !this.shadowRoot || e < this._firstVisibleIndex || this._lastVisibleIndex < e ? null : this.querySelector(`[item-index="${e}"]`);
161
+ }
162
+ connectedCallback() {
163
+ super.connectedCallback(), this._resizeObserver.observe(this), this.scrollTop !== this._lastKnownScrollTop && (this.scrollTop = this._lastKnownScrollTop, this.requestUpdate());
164
+ }
165
+ disconnectedCallback() {
166
+ super.disconnectedCallback(), this._resizeObserver.disconnect();
167
+ }
168
+ firstUpdated(e) {
169
+ super.firstUpdated(e), this.addEventListener("scroll", this.onScroll), this.addEventListener("keydown", this.handleKeyDown), this.addEventListener("click", this.handleClick), this.addEventListener("mousedown", (t) => {
170
+ t.button == 1 && t.preventDefault();
171
+ }), this.addEventListener("auxclick", this.handleClick), this.addEventListener("focus", () => {
172
+ this.matches(":focus-visible") && (this.focusIndex == -1 ? (this.selectedIndices && (this.focusIndex = this.selectedIndices[0]), this.focusIndex == -1 && this.itemCount > 0 && (this.focusIndex = 0)) : this.updateFocusedItemAttributes());
173
+ }), this.addEventListener("blur", () => {
174
+ this.focusIndex != -1 && this.updateFocusedItemAttributes();
175
+ }), this.selectedIndices.length > 0 && this.scrollToItem(this.selectedIndices[0], "center");
176
+ }
177
+ updateFocusedItemAttributes() {
178
+ const e = this.getListItem(this.focusIndex);
179
+ e && (this.focusTarget || document.activeElement == this ? (e.setAttribute("focused", ""), this.setAttribute("aria-activedescendant", e.id)) : (e.removeAttribute("focused"), this.removeAttribute("aria-activedescendant")));
180
+ }
181
+ static get styles() {
182
+ return [
183
+ b`
184
+ ${_(y)}
185
+ `
186
+ ];
187
+ }
188
+ render() {
189
+ return this.updateItemsRenderData(), x`
190
+ <div class="container" style="height: ${this.itemCount * this.itemHeight}px">
191
+ <slot name="items"></slot>
192
+ </div>
193
+ `;
194
+ }
195
+ updated(e) {
196
+ if (super.updated(e), this._lastRenderedScrollTop = this._lastKnownScrollTop, this.updateItems(), (this._increaseWidthOnNextRenderIfNeeded || this._reachedMaxWidth) && //
197
+ this._firstVisibleIndex < this._lastVisibleIndex)
198
+ if (this.querySelector("[item-index]"))
199
+ this.adjustWidthIfNeeded();
200
+ else {
201
+ const t = new MutationObserver(() => {
202
+ this.adjustWidthIfNeeded(), t.disconnect();
203
+ });
204
+ t.observe(this);
205
+ }
206
+ }
207
+ adjustWidthIfNeeded() {
208
+ this._increaseWidthOnNextRenderIfNeeded ? (this._increaseWidthOnNextRenderIfNeeded = !1, window.requestAnimationFrame(() => {
209
+ const e = Number.parseInt(getComputedStyle(this).maxWidth) - this.offsetWidth;
210
+ if (e == 0)
211
+ this._reachedMaxWidth = !0, this.enableLineClampOnItemsIfNeeded();
212
+ else {
213
+ this._reachedMaxWidth = !1;
214
+ const t = [...this.querySelectorAll("[item-index]")].map((n) => {
215
+ if (n instanceof f) {
216
+ n.enableLineClamp = !1;
217
+ const s = n.missingWidthForTexts;
218
+ return s > e && (n.enableLineClamp = !0), s;
219
+ }
220
+ }), i = Math.max(...t);
221
+ i > 0 && (this.style.width = `${this.offsetWidth + i}px`);
222
+ }
223
+ })) : this._reachedMaxWidth && this.enableLineClampOnItemsIfNeeded();
224
+ }
225
+ enableLineClampOnItemsIfNeeded() {
226
+ this.querySelectorAll("[item-index]").forEach((e) => {
227
+ e instanceof f && (e.enableLineClamp = e.enableLineClamp || e.missingWidthForTexts > 0);
228
+ });
229
+ }
230
+ /**
231
+ * Searches for list-items where there is a need for an additional width (ellipsis maybe shown) and increases the width of the list,
232
+ * therefore all the content is visible without tooltips. As it can be an expensive task to retrieve the required details, calling
233
+ * this function has an effect only on the very next render. Note that it only works if the virtual-list works with sd-list-item elements.
234
+ * If the maximum width is reached, line clamp is enabled on list items as a last resort approach to show the content if possible.
235
+ */
236
+ increaseWidthOnNextRenderIfNeeded() {
237
+ this._increaseWidthOnNextRenderIfNeeded = !0;
238
+ }
239
+ updateItems() {
240
+ const e = [...this.querySelectorAll("[item-index]")], t = /* @__PURE__ */ new Map(), i = document.createDocumentFragment();
241
+ for (const n of this._itemsRenderData) {
242
+ const s = this.renderItem(n);
243
+ s.parentElement || i.appendChild(s), t.set(n.dataHash, s);
244
+ const a = e.indexOf(s);
245
+ a !== -1 && e.splice(a, 1);
246
+ }
247
+ this.appendChild(i);
248
+ for (const n of e)
249
+ n instanceof f && (n.enableLineClamp = !1), this.removeChild(n);
250
+ t.forEach((n, s) => {
251
+ this._elementCache.set(s, n);
252
+ });
253
+ }
254
+ renderItem({ index: e, top: t, dataHash: i, data: n }) {
255
+ let s;
256
+ return n ? this._elementCache.has(i) ? (s = this._elementCache.get(i), this._elementCache.delete(i)) : (s = this.itemGenerator(n, e), s.setAttribute("slot", "items")) : (s = document.createElement("div"), s.setAttribute("placeholder-item", ""), s.setAttribute("slot", "items")), Object.assign(s.style, {
257
+ transform: `translateY(${t}px)`,
258
+ height: `${this.itemHeight}px`
259
+ }), s.setAttribute("item-index", e.toString()), s.setAttribute("aria-setsize", String(this.finalSizeIsKnown ? this.itemCount : -1)), s.setAttribute("aria-posinset", String(e + 1)), (!s.id || s.id.startsWith(this.id + "_item_")) && (s.id = this.id + "_item_" + e), this.itemCount - 1 == e ? s.setAttribute("last", "") : s.removeAttribute("last"), this.updateSelectedAttribute(e, s), this.updateFocusedAttribute(e, s), s;
260
+ }
261
+ updateFocusedAttribute(e, t) {
262
+ this.focusIndex == e && (this.focusTarget || document.activeElement == this) ? (t.setAttribute("focused", ""), this.setAttribute("aria-activedescendant", t.id)) : t.removeAttribute("focused");
263
+ }
264
+ updateSelectedAttribute(e, t) {
265
+ const i = this.selectedIndices.indexOf(e) !== -1;
266
+ i ? t.setAttribute("selected", "") : t.removeAttribute("selected"), t.setAttribute("aria-selected", String(i));
267
+ }
268
+ updateItemsRenderData() {
269
+ if (this._itemsRenderData = [], this._visibleItemsNum = Math.min(Math.ceil(this.height / this.itemHeight), this.itemCount), this._visibleItemsNum > 0) {
270
+ this._firstVisibleIndex = this.normalizeIndex(Math.floor(this._lastKnownScrollTop / this.itemHeight)), this._lastVisibleIndex = this.normalizeIndex(this._firstVisibleIndex + this._visibleItemsNum);
271
+ const e = this.normalizeIndex(this._firstVisibleIndex - 2), t = this.normalizeIndex(this._lastVisibleIndex + 2);
272
+ this.requestData(e, t);
273
+ for (let i = e; i <= t; i++) {
274
+ const n = i - e, s = this.items[n];
275
+ let a;
276
+ s ? a = JSON.stringify(s) : a = `placeholder-${n}`, this._itemsRenderData.push({
277
+ index: i,
278
+ top: this.itemHeight * i,
279
+ physicalIndex: n,
280
+ dataHash: a,
281
+ data: s
282
+ });
283
+ }
284
+ } else
285
+ this._firstVisibleIndex = 0, this._lastVisibleIndex = 0;
286
+ }
287
+ normalizeIndex(e) {
288
+ return Math.max(0, Math.min(e, this.itemCount - 1));
289
+ }
290
+ get height() {
291
+ return this.offsetHeight;
292
+ }
293
+ requestData(e, t) {
294
+ !Number.isNaN(e) && !Number.isNaN(t) && this.dispatchEvent(
295
+ new CustomEvent("data-request", {
296
+ detail: {
297
+ startIndex: e,
298
+ stopIndex: t
299
+ }
300
+ })
301
+ );
302
+ }
303
+ handleSelection(e, t) {
304
+ if (e < 0 || this.itemCount <= e)
305
+ return;
306
+ const i = e % this._visibleItemsNum, n = this.items[i];
307
+ if (!n || n.disabled)
308
+ return;
309
+ let s = !0;
310
+ if (this.selectionType !== "trigger-only") {
311
+ const a = this.selectedIndices.indexOf(e);
312
+ s = a == -1, s ? this.selectionType === "single" ? this.selectedIndices = [e] : this.selectedIndices.push(e) : this.selectedIndices.splice(a, 1), this.requestUpdate("selectedIndices");
313
+ }
314
+ this.focusIndex = e, this.dispatchSelectionEvent(e, s, t);
315
+ }
316
+ dispatchSelectionEvent(e, t, i) {
317
+ this.dispatchEvent(
318
+ new CustomEvent("selection", {
319
+ detail: { index: e, selected: t, hasModifier: i }
320
+ })
321
+ );
322
+ }
323
+ handleClick(e) {
324
+ const t = e.composedPath().find((i) => i.hasAttribute && i.hasAttribute("item-index"));
325
+ if (t) {
326
+ const i = parseInt(t.getAttribute("item-index"));
327
+ if (Number.isInteger(i)) {
328
+ if (e.button == 0 || e.button == 1) {
329
+ const n = e.type == "auxclick" && e.button == 1 || e.metaKey || e.ctrlKey;
330
+ this.handleSelection(i, n);
331
+ }
332
+ this.focusIndex = i;
333
+ }
334
+ }
335
+ }
336
+ }, r.ID = "sd-virtual-list", r.ensureDefined = () => {
337
+ f.ensureDefined(), customElements.get(r.ID) || customElements.define(r.ID, r);
338
+ }, r);
339
+ l([
340
+ d({ type: Number, attribute: "item-height", reflect: !0 })
341
+ ], o.prototype, "itemHeight", 2);
342
+ l([
343
+ d({ type: Number })
344
+ ], o.prototype, "itemCount", 2);
345
+ l([
346
+ d({ type: Array, attribute: !1 })
347
+ ], o.prototype, "items", 2);
348
+ l([
349
+ d({ type: String, attribute: "selection-type", reflect: !0, noAccessor: !0 })
350
+ ], o.prototype, "selectionType", 2);
351
+ l([
352
+ d({ type: String, attribute: !0, reflect: !0 })
353
+ ], o.prototype, "id", 2);
354
+ l([
355
+ d({ type: String, reflect: !0 })
356
+ ], o.prototype, "role", 2);
357
+ l([
358
+ d({ type: Number, attribute: "focus-index", reflect: !0 })
359
+ ], o.prototype, "focusIndex", 1);
360
+ l([
361
+ d({ type: Array, attribute: !1 })
362
+ ], o.prototype, "selectedIndices", 1);
363
+ let D = o;
364
+ D.ensureDefined();
365
+ export {
366
+ T as ListDataProvider,
367
+ A as SelectionType,
368
+ D as default
369
+ };
370
+ //# sourceMappingURL=virtual-list.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-list.mjs","sources":["../list-util.ts","../data-provider.ts","../virtual-list.ts"],"sourcesContent":["export type ScrollToAlignment = \"auto\" | \"center\" | \"start\" | \"end\";\n\nexport interface IListUtil {\n getOffsetForIndexAndAlignment(\n index: number,\n alignment: ScrollToAlignment,\n scrollOffset: number,\n itemHeight: number,\n height: number,\n itemCount: number,\n ): number;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n debounce(func: (...args: any) => void): () => void;\n}\n\nclass ListUtil implements IListUtil {\n public getOffsetForIndexAndAlignment(\n index: number,\n alignment: ScrollToAlignment,\n scrollOffset: number,\n itemHeight: number,\n height: number,\n itemCount: number,\n ): number {\n const lastItemOffset = Math.max(0, itemCount * itemHeight);\n const maxOffset = Math.min(lastItemOffset, index * itemHeight);\n const minOffset = Math.max(0, index * itemHeight - height + itemHeight);\n\n switch (alignment) {\n case \"start\":\n return maxOffset;\n case \"end\":\n return minOffset;\n case \"center\": {\n const middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);\n if (middleOffset < Math.ceil(height / 2)) {\n return 0;\n } else if (middleOffset > lastItemOffset + Math.floor(height / 2)) {\n return lastItemOffset;\n } else {\n return middleOffset;\n }\n }\n case \"auto\":\n default:\n if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {\n return scrollOffset;\n } else if (scrollOffset < minOffset) {\n return minOffset;\n } else {\n return maxOffset;\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public debounce(func: (...args: any) => void): (...args: unknown[]) => void {\n let timer: number;\n return (...args: unknown[]) => {\n if (timer) {\n window.cancelAnimationFrame(timer);\n }\n timer = window.requestAnimationFrame(() => {\n func(...args);\n timer = null;\n });\n };\n }\n}\n\nexport default new ListUtil();\n","import VirtualList from \"./virtual-list\";\n\nexport class ListDataProvider {\n public onDataRequest: (page: number) => void;\n\n private _finalSizeIsKnown = false;\n private _itemCache: unknown[] = [];\n private _lastRequestedFirstIndex = 0;\n private _lastRequestedLastIndex = 0;\n private _lastLoadedIndex = 0;\n private _list: VirtualList;\n private _itemCount: number;\n private _pendingDataRequest: boolean;\n\n constructor(\n public pageSize: number = 100,\n public preloadedItemsCount: number = 5,\n ) {\n this.itemCount = pageSize; // configure initial load\n }\n\n public get currentPage(): number {\n if (this.items.length == 0 && this.finalSizeIsKnown) {\n return 0; // Otherwise empty cache means we haven't fetched anything\n }\n // With pageSize 100\n // 0 => -1\n // 1 100 => 0\n // 101 200 => 1\n return Math.floor((this.items.length - 1) / this.pageSize);\n }\n\n public get finalSizeIsKnown(): boolean {\n return this._finalSizeIsKnown;\n }\n\n public set finalSizeIsKnown(value: boolean) {\n this._finalSizeIsKnown = value;\n if (value) {\n this.itemCount = this._itemCache.length;\n }\n if (this._list) {\n this._list.finalSizeIsKnown = value;\n }\n }\n\n private get itemCount(): number {\n return this._itemCount;\n }\n\n private set itemCount(count: number) {\n this._itemCount = count;\n if (this._list) {\n this._list.itemCount = count;\n }\n }\n\n public get items(): unknown[] {\n return this._itemCache;\n }\n\n public set items(items: unknown[]) {\n this._itemCache = items;\n this.onItemsChange();\n }\n\n public addItems(items: unknown[]): void {\n this._itemCache = this._itemCache.concat(items);\n this.onItemsChange();\n }\n\n public connectList(list: VirtualList): void {\n if (this._list) {\n this._list.removeEventListener(\"data-request\", this.handleListDataRequest);\n }\n this._list = list;\n list.itemCount = this.itemCount;\n list.addEventListener(\"data-request\", this.handleListDataRequest);\n list.finalSizeIsKnown = this._finalSizeIsKnown;\n }\n\n private onItemsChange(): void {\n this._pendingDataRequest = false;\n this._lastLoadedIndex = this._itemCache.length - 1;\n if (this.finalSizeIsKnown) {\n this.itemCount = this._itemCache.length;\n } else if (this._lastLoadedIndex > this.itemCount) {\n this.itemCount = this._lastLoadedIndex;\n }\n if (this._list) {\n this._list.items = this._itemCache.slice(this._lastRequestedFirstIndex, this._lastRequestedLastIndex + 1);\n }\n }\n\n private handleListDataRequest = (event: CustomEvent) => {\n const { startIndex, stopIndex } = event.detail;\n this._lastRequestedFirstIndex = startIndex;\n this._lastRequestedLastIndex = stopIndex;\n this._list.items = this._itemCache.slice(startIndex, stopIndex + 1);\n\n if (!this.finalSizeIsKnown && this._lastLoadedIndex < stopIndex + this.preloadedItemsCount) {\n this.requestData();\n }\n };\n\n private requestData(): void {\n if (this._pendingDataRequest) {\n return;\n }\n if (this.onDataRequest) {\n this._pendingDataRequest = true;\n this.onDataRequest(this.currentPage + 1);\n this._lastLoadedIndex += this.pageSize - 1;\n if (this._lastLoadedIndex > this.itemCount) {\n this.itemCount = this._lastLoadedIndex;\n }\n } else {\n throw Error(\n \"The final size is not yet known and the list would require item data from index \" +\n this._lastRequestedFirstIndex +\n \". to \" +\n this._lastRequestedLastIndex +\n \". which is not possible to load without a configured onDataRequest\",\n );\n }\n }\n}\n","import { LitElement, TemplateResult, html, unsafeCSS, PropertyValues, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport ListUtil, { ScrollToAlignment } from \"./list-util\";\nimport ListItem, { generator } from \"@cas-smartdesign/list-item\";\nexport { ListDataProvider } from \"./data-provider\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [VirtualList.ID]: VirtualList;\n }\n}\n\nimport style from \"./style.scss?inline\";\n\nexport type ItemGenerator = (data: unknown, index: number) => HTMLElement;\nexport enum SelectionType {\n TriggerOnly = \"trigger-only\",\n Single = \"single\",\n Multi = \"multi\",\n}\n\ninterface ItemRenderData {\n index: number;\n top: number;\n physicalIndex: number;\n dataHash: string;\n data?: unknown;\n}\n\nlet idCounter = 0;\n\nexport interface IDataRequestEvent {\n startIndex: number;\n stopIndex: number;\n}\n\nexport interface ISelectionEvent {\n index: number;\n selected: boolean;\n hasModifier: boolean;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"data-request\": CustomEvent<IDataRequestEvent>;\n selection: CustomEvent<ISelectionEvent>;\n}\n\nexport default interface VirtualList {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class VirtualList extends LitElement {\n public static readonly ID = \"sd-virtual-list\";\n public static ensureDefined = (): void => {\n ListItem.ensureDefined();\n if (!customElements.get(VirtualList.ID)) {\n customElements.define(VirtualList.ID, VirtualList);\n }\n };\n\n @property({ type: Number, attribute: \"item-height\", reflect: true })\n public itemHeight: number;\n @property({ type: Number })\n public itemCount: number;\n @property({ type: Array, attribute: false })\n public items: unknown[] = [];\n @property({ type: String, attribute: \"selection-type\", reflect: true, noAccessor: true })\n public selectionType: SelectionType = SelectionType.TriggerOnly;\n @property({ type: String, attribute: true, reflect: true })\n public id: string = VirtualList.ID + \"_\" + idCounter++;\n\n // aria attributes\n @property({ type: String, reflect: true })\n public role = \"listbox\";\n\n public itemGenerator: ItemGenerator = generator;\n public finalSizeIsKnown: boolean;\n\n private _lastKnownScrollTop = 0;\n private _lastRenderedScrollTop = 0;\n\n private _itemsRenderData: ItemRenderData[] = [];\n private _elementCache: Map<string, HTMLElement> = new Map();\n\n private _firstVisibleIndex: number;\n private _lastVisibleIndex: number;\n private _visibleItemsNum = 0;\n\n private _selectedIndices: number[] = [];\n private _focusIndex = -1;\n private _resizeObserver: ResizeObserver;\n private _lastKnownHeight = 0;\n private _increaseWidthOnNextRenderIfNeeded: boolean;\n private _reachedMaxWidth: boolean;\n\n public get focusTarget(): boolean {\n return this.hasAttribute(\"focus-target\");\n }\n\n public set focusTarget(value: boolean) {\n this.toggleAttribute(\"focus-target\", value);\n }\n\n @property({ type: Number, attribute: \"focus-index\", reflect: true })\n public get focusIndex(): number {\n return this._focusIndex;\n }\n\n public set focusIndex(index: number) {\n if (index >= -1 && index < this.itemCount) {\n const oldValue = this._focusIndex;\n this._focusIndex = index;\n if (index <= this._firstVisibleIndex || this._lastVisibleIndex <= index) {\n this.scrollToItem(index);\n }\n if (oldValue != index) {\n if (index == -1) {\n this.removeAttribute(\"aria-activedescendant\");\n }\n this.requestUpdate(\"focusIndex\", oldValue);\n }\n }\n }\n\n @property({ type: Array, attribute: false })\n public get selectedIndices(): number[] {\n return this._selectedIndices;\n }\n\n public set selectedIndices(selectedIndices: number[]) {\n if (selectedIndices) {\n // Parse to primitive numbers as the virtual-list uses numbers and not objects for the indexOf(item-index) checks.\n this._selectedIndices = selectedIndices.map((index) => Number(index));\n } else {\n this._selectedIndices = [];\n }\n this.requestUpdate(\"selectedIndices\");\n }\n\n public scrollToItem(index: number, alignment: ScrollToAlignment = \"auto\"): void {\n this.scrollTop = ListUtil.getOffsetForIndexAndAlignment(\n this.normalizeIndex(index),\n alignment,\n this.scrollTop,\n this.itemHeight,\n this.height,\n this.itemCount,\n );\n // The render might have already been scheduled, but the onScroll event is dispatched later.\n // We need to update the _lastKnownScrollTop manually to ensure an up-to-date value is used even for the next render.\n this._lastKnownScrollTop = this.scrollTop;\n }\n\n public getListItem(index: number): HTMLElement {\n if (!this.shadowRoot || index < this._firstVisibleIndex || this._lastVisibleIndex < index) {\n return null;\n }\n return this.querySelector(`[item-index=\"${index}\"]`);\n }\n\n constructor() {\n super();\n this._resizeObserver = new ResizeObserver(() => {\n if (this._lastKnownHeight !== this.offsetHeight) {\n this._lastKnownHeight = this.offsetHeight;\n this.requestUpdate();\n }\n });\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n\n this._resizeObserver.observe(this);\n // these are needed because when reattaching the list to the DOM\n // then the scroll position is reset but no scroll event is called\n // so the list shows the items at incorrect position\n if (this.scrollTop !== this._lastKnownScrollTop) {\n this.scrollTop = this._lastKnownScrollTop;\n this.requestUpdate();\n }\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n this._resizeObserver.disconnect();\n }\n\n public firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n\n this.addEventListener(\"scroll\", this.onScroll);\n this.addEventListener(\"keydown\", this.handleKeyDown);\n this.addEventListener(\"click\", this.handleClick);\n this.addEventListener(\"mousedown\", (event) => {\n if (event.button == 1) {\n event.preventDefault();\n }\n });\n this.addEventListener(\"auxclick\", this.handleClick);\n this.addEventListener(\"focus\", () => {\n if (this.matches(\":focus-visible\")) {\n if (this.focusIndex == -1) {\n if (this.selectedIndices) {\n this.focusIndex = this.selectedIndices[0];\n }\n if (this.focusIndex == -1 && this.itemCount > 0) {\n this.focusIndex = 0;\n }\n } else {\n this.updateFocusedItemAttributes();\n }\n }\n });\n this.addEventListener(\"blur\", () => {\n if (this.focusIndex != -1) {\n this.updateFocusedItemAttributes();\n }\n });\n if (this.selectedIndices.length > 0) {\n this.scrollToItem(this.selectedIndices[0], \"center\");\n }\n }\n\n private updateFocusedItemAttributes() {\n const focusedElement = this.getListItem(this.focusIndex);\n if (focusedElement) {\n if (this.focusTarget || document.activeElement == this) {\n focusedElement.setAttribute(\"focused\", \"\");\n this.setAttribute(\"aria-activedescendant\", focusedElement.id);\n } else {\n focusedElement.removeAttribute(\"focused\");\n this.removeAttribute(\"aria-activedescendant\");\n }\n }\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n public render(): TemplateResult {\n this.updateItemsRenderData();\n return html`\n <div class=\"container\" style=\"height: ${this.itemCount * this.itemHeight}px\">\n <slot name=\"items\"></slot>\n </div>\n `;\n }\n\n public updated(_changedProperties: PropertyValues): void {\n super.updated(_changedProperties);\n this._lastRenderedScrollTop = this._lastKnownScrollTop;\n this.updateItems();\n\n if (\n (this._increaseWidthOnNextRenderIfNeeded || this._reachedMaxWidth) && //\n this._firstVisibleIndex < this._lastVisibleIndex\n ) {\n if (!this.querySelector(\"[item-index]\")) {\n // If ShadyDOM is in use, then it needs a delay, because dom mutations are not applied immediately.\n const observer = new MutationObserver(() => {\n this.adjustWidthIfNeeded();\n observer.disconnect();\n });\n observer.observe(this);\n } else {\n this.adjustWidthIfNeeded();\n }\n }\n }\n\n private adjustWidthIfNeeded() {\n if (this._increaseWidthOnNextRenderIfNeeded) {\n this._increaseWidthOnNextRenderIfNeeded = false;\n window.requestAnimationFrame(() => {\n const remainingWidth = Number.parseInt(getComputedStyle(this).maxWidth) - this.offsetWidth;\n if (remainingWidth == 0) {\n this._reachedMaxWidth = true;\n this.enableLineClampOnItemsIfNeeded();\n } else {\n this._reachedMaxWidth = false;\n const missingWidths = [...this.querySelectorAll(\"[item-index]\")].map((item) => {\n if (item instanceof ListItem) {\n item.enableLineClamp = false;\n const missingWidthForTexts = item.missingWidthForTexts;\n if (missingWidthForTexts > remainingWidth) {\n item.enableLineClamp = true;\n }\n return missingWidthForTexts;\n }\n });\n const additionalWidth = Math.max(...missingWidths);\n if (additionalWidth > 0) {\n this.style.width = `${this.offsetWidth + additionalWidth}px`;\n }\n }\n });\n } else if (this._reachedMaxWidth) {\n this.enableLineClampOnItemsIfNeeded();\n }\n }\n\n private enableLineClampOnItemsIfNeeded() {\n this.querySelectorAll(\"[item-index]\").forEach((item) => {\n if (item instanceof ListItem) {\n item.enableLineClamp = item.enableLineClamp || item.missingWidthForTexts > 0;\n }\n });\n }\n\n /**\n * Searches for list-items where there is a need for an additional width (ellipsis maybe shown) and increases the width of the list,\n * therefore all the content is visible without tooltips. As it can be an expensive task to retrieve the required details, calling\n * this function has an effect only on the very next render. Note that it only works if the virtual-list works with sd-list-item elements.\n * If the maximum width is reached, line clamp is enabled on list items as a last resort approach to show the content if possible.\n */\n public increaseWidthOnNextRenderIfNeeded(): void {\n this._increaseWidthOnNextRenderIfNeeded = true;\n }\n\n private updateItems() {\n const unusedItems: Element[] = [...this.querySelectorAll(\"[item-index]\")];\n const renderedItems: Map<string, HTMLElement> = new Map();\n\n const newItemsFragment = document.createDocumentFragment();\n for (const renderData of this._itemsRenderData) {\n const itemElement = this.renderItem(renderData);\n if (!itemElement.parentElement) {\n newItemsFragment.appendChild(itemElement);\n }\n renderedItems.set(renderData.dataHash, itemElement);\n const index = unusedItems.indexOf(itemElement);\n if (index !== -1) {\n unusedItems.splice(index, 1);\n }\n }\n this.appendChild(newItemsFragment);\n\n for (const unusedItemElement of unusedItems) {\n if (unusedItemElement instanceof ListItem) {\n unusedItemElement.enableLineClamp = false;\n }\n this.removeChild(unusedItemElement);\n }\n\n renderedItems.forEach((itemElement, dataHash) => {\n this._elementCache.set(dataHash, itemElement);\n });\n }\n\n private renderItem({ index, top, dataHash, data }: ItemRenderData): HTMLElement {\n let element: HTMLElement;\n if (data) {\n if (this._elementCache.has(dataHash)) {\n element = this._elementCache.get(dataHash);\n this._elementCache.delete(dataHash); // Allow to be rendered twice\n } else {\n element = this.itemGenerator(data, index);\n element.setAttribute(\"slot\", \"items\");\n // Do not add to cache yet, because the same item might need to be rendered twice\n }\n } else {\n element = document.createElement(\"div\");\n element.setAttribute(\"placeholder-item\", \"\");\n element.setAttribute(\"slot\", \"items\");\n }\n Object.assign(element.style, {\n transform: `translateY(${top}px)`,\n height: `${this.itemHeight}px`,\n });\n element.setAttribute(\"item-index\", index.toString());\n element.setAttribute(\"aria-setsize\", String(this.finalSizeIsKnown ? this.itemCount : -1));\n element.setAttribute(\"aria-posinset\", String(index + 1));\n if (!element.id || element.id.startsWith(this.id + \"_item_\")) {\n element.id = this.id + \"_item_\" + index;\n }\n if (this.itemCount - 1 == index) {\n element.setAttribute(\"last\", \"\");\n } else {\n element.removeAttribute(\"last\");\n }\n\n this.updateSelectedAttribute(index, element);\n this.updateFocusedAttribute(index, element);\n\n return element;\n }\n\n private onScroll = () => {\n this._lastKnownScrollTop = this.scrollTop;\n const delta = this._lastRenderedScrollTop - this._lastKnownScrollTop;\n if (Math.abs(delta) >= this.itemHeight) {\n this._lastRenderedScrollTop = this._lastKnownScrollTop;\n this.requestUpdate();\n }\n };\n\n private updateFocusedAttribute(index: number, itemElement: HTMLElement) {\n if (this.focusIndex == index && (this.focusTarget || document.activeElement == this)) {\n itemElement.setAttribute(\"focused\", \"\");\n this.setAttribute(\"aria-activedescendant\", itemElement.id);\n } else {\n itemElement.removeAttribute(\"focused\");\n }\n }\n\n private updateSelectedAttribute(index: number, itemElement: HTMLElement) {\n const selected = this.selectedIndices.indexOf(index) !== -1;\n if (selected) {\n itemElement.setAttribute(\"selected\", \"\");\n } else {\n itemElement.removeAttribute(\"selected\");\n }\n itemElement.setAttribute(\"aria-selected\", String(selected));\n }\n\n private updateItemsRenderData(): void {\n this._itemsRenderData = [];\n this._visibleItemsNum = Math.min(Math.ceil(this.height / this.itemHeight), this.itemCount);\n\n if (this._visibleItemsNum > 0) {\n this._firstVisibleIndex = this.normalizeIndex(Math.floor(this._lastKnownScrollTop / this.itemHeight));\n this._lastVisibleIndex = this.normalizeIndex(this._firstVisibleIndex + this._visibleItemsNum);\n\n const firstRenderedIndex = this.normalizeIndex(this._firstVisibleIndex - 2);\n const lastRenderedIndex = this.normalizeIndex(this._lastVisibleIndex + 2);\n\n // May update value of this.items, which could trigger another render if not called from a lifecycle callback where it is ignored\n this.requestData(firstRenderedIndex, lastRenderedIndex);\n\n for (let i = firstRenderedIndex; i <= lastRenderedIndex; i++) {\n const physicalIndex = i - firstRenderedIndex;\n const itemData = this.items[physicalIndex];\n let dataHash;\n if (itemData) {\n dataHash = JSON.stringify(itemData);\n } else {\n dataHash = `placeholder-${physicalIndex}`;\n }\n this._itemsRenderData.push({\n index: i,\n top: this.itemHeight * i,\n physicalIndex,\n dataHash,\n data: itemData,\n });\n }\n } else {\n this._firstVisibleIndex = 0;\n this._lastVisibleIndex = 0;\n }\n }\n\n private normalizeIndex(index: number): number {\n return Math.max(0, Math.min(index, this.itemCount - 1));\n }\n\n private get height(): number {\n return this.offsetHeight;\n }\n\n private requestData(firstRenderedIndex: number, lastRenderedIndex: number): void {\n if (!Number.isNaN(firstRenderedIndex) && !Number.isNaN(lastRenderedIndex)) {\n this.dispatchEvent(\n new CustomEvent<IDataRequestEvent>(\"data-request\", {\n detail: {\n startIndex: firstRenderedIndex,\n stopIndex: lastRenderedIndex,\n },\n }),\n );\n }\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n let shouldPrevent = true;\n switch (event.key) {\n case \"Down\":\n case \"ArrowDown\":\n this.focusIndex = this.normalizeIndex(this.focusIndex + 1);\n break;\n case \"Up\":\n case \"ArrowUp\":\n this.focusIndex = this.normalizeIndex(this.focusIndex - 1);\n break;\n case \"Enter\":\n this.handleSelection(this.focusIndex, event.metaKey || event.ctrlKey);\n break;\n case \"End\":\n this.focusIndex = this.itemCount - 1;\n break;\n case \"PageDown\":\n this.focusIndex = this.normalizeIndex(this.focusIndex + this._visibleItemsNum - 1);\n break;\n case \"Home\":\n this.focusIndex = 0;\n break;\n case \"PageUp\":\n this.focusIndex = this.normalizeIndex(this.focusIndex - this._visibleItemsNum + 1);\n break;\n default:\n shouldPrevent = false;\n break;\n }\n if (shouldPrevent) {\n event.preventDefault();\n event.stopPropagation();\n }\n };\n\n private handleSelection(index: number, hasModifier: boolean): void {\n if (index < 0 || this.itemCount <= index) {\n return;\n }\n const physicalIndex = index % this._visibleItemsNum;\n const item = this.items[physicalIndex];\n if (!item || (item as { disabled?: boolean }).disabled) {\n return;\n }\n let hasBeenSelected = true;\n if (this.selectionType !== SelectionType.TriggerOnly) {\n const existingIndex = this.selectedIndices.indexOf(index);\n hasBeenSelected = existingIndex == -1;\n if (hasBeenSelected) {\n if (this.selectionType === SelectionType.Single) {\n this.selectedIndices = [index];\n } else {\n this.selectedIndices.push(index);\n }\n } else {\n this.selectedIndices.splice(existingIndex, 1);\n }\n this.requestUpdate(\"selectedIndices\"); // altering inside of an array does not retrigger an update\n }\n this.focusIndex = index;\n this.dispatchSelectionEvent(index, hasBeenSelected, hasModifier);\n }\n\n private dispatchSelectionEvent(index: number, selected: boolean, hasModifier: boolean): void {\n this.dispatchEvent(\n new CustomEvent<ISelectionEvent>(\"selection\", {\n detail: { index, selected, hasModifier },\n }),\n );\n }\n\n private handleClick(event: MouseEvent): void {\n const clickedElement = event\n .composedPath()\n .find((target: HTMLElement) => target.hasAttribute && target.hasAttribute(\"item-index\")) as HTMLElement;\n if (clickedElement) {\n const index = parseInt(clickedElement.getAttribute(\"item-index\"));\n if (Number.isInteger(index)) {\n if (event.button == 0 || event.button == 1) {\n const hasModifier =\n (event.type == \"auxclick\" && event.button == 1) || event.metaKey || event.ctrlKey;\n this.handleSelection(index, hasModifier);\n }\n this.focusIndex = index;\n }\n }\n }\n}\n\nVirtualList.ensureDefined();\n"],"names":["ListUtil","index","alignment","scrollOffset","itemHeight","height","itemCount","lastItemOffset","maxOffset","minOffset","middleOffset","func","timer","args","ListUtil$1","ListDataProvider","pageSize","preloadedItemsCount","event","startIndex","stopIndex","value","count","items","list","SelectionType","idCounter","_VirtualList","_a","LitElement","generator","delta","shouldPrevent","oldValue","selectedIndices","_changedProperties","focusedElement","css","unsafeCSS","style","html","observer","remainingWidth","missingWidths","item","ListItem","missingWidthForTexts","additionalWidth","unusedItems","renderedItems","newItemsFragment","renderData","itemElement","unusedItemElement","dataHash","top","data","element","selected","firstRenderedIndex","lastRenderedIndex","physicalIndex","itemData","hasModifier","hasBeenSelected","existingIndex","clickedElement","target","__decorateClass","property","VirtualList"],"mappings":";;;AAeA,MAAMA,EAA8B;AAAA,EACzB,8BACHC,GACAC,GACAC,GACAC,GACAC,GACAC,GACM;AACN,UAAMC,IAAiB,KAAK,IAAI,GAAGD,IAAYF,CAAU,GACnDI,IAAY,KAAK,IAAID,GAAgBN,IAAQG,CAAU,GACvDK,IAAY,KAAK,IAAI,GAAGR,IAAQG,IAAaC,IAASD,CAAU;AAEtE,YAAQF,GAAW;AAAA,MACf,KAAK;AACM,eAAAM;AAAA,MACX,KAAK;AACM,eAAAC;AAAA,MACX,KAAK,UAAU;AACX,cAAMC,IAAe,KAAK,MAAMD,KAAaD,IAAYC,KAAa,CAAC;AACvE,eAAIC,IAAe,KAAK,KAAKL,IAAS,CAAC,IAC5B,IACAK,IAAeH,IAAiB,KAAK,MAAMF,IAAS,CAAC,IACrDE,IAEAG;AAAA,MAEf;AAAA,MACA,KAAK;AAAA,MACL;AACQ,eAAAP,KAAgBM,KAAaN,KAAgBK,IACtCL,IACAA,IAAeM,IACfA,IAEAD;AAAA,IAEnB;AAAA,EACJ;AAAA;AAAA,EAGO,SAASG,GAA4D;AACpE,QAAAC;AACJ,WAAO,IAAIC,MAAoB;AAC3B,MAAID,KACA,OAAO,qBAAqBA,CAAK,GAE7BA,IAAA,OAAO,sBAAsB,MAAM;AACvC,QAAAD,EAAK,GAAGE,CAAI,GACJD,IAAA;AAAA,MAAA,CACX;AAAA,IAAA;AAAA,EAET;AACJ;AAEA,MAAeE,IAAA,IAAId,EAAS;ACpErB,MAAMe,EAAiB;AAAA,EAY1B,YACWC,IAAmB,KACnBC,IAA8B,GACvC;AAFS,SAAA,WAAAD,GACA,KAAA,sBAAAC,GAXX,KAAQ,oBAAoB,IAC5B,KAAQ,aAAwB,IAChC,KAAQ,2BAA2B,GACnC,KAAQ,0BAA0B,GAClC,KAAQ,mBAAmB,GAqFnB,KAAA,wBAAwB,CAACC,MAAuB;AACpD,YAAM,E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