@ixfx/components 0.7.4 → 0.8.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/bundle/index.d.ts +787 -190
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +2770 -592
- package/bundle/index.js.map +1 -1
- package/dist/ac-token.js +1 -1
- package/dist/crumbs.d.ts +5 -1
- package/dist/crumbs.d.ts.map +1 -1
- package/dist/crumbs.js +10 -0
- package/dist/crumbs.js.map +1 -1
- package/dist/{data-grid-BddUjAti.d.ts → data-grid-D-z7bx5-.d.ts} +26 -1
- package/dist/data-grid-D-z7bx5-.d.ts.map +1 -0
- package/dist/data-grid.d.ts +1 -1
- package/dist/data-grid.js +88 -7
- package/dist/data-grid.js.map +1 -1
- package/dist/{detail-list-Br0WAnry.d.ts → detail-list-_ZJHYEBr.d.ts} +20 -12
- package/dist/detail-list-_ZJHYEBr.d.ts.map +1 -0
- package/dist/detail-list.d.ts +2 -2
- package/dist/detail-list.js +51 -135
- package/dist/detail-list.js.map +1 -1
- package/dist/grid-list-nRUQOcEL.js +1537 -0
- package/dist/grid-list-nRUQOcEL.js.map +1 -0
- package/dist/{grid-list-B_orPsot.d.ts → grid-list-u33vmKzb.d.ts} +128 -10
- package/dist/grid-list-u33vmKzb.d.ts.map +1 -0
- package/dist/grid-list.d.ts +1 -1
- package/dist/grid-list.js +1 -932
- package/dist/incr-search-C05WjbZh.js +999 -0
- package/dist/incr-search-C05WjbZh.js.map +1 -0
- package/dist/incr-search.d.ts +2 -2
- package/dist/incr-search.js +2 -3
- package/dist/index-h6gxtfHH.d.ts +397 -0
- package/dist/index-h6gxtfHH.d.ts.map +1 -0
- package/dist/index.d.ts +62 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +343 -17
- package/dist/index.js.map +1 -1
- package/dist/led.d.ts +33 -1
- package/dist/led.d.ts.map +1 -1
- package/dist/led.js +157 -13
- package/dist/led.js.map +1 -1
- package/dist/{list-selection-controller-CUo-Hhcm.js → list-selection-controller-DTFI40li.js} +2 -76
- package/dist/list-selection-controller-DTFI40li.js.map +1 -0
- package/dist/miller.d.ts +81 -3
- package/dist/miller.d.ts.map +1 -1
- package/dist/miller.js +327 -68
- package/dist/miller.js.map +1 -1
- package/dist/narrowed-text.js +1 -2
- package/dist/narrowed-text.js.map +1 -1
- package/dist/panel.d.ts +3 -1
- package/dist/panel.d.ts.map +1 -1
- package/dist/panel.js +31 -1
- package/dist/panel.js.map +1 -1
- package/dist/plots.d.ts +2 -2
- package/dist/plots.js +1 -1
- package/dist/{titlebar-Bj5pfdw_.d.ts → titlebar-YQ-jVQoS.d.ts} +2 -2
- package/dist/{titlebar-Bj5pfdw_.d.ts.map → titlebar-YQ-jVQoS.d.ts.map} +1 -1
- package/dist/titlebar.d.ts +1 -1
- package/dist/titlebar.js +83 -1
- package/dist/titlebar.js.map +1 -1
- package/dist/{tree-B74zdI60.js → tree-Chptss7I.js} +77 -15
- package/dist/tree-Chptss7I.js.map +1 -0
- package/dist/{tree-component-BvV4muxx.d.ts → tree-component-F6qZ0Gdv.d.ts} +9 -1
- package/dist/{tree-component-BvV4muxx.d.ts.map → tree-component-F6qZ0Gdv.d.ts.map} +1 -1
- package/dist/tree.d.ts +22 -1
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +1 -1
- package/dist/{vertical-list-CQSEVeOT.d.ts → vertical-list-CFuFDygi.d.ts} +17 -14
- package/dist/vertical-list-CFuFDygi.d.ts.map +1 -0
- package/dist/vertical-list.d.ts +1 -1
- package/dist/vertical-list.js +59 -127
- package/dist/vertical-list.js.map +1 -1
- package/dist/{xy-axis-5KhVTNoX.d.ts → xy-axis-BfP9hKLj.d.ts} +25 -2
- package/dist/{xy-axis-5KhVTNoX.d.ts.map → xy-axis-BfP9hKLj.d.ts.map} +1 -1
- package/dist/{xy-axis-VrX8dmvS.js → xy-axis-DzM1brBZ.js} +141 -8
- package/dist/xy-axis-DzM1brBZ.js.map +1 -0
- package/docs-user/data-grid.md +19 -0
- package/docs-user/detail-list.md +1 -1
- package/docs-user/grid-list.md +120 -11
- package/docs-user/incr-search.md +12 -2
- package/docs-user/index.json +3 -3
- package/docs-user/led.md +37 -7
- package/docs-user/llms.txt +1 -1
- package/docs-user/panel.md +68 -13
- package/docs-user/titlebar.md +3 -4
- package/docs-user/tree.md +22 -1
- package/docs-user/vertical-list.md +7 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/data-grid-BddUjAti.d.ts.map +0 -1
- package/dist/detail-list-Br0WAnry.d.ts.map +0 -1
- package/dist/element-search-Y8SRfPGM.js +0 -185
- package/dist/element-search-Y8SRfPGM.js.map +0 -1
- package/dist/grid-list-B_orPsot.d.ts.map +0 -1
- package/dist/grid-list.js.map +0 -1
- package/dist/incr-search-vCzuao-2.js +0 -137
- package/dist/incr-search-vCzuao-2.js.map +0 -1
- package/dist/index-Cu5i8zZY.d.ts +0 -160
- package/dist/index-Cu5i8zZY.d.ts.map +0 -1
- package/dist/list-selection-controller-CUo-Hhcm.js.map +0 -1
- package/dist/tree-B74zdI60.js.map +0 -1
- package/dist/vertical-list-CQSEVeOT.d.ts.map +0 -1
- package/dist/xy-axis-VrX8dmvS.js.map +0 -1
|
@@ -0,0 +1,1537 @@
|
|
|
1
|
+
import { t as TickledController } from "./tickled-controller-C66DgJHl.js";
|
|
2
|
+
import { n as tickledStyles, t as tickledItemStyles } from "./tickled-styles-BrAHEj1q.js";
|
|
3
|
+
import { t as themeFallbacks } from "./fallbacks-DNI9xt0F.js";
|
|
4
|
+
import { n as safeCustomElement, t as __decorate } from "./decorate-VRK8rslU.js";
|
|
5
|
+
import { c as createElementListSearchAdapter, d as createDataListSearchAdapter, i as ListSearchController, n as listSearchStyles, o as registerListSearchCommands, r as LIST_SEARCH_MODES, u as keyForElement } from "./incr-search-C05WjbZh.js";
|
|
6
|
+
import { i as listItemFadeKeyframes } from "./list-item-animation-DuiwgN3l.js";
|
|
7
|
+
import { t as ListSelectionController } from "./list-selection-controller-DTFI40li.js";
|
|
8
|
+
import "./interaction-Cr13azbM.js";
|
|
9
|
+
import { t as scrollFadeStyles } from "./scroll-fade-CAs1EabA.js";
|
|
10
|
+
import { LitElement, css, html } from "lit";
|
|
11
|
+
import { property, state } from "lit/decorators.js";
|
|
12
|
+
import { createCommandRegistry } from "@clinth/ui-commands";
|
|
13
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
14
|
+
import { createRef, ref } from "lit/directives/ref.js";
|
|
15
|
+
//#region src/grid-list/grid-list-source.ts
|
|
16
|
+
const ITEM_SELECTOR$1 = `:scope > *`;
|
|
17
|
+
const SYNTHETIC_PREFIX = `gl-auto-`;
|
|
18
|
+
/** Whether `key` is an auto-assigned key for a keyless light-DOM item. */
|
|
19
|
+
function isSyntheticKey(key) {
|
|
20
|
+
return key.startsWith(SYNTHETIC_PREFIX);
|
|
21
|
+
}
|
|
22
|
+
function warnDuplicateKeys(keys) {
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
const dupes = /* @__PURE__ */ new Set();
|
|
25
|
+
for (const k of keys) {
|
|
26
|
+
if (isSyntheticKey(k)) continue;
|
|
27
|
+
if (seen.has(k)) dupes.add(k);
|
|
28
|
+
else seen.add(k);
|
|
29
|
+
}
|
|
30
|
+
if (dupes.size > 0) console.warn(`ixfx-grid-list: duplicate item key(s) ${[...dupes].map((k) => `"${k}"`).join(`, `)} — the first occurrence wins for key-based operations.`);
|
|
31
|
+
}
|
|
32
|
+
var ElementGridListSource = class {
|
|
33
|
+
#host;
|
|
34
|
+
#items = [];
|
|
35
|
+
#slotNames = /* @__PURE__ */ new WeakMap();
|
|
36
|
+
#syntheticKeys = /* @__PURE__ */ new WeakMap();
|
|
37
|
+
#seq = 0;
|
|
38
|
+
#predicate;
|
|
39
|
+
#searchKeys;
|
|
40
|
+
#effectiveIndices = [];
|
|
41
|
+
#keysCache;
|
|
42
|
+
constructor(host) {
|
|
43
|
+
this.#host = host;
|
|
44
|
+
this.refresh();
|
|
45
|
+
}
|
|
46
|
+
get count() {
|
|
47
|
+
return this.#effectiveIndices.length;
|
|
48
|
+
}
|
|
49
|
+
get rawCount() {
|
|
50
|
+
return this.#items.length;
|
|
51
|
+
}
|
|
52
|
+
keyAt(index) {
|
|
53
|
+
const eff = this.#effectiveIndices[index];
|
|
54
|
+
return eff === void 0 ? `` : this.#itemKey(this.#items[eff]);
|
|
55
|
+
}
|
|
56
|
+
indexOfKey(key) {
|
|
57
|
+
return this.#effectiveIndices.findIndex((i) => this.#itemKey(this.#items[i]) === key);
|
|
58
|
+
}
|
|
59
|
+
keys() {
|
|
60
|
+
this.#keysCache ??= this.#effectiveIndices.map((i) => this.#itemKey(this.#items[i]));
|
|
61
|
+
return this.#keysCache;
|
|
62
|
+
}
|
|
63
|
+
labelAt(index) {
|
|
64
|
+
const eff = this.#effectiveIndices[index];
|
|
65
|
+
return eff === void 0 ? `` : this.#captionFor(this.#items[eff]);
|
|
66
|
+
}
|
|
67
|
+
rawKeyAt(index) {
|
|
68
|
+
const el = this.#items[index];
|
|
69
|
+
return el === void 0 ? `` : this.#itemKey(el);
|
|
70
|
+
}
|
|
71
|
+
rawSearchTextAt(index) {
|
|
72
|
+
const el = this.#items[index];
|
|
73
|
+
if (el === void 0) return ``;
|
|
74
|
+
return el.getAttribute(`data-search-label`) ?? el.getAttribute(`data-label`) ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim() ?? el.textContent?.trim() ?? ``;
|
|
75
|
+
}
|
|
76
|
+
isSelectable(index) {
|
|
77
|
+
const eff = this.#effectiveIndices[index];
|
|
78
|
+
return eff !== void 0 && !this.#items[eff].hasAttribute(`not-checked`);
|
|
79
|
+
}
|
|
80
|
+
renderCellContent(index) {
|
|
81
|
+
const eff = this.#effectiveIndices[index];
|
|
82
|
+
if (eff === void 0) return void 0;
|
|
83
|
+
return html`<slot name=${this.slotNameFor(this.#items[eff])}></slot>`;
|
|
84
|
+
}
|
|
85
|
+
setFilters(opts) {
|
|
86
|
+
if (`predicate` in opts) this.#predicate = opts.predicate;
|
|
87
|
+
if (`searchKeys` in opts) this.#searchKeys = opts.searchKeys;
|
|
88
|
+
this.#recomputeEffective();
|
|
89
|
+
}
|
|
90
|
+
refresh() {
|
|
91
|
+
this.#items = Array.from(this.#host.querySelectorAll(ITEM_SELECTOR$1)).filter((el) => !el.hidden);
|
|
92
|
+
for (const el of this.#items) {
|
|
93
|
+
const name = this.slotNameFor(el);
|
|
94
|
+
if (el.getAttribute(`slot`) !== name) el.setAttribute(`slot`, name);
|
|
95
|
+
}
|
|
96
|
+
warnDuplicateKeys(this.#items.map((el) => this.#itemKey(el)));
|
|
97
|
+
this.#recomputeEffective();
|
|
98
|
+
}
|
|
99
|
+
/** Effective-order elements — the array `GridListElement` renders and slices. */
|
|
100
|
+
effectiveElements() {
|
|
101
|
+
return this.#effectiveIndices.map((i) => this.#items[i]);
|
|
102
|
+
}
|
|
103
|
+
/** Raw-order element at `index`, or `undefined`. */
|
|
104
|
+
rawElementAt(index) {
|
|
105
|
+
return this.#items[index];
|
|
106
|
+
}
|
|
107
|
+
/** Stable per-element `<slot>` name. */
|
|
108
|
+
slotNameFor(el) {
|
|
109
|
+
let name = this.#slotNames.get(el);
|
|
110
|
+
if (name === void 0) {
|
|
111
|
+
this.#seq += 1;
|
|
112
|
+
name = `gl-item-${this.#seq}`;
|
|
113
|
+
this.#slotNames.set(el, name);
|
|
114
|
+
}
|
|
115
|
+
return name;
|
|
116
|
+
}
|
|
117
|
+
resolveKeyToElement(key) {
|
|
118
|
+
if (isSyntheticKey(key)) return this.#items.find((el) => this.#syntheticKeys.get(el) === key);
|
|
119
|
+
return this.#items.find((el) => keyForElement(el) === key);
|
|
120
|
+
}
|
|
121
|
+
resolveKeyToData(_key) {}
|
|
122
|
+
#recomputeEffective() {
|
|
123
|
+
const effective = [];
|
|
124
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
125
|
+
if (this.#predicate !== void 0 && !this.#predicate(i)) continue;
|
|
126
|
+
if (this.#searchKeys !== void 0) {
|
|
127
|
+
const key = this.#itemKey(this.#items[i]);
|
|
128
|
+
if (!isSyntheticKey(key) && !this.#searchKeys.has(key)) continue;
|
|
129
|
+
}
|
|
130
|
+
effective.push(i);
|
|
131
|
+
}
|
|
132
|
+
this.#effectiveIndices = effective;
|
|
133
|
+
this.#keysCache = void 0;
|
|
134
|
+
}
|
|
135
|
+
#itemKey(el) {
|
|
136
|
+
const userKey = keyForElement(el);
|
|
137
|
+
if (userKey !== void 0) return userKey;
|
|
138
|
+
let synthetic = this.#syntheticKeys.get(el);
|
|
139
|
+
if (synthetic === void 0) {
|
|
140
|
+
this.#seq += 1;
|
|
141
|
+
synthetic = `${SYNTHETIC_PREFIX}${this.#seq}`;
|
|
142
|
+
this.#syntheticKeys.set(el, synthetic);
|
|
143
|
+
}
|
|
144
|
+
return synthetic;
|
|
145
|
+
}
|
|
146
|
+
#captionFor(el) {
|
|
147
|
+
return el.getAttribute(`data-label`) ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim() ?? ``;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var DataGridListSource = class {
|
|
151
|
+
#items;
|
|
152
|
+
#adapter;
|
|
153
|
+
#predicate;
|
|
154
|
+
#searchKeys;
|
|
155
|
+
#effectiveIndices = [];
|
|
156
|
+
#keysCache;
|
|
157
|
+
constructor(items, adapter) {
|
|
158
|
+
this.#items = items;
|
|
159
|
+
this.#adapter = adapter;
|
|
160
|
+
warnDuplicateKeys(items.map((it, i) => adapter.key(it, i)));
|
|
161
|
+
this.#recomputeEffective();
|
|
162
|
+
}
|
|
163
|
+
get count() {
|
|
164
|
+
return this.#effectiveIndices.length;
|
|
165
|
+
}
|
|
166
|
+
get rawCount() {
|
|
167
|
+
return this.#items.length;
|
|
168
|
+
}
|
|
169
|
+
keyAt(index) {
|
|
170
|
+
const eff = this.#effectiveIndices[index];
|
|
171
|
+
return eff === void 0 ? `` : this.#adapter.key(this.#items[eff], eff);
|
|
172
|
+
}
|
|
173
|
+
indexOfKey(key) {
|
|
174
|
+
return this.#effectiveIndices.findIndex((i) => this.#adapter.key(this.#items[i], i) === key);
|
|
175
|
+
}
|
|
176
|
+
keys() {
|
|
177
|
+
this.#keysCache ??= this.#effectiveIndices.map((i) => this.#adapter.key(this.#items[i], i));
|
|
178
|
+
return this.#keysCache;
|
|
179
|
+
}
|
|
180
|
+
labelAt(index) {
|
|
181
|
+
const eff = this.#effectiveIndices[index];
|
|
182
|
+
if (eff === void 0) return ``;
|
|
183
|
+
return this.#adapter.label?.(this.#items[eff], eff) ?? this.#adapter.key(this.#items[eff], eff);
|
|
184
|
+
}
|
|
185
|
+
rawKeyAt(index) {
|
|
186
|
+
return index < 0 || index >= this.#items.length ? `` : this.#adapter.key(this.#items[index], index);
|
|
187
|
+
}
|
|
188
|
+
rawSearchTextAt(index) {
|
|
189
|
+
if (index < 0 || index >= this.#items.length) return ``;
|
|
190
|
+
const item = this.#items[index];
|
|
191
|
+
return this.#adapter.searchableText?.(item, index) ?? this.#adapter.label?.(item, index) ?? ``;
|
|
192
|
+
}
|
|
193
|
+
isSelectable(index) {
|
|
194
|
+
const eff = this.#effectiveIndices[index];
|
|
195
|
+
return eff !== void 0 && !this.#adapter.disabled?.(this.#items[eff], eff);
|
|
196
|
+
}
|
|
197
|
+
renderCellContent(index) {
|
|
198
|
+
const eff = this.#effectiveIndices[index];
|
|
199
|
+
return eff === void 0 ? void 0 : this.#adapter.render(this.#items[eff], eff);
|
|
200
|
+
}
|
|
201
|
+
setFilters(opts) {
|
|
202
|
+
if (`predicate` in opts) this.#predicate = opts.predicate;
|
|
203
|
+
if (`searchKeys` in opts) this.#searchKeys = opts.searchKeys;
|
|
204
|
+
this.#recomputeEffective();
|
|
205
|
+
}
|
|
206
|
+
refresh() {
|
|
207
|
+
this.#recomputeEffective();
|
|
208
|
+
}
|
|
209
|
+
/** Raw-order item at `index`, or `undefined`. */
|
|
210
|
+
rawItemAt(index) {
|
|
211
|
+
return this.#items[index];
|
|
212
|
+
}
|
|
213
|
+
/** Effective-order item at `index`, or `undefined`. */
|
|
214
|
+
getItemAt(index) {
|
|
215
|
+
const eff = this.#effectiveIndices[index];
|
|
216
|
+
return eff === void 0 ? void 0 : this.#items[eff];
|
|
217
|
+
}
|
|
218
|
+
resolveKeyToElement(_key) {}
|
|
219
|
+
resolveKeyToData(key) {
|
|
220
|
+
const idx = this.#items.findIndex((item, i) => this.#adapter.key(item, i) === key);
|
|
221
|
+
return idx >= 0 ? this.#items[idx] : void 0;
|
|
222
|
+
}
|
|
223
|
+
#recomputeEffective() {
|
|
224
|
+
const effective = [];
|
|
225
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
226
|
+
if (this.#predicate !== void 0 && !this.#predicate(i)) continue;
|
|
227
|
+
if (this.#searchKeys !== void 0 && !this.#searchKeys.has(this.#adapter.key(this.#items[i], i))) continue;
|
|
228
|
+
effective.push(i);
|
|
229
|
+
}
|
|
230
|
+
this.#effectiveIndices = effective;
|
|
231
|
+
this.#keysCache = void 0;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/grid-list/grid-list.ts
|
|
236
|
+
const ITEM_SELECTOR = `:scope > *`;
|
|
237
|
+
const MIN_ITEM_SIZE = 16;
|
|
238
|
+
/**
|
|
239
|
+
* How long the host keeps the `[reflowing]` attribute after items are inserted
|
|
240
|
+
* mid-list — long enough for the cell move-transition and the enter animation
|
|
241
|
+
* to finish. Kept a touch above the default `--grid-list-item-move-duration`.
|
|
242
|
+
*/
|
|
243
|
+
const REFLOW_WINDOW_MS = 320;
|
|
244
|
+
function computeGridWindow(count, itemWidth, rowHeight, gap, viewportWidth, viewportHeight, scrollOffset, orientation, overscan = 2) {
|
|
245
|
+
const w = Math.max(1, itemWidth);
|
|
246
|
+
const h = Math.max(1, rowHeight);
|
|
247
|
+
const g = Math.max(0, gap);
|
|
248
|
+
const colStride = w + g;
|
|
249
|
+
const rowStride = h + g;
|
|
250
|
+
const offset = Math.max(0, scrollOffset);
|
|
251
|
+
if (orientation === `row`) {
|
|
252
|
+
const rows = count === 0 ? 0 : 1;
|
|
253
|
+
const totalWidth = count === 0 ? 0 : (count - 1) * colStride + w;
|
|
254
|
+
if (count === 0 || viewportWidth <= 0) return {
|
|
255
|
+
cols: count,
|
|
256
|
+
rows,
|
|
257
|
+
totalHeight: 0,
|
|
258
|
+
totalWidth,
|
|
259
|
+
startIndex: 0,
|
|
260
|
+
endIndex: 0,
|
|
261
|
+
colStride,
|
|
262
|
+
rowStride,
|
|
263
|
+
horizontal: true
|
|
264
|
+
};
|
|
265
|
+
const firstVisible = Math.max(0, Math.floor(offset / colStride));
|
|
266
|
+
const lastVisible = Math.ceil((offset + viewportWidth) / colStride);
|
|
267
|
+
return {
|
|
268
|
+
cols: count,
|
|
269
|
+
rows,
|
|
270
|
+
totalHeight: 0,
|
|
271
|
+
totalWidth,
|
|
272
|
+
startIndex: Math.max(0, firstVisible - overscan),
|
|
273
|
+
endIndex: Math.min(count, lastVisible + overscan),
|
|
274
|
+
colStride,
|
|
275
|
+
rowStride,
|
|
276
|
+
horizontal: true
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const cols = orientation === `column` ? 1 : Math.max(1, Math.floor((Math.max(0, viewportWidth) + g) / colStride));
|
|
280
|
+
const rows = count === 0 ? 0 : Math.ceil(count / cols);
|
|
281
|
+
const totalHeight = rows === 0 ? 0 : (rows - 1) * rowStride + h;
|
|
282
|
+
if (count === 0 || viewportHeight <= 0) return {
|
|
283
|
+
cols,
|
|
284
|
+
rows,
|
|
285
|
+
totalHeight,
|
|
286
|
+
totalWidth: 0,
|
|
287
|
+
startIndex: 0,
|
|
288
|
+
endIndex: 0,
|
|
289
|
+
colStride,
|
|
290
|
+
rowStride,
|
|
291
|
+
horizontal: false
|
|
292
|
+
};
|
|
293
|
+
const firstVisibleRow = Math.max(0, Math.floor(offset / rowStride));
|
|
294
|
+
const lastVisibleRow = Math.ceil((offset + viewportHeight) / rowStride);
|
|
295
|
+
const rowStart = Math.max(0, firstVisibleRow - overscan);
|
|
296
|
+
const rowEnd = Math.min(rows, lastVisibleRow + overscan);
|
|
297
|
+
return {
|
|
298
|
+
cols,
|
|
299
|
+
rows,
|
|
300
|
+
totalHeight,
|
|
301
|
+
totalWidth: 0,
|
|
302
|
+
startIndex: rowStart * cols,
|
|
303
|
+
endIndex: Math.min(count, rowEnd * cols),
|
|
304
|
+
colStride,
|
|
305
|
+
rowStride,
|
|
306
|
+
horizontal: false
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function columnOf(index, cols) {
|
|
310
|
+
return cols <= 1 ? 0 : index % cols;
|
|
311
|
+
}
|
|
312
|
+
function rowOf(index, cols) {
|
|
313
|
+
return cols <= 1 ? index : Math.floor(index / cols);
|
|
314
|
+
}
|
|
315
|
+
let GridListElement = class GridListElement extends LitElement {
|
|
316
|
+
constructor(..._args) {
|
|
317
|
+
super(..._args);
|
|
318
|
+
this.selectionMode = `single`;
|
|
319
|
+
this.interactionMode = `standard`;
|
|
320
|
+
this.itemSize = 160;
|
|
321
|
+
this.gap = 8;
|
|
322
|
+
this.orientation = `grid`;
|
|
323
|
+
this.captionStyle = `under`;
|
|
324
|
+
this.captionAlign = `middle`;
|
|
325
|
+
this.captionPosition = `bottom`;
|
|
326
|
+
this.captionBackdrop = `scrim`;
|
|
327
|
+
this.captionHeight = 24;
|
|
328
|
+
this.itemWrap = `stop`;
|
|
329
|
+
this.items = [];
|
|
330
|
+
this._scrollTop = 0;
|
|
331
|
+
this._scrollLeft = 0;
|
|
332
|
+
this._viewportHeight = 0;
|
|
333
|
+
this._viewportWidth = 0;
|
|
334
|
+
this.#viewportRef = createRef();
|
|
335
|
+
this.#scrollRaf = 0;
|
|
336
|
+
this.#items = [];
|
|
337
|
+
this.#itemWrap = `stop`;
|
|
338
|
+
this.#entering = /* @__PURE__ */ new Set();
|
|
339
|
+
this.#reflowTimer = 0;
|
|
340
|
+
this.#sourceElement = new ElementGridListSource(this);
|
|
341
|
+
this.#source = this.#sourceElement;
|
|
342
|
+
this.selection = new ListSelectionController({
|
|
343
|
+
getOrderedItems: () => this.#source.keys(),
|
|
344
|
+
isSelectable: (k) => {
|
|
345
|
+
const i = this.#source.indexOfKey(k);
|
|
346
|
+
return i >= 0 && this.#source.isSelectable(i);
|
|
347
|
+
},
|
|
348
|
+
getModes: () => ({
|
|
349
|
+
selectionMode: this.selectionMode,
|
|
350
|
+
interactionMode: this.interactionMode
|
|
351
|
+
}),
|
|
352
|
+
getKey: (k) => k,
|
|
353
|
+
onChange: (selected, previous) => {
|
|
354
|
+
this._syncItemStates();
|
|
355
|
+
this.requestUpdate();
|
|
356
|
+
this.#emitSelect(selected, previous);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
this.tickled = new TickledController(this, {
|
|
360
|
+
getItems: () => this.#source.keys().map((k, i) => ({
|
|
361
|
+
id: k,
|
|
362
|
+
enabled: this.#source.isSelectable(i)
|
|
363
|
+
})),
|
|
364
|
+
onTickle: (k) => {
|
|
365
|
+
if (k !== void 0) this.#emitItemEvent(`list-tickle`, k);
|
|
366
|
+
},
|
|
367
|
+
onStateChange: () => this._syncItemStates(),
|
|
368
|
+
itemWrap: this.#itemWrap
|
|
369
|
+
});
|
|
370
|
+
this.#selectedSnapshot = /* @__PURE__ */ new Set();
|
|
371
|
+
this.#onScroll = (e) => {
|
|
372
|
+
const el = e.target;
|
|
373
|
+
this.#cancelScrollRaf();
|
|
374
|
+
this.#scrollRaf = requestAnimationFrame(() => {
|
|
375
|
+
this.#scrollRaf = 0;
|
|
376
|
+
this._scrollTop = el.scrollTop;
|
|
377
|
+
this._scrollLeft = el.scrollLeft;
|
|
378
|
+
this.#emitViewportChange();
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
this._onKeyDown = (e) => {
|
|
382
|
+
if ((e.ctrlKey || e.metaKey) && e.key === `f`) return;
|
|
383
|
+
if ((e.ctrlKey || e.metaKey) && e.key === `a`) {
|
|
384
|
+
if (this.selection.canSelectAll()) {
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
this.selection.selectAll();
|
|
387
|
+
}
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
const count = this.#source.count;
|
|
391
|
+
if (count === 0) return;
|
|
392
|
+
const win = this.#currentWindow();
|
|
393
|
+
const move = (delta) => {
|
|
394
|
+
const from = this.tickled.tickledId ? this.#source.indexOfKey(this.tickled.tickledId) : -1;
|
|
395
|
+
const nextIndex = Math.max(0, Math.min(count - 1, from + delta));
|
|
396
|
+
const nextKey = this.#source.keyAt(nextIndex);
|
|
397
|
+
if (nextKey) {
|
|
398
|
+
this.tickled.handleKeyboardNavigation(nextKey);
|
|
399
|
+
this.#scrollItemIntoView(nextKey);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const perLine = this.orientation === `grid` ? win.cols : 1;
|
|
403
|
+
switch (e.key) {
|
|
404
|
+
case `ArrowLeft`:
|
|
405
|
+
move(-1);
|
|
406
|
+
break;
|
|
407
|
+
case `ArrowRight`:
|
|
408
|
+
move(1);
|
|
409
|
+
break;
|
|
410
|
+
case `ArrowUp`:
|
|
411
|
+
move(-perLine);
|
|
412
|
+
break;
|
|
413
|
+
case `ArrowDown`:
|
|
414
|
+
move(perLine);
|
|
415
|
+
break;
|
|
416
|
+
case `Home`:
|
|
417
|
+
this.tickled.handleKeyboardNavigation(`first`);
|
|
418
|
+
if (this.tickled.tickledId) this.#scrollItemIntoView(this.tickled.tickledId);
|
|
419
|
+
break;
|
|
420
|
+
case `End`:
|
|
421
|
+
this.tickled.handleKeyboardNavigation(`last`);
|
|
422
|
+
if (this.tickled.tickledId) this.#scrollItemIntoView(this.tickled.tickledId);
|
|
423
|
+
break;
|
|
424
|
+
case `PageUp`:
|
|
425
|
+
case `PageDown`: {
|
|
426
|
+
const mainExtent = win.horizontal ? this._viewportWidth : this._viewportHeight;
|
|
427
|
+
const mainStride = win.horizontal ? win.colStride : win.rowStride;
|
|
428
|
+
const visibleLines = Math.max(1, Math.floor(mainExtent / mainStride));
|
|
429
|
+
move((e.key === `PageDown` ? 1 : -1) * visibleLines * perLine);
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
case `Enter`: {
|
|
433
|
+
const id = this.tickled.tickledId;
|
|
434
|
+
if (id) {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
this.#emitItemEvent(`list-item-click`, id);
|
|
437
|
+
this.#onCellActivate(id);
|
|
438
|
+
}
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
case ` `: {
|
|
442
|
+
const id = this.tickled.tickledId;
|
|
443
|
+
if (id) {
|
|
444
|
+
e.preventDefault();
|
|
445
|
+
this.selection.handleSpace(id);
|
|
446
|
+
}
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
case `Escape`:
|
|
450
|
+
this.selection.clear();
|
|
451
|
+
break;
|
|
452
|
+
default: return;
|
|
453
|
+
}
|
|
454
|
+
e.preventDefault();
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
static {
|
|
458
|
+
this.styles = [
|
|
459
|
+
themeFallbacks,
|
|
460
|
+
tickledStyles,
|
|
461
|
+
tickledItemStyles,
|
|
462
|
+
scrollFadeStyles(`x`),
|
|
463
|
+
scrollFadeStyles(`y`),
|
|
464
|
+
listItemFadeKeyframes,
|
|
465
|
+
listSearchStyles,
|
|
466
|
+
css`
|
|
467
|
+
:host {
|
|
468
|
+
--grid-list-item-bg: var(--item-bg);
|
|
469
|
+
--grid-list-radius: var(--radius-m);
|
|
470
|
+
--grid-list-gap: var(--space-xs);
|
|
471
|
+
position: relative;
|
|
472
|
+
display: block;
|
|
473
|
+
height: 100%;
|
|
474
|
+
min-height: 2em;
|
|
475
|
+
overflow: hidden;
|
|
476
|
+
user-select: none;
|
|
477
|
+
background: var(--surface-3);
|
|
478
|
+
color: var(--surface-3-text);
|
|
479
|
+
border-radius: var(--radius-s);
|
|
480
|
+
border: 1px solid var(--border);
|
|
481
|
+
}
|
|
482
|
+
:host(:focus-visible) {
|
|
483
|
+
outline: 2px solid var(--accent);
|
|
484
|
+
outline-offset: -2px;
|
|
485
|
+
}
|
|
486
|
+
.viewport {
|
|
487
|
+
position: relative;
|
|
488
|
+
height: 100%;
|
|
489
|
+
overflow-y: auto;
|
|
490
|
+
overflow-x: hidden;
|
|
491
|
+
/* Consumer control over the native scrollbar (both orientations): set
|
|
492
|
+
--grid-list-scrollbar-width to "none" to hide it or "thin" to slim it.
|
|
493
|
+
The container is also exposed as ::part(viewport). */
|
|
494
|
+
scrollbar-width: var(--grid-list-scrollbar-width, auto);
|
|
495
|
+
scrollbar-gutter: var(--grid-list-scrollbar-gutter, auto);
|
|
496
|
+
scrollbar-color: var(--grid-list-scrollbar-color, auto);
|
|
497
|
+
}
|
|
498
|
+
:host([orientation="row"]) .viewport {
|
|
499
|
+
overflow-x: auto;
|
|
500
|
+
overflow-y: hidden;
|
|
501
|
+
}
|
|
502
|
+
.spacer {
|
|
503
|
+
position: relative;
|
|
504
|
+
width: 100%;
|
|
505
|
+
}
|
|
506
|
+
.cell {
|
|
507
|
+
position: absolute;
|
|
508
|
+
inset: 0 auto auto 0;
|
|
509
|
+
box-sizing: border-box;
|
|
510
|
+
display: flex;
|
|
511
|
+
flex-direction: column;
|
|
512
|
+
align-items: stretch;
|
|
513
|
+
contain: layout style;
|
|
514
|
+
border-radius: var(--grid-list-radius);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/* The square that holds the slotted content. */
|
|
518
|
+
.thumb {
|
|
519
|
+
position: relative;
|
|
520
|
+
flex: 1;
|
|
521
|
+
min-height: 0;
|
|
522
|
+
display: flex;
|
|
523
|
+
align-items: stretch;
|
|
524
|
+
box-sizing: border-box;
|
|
525
|
+
overflow: hidden;
|
|
526
|
+
border-radius: 0;
|
|
527
|
+
background: transparent;
|
|
528
|
+
border: 1px solid transparent;
|
|
529
|
+
transition: background var(--transition), border-color var(--transition);
|
|
530
|
+
}
|
|
531
|
+
.thumb ::slotted(*) {
|
|
532
|
+
flex: 1;
|
|
533
|
+
min-width: 0;
|
|
534
|
+
min-height: 0;
|
|
535
|
+
width: 100%;
|
|
536
|
+
display: flex;
|
|
537
|
+
align-items: center;
|
|
538
|
+
justify-content: center;
|
|
539
|
+
overflow: hidden;
|
|
540
|
+
}
|
|
541
|
+
.thumb ::slotted(*:empty)::after {
|
|
542
|
+
content: "Empty";
|
|
543
|
+
color: var(--surface-muted-text);
|
|
544
|
+
font-size: var(--text-s);
|
|
545
|
+
}
|
|
546
|
+
::slotted([hidden]) {
|
|
547
|
+
display: none !important;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/* Selection / cursor wash — sits over the slotted content so it reads
|
|
551
|
+
on photos and arbitrary DOM alike. */
|
|
552
|
+
.thumb::after {
|
|
553
|
+
content: "";
|
|
554
|
+
position: absolute;
|
|
555
|
+
inset: 0;
|
|
556
|
+
pointer-events: none;
|
|
557
|
+
border-radius: inherit;
|
|
558
|
+
background: var(--accent);
|
|
559
|
+
opacity: 0;
|
|
560
|
+
transition: opacity var(--transition, 0.1s ease-out);
|
|
561
|
+
}
|
|
562
|
+
.cell.selected .thumb::after {
|
|
563
|
+
opacity: 0.18;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/* ---- Caption (base) ---- */
|
|
567
|
+
.caption {
|
|
568
|
+
box-sizing: border-box;
|
|
569
|
+
flex: none;
|
|
570
|
+
padding: 3px 6px;
|
|
571
|
+
font-size: var(--text-s, 0.8rem);
|
|
572
|
+
line-height: 1.3;
|
|
573
|
+
text-align: center;
|
|
574
|
+
white-space: nowrap;
|
|
575
|
+
overflow: hidden;
|
|
576
|
+
text-overflow: ellipsis;
|
|
577
|
+
color: var(--surface-3-text);
|
|
578
|
+
}
|
|
579
|
+
:host([caption-align="left"]) .caption { text-align: left; }
|
|
580
|
+
:host([caption-align="right"]) .caption { text-align: right; }
|
|
581
|
+
|
|
582
|
+
/* ---- Box modes (hidden / under / overlaid): the cell is one box with a
|
|
583
|
+
single selection outline ---- */
|
|
584
|
+
:host(:not([caption-style="separate"])) .cell {
|
|
585
|
+
background: var(--grid-list-item-bg);
|
|
586
|
+
border: 1px solid transparent;
|
|
587
|
+
overflow: hidden;
|
|
588
|
+
transition: background var(--transition), border-color var(--transition);
|
|
589
|
+
}
|
|
590
|
+
:host(:not([caption-style="separate"])) .cell:hover,
|
|
591
|
+
:host(:not([caption-style="separate"])) .cell.tickled {
|
|
592
|
+
background: var(--item-bg-tickled);
|
|
593
|
+
border: var(--item-border-tickled);
|
|
594
|
+
}
|
|
595
|
+
:host(:not([caption-style="separate"])) .cell.selected {
|
|
596
|
+
outline: 2px solid var(--accent);
|
|
597
|
+
outline-offset: -2px;
|
|
598
|
+
}
|
|
599
|
+
:host(:not([caption-style="separate"])) .cell.selected.tickled {
|
|
600
|
+
background: var(--item-bg-selected-tickled);
|
|
601
|
+
outline: 2px dashed var(--surface-3);
|
|
602
|
+
outline-offset: -2px;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/* under: caption is a strip inside the box, below the content */
|
|
606
|
+
:host([caption-style="under"]) .caption {
|
|
607
|
+
border-top: 1px solid var(--border, rgba(128, 128, 128, 0.3));
|
|
608
|
+
background: var(--surface-4, transparent);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/* overlaid: caption floats over the content */
|
|
612
|
+
:host([caption-style="overlaid"]) .caption {
|
|
613
|
+
position: absolute;
|
|
614
|
+
left: 0;
|
|
615
|
+
right: 0;
|
|
616
|
+
bottom: 0;
|
|
617
|
+
color: #fff;
|
|
618
|
+
}
|
|
619
|
+
:host([caption-style="overlaid"][caption-position="top"]) .caption {
|
|
620
|
+
top: 0;
|
|
621
|
+
bottom: auto;
|
|
622
|
+
}
|
|
623
|
+
:host([caption-style="overlaid"][caption-position="middle"]) .caption {
|
|
624
|
+
top: 50%;
|
|
625
|
+
bottom: auto;
|
|
626
|
+
transform: translateY(-50%);
|
|
627
|
+
}
|
|
628
|
+
/* overlaid backdrop */
|
|
629
|
+
:host([caption-style="overlaid"][caption-backdrop="scrim"]) .caption {
|
|
630
|
+
background: rgba(0, 0, 0, 0.55);
|
|
631
|
+
}
|
|
632
|
+
:host([caption-style="overlaid"][caption-backdrop="gradient"]) .caption {
|
|
633
|
+
background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
|
|
634
|
+
padding-block: 10px 4px;
|
|
635
|
+
}
|
|
636
|
+
:host([caption-style="overlaid"][caption-backdrop="gradient"][caption-position="top"]) .caption {
|
|
637
|
+
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
|
|
638
|
+
padding-block: 4px 10px;
|
|
639
|
+
}
|
|
640
|
+
:host([caption-style="overlaid"][caption-backdrop="gradient"][caption-position="middle"]) .caption {
|
|
641
|
+
background: rgba(0, 0, 0, 0.5);
|
|
642
|
+
padding-block: 3px;
|
|
643
|
+
}
|
|
644
|
+
:host([caption-style="overlaid"][caption-backdrop="blur"]) .caption {
|
|
645
|
+
background: rgba(20, 20, 20, 0.3);
|
|
646
|
+
backdrop-filter: blur(6px);
|
|
647
|
+
-webkit-backdrop-filter: blur(6px);
|
|
648
|
+
}
|
|
649
|
+
:host([caption-style="overlaid"][caption-backdrop="none"]) .caption {
|
|
650
|
+
background: none;
|
|
651
|
+
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.7);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/* ---- separate mode: square + detached caption, each highlighted ---- */
|
|
655
|
+
:host([caption-style="separate"]) .thumb {
|
|
656
|
+
flex: none;
|
|
657
|
+
border-radius: var(--grid-list-radius);
|
|
658
|
+
background: var(--grid-list-item-bg);
|
|
659
|
+
border: 1px solid transparent;
|
|
660
|
+
}
|
|
661
|
+
:host([caption-style="separate"]) .cell:hover .thumb,
|
|
662
|
+
:host([caption-style="separate"]) .cell.tickled .thumb {
|
|
663
|
+
background: var(--item-bg-tickled);
|
|
664
|
+
border: var(--item-border-tickled);
|
|
665
|
+
}
|
|
666
|
+
:host([caption-style="separate"]) .caption {
|
|
667
|
+
display: flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
align-self: center;
|
|
670
|
+
max-width: 100%;
|
|
671
|
+
margin-top: 4px;
|
|
672
|
+
border-radius: var(--radius-s, 4px);
|
|
673
|
+
}
|
|
674
|
+
:host([caption-style="separate"][caption-align="left"]) .caption { align-self: flex-start; }
|
|
675
|
+
:host([caption-style="separate"][caption-align="right"]) .caption { align-self: flex-end; }
|
|
676
|
+
:host([caption-style="separate"]) .cell.selected .thumb {
|
|
677
|
+
outline: 2px solid var(--accent);
|
|
678
|
+
outline-offset: 2px;
|
|
679
|
+
}
|
|
680
|
+
:host([caption-style="separate"]) .cell.selected.tickled .thumb {
|
|
681
|
+
background: var(--item-bg-selected-tickled);
|
|
682
|
+
outline: 2px dashed var(--surface-3);
|
|
683
|
+
outline-offset: 2px;
|
|
684
|
+
}
|
|
685
|
+
:host([caption-style="separate"]) .cell.selected .caption {
|
|
686
|
+
background: var(--accent);
|
|
687
|
+
color: var(--accent-text, #000);
|
|
688
|
+
}
|
|
689
|
+
:host([caption-style="separate"]) .cell.tickled .caption {
|
|
690
|
+
background: var(--item-bg-tickled);
|
|
691
|
+
outline: var(--item-border-tickled);
|
|
692
|
+
}
|
|
693
|
+
:host([caption-style="separate"]) .cell.selected.tickled .caption {
|
|
694
|
+
background: var(--item-bg-selected-tickled);
|
|
695
|
+
outline: 2px dashed var(--surface-3);
|
|
696
|
+
outline-offset: -2px;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/* ---- Insertion / removal animation ----
|
|
700
|
+
Active only while the host carries [reflowing] — the ~0.3s window after
|
|
701
|
+
the child list changes mid-list (see #noteChildMutation). Kept out of
|
|
702
|
+
the base rules so it never fires during scroll virtualisation, where
|
|
703
|
+
cells are recycled to wildly different positions every frame. Placed
|
|
704
|
+
last so it wins over the earlier cell transition rule regardless of
|
|
705
|
+
specificity. Survivors slide to their new slot; a freshly inserted cell
|
|
706
|
+
also fades in. (A removed item's element is already gone, so there's
|
|
707
|
+
nothing left to fade — the gap simply closes as the others slide.) */
|
|
708
|
+
:host([reflowing]) .cell {
|
|
709
|
+
transition:
|
|
710
|
+
transform var(--grid-list-item-move-duration, 200ms) cubic-bezier(0.2, 0, 0, 1),
|
|
711
|
+
background var(--transition),
|
|
712
|
+
border-color var(--transition);
|
|
713
|
+
}
|
|
714
|
+
.cell.entering {
|
|
715
|
+
animation: ixfx-list-item-in var(--grid-list-item-move-duration, 200ms) ease both;
|
|
716
|
+
}
|
|
717
|
+
@media (prefers-reduced-motion: reduce) {
|
|
718
|
+
:host([reflowing]) .cell { transition: background var(--transition), border-color var(--transition); }
|
|
719
|
+
.cell.entering { animation: none; }
|
|
720
|
+
}
|
|
721
|
+
`
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
#viewportRef;
|
|
725
|
+
#resizeObserver;
|
|
726
|
+
#mutationObserver;
|
|
727
|
+
#scrollRaf;
|
|
728
|
+
#items;
|
|
729
|
+
#itemWrap;
|
|
730
|
+
/** Items added mid-list that are still playing their enter animation. */
|
|
731
|
+
#entering;
|
|
732
|
+
/** Timer that ends the `[reflowing]` window opened by a mid-list insertion. */
|
|
733
|
+
#reflowTimer;
|
|
734
|
+
/**
|
|
735
|
+
* When cell geometry changes (zoom), the item nearest the viewport centre is
|
|
736
|
+
* captured here in `willUpdate` and the scroll position is corrected in
|
|
737
|
+
* `updated` so that item stays put — rather than the grid anchoring to its
|
|
738
|
+
* top-left corner.
|
|
739
|
+
*/
|
|
740
|
+
#zoomAnchor;
|
|
741
|
+
/**
|
|
742
|
+
* The active view over the items. Element mode projects light-DOM children
|
|
743
|
+
* through named `<slot>`s (owned by {@link ElementGridListSource}); data mode
|
|
744
|
+
* renders from {@link items} via {@link itemAdapter}. Everything else here
|
|
745
|
+
* addresses items by effective index + key and never branches on the mode.
|
|
746
|
+
*
|
|
747
|
+
* Initialised eagerly (element mode) so the public getters — `count`,
|
|
748
|
+
* `selectedKeys`, … — are safe to touch before the first Lit update. The
|
|
749
|
+
* first `willUpdate` rebuilds it once the light DOM / `itemAdapter` is known.
|
|
750
|
+
*/
|
|
751
|
+
#sourceElement;
|
|
752
|
+
#source;
|
|
753
|
+
#searchMode;
|
|
754
|
+
#searchFilterKeys;
|
|
755
|
+
/** (Re)build {@link search} for the current mode; a no-op if it already matches. */
|
|
756
|
+
#ensureSearch() {
|
|
757
|
+
const mode = this.itemAdapter !== void 0 ? `data` : `element`;
|
|
758
|
+
if (this.#searchMode === mode && this.search !== void 0) return;
|
|
759
|
+
const previous = this.search;
|
|
760
|
+
if (previous) {
|
|
761
|
+
previous.hostDisconnected();
|
|
762
|
+
this.removeController(previous);
|
|
763
|
+
}
|
|
764
|
+
this.search = mode === `data` ? new ListSearchController(this, { adapter: createDataListSearchAdapter(this, {
|
|
765
|
+
rawCount: () => this.#source?.rawCount ?? 0,
|
|
766
|
+
rawKeyAt: (i) => this.#source?.rawKeyAt(i) ?? ``,
|
|
767
|
+
rawSearchTextAt: (i) => this.#source?.rawSearchTextAt(i) ?? ``,
|
|
768
|
+
onFilterChange: (keys) => {
|
|
769
|
+
this.#searchFilterKeys = keys;
|
|
770
|
+
this.#source?.setFilters({ searchKeys: keys });
|
|
771
|
+
this.requestUpdate();
|
|
772
|
+
this.updateComplete.then(() => this.#emitViewportChange());
|
|
773
|
+
},
|
|
774
|
+
onActivate: (key) => this.#onCellActivate(key),
|
|
775
|
+
getHighlightRoot: () => this.renderRoot
|
|
776
|
+
}) }) : new ListSearchController(this, { adapter: createElementListSearchAdapter(this, {
|
|
777
|
+
itemSelector: ITEM_SELECTOR,
|
|
778
|
+
getLabel: (el) => el.getAttribute(`data-label`) ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim() ?? el.getAttribute(`data-search-label`) ?? el.textContent?.trim() ?? ``,
|
|
779
|
+
highlightKey: `grid-list-search`
|
|
780
|
+
}) });
|
|
781
|
+
this.#searchMode = mode;
|
|
782
|
+
}
|
|
783
|
+
#searchRegistry;
|
|
784
|
+
#unregisterSearchCommands;
|
|
785
|
+
/** Command registry carrying this grid's `list.search.*` commands. */
|
|
786
|
+
get registry() {
|
|
787
|
+
return this.#searchRegistry;
|
|
788
|
+
}
|
|
789
|
+
/** Effective search modes: this component's capability (all three) ∩ the `search-modes` attribute. */
|
|
790
|
+
#effectiveSearchModes() {
|
|
791
|
+
const raw = this.searchModes?.trim();
|
|
792
|
+
if (raw === void 0) return [...LIST_SEARCH_MODES];
|
|
793
|
+
const requested = new Set(raw.split(/\s+/));
|
|
794
|
+
return LIST_SEARCH_MODES.filter((m) => requested.has(m));
|
|
795
|
+
}
|
|
796
|
+
#syncSearchCommands() {
|
|
797
|
+
if (!this.#searchRegistry || !this.search) return;
|
|
798
|
+
this.search.setModes(this.#effectiveSearchModes());
|
|
799
|
+
this.#unregisterSearchCommands?.();
|
|
800
|
+
this.#unregisterSearchCommands = registerListSearchCommands(this.#searchRegistry, this.search);
|
|
801
|
+
}
|
|
802
|
+
connectedCallback() {
|
|
803
|
+
super.connectedCallback();
|
|
804
|
+
if (!this.hasAttribute(`tabindex`)) this.tabIndex = 0;
|
|
805
|
+
if (!this.hasAttribute(`role`)) this.setAttribute(`role`, `listbox`);
|
|
806
|
+
this.#syncAriaMultiselectable();
|
|
807
|
+
for (const [attr, value] of [
|
|
808
|
+
[`caption-style`, this.captionStyle],
|
|
809
|
+
[`caption-align`, this.captionAlign],
|
|
810
|
+
[`caption-position`, this.captionPosition],
|
|
811
|
+
[`caption-backdrop`, this.captionBackdrop]
|
|
812
|
+
]) if (!this.hasAttribute(attr)) this.setAttribute(attr, value);
|
|
813
|
+
this.addEventListener(`keydown`, this._onKeyDown);
|
|
814
|
+
this.#mutationObserver ??= new MutationObserver((records) => this.#onChildrenChanged(records));
|
|
815
|
+
this.#mutationObserver.observe(this, {
|
|
816
|
+
childList: true,
|
|
817
|
+
attributeFilter: [`hidden`]
|
|
818
|
+
});
|
|
819
|
+
this.#searchRegistry ??= createCommandRegistry();
|
|
820
|
+
this.#ensureSearch();
|
|
821
|
+
this.#syncSearchCommands();
|
|
822
|
+
}
|
|
823
|
+
disconnectedCallback() {
|
|
824
|
+
super.disconnectedCallback();
|
|
825
|
+
this.removeEventListener(`keydown`, this._onKeyDown);
|
|
826
|
+
this.#resizeObserver?.disconnect();
|
|
827
|
+
this.#resizeObserver = void 0;
|
|
828
|
+
this.#mutationObserver?.disconnect();
|
|
829
|
+
this.#cancelScrollRaf();
|
|
830
|
+
this.#unregisterSearchCommands?.();
|
|
831
|
+
this.#unregisterSearchCommands = void 0;
|
|
832
|
+
this.#searchRegistry = void 0;
|
|
833
|
+
if (this.#reflowTimer) {
|
|
834
|
+
clearTimeout(this.#reflowTimer);
|
|
835
|
+
this.#reflowTimer = 0;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
#onChildrenChanged(records) {
|
|
839
|
+
const previousLength = this.#items.length;
|
|
840
|
+
this.#syncItems();
|
|
841
|
+
const removedKeys = [];
|
|
842
|
+
for (const record of records ?? []) for (const node of record.removedNodes) {
|
|
843
|
+
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
844
|
+
const key = keyForElement(node);
|
|
845
|
+
if (key !== void 0) removedKeys.push(key);
|
|
846
|
+
}
|
|
847
|
+
if (removedKeys.length > 0) {
|
|
848
|
+
const present = new Set(this.#source.keys());
|
|
849
|
+
const gone = removedKeys.filter((k) => !present.has(k));
|
|
850
|
+
if (gone.length > 0) this.selection.removeKeys(gone, (k) => k);
|
|
851
|
+
const tickledId = this.tickled.tickledId;
|
|
852
|
+
if (tickledId && gone.includes(tickledId)) this.tickled.focus(void 0);
|
|
853
|
+
}
|
|
854
|
+
this._syncItemStates();
|
|
855
|
+
this.#noteChildMutation(previousLength, records);
|
|
856
|
+
this.requestUpdate();
|
|
857
|
+
this.updateComplete.then(() => this.#emitViewportChange());
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* When the child list changes mid-list — not a first populate or a wholesale
|
|
861
|
+
* replace — mark any newcomers for an enter animation and open a short
|
|
862
|
+
* `[reflowing]` window so the cells that shift slide to their new position
|
|
863
|
+
* instead of snapping. Removals get the same window (the survivors slide to
|
|
864
|
+
* close the gap). The window is bounded in time so the transform transition
|
|
865
|
+
* never bleeds into scroll virtualisation.
|
|
866
|
+
*
|
|
867
|
+
* Reads the `MutationRecord`s directly rather than diffing `#items`, because a
|
|
868
|
+
* `requestUpdate()` between the DOM change and this callback (e.g. a caller
|
|
869
|
+
* that clears the selection before removing) lets `updated()` re-sync `#items`
|
|
870
|
+
* first, which would hide the change from a naive diff.
|
|
871
|
+
*/
|
|
872
|
+
#noteChildMutation(previousLength, records) {
|
|
873
|
+
if (!this.hasUpdated || !records || records.length === 0) return;
|
|
874
|
+
const currentSet = new Set(this.#items);
|
|
875
|
+
const added = [];
|
|
876
|
+
let removedCount = 0;
|
|
877
|
+
for (const record of records) {
|
|
878
|
+
for (const node of record.addedNodes) if (node.nodeType === Node.ELEMENT_NODE && currentSet.has(node)) added.push(node);
|
|
879
|
+
for (const node of record.removedNodes) if (node.nodeType === Node.ELEMENT_NODE) removedCount++;
|
|
880
|
+
}
|
|
881
|
+
if (added.length === 0 && removedCount === 0) return;
|
|
882
|
+
if (previousLength === 0 && removedCount === 0) return;
|
|
883
|
+
if (added.length > 0 && added.length === this.#items.length) return;
|
|
884
|
+
for (const el of added) this.#entering.add(el);
|
|
885
|
+
this.toggleAttribute(`reflowing`, true);
|
|
886
|
+
if (this.#reflowTimer) clearTimeout(this.#reflowTimer);
|
|
887
|
+
this.#reflowTimer = window.setTimeout(() => {
|
|
888
|
+
this.#reflowTimer = 0;
|
|
889
|
+
this.#entering.clear();
|
|
890
|
+
this.toggleAttribute(`reflowing`, false);
|
|
891
|
+
this.requestUpdate();
|
|
892
|
+
}, REFLOW_WINDOW_MS);
|
|
893
|
+
}
|
|
894
|
+
#emitViewportChange() {
|
|
895
|
+
this._dispatch(`grid-list-viewport-change`, {
|
|
896
|
+
renderedKeys: this.renderedKeys(),
|
|
897
|
+
visibleKeys: this.visibleKeys()
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
firstUpdated() {
|
|
901
|
+
if (!this.#source) this.#rebuildSource();
|
|
902
|
+
const el = this.#viewportRef.value;
|
|
903
|
+
if (!el) return;
|
|
904
|
+
this.#resizeObserver = new ResizeObserver((entries) => {
|
|
905
|
+
for (const entry of entries) {
|
|
906
|
+
const w = entry.contentRect.width;
|
|
907
|
+
const h = entry.contentRect.height;
|
|
908
|
+
if (w <= 0 || h <= 0) return;
|
|
909
|
+
this._viewportWidth = w;
|
|
910
|
+
this._viewportHeight = h;
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
this.#resizeObserver.observe(el);
|
|
914
|
+
this.#measureViewport(false);
|
|
915
|
+
this.#syncItems();
|
|
916
|
+
this.requestUpdate();
|
|
917
|
+
}
|
|
918
|
+
/** (Re)construct {@link #source} for the current mode and re-apply the filters. */
|
|
919
|
+
#rebuildSource() {
|
|
920
|
+
if (this.itemAdapter !== void 0) {
|
|
921
|
+
this.#source = new DataGridListSource(this.items, this.itemAdapter);
|
|
922
|
+
this.#sourceElement = void 0;
|
|
923
|
+
} else {
|
|
924
|
+
this.#sourceElement = new ElementGridListSource(this);
|
|
925
|
+
this.#source = this.#sourceElement;
|
|
926
|
+
}
|
|
927
|
+
this.#applyFilters();
|
|
928
|
+
if (this.#searchFilterKeys) this.#source.setFilters({ searchKeys: this.#searchFilterKeys });
|
|
929
|
+
}
|
|
930
|
+
/** Push the current filter predicate into whichever source is active. */
|
|
931
|
+
#applyFilters() {
|
|
932
|
+
if (this.#source instanceof ElementGridListSource) {
|
|
933
|
+
const fp = this.filterPredicate;
|
|
934
|
+
const src = this.#source;
|
|
935
|
+
src.setFilters({ predicate: fp ? (i) => fp(src.rawElementAt(i)) : void 0 });
|
|
936
|
+
this.#items = src.effectiveElements();
|
|
937
|
+
} else if (this.#source instanceof DataGridListSource) {
|
|
938
|
+
const ip = this.itemFilterPredicate;
|
|
939
|
+
const src = this.#source;
|
|
940
|
+
src.setFilters({ predicate: ip ? (i) => ip(src.rawItemAt(i), i) : void 0 });
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
willUpdate(changed) {
|
|
944
|
+
if (changed.has(`searchModes`)) this.#syncSearchCommands();
|
|
945
|
+
if (changed.has(`filterPredicate`) || changed.has(`itemFilterPredicate`)) {
|
|
946
|
+
this.#applyFilters();
|
|
947
|
+
this.updateComplete.then(() => this.#emitViewportChange());
|
|
948
|
+
}
|
|
949
|
+
if (changed.has(`items`) || changed.has(`itemAdapter`)) {
|
|
950
|
+
this.#zoomAnchor = void 0;
|
|
951
|
+
const prevKeys = this.#source?.keys() ?? [];
|
|
952
|
+
const modeFlipped = this.itemAdapter !== void 0 !== this.#source instanceof DataGridListSource;
|
|
953
|
+
this.#rebuildSource();
|
|
954
|
+
const nextKeys = this.#source.keys();
|
|
955
|
+
const nextKeySet = new Set(nextKeys);
|
|
956
|
+
const removedKeys = prevKeys.filter((k) => !nextKeySet.has(k));
|
|
957
|
+
if (removedKeys.length > 0) this.selection.removeKeys(removedKeys, (k) => k);
|
|
958
|
+
const tickledId = this.tickled.tickledId;
|
|
959
|
+
if (tickledId && !nextKeySet.has(tickledId)) this.tickled.focus(void 0);
|
|
960
|
+
this._syncItemStates();
|
|
961
|
+
this.updateComplete.then(() => this.#emitViewportChange());
|
|
962
|
+
if (modeFlipped) {
|
|
963
|
+
this.#ensureSearch();
|
|
964
|
+
this.#syncSearchCommands();
|
|
965
|
+
}
|
|
966
|
+
this.search?.refresh();
|
|
967
|
+
}
|
|
968
|
+
if (changed.has(`itemSize`) || changed.has(`gap`)) {
|
|
969
|
+
this.itemSize = Math.max(MIN_ITEM_SIZE, Math.round(this.itemSize));
|
|
970
|
+
this.gap = Math.max(0, Math.round(this.gap));
|
|
971
|
+
}
|
|
972
|
+
if (changed.has(`captionHeight`)) this.captionHeight = Math.max(0, Math.round(this.captionHeight));
|
|
973
|
+
if (changed.has(`itemWrap`)) this.#itemWrap = this.itemWrap;
|
|
974
|
+
if ((changed.has(`itemSize`) || changed.has(`gap`) || changed.has(`captionStyle`) || changed.has(`captionHeight`) || changed.has(`orientation`)) && this.hasUpdated && this.#source.count > 0) {
|
|
975
|
+
const prevOrientation = changed.get(`orientation`) ?? this.orientation;
|
|
976
|
+
const horizontal = prevOrientation === `row`;
|
|
977
|
+
const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;
|
|
978
|
+
const prevExtent = horizontal ? this._viewportWidth : this._viewportHeight;
|
|
979
|
+
if (prevExtent > 0 && prevOffset > 1) {
|
|
980
|
+
const prevItemSize = changed.get(`itemSize`) ?? this.itemSize;
|
|
981
|
+
const prevGap = changed.get(`gap`) ?? this.gap;
|
|
982
|
+
const prevCaptionStyle = changed.get(`captionStyle`) ?? this.captionStyle;
|
|
983
|
+
const prevCaptionHeight = changed.get(`captionHeight`) ?? this.captionHeight;
|
|
984
|
+
this.#captureCentreAnchor(prevOffset, prevExtent, prevItemSize, prevGap, prevCaptionStyle, prevCaptionHeight, prevOrientation);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
#syncAriaMultiselectable() {
|
|
989
|
+
this.setAttribute(`aria-multiselectable`, this.selection.canSelectMultiple() ? `true` : `false`);
|
|
990
|
+
}
|
|
991
|
+
/** Full cell height: the square, plus a caption band in `separate` / `under`. */
|
|
992
|
+
#rowHeight() {
|
|
993
|
+
const captionBand = this.captionStyle === `separate` || this.captionStyle === `under`;
|
|
994
|
+
return this.itemSize + (captionBand ? this.captionHeight : 0);
|
|
995
|
+
}
|
|
996
|
+
#captionFor(el) {
|
|
997
|
+
return el.getAttribute(`data-label`) ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim() ?? ``;
|
|
998
|
+
}
|
|
999
|
+
updated(changed) {
|
|
1000
|
+
super.updated(changed);
|
|
1001
|
+
this.#syncItems();
|
|
1002
|
+
if (changed.has(`selectionMode`) || changed.has(`interactionMode`)) {
|
|
1003
|
+
this.selection.clearAnchor();
|
|
1004
|
+
this.#syncAriaMultiselectable();
|
|
1005
|
+
}
|
|
1006
|
+
if (changed.has(`orientation`)) {
|
|
1007
|
+
const vp = this.#viewportRef.value;
|
|
1008
|
+
if (vp) {
|
|
1009
|
+
if (this.orientation === `row`) {
|
|
1010
|
+
vp.scrollTop = 0;
|
|
1011
|
+
this._scrollTop = 0;
|
|
1012
|
+
} else {
|
|
1013
|
+
vp.scrollLeft = 0;
|
|
1014
|
+
this._scrollLeft = 0;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
const vp = this.#viewportRef.value;
|
|
1019
|
+
if (vp) {
|
|
1020
|
+
if (Math.abs(vp.scrollTop - this._scrollTop) > .5) vp.scrollTop = this._scrollTop;
|
|
1021
|
+
if (Math.abs(vp.scrollLeft - this._scrollLeft) > .5) vp.scrollLeft = this._scrollLeft;
|
|
1022
|
+
}
|
|
1023
|
+
this.#applyZoomAnchor();
|
|
1024
|
+
}
|
|
1025
|
+
/** Re-anchor the scroll so the item captured in `willUpdate` stays centred. */
|
|
1026
|
+
#applyZoomAnchor() {
|
|
1027
|
+
if (!this.#zoomAnchor) return;
|
|
1028
|
+
const { index, lineFrac } = this.#zoomAnchor;
|
|
1029
|
+
this.#zoomAnchor = void 0;
|
|
1030
|
+
const vp = this.#viewportRef.value;
|
|
1031
|
+
if (!vp) return;
|
|
1032
|
+
const win = this.#currentWindow();
|
|
1033
|
+
if (win.horizontal) {
|
|
1034
|
+
if (this._viewportWidth <= 0) return;
|
|
1035
|
+
const targetCenter = (index + lineFrac) * win.colStride;
|
|
1036
|
+
const maxScroll = Math.max(0, win.totalWidth - this._viewportWidth);
|
|
1037
|
+
const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportWidth / 2));
|
|
1038
|
+
if (Math.abs(vp.scrollLeft - next) > .5) {
|
|
1039
|
+
vp.scrollLeft = next;
|
|
1040
|
+
this._scrollLeft = next;
|
|
1041
|
+
}
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
if (this._viewportHeight <= 0) return;
|
|
1045
|
+
const targetCenter = ((win.cols > 0 ? Math.floor(index / win.cols) : 0) + lineFrac) * win.rowStride;
|
|
1046
|
+
const maxScroll = Math.max(0, win.totalHeight - this._viewportHeight);
|
|
1047
|
+
const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportHeight / 2));
|
|
1048
|
+
if (Math.abs(vp.scrollTop - next) > .5) {
|
|
1049
|
+
vp.scrollTop = next;
|
|
1050
|
+
this._scrollTop = next;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
#captureCentreAnchor(prevOffset, prevExtent, prevItemSize, prevGap, prevCaptionStyle, prevCaptionHeight, prevOrientation) {
|
|
1054
|
+
const count = this.#source?.count ?? 0;
|
|
1055
|
+
if (count === 0) return;
|
|
1056
|
+
const prevRowHeight = prevItemSize + (prevCaptionStyle === `separate` || prevCaptionStyle === `under` ? prevCaptionHeight : 0);
|
|
1057
|
+
const horizontal = prevOrientation === `row`;
|
|
1058
|
+
const prev = computeGridWindow(count, prevItemSize, prevRowHeight, prevGap, this._viewportWidth, this._viewportHeight, prevOffset, prevOrientation);
|
|
1059
|
+
const mainStride = horizontal ? prev.colStride : prev.rowStride;
|
|
1060
|
+
const centerLine = (prevOffset + prevExtent / 2) / mainStride;
|
|
1061
|
+
const lineFloor = Math.max(0, Math.floor(centerLine));
|
|
1062
|
+
const index = horizontal ? Math.min(count - 1, lineFloor) : Math.min(count - 1, lineFloor * prev.cols + Math.max(0, Math.floor((prev.cols - 1) / 2)));
|
|
1063
|
+
this.#zoomAnchor = {
|
|
1064
|
+
index,
|
|
1065
|
+
lineFrac: centerLine - lineFloor
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Re-read the viewport after an ancestor's visibility/layout changed.
|
|
1070
|
+
* Safe while hidden (zero-sized reads are ignored); forces a repaint of the
|
|
1071
|
+
* virtual window even when the size is unchanged.
|
|
1072
|
+
*/
|
|
1073
|
+
refreshLayout() {
|
|
1074
|
+
this.#measureViewport(true);
|
|
1075
|
+
}
|
|
1076
|
+
/** Alias of {@link refreshLayout}. */
|
|
1077
|
+
remeasure() {
|
|
1078
|
+
this.#measureViewport(true);
|
|
1079
|
+
}
|
|
1080
|
+
#measureViewport(forceRender = false) {
|
|
1081
|
+
const vp = this.#viewportRef.value;
|
|
1082
|
+
if (!vp) return;
|
|
1083
|
+
const w = vp.clientWidth;
|
|
1084
|
+
const h = vp.clientHeight;
|
|
1085
|
+
if (w <= 0 || h <= 0) return;
|
|
1086
|
+
const horizontal = this.orientation === `row`;
|
|
1087
|
+
const changed = w !== this._viewportWidth || h !== this._viewportHeight;
|
|
1088
|
+
if (changed) {
|
|
1089
|
+
const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;
|
|
1090
|
+
const prevExtent = horizontal ? w : h;
|
|
1091
|
+
this.#captureCentreAnchor(prevOffset, prevExtent, this.itemSize, this.gap, this.captionStyle, this.captionHeight, this.orientation);
|
|
1092
|
+
this._viewportWidth = w;
|
|
1093
|
+
this._viewportHeight = h;
|
|
1094
|
+
}
|
|
1095
|
+
if (forceRender && !changed) {
|
|
1096
|
+
this.#captureCentreAnchor(horizontal ? this._scrollLeft : this._scrollTop, horizontal ? w : h, this.itemSize, this.gap, this.captionStyle, this.captionHeight, this.orientation);
|
|
1097
|
+
this.requestUpdate();
|
|
1098
|
+
}
|
|
1099
|
+
if (changed || forceRender) this.updateComplete.then(() => this.#emitViewportChange());
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Element mode only: re-read the light DOM into the source and refresh the
|
|
1103
|
+
* `#items` cache + filter. A no-op in data mode (the source is rebuilt through
|
|
1104
|
+
* `#rebuildSource` when `items` / `itemAdapter` change).
|
|
1105
|
+
*/
|
|
1106
|
+
#syncItems() {
|
|
1107
|
+
if (this.#source instanceof ElementGridListSource) {
|
|
1108
|
+
this.#source.refresh();
|
|
1109
|
+
this.#applyFilters();
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
get count() {
|
|
1113
|
+
return this.#source.count;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Number of cells currently rendered in the shadow DOM. With virtualization
|
|
1117
|
+
* this is roughly the visible rows plus overscan, regardless of how large
|
|
1118
|
+
* `count` is — useful for demos/diagnostics.
|
|
1119
|
+
*/
|
|
1120
|
+
get renderedCount() {
|
|
1121
|
+
return this.renderRoot.querySelectorAll(`.cell`).length;
|
|
1122
|
+
}
|
|
1123
|
+
get selectedItems() {
|
|
1124
|
+
const els = /* @__PURE__ */ new Set();
|
|
1125
|
+
for (const key of this.selection.selectedKeys) {
|
|
1126
|
+
const el = this.#source.resolveKeyToElement(key);
|
|
1127
|
+
if (el) els.add(el);
|
|
1128
|
+
}
|
|
1129
|
+
return els;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* The selection as stable `data-key` / `data-value` strings. Auto-assigned
|
|
1133
|
+
* keys for keyless light-DOM items are omitted (they are not a stable contract
|
|
1134
|
+
* for the consumer).
|
|
1135
|
+
*/
|
|
1136
|
+
get selectedKeys() {
|
|
1137
|
+
const out = /* @__PURE__ */ new Set();
|
|
1138
|
+
for (const k of this.selection.selectedKeys) if (!isSyntheticKey(k)) out.add(k);
|
|
1139
|
+
return out;
|
|
1140
|
+
}
|
|
1141
|
+
select(item) {
|
|
1142
|
+
const key = keyForElement(item);
|
|
1143
|
+
if (key) this.selection.replace(key);
|
|
1144
|
+
}
|
|
1145
|
+
selectMany(items) {
|
|
1146
|
+
const keys = [];
|
|
1147
|
+
for (const item of items) {
|
|
1148
|
+
const key = keyForElement(item);
|
|
1149
|
+
if (key) keys.push(key);
|
|
1150
|
+
}
|
|
1151
|
+
this.selection.selectMany(keys);
|
|
1152
|
+
}
|
|
1153
|
+
deselect(item) {
|
|
1154
|
+
const key = keyForElement(item);
|
|
1155
|
+
if (key) this.selection.deselect(key);
|
|
1156
|
+
}
|
|
1157
|
+
clearSelection() {
|
|
1158
|
+
this.selection.clear();
|
|
1159
|
+
}
|
|
1160
|
+
selectAll() {
|
|
1161
|
+
if (this.selection.canSelectAll()) this.selection.selectAll();
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Replace the selection with the items carrying these keys. Unknown keys are
|
|
1165
|
+
* ignored; survives the host rebuilding the item set. Requires each item to
|
|
1166
|
+
* have a `data-key` (or `data-value`).
|
|
1167
|
+
*/
|
|
1168
|
+
selectKeys(keys) {
|
|
1169
|
+
this.selection.selectKeys(keys, (k) => k);
|
|
1170
|
+
}
|
|
1171
|
+
/** Add items by key to the selection (multi-select modes only). */
|
|
1172
|
+
addSelectedKeys(keys) {
|
|
1173
|
+
this.selection.addKeys(keys, (k) => k);
|
|
1174
|
+
}
|
|
1175
|
+
/** Remove items by key from the selection. */
|
|
1176
|
+
removeSelectedKeys(keys) {
|
|
1177
|
+
this.selection.removeKeys(keys, (k) => k);
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Data mode only: raw index of `key` in `this.items`, or `-1`. Data-mode keys
|
|
1181
|
+
* come straight from the adapter, so this is exact even under a filter/search.
|
|
1182
|
+
*/
|
|
1183
|
+
#rawIndexOfKey(key) {
|
|
1184
|
+
const adapter = this.itemAdapter;
|
|
1185
|
+
if (!adapter) return -1;
|
|
1186
|
+
return this.items.findIndex((it, i) => adapter.key(it, i) === key);
|
|
1187
|
+
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Data mode: replace the whole item array. Selection and cursor keep any key
|
|
1190
|
+
* that is still present; keys that vanish are dropped (one `list-select`).
|
|
1191
|
+
* A no-op in element mode.
|
|
1192
|
+
*/
|
|
1193
|
+
setItems(items) {
|
|
1194
|
+
if (this.itemAdapter) this.items = items;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Data mode: append items to the end. Scroll position, selection and cursor
|
|
1198
|
+
* are untouched; appended items don't play the mid-list `[reflowing]` slide.
|
|
1199
|
+
* A no-op in element mode.
|
|
1200
|
+
*/
|
|
1201
|
+
appendItems(items) {
|
|
1202
|
+
if (this.itemAdapter && items.length > 0) this.items = [...this.items, ...items];
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Data mode: replace the item carrying `key`. A visible cell re-renders in
|
|
1206
|
+
* place (the keyed subtree is kept); an offscreen item shows its new content
|
|
1207
|
+
* when scrolled into view. Scroll and selection are untouched. Unknown keys
|
|
1208
|
+
* are ignored.
|
|
1209
|
+
*/
|
|
1210
|
+
updateItem(key, item) {
|
|
1211
|
+
if (!this.itemAdapter) return;
|
|
1212
|
+
const idx = this.#rawIndexOfKey(key);
|
|
1213
|
+
if (idx < 0) return;
|
|
1214
|
+
const next = [...this.items];
|
|
1215
|
+
next[idx] = item;
|
|
1216
|
+
this.items = next;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Data mode: remove the items carrying these keys. Removed keys are dropped
|
|
1220
|
+
* from selection and cursor (via the `items` change). A no-op in element mode.
|
|
1221
|
+
*/
|
|
1222
|
+
removeItems(keys) {
|
|
1223
|
+
if (!this.itemAdapter) return;
|
|
1224
|
+
const adapter = this.itemAdapter;
|
|
1225
|
+
const keySet = new Set(keys);
|
|
1226
|
+
this.items = this.items.filter((it, i) => !keySet.has(adapter.key(it, i)));
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Data mode: drop every item. Selection and cursor are reset and one
|
|
1230
|
+
* `list-select` with empty sets is emitted. A no-op in element mode.
|
|
1231
|
+
*/
|
|
1232
|
+
clearItems() {
|
|
1233
|
+
if (!this.itemAdapter) return;
|
|
1234
|
+
this.selection.reset();
|
|
1235
|
+
this.tickled.focus(void 0);
|
|
1236
|
+
this.items = [];
|
|
1237
|
+
this.#emitSelect(/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set());
|
|
1238
|
+
}
|
|
1239
|
+
/** Move the cursor to the item with this key and scroll it into view. */
|
|
1240
|
+
focusKey(key) {
|
|
1241
|
+
if (this.#source.indexOfKey(key) < 0) return;
|
|
1242
|
+
this.tickled.focus(key);
|
|
1243
|
+
this.#scrollItemIntoView(key);
|
|
1244
|
+
}
|
|
1245
|
+
/** The key of the item under the cursor, or `undefined`. */
|
|
1246
|
+
get tickledKey() {
|
|
1247
|
+
return this.tickled.tickledId;
|
|
1248
|
+
}
|
|
1249
|
+
/** Element mode: the light-DOM element carrying `key`, or `undefined`. */
|
|
1250
|
+
getItem(key) {
|
|
1251
|
+
return this.#source.resolveKeyToElement(key);
|
|
1252
|
+
}
|
|
1253
|
+
/** Element mode: the light-DOM element at effective index `index`. */
|
|
1254
|
+
getItemByIndex(index) {
|
|
1255
|
+
return this.#items[index];
|
|
1256
|
+
}
|
|
1257
|
+
/** Data mode: the data value carrying `key`, or `undefined`. */
|
|
1258
|
+
getData(key) {
|
|
1259
|
+
return this.#source.resolveKeyToData(key);
|
|
1260
|
+
}
|
|
1261
|
+
getKey(item) {
|
|
1262
|
+
return keyForElement(item);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Keys of items in the rendered window (viewport + overscan) — the priority
|
|
1266
|
+
* set for prefetching. Use {@link visibleKeys} for the strict viewport
|
|
1267
|
+
* intersection. Auto-assigned keyless-item keys are omitted.
|
|
1268
|
+
*/
|
|
1269
|
+
renderedKeys() {
|
|
1270
|
+
return this.#windowKeys(this.#currentWindow());
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Keys of items actually intersecting the viewport (no overscan).
|
|
1274
|
+
* Auto-assigned keyless-item keys are omitted.
|
|
1275
|
+
*/
|
|
1276
|
+
visibleKeys() {
|
|
1277
|
+
return this.#windowKeys(this.#currentWindow(true));
|
|
1278
|
+
}
|
|
1279
|
+
#windowKeys(win) {
|
|
1280
|
+
return this.#source.keys().slice(win.startIndex, win.endIndex).filter((k) => !isSyntheticKey(k));
|
|
1281
|
+
}
|
|
1282
|
+
#currentWindow(noOverscan = false) {
|
|
1283
|
+
const overscan = noOverscan ? 0 : 2;
|
|
1284
|
+
return computeGridWindow(this.#source.count, this.itemSize, this.#rowHeight(), this.gap, this._viewportWidth, this._viewportHeight, this.orientation === `row` ? this._scrollLeft : this._scrollTop, this.orientation, overscan);
|
|
1285
|
+
}
|
|
1286
|
+
/** Adjust the scroll offset so `key` is fully within the viewport. */
|
|
1287
|
+
#scrollItemIntoView(key) {
|
|
1288
|
+
const index = this.#source.indexOfKey(key);
|
|
1289
|
+
const vp = this.#viewportRef.value;
|
|
1290
|
+
if (index < 0 || !vp) return;
|
|
1291
|
+
const win = this.#currentWindow();
|
|
1292
|
+
if (win.horizontal) {
|
|
1293
|
+
const left = index * win.colStride;
|
|
1294
|
+
const right = left + this.itemSize;
|
|
1295
|
+
const viewLeft = vp.scrollLeft;
|
|
1296
|
+
let next = viewLeft;
|
|
1297
|
+
if (left < viewLeft) next = left;
|
|
1298
|
+
else if (right > viewLeft + this._viewportWidth) next = right - this._viewportWidth;
|
|
1299
|
+
if (next !== viewLeft) {
|
|
1300
|
+
vp.scrollLeft = next;
|
|
1301
|
+
this._scrollLeft = next;
|
|
1302
|
+
}
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
const top = (win.cols > 0 ? Math.floor(index / win.cols) : 0) * win.rowStride;
|
|
1306
|
+
const bottom = top + this.#rowHeight();
|
|
1307
|
+
const viewTop = vp.scrollTop;
|
|
1308
|
+
let next = viewTop;
|
|
1309
|
+
if (top < viewTop) next = top;
|
|
1310
|
+
else if (bottom > viewTop + this._viewportHeight) next = bottom - this._viewportHeight;
|
|
1311
|
+
if (next !== viewTop) {
|
|
1312
|
+
vp.scrollTop = next;
|
|
1313
|
+
this._scrollTop = next;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
_syncItemStates() {
|
|
1317
|
+
const selected = this.selection.selectedKeys;
|
|
1318
|
+
for (const el of this.#items) {
|
|
1319
|
+
const key = keyForElement(el);
|
|
1320
|
+
el.toggleAttribute(`data-tickled`, key !== void 0 && this.tickled.isTickled(key));
|
|
1321
|
+
el.toggleAttribute(`data-selected`, key !== void 0 && selected.has(key));
|
|
1322
|
+
}
|
|
1323
|
+
this.setAttribute(`data-input-mode`, this.tickled.inputMode);
|
|
1324
|
+
}
|
|
1325
|
+
#emitSelect(selected, previous) {
|
|
1326
|
+
const selectedEls = /* @__PURE__ */ new Set();
|
|
1327
|
+
const previousEls = /* @__PURE__ */ new Set();
|
|
1328
|
+
for (const key of selected) {
|
|
1329
|
+
const el = this.#source.resolveKeyToElement(key);
|
|
1330
|
+
if (el) selectedEls.add(el);
|
|
1331
|
+
}
|
|
1332
|
+
for (const key of previous) {
|
|
1333
|
+
const el = this.#source.resolveKeyToElement(key);
|
|
1334
|
+
if (el) previousEls.add(el);
|
|
1335
|
+
}
|
|
1336
|
+
this._dispatch(`list-select`, {
|
|
1337
|
+
selected: selectedEls,
|
|
1338
|
+
previous: previousEls,
|
|
1339
|
+
selectedKeys: this.selectedKeys,
|
|
1340
|
+
previousKeys: new Set([...previous].filter((k) => !isSyntheticKey(k)))
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
#emitItemEvent(name, key) {
|
|
1344
|
+
const index = this.#source.indexOfKey(key);
|
|
1345
|
+
const element = this.#source.resolveKeyToElement(key);
|
|
1346
|
+
const item = element ?? this.#source.resolveKeyToData(key);
|
|
1347
|
+
this._dispatch(name, {
|
|
1348
|
+
item,
|
|
1349
|
+
key,
|
|
1350
|
+
index,
|
|
1351
|
+
element
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
_dispatch(name, detail) {
|
|
1355
|
+
this.dispatchEvent(new CustomEvent(name, {
|
|
1356
|
+
detail,
|
|
1357
|
+
bubbles: true,
|
|
1358
|
+
composed: true
|
|
1359
|
+
}));
|
|
1360
|
+
}
|
|
1361
|
+
/** Selected keys, snapshotted once per render so the cell renderers don't each rebuild the set. */
|
|
1362
|
+
#selectedSnapshot;
|
|
1363
|
+
render() {
|
|
1364
|
+
const win = this.#currentWindow();
|
|
1365
|
+
this.#selectedSnapshot = this.selection.selectedKeys;
|
|
1366
|
+
const spacerStyle = win.horizontal ? `width:${win.totalWidth}px;height:100%` : `height:${win.totalHeight}px`;
|
|
1367
|
+
const scrollFade = win.horizontal ? `scroll-fade-x` : `scroll-fade-y`;
|
|
1368
|
+
return html`
|
|
1369
|
+
<div
|
|
1370
|
+
class="viewport ${scrollFade}"
|
|
1371
|
+
part="viewport"
|
|
1372
|
+
${ref(this.#viewportRef)}
|
|
1373
|
+
data-input-mode=${this.tickled.inputMode}
|
|
1374
|
+
@scroll=${this.#onScroll}
|
|
1375
|
+
>
|
|
1376
|
+
<div class="spacer" style=${spacerStyle}>
|
|
1377
|
+
${this.#source instanceof DataGridListSource ? this.#renderDataCells(win) : this.#renderElementCells(win)}
|
|
1378
|
+
</div>
|
|
1379
|
+
</div>
|
|
1380
|
+
${this.search?.renderField()}
|
|
1381
|
+
`;
|
|
1382
|
+
}
|
|
1383
|
+
#renderDataCells(win) {
|
|
1384
|
+
const slice = Array.from({ length: win.endIndex - win.startIndex }, (_, i) => win.startIndex + i);
|
|
1385
|
+
return repeat(slice, (index) => this.#source.keyAt(index), (index) => this.#renderDataCell(index, win));
|
|
1386
|
+
}
|
|
1387
|
+
#renderDataCell(index, win) {
|
|
1388
|
+
const key = this.#source.keyAt(index);
|
|
1389
|
+
const selected = this.#selectedSnapshot.has(key);
|
|
1390
|
+
const tickled = this.tickled.isTickled(key);
|
|
1391
|
+
const style = this.captionStyle;
|
|
1392
|
+
const separate = style === `separate`;
|
|
1393
|
+
const caption = style === `hidden` ? `` : this.#source.labelAt(index);
|
|
1394
|
+
const showCaption = caption !== ``;
|
|
1395
|
+
const cellHeight = win.rowStride - this.gap;
|
|
1396
|
+
const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;
|
|
1397
|
+
const y = win.horizontal ? Math.max(0, (this._viewportHeight - cellHeight) / 2) : rowOf(index, win.cols) * win.rowStride;
|
|
1398
|
+
const captionCss = separate ? `height:${Math.max(0, this.captionHeight - 4)}px` : style === `under` ? `height:${this.captionHeight}px` : ``;
|
|
1399
|
+
return html`
|
|
1400
|
+
<div
|
|
1401
|
+
class="cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}"
|
|
1402
|
+
part="item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}"
|
|
1403
|
+
role="option"
|
|
1404
|
+
aria-selected=${selected ? `true` : `false`}
|
|
1405
|
+
style="width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)"
|
|
1406
|
+
data-index=${index}
|
|
1407
|
+
data-key=${key}
|
|
1408
|
+
?data-selected=${selected}
|
|
1409
|
+
?data-tickled=${tickled}
|
|
1410
|
+
@click=${(e) => this.#onCellClick(e, key)}
|
|
1411
|
+
@dblclick=${() => this.#onCellActivate(key)}
|
|
1412
|
+
@pointerenter=${() => this.tickled.handlePointerEnter(key)}
|
|
1413
|
+
>
|
|
1414
|
+
<div class="content" part="content">${this.#source.renderCellContent(index)}</div>
|
|
1415
|
+
${showCaption ? html`<div class="caption" part="caption" style=${captionCss} title=${caption}>${caption}</div>` : ``}
|
|
1416
|
+
</div>
|
|
1417
|
+
`;
|
|
1418
|
+
}
|
|
1419
|
+
#renderElementCells(win) {
|
|
1420
|
+
const slice = this.#items.slice(win.startIndex, win.endIndex);
|
|
1421
|
+
return repeat(slice, (_el, i) => this.#source.keyAt(win.startIndex + i), (el, i) => this.#renderCell(el, win.startIndex + i, win));
|
|
1422
|
+
}
|
|
1423
|
+
#renderCell(el, index, win) {
|
|
1424
|
+
const key = this.#source.keyAt(index);
|
|
1425
|
+
const selected = this.#selectedSnapshot.has(key);
|
|
1426
|
+
const tickled = this.tickled.isTickled(key);
|
|
1427
|
+
const entering = this.#entering.has(el);
|
|
1428
|
+
const style = this.captionStyle;
|
|
1429
|
+
const separate = style === `separate`;
|
|
1430
|
+
const caption = style === `hidden` ? `` : this.#captionFor(el);
|
|
1431
|
+
const showCaption = caption !== ``;
|
|
1432
|
+
const cellHeight = win.rowStride - this.gap;
|
|
1433
|
+
const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;
|
|
1434
|
+
const y = win.horizontal ? Math.max(0, (this._viewportHeight - cellHeight) / 2) : rowOf(index, win.cols) * win.rowStride;
|
|
1435
|
+
const thumbStyle = separate ? `height:${this.itemSize}px` : ``;
|
|
1436
|
+
const captionCss = separate ? `height:${Math.max(0, this.captionHeight - 4)}px` : style === `under` ? `height:${this.captionHeight}px` : ``;
|
|
1437
|
+
return html`
|
|
1438
|
+
<div
|
|
1439
|
+
class="cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}${entering ? ` entering` : ``}"
|
|
1440
|
+
part="item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}"
|
|
1441
|
+
role="option"
|
|
1442
|
+
aria-selected=${selected ? `true` : `false`}
|
|
1443
|
+
style="width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)"
|
|
1444
|
+
data-index=${index}
|
|
1445
|
+
data-key=${key}
|
|
1446
|
+
?data-selected=${selected}
|
|
1447
|
+
?data-tickled=${tickled}
|
|
1448
|
+
@click=${(e) => this.#onCellClick(e, key)}
|
|
1449
|
+
@dblclick=${() => this.#onCellActivate(key)}
|
|
1450
|
+
@pointerenter=${() => this.tickled.handlePointerEnter(key)}
|
|
1451
|
+
>
|
|
1452
|
+
<div class="thumb" part="thumb" style=${thumbStyle}>
|
|
1453
|
+
${this.#source.renderCellContent(index)}
|
|
1454
|
+
</div>
|
|
1455
|
+
${showCaption ? html`<div class="caption" part="caption" style=${captionCss} title=${caption}>${caption}</div>` : ``}
|
|
1456
|
+
</div>
|
|
1457
|
+
`;
|
|
1458
|
+
}
|
|
1459
|
+
#onScroll;
|
|
1460
|
+
#cancelScrollRaf() {
|
|
1461
|
+
if (this.#scrollRaf !== 0) {
|
|
1462
|
+
cancelAnimationFrame(this.#scrollRaf);
|
|
1463
|
+
this.#scrollRaf = 0;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
#onCellClick(e, key) {
|
|
1467
|
+
this.selection.handleClick(key, e);
|
|
1468
|
+
this.#emitItemEvent(`list-item-click`, key);
|
|
1469
|
+
}
|
|
1470
|
+
#onCellActivate(key) {
|
|
1471
|
+
if (this.interactionMode !== `manual`) this.selection.replace(key);
|
|
1472
|
+
this.#emitItemEvent(`list-activate`, key);
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
__decorate([property({
|
|
1476
|
+
type: String,
|
|
1477
|
+
attribute: `selection-mode`
|
|
1478
|
+
})], GridListElement.prototype, "selectionMode", void 0);
|
|
1479
|
+
__decorate([property({
|
|
1480
|
+
type: String,
|
|
1481
|
+
attribute: `interaction-mode`
|
|
1482
|
+
})], GridListElement.prototype, "interactionMode", void 0);
|
|
1483
|
+
__decorate([property({
|
|
1484
|
+
type: Number,
|
|
1485
|
+
attribute: `item-size`
|
|
1486
|
+
})], GridListElement.prototype, "itemSize", void 0);
|
|
1487
|
+
__decorate([property({ type: Number })], GridListElement.prototype, "gap", void 0);
|
|
1488
|
+
__decorate([property({
|
|
1489
|
+
type: String,
|
|
1490
|
+
reflect: true
|
|
1491
|
+
})], GridListElement.prototype, "orientation", void 0);
|
|
1492
|
+
__decorate([property({
|
|
1493
|
+
type: String,
|
|
1494
|
+
attribute: `caption-style`,
|
|
1495
|
+
reflect: true
|
|
1496
|
+
})], GridListElement.prototype, "captionStyle", void 0);
|
|
1497
|
+
__decorate([property({
|
|
1498
|
+
type: String,
|
|
1499
|
+
attribute: `caption-align`,
|
|
1500
|
+
reflect: true
|
|
1501
|
+
})], GridListElement.prototype, "captionAlign", void 0);
|
|
1502
|
+
__decorate([property({
|
|
1503
|
+
type: String,
|
|
1504
|
+
attribute: `caption-position`,
|
|
1505
|
+
reflect: true
|
|
1506
|
+
})], GridListElement.prototype, "captionPosition", void 0);
|
|
1507
|
+
__decorate([property({
|
|
1508
|
+
type: String,
|
|
1509
|
+
attribute: `caption-backdrop`,
|
|
1510
|
+
reflect: true
|
|
1511
|
+
})], GridListElement.prototype, "captionBackdrop", void 0);
|
|
1512
|
+
__decorate([property({
|
|
1513
|
+
type: Number,
|
|
1514
|
+
attribute: `caption-height`
|
|
1515
|
+
})], GridListElement.prototype, "captionHeight", void 0);
|
|
1516
|
+
__decorate([property({
|
|
1517
|
+
type: String,
|
|
1518
|
+
attribute: `item-wrap`
|
|
1519
|
+
})], GridListElement.prototype, "itemWrap", void 0);
|
|
1520
|
+
__decorate([property({ attribute: false })], GridListElement.prototype, "filterPredicate", void 0);
|
|
1521
|
+
__decorate([property({ attribute: false })], GridListElement.prototype, "itemFilterPredicate", void 0);
|
|
1522
|
+
__decorate([property({
|
|
1523
|
+
type: String,
|
|
1524
|
+
attribute: `search-modes`,
|
|
1525
|
+
reflect: true
|
|
1526
|
+
})], GridListElement.prototype, "searchModes", void 0);
|
|
1527
|
+
__decorate([property({ attribute: false })], GridListElement.prototype, "items", void 0);
|
|
1528
|
+
__decorate([property({ attribute: false })], GridListElement.prototype, "itemAdapter", void 0);
|
|
1529
|
+
__decorate([state()], GridListElement.prototype, "_scrollTop", void 0);
|
|
1530
|
+
__decorate([state()], GridListElement.prototype, "_scrollLeft", void 0);
|
|
1531
|
+
__decorate([state()], GridListElement.prototype, "_viewportHeight", void 0);
|
|
1532
|
+
__decorate([state()], GridListElement.prototype, "_viewportWidth", void 0);
|
|
1533
|
+
GridListElement = __decorate([safeCustomElement(`ixfx-grid-list`)], GridListElement);
|
|
1534
|
+
//#endregion
|
|
1535
|
+
export { GridListElement as t };
|
|
1536
|
+
|
|
1537
|
+
//# sourceMappingURL=grid-list-nRUQOcEL.js.map
|