@ixfx/components 0.13.1 → 0.13.3

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.
Files changed (78) hide show
  1. package/bundle/index.d.ts +100 -14
  2. package/bundle/index.d.ts.map +1 -1
  3. package/bundle/index.js +2211 -636
  4. package/bundle/index.js.map +1 -1
  5. package/dist/ac-token.js +1 -1
  6. package/dist/{data-grid-Ck1Qx2H1.d.ts → data-grid-DHWJN66w.d.ts} +7 -5
  7. package/dist/{data-grid-Ck1Qx2H1.d.ts.map → data-grid-DHWJN66w.d.ts.map} +1 -1
  8. package/dist/data-grid.d.ts +1 -1
  9. package/dist/data-grid.js +210 -120
  10. package/dist/data-grid.js.map +1 -1
  11. package/dist/detail-list-C96B5Txz.js +2001 -0
  12. package/dist/detail-list-C96B5Txz.js.map +1 -0
  13. package/dist/{detail-list-C1xzr1z7.d.ts → detail-list-dX7jLO6b.d.ts} +12 -3
  14. package/dist/{detail-list-C1xzr1z7.d.ts.map → detail-list-dX7jLO6b.d.ts.map} +1 -1
  15. package/dist/detail-list.d.ts +2 -2
  16. package/dist/detail-list.js +1 -1680
  17. package/dist/{flat-list-DEDG6epz.d.ts → flat-list-Y98IqH00.d.ts} +5 -2
  18. package/dist/flat-list-Y98IqH00.d.ts.map +1 -0
  19. package/dist/flat-list.d.ts +1 -1
  20. package/dist/flat-list.js +33 -1
  21. package/dist/flat-list.js.map +1 -1
  22. package/dist/{grid-list-pefLORIr.d.ts → grid-list-CoT9e1jB.d.ts} +9 -2
  23. package/dist/{grid-list-pefLORIr.d.ts.map → grid-list-CoT9e1jB.d.ts.map} +1 -1
  24. package/dist/{grid-list-DjIl910A.js → grid-list-DeqAd9-h.js} +189 -40
  25. package/dist/grid-list-DeqAd9-h.js.map +1 -0
  26. package/dist/grid-list.d.ts +1 -1
  27. package/dist/grid-list.js +1 -1
  28. package/dist/{incr-search-D91M4Ozq.js → incr-search-JIhwB49y.js} +27 -5
  29. package/dist/incr-search-JIhwB49y.js.map +1 -0
  30. package/dist/incr-search.d.ts +1 -1
  31. package/dist/incr-search.js +1 -1
  32. package/dist/index-CnQPCywE.d.ts +325 -0
  33. package/dist/index-CnQPCywE.d.ts.map +1 -0
  34. package/dist/{index-CxZ61DO1.d.ts → index-Dlah7Zfi.d.ts} +8 -1
  35. package/dist/{index-CxZ61DO1.d.ts.map → index-Dlah7Zfi.d.ts.map} +1 -1
  36. package/dist/index.d.ts +9 -9
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +46 -25
  39. package/dist/index.js.map +1 -1
  40. package/dist/miller.d.ts +1 -1
  41. package/dist/miller.d.ts.map +1 -1
  42. package/dist/miller.js +146 -100
  43. package/dist/miller.js.map +1 -1
  44. package/dist/narrowed-text.js +1 -1
  45. package/dist/split-layout-C5SYbDrq.d.ts.map +1 -1
  46. package/dist/{split-layout-CXotkdbx.js → split-layout-Deoxy47d.js} +6 -1
  47. package/dist/{split-layout-CXotkdbx.js.map → split-layout-Deoxy47d.js.map} +1 -1
  48. package/dist/split-layout.js +1 -1
  49. package/dist/{tab-list-v8mKX7Fu.d.ts → tab-list-D_dmImJM.d.ts} +2 -3
  50. package/dist/tab-list-D_dmImJM.d.ts.map +1 -0
  51. package/dist/tabs.d.ts +1 -1
  52. package/dist/tabs.js +22 -0
  53. package/dist/tabs.js.map +1 -1
  54. package/dist/{tree-DGveys4K.js → tree-DD8OaqsK.js} +1010 -230
  55. package/dist/tree-DD8OaqsK.js.map +1 -0
  56. package/dist/tree.d.ts +4 -267
  57. package/dist/tree.js +1 -1
  58. package/dist/{vertical-list-CqBc-t8w.d.ts → vertical-list-lj_19DCx.d.ts} +3 -2
  59. package/dist/{vertical-list-CqBc-t8w.d.ts.map → vertical-list-lj_19DCx.d.ts.map} +1 -1
  60. package/dist/vertical-list.d.ts +1 -1
  61. package/dist/vertical-list.js +113 -24
  62. package/dist/vertical-list.js.map +1 -1
  63. package/docs-user/data-grid.md +74 -4
  64. package/docs-user/detail-list.md +65 -0
  65. package/docs-user/flat-list.md +14 -2
  66. package/docs-user/grid-list.md +81 -4
  67. package/docs-user/index.json +2 -2
  68. package/docs-user/miller.md +59 -3
  69. package/docs-user/tree.md +63 -2
  70. package/docs-user/vertical-list.md +9 -1
  71. package/package.json +6 -1
  72. package/dist/detail-list.js.map +0 -1
  73. package/dist/flat-list-DEDG6epz.d.ts.map +0 -1
  74. package/dist/grid-list-DjIl910A.js.map +0 -1
  75. package/dist/incr-search-D91M4Ozq.js.map +0 -1
  76. package/dist/tab-list-v8mKX7Fu.d.ts.map +0 -1
  77. package/dist/tree-DGveys4K.js.map +0 -1
  78. package/dist/tree.d.ts.map +0 -1
@@ -1,1682 +1,3 @@
1
- import { t as TickledController } from "./tickled-controller-D-HZymaZ.js";
2
- import { t as themeFallbacks } from "./fallbacks-DQ_5OsmR.js";
3
- import { n as safeCustomElement, t as __decorate } from "./decorate-VRK8rslU.js";
4
- import "./icon-1gpwtPx8.js";
5
- import { t as DataController } from "./data-controller-DOlmqNKb.js";
6
- import { c as createElementListSearchAdapter, i as ListSearchController, n as listSearchStyles, o as registerListSearchCommands, r as LIST_SEARCH_MODES, u as keyForElement } from "./incr-search-D91M4Ozq.js";
7
- import { a as toGroupKey, r as partitionByGroup } from "./grouping-RYPnHkrS.js";
8
- import { t as ListNativeDragController } from "./list-native-drag-controller-B9xO0XWn.js";
9
- import { r as ListDragSelectController, t as ListSelectionController } from "./list-selection-controller-BeE70lbB.js";
10
- import { n as animateListItemIn, r as animateListItemOut } from "./list-item-animation-BUoEKi5s.js";
11
- import { t as scrollFadeStyles } from "./scroll-fade-BrNUIYnm.js";
12
- import { n as appearanceColor, t as appearanceAbsent } from "./item-appearance-BjcMyauw.js";
1
+ import { t as DetailListElement } from "./detail-list-C96B5Txz.js";
13
2
  import "./list-group-header.js";
