@cas-smartdesign/virtual-list 7.0.2 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/doc.mjs +27 -16
- package/dist/virtual-list-with-externals.js +2 -2
- package/dist/virtual-list-with-externals.js.map +2 -2
- package/dist/virtual-list.mjs +128 -129
- package/dist/virtual-list.mjs.map +1 -1
- package/npm-third-party-licenses.json +16 -16
- package/package.json +5 -5
- package/readme.md +7 -0
package/dist/virtual-list.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement as p, unsafeCSS as b, css as _, html as x } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as l } from "lit/decorators/property.js";
|
|
3
3
|
import f, { generator as g } from "@cas-smartdesign/list-item";
|
|
4
4
|
class C {
|
|
5
|
-
getOffsetForIndexAndAlignment(
|
|
6
|
-
const m = Math.max(0,
|
|
7
|
-
switch (
|
|
5
|
+
getOffsetForIndexAndAlignment(t, e, i, n, s, r) {
|
|
6
|
+
const m = Math.max(0, r * n), u = Math.min(m, t * n), c = Math.max(0, t * n - s + n);
|
|
7
|
+
switch (e) {
|
|
8
8
|
case "start":
|
|
9
9
|
return u;
|
|
10
10
|
case "end":
|
|
@@ -13,28 +13,27 @@ class C {
|
|
|
13
13
|
const I = Math.round(c + (u - c) / 2);
|
|
14
14
|
return I < Math.ceil(s / 2) ? 0 : I > m + Math.floor(s / 2) ? m : I;
|
|
15
15
|
}
|
|
16
|
-
case "auto":
|
|
17
16
|
default:
|
|
18
17
|
return i >= c && i <= u ? i : i < c ? c : u;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
debounce(
|
|
23
|
-
let
|
|
21
|
+
debounce(t) {
|
|
22
|
+
let e;
|
|
24
23
|
return (...i) => {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
e && window.cancelAnimationFrame(e), e = window.requestAnimationFrame(() => {
|
|
25
|
+
t(...i), e = null;
|
|
27
26
|
});
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
const w = new C();
|
|
32
31
|
class T {
|
|
33
|
-
constructor(
|
|
34
|
-
this.pageSize =
|
|
32
|
+
constructor(t = 100, e = 5) {
|
|
33
|
+
this.pageSize = t, this.preloadedItemsCount = e, this._finalSizeIsKnown = !1, this._itemCache = [], this._lastRequestedFirstIndex = 0, this._lastRequestedLastIndex = 0, this._lastLoadedIndex = 0, this.handleListDataRequest = (i) => {
|
|
35
34
|
const { startIndex: n, stopIndex: s } = i.detail;
|
|
36
35
|
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 =
|
|
36
|
+
}, this.itemCount = t;
|
|
38
37
|
}
|
|
39
38
|
get currentPage() {
|
|
40
39
|
return this.items.length == 0 && this.finalSizeIsKnown ? 0 : Math.floor((this.items.length - 1) / this.pageSize);
|
|
@@ -42,26 +41,26 @@ class T {
|
|
|
42
41
|
get finalSizeIsKnown() {
|
|
43
42
|
return this._finalSizeIsKnown;
|
|
44
43
|
}
|
|
45
|
-
set finalSizeIsKnown(
|
|
46
|
-
this._finalSizeIsKnown =
|
|
44
|
+
set finalSizeIsKnown(t) {
|
|
45
|
+
this._finalSizeIsKnown = t, t && (this.itemCount = this._itemCache.length), this._list && (this._list.finalSizeIsKnown = t);
|
|
47
46
|
}
|
|
48
47
|
get itemCount() {
|
|
49
48
|
return this._itemCount;
|
|
50
49
|
}
|
|
51
|
-
set itemCount(
|
|
52
|
-
this._itemCount =
|
|
50
|
+
set itemCount(t) {
|
|
51
|
+
this._itemCount = t, this._list && (this._list.itemCount = t);
|
|
53
52
|
}
|
|
54
53
|
get items() {
|
|
55
54
|
return this._itemCache;
|
|
56
55
|
}
|
|
57
|
-
set items(
|
|
58
|
-
this._itemCache =
|
|
56
|
+
set items(t) {
|
|
57
|
+
this._itemCache = t, this.onItemsChange();
|
|
59
58
|
}
|
|
60
|
-
addItems(
|
|
61
|
-
this._itemCache = this._itemCache.concat(
|
|
59
|
+
addItems(t) {
|
|
60
|
+
this._itemCache = this._itemCache.concat(t), this.onItemsChange();
|
|
62
61
|
}
|
|
63
|
-
connectList(
|
|
64
|
-
this._list && this._list.removeEventListener("data-request", this.handleListDataRequest), this._list =
|
|
62
|
+
connectList(t) {
|
|
63
|
+
this._list && this._list.removeEventListener("data-request", this.handleListDataRequest), this._list = t, t.itemCount = this.itemCount, t.addEventListener("data-request", this.handleListDataRequest), t.finalSizeIsKnown = this._finalSizeIsKnown;
|
|
65
64
|
}
|
|
66
65
|
onItemsChange() {
|
|
67
66
|
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));
|
|
@@ -76,23 +75,23 @@ class T {
|
|
|
76
75
|
);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
const
|
|
80
|
-
var
|
|
81
|
-
for (var n = i > 1 ? void 0 : i ? A(
|
|
82
|
-
(
|
|
83
|
-
return i && n &&
|
|
78
|
+
const v = ":host{display:block;position:relative;contain:layout;--sd-virtual-list-focus-highlight-color: #1467ba;--sd-virtual-list-item-separator-color: #d9d9d9}:host(:focus){outline:none}:host(:focus-visible) ::slotted([focused]){box-shadow:0 0 0 1px var(--sd-virtual-list-focus-highlight-color) inset}.container{width:100%}.container>::slotted(*){width:100%;position:absolute;box-sizing:border-box}.container>::slotted(:not([last])){border-bottom:1px solid var(--sd-virtual-list-item-separator-color)}";
|
|
79
|
+
var S = Object.defineProperty, A = Object.getOwnPropertyDescriptor, d = (h, t, e, i) => {
|
|
80
|
+
for (var n = i > 1 ? void 0 : i ? A(t, e) : t, s = h.length - 1, r; s >= 0; s--)
|
|
81
|
+
(r = h[s]) && (n = (i ? r(t, e, n) : r(n)) || n);
|
|
82
|
+
return i && n && S(t, e, n), n;
|
|
84
83
|
}, y = /* @__PURE__ */ ((h) => (h.TriggerOnly = "trigger-only", h.Single = "single", h.Multi = "multi", h))(y || {});
|
|
85
84
|
let L = 0;
|
|
86
|
-
var
|
|
87
|
-
const o = (
|
|
85
|
+
var a;
|
|
86
|
+
const o = (a = class extends p {
|
|
88
87
|
constructor() {
|
|
89
|
-
super(), this.items = [], this.selectionType = "trigger-only", this.id =
|
|
88
|
+
super(), this.items = [], this.selectionType = "trigger-only", this.id = a.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
89
|
this._lastKnownScrollTop = this.scrollTop;
|
|
91
|
-
const
|
|
92
|
-
Math.abs(
|
|
93
|
-
}, this.handleKeyDown = (
|
|
94
|
-
let
|
|
95
|
-
switch (
|
|
90
|
+
const t = this._lastRenderedScrollTop - this._lastKnownScrollTop;
|
|
91
|
+
Math.abs(t) >= this.itemHeight && (this._lastRenderedScrollTop = this._lastKnownScrollTop, this.requestUpdate());
|
|
92
|
+
}, this.handleKeyDown = (t) => {
|
|
93
|
+
let e = !0;
|
|
94
|
+
switch (t.key) {
|
|
96
95
|
case "Down":
|
|
97
96
|
case "ArrowDown":
|
|
98
97
|
this.focusIndex = (this.focusIndex + 1) % this.itemCount;
|
|
@@ -102,7 +101,7 @@ const o = (r = class extends p {
|
|
|
102
101
|
this.focusIndex > 0 ? this.focusIndex-- : this.finalSizeIsKnown && (this.focusIndex = this.itemCount - 1);
|
|
103
102
|
break;
|
|
104
103
|
case "Enter":
|
|
105
|
-
this.handleSelection(this.focusIndex,
|
|
104
|
+
this.handleSelection(this.focusIndex, t);
|
|
106
105
|
break;
|
|
107
106
|
case "End":
|
|
108
107
|
this.focusIndex = this.itemCount - 1;
|
|
@@ -117,10 +116,10 @@ const o = (r = class extends p {
|
|
|
117
116
|
this.focusIndex = this.normalizeIndex(this.focusIndex - this._visibleItemsNum + 1);
|
|
118
117
|
break;
|
|
119
118
|
default:
|
|
120
|
-
|
|
119
|
+
e = !1;
|
|
121
120
|
break;
|
|
122
121
|
}
|
|
123
|
-
|
|
122
|
+
e && (t.preventDefault(), t.stopPropagation());
|
|
124
123
|
}, this._resizeObserver = new ResizeObserver(() => {
|
|
125
124
|
this._lastKnownHeight !== this.offsetHeight && (this._lastKnownHeight = this.offsetHeight, this.requestUpdate());
|
|
126
125
|
});
|
|
@@ -128,36 +127,36 @@ const o = (r = class extends p {
|
|
|
128
127
|
get focusTarget() {
|
|
129
128
|
return this.hasAttribute("focus-target");
|
|
130
129
|
}
|
|
131
|
-
set focusTarget(
|
|
132
|
-
this.toggleAttribute("focus-target",
|
|
130
|
+
set focusTarget(t) {
|
|
131
|
+
this.toggleAttribute("focus-target", t);
|
|
133
132
|
}
|
|
134
133
|
get focusIndex() {
|
|
135
134
|
return this._focusIndex;
|
|
136
135
|
}
|
|
137
|
-
set focusIndex(
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
this._focusIndex =
|
|
136
|
+
set focusIndex(t) {
|
|
137
|
+
if (t >= -1 && t < this.itemCount) {
|
|
138
|
+
const e = this._focusIndex;
|
|
139
|
+
this._focusIndex = t, (t <= this._firstVisibleIndex || this._lastVisibleIndex <= t) && this.scrollToItem(t), e != t && (t == -1 && this.removeAttribute("aria-activedescendant"), this.requestUpdate("focusIndex", e));
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
get selectedIndices() {
|
|
144
143
|
return this._selectedIndices;
|
|
145
144
|
}
|
|
146
|
-
set selectedIndices(
|
|
147
|
-
|
|
145
|
+
set selectedIndices(t) {
|
|
146
|
+
t ? this._selectedIndices = t.map((e) => Number(e)) : this._selectedIndices = [], this.requestUpdate("selectedIndices");
|
|
148
147
|
}
|
|
149
|
-
scrollToItem(
|
|
148
|
+
scrollToItem(t, e = "auto") {
|
|
150
149
|
this.scrollTop = w.getOffsetForIndexAndAlignment(
|
|
151
|
-
this.normalizeIndex(
|
|
152
|
-
|
|
150
|
+
this.normalizeIndex(t),
|
|
151
|
+
e,
|
|
153
152
|
this.scrollTop,
|
|
154
153
|
this.itemHeight,
|
|
155
154
|
this.height,
|
|
156
155
|
this.itemCount
|
|
157
156
|
), this._lastKnownScrollTop = this.scrollTop;
|
|
158
157
|
}
|
|
159
|
-
getListItem(
|
|
160
|
-
return !this.shadowRoot ||
|
|
158
|
+
getListItem(t) {
|
|
159
|
+
return !this.shadowRoot || t < this._firstVisibleIndex || this._lastVisibleIndex < t ? null : this.querySelector(`[item-index="${t}"]`);
|
|
161
160
|
}
|
|
162
161
|
connectedCallback() {
|
|
163
162
|
super.connectedCallback(), this._resizeObserver.observe(this), this.scrollTop !== this._lastKnownScrollTop && (this.scrollTop = this._lastKnownScrollTop, this.requestUpdate());
|
|
@@ -165,9 +164,9 @@ const o = (r = class extends p {
|
|
|
165
164
|
disconnectedCallback() {
|
|
166
165
|
super.disconnectedCallback(), this._resizeObserver.disconnect();
|
|
167
166
|
}
|
|
168
|
-
firstUpdated(
|
|
169
|
-
super.firstUpdated(
|
|
170
|
-
|
|
167
|
+
firstUpdated(t) {
|
|
168
|
+
super.firstUpdated(t), this.addEventListener("scroll", this.onScroll), this.addEventListener("keydown", this.handleKeyDown), this.addEventListener("click", this.handleClick), this.addEventListener("mousedown", (e) => {
|
|
169
|
+
e.button == 1 && e.preventDefault();
|
|
171
170
|
}), this.addEventListener("auxclick", this.handleClick), this.addEventListener("focus", () => {
|
|
172
171
|
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
172
|
}), this.addEventListener("blur", () => {
|
|
@@ -175,13 +174,13 @@ const o = (r = class extends p {
|
|
|
175
174
|
}), this.selectedIndices.length > 0 && this.scrollToItem(this.selectedIndices[0], "center");
|
|
176
175
|
}
|
|
177
176
|
updateFocusedItemAttributes() {
|
|
178
|
-
const
|
|
179
|
-
|
|
177
|
+
const t = this.getListItem(this.focusIndex);
|
|
178
|
+
t && (this.focusTarget || document.activeElement == this ? (t.setAttribute("focused", ""), this.setAttribute("aria-activedescendant", t.id)) : (t.removeAttribute("focused"), this.removeAttribute("aria-activedescendant")));
|
|
180
179
|
}
|
|
181
180
|
static get styles() {
|
|
182
181
|
return [
|
|
183
182
|
_`
|
|
184
|
-
${b(
|
|
183
|
+
${b(v)}
|
|
185
184
|
`
|
|
186
185
|
];
|
|
187
186
|
}
|
|
@@ -192,39 +191,39 @@ const o = (r = class extends p {
|
|
|
192
191
|
</div>
|
|
193
192
|
`;
|
|
194
193
|
}
|
|
195
|
-
updated(
|
|
196
|
-
if (super.updated(
|
|
194
|
+
updated(t) {
|
|
195
|
+
if (super.updated(t), this._lastRenderedScrollTop = this._lastKnownScrollTop, this.updateItems(), (this._increaseWidthOnNextRenderIfNeeded || this._reachedMaxWidth) && //
|
|
197
196
|
this._firstVisibleIndex < this._lastVisibleIndex)
|
|
198
197
|
if (this.querySelector("[item-index]"))
|
|
199
198
|
this.adjustWidthIfNeeded();
|
|
200
199
|
else {
|
|
201
|
-
const
|
|
202
|
-
this.adjustWidthIfNeeded(),
|
|
200
|
+
const e = new MutationObserver(() => {
|
|
201
|
+
this.adjustWidthIfNeeded(), e.disconnect();
|
|
203
202
|
});
|
|
204
|
-
|
|
203
|
+
e.observe(this);
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
206
|
adjustWidthIfNeeded() {
|
|
208
207
|
this._increaseWidthOnNextRenderIfNeeded ? (this._increaseWidthOnNextRenderIfNeeded = !1, window.requestAnimationFrame(() => {
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
208
|
+
const t = Number.parseInt(getComputedStyle(this).maxWidth) - this.offsetWidth;
|
|
209
|
+
if (t == 0)
|
|
211
210
|
this._reachedMaxWidth = !0, this.enableLineClampOnItemsIfNeeded();
|
|
212
211
|
else {
|
|
213
212
|
this._reachedMaxWidth = !1;
|
|
214
|
-
const
|
|
213
|
+
const e = [...this.querySelectorAll("[item-index]")].map((n) => {
|
|
215
214
|
if (n instanceof f) {
|
|
216
215
|
n.enableLineClamp = !1;
|
|
217
216
|
const s = n.missingWidthForTexts;
|
|
218
|
-
return s >
|
|
217
|
+
return s > t && (n.enableLineClamp = !0), s;
|
|
219
218
|
}
|
|
220
|
-
}), i = Math.max(...
|
|
219
|
+
}), i = Math.max(...e);
|
|
221
220
|
i > 0 && (this.style.width = `${this.offsetWidth + i}px`);
|
|
222
221
|
}
|
|
223
222
|
})) : this._reachedMaxWidth && this.enableLineClampOnItemsIfNeeded();
|
|
224
223
|
}
|
|
225
224
|
enableLineClampOnItemsIfNeeded() {
|
|
226
|
-
this.querySelectorAll("[item-index]").forEach((
|
|
227
|
-
|
|
225
|
+
this.querySelectorAll("[item-index]").forEach((t) => {
|
|
226
|
+
t instanceof f && (t.enableLineClamp = t.enableLineClamp || t.missingWidthForTexts > 0);
|
|
228
227
|
});
|
|
229
228
|
}
|
|
230
229
|
/**
|
|
@@ -237,122 +236,122 @@ const o = (r = class extends p {
|
|
|
237
236
|
this._increaseWidthOnNextRenderIfNeeded = !0;
|
|
238
237
|
}
|
|
239
238
|
updateItems() {
|
|
240
|
-
const
|
|
239
|
+
const t = [...this.querySelectorAll("[item-index]")], e = /* @__PURE__ */ new Map(), i = document.createDocumentFragment();
|
|
241
240
|
for (const n of this._itemsRenderData) {
|
|
242
241
|
const s = this.renderItem(n);
|
|
243
|
-
s.parentElement || i.appendChild(s),
|
|
244
|
-
const
|
|
245
|
-
|
|
242
|
+
s.parentElement || i.appendChild(s), e.set(n.dataHash, s);
|
|
243
|
+
const r = t.indexOf(s);
|
|
244
|
+
r !== -1 && t.splice(r, 1);
|
|
246
245
|
}
|
|
247
246
|
this.appendChild(i);
|
|
248
|
-
for (const n of
|
|
247
|
+
for (const n of t)
|
|
249
248
|
n instanceof f && (n.enableLineClamp = !1), this.removeChild(n);
|
|
250
|
-
|
|
249
|
+
e.forEach((n, s) => {
|
|
251
250
|
this._elementCache.set(s, n);
|
|
252
251
|
});
|
|
253
252
|
}
|
|
254
|
-
renderItem({ index:
|
|
253
|
+
renderItem({ index: t, top: e, dataHash: i, data: n }) {
|
|
255
254
|
let s;
|
|
256
|
-
return n ? this._elementCache.has(i) ? (s = this._elementCache.get(i), this._elementCache.delete(i)) : (s = this.itemGenerator(n,
|
|
257
|
-
transform: `translateY(${
|
|
255
|
+
return n ? this._elementCache.has(i) ? (s = this._elementCache.get(i), this._elementCache.delete(i)) : (s = this.itemGenerator(n, t), s.setAttribute("slot", "items")) : (s = document.createElement("div"), s.setAttribute("placeholder-item", ""), s.setAttribute("slot", "items")), Object.assign(s.style, {
|
|
256
|
+
transform: `translateY(${e}px)`,
|
|
258
257
|
height: `${this.itemHeight}px`
|
|
259
|
-
}), s.setAttribute("item-index",
|
|
258
|
+
}), s.setAttribute("item-index", t.toString()), s.setAttribute("aria-setsize", String(this.finalSizeIsKnown ? this.itemCount : -1)), s.setAttribute("aria-posinset", String(t + 1)), (!s.id || s.id.startsWith(this.id + "_item_")) && (s.id = this.id + "_item_" + t), this.itemCount - 1 == t ? s.setAttribute("last", "") : s.removeAttribute("last"), this.updateSelectedAttribute(t, s), this.updateFocusedAttribute(t, s), s;
|
|
260
259
|
}
|
|
261
|
-
updateFocusedAttribute(
|
|
262
|
-
this.focusIndex ==
|
|
260
|
+
updateFocusedAttribute(t, e) {
|
|
261
|
+
this.focusIndex == t && (this.focusTarget || document.activeElement == this) ? (e.setAttribute("focused", ""), this.setAttribute("aria-activedescendant", e.id)) : e.removeAttribute("focused");
|
|
263
262
|
}
|
|
264
|
-
updateSelectedAttribute(
|
|
265
|
-
const i = this.selectedIndices.indexOf(
|
|
266
|
-
i ?
|
|
263
|
+
updateSelectedAttribute(t, e) {
|
|
264
|
+
const i = this.selectedIndices.indexOf(t) !== -1;
|
|
265
|
+
i ? e.setAttribute("selected", "") : e.removeAttribute("selected"), e.setAttribute("aria-selected", String(i));
|
|
267
266
|
}
|
|
268
267
|
updateItemsRenderData() {
|
|
269
268
|
if (this._itemsRenderData = [], this._visibleItemsNum = Math.min(Math.ceil(this.height / this.itemHeight), this.itemCount), this._visibleItemsNum > 0) {
|
|
270
269
|
this._firstVisibleIndex = this.normalizeIndex(Math.floor(this._lastKnownScrollTop / this.itemHeight)), this._lastVisibleIndex = this.normalizeIndex(this._firstVisibleIndex + this._visibleItemsNum);
|
|
271
|
-
const
|
|
272
|
-
this.requestData(
|
|
273
|
-
for (let i =
|
|
274
|
-
const n = i -
|
|
275
|
-
let
|
|
276
|
-
s ?
|
|
270
|
+
const t = this.normalizeIndex(this._firstVisibleIndex - 2), e = this.normalizeIndex(this._lastVisibleIndex + 2);
|
|
271
|
+
this.requestData(t, e);
|
|
272
|
+
for (let i = t; i <= e; i++) {
|
|
273
|
+
const n = i - t, s = this.items[n];
|
|
274
|
+
let r;
|
|
275
|
+
s ? r = JSON.stringify(s) : r = `placeholder-${n}`, this._itemsRenderData.push({
|
|
277
276
|
index: i,
|
|
278
277
|
top: this.itemHeight * i,
|
|
279
278
|
physicalIndex: n,
|
|
280
|
-
dataHash:
|
|
279
|
+
dataHash: r,
|
|
281
280
|
data: s
|
|
282
281
|
});
|
|
283
282
|
}
|
|
284
283
|
} else
|
|
285
284
|
this._firstVisibleIndex = 0, this._lastVisibleIndex = 0;
|
|
286
285
|
}
|
|
287
|
-
normalizeIndex(
|
|
288
|
-
return Math.max(0, Math.min(
|
|
286
|
+
normalizeIndex(t) {
|
|
287
|
+
return Math.max(0, Math.min(t, this.itemCount - 1));
|
|
289
288
|
}
|
|
290
289
|
get height() {
|
|
291
290
|
return this.offsetHeight;
|
|
292
291
|
}
|
|
293
|
-
requestData(
|
|
294
|
-
!Number.isNaN(
|
|
292
|
+
requestData(t, e) {
|
|
293
|
+
!Number.isNaN(t) && !Number.isNaN(e) && this.dispatchEvent(
|
|
295
294
|
new CustomEvent("data-request", {
|
|
296
295
|
detail: {
|
|
297
|
-
startIndex:
|
|
298
|
-
stopIndex:
|
|
296
|
+
startIndex: t,
|
|
297
|
+
stopIndex: e
|
|
299
298
|
}
|
|
300
299
|
})
|
|
301
300
|
);
|
|
302
301
|
}
|
|
303
|
-
handleSelection(
|
|
304
|
-
if (
|
|
302
|
+
handleSelection(t, e) {
|
|
303
|
+
if (t < 0 || this.itemCount <= t)
|
|
305
304
|
return;
|
|
306
|
-
const i = this.getListItem(
|
|
305
|
+
const i = this.getListItem(t);
|
|
307
306
|
if (i.getAttribute("aria-disabled") == "true" || i.hasAttribute("disabled"))
|
|
308
307
|
return;
|
|
309
308
|
let n = !0;
|
|
310
309
|
if (this.selectionType !== "trigger-only") {
|
|
311
|
-
const s = this.selectedIndices.indexOf(
|
|
312
|
-
n = s == -1, n ? this.selectionType === "single" ? this.selectedIndices = [
|
|
310
|
+
const s = this.selectedIndices.indexOf(t);
|
|
311
|
+
n = s == -1, n ? this.selectionType === "single" ? this.selectedIndices = [t] : this.selectedIndices.push(t) : this.selectedIndices.splice(s, 1), this.requestUpdate("selectedIndices");
|
|
313
312
|
}
|
|
314
|
-
this.focusIndex =
|
|
313
|
+
this.focusIndex = t, this.dispatchSelectionEvent(t, n, e);
|
|
315
314
|
}
|
|
316
|
-
dispatchSelectionEvent(
|
|
315
|
+
dispatchSelectionEvent(t, e, i) {
|
|
317
316
|
this.dispatchEvent(
|
|
318
317
|
new CustomEvent("selection", {
|
|
319
|
-
detail: { index:
|
|
318
|
+
detail: { index: t, selected: e, originalEvent: i }
|
|
320
319
|
})
|
|
321
320
|
);
|
|
322
321
|
}
|
|
323
|
-
handleClick(
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
326
|
-
const i = parseInt(
|
|
327
|
-
Number.isInteger(i) && ((
|
|
322
|
+
handleClick(t) {
|
|
323
|
+
const e = t.composedPath().find((i) => i.hasAttribute && i.hasAttribute("item-index"));
|
|
324
|
+
if (e) {
|
|
325
|
+
const i = parseInt(e.getAttribute("item-index"));
|
|
326
|
+
Number.isInteger(i) && ((t.button == 0 || t.button == 1) && this.handleSelection(i, t), this.focusIndex = i);
|
|
328
327
|
}
|
|
329
328
|
}
|
|
330
|
-
},
|
|
331
|
-
f.ensureDefined(), customElements.get(
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
|
|
329
|
+
}, a.ID = "sd-virtual-list", a.ensureDefined = () => {
|
|
330
|
+
f.ensureDefined(), customElements.get(a.ID) || customElements.define(a.ID, a);
|
|
331
|
+
}, a);
|
|
332
|
+
d([
|
|
333
|
+
l({ type: Number, attribute: "item-height", reflect: !0 })
|
|
335
334
|
], o.prototype, "itemHeight", 2);
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
d([
|
|
336
|
+
l({ type: Number })
|
|
338
337
|
], o.prototype, "itemCount", 2);
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
d([
|
|
339
|
+
l({ type: Array, attribute: !1 })
|
|
341
340
|
], o.prototype, "items", 2);
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
d([
|
|
342
|
+
l({ type: String, attribute: "selection-type", reflect: !0, noAccessor: !0 })
|
|
344
343
|
], o.prototype, "selectionType", 2);
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
d([
|
|
345
|
+
l({ type: String, attribute: !0, reflect: !0 })
|
|
347
346
|
], o.prototype, "id", 2);
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
d([
|
|
348
|
+
l({ type: String, reflect: !0 })
|
|
350
349
|
], o.prototype, "role", 2);
|
|
351
|
-
|
|
352
|
-
|
|
350
|
+
d([
|
|
351
|
+
l({ type: Number, attribute: "focus-index", reflect: !0 })
|
|
353
352
|
], o.prototype, "focusIndex", 1);
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
d([
|
|
354
|
+
l({ type: Array, attribute: !1 })
|
|
356
355
|
], o.prototype, "selectedIndices", 1);
|
|
357
356
|
let D = o;
|
|
358
357
|
D.ensureDefined();
|