14
- import { LitElement, css, html, nothing, render } from "lit";
15
- import { property, query, state } from "lit/decorators.js";
16
- import { createCommandRegistry } from "@clinth/ui-commands";
17
- //#region src/detail-list/detail-list.ts
18
- const ITEM_SELECTOR = `:scope > li`;
19
- const GROUP_HEADER_ATTR = `data-ixfx-group-header`;
20
- const GROUP_COLLAPSED_ATTR = `data-group-collapsed`;
21
- const SEARCH_HIGHLIGHT_KEY = `detail-list-search`;
22
- const NAV_KEYS = /* @__PURE__ */ new Set([
23
- `ArrowDown`,
24
- `ArrowUp`,
25
- `ArrowLeft`,
26
- `ArrowRight`,
27
- `Home`,
28
- `End`
29
- ]);
30
- const LABEL_SPAN_CSS = `overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0`;
31
- /**
32
- * Layout for the per-item badge wrapper `#ensureBadge` adds. Applied as inline
33
- * `cssText` rather than shadow CSS because `::slotted()` only matches the
34
- * host's *direct* children — the badge lives inside a slotted `<li>`, so a
35
- * `::slotted()` rule could never reach it. The values still read the CSS
36
- * custom property, so it stays themeable from the outside.
37
- */
38
- const BADGE_EL_CSS = `flex-shrink:0;display:inline-flex;align-items:center;margin-inline-start:auto;padding-inline-start:var(--detail-list-badge-gap,8px)`;
39
- function pointInRect(x, y, rect) {
40
- return rect.width > 0 && rect.height > 0 && x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom;
41
- }
42
- /** Hit-test the painted content, not a layout wrapper that may fill the row. */
43
- function contentAtPoint(node, x, y) {
44
- if (node instanceof Text) {
45
- if (!node.textContent?.trim()) return false;
46
- const range = document.createRange();
47
- range.selectNodeContents(node);
48
- return Array.from(range.getClientRects()).some((rect) => pointInRect(x, y, rect));
49
- }
50
- if (!(node instanceof Element)) return false;
51
- if (node.hasAttribute(`data-drag-select-blank`)) return false;
52
- if (node.hasAttribute(`data-drag-select-content`)) return pointInRect(x, y, node.getBoundingClientRect());
53
- if (Array.from(node.childNodes).some((child) => contentAtPoint(child, x, y))) return true;
54
- return node.childNodes.length === 0 && pointInRect(x, y, node.getBoundingClientRect());
55
- }
56
- /** Shallow key-array equality, treating `undefined` (never dispatched) as different. */
57
- function sameKeys(a, b) {
58
- if (a === void 0 || a.length !== b.length) return false;
59
- for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
60
- return true;
61
- }
62
- let DetailListElement = class DetailListElement extends LitElement {
63
- constructor(..._args) {
64
- super(..._args);
65
- this.selectionMode = `single`;
66
- this.interactionMode = `standard`;
67
- this.sort = `none`;
68
- this.sortBy = ``;
69
- this.items = [];
70
- this.displayProperty = ``;
71
- this.iconProperty = ``;
72
- this.iconColorProperty = ``;
73
- this.textColorProperty = ``;
74
- this.badgeProperty = ``;
75
- this.keyProperty = ``;
76
- this.itemWrap = `stop`;
77
- this.itemsDraggable = false;
78
- this.groupBy = null;
79
- this.crossGroupSelection = false;
80
- this._collapsedGroups = /* @__PURE__ */ new Set();
81
- this.#itemData = /* @__PURE__ */ new WeakMap();
82
- this.#grid = [];
83
- this.#positions = /* @__PURE__ */ new Map();
84
- this.#tops = /* @__PURE__ */ new Map();
85
- this.#geometryScheduled = false;
86
- this.#sortRaf = 0;
87
- this.#viewportScrollRaf = 0;
88
- this.#animatedItems = /* @__PURE__ */ new WeakSet();
89
- this.#builtFromProvider = [];
90
- this.#groupIndex = /* @__PURE__ */ new Map();
91
- this.#groupList = [];
92
- this.#headerEls = /* @__PURE__ */ new Map();
93
- this.#seq = /* @__PURE__ */ new WeakMap();
94
- this.#seqNext = 0;
95
- this.#wasGrouped = false;
96
- this.#groupsScheduled = false;
97
- this.#groupByChanged = false;
98
- this.#providerBuilt = 0;
99
- this.#data = new DataController(this);
100
- this.selection = new ListSelectionController({
101
- getOrderedItems: () => this._getVisibleItems(),
102
- isSelectable: (el) => this._isCheckable(el),
103
- getModes: () => ({
104
- selectionMode: this.selectionMode,
105
- interactionMode: this.interactionMode
106
- }),
107
- getKey: keyForElement,
108
- getGroupKey: (el) => this.#groupIndex.get(el) ?? null,
109
- crossGroupSelection: () => this.crossGroupSelection,
110
- getFallbackGroupKey: () => {
111
- const t = this.tickled.tickledId;
112
- return t ? this.#groupIndex.get(t) ?? null : null;
113
- },
114
- onChange: (selected, previous) => {
115
- this._syncItemStates();
116
- this._dispatch(`list-select`, {
117
- selected,
118
- previous,
119
- selectedKeys: this.selection.selectedKeys
120
- });
121
- }
122
- });
123
- this.tickled = new TickledController(this, {
124
- getItems: () => this._getVisibleItems().map((el) => ({
125
- id: el,
126
- enabled: !el.hasAttribute(`not-checked`)
127
- })),
128
- onTickle: (id) => {
129
- if (id !== void 0) this._dispatch(`list-tickle`, { item: id });
130
- },
131
- onStateChange: () => this._syncItemStates(),
132
- itemWrap: this.itemWrap,
133
- hoverDisabled: () => this.#dragSelect.isDragging || this.#nativeDrag.isDragging
134
- });
135
- this.#nativeDragging = false;
136
- this.#postDragSuppressTimer = 0;
137
- this.#blankItemPressPending = false;
138
- this.#clearBlankItemPress = () => {
139
- this.#blankItemPressPending = false;
140
- };
141
- this.#nativeDrag = new ListNativeDragController(this, {
142
- source: `detail-list`,
143
- isEnabled: () => this.itemsDraggable && this.selectionMode !== `none` && this._getVisibleItems().length > 0,
144
- resolveEventToKey: (target) => {
145
- if (!(target instanceof Element)) return void 0;
146
- const li = target.closest?.(`li`);
147
- if (!li || !this.contains(li)) return void 0;
148
- return keyForElement(li);
149
- },
150
- prepareSelection: (originKey) => this.#prepareNativeDrag(originKey),
151
- getMetrics: () => ({}),
152
- getRenderer: () => this.dragPreviewRenderer,
153
- getDragPreviewSourceResolver: () => this.dragPreviewSource,
154
- dispatch: (detail) => this._dispatchCancelable(`list-native-drag-start`, detail),
155
- onActiveChange: (active, originKey) => {
156
- this.#nativeDragging = active;
157
- this.toggleAttribute(`data-native-dragging`, active);
158
- for (const el of this.querySelectorAll(`li`)) el.toggleAttribute(`data-drag-origin`, active && originKey !== void 0 && keyForElement(el) === originKey);
159
- if (active) {
160
- const count = this.selection.selected.size;
161
- this.setAttribute(`aria-label`, count <= 1 ? `Dragging 1 item` : `Dragging ${count} items`);
162
- } else this.removeAttribute(`aria-label`);
163
- this.requestUpdate();
164
- },
165
- onEnd: () => {
166
- this.#nativeDragging = false;
167
- this.toggleAttribute(`data-native-dragging`, false);
168
- this.removeAttribute(`aria-label`);
169
- for (const el of this.querySelectorAll(`li`)) el.removeAttribute(`data-drag-origin`);
170
- this.#startPostDragSuppressTimer();
171
- },
172
- syncLightDomDraggable: () => this._syncNativeDraggable(),
173
- shouldStart: () => !this.#blankItemPressPending
174
- });
175
- this.#dragSelect = new ListDragSelectController(this, {
176
- getSurface: () => this.renderRoot.querySelector(`.container`),
177
- isEnabled: () => this.selection.canDragSelect() && this._getVisibleItems().length > 0 && !this.hasAttribute(`disable-drag-select`),
178
- hitTest: (rect) => this.#marqueeHitTest(rect),
179
- getBaseSelection: () => this.selection.selected,
180
- onPreview: (preview, rect) => {
181
- this.#marqueeRect = rect;
182
- for (const el of this._getVisibleItems()) el.toggleAttribute(`data-marquee`, preview.has(el));
183
- this.requestUpdate();
184
- },
185
- onCommit: (finalSet) => {
186
- this.selection.applyDragSelection(finalSet);
187
- for (const el of this._getVisibleItems()) el.removeAttribute(`data-marquee`);
188
- this.#marqueeRect = void 0;
189
- this.requestUpdate();
190
- },
191
- autoScroll: (dx, _dy) => {
192
- if (this._listEl) this._listEl.scrollLeft += dx;
193
- },
194
- shouldStart: (event) => {
195
- if (this.#findGroupHeader(event.composedPath())) return false;
196
- this.#blankItemPressPending = this.itemsDraggable && this.#isBlankItemPress(event);
197
- return !this.itemsDraggable || this.#blankItemPressPending;
198
- }
199
- });
200
- this.search = new ListSearchController(this, { adapter: createElementListSearchAdapter(this, {
201
- itemSelector: ITEM_SELECTOR,
202
- getLabel: (el) => el.getAttribute(`data-search-label`) ?? el.textContent?.trim() ?? ``,
203
- highlightKey: SEARCH_HIGHLIGHT_KEY
204
- }) });
205
- this.#onListScroll = () => {
206
- if (this.#viewportScrollRaf !== 0) return;
207
- this.#viewportScrollRaf = requestAnimationFrame(() => {
208
- this.#viewportScrollRaf = 0;
209
- this.#emitViewportChangeIfChanged();
210
- });
211
- };
212
- this._onPointerOver = (e) => {
213
- const item = this._findListItem(e.composedPath());
214
- if (item) this.tickled.handlePointerEnter(item);
215
- };
216
- this._onPointerLeave = (e) => {
217
- this.tickled.handlePointerLeave(e);
218
- };
219
- this._endKeyboardNav = () => {
220
- this.removeAttribute(`data-keyboard-nav`);
221
- };
222
- this._onKeyDown = (e) => {
223
- if (this.search.isOpen) return;
224
- if ((e.ctrlKey || e.metaKey) && e.key === `a`) {
225
- if (this.selection.canSelectAll()) {
226
- e.preventDefault();
227
- this.selection.selectAll();
228
- }
229
- return;
230
- }
231
- if (NAV_KEYS.has(e.key)) this.setAttribute(`data-keyboard-nav`, ``);
232
- switch (e.key) {
233
- case `ArrowDown`:
234
- e.preventDefault();
235
- this.#navigateDown();
236
- if (e.shiftKey && this.interactionMode === `vscode`) {
237
- const cur = this.tickled.tickledId;
238
- if (cur) this.selection.rangeTo(cur);
239
- }
240
- break;
241
- case `ArrowUp`:
242
- e.preventDefault();
243
- this.#navigateUp();
244
- if (e.shiftKey && this.interactionMode === `vscode`) {
245
- const cur = this.tickled.tickledId;
246
- if (cur) this.selection.rangeTo(cur);
247
- }
248
- break;
249
- case `ArrowRight`:
250
- e.preventDefault();
251
- this.#navigateRight();
252
- break;
253
- case `ArrowLeft`:
254
- e.preventDefault();
255
- this.#navigateLeft();
256
- break;
257
- case `Home`:
258
- e.preventDefault();
259
- this.#navigateTo(this.#findFirstCheckable());
260
- break;
261
- case `End`:
262
- e.preventDefault();
263
- this.#navigateTo(this.#findLastCheckable());
264
- break;
265
- case `Enter`: {
266
- const id = this.tickled.tickledId;
267
- if (id) {
268
- e.preventDefault();
269
- this._dispatch(`list-item-click`, { item: id });
270
- this._activateItem(id);
271
- }
272
- break;
273
- }
274
- case ` `: {
275
- const id = this.tickled.tickledId;
276
- if (id) {
277
- e.preventDefault();
278
- this.selection.handleSpace(id);
279
- }
280
- break;
281
- }
282
- case `Escape`: this.selection.clear();
283
- }
284
- };
285
- this._onClick = (e) => {
286
- if (this.#dragSelect.isDragging || this.#nativeDrag.isDragging || this.#postDragSuppressTimer !== 0) return;
287
- const path = e.composedPath();
288
- const header = this.#findGroupHeader(path);
289
- if (header) {
290
- this.toggleGroup(header.dataset.groupKey ?? ``);
291
- return;
292
- }
293
- const item = this._findListItem(path);
294
- if (!item) return;
295
- this.focus();
296
- this._dispatch(`list-item-click`, { item });
297
- this.selection.handleClick(item, e);
298
- };
299
- this._onDblClick = (e) => {
300
- const item = this._findListItem(e.composedPath());
301
- if (item) this._activateItem(item);
302
- };
303
- this._onWheel = (e) => {
304
- e.preventDefault();
305
- const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
306
- this._listEl.scrollLeft += delta;
307
- };
308
- }
309
- #itemData;
310
- #grid;
311
- #positions;
312
- /** Viewport-relative `top` per item at the last geometry pass — lines rows up across columns. */
313
- #tops;
314
- #geometryScheduled;
315
- #sortRaf;
316
- #viewportScrollRaf;
317
- /** Key sets as of the last viewport-change dispatch, for dedupe. */
318
- #lastViewportRenderedKeys;
319
- #lastViewportVisibleKeys;
320
- #resizeObserver;
321
- #mutationObserver;
322
- /** Items that have already played (or been skipped for) their enter animation. */
323
- #animatedItems;
324
- #builtFromProvider;
325
- /** Element → group key, for the selection controller. Empty while ungrouped. */
326
- #groupIndex;
327
- #groupList;
328
- #headerEls;
329
- /** Insertion sequence per item, so regrouping starts from the original order. */
330
- #seq;
331
- #seqNext;
332
- #wasGrouped;
333
- #groupsScheduled;
334
- #groupByChanged;
335
- #groupObserver;
336
- #providerBuilt;
337
- #data;
338
- #nativeDragging;
339
- #postDragSuppressTimer;
340
- #blankItemPressPending;
341
- #clearBlankItemPress;
342
- #nativeDrag;
343
- #prepareNativeDrag(originKey) {
344
- const visible = this._getVisibleItems();
345
- const originEl = visible.find((el) => keyForElement(el) === originKey);
346
- if (!originEl || !this._isCheckable(originEl)) return void 0;
347
- if (!this.selection.selected.has(originEl)) this.selection.replace(originEl);
348
- const selected = [];
349
- visible.forEach((el, index) => {
350
- if (!this.selection.selected.has(el)) return;
351
- const key = keyForElement(el) ?? originKey;
352
- selected.push({
353
- key,
354
- index,
355
- item: this.#itemData.get(el) ?? el,
356
- element: el
357
- });
358
- });
359
- const origin = selected.find((entry) => entry.key === originKey);
360
- if (!origin) return void 0;
361
- return {
362
- origin,
363
- selected
364
- };
365
- }
366
- _syncNativeDraggable() {
367
- if (!this.isConnected) return;
368
- for (const el of this.querySelectorAll(`li`)) if (el instanceof HTMLElement) el.draggable = this.itemsDraggable && this._isCheckable(el);
369
- }
370
- #startPostDragSuppressTimer() {
371
- if (this.#postDragSuppressTimer) clearTimeout(this.#postDragSuppressTimer);
372
- this.#postDragSuppressTimer = window.setTimeout(() => {
373
- this.#postDragSuppressTimer = 0;
374
- }, 0);
375
- }
376
- /** Live drag-select preview rect (surface-relative); the covered items carry `data-marquee`. */
377
- #marqueeRect;
378
- #dragSelect;
379
- /** A row's padding/empty area may start marquee; its actual content may drag out. */
380
- #isBlankItemPress(event) {
381
- const path = event.composedPath();
382
- const item = this._findListItem(path);
383
- if (!item) return false;
384
- for (const node of path) {
385
- if (node === item) break;
386
- if (node instanceof Element) {
387
- if (node.matches(`input, button, a, select, textarea, [contenteditable], .ixfx-list-checkbox, [role="checkbox"]`)) return false;
388
- if (node.hasAttribute(`data-drag-select-blank`)) return true;
389
- if (node.hasAttribute(`data-drag-select-content`)) return false;
390
- }
391
- }
392
- return !Array.from(item.childNodes).some((node) => contentAtPoint(node, event.clientX, event.clientY));
393
- }
394
- /** Collect visible items whose surface-relative box intersects `rect`. */
395
- #marqueeHitTest(rect) {
396
- const surface = this.renderRoot.querySelector(`.container`);
397
- if (!surface) return [];
398
- const box = surface.getBoundingClientRect();
399
- const rx0 = rect.x;
400
- const ry0 = rect.y;
401
- const rx1 = rect.x + rect.width;
402
- const ry1 = rect.y + rect.height;
403
- const out = [];
404
- for (const el of this._getVisibleItems()) {
405
- const r = el.getBoundingClientRect();
406
- const left = r.left - box.left;
407
- const top = r.top - box.top;
408
- if (left <= rx1 && left + r.width >= rx0 && top <= ry1 && top + r.height >= ry0) out.push(el);
409
- }
410
- return out;
411
- }
412
- #marqueeStyle(rect) {
413
- return `left:${rect.x}px;top:${rect.y}px;width:${Math.max(0, rect.width)}px;height:${Math.max(0, rect.height)}px`;
414
- }
415
- #searchRegistry;
416
- #unregisterSearchCommands;
417
- /** Command registry carrying this list's `list.search.*` commands. */
418
- get registry() {
419
- return this.#searchRegistry;
420
- }
421
- #effectiveSearchModes() {
422
- const raw = this.searchModes?.trim();
423
- if (raw === void 0) return [...LIST_SEARCH_MODES];
424
- const requested = new Set(raw.split(/\s+/));
425
- return LIST_SEARCH_MODES.filter((m) => requested.has(m));
426
- }
427
- #syncSearchCommands() {
428
- if (!this.#searchRegistry) return;
429
- this.search.setModes(this.#effectiveSearchModes());
430
- this.#unregisterSearchCommands?.();
431
- this.#unregisterSearchCommands = registerListSearchCommands(this.#searchRegistry, this.search);
432
- }
433
- connectedCallback() {
434
- super.connectedCallback();
435
- if (!this.hasAttribute(`tabindex`)) this.tabIndex = 0;
436
- this.addEventListener(`pointerover`, this._onPointerOver);
437
- this.addEventListener(`pointerleave`, this._onPointerLeave);
438
- this.addEventListener(`keydown`, this._onKeyDown);
439
- this.addEventListener(`pointermove`, this._endKeyboardNav);
440
- this.addEventListener(`pointerdown`, this._endKeyboardNav);
441
- this.addEventListener(`click`, this._onClick);
442
- this.addEventListener(`dblclick`, this._onDblClick);
443
- this.addEventListener(`wheel`, this._onWheel);
444
- window.addEventListener(`pointerup`, this.#clearBlankItemPress);
445
- window.addEventListener(`pointercancel`, this.#clearBlankItemPress);
446
- this.#resizeObserver = new ResizeObserver(() => this.#scheduleGeometry());
447
- this.#resizeObserver.observe(this);
448
- this.#mutationObserver = new MutationObserver((records) => {
449
- this.#processChildren();
450
- this.#animateChildMutations(records);
451
- this.#scheduleGeometry();
452
- this.#scheduleGroups();
453
- });
454
- this.#mutationObserver.observe(this, {
455
- childList: true,
456
- subtree: false,
457
- attributeFilter: [`hidden`]
458
- });
459
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) this.#animatedItems.add(el);
460
- this.#searchRegistry ??= createCommandRegistry();
461
- this.#syncSearchCommands();
462
- this.#scheduleGroups();
463
- }
464
- /**
465
- * Collapse-in items appended to the light DOM (however they got there). A bulk
466
- * populate is left alone. Geometry is re-read once the animations settle so
467
- * keyboard navigation lines back up with the final layout.
468
- */
469
- #animateChildMutations(records) {
470
- if (!this.isConnected) return;
471
- const fresh = [];
472
- for (const record of records) for (const node of record.addedNodes) {
473
- if (!(node instanceof HTMLElement) || node.parentElement !== this || node.localName !== `li`) continue;
474
- if (this.#animatedItems.has(node)) continue;
475
- this.#animatedItems.add(node);
476
- fresh.push(node);
477
- }
478
- if (fresh.length === 0) return;
479
- const total = this.querySelectorAll(ITEM_SELECTOR).length;
480
- if (fresh.length >= total) return;
481
- for (const el of fresh) animateListItemIn(el);
482
- window.setTimeout(() => this.#scheduleGeometry(), 230);
483
- }
484
- disconnectedCallback() {
485
- super.disconnectedCallback();
486
- this.removeEventListener(`pointerover`, this._onPointerOver);
487
- this.removeEventListener(`pointerleave`, this._onPointerLeave);
488
- this.removeEventListener(`keydown`, this._onKeyDown);
489
- this.removeEventListener(`pointermove`, this._endKeyboardNav);
490
- this.removeEventListener(`pointerdown`, this._endKeyboardNav);
491
- this.removeEventListener(`click`, this._onClick);
492
- this.removeEventListener(`dblclick`, this._onDblClick);
493
- this.removeEventListener(`wheel`, this._onWheel);
494
- window.removeEventListener(`pointerup`, this.#clearBlankItemPress);
495
- window.removeEventListener(`pointercancel`, this.#clearBlankItemPress);
496
- this.#blankItemPressPending = false;
497
- cancelAnimationFrame(this.#sortRaf);
498
- cancelAnimationFrame(this.#viewportScrollRaf);
499
- this.#viewportScrollRaf = 0;
500
- this.#resizeObserver?.disconnect();
501
- this.#resizeObserver = void 0;
502
- this.#mutationObserver?.disconnect();
503
- this.#mutationObserver = void 0;
504
- this.#groupObserver?.disconnect();
505
- this.#groupObserver = void 0;
506
- this.#unregisterSearchCommands?.();
507
- this.#unregisterSearchCommands = void 0;
508
- this.#searchRegistry = void 0;
509
- if (this.#postDragSuppressTimer) {
510
- clearTimeout(this.#postDragSuppressTimer);
511
- this.#postDragSuppressTimer = 0;
512
- }
513
- }
514
- firstUpdated() {
515
- this.#processChildren();
516
- if (this.filterPredicate) this.#applyFilterPredicate();
517
- this.#recomputeGeometry();
518
- this._syncNativeDraggable();
519
- }
520
- willUpdate(changed) {
521
- super.willUpdate(changed);
522
- if (changed.has(`groupBy`) && this.hasUpdated) {
523
- if (this._collapsedGroups.size > 0) this._collapsedGroups = /* @__PURE__ */ new Set();
524
- this.#groupByChanged = true;
525
- }
526
- }
527
- updated(changed) {
528
- super.updated(changed);
529
- if (changed.has(`groupBy`) || changed.has(`groupLabel`) || changed.has(`_collapsedGroups`)) {
530
- this.#scheduleGroups();
531
- if (this.#groupByChanged) {
532
- this.#groupByChanged = false;
533
- this._dispatch(`list-group-change`, { groupBy: this.groupBy });
534
- }
535
- }
536
- if (changed.has(`searchModes`)) this.#syncSearchCommands();
537
- if (changed.has(`provider`)) {
538
- this.#builtFromProvider = [];
539
- this.#providerBuilt = 0;
540
- this.#data.provider = this.provider;
541
- queueMicrotask(() => {
542
- if (this.provider) this.#data.request(void 0);
543
- });
544
- return;
545
- }
546
- if ((changed.has(`items`) || changed.has(`displayProperty`) || changed.has(`formatter`) || changed.has(`iconProperty`) || changed.has(`iconColorProperty`) || changed.has(`textColorProperty`) || changed.has(`badgeProperty`) || changed.has(`keyProperty`)) && this.provider === void 0 && this.items.length > 0) this.#rebuildFromObjects(this.items);
547
- this.#syncFromProvider();
548
- if (changed.has(`sort`) || changed.has(`sortBy`) || changed.has(`sortComparator`)) this.#applySort();
549
- if (changed.has(`filterPredicate`)) {
550
- this.#applyFilterPredicate();
551
- this.#scheduleGeometry();
552
- this.#scheduleGroups();
553
- }
554
- if (changed.has(`interactionMode`)) {
555
- this.selection.clearAnchor();
556
- this._syncItemStates();
557
- this._syncNativeDraggable();
558
- } else if (changed.has(`checkboxRenderer`) && this.interactionMode === `checked`) this._syncCheckboxes();
559
- if (changed.has(`itemsDraggable`)) {
560
- this._syncNativeDraggable();
561
- this.#nativeDrag.refreshDraggable();
562
- }
563
- }
564
- /** The most recently selected item, or `undefined` if nothing is selected. */
565
- get selectedItem() {
566
- return [...this.selection.selected].at(-1);
567
- }
568
- /** The full current selection set (read-only). */
569
- get selectedItems() {
570
- return this.selection.selected;
571
- }
572
- /**
573
- * Force an immediate geometry recompute. Called automatically on resize,
574
- * DOM changes, sort/filter/search changes — only needed when layout is
575
- * changed by outside forces (e.g. an external font load).
576
- */
577
- refreshLayout() {
578
- this.#recomputeGeometry();
579
- }
580
- addItem(item, options) {
581
- let el;
582
- if (typeof item === `string`) {
583
- const li = document.createElement(`li`);
584
- this._setLabel(li, item);
585
- el = li;
586
- } else el = item;
587
- if (options?.notChecked) el.setAttribute(`not-checked`, ``);
588
- this.appendChild(el);
589
- this.#ensureIcon(el);
590
- if (this.sort !== `none`) this.#applySort();
591
- if (this.interactionMode === `checked`) this._syncCheckboxes();
592
- this.#scheduleGroups();
593
- }
594
- /**
595
- * Collapse + fade `item` out, then detach it; the rows after it slide up to
596
- * close the gap. Resolves once removed. Immediate under reduced motion.
597
- */
598
- removeItem(item) {
599
- this.selection.deselect(item);
600
- return animateListItemOut(item).then(() => {
601
- item.remove();
602
- this.#scheduleGroups();
603
- if (this.interactionMode === `checked`) this._syncCheckboxes();
604
- this.#recomputeGeometry();
605
- });
606
- }
607
- /** {@link removeItem} for several items at once. */
608
- removeItems(items) {
609
- return Promise.all([...items].map((item) => this.removeItem(item))).then(() => void 0);
610
- }
611
- clearItems() {
612
- this.replaceChildren();
613
- this.#headerEls.clear();
614
- this.#scheduleGroups();
615
- this.selection.reset();
616
- this.#builtFromProvider = [];
617
- this.#providerBuilt = 0;
618
- this._syncItemStates();
619
- }
620
- /**
621
- * Replace the entire item list in one call.
622
- * Equivalent to `clearItems()` followed by `addItem()` for each element.
623
- */
624
- setItems(items) {
625
- this.clearItems();
626
- for (const item of items) {
627
- this.appendChild(item);
628
- this.#ensureIcon(item);
629
- }
630
- if (this.sort !== `none`) this.#applySort();
631
- if (this.interactionMode === `checked`) this._syncCheckboxes();
632
- this.#scheduleGroups();
633
- }
634
- /**
635
- * Get the source object behind an `<li>` built from an `items` array or
636
- * provider. Returns `undefined` for declarative / programmatic elements.
637
- */
638
- getItemData(item) {
639
- return this.#itemData.get(item);
640
- }
641
- /**
642
- * Keys of items currently intersecting the viewport — for prioritising
643
- * viewport-first work (e.g. metadata/thumbnail fetches). Items are laid
644
- * out as a fixed-height, horizontally-scrolling column grid, so this is a
645
- * horizontal intersection test against the scroll container; every row of
646
- * an intersecting column counts as visible. Hidden (filtered-out) and
647
- * keyless items are omitted. Mirrors `ixfx-grid-list.visibleKeys()` /
648
- * `ixfx-data-grid.getVisibleRange()`.
649
- */
650
- visibleKeys() {
651
- const container = this._listEl;
652
- if (!container) return [];
653
- const box = container.getBoundingClientRect();
654
- const out = [];
655
- for (const el of this._getVisibleItems()) {
656
- const key = keyForElement(el);
657
- if (key === void 0) continue;
658
- const r = el.getBoundingClientRect();
659
- if (r.right > box.left && r.left < box.right) out.push(key);
660
- }
661
- return out;
662
- }
663
- /**
664
- * Dispatch a command to this list — used by `ixfx-grouped-item-lister` to
665
- * forward commands. Routes through the command registry (so `list.search.*`
666
- * and any other registered commands work).
667
- */
668
- dispatch(commandId, args) {
669
- this.#searchRegistry?.invoke(commandId, args);
670
- }
671
- select(item) {
672
- this.selection.replace(item);
673
- }
674
- selectMany(items) {
675
- this.selection.selectMany(items);
676
- }
677
- deselect(item) {
678
- this.selection.deselect(item);
679
- }
680
- clearSelection() {
681
- this.selection.clear();
682
- }
683
- selectAll() {
684
- if (this.selection.canSelectAll()) this.selection.selectAll();
685
- }
686
- /** The selection as stable `data-key` / `data-value` strings. */
687
- get selectedKeys() {
688
- return this.selection.selectedKeys;
689
- }
690
- /** The key of the item under the cursor, or `undefined`. */
691
- get tickledKey() {
692
- const id = this.tickled.tickledId;
693
- return id ? keyForElement(id) : void 0;
694
- }
695
- /** Replace the selection with the items carrying these keys (unknown keys ignored). */
696
- selectKeys(keys) {
697
- this.selection.selectKeys(keys, (key) => this.#itemForKey(key));
698
- }
699
- /** Add items by key to the selection (multi-select modes only). */
700
- addSelectedKeys(keys) {
701
- this.selection.addKeys(keys, (key) => this.#itemForKey(key));
702
- }
703
- /** Remove items by key from the selection. */
704
- removeSelectedKeys(keys) {
705
- this.selection.removeKeys(keys, (key) => this.#itemForKey(key));
706
- }
707
- /** Move the cursor to the item with this key and scroll it into view. */
708
- focusKey(key) {
709
- const el = this.#itemForKey(key);
710
- if (!el) return;
711
- this.tickled.focus(el);
712
- el.scrollIntoView({
713
- block: `nearest`,
714
- inline: `nearest`
715
- });
716
- }
717
- #itemForKey(key) {
718
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) if (keyForElement(el) === key) return el;
719
- }
720
- *selectedFilter(kind) {
721
- const wanted = (el) => {
722
- switch (kind) {
723
- case `selected`: return el.hasAttribute(`data-selected`);
724
- case `checked`: return el.hasAttribute(`data-checked`);
725
- case `either`: return el.hasAttribute(`data-selected`) || el.hasAttribute(`data-checked`);
726
- }
727
- };
728
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) {
729
- if (el.hidden) continue;
730
- if (wanted(el)) yield el;
731
- }
732
- }
733
- #rebuildFromObjects(items) {
734
- const keyOf = (el) => el.getAttribute(`data-key`) ?? el.getAttribute(`data-search-label`) ?? null;
735
- const previousKeys = new Set([...this.selection.selected].map(keyOf).filter((k) => k !== null));
736
- const anchorKey = this.selection.anchor ? keyOf(this.selection.anchor) : null;
737
- this.replaceChildren(...items.map((item, index) => this.#createItemEl(item, index)));
738
- if (previousKeys.size > 0 || anchorKey !== null) {
739
- const next = [];
740
- let anchor;
741
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) {
742
- const key = keyOf(el);
743
- if (key !== null && previousKeys.has(key)) next.push(el);
744
- if (key !== null && key === anchorKey) anchor = el;
745
- }
746
- this.selection.seed(next, anchor);
747
- }
748
- if (this.sort !== `none`) this.#applySort();
749
- if (this.interactionMode === `checked`) this._syncCheckboxes();
750
- this._syncItemStates();
751
- this.#scheduleGeometry();
752
- this.#scheduleGroups();
753
- }
754
- #createItemEl(item, index) {
755
- const li = document.createElement(`li`);
756
- this.#itemData.set(li, item);
757
- const content = this.formatter ? this.formatter(item, index) : this.displayProperty ? this.#propertyValue(item, this.displayProperty) : item;
758
- const textColor = this.#colorValue(item, this.textColorProperty);
759
- const iconColor = this.#colorValue(item, this.iconColorProperty);
760
- if (iconColor !== void 0) li.setAttribute(`data-icon-color`, iconColor);
761
- if (typeof content === `string`) {
762
- const span = this._setLabel(li, content);
763
- if (textColor !== void 0) span.style.color = textColor;
764
- if (this.iconProperty) {
765
- const icon = this.#propertyValue(item, this.iconProperty);
766
- if (typeof icon === `string` && icon.length > 0) li.setAttribute(`data-icon`, icon);
767
- }
768
- } else if (content instanceof Node) {
769
- li.appendChild(content);
770
- if (textColor !== void 0) li.style.color = textColor;
771
- }
772
- if (this.keyProperty) {
773
- const key = this.#propertyValue(item, this.keyProperty);
774
- if (key !== void 0 && key !== null) li.setAttribute(`data-key`, String(key));
775
- }
776
- this.#ensureIcon(li);
777
- this.#ensureBadge(li, this.#propertyValue(item, this.badgeProperty));
778
- return li;
779
- }
780
- #propertyValue(item, prop) {
781
- if (typeof item !== `object` || item === null || !(prop in item)) return void 0;
782
- return item[prop];
783
- }
784
- /** A non-empty string from `item[prop]`, else `undefined`. */
785
- #colorValue(item, prop) {
786
- return prop ? appearanceColor(this.#propertyValue(item, prop)) : void 0;
787
- }
788
- #syncFromProvider() {
789
- if (this.provider === void 0) return;
790
- const items = this.#data.items;
791
- if (items === this.#builtFromProvider) return;
792
- let prefix = 0;
793
- while (prefix < this.#builtFromProvider.length && prefix < items.length && this.#builtFromProvider[prefix] === items[prefix]) prefix++;
794
- if (prefix === this.#builtFromProvider.length && prefix <= items.length) {
795
- const tail = items.slice(prefix);
796
- for (const item of tail) this.appendChild(this.#createItemEl(item, this.#providerBuilt++));
797
- if (this.sort !== `none`) {
798
- cancelAnimationFrame(this.#sortRaf);
799
- this.#sortRaf = requestAnimationFrame(() => this.#applySort());
800
- }
801
- if (this.interactionMode === `checked`) this._syncCheckboxes();
802
- this._syncItemStates();
803
- this.#scheduleGeometry();
804
- this.#scheduleGroups();
805
- } else {
806
- this.#providerBuilt = 0;
807
- this.#rebuildFromObjects(items);
808
- }
809
- this.#builtFromProvider = items;
810
- }
811
- #applyFilterPredicate() {
812
- if (!this.filterPredicate) {
813
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) el.removeAttribute(`hidden`);
814
- return;
815
- }
816
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) if (this.filterPredicate(el)) el.removeAttribute(`hidden`);
817
- else el.setAttribute(`hidden`, ``);
818
- }
819
- #applySort() {
820
- if (this.sort === `none`) return;
821
- const rows = [...this.querySelectorAll(ITEM_SELECTOR)];
822
- if (rows.length < 2) return;
823
- if (this.#groupingActive()) {
824
- this.#scheduleGroups();
825
- return;
826
- }
827
- for (const el of this.#sortRows(rows)) this.appendChild(el);
828
- this.#scheduleGeometry();
829
- this.#scheduleGroups();
830
- }
831
- /** Stable sort of `rows` by the current `sort` / `sortBy` / `sortComparator`. */
832
- #sortRows(rows) {
833
- const dir = this.sort === `descending` ? -1 : 1;
834
- const meta = (el) => ({
835
- element: el,
836
- data: this.getItemData(el),
837
- label: el.getAttribute(`data-search-label`) ?? el.textContent?.trim() ?? ``
838
- });
839
- let cmp;
840
- if (this.sortComparator) {
841
- const user = this.sortComparator;
842
- cmp = (a, b) => user(meta(a), meta(b));
843
- } else if (this.sortBy) {
844
- const prop = this.sortBy;
845
- const key = (el) => {
846
- const v = this.#propertyValue(this.getItemData(el), prop);
847
- if (typeof v === `number`) return v;
848
- return v === void 0 || v === null ? `` : String(v);
849
- };
850
- cmp = (a, b) => {
851
- const ka = key(a);
852
- const kb = key(b);
853
- if (typeof ka === `number` && typeof kb === `number`) return ka - kb;
854
- return String(ka).localeCompare(String(kb), void 0, { numeric: true });
855
- };
856
- } else cmp = (a, b) => meta(a).label.localeCompare(meta(b).label, void 0, { numeric: true });
857
- const indexed = rows.map((el, i) => ({
858
- el,
859
- i
860
- }));
861
- indexed.sort((a, b) => cmp(a.el, b.el) * dir || a.i - b.i);
862
- return indexed.map(({ el }) => el);
863
- }
864
- #groupingActive() {
865
- return this.groupBy !== null && this.groupBy !== void 0 && this.groupBy !== ``;
866
- }
867
- /** Coalesce regrouping to one pass per microtask (streaming batches, search keystrokes). */
868
- #scheduleGroups() {
869
- if (this.#groupsScheduled || !this.#groupingActive() && !this.#wasGrouped) return;
870
- this.#groupsScheduled = true;
871
- queueMicrotask(() => {
872
- this.#groupsScheduled = false;
873
- this.#syncGroups();
874
- });
875
- }
876
- #groupValue(el, name) {
877
- return this.#propertyValue(this.getItemData(el), name) ?? el.getAttribute(`data-${name}`);
878
- }
879
- #groupKeyOf(el) {
880
- const by = this.groupBy;
881
- if (typeof by === `string`) return toGroupKey(this.#groupValue(el, by));
882
- return toGroupKey(by(this.getItemData(el), el));
883
- }
884
- #isItemVisible(el) {
885
- return !el.hidden && (!this.filterPredicate || this.filterPredicate(el));
886
- }
887
- #headerFor(key) {
888
- let header = this.#headerEls.get(key);
889
- if (!header) {
890
- header = document.createElement(`ixfx-list-group-header`);
891
- header.setAttribute(GROUP_HEADER_ATTR, ``);
892
- header.dataset.groupKey = key;
893
- this.#headerEls.set(key, header);
894
- }
895
- return header;
896
- }
897
- /**
898
- * Bring the light DOM into grouped order: original order → sort → partition
899
- * into contiguous groups, each preceded by a header row. Idempotent — it only
900
- * touches the DOM when the order actually changes, so it never loops through
901
- * the mutation observer. Ungrouping restores the original (sorted) order.
902
- */
903
- #syncGroups() {
904
- const active = this.#groupingActive();
905
- if (!active && !this.#wasGrouped) return;
906
- const items = [...this.querySelectorAll(ITEM_SELECTOR)];
907
- for (const el of items) if (!this.#seq.has(el)) this.#seq.set(el, this.#seqNext++);
908
- let ordered = items.toSorted((a, b) => this.#seq.get(a) - this.#seq.get(b));
909
- if (this.sort !== `none` && ordered.length > 1) ordered = this.#sortRows(ordered);
910
- const nodes = [];
911
- const info = [];
912
- const index = /* @__PURE__ */ new Map();
913
- const liveHeaders = /* @__PURE__ */ new Set();
914
- if (active) {
915
- const label = this.groupLabel;
916
- const parts = partitionByGroup(ordered, (el) => this.#groupKeyOf(el), label ? (key, els) => label(key, els.map((el) => this.getItemData(el) ?? el)) : void 0);
917
- for (const part of parts) {
918
- const count = part.items.filter((el) => this.#isItemVisible(el)).length;
919
- const collapsed = count > 0 && this._collapsedGroups.has(part.key);
920
- if (count > 0) {
921
- const header = this.#headerFor(part.key);
922
- header.label = part.label;
923
- header.count = count;
924
- header.collapsed = collapsed;
925
- liveHeaders.add(part.key);
926
- nodes.push(header);
927
- info.push({
928
- key: part.key,
929
- label: part.label,
930
- count,
931
- collapsed: this._collapsedGroups.has(part.key)
932
- });
933
- }
934
- for (const el of part.items) {
935
- index.set(el, part.key);
936
- el.toggleAttribute(GROUP_COLLAPSED_ATTR, collapsed);
937
- nodes.push(el);
938
- }
939
- }
940
- } else {
941
- for (const el of ordered) el.removeAttribute(GROUP_COLLAPSED_ATTR);
942
- nodes.push(...ordered);
943
- }
944
- for (const [key, header] of this.#headerEls) if (!liveHeaders.has(key)) {
945
- header.remove();
946
- this.#headerEls.delete(key);
947
- }
948
- this.#groupIndex = index;
949
- this.#groupList = info;
950
- this.#wasGrouped = active;
951
- const current = [...this.children].filter((c) => c.matches(`li`) || c.hasAttribute(GROUP_HEADER_ATTR));
952
- if (current.length !== nodes.length || current.some((c, i) => c !== nodes[i])) this.append(...nodes);
953
- if (this.tickled.tickledId?.hasAttribute(GROUP_COLLAPSED_ATTR)) this.tickled.focus(void 0);
954
- this.#syncGroupObserver(active);
955
- this.#scheduleGeometry();
956
- }
957
- /** Filter-search hides rows via `hidden` on the `<li>`s — regroup when that changes. */
958
- #syncGroupObserver(active) {
959
- if (!active) {
960
- this.#groupObserver?.disconnect();
961
- this.#groupObserver = void 0;
962
- return;
963
- }
964
- if (this.#groupObserver || !this.isConnected) return;
965
- this.#groupObserver = new MutationObserver(() => this.#scheduleGroups());
966
- this.#groupObserver.observe(this, {
967
- subtree: true,
968
- attributes: true,
969
- attributeFilter: [`hidden`]
970
- });
971
- }
972
- /** Groups in display order (empty when ungrouped). */
973
- get groups() {
974
- return this.#groupList;
975
- }
976
- /** Collapse or expand one group. Fires `list-group-toggle` when the state changes. */
977
- setGroupCollapsed(groupKey, collapsed) {
978
- if (this._collapsedGroups.has(groupKey) === collapsed) return;
979
- const next = new Set(this._collapsedGroups);
980
- if (collapsed) next.add(groupKey);
981
- else next.delete(groupKey);
982
- this._collapsedGroups = next;
983
- this._dispatch(`list-group-toggle`, {
984
- groupKey,
985
- collapsed
986
- });
987
- }
988
- toggleGroup(groupKey) {
989
- this.setGroupCollapsed(groupKey, !this._collapsedGroups.has(groupKey));
990
- }
991
- collapseAllGroups() {
992
- for (const g of this.#groupList) this.setGroupCollapsed(g.key, true);
993
- }
994
- expandAllGroups() {
995
- for (const key of [...this._collapsedGroups]) this.setGroupCollapsed(key, false);
996
- }
997
- #findGroupHeader(path) {
998
- for (const target of path) {
999
- if (target === this) break;
1000
- if (target instanceof HTMLElement && target.parentElement === this && target.hasAttribute(GROUP_HEADER_ATTR)) return target;
1001
- }
1002
- }
1003
- #scheduleGeometry() {
1004
- if (this.#geometryScheduled) return;
1005
- this.#geometryScheduled = true;
1006
- requestAnimationFrame(() => {
1007
- this.#geometryScheduled = false;
1008
- this.#recomputeGeometry();
1009
- });
1010
- }
1011
- #recomputeGeometry() {
1012
- this.#grid = [];
1013
- this.#positions.clear();
1014
- this.#tops.clear();
1015
- if (!this.isConnected) return;
1016
- const columns = [];
1017
- for (const el of this._getVisibleItems()) {
1018
- const rect = el.getBoundingClientRect();
1019
- if (rect.width === 0 && rect.height === 0) continue;
1020
- this.#tops.set(el, rect.top);
1021
- let ci = columns.findIndex((c) => Math.abs(c.left - rect.left) <= 1);
1022
- if (ci === -1) {
1023
- columns.push({
1024
- left: rect.left,
1025
- items: []
1026
- });
1027
- ci = columns.length - 1;
1028
- }
1029
- columns[ci].items.push(el);
1030
- }
1031
- columns.sort((a, b) => a.left - b.left);
1032
- for (const col of columns) col.items.sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
1033
- this.#grid = columns.map((c) => c.items);
1034
- this.#grid.forEach((col, colIdx) => col.forEach((el, rowIdx) => this.#positions.set(el, {
1035
- col: colIdx,
1036
- row: rowIdx
1037
- })));
1038
- this.#scheduleViewportChangeEmit();
1039
- }
1040
- #positionOf(el) {
1041
- let pos = this.#positions.get(el);
1042
- if (pos === void 0) {
1043
- this.#recomputeGeometry();
1044
- pos = this.#positions.get(el);
1045
- }
1046
- return pos;
1047
- }
1048
- #itemAt(col, row) {
1049
- return this.#grid[col]?.[row];
1050
- }
1051
- #gridSize() {
1052
- if (this.#grid.length === 0) this.#recomputeGeometry();
1053
- return {
1054
- cols: this.#grid.length,
1055
- rows: Math.max(0, ...this.#grid.map((c) => c.length))
1056
- };
1057
- }
1058
- #navigateTo(target) {
1059
- if (!target) return;
1060
- this.tickled.handleKeyboardNavigation(target);
1061
- this.tickled.tickledId?.scrollIntoView({
1062
- block: `nearest`,
1063
- inline: `nearest`
1064
- });
1065
- }
1066
- #findNextCheckable(fromCol, fromRow, deltaCol, deltaRow) {
1067
- const { cols } = this.#gridSize();
1068
- const maxIterations = this._getVisibleItems().length + 1;
1069
- let col = deltaCol !== 0 ? fromCol + deltaCol : fromCol;
1070
- let row = deltaRow !== 0 ? fromRow + deltaRow : fromRow;
1071
- let wrappedColumns = false;
1072
- for (let iterations = 0; iterations < maxIterations; iterations++) {
1073
- const colLength = this.#grid[col]?.length ?? 0;
1074
- if (row < 0 || row >= colLength) {
1075
- if (deltaCol !== 0 || wrappedColumns) {
1076
- if (this.itemWrap === `wrap`) {
1077
- if (deltaCol < 0) col = cols - 1;
1078
- else if (deltaCol > 0) col = 0;
1079
- wrappedColumns = true;
1080
- } else return;
1081
- }
1082
- if (deltaRow > 0) {
1083
- if (col + 1 < cols) {
1084
- col = col + 1;
1085
- row = 0;
1086
- wrappedColumns = true;
1087
- } else if (this.itemWrap === `wrap`) {
1088
- col = 0;
1089
- row = 0;
1090
- wrappedColumns = true;
1091
- } else return;
1092
- } else if (deltaRow < 0) {
1093
- if (col - 1 >= 0) {
1094
- col = col - 1;
1095
- row = (this.#grid[col]?.length ?? 1) - 1;
1096
- wrappedColumns = true;
1097
- } else if (this.itemWrap === `wrap`) {
1098
- col = cols - 1;
1099
- row = (this.#grid[col]?.length ?? 1) - 1;
1100
- wrappedColumns = true;
1101
- } else return;
1102
- } else if (deltaCol !== 0) {
1103
- const targetColLength = this.#grid[col]?.length ?? 0;
1104
- if (row >= targetColLength && targetColLength > 0) row = targetColLength - 1;
1105
- }
1106
- if (col === fromCol && row === fromRow + deltaRow) return;
1107
- continue;
1108
- }
1109
- const item = this.#itemAt(col, row);
1110
- if (item && this._isCheckable(item)) return item;
1111
- row += deltaRow;
1112
- }
1113
- }
1114
- #findFirstCheckable() {
1115
- return this._getVisibleItems().find((item) => this._isCheckable(item));
1116
- }
1117
- #findLastCheckable() {
1118
- const visibleItems = this._getVisibleItems();
1119
- for (let i = visibleItems.length - 1; i >= 0; i--) if (this._isCheckable(visibleItems[i])) return visibleItems[i];
1120
- }
1121
- #navigateDown() {
1122
- this.#recomputeGeometry();
1123
- const cur = this.tickled.tickledId ? this.#positionOf(this.tickled.tickledId) : void 0;
1124
- if (!cur) {
1125
- this.#navigateTo(this.#findFirstCheckable());
1126
- return;
1127
- }
1128
- const next = this.#findNextCheckable(cur.col, cur.row, 0, 1);
1129
- if (next) this.#navigateTo(next);
1130
- }
1131
- #navigateUp() {
1132
- this.#recomputeGeometry();
1133
- const cur = this.tickled.tickledId ? this.#positionOf(this.tickled.tickledId) : void 0;
1134
- if (!cur) {
1135
- this.#navigateTo(this.#findLastCheckable());
1136
- return;
1137
- }
1138
- const next = this.#findNextCheckable(cur.col, cur.row, 0, -1);
1139
- if (next) this.#navigateTo(next);
1140
- }
1141
- /**
1142
- * Left/Right target. Ungrouped lists keep the row-index rule. Grouped lists
1143
- * have headers at arbitrary heights, so an item's row index no longer equals
1144
- * its visual row — pick the item in the neighbouring column whose top is
1145
- * nearest the cursor's (ties go to the upper one).
1146
- */
1147
- #horizontalTarget(from, dir) {
1148
- if (this.#groupList.length === 0) return this.#findNextCheckable(from.col, from.row, dir, 0);
1149
- const column = this.#grid[from.col + dir];
1150
- const current = this.tickled.tickledId;
1151
- const top = current ? this.#tops.get(current) : void 0;
1152
- if (!column || top === void 0) return void 0;
1153
- let best;
1154
- let bestDelta = Number.POSITIVE_INFINITY;
1155
- for (const el of column) {
1156
- if (!this._isCheckable(el)) continue;
1157
- const delta = Math.abs((this.#tops.get(el) ?? Number.POSITIVE_INFINITY) - top);
1158
- if (delta < bestDelta) {
1159
- best = el;
1160
- bestDelta = delta;
1161
- }
1162
- }
1163
- return best;
1164
- }
1165
- #navigateRight() {
1166
- this.#recomputeGeometry();
1167
- const cur = this.tickled.tickledId ? this.#positionOf(this.tickled.tickledId) : void 0;
1168
- if (!cur) {
1169
- this.#navigateTo(this.#findFirstCheckable());
1170
- return;
1171
- }
1172
- const next = this.#horizontalTarget(cur, 1);
1173
- if (next) this.#navigateTo(next);
1174
- else if (this.itemWrap === `wrap`) this.#navigateTo(this.#findFirstCheckable());
1175
- }
1176
- #navigateLeft() {
1177
- this.#recomputeGeometry();
1178
- const cur = this.tickled.tickledId ? this.#positionOf(this.tickled.tickledId) : void 0;
1179
- if (!cur) {
1180
- this.#navigateTo(this.#findFirstCheckable());
1181
- return;
1182
- }
1183
- const next = this.#horizontalTarget(cur, -1);
1184
- if (next) this.#navigateTo(next);
1185
- else if (this.itemWrap === `wrap`) this.#navigateTo(this.#findLastCheckable());
1186
- }
1187
- _getVisibleItems() {
1188
- return Array.from(this.querySelectorAll(ITEM_SELECTOR)).filter((el) => {
1189
- if (el.hidden) return false;
1190
- if (el.hasAttribute(GROUP_COLLAPSED_ATTR)) return false;
1191
- if (this.filterPredicate && !this.filterPredicate(el)) return false;
1192
- return true;
1193
- });
1194
- }
1195
- /**
1196
- * Set the column width to fit the widest visible item.
1197
- *
1198
- * This is opt-in; detail lists continue to use `--detail-list-column-width`
1199
- * (or its 220px fallback) until this method is called. The measured value is
1200
- * set directly on this element, so it takes precedence over an inherited
1201
- * value. Returns the applied width in pixels, or 0 when there are no items.
1202
- */
1203
- async fitColumnWidth() {
1204
- await this.updateComplete;
1205
- const items = this._getVisibleItems();
1206
- if (items.length === 0) return 0;
1207
- const previousWidth = this.style.getPropertyValue(`--detail-list-column-width`);
1208
- const previousPriority = this.style.getPropertyPriority(`--detail-list-column-width`);
1209
- this.style.setProperty(`--detail-list-column-width`, `max-content`);
1210
- const width = Math.ceil(Math.max(...items.map((item) => item.getBoundingClientRect().width)));
1211
- if (previousWidth) this.style.setProperty(`--detail-list-column-width`, previousWidth, previousPriority);
1212
- else this.style.removeProperty(`--detail-list-column-width`);
1213
- this.style.setProperty(`--detail-list-column-width`, `${width}px`);
1214
- this.#scheduleGeometry();
1215
- return width;
1216
- }
1217
- _isCheckable(item) {
1218
- if (this.interactionMode !== `checked`) return true;
1219
- return !item.hasAttribute(`not-checked`);
1220
- }
1221
- /** Appends the caption span; returns it so callers can style it per item. */
1222
- _setLabel(li, label) {
1223
- const span = document.createElement(`span`);
1224
- span.style.cssText = LABEL_SPAN_CSS;
1225
- span.textContent = label;
1226
- li.appendChild(span);
1227
- li.setAttribute(`data-search-label`, label);
1228
- return span;
1229
- }
1230
- /**
1231
- * Inject a leading `<ixfx-icon>` into an item carrying `data-icon`.
1232
- * Idempotent — skips when the item already starts with an icon.
1233
- */
1234
- #ensureIcon(li) {
1235
- const name = li.getAttribute(`data-icon`);
1236
- if (!name) return;
1237
- if (li.firstElementChild?.tagName === `IXFX-ICON`) return;
1238
- const icon = document.createElement(`ixfx-icon`);
1239
- icon.setAttribute(`name`, name);
1240
- icon.style.marginInlineEnd = `var(--detail-list-icon-gap, 6px)`;
1241
- icon.style.flexShrink = `0`;
1242
- const color = li.getAttribute(`data-icon-color`);
1243
- if (color) icon.style.color = color;
1244
- li.prepend(icon);
1245
- }
1246
- /**
1247
- * Append a right-justified Finder-style badge. `badge` may be a DOM `Node`
1248
- * or anything Lit can render (typically a `TemplateResult`). Idempotent —
1249
- * a second call replaces the existing badge.
1250
- */
1251
- #ensureBadge(li, badge) {
1252
- if (appearanceAbsent(badge)) return;
1253
- let holder = li.querySelector(`:scope > .item-badge`);
1254
- if (!holder) {
1255
- holder = document.createElement(`span`);
1256
- holder.className = `item-badge`;
1257
- holder.style.cssText = BADGE_EL_CSS;
1258
- li.appendChild(holder);
1259
- }
1260
- holder.replaceChildren();
1261
- if (badge instanceof Node) holder.appendChild(badge);
1262
- else render(badge, holder);
1263
- }
1264
- /** Scan light-DOM children for unprocessed `data-icon` items. */
1265
- #processChildren() {
1266
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) this.#ensureIcon(el);
1267
- }
1268
- _syncItemStates() {
1269
- for (const el of this.querySelectorAll(ITEM_SELECTOR)) {
1270
- el.toggleAttribute(`data-tickled`, this.tickled.isTickled(el));
1271
- el.toggleAttribute(`data-selected`, this.selection.selected.has(el));
1272
- if (this.interactionMode === `checked`) el.toggleAttribute(`data-checked`, !el.hasAttribute(`not-checked`) && this.selection.selected.has(el));
1273
- else el.removeAttribute(`data-checked`);
1274
- }
1275
- this.dataset.inputMode = this.tickled.inputMode;
1276
- this._syncCheckboxes();
1277
- }
1278
- _syncCheckboxes() {
1279
- const inCheckedMode = this.interactionMode === `checked`;
1280
- const wantsCustom = typeof this.checkboxRenderer === `function`;
1281
- for (const el of this.querySelectorAll(`li`)) {
1282
- const existing = el.querySelector(`.ixfx-list-checkbox`);
1283
- if (!inCheckedMode) {
1284
- if (existing) existing.remove();
1285
- continue;
1286
- }
1287
- if (el.hasAttribute(`not-checked`)) {
1288
- if (existing) existing.remove();
1289
- continue;
1290
- }
1291
- const existingIsCustom = existing?.classList.contains(`ixfx-list-checkbox-custom`) ?? false;
1292
- if (existing && existingIsCustom !== wantsCustom) existing.remove();
1293
- let cb = el.querySelector(`.ixfx-list-checkbox`);
1294
- if (!cb) {
1295
- if (wantsCustom) {
1296
- const opts = this.checkboxRenderer;
1297
- const margin = opts.margin ?? `0`;
1298
- const width = opts.width ?? `24px`;
1299
- cb = this._createCustomCheckbox(el, margin, width);
1300
- } else cb = this._createNativeCheckboxCell(el);
1301
- el.prepend(cb);
1302
- }
1303
- const checked = this.selection.selected.has(el);
1304
- if (wantsCustom) {
1305
- cb.setAttribute(`aria-checked`, String(checked));
1306
- cb.toggleAttribute(`data-checked`, checked);
1307
- if (this.checkboxRenderer) {
1308
- const renderer = typeof this.checkboxRenderer === `function` ? this.checkboxRenderer : this.checkboxRenderer.renderer;
1309
- render(renderer(checked), cb);
1310
- }
1311
- } else {
1312
- const input = cb.querySelector(`input.ixfx-list-checkbox`);
1313
- if (input) input.checked = checked;
1314
- }
1315
- }
1316
- }
1317
- /**
1318
- * Native checkbox cell: a span that stretches to the row's full cross-axis
1319
- * (so the entire column height is a click target) with a real `<input>`
1320
- * centred inside. The span owns the click; the input is purely visual and
1321
- * has `pointer-events:none` so a single click produces one toggle.
1322
- */
1323
- _createNativeCheckboxCell(el) {
1324
- const cell = document.createElement(`span`);
1325
- cell.className = `ixfx-list-checkbox ixfx-list-checkbox-native`;
1326
- cell.style.cssText = `display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;align-self:stretch;width:18px;margin:0 6px 0 0;cursor:pointer;pointer-events:auto`;
1327
- cell.tabIndex = -1;
1328
- cell.setAttribute(`role`, `checkbox`);
1329
- cell.setAttribute(`part`, `checkbox`);
1330
- cell.addEventListener(`click`, (e) => {
1331
- e.stopPropagation();
1332
- this.selection.toggle(el);
1333
- });
1334
- const input = document.createElement(`input`);
1335
- input.type = `checkbox`;
1336
- input.className = `ixfx-list-checkbox`;
1337
- input.style.cssText = `pointer-events:none;cursor:pointer;margin:0`;
1338
- cell.appendChild(input);
1339
- return cell;
1340
- }
1341
- /** Custom checkbox cell: same shape as the native cell; renderer content inside. */
1342
- _createCustomCheckbox(el, margin, width) {
1343
- const span = document.createElement(`span`);
1344
- span.className = `ixfx-list-checkbox ixfx-list-checkbox-custom`;
1345
- span.style.cssText = `display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;align-self:stretch;width:${width};margin:${margin};cursor:pointer;pointer-events:auto`;
1346
- span.tabIndex = -1;
1347
- span.setAttribute(`role`, `checkbox`);
1348
- span.setAttribute(`part`, `checkbox`);
1349
- span.addEventListener(`click`, (e) => {
1350
- e.stopPropagation();
1351
- this.selection.toggle(el);
1352
- });
1353
- return span;
1354
- }
1355
- _findListItem(path) {
1356
- for (const target of path) {
1357
- if (!(target instanceof Element)) continue;
1358
- if (target === this) break;
1359
- if (target.parentElement === this && target.matches(`li`)) return target;
1360
- }
1361
- }
1362
- _dispatch(name, detail) {
1363
- this.dispatchEvent(new CustomEvent(name, {
1364
- detail,
1365
- bubbles: true,
1366
- composed: true
1367
- }));
1368
- }
1369
- _dispatchCancelable(name, detail) {
1370
- return this.dispatchEvent(new CustomEvent(name, {
1371
- detail,
1372
- bubbles: true,
1373
- composed: true,
1374
- cancelable: true
1375
- }));
1376
- }
1377
- /** Scroll on the `part="list"` element — rAF-coalesced viewport-change check. */
1378
- #onListScroll;
1379
- /** Coalesce non-scroll viewport checks to at most one per animation frame. */
1380
- #scheduleViewportChangeEmit() {
1381
- if (this.#viewportScrollRaf !== 0) return;
1382
- this.#viewportScrollRaf = requestAnimationFrame(() => {
1383
- this.#viewportScrollRaf = 0;
1384
- this.#emitViewportChangeIfChanged();
1385
- });
1386
- }
1387
- /**
1388
- * Keys of everything currently rendered. The list has no virtual window —
1389
- * every non-hidden item is in the DOM — so this is all keyed items, mirroring
1390
- * `ixfx-vertical-list.renderedKeys()` in its non-virtualized mode.
1391
- */
1392
- #renderedKeys() {
1393
- const out = [];
1394
- for (const el of this._getVisibleItems()) {
1395
- const key = keyForElement(el);
1396
- if (key !== void 0) out.push(key);
1397
- }
1398
- return out;
1399
- }
1400
- /**
1401
- * Dispatch `detail-list-viewport-change` with the current key sets — unless
1402
- * neither set changed since the last dispatch, so coalesced frames and
1403
- * no-op scrolls stay silent.
1404
- */
1405
- #emitViewportChangeIfChanged() {
1406
- const renderedKeys = this.#renderedKeys();
1407
- const visibleKeys = this.visibleKeys();
1408
- if (sameKeys(this.#lastViewportRenderedKeys, renderedKeys) && sameKeys(this.#lastViewportVisibleKeys, visibleKeys)) return;
1409
- this.#lastViewportRenderedKeys = renderedKeys;
1410
- this.#lastViewportVisibleKeys = visibleKeys;
1411
- this._dispatch(`detail-list-viewport-change`, {
1412
- renderedKeys,
1413
- visibleKeys
1414
- });
1415
- }
1416
- _activateItem(item) {
1417
- if (this.interactionMode !== `manual`) this.selection.replace(item);
1418
- this._dispatch(`list-activate`, { item });
1419
- }
1420
- static {
1421
- this.styles = [
1422
- themeFallbacks,
1423
- scrollFadeStyles(`x`),
1424
- listSearchStyles,
1425
- css`
1426
- :host {
1427
- display: block;
1428
- position: relative;
1429
- background: var(--detail-list-bg, var(--surface-3));
1430
- color: var(--detail-list-text, var(--surface-3-text));
1431
- border-radius: var(--detail-list-radius, var(--radius-s));
1432
- border: 1px solid var(--detail-list-border, var(--border));
1433
- width: 100%;
1434
- height: 100%;
1435
- overflow: hidden;
1436
- box-sizing: border-box;
1437
- outline: none;
1438
- --_detail-list-item-padding:
1439
- var(--ixfx-detail-list-item-padding, var(--detail-list-item-padding, 0 var(--space-xs, 3px)));
1440
- }
1441
-
1442
- :host(:focus-visible) {
1443
- outline: 2px solid var(--accent);
1444
- outline-offset: 2px;
1445
- }
1446
-
1447
- .container {
1448
- position: relative;
1449
- width: 100%;
1450
- height: 100%;
1451
- }
1452
-
1453
- ul {
1454
- list-style: none;
1455
- margin: 0;
1456
- padding: 0;
1457
- /* keep the last column clear of the scrollbar / right edge */
1458
- padding-inline-end: calc(var(--detail-list-column-gap, 8px) + 4px);
1459
- width: 100%;
1460
- height: 100%;
1461
- display: flex;
1462
- flex-flow: column wrap;
1463
- align-content: flex-start;
1464
- column-gap: var(--detail-list-column-gap, 8px);
1465
- overflow-x: auto;
1466
- overflow-y: hidden;
1467
- box-sizing: border-box;
1468
- /* Scrollbar theming: consumers override these CSS variables to control
1469
- the native scrollbar (scrollbar-width, scrollbar-gutter, scrollbar-color). */
1470
- scrollbar-width: var(--detail-list-scrollbar-width, auto);
1471
- scrollbar-gutter: var(--detail-list-scrollbar-gutter, auto);
1472
- scrollbar-color: var(--detail-list-scrollbar-color, auto);
1473
- }
1474
-
1475
- ::slotted([hidden]) {
1476
- display: none !important;
1477
- }
1478
-
1479
- /* Rows of a collapsed group leave the flow; their header stays. */
1480
- ::slotted([data-group-collapsed]) {
1481
- display: none !important;
1482
- }
1483
-
1484
- /* Group headers are rows in the column flow, the same size as an item. */
1485
- ::slotted(ixfx-list-group-header) {
1486
- box-sizing: border-box;
1487
- flex: none;
1488
- width: var(--detail-list-column-width, 220px);
1489
- height: var(--detail-list-item-height, 28px);
1490
- --list-group-header-height: var(--detail-list-group-header-height, var(--detail-list-item-height, 28px));
1491
- }
1492
-
1493
- ::slotted(li) {
1494
- box-sizing: border-box;
1495
- display: flex;
1496
- align-items: center;
1497
- flex: none;
1498
- width: var(--detail-list-column-width, 220px);
1499
- height: var(--detail-list-item-height, 28px);
1500
- padding: var(--_detail-list-item-padding);
1501
- cursor: pointer;
1502
- user-select: none;
1503
- transition: background var(--transition, 0.1s ease-out),
1504
- outline-color var(--transition, 0.1s ease-out);
1505
- outline: 1px solid transparent;
1506
- }
1507
-
1508
- /* While navigating by keyboard, key-repeat outpaces the 0.1s fade so the
1509
- cursor smears across rows. Snap instead. */
1510
- :host([data-keyboard-nav]) ::slotted(li) {
1511
- transition: none;
1512
- }
1513
-
1514
- /* In checked mode, only the checkbox column is clickable; the row body
1515
- gets a default cursor so it doesn't suggest otherwise. */
1516
- :host([interaction-mode="checked"]) ::slotted(li) {
1517
- cursor: default;
1518
- }
1519
-
1520
- ::slotted([data-tickled]) {
1521
- background: var(--item-bg-tickled);
1522
- outline: var(--item-border-tickled);
1523
- }
1524
-
1525
- ::slotted([data-selected]) {
1526
- background: var(--item-bg-selected);
1527
- color: var(--item-text-selected);
1528
- outline: 1px solid transparent;
1529
- }
1530
-
1531
- ::slotted([data-selected][data-tickled]) {
1532
- background: var(--item-bg-selected-tickled);
1533
- outline: 2px dashed var(--surface-3);
1534
- outline-offset: -2px;
1535
- }
1536
-
1537
- /* Drag-select (marquee) rectangle + covered-row preview.
1538
- Style hooks: part="marquee", --detail-list-marquee-border,
1539
- --detail-list-marquee-fill. */
1540
- .marquee {
1541
- position: absolute;
1542
- pointer-events: none;
1543
- z-index: 5;
1544
- border: 1px solid var(--detail-list-marquee-border, var(--accent));
1545
- background: var(--detail-list-marquee-fill, color-mix(in srgb, var(--accent) 15%, transparent));
1546
- }
1547
-
1548
- ::slotted([data-marquee]) {
1549
- background: var(--item-bg-selected);
1550
- color: var(--item-text-selected);
1551
- }
1552
-
1553
- ::slotted([data-drag-origin]) {
1554
- opacity: 0.6;
1555
- }
1556
-
1557
- /* Per-item icon / badge (adapter mode) are styled inline by
1558
- #ensureBadge — ::slotted() only reaches the host's direct children,
1559
- and these spans live inside a slotted <li>. */
1560
-
1561
- /* checked mode: the injected checkbox communicates selection — suppress bg */
1562
- :host([interaction-mode="checked"]) ::slotted([data-selected]) {
1563
- background: transparent;
1564
- color: inherit;
1565
- outline: 1px solid transparent;
1566
- }
1567
-
1568
- :host([interaction-mode="checked"]) ::slotted([data-selected][data-tickled]) {
1569
- background: var(--item-bg-tickled);
1570
- color: inherit;
1571
- outline: var(--item-border-tickled);
1572
- }
1573
-
1574
- .loading {
1575
- position: absolute;
1576
- bottom: 8px;
1577
- right: 8px;
1578
- z-index: 10;
1579
- background: var(--surface-4, #2a2a2a);
1580
- border: 1px solid var(--border, #444);
1581
- border-radius: var(--radius-m, 4px);
1582
- padding: 2px 8px;
1583
- font-size: var(--text-s, 11px);
1584
- color: var(--surface-muted-text, #888);
1585
- }
1586
-
1587
- .loading[hidden] {
1588
- display: none;
1589
- }
1590
- `
1591
- ];
1592
- }
1593
- render() {
1594
- const loading = this.#data.loading;
1595
- const progress = this.#data.progress;
1596
- return html`
1597
- <div class="container">
1598
- <ul part="list" class="scroll-fade-x" @scroll=${this.#onListScroll}>
1599
- <slot></slot>
1600
- </ul>
1601
- ${this.#marqueeRect ? html`<div class="marquee" part="marquee" style=${this.#marqueeStyle(this.#marqueeRect)}></div>` : ``}
1602
- <div class="loading" part="loading" ?hidden=${!loading}>
1603
- ${loading ? progress !== void 0 ? `${Math.round(progress * 100)}%` : `loading…` : nothing}
1604
- </div>
1605
- ${this.search.renderField()}
1606
- </div>
1607
- `;
1608
- }
1609
- };
1610
- __decorate([property({
1611
- type: String,
1612
- attribute: `selection-mode`
1613
- })], DetailListElement.prototype, "selectionMode", void 0);
1614
- __decorate([property({
1615
- type: String,
1616
- attribute: `interaction-mode`
1617
- })], DetailListElement.prototype, "interactionMode", void 0);
1618
- __decorate([property({ type: String })], DetailListElement.prototype, "sort", void 0);
1619
- __decorate([property({
1620
- type: String,
1621
- attribute: `sort-by`
1622
- })], DetailListElement.prototype, "sortBy", void 0);
1623
- __decorate([property({ attribute: false })], DetailListElement.prototype, "sortComparator", void 0);
1624
- __decorate([property({ attribute: false })], DetailListElement.prototype, "items", void 0);
1625
- __decorate([property({ attribute: false })], DetailListElement.prototype, "provider", void 0);
1626
- __decorate([property({
1627
- type: String,
1628
- attribute: `display-property`
1629
- })], DetailListElement.prototype, "displayProperty", void 0);
1630
- __decorate([property({ attribute: false })], DetailListElement.prototype, "formatter", void 0);
1631
- __decorate([property({
1632
- type: String,
1633
- attribute: `icon-property`
1634
- })], DetailListElement.prototype, "iconProperty", void 0);
1635
- __decorate([property({
1636
- type: String,
1637
- attribute: `icon-color-property`
1638
- })], DetailListElement.prototype, "iconColorProperty", void 0);
1639
- __decorate([property({
1640
- type: String,
1641
- attribute: `text-color-property`
1642
- })], DetailListElement.prototype, "textColorProperty", void 0);
1643
- __decorate([property({
1644
- type: String,
1645
- attribute: `badge-property`
1646
- })], DetailListElement.prototype, "badgeProperty", void 0);
1647
- __decorate([property({
1648
- type: String,
1649
- attribute: `key-property`
1650
- })], DetailListElement.prototype, "keyProperty", void 0);
1651
- __decorate([property({ attribute: false })], DetailListElement.prototype, "filterPredicate", void 0);
1652
- __decorate([property({
1653
- type: String,
1654
- attribute: `item-wrap`
1655
- })], DetailListElement.prototype, "itemWrap", void 0);
1656
- __decorate([property({ attribute: false })], DetailListElement.prototype, "checkboxRenderer", void 0);
1657
- __decorate([property({
1658
- type: String,
1659
- attribute: `search-modes`,
1660
- reflect: true
1661
- })], DetailListElement.prototype, "searchModes", void 0);
1662
- __decorate([property({
1663
- type: Boolean,
1664
- attribute: `items-draggable`,
1665
- reflect: true
1666
- })], DetailListElement.prototype, "itemsDraggable", void 0);
1667
- __decorate([property({ attribute: false })], DetailListElement.prototype, "dragPreviewRenderer", void 0);
1668
- __decorate([property({ attribute: false })], DetailListElement.prototype, "dragPreviewSource", void 0);
1669
- __decorate([property({ attribute: `group-by` })], DetailListElement.prototype, "groupBy", void 0);
1670
- __decorate([property({ attribute: false })], DetailListElement.prototype, "groupLabel", void 0);
1671
- __decorate([property({
1672
- type: Boolean,
1673
- attribute: `cross-group-selection`,
1674
- reflect: true
1675
- })], DetailListElement.prototype, "crossGroupSelection", void 0);
1676
- __decorate([state()], DetailListElement.prototype, "_collapsedGroups", void 0);
1677
- __decorate([query(`ul`)], DetailListElement.prototype, "_listEl", void 0);
1678
- DetailListElement = __decorate([safeCustomElement(`ixfx-detail-list`)], DetailListElement);
1679
- //#endregion
1680
3
  export { DetailListElement };
1681
-
1682
- //# sourceMappingURL=detail-list.js.map