@ixfx/components 0.9.2 → 0.9.4

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 (71) hide show
  1. package/bundle/index.d.ts +10 -6
  2. package/bundle/index.d.ts.map +1 -1
  3. package/bundle/index.js +45 -15
  4. package/bundle/index.js.map +1 -1
  5. package/dist/ac-text.d.ts +1 -1
  6. package/dist/{ac-token--_vCHXWw.d.ts → ac-token-TCLAZeVg.d.ts} +2 -2
  7. package/dist/{ac-token--_vCHXWw.d.ts.map → ac-token-TCLAZeVg.d.ts.map} +1 -1
  8. package/dist/ac-token.d.ts +1 -1
  9. package/dist/button.d.ts +1 -1
  10. package/dist/button.d.ts.map +1 -1
  11. package/dist/colour-picker.d.ts +1 -1
  12. package/dist/crumbs.d.ts +1 -1
  13. package/dist/{data-grid-C588pTgt.d.ts → data-grid-pp8WaKxG.d.ts} +2 -2
  14. package/dist/{data-grid-C588pTgt.d.ts.map → data-grid-pp8WaKxG.d.ts.map} +1 -1
  15. package/dist/data-grid.d.ts +1 -1
  16. package/dist/data-grid.js +1 -1
  17. package/dist/{detail-list-IKl76Wnp.d.ts → detail-list-DbYaz-YX.d.ts} +2 -2
  18. package/dist/{detail-list-IKl76Wnp.d.ts.map → detail-list-DbYaz-YX.d.ts.map} +1 -1
  19. package/dist/detail-list.d.ts +1 -1
  20. package/dist/detail-list.js +1 -1
  21. package/dist/{grid-list-DqHRR7kJ.js → grid-list-mL0GJTQR.js} +2 -2
  22. package/dist/{grid-list-DqHRR7kJ.js.map → grid-list-mL0GJTQR.js.map} +1 -1
  23. package/dist/grid-list.js +1 -1
  24. package/dist/{grouped-item-lister-fdZHVxFM.d.ts → grouped-item-lister-CEZ72VOs.d.ts} +2 -2
  25. package/dist/{grouped-item-lister-fdZHVxFM.d.ts.map → grouped-item-lister-CEZ72VOs.d.ts.map} +1 -1
  26. package/dist/grouped-item-lister.d.ts +1 -1
  27. package/dist/{icon-CDGprSdE.d.ts → icon-DR_3rSyZ.d.ts} +2 -2
  28. package/dist/icon-DR_3rSyZ.d.ts.map +1 -0
  29. package/dist/icons.d.ts +2 -2
  30. package/dist/{index-tq6f8007.d.ts → index-BOUaDIW-.d.ts} +2 -2
  31. package/dist/{index-tq6f8007.d.ts.map → index-BOUaDIW-.d.ts.map} +1 -1
  32. package/dist/{index-CoqtMSd9.d.ts → index-BUB5SICW.d.ts} +2 -2
  33. package/dist/{index-CoqtMSd9.d.ts.map → index-BUB5SICW.d.ts.map} +1 -1
  34. package/dist/{index-9AhaHIT2.d.ts → index-C59-JEPl.d.ts} +3 -3
  35. package/dist/{index-9AhaHIT2.d.ts.map → index-C59-JEPl.d.ts.map} +1 -1
  36. package/dist/{index-UvnoZUAo.d.ts → index-CJ5fshD3.d.ts} +2 -2
  37. package/dist/{index-UvnoZUAo.d.ts.map → index-CJ5fshD3.d.ts.map} +1 -1
  38. package/dist/{index-CS9yM8L-.d.ts → index-DsjpDksO.d.ts} +2 -2
  39. package/dist/{index-CS9yM8L-.d.ts.map → index-DsjpDksO.d.ts.map} +1 -1
  40. package/dist/index.d.ts +18 -14
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +44 -14
  43. package/dist/index.js.map +1 -1
  44. package/dist/{labelled-input-base-DiTme1JO.d.ts → labelled-input-base-Dp_9KP0G.d.ts} +2 -2
  45. package/dist/{labelled-input-base-DiTme1JO.d.ts.map → labelled-input-base-Dp_9KP0G.d.ts.map} +1 -1
  46. package/dist/labelled-radial-input.d.ts +2 -2
  47. package/dist/labelled-radial-input.d.ts.map +1 -1
  48. package/dist/labelled-range-input.d.ts +1 -1
  49. package/dist/labelled-slider-input.d.ts +1 -1
  50. package/dist/{list-native-drag-controller-DaBNcjgG.js → list-native-drag-controller-B0hWdbtM.js} +5 -5
  51. package/dist/{list-native-drag-controller-DaBNcjgG.js.map → list-native-drag-controller-B0hWdbtM.js.map} +1 -1
  52. package/dist/{menu-item-CZi9vy5O.d.ts → menu-item-ZmkXNjek.d.ts} +2 -2
  53. package/dist/{menu-item-CZi9vy5O.d.ts.map → menu-item-ZmkXNjek.d.ts.map} +1 -1
  54. package/dist/menu.d.ts +2 -2
  55. package/dist/panel.d.ts +1 -1
  56. package/dist/{split-layout-JK3xWVX2.d.ts → split-layout-C5SYbDrq.d.ts} +2 -2
  57. package/dist/{split-layout-JK3xWVX2.d.ts.map → split-layout-C5SYbDrq.d.ts.map} +1 -1
  58. package/dist/split-layout.d.ts +1 -1
  59. package/dist/{tab-list-CGyPt07Z.d.ts → tab-list-DbMIL520.d.ts} +2 -2
  60. package/dist/{tab-list-CGyPt07Z.d.ts.map → tab-list-DbMIL520.d.ts.map} +1 -1
  61. package/dist/tabs.d.ts +1 -1
  62. package/dist/{titlebar-Tqu-VvMU.d.ts → titlebar-B5zSTZnF.d.ts} +2 -2
  63. package/dist/{titlebar-Tqu-VvMU.d.ts.map → titlebar-B5zSTZnF.d.ts.map} +1 -1
  64. package/dist/titlebar.d.ts +1 -1
  65. package/dist/{tree-CwifXCzR.js → tree-DAFBO_MF.js} +2 -2
  66. package/dist/{tree-CwifXCzR.js.map → tree-DAFBO_MF.js.map} +1 -1
  67. package/dist/tree.js +1 -1
  68. package/dist/vertical-list.js +1 -1
  69. package/docs-user/index.json +2 -2
  70. package/package.json +2 -2
  71. package/dist/icon-CDGprSdE.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"grid-list-DqHRR7kJ.js","names":["ITEM_SELECTOR","#host","#effectiveIndices","#items","#itemKey","#keysCache","#captionFor","#predicate","#searchKeys","#recomputeEffective","#slotNames","#seq","#syntheticKeys","#adapter","customElement","#sourceElement","#source","#emitSelect","#stopActiveCaptionPan","#emitItemEvent","#itemWrap","#dragSelect","#nativeDrag","#prepareNativeDrag","#rowHeight","#nativeDragging","#dragOriginKey","#clearNativeDragState","#startPostDragSuppressTimer","#isCellBlankPress","#viewportRef","#marqueeHitTest","#marqueePreview","#marqueeRect","#cancelScrollRaf","#scrollRaf","#emitViewportChange","#currentWindow","#scrollItemIntoView","#onCellActivate","#searchMode","#searchFilterKeys","#searchRegistry","#effectiveSearchModes","#unregisterSearchCommands","#syncAriaMultiselectable","#mutationObserver","#onChildrenChanged","#ensureSearch","#syncSearchCommands","#resizeObserver","#reflowTimer","#items","#syncItems","#noteChildMutation","#entering","#rebuildSource","#measureViewport","#applyFilters","#zoomAnchor","#captureCentreAnchor","#applyZoomAnchor","#activateTickledPan","#rawIndexOfKey","#windowKeys","#selectedSnapshot","#onScroll","#renderDataCells","#renderElementCells","#marqueeStyle","#renderDataCell","#onCellClick","#renderCaption","#activeCaptionPan","#renderCell","#captionFor","#postDragSuppressTimer","customElement"],"sources":["../src/grid-list/grid-list-source.ts","../src/pan-text/pan-text.ts","../src/grid-list/grid-list.ts"],"sourcesContent":["import type { GridListDataAdapter } from './types.js';\nimport { html } from 'lit';\nimport { keyForElement } from '../interaction/keyed-list.js';\n\n/**\n * Uniform view over a grid-list's items, in either mode:\n *\n * - element mode ({@link ElementGridListSource}) — light-DOM children projected\n * through named `<slot>`s;\n * - data mode ({@link DataGridListSource}) — a plain array plus a\n * {@link GridListDataAdapter}.\n *\n * Everything else in `GridListElement` addresses items by **effective index**\n * (0…`count`, after `[hidden]` / filter / search) and **key**, and never\n * branches on the mode.\n */\nexport interface GridListSource {\n /** After `[hidden]`, the filter predicate and the live search filter. */\n readonly count: number;\n /** Before the filter predicate / search filter (element mode still drops `[hidden]`). */\n readonly rawCount: number;\n\n /** Effective index → key. Includes synthetic keys for keyless light-DOM items. */\n keyAt(index: number): string;\n /** Effective index of `key`, or `-1`. First match wins on duplicates. */\n indexOfKey(key: string): number;\n /** Every effective key, in order (synthetic keys included). */\n keys(): string[];\n\n /** Caption text for a cell. */\n labelAt(index: number): string;\n /** Raw (unfiltered) index → key — used by search, which sees the whole collection. */\n rawKeyAt(index: number): string;\n /** Raw (unfiltered) index → fzf haystack (falls back to the label). */\n rawSearchTextAt(index: number): string;\n\n /** `false` for `not-checked` / `disabled` items. */\n isSelectable(index: number): boolean;\n\n /** Lit-renderable cell content (element mode: a named `<slot>`; data mode: `adapter.render`). */\n renderCellContent(index: number): unknown;\n\n /** Push the current filter predicate / search-filter key set; recomputes the effective order. */\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void;\n /** Re-read the underlying data. */\n refresh(): void;\n\n /** The Element for `key`, if this source has one. */\n resolveKeyToElement(key: string): Element | undefined;\n /** The data value for `key`, if this source has one. */\n resolveKeyToData(key: string): unknown;\n}\n\nconst ITEM_SELECTOR = `:scope > *`;\nconst SYNTHETIC_PREFIX = `gl-auto-`;\n\n/** Whether `key` is an auto-assigned key for a keyless light-DOM item. */\nexport function isSyntheticKey(key: string): boolean {\n return key.startsWith(SYNTHETIC_PREFIX);\n}\n\nfunction warnDuplicateKeys(keys: readonly string[]): void {\n const seen = new Set<string>();\n const dupes = new Set<string>();\n for (const k of keys) {\n if (isSyntheticKey(k))\n continue;\n if (seen.has(k))\n dupes.add(k);\n else\n seen.add(k);\n }\n if (dupes.size > 0) {\n console.warn(\n `ixfx-grid-list: duplicate item key(s) ${[...dupes].map(k => `\"${k}\"`).join(`, `)} — the first occurrence wins for key-based operations.`,\n );\n }\n}\n\nexport class ElementGridListSource implements GridListSource {\n readonly #host: HTMLElement;\n #items: Element[] = [];\n #slotNames = new WeakMap<Element, string>();\n #syntheticKeys = new WeakMap<Element, string>();\n #seq = 0;\n #predicate: ((index: number) => boolean) | undefined;\n #searchKeys: ReadonlySet<string> | undefined;\n #effectiveIndices: number[] = [];\n #keysCache: string[] | undefined;\n\n constructor(host: HTMLElement) {\n this.#host = host;\n this.refresh();\n }\n\n get count(): number {\n return this.#effectiveIndices.length;\n }\n\n get rawCount(): number {\n return this.#items.length;\n }\n\n keyAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#itemKey(this.#items[eff]);\n }\n\n indexOfKey(key: string): number {\n return this.#effectiveIndices.findIndex(i => this.#itemKey(this.#items[i]) === key);\n }\n\n keys(): string[] {\n this.#keysCache ??= this.#effectiveIndices.map(i => this.#itemKey(this.#items[i]));\n return this.#keysCache;\n }\n\n labelAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#captionFor(this.#items[eff]);\n }\n\n rawKeyAt(index: number): string {\n const el = this.#items[index];\n return el === undefined ? `` : this.#itemKey(el);\n }\n\n rawSearchTextAt(index: number): string {\n const el = this.#items[index];\n if (el === undefined)\n return ``;\n return (\n el.getAttribute(`data-search-label`)\n ?? el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? el.textContent?.trim()\n ?? ``\n );\n }\n\n isSelectable(index: number): boolean {\n const eff = this.#effectiveIndices[index];\n return eff !== undefined && !this.#items[eff].hasAttribute(`not-checked`);\n }\n\n renderCellContent(index: number): unknown {\n const eff = this.#effectiveIndices[index];\n if (eff === undefined)\n return undefined;\n return html`<slot name=${this.slotNameFor(this.#items[eff])}></slot>`;\n }\n\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void {\n if (`predicate` in opts)\n this.#predicate = opts.predicate;\n if (`searchKeys` in opts)\n this.#searchKeys = opts.searchKeys;\n this.#recomputeEffective();\n }\n\n refresh(): void {\n this.#items = Array.from(this.#host.querySelectorAll(ITEM_SELECTOR)).filter(\n el => !(el as HTMLElement).hidden,\n );\n for (const el of this.#items) {\n const name = this.slotNameFor(el);\n if (el.getAttribute(`slot`) !== name)\n el.setAttribute(`slot`, name);\n }\n warnDuplicateKeys(this.#items.map(el => this.#itemKey(el)));\n this.#recomputeEffective();\n }\n\n /** Effective-order elements — the array `GridListElement` renders and slices. */\n effectiveElements(): Element[] {\n return this.#effectiveIndices.map(i => this.#items[i]);\n }\n\n /** Raw-order element at `index`, or `undefined`. */\n rawElementAt(index: number): Element | undefined {\n return this.#items[index];\n }\n\n /** Stable per-element `<slot>` name. */\n slotNameFor(el: Element): string {\n let name = this.#slotNames.get(el);\n if (name === undefined) {\n this.#seq += 1;\n name = `gl-item-${this.#seq}`;\n this.#slotNames.set(el, name);\n }\n return name;\n }\n\n resolveKeyToElement(key: string): Element | undefined {\n if (isSyntheticKey(key))\n return this.#items.find(el => this.#syntheticKeys.get(el) === key);\n return this.#items.find(el => keyForElement(el) === key);\n }\n\n resolveKeyToData(_key: string): undefined {\n return undefined;\n }\n\n #recomputeEffective(): void {\n const effective: number[] = [];\n for (let i = 0; i < this.#items.length; i++) {\n if (this.#predicate !== undefined && !this.#predicate(i))\n continue;\n if (this.#searchKeys !== undefined) {\n const key = this.#itemKey(this.#items[i]);\n if (!isSyntheticKey(key) && !this.#searchKeys.has(key))\n continue;\n }\n effective.push(i);\n }\n this.#effectiveIndices = effective;\n this.#keysCache = undefined;\n }\n\n #itemKey(el: Element): string {\n const userKey = keyForElement(el);\n if (userKey !== undefined)\n return userKey;\n let synthetic = this.#syntheticKeys.get(el);\n if (synthetic === undefined) {\n this.#seq += 1;\n synthetic = `${SYNTHETIC_PREFIX}${this.#seq}`;\n this.#syntheticKeys.set(el, synthetic);\n }\n return synthetic;\n }\n\n #captionFor(el: Element): string {\n return (\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? ``\n );\n }\n}\n\nexport class DataGridListSource<T> implements GridListSource {\n #items: readonly T[];\n readonly #adapter: GridListDataAdapter<T>;\n #predicate: ((index: number) => boolean) | undefined;\n #searchKeys: ReadonlySet<string> | undefined;\n #effectiveIndices: number[] = [];\n #keysCache: string[] | undefined;\n\n constructor(items: readonly T[], adapter: GridListDataAdapter<T>) {\n this.#items = items;\n this.#adapter = adapter;\n warnDuplicateKeys(items.map((it, i) => adapter.key(it, i)));\n this.#recomputeEffective();\n }\n\n get count(): number {\n return this.#effectiveIndices.length;\n }\n\n get rawCount(): number {\n return this.#items.length;\n }\n\n keyAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#adapter.key(this.#items[eff], eff);\n }\n\n indexOfKey(key: string): number {\n return this.#effectiveIndices.findIndex(i => this.#adapter.key(this.#items[i], i) === key);\n }\n\n keys(): string[] {\n this.#keysCache ??= this.#effectiveIndices.map(i => this.#adapter.key(this.#items[i], i));\n return this.#keysCache;\n }\n\n labelAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n if (eff === undefined)\n return ``;\n return this.#adapter.label?.(this.#items[eff], eff) ?? this.#adapter.key(this.#items[eff], eff);\n }\n\n rawKeyAt(index: number): string {\n return index < 0 || index >= this.#items.length ? `` : this.#adapter.key(this.#items[index], index);\n }\n\n rawSearchTextAt(index: number): string {\n if (index < 0 || index >= this.#items.length)\n return ``;\n const item = this.#items[index];\n return this.#adapter.searchableText?.(item, index) ?? this.#adapter.label?.(item, index) ?? ``;\n }\n\n isSelectable(index: number): boolean {\n const eff = this.#effectiveIndices[index];\n return eff !== undefined && !this.#adapter.disabled?.(this.#items[eff], eff);\n }\n\n renderCellContent(index: number): unknown {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? undefined : this.#adapter.render(this.#items[eff], eff);\n }\n\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void {\n if (`predicate` in opts)\n this.#predicate = opts.predicate;\n if (`searchKeys` in opts)\n this.#searchKeys = opts.searchKeys;\n this.#recomputeEffective();\n }\n\n refresh(): void {\n this.#recomputeEffective();\n }\n\n /** Raw-order item at `index`, or `undefined`. */\n rawItemAt(index: number): T | undefined {\n return this.#items[index];\n }\n\n /** Effective-order item at `index`, or `undefined`. */\n getItemAt(index: number): T | undefined {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? undefined : this.#items[eff];\n }\n\n resolveKeyToElement(_key: string): undefined {\n return undefined;\n }\n\n resolveKeyToData(key: string): T | undefined {\n const idx = this.#items.findIndex((item, i) => this.#adapter.key(item, i) === key);\n return idx >= 0 ? this.#items[idx] : undefined;\n }\n\n #recomputeEffective(): void {\n const effective: number[] = [];\n for (let i = 0; i < this.#items.length; i++) {\n if (this.#predicate !== undefined && !this.#predicate(i))\n continue;\n if (this.#searchKeys !== undefined && !this.#searchKeys.has(this.#adapter.key(this.#items[i], i)))\n continue;\n effective.push(i);\n }\n this.#effectiveIndices = effective;\n this.#keysCache = undefined;\n }\n}\n","import type { PropertyValues } from 'lit';\nimport { css, html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { themeFallbacks } from '../styles/fallbacks.js';\nimport { safeCustomElement as customElement } from '../util/custom-elements.js';\n\nconst SPEED = 45; // px per second\nconst END_PADDING = 4;\nconst START_DELAY = 300; // ms to wait on hover before panning begins\nconst END_DWELL = 2000; // ms to dwell at the end of the text in loop mode\nconst RESET_DURATION = 400; // ms to snap back to the start in loop mode\n// Decelerating curve: moves off fast then eases into the reveal (~easeOutQuad).\nconst PAN_EASING = `cubic-bezier(0.25, 0.46, 0.45, 0.94)`;\n\nexport type PanTextMode = `hover` | `loop`;\n\n@customElement(`ixfx-pan-text`)\nexport class PanTextElement extends LitElement {\n @property({ type: String, attribute: `direction` }) direction: `start` | `end` = `end`;\n @property({ type: Boolean, attribute: `disabled` }) disabled = false;\n /**\n * Interaction mode.\n * - `hover` (default): pans once while hovered.\n * - `loop`: pans repeatedly — dwell 2s at the end, reset to the start,\n * and pan again — until `stopLoop()` is called. Auto-starts when set.\n */\n @property({ type: String, attribute: `mode`, reflect: true }) mode: PanTextMode = `hover`;\n\n @state() private _isOverflowing = false;\n @state() private _isHovering = false;\n @state() private _loopActive = false;\n @state() private _loopAtEnd = false;\n\n @query(`.text`) private _textEl!: HTMLElement | null;\n\n private _overflow = 0;\n private _resizeObserver: ResizeObserver | null = null;\n private _loopTimer = 0;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._resizeObserver = new ResizeObserver(() => this._measure());\n this.addEventListener(`mouseenter`, this._onMouseEnter);\n this.addEventListener(`mouseleave`, this._onMouseLeave);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._clearLoopTimer();\n // Reset without requesting an update — the element is leaving the DOM.\n this._loopActive = false;\n this._loopAtEnd = false;\n this._resizeObserver?.disconnect();\n this._resizeObserver = null;\n this.removeEventListener(`mouseenter`, this._onMouseEnter);\n this.removeEventListener(`mouseleave`, this._onMouseLeave);\n }\n\n override firstUpdated(): void {\n this._measure();\n this._resizeObserver?.observe(this);\n // Text metrics change once web fonts load; re-check when they settle.\n document.fonts?.ready.then(() => this._measure());\n if (this.mode === `loop`)\n this.startLoop();\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has(`mode`)) {\n if (this.mode === `loop`)\n this.startLoop();\n else\n this.stopLoop();\n }\n if (changed.has(`disabled`) && this.disabled)\n this.stopLoop();\n this._measure();\n }\n\n /**\n * Whether a loop pan is currently active (between `startLoop()` and `stopLoop()`).\n */\n get looping(): boolean {\n return this._loopActive;\n }\n\n /**\n * Begin looping: pan to the end, dwell there for 2 seconds, reset to the\n * start and pan again, repeating until `stopLoop()` is called. A no-op when\n * `disabled`, when there is nothing to reveal, or under reduced-motion.\n */\n startLoop(): void {\n if (this.disabled || this._prefersReducedMotion())\n return;\n this._loopActive = true;\n this._loopAtEnd = false;\n this.requestUpdate();\n if (this._isOverflowing && this._loopTimer === 0)\n this._scheduleLoopPan(START_DELAY);\n // Otherwise `_measure()` picks it up once overflow is known.\n }\n\n /**\n * Stop a loop started with `startLoop()` and snap back to the rest position.\n */\n stopLoop(): void {\n if (!this._loopActive && !this._loopAtEnd && this._loopTimer === 0)\n return;\n this._clearLoopTimer();\n this._loopActive = false;\n this._loopAtEnd = false;\n this.requestUpdate();\n }\n\n private _prefersReducedMotion(): boolean {\n return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches ?? false;\n }\n\n private _panDuration(): number {\n return Math.max(1.5, (this._overflow + END_PADDING) / SPEED);\n }\n\n private _clearLoopTimer(): void {\n if (this._loopTimer !== 0) {\n clearTimeout(this._loopTimer);\n this._loopTimer = 0;\n }\n }\n\n private _scheduleLoopPan(delay: number): void {\n this._clearLoopTimer();\n this._loopTimer = window.setTimeout(() => {\n this._loopTimer = 0;\n if (!this._loopActive || this.disabled || !this._isOverflowing)\n return;\n this._loopAtEnd = true;\n this.requestUpdate();\n const dwell = this._panDuration() * 1000 + END_DWELL;\n this._loopTimer = window.setTimeout(() => {\n this._loopTimer = 0;\n if (!this._loopActive)\n return;\n this._loopAtEnd = false;\n this.requestUpdate();\n this._scheduleLoopPan(RESET_DURATION + START_DELAY);\n }, dwell);\n }, delay);\n }\n\n private _onMouseEnter = (): void => {\n this._isHovering = true;\n };\n\n private _onMouseLeave = (): void => {\n this._isHovering = false;\n };\n\n /**\n * Measures how far the slotted text overflows its container. The measurement\n * is taken on the inner `.text` span (which clips with an ellipsis), not on\n * the host — the host never overflows, so measuring it always yielded zero\n * and the hover interaction never activated.\n *\n * Skipped while hovering, because the hover styles switch `.text` to\n * `overflow: visible` and the measurement would collapse to zero mid-pan.\n */\n private _measure = (): void => {\n if (this._isHovering || this._loopAtEnd)\n return;\n const el = this._textEl;\n if (!el)\n return;\n\n this._overflow = Math.max(0, el.scrollWidth - el.clientWidth);\n const overflowing = this._overflow > 0;\n\n this.classList.toggle(`is-overflowing`, overflowing);\n if (overflowing !== this._isOverflowing) {\n this._isOverflowing = overflowing;\n }\n // A loop requested before overflow was known (fonts, resize, late slot)\n // starts here once there is something to reveal.\n if (this._loopActive && this.mode === `loop` && !this.disabled && overflowing && this._loopTimer === 0)\n this._scheduleLoopPan(START_DELAY);\n if (!overflowing && this._loopAtEnd) {\n this._loopAtEnd = false;\n this.requestUpdate();\n }\n };\n\n private _textStyle(): string {\n if (!this._isOverflowing)\n return ``;\n\n const distance = this._overflow + END_PADDING;\n const duration = Math.max(1.5, distance / SPEED);\n const revealEnd = this.direction === `end`;\n\n // \"end\": rest shows the start of the text, hover pans left to the end.\n // \"start\": rest shows the end of the text, hover pans right to the start.\n const restX = revealEnd ? 0 : -distance;\n const hoverX = revealEnd ? -distance : 0;\n\n // Loop mode drives the same transform off a timer instead of hover. The\n // dwell/reset delays live in the timeout chain, so the transition itself\n // carries no extra delay.\n if (this._loopActive && this.mode === `loop`) {\n if (this._loopAtEnd) {\n return [\n `transform: translateX(${hoverX}px)`,\n `transition: transform ${duration}s ${PAN_EASING}`,\n `overflow: visible`,\n `text-overflow: clip`,\n ].join(`; `);\n }\n return [\n `transform: translateX(${restX}px)`,\n `transition: transform ${RESET_DURATION}ms ${PAN_EASING}`,\n revealEnd ? `` : `overflow: visible; text-overflow: clip`,\n ].filter(Boolean).join(`; `);\n }\n\n if (this._isHovering) {\n return [\n `transform: translateX(${hoverX}px)`,\n `transition: transform ${duration}s ${PAN_EASING} ${START_DELAY}ms`,\n `overflow: visible`,\n `text-overflow: clip`,\n ].join(`; `);\n }\n\n return [\n `transform: translateX(${restX}px)`,\n `transition: transform 400ms ${PAN_EASING}`,\n // \"start\" mode keeps the tail visible at rest, so it can't clip/ellipsis.\n revealEnd ? `` : `overflow: visible; text-overflow: clip`,\n ].filter(Boolean).join(`; `);\n }\n\n protected override render() {\n const textClasses = {\n 'is-overflowing': this._isOverflowing,\n 'is-hovering': this._isHovering,\n };\n\n return html`\n <span class=\"text ${classMap(textClasses)}\" part=\"text\" style=${this._textStyle()}>\n <slot @slotchange=${this._measure}></slot>\n </span>\n `;\n }\n\n static override styles = [themeFallbacks, css`\n /* Renders like plain inline text: no colours, border, padding or margin\n of its own — it only adds the clipping needed to pan on hover. */\n :host {\n display: inline-block;\n overflow: hidden;\n white-space: nowrap;\n max-width: 100%;\n box-sizing: border-box;\n font: inherit;\n color: inherit;\n }\n\n :host([disabled]) {\n opacity: var(--disabled-opacity, 0.5);\n pointer-events: none;\n }\n\n .text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n will-change: transform;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .text {\n transition: none !important;\n transform: none !important;\n }\n }\n `];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ixfx-pan-text': PanTextElement;\n }\n}\n","/* eslint-disable ts/no-unsafe-declaration-merging */\nimport type { CommandRegistry } from '@clinth/ui-commands';\nimport type { PropertyValues } from 'lit';\nimport type { DataListSearchItem, ListSearchMode } from '../incr-search/index.js';\nimport type {\n DragSelectRect,\n ListDragEntry,\n ListDragPreviewRenderer,\n ListNativeDragStartDetail,\n} from '../interaction/index.js';\nimport type { ListInteractionMode, ListSelectionMode } from '../interaction/list-selection-types.js';\nimport type { PanTextElement } from '../pan-text/pan-text.js';\nimport type { GridListSource } from './grid-list-source.js';\nimport type {\n GridListCaptionAlign,\n GridListCaptionBackdrop,\n GridListCaptionPosition,\n GridListCaptionStyle,\n GridListDataAdapter as GridListDataAdapterType,\n GridListFullElementEventMap,\n GridListItemClickDetail,\n GridListOrientation,\n GridListSelectDetail,\n GridListViewportChangeDetail,\n} from './types.js';\nimport { createCommandRegistry } from '@clinth/ui-commands';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport {\n createDataListSearchAdapter,\n createElementListSearchAdapter,\n LIST_SEARCH_MODES,\n ListSearchController,\n listSearchStyles,\n registerListSearchCommands,\n} from '../incr-search/index.js';\nimport { listItemFadeKeyframes, tickledItemStyles, tickledStyles } from '../interaction/index.js';\nimport { keyForElement } from '../interaction/keyed-list.js';\nimport { ListDragSelectController } from '../interaction/list-drag-select-controller.js';\nimport { ListNativeDragController } from '../interaction/list-native-drag-controller.js';\nimport { ListSelectionController } from '../interaction/list-selection-controller.js';\nimport { TickledController } from '../interaction/tickled-controller.js';\nimport { themeFallbacks } from '../styles/fallbacks.js';\nimport { scrollFadeStyles } from '../styles/scroll-fade.js';\nimport { safeCustomElement as customElement } from '../util/custom-elements.js';\nimport { DataGridListSource, ElementGridListSource, isSyntheticKey } from './grid-list-source.js';\nimport '../pan-text/pan-text.js';\n\nexport type {\n GridListActivateDetail,\n GridListActivateEvent,\n GridListCaptionAlign,\n GridListCaptionBackdrop,\n GridListCaptionPosition,\n GridListCaptionStyle,\n GridListDataAdapter,\n GridListElementEventMap,\n GridListFullElementEventMap,\n GridListItemClickDetail,\n GridListItemClickEvent,\n GridListItemEventDetail,\n GridListOrientation,\n GridListSelectDetail,\n GridListSelectEvent,\n GridListTickleDetail,\n GridListTickleEvent,\n GridListViewportChangeDetail,\n GridListViewportChangeEvent,\n ListDragEntry,\n ListDragPreview,\n ListDragPreviewContext,\n ListDragPreviewRenderer,\n ListDragSource,\n ListInteractionMode,\n ListNativeDragStartDetail,\n ListNativeDragStartEvent,\n ListSelectionMode,\n} from './types.js';\n\ntype GridWindow = {\n readonly cols: number;\n readonly rows: number;\n /** Spacer height in px (vertical orientations); 0 when CSS controls it. */\n readonly totalHeight: number;\n /** Spacer width in px (`row` orientation); 0 when CSS controls it. */\n readonly totalWidth: number;\n readonly startIndex: number;\n readonly endIndex: number;\n /** Distance between the left edges of adjacent columns (item width + gap). */\n readonly colStride: number;\n /** Distance between the top edges of adjacent rows (row height + gap). */\n readonly rowStride: number;\n /** `true` for `row` orientation — the list scrolls along the x axis. */\n readonly horizontal: boolean;\n};\n\nconst ITEM_SELECTOR = `:scope > *`;\n\nconst MIN_ITEM_SIZE = 16;\n\n/**\n * How long the host keeps the `[reflowing]` attribute after items are inserted\n * mid-list — long enough for the cell move-transition and the enter animation\n * to finish. Kept a touch above the default `--grid-list-item-move-duration`.\n */\nconst REFLOW_WINDOW_MS = 320;\n\n// `itemWidth` is the square's width; `rowHeight` is the full cell height\n// (square, plus the caption band in `labelled` style). `scrollOffset` is\n// `scrollTop` for `grid`/`column` and `scrollLeft` for `row`.\nfunction computeGridWindow(\n count: number,\n itemWidth: number,\n rowHeight: number,\n gap: number,\n viewportWidth: number,\n viewportHeight: number,\n scrollOffset: number,\n orientation: GridListOrientation,\n overscan = 2,\n): GridWindow {\n const w = Math.max(1, itemWidth);\n const h = Math.max(1, rowHeight);\n const g = Math.max(0, gap);\n const colStride = w + g;\n const rowStride = h + g;\n const offset = Math.max(0, scrollOffset);\n\n if (orientation === `row`) {\n const rows = count === 0 ? 0 : 1;\n const totalWidth = count === 0 ? 0 : (count - 1) * colStride + w;\n if (count === 0 || viewportWidth <= 0) {\n return { cols: count, rows, totalHeight: 0, totalWidth, startIndex: 0, endIndex: 0, colStride, rowStride, horizontal: true };\n }\n const firstVisible = Math.max(0, Math.floor(offset / colStride));\n const lastVisible = Math.ceil((offset + viewportWidth) / colStride);\n return {\n cols: count,\n rows,\n totalHeight: 0,\n totalWidth,\n startIndex: Math.max(0, firstVisible - overscan),\n endIndex: Math.min(count, lastVisible + overscan),\n colStride,\n rowStride,\n horizontal: true,\n };\n }\n\n const cols = orientation === `column`\n ? 1\n : Math.max(1, Math.floor((Math.max(0, viewportWidth) + g) / colStride));\n const rows = count === 0 ? 0 : Math.ceil(count / cols);\n const totalHeight = rows === 0 ? 0 : (rows - 1) * rowStride + h;\n\n if (count === 0 || viewportHeight <= 0) {\n return { cols, rows, totalHeight, totalWidth: 0, startIndex: 0, endIndex: 0, colStride, rowStride, horizontal: false };\n }\n\n const firstVisibleRow = Math.max(0, Math.floor(offset / rowStride));\n const lastVisibleRow = Math.ceil((offset + viewportHeight) / rowStride);\n const rowStart = Math.max(0, firstVisibleRow - overscan);\n const rowEnd = Math.min(rows, lastVisibleRow + overscan);\n\n return {\n cols,\n rows,\n totalHeight,\n totalWidth: 0,\n startIndex: rowStart * cols,\n endIndex: Math.min(count, rowEnd * cols),\n colStride,\n rowStride,\n horizontal: false,\n };\n}\n\nfunction columnOf(index: number, cols: number): number {\n return cols <= 1 ? 0 : index % cols;\n}\n\nfunction rowOf(index: number, cols: number): number {\n return cols <= 1 ? index : Math.floor(index / cols);\n}\n\n@customElement(`ixfx-grid-list`)\nexport class GridListElement<T = unknown> extends LitElement {\n static override styles = [\n themeFallbacks,\n tickledStyles,\n tickledItemStyles,\n // Both axes are registered; `render()` applies whichever one matches the\n // current orientation to the viewport (see the `scroll-fade-*` class there).\n scrollFadeStyles(`x`),\n scrollFadeStyles(`y`),\n listItemFadeKeyframes,\n listSearchStyles,\n css`\n :host {\n --grid-list-item-bg: var(--item-bg);\n --grid-list-radius: var(--radius-m);\n --grid-list-gap: var(--space-xs);\n --grid-list-padding: var(--space-xs);\n position: relative;\n display: block;\n height: 100%;\n min-height: 2em;\n overflow: hidden;\n user-select: none;\n background: var(--surface-3);\n color: var(--surface-3-text);\n border-radius: var(--radius-s);\n border: 1px solid var(--border);\n }\n :host(:focus-visible) {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n .viewport {\n position: relative;\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n padding: var(--grid-list-padding);\n /* Consumer control over the native scrollbar (both orientations): set\n --grid-list-scrollbar-width to \"none\" to hide it or \"thin\" to slim it.\n The container is also exposed as ::part(viewport). */\n scrollbar-width: var(--grid-list-scrollbar-width, auto);\n scrollbar-gutter: var(--grid-list-scrollbar-gutter, auto);\n scrollbar-color: var(--grid-list-scrollbar-color, auto);\n }\n :host([orientation=\"row\"]) .viewport {\n overflow-x: auto;\n overflow-y: hidden;\n }\n .spacer {\n position: relative;\n width: 100%;\n }\n .cell {\n position: absolute;\n inset: 0 auto auto 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: stretch;\n contain: layout style;\n border-radius: var(--grid-list-radius);\n }\n\n /* The square that holds the slotted content — the \"image well\". Its\n background is a set of consumer-settable variables so a Finder-style\n look is possible: on selection the caption takes the accent colouring\n while the well takes a tint of the surface colour. Each variable is\n unset by default, so the fallback (today's look) applies until a\n consumer opts in.\n --grid-list-thumb-bg idle well background\n --grid-list-thumb-bg-tickled under the cursor\n --grid-list-thumb-bg-selected when the cell is selected\n --grid-list-thumb-bg-selected-tickled selected + under the cursor\n --grid-list-thumb-selection-wash colour of the box-mode wash (default: --accent)\n --grid-list-thumb-selection-wash-opacity strength of that wash (default: 0.18; set 0 to drop it) */\n .thumb {\n position: relative;\n flex: 1;\n min-height: 0;\n display: flex;\n align-items: stretch;\n box-sizing: border-box;\n overflow: hidden;\n border-radius: 0;\n background: var(--grid-list-thumb-bg, transparent);\n border: 1px solid transparent;\n transition: background var(--transition), border-color var(--transition);\n }\n .thumb ::slotted(*) {\n flex: 1;\n min-width: 0;\n min-height: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n }\n .thumb ::slotted(*:empty)::after {\n content: \"Empty\";\n color: var(--surface-muted-text);\n font-size: var(--text-s);\n }\n ::slotted([hidden]) {\n display: none !important;\n }\n\n /* Selection / cursor wash — sits over the slotted content so it reads\n on photos and arbitrary DOM alike. Set\n --grid-list-thumb-selection-wash-opacity: 0 to drop it in favour of a\n --grid-list-thumb-bg-selected tint. */\n .thumb::after {\n content: \"\";\n position: absolute;\n inset: 0;\n pointer-events: none;\n border-radius: inherit;\n background: var(--grid-list-thumb-selection-wash, var(--accent));\n opacity: 0;\n transition: opacity var(--transition, 0.1s ease-out);\n }\n .cell.selected .thumb::after {\n opacity: var(--grid-list-thumb-selection-wash-opacity, 0.18);\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected .thumb {\n background: var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, transparent));\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected.tickled .thumb {\n background: var(--grid-list-thumb-bg-selected-tickled, var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, transparent)));\n }\n\n /* ---- Caption (base) ---- */\n .caption {\n box-sizing: border-box;\n flex: none;\n padding: 3px 6px;\n font-size: var(--text-s, 0.8rem);\n line-height: 1.3;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--surface-3-text);\n }\n :host([caption-align=\"left\"]) .caption { text-align: left; }\n :host([caption-align=\"right\"]) .caption { text-align: right; }\n /* Tickled captions swap their plain label for an ixfx-pan-text in loop\n mode so a truncated label scrolls instead of staying an ellipsis. The\n pan fills the caption band (flex in 'separate', block otherwise) and\n inherits its alignment. */\n .caption ixfx-pan-text {\n display: block;\n flex: 1;\n min-width: 0;\n max-width: 100%;\n font: inherit;\n color: inherit;\n }\n\n /* ---- Box modes (hidden / under / overlaid): the cell is one box with a\n single selection outline ---- */\n :host(:not([caption-style=\"separate\"])) .cell {\n background: var(--grid-list-item-bg);\n border: 1px solid transparent;\n overflow: hidden;\n transition: background var(--transition), border-color var(--transition);\n }\n :host(:not([caption-style=\"separate\"])) .cell.tickled,\n :host(:not([caption-style=\"separate\"]):not([disable-hover-tickle])) .cell:hover {\n background: var(--item-bg-tickled);\n border: var(--item-border-tickled);\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected.tickled {\n background: var(--item-bg-selected-tickled);\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n\n /* under: caption is a strip inside the box, below the content */\n :host([caption-style=\"under\"]) .caption {\n border-top: 1px solid var(--border, rgba(128, 128, 128, 0.3));\n background: var(--surface-4, transparent);\n }\n :host([caption-style=\"under\"][caption-position=\"top\"]) .caption {\n order: -1;\n border-top: none;\n border-bottom: 1px solid var(--border, rgba(128, 128, 128, 0.3));\n }\n\n /* overlaid: caption floats over the content */\n :host([caption-style=\"overlaid\"]) .caption {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n color: #fff;\n }\n :host([caption-style=\"overlaid\"][caption-position=\"top\"]) .caption {\n top: 0;\n bottom: auto;\n }\n :host([caption-style=\"overlaid\"][caption-position=\"middle\"]) .caption {\n top: 50%;\n bottom: auto;\n transform: translateY(-50%);\n }\n /* overlaid backdrop */\n :host([caption-style=\"overlaid\"][caption-backdrop=\"scrim\"]) .caption {\n background: rgba(0, 0, 0, 0.55);\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"]) .caption {\n background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n padding-block: 10px 4px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"][caption-position=\"top\"]) .caption {\n background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n padding-block: 4px 10px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"][caption-position=\"middle\"]) .caption {\n background: rgba(0, 0, 0, 0.5);\n padding-block: 3px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"blur\"]) .caption {\n background: rgba(20, 20, 20, 0.3);\n backdrop-filter: blur(6px);\n -webkit-backdrop-filter: blur(6px);\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"none\"]) .caption {\n background: none;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.7);\n }\n\n /* ---- separate mode: square + detached caption, each highlighted ---- */\n :host([caption-style=\"separate\"]) .thumb {\n flex: none;\n border-radius: var(--grid-list-radius);\n background: var(--grid-list-thumb-bg, var(--grid-list-item-bg));\n border: 1px solid transparent;\n }\n :host([caption-style=\"separate\"]) .cell.tickled .thumb,\n :host([caption-style=\"separate\"]:not([disable-hover-tickle])) .cell:hover .thumb {\n background: var(--grid-list-thumb-bg-tickled, var(--item-bg-tickled));\n border: var(--item-border-tickled);\n }\n :host([caption-style=\"separate\"]) .caption {\n display: flex;\n align-items: center;\n align-self: center;\n max-width: 100%;\n margin-top: 4px;\n border-radius: var(--radius-s, 4px);\n }\n :host([caption-style=\"separate\"][caption-align=\"left\"]) .caption { align-self: flex-start; }\n :host([caption-style=\"separate\"][caption-align=\"right\"]) .caption { align-self: flex-end; }\n :host([caption-style=\"separate\"][caption-position=\"top\"]) .caption {\n order: -1;\n margin-top: 0;\n margin-bottom: 4px;\n }\n /* Inset the selection ring (negative offset) so it is never clipped by the\n scroll viewport's overflow when the cell sits against an edge. */\n :host([caption-style=\"separate\"]) .cell.selected .thumb {\n background: var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, var(--grid-list-item-bg)));\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n :host([caption-style=\"separate\"]) .cell.selected.tickled .thumb {\n background: var(--grid-list-thumb-bg-selected-tickled, var(--item-bg-selected-tickled));\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n :host([caption-style=\"separate\"]) .cell.selected .caption {\n background: var(--accent);\n color: var(--accent-text, #000);\n }\n :host([caption-style=\"separate\"]) .cell.tickled .caption {\n background: var(--item-bg-tickled);\n outline: var(--item-border-tickled);\n }\n :host([caption-style=\"separate\"]) .cell.selected.tickled .caption {\n background: var(--item-bg-selected-tickled);\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n\n /* ---- Insertion / removal animation ----\n Active only while the host carries [reflowing] — the ~0.3s window after\n the child list changes mid-list (see #noteChildMutation). Kept out of\n the base rules so it never fires during scroll virtualisation, where\n cells are recycled to wildly different positions every frame. Placed\n last so it wins over the earlier cell transition rule regardless of\n specificity. Survivors slide to their new slot; a freshly inserted cell\n also fades in. (A removed item's element is already gone, so there's\n nothing left to fade — the gap simply closes as the others slide.) */\n :host([reflowing]) .cell {\n transition:\n transform var(--grid-list-item-move-duration, 200ms) cubic-bezier(0.2, 0, 0, 1),\n background var(--transition),\n border-color var(--transition);\n }\n .cell.entering {\n animation: ixfx-list-item-in var(--grid-list-item-move-duration, 200ms) ease both;\n }\n @media (prefers-reduced-motion: reduce) {\n :host([reflowing]) .cell { transition: background var(--transition), border-color var(--transition); }\n .cell.entering { animation: none; }\n }\n\n /* Drag-select (marquee) rectangle + covered-cell preview. The preview\n reuses the selection wash so covered cells read as \"about to be\n selected\". Style hooks: part=\"marquee\", --grid-list-marquee-border,\n --grid-list-marquee-fill. */\n .marquee {\n position: absolute;\n pointer-events: none;\n z-index: 5;\n border: 1px solid var(--grid-list-marquee-border, var(--accent));\n background: var(--grid-list-marquee-fill, color-mix(in srgb, var(--accent) 15%, transparent));\n }\n .cell.marquee .thumb::after {\n opacity: var(--grid-list-thumb-selection-wash-opacity, 0.18);\n }\n\n /* Native item drag origin cell. */\n .cell.dragging-origin {\n opacity: 0.6;\n }\n `,\n ];\n\n @property({ type: String, attribute: `selection-mode` })\n selectionMode: ListSelectionMode = `single`;\n\n @property({ type: String, attribute: `interaction-mode` })\n interactionMode: ListInteractionMode = `standard`;\n\n /**\n * Disable hover tickling: pointer hover no longer moves the cursor, fires\n * `list-tickle`, or changes where keyboard navigation resumes from. Keyboard\n * navigation, selection, and `focusKey()` are unaffected.\n */\n @property({ type: Boolean, attribute: `disable-hover-tickle`, reflect: true })\n disableHoverTickle = false;\n\n @property({ type: Number, attribute: `item-size` })\n itemSize = 160;\n\n @property({ type: Number })\n gap = 8;\n\n /**\n * Layout / scroll direction.\n * - `grid` (default): items wrap across as many columns as fit, scrolls vertically.\n * - `row`: a single row of items, scrolls horizontally.\n * - `column`: a single column of items, scrolls vertically.\n */\n @property({ type: String, reflect: true })\n orientation: GridListOrientation = `grid`;\n\n /**\n * How the caption relates to the content — see {@link GridListCaptionStyle}.\n * - `hidden`: no caption.\n * - `separate`: detached label below the square, each highlighted on its own.\n * - `under` (default): one box, content on top, caption strip below it inside.\n * - `overlaid`: caption floats over the content.\n */\n @property({ type: String, attribute: `caption-style`, reflect: true })\n captionStyle: GridListCaptionStyle = `under`;\n\n /** Horizontal alignment of the caption text: `left`, `middle` (default), `right`. */\n @property({ type: String, attribute: `caption-align`, reflect: true })\n captionAlign: GridListCaptionAlign = `middle`;\n\n /** Vertical placement of caption: `top`, `middle` (default), `bottom`. `middle` only has effect for `overlaid` style. */\n @property({ type: String, attribute: `caption-position`, reflect: true })\n captionPosition: GridListCaptionPosition = `bottom`;\n\n /** `overlaid` only — backdrop behind the caption: `scrim` (default), `gradient`, `blur`, `none`. */\n @property({ type: String, attribute: `caption-backdrop`, reflect: true })\n captionBackdrop: GridListCaptionBackdrop = `scrim`;\n\n /**\n * Height reserved for the caption in `separate` / `under` styles, in pixels.\n * Ignored by `overlaid` and `hidden`.\n */\n @property({ type: Number, attribute: `caption-height` })\n captionHeight = 24;\n\n @property({ type: String, attribute: `item-wrap` })\n itemWrap: `stop` | `wrap` = `stop`;\n\n /**\n * Element-mode filter predicate (also driven by incremental filter-search).\n * Light-DOM items for which it returns `false` are removed from layout and\n * navigation. For data mode use {@link itemFilterPredicate}.\n */\n @property({ attribute: false })\n filterPredicate: ((el: Element) => boolean) | undefined;\n\n /**\n * Data-mode filter predicate. Items for which it returns `false` are removed\n * from layout and navigation without any element being materialised.\n */\n @property({ attribute: false })\n itemFilterPredicate: ((item: T, index: number) => boolean) | undefined;\n\n /**\n * Space-separated subset of `navigate select filter` — limits which\n * incremental-search modes are offered (as commands and in-popover switches).\n * Unset ⇒ all three; empty ⇒ search disabled. See `docs/infra-incremental.md`.\n */\n /**\n * Enable native browser drag-and-drop for selectable items. When true,\n * selectable cells become draggable and the grid emits\n * `list-native-drag-start` when a drag begins.\n */\n @property({ type: Boolean, attribute: `items-draggable`, reflect: true })\n itemsDraggable = false;\n\n /**\n * Allow a marquee (region) selection to start from a cell's blank well area —\n * a press that lands on the cell's content container (`.content` / `.thumb`)\n * itself rather than on the item content, caption, or an interactive control.\n * The same press is prevented from starting the cell's native drag.\n *\n * Off by default. The consumer must ensure blank areas are not covered by\n * pointer-eventful slotted nodes (size content to its box and/or set\n * `pointer-events: none` on filler), otherwise the blank area still counts as\n * content and this has no effect.\n */\n @property({ type: Boolean, attribute: `marquee-from-cell-blank`, reflect: true })\n marqueeFromCellBlank = false;\n\n /**\n * Custom drag preview renderer. Receives the selection snapshot and returns\n * an element for `DataTransfer.setDragImage()` plus an optional pre-painted\n * canvas for native hosts. Synchronous by contract — pre-decode thumbnails\n * as selection changes. Defaults to the shared built-in preview.\n */\n @property({ attribute: false })\n dragPreviewRenderer: ListDragPreviewRenderer<T> | undefined;\n\n @property({ type: String, attribute: `search-modes`, reflect: true })\n searchModes: string | undefined;\n\n /**\n * Data items for data-backed mode. When set along with `itemAdapter`, the\n * component operates in data mode instead of element mode.\n */\n @property({ attribute: false })\n items: readonly T[] = [];\n\n /**\n * Adapter for data-backed mode. When set, the component renders items from\n * the `items` array using this adapter instead of projecting light-DOM children.\n */\n @property({ attribute: false })\n itemAdapter: GridListDataAdapterType<T> | undefined;\n\n @state() private _scrollTop = 0;\n @state() private _scrollLeft = 0;\n @state() private _viewportHeight = 0;\n @state() private _viewportWidth = 0;\n\n #viewportRef = createRef<HTMLDivElement>();\n\n #resizeObserver?: ResizeObserver;\n #mutationObserver?: MutationObserver;\n #scrollRaf = 0;\n #items: Element[] = [];\n #itemWrap: `stop` | `wrap` = `stop`;\n\n /** Items added mid-list that are still playing their enter animation. */\n #entering = new Set<Element>();\n /** Timer that ends the `[reflowing]` window opened by a mid-list insertion. */\n #reflowTimer = 0;\n\n /**\n * When cell geometry changes (zoom), the item nearest the viewport centre is\n * captured here in `willUpdate` and the scroll position is corrected in\n * `updated` so that item stays put — rather than the grid anchoring to its\n * top-left corner.\n */\n #zoomAnchor?: { index: number; lineFrac: number };\n\n /**\n * The active view over the items. Element mode projects light-DOM children\n * through named `<slot>`s (owned by {@link ElementGridListSource}); data mode\n * renders from {@link items} via {@link itemAdapter}. Everything else here\n * addresses items by effective index + key and never branches on the mode.\n *\n * Initialised eagerly (element mode) so the public getters — `count`,\n * `selectedKeys`, … — are safe to touch before the first Lit update. The\n * first `willUpdate` rebuilds it once the light DOM / `itemAdapter` is known.\n */\n #sourceElement: ElementGridListSource | undefined = new ElementGridListSource(this);\n #source: GridListSource = this.#sourceElement!;\n\n readonly selection = new ListSelectionController<string>({\n getOrderedItems: () => this.#source.keys(),\n isSelectable: (k) => {\n const i = this.#source.indexOfKey(k);\n return i >= 0 && this.#source.isSelectable(i);\n },\n getModes: () => ({ selectionMode: this.selectionMode, interactionMode: this.interactionMode }),\n getKey: k => k,\n onChange: (selected, previous) => {\n this._syncItemStates();\n this.requestUpdate();\n this.#emitSelect(selected, previous);\n },\n });\n\n readonly tickled = new TickledController<string>(this, {\n // `keys()` is in effective order, so position === effective index — avoid a\n // per-key `indexOfKey` lookup (that would make this O(n²) for large lists).\n getItems: () =>\n this.#source.keys().map((k, i) => ({\n id: k,\n enabled: this.#source.isSelectable(i),\n })),\n onTickle: (k) => {\n // Stop the previous caption pan immediately so two labels never scroll\n // together during the re-render window; `updated()` starts the new one.\n this.#stopActiveCaptionPan();\n if (k !== undefined)\n this.#emitItemEvent(`list-tickle`, k);\n },\n onStateChange: () => this._syncItemStates(),\n itemWrap: this.#itemWrap,\n hoverDisabled: () => this.disableHoverTickle || this.#dragSelect.isDragging || this.#nativeDrag.isDragging,\n });\n\n /** Live drag-select preview: covered keys + the surface-relative rect. */\n #marqueePreview: ReadonlySet<string> = new Set();\n #marqueeRect: DragSelectRect | undefined;\n\n /** Native item drag state: true while a drag is active. */\n #nativeDragging = false;\n /** Key of the cell that originated the native drag. */\n #dragOriginKey: string | undefined = undefined;\n /** Timer handle for post-drag click suppression. */\n #postDragSuppressTimer = 0;\n\n readonly #nativeDrag = new ListNativeDragController<T>(this, {\n source: `grid-list`,\n isEnabled: () => this.itemsDraggable && this.selectionMode !== `none` && this.#source.count > 0,\n resolveEventToKey: (target) => {\n if (target instanceof Element) {\n const cell = target.closest?.(`.cell`) as HTMLElement | null;\n const key = cell?.dataset.key;\n if (key)\n return key;\n const keyed = (target.closest?.(`[data-key]`) as HTMLElement | null)?.dataset.key\n ?? (target as HTMLElement).dataset?.key\n ?? keyForElement(target);\n if (keyed)\n return keyed;\n }\n return undefined;\n },\n prepareSelection: originKey => this.#prepareNativeDrag(originKey),\n getMetrics: () => ({\n itemSize: this.itemSize,\n captionStyle: this.captionStyle,\n captionHeight: this.captionHeight,\n rowHeight: this.#rowHeight(),\n }),\n getRenderer: () => this.dragPreviewRenderer,\n dispatch: detail => this._dispatch<ListNativeDragStartDetail<T>>(`list-native-drag-start`, detail, true),\n onActiveChange: (active, originKey) => {\n this.#nativeDragging = active;\n this.#dragOriginKey = active ? originKey : undefined;\n this.toggleAttribute(`data-native-dragging`, active);\n if (active) {\n const count = [...this.selection.selectedKeys].filter(k => !isSyntheticKey(k)).length;\n this.setAttribute(`aria-label`, count <= 1 ? `Dragging 1 item` : `Dragging ${count} items`);\n } else {\n this.removeAttribute(`aria-label`);\n }\n this.requestUpdate();\n },\n onEnd: () => {\n this.#clearNativeDragState();\n this.#startPostDragSuppressTimer();\n },\n syncLightDomDraggable: () => {\n for (const child of this.children) {\n if (child instanceof HTMLElement)\n child.draggable = this.itemsDraggable;\n }\n },\n shouldStart: event =>\n !(this.marqueeFromCellBlank && this.#isCellBlankPress(event)),\n });\n\n /** Origin rule + display-ordered entry resolution for native drag-out (both modes). */\n #prepareNativeDrag(originKey: string): { origin: ListDragEntry<T>; selected: Array<ListDragEntry<T>> } | undefined {\n const index = this.#source.indexOfKey(originKey);\n if (index < 0 || !this.#source.isSelectable(index))\n return undefined;\n if (!this.selection.selectedKeys.has(originKey))\n this.selection.replace(originKey);\n const ordered = this.#source.keys().filter(k => !isSyntheticKey(k) && this.selection.selectedKeys.has(k));\n const selected: Array<ListDragEntry<T>> = [];\n for (const key of ordered) {\n const entryIndex = this.#source.indexOfKey(key);\n if (entryIndex < 0)\n continue;\n const data = this.#source.resolveKeyToData(key) as T | undefined;\n const element = this.#source.resolveKeyToElement(key);\n const item = (data ?? element) as T | Element;\n if (item === undefined)\n continue;\n selected.push({\n key,\n index: entryIndex,\n item,\n ...(element ? { element } : {}),\n });\n }\n const origin = selected.find(entry => entry.key === originKey);\n if (!origin)\n return undefined;\n return { origin, selected };\n }\n\n /**\n * The single caption pan-text currently scrolling. At most one caption is\n * a pan-text in loop mode at a time — when tickle moves, the old one is\n * stopped before the new one starts (see `#activateTickledPan`).\n */\n #activeCaptionPan: PanTextElement | null = null;\n\n readonly #dragSelect = new ListDragSelectController<string>(this, {\n getSurface: () => this.#viewportRef.value,\n isEnabled: () =>\n this.selection.canDragSelect()\n && this.#source.count > 0\n && !this.hasAttribute(`disable-drag-select`),\n hitTest: rect => this.#marqueeHitTest(rect),\n getBaseSelection: () => this.selection.selected,\n onPreview: (preview, rect) => {\n this.#marqueePreview = preview;\n this.#marqueeRect = rect;\n this.requestUpdate();\n },\n onCommit: (finalSet) => {\n this.selection.applyDragSelection(finalSet);\n this.#marqueePreview = new Set();\n this.#marqueeRect = undefined;\n this.requestUpdate();\n },\n autoScroll: (dx, dy) => {\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n if (dx !== 0) {\n vp.scrollLeft += dx;\n this._scrollLeft = vp.scrollLeft;\n }\n if (dy !== 0) {\n vp.scrollTop += dy;\n this._scrollTop = vp.scrollTop;\n }\n },\n shouldStart: (event) => {\n if (this.marqueeFromCellBlank && this.#isCellBlankPress(event))\n return true;\n for (const node of event.composedPath()) {\n if (node instanceof Element && node.classList.contains(`cell`))\n return false;\n }\n return true;\n },\n });\n\n /**\n * True when a pointer / drag event landed on a cell's blank well: the event\n * target is the cell's content container itself (`.content` / `.thumb`) — i.e.\n * nothing of the item's own content sat under the pointer. Relies on the\n * consumer setting `pointer-events: none` on the blank filler around its cell\n * content so that filler presses land on the well, not on the item element.\n */\n #isCellBlankPress(event: Event): boolean {\n for (const node of event.composedPath()) {\n if (!(node instanceof Element))\n continue;\n if (node.classList.contains(`caption`))\n return false;\n if (node.matches?.(`input,button,a,select,textarea,[contenteditable]`))\n return false;\n // Reached the well with nothing between it and the event target.\n if (node.classList.contains(`content`) || node.classList.contains(`thumb`))\n return true;\n if (node.classList.contains(`cell`))\n return false; // reached the cell without a well — be conservative\n // Any other element seen before the well is the item's own content\n // (glyph / thumbnail / caption text) — this press belongs to the item.\n return false;\n }\n return false;\n }\n\n /**\n * Map a surface-relative (viewport-visible) rect to covered item keys using\n * the same `computeGridWindow` geometry the renderer uses — pure arithmetic,\n * so virtualized off-screen items are covered without DOM measurement.\n */\n #marqueeHitTest(rect: DragSelectRect): string[] {\n const count = this.#source.count;\n if (count === 0)\n return [];\n const horizontal = this.orientation === `row`;\n const win = computeGridWindow(\n count,\n this.itemSize,\n this.#rowHeight(),\n this.gap,\n Math.max(1, this._viewportWidth),\n Math.max(1, this._viewportHeight),\n horizontal ? this._scrollLeft : this._scrollTop,\n this.orientation,\n 0,\n );\n const out: number[] = [];\n if (horizontal) {\n const x0 = rect.x + this._scrollLeft;\n const x1 = x0 + rect.width;\n const lo = Math.max(0, Math.floor(x0 / win.colStride));\n const hi = Math.min(count - 1, Math.floor(x1 / win.colStride));\n for (let i = lo; i <= hi; i++)\n out.push(i);\n } else {\n const x0 = rect.x + this._scrollLeft;\n const x1 = x0 + rect.width;\n const y0 = rect.y + this._scrollTop;\n const y1 = y0 + rect.height;\n const colLo = Math.max(0, Math.floor(x0 / win.colStride));\n const colHi = Math.min(win.cols - 1, Math.floor(x1 / win.colStride));\n const rowLo = Math.max(0, Math.floor(y0 / win.rowStride));\n const rowHi = Math.floor(y1 / win.rowStride);\n for (let row = rowLo; row <= rowHi; row++) {\n for (let col = colLo; col <= colHi; col++) {\n const index = row * win.cols + col;\n if (index >= 0 && index < count)\n out.push(index);\n }\n }\n }\n const keys: string[] = [];\n for (const index of out) {\n const key = this.#source.keyAt(index);\n if (!key || isSyntheticKey(key))\n continue;\n if (!this.#source.isSelectable(index))\n continue;\n keys.push(key);\n }\n return keys;\n }\n\n /**\n * Incremental search (navigate / select / filter). Element- or data-backed\n * depending on the mode; the mode-agnostic surface (`renderField`, `open`,\n * `close`, `setModes`, …) is the same either way. See `docs/infra-incremental.md`.\n */\n search!: ListSearchController<unknown>;\n\n #searchMode: `element` | `data` | undefined;\n #searchFilterKeys: ReadonlySet<string> | undefined;\n\n /** (Re)build {@link search} for the current mode; a no-op if it already matches. */\n #ensureSearch(): void {\n const mode = this.itemAdapter !== undefined ? `data` : `element`;\n if (this.#searchMode === mode && this.search !== undefined)\n return;\n\n const previous = this.search as ListSearchController<unknown> | undefined;\n if (previous) {\n previous.hostDisconnected();\n this.removeController(previous);\n }\n\n this.search = (mode === `data`\n ? new ListSearchController<DataListSearchItem>(this, {\n adapter: createDataListSearchAdapter(this, {\n rawCount: () => this.#source?.rawCount ?? 0,\n rawKeyAt: i => this.#source?.rawKeyAt(i) ?? ``,\n rawSearchTextAt: i => this.#source?.rawSearchTextAt(i) ?? ``,\n onFilterChange: (keys) => {\n this.#searchFilterKeys = keys;\n this.#source?.setFilters({ searchKeys: keys });\n this.requestUpdate();\n void this.updateComplete.then(() => this.#emitViewportChange());\n },\n onActivate: key => this.#onCellActivate(key),\n getHighlightRoot: () => this.renderRoot as ShadowRoot | Element,\n }),\n })\n : new ListSearchController<Element>(this, {\n adapter: createElementListSearchAdapter(this, {\n itemSelector: ITEM_SELECTOR,\n getLabel: el =>\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? el.getAttribute(`data-search-label`)\n ?? el.textContent?.trim()\n ?? ``,\n highlightKey: `grid-list-search`,\n }),\n })) as ListSearchController<unknown>;\n this.#searchMode = mode;\n }\n\n #searchRegistry: CommandRegistry<unknown> | undefined;\n #unregisterSearchCommands: (() => void) | undefined;\n\n /** Command registry carrying this grid's `list.search.*` commands. */\n get registry(): CommandRegistry<unknown> | undefined {\n return this.#searchRegistry;\n }\n\n /** Effective search modes: this component's capability (all three) ∩ the `search-modes` attribute. */\n #effectiveSearchModes(): ListSearchMode[] {\n const raw = this.searchModes?.trim();\n if (raw === undefined)\n return [...LIST_SEARCH_MODES];\n const requested = new Set(raw.split(/\\s+/));\n return LIST_SEARCH_MODES.filter(m => requested.has(m));\n }\n\n #syncSearchCommands(): void {\n if (!this.#searchRegistry || !this.search)\n return;\n this.search.setModes(this.#effectiveSearchModes());\n this.#unregisterSearchCommands?.();\n this.#unregisterSearchCommands = registerListSearchCommands(this.#searchRegistry, this.search);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(`tabindex`)) {\n this.tabIndex = 0;\n }\n if (!this.hasAttribute(`role`)) {\n this.setAttribute(`role`, `listbox`);\n }\n this.#syncAriaMultiselectable();\n // Reflect caption defaults up-front so the `:host([caption-*])` style rules\n // apply even when the consumer never sets the attributes.\n for (const [attr, value] of [\n [`caption-style`, this.captionStyle],\n [`caption-align`, this.captionAlign],\n [`caption-position`, this.captionPosition],\n [`caption-backdrop`, this.captionBackdrop],\n ] as const) {\n if (!this.hasAttribute(attr)) {\n this.setAttribute(attr, value);\n }\n }\n this.addEventListener(`keydown`, this._onKeyDown as EventListener);\n this.#mutationObserver ??= new MutationObserver(records => this.#onChildrenChanged(records));\n this.#mutationObserver.observe(this, { childList: true, attributeFilter: [`hidden`] });\n this.#searchRegistry ??= createCommandRegistry();\n this.#ensureSearch();\n this.#syncSearchCommands();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#stopActiveCaptionPan();\n this.removeEventListener(`keydown`, this._onKeyDown as EventListener);\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = undefined;\n this.#mutationObserver?.disconnect();\n this.#cancelScrollRaf();\n this.#unregisterSearchCommands?.();\n this.#unregisterSearchCommands = undefined;\n this.#searchRegistry = undefined;\n if (this.#reflowTimer) {\n clearTimeout(this.#reflowTimer);\n this.#reflowTimer = 0;\n }\n if (this.#nativeDragging || this.#nativeDrag.isDragging) {\n this.#clearNativeDragState();\n }\n }\n\n #onChildrenChanged(records?: MutationRecord[]): void {\n const previousLength = this.#items.length;\n this.#syncItems();\n // Prune selection / cursor for elements that were actually removed. Read the\n // records directly rather than diffing `keys()` before/after: a pending\n // `requestUpdate()` can let `updated()` re-sync the source before this\n // callback runs, which would hide the removal from a diff.\n const removedKeys: string[] = [];\n for (const record of records ?? []) {\n for (const node of record.removedNodes) {\n if (node.nodeType !== Node.ELEMENT_NODE)\n continue;\n const key = keyForElement(node as Element);\n if (key !== undefined)\n removedKeys.push(key);\n }\n }\n if (removedKeys.length > 0) {\n const present = new Set(this.#source.keys());\n const gone = removedKeys.filter(k => !present.has(k));\n if (gone.length > 0)\n this.selection.removeKeys(gone, k => k);\n const tickledId = this.tickled.tickledId;\n if (tickledId && gone.includes(tickledId))\n this.tickled.focus(undefined);\n }\n this._syncItemStates();\n this.#noteChildMutation(previousLength, records);\n this.requestUpdate();\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n\n /**\n * When the child list changes mid-list — not a first populate or a wholesale\n * replace — mark any newcomers for an enter animation and open a short\n * `[reflowing]` window so the cells that shift slide to their new position\n * instead of snapping. Removals get the same window (the survivors slide to\n * close the gap). The window is bounded in time so the transform transition\n * never bleeds into scroll virtualisation.\n *\n * Reads the `MutationRecord`s directly rather than diffing `#items`, because a\n * `requestUpdate()` between the DOM change and this callback (e.g. a caller\n * that clears the selection before removing) lets `updated()` re-sync `#items`\n * first, which would hide the change from a naive diff.\n */\n #noteChildMutation(previousLength: number, records?: MutationRecord[]): void {\n if (!this.hasUpdated || !records || records.length === 0)\n return;\n const currentSet = new Set(this.#items);\n const added: Element[] = [];\n let removedCount = 0;\n for (const record of records) {\n for (const node of record.addedNodes) {\n if (node.nodeType === Node.ELEMENT_NODE && currentSet.has(node as Element))\n added.push(node as Element);\n }\n for (const node of record.removedNodes) {\n if (node.nodeType === Node.ELEMENT_NODE)\n removedCount++;\n }\n }\n // Nothing to animate, a first populate, or a wholesale replace (every\n // current item is new) — leave it alone.\n if (added.length === 0 && removedCount === 0)\n return;\n if (previousLength === 0 && removedCount === 0)\n return;\n if (added.length > 0 && added.length === this.#items.length)\n return;\n for (const el of added)\n this.#entering.add(el);\n this.toggleAttribute(`reflowing`, true);\n if (this.#reflowTimer)\n clearTimeout(this.#reflowTimer);\n this.#reflowTimer = window.setTimeout(() => {\n this.#reflowTimer = 0;\n this.#entering.clear();\n this.toggleAttribute(`reflowing`, false);\n this.requestUpdate();\n }, REFLOW_WINDOW_MS);\n }\n\n #emitViewportChange(): void {\n this._dispatch<GridListViewportChangeDetail>(`grid-list-viewport-change`, {\n renderedKeys: this.renderedKeys(),\n visibleKeys: this.visibleKeys(),\n });\n }\n\n protected override firstUpdated(): void {\n if (!this.#source)\n this.#rebuildSource();\n const el = this.#viewportRef.value;\n if (!el)\n return;\n this.#resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const w = entry.contentRect.width;\n const h = entry.contentRect.height;\n // A zero-sized observation (e.g. an inactive dock tab) must never\n // replace the last usable geometry — see #measureViewport / refreshLayout.\n if (w <= 0 || h <= 0)\n return;\n this._viewportWidth = w;\n this._viewportHeight = h;\n }\n });\n this.#resizeObserver.observe(el);\n this.#measureViewport(false);\n this.#syncItems();\n this.requestUpdate();\n this.#nativeDrag.refreshDraggable();\n }\n\n /** (Re)construct {@link #source} for the current mode and re-apply the filters. */\n #rebuildSource(): void {\n if (this.itemAdapter !== undefined) {\n this.#source = new DataGridListSource<T>(this.items, this.itemAdapter);\n this.#sourceElement = undefined;\n } else {\n this.#sourceElement = new ElementGridListSource(this);\n this.#source = this.#sourceElement;\n }\n this.#applyFilters();\n if (this.#searchFilterKeys)\n this.#source.setFilters({ searchKeys: this.#searchFilterKeys });\n }\n\n /** Push the current filter predicate into whichever source is active. */\n #applyFilters(): void {\n if (this.#source instanceof ElementGridListSource) {\n const fp = this.filterPredicate;\n const src = this.#source;\n src.setFilters({ predicate: fp ? i => fp(src.rawElementAt(i)!) : undefined });\n this.#items = src.effectiveElements();\n } else if (this.#source instanceof DataGridListSource) {\n const ip = this.itemFilterPredicate;\n const src = this.#source as DataGridListSource<T>;\n src.setFilters({ predicate: ip ? i => ip(src.rawItemAt(i) as T, i) : undefined });\n }\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has(`searchModes`)) {\n this.#syncSearchCommands();\n }\n if (changed.has(`filterPredicate`) || changed.has(`itemFilterPredicate`)) {\n this.#applyFilters();\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n\n const dataModeChanged = changed.has(`items`) || changed.has(`itemAdapter`);\n if (dataModeChanged) {\n this.#zoomAnchor = undefined;\n const prevKeys = this.#source?.keys() ?? [];\n const modeFlipped = (this.itemAdapter !== undefined)\n !== (this.#source instanceof DataGridListSource);\n this.#rebuildSource();\n const nextKeys = this.#source.keys();\n const nextKeySet = new Set(nextKeys);\n const removedKeys = prevKeys.filter(k => !nextKeySet.has(k));\n if (removedKeys.length > 0)\n this.selection.removeKeys(removedKeys, k => k);\n const tickledId = this.tickled.tickledId;\n if (tickledId && !nextKeySet.has(tickledId))\n this.tickled.focus(undefined);\n this._syncItemStates();\n // No requestUpdate() here — we're already in willUpdate, the render that\n // follows picks up the rebuilt source.\n void this.updateComplete.then(() => this.#emitViewportChange());\n if (modeFlipped) {\n this.#ensureSearch();\n this.#syncSearchCommands();\n }\n this.search?.refresh();\n }\n\n if (changed.has(`itemSize`) || changed.has(`gap`)) {\n this.itemSize = Math.max(MIN_ITEM_SIZE, Math.round(this.itemSize));\n this.gap = Math.max(0, Math.round(this.gap));\n }\n if (changed.has(`captionHeight`)) {\n this.captionHeight = Math.max(0, Math.round(this.captionHeight));\n }\n if (changed.has(`itemWrap`)) {\n this.#itemWrap = this.itemWrap;\n }\n\n const geometryChanged = changed.has(`itemSize`) || changed.has(`gap`)\n || changed.has(`captionStyle`) || changed.has(`captionHeight`)\n || changed.has(`orientation`);\n if (geometryChanged && this.hasUpdated && this.#source.count > 0) {\n const prevOrientation = (changed.get(`orientation`) as GridListOrientation | undefined) ?? this.orientation;\n const horizontal = prevOrientation === `row`;\n const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;\n const prevExtent = horizontal ? this._viewportWidth : this._viewportHeight;\n if (prevExtent > 0 && prevOffset > 1) {\n const prevItemSize = (changed.get(`itemSize`) as number | undefined) ?? this.itemSize;\n const prevGap = (changed.get(`gap`) as number | undefined) ?? this.gap;\n const prevCaptionStyle = (changed.get(`captionStyle`) as GridListCaptionStyle | undefined) ?? this.captionStyle;\n const prevCaptionHeight = (changed.get(`captionHeight`) as number | undefined) ?? this.captionHeight;\n this.#captureCentreAnchor(prevOffset, prevExtent, prevItemSize, prevGap, prevCaptionStyle, prevCaptionHeight, prevOrientation);\n }\n }\n }\n\n #syncAriaMultiselectable(): void {\n this.setAttribute(\n `aria-multiselectable`,\n this.selection.canSelectMultiple() ? `true` : `false`,\n );\n }\n\n /** Full cell height: the square, plus a caption band in `separate` / `under`. */\n #rowHeight(): number {\n const captionBand = this.captionStyle === `separate` || this.captionStyle === `under`;\n return this.itemSize + (captionBand ? this.captionHeight : 0);\n }\n\n #captionFor(el: Element): string {\n return (\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? ``\n );\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n super.updated(changed);\n this.#syncItems();\n if (changed.has(`selectionMode`) || changed.has(`interactionMode`)) {\n this.selection.clearAnchor();\n this.#syncAriaMultiselectable();\n }\n if (changed.has(`itemsDraggable`)) {\n this.#nativeDrag.refreshDraggable();\n }\n if (changed.has(`orientation`)) {\n // Reset the axis that's no longer scrollable so a later switch back\n // doesn't inherit a stale offset.\n const vp = this.#viewportRef.value;\n if (vp) {\n if (this.orientation === `row`) {\n vp.scrollTop = 0;\n this._scrollTop = 0;\n } else {\n vp.scrollLeft = 0;\n this._scrollLeft = 0;\n }\n }\n }\n const vp = this.#viewportRef.value;\n if (vp) {\n if (Math.abs(vp.scrollTop - this._scrollTop) > 0.5) {\n vp.scrollTop = this._scrollTop;\n }\n if (Math.abs(vp.scrollLeft - this._scrollLeft) > 0.5) {\n vp.scrollLeft = this._scrollLeft;\n }\n }\n this.#applyZoomAnchor();\n this.#activateTickledPan();\n }\n\n /** Re-anchor the scroll so the item captured in `willUpdate` stays centred. */\n #applyZoomAnchor(): void {\n if (!this.#zoomAnchor)\n return;\n const { index, lineFrac } = this.#zoomAnchor;\n this.#zoomAnchor = undefined;\n\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n const win = this.#currentWindow();\n\n if (win.horizontal) {\n if (this._viewportWidth <= 0)\n return;\n const targetCenter = (index + lineFrac) * win.colStride;\n const maxScroll = Math.max(0, win.totalWidth - this._viewportWidth);\n const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportWidth / 2));\n if (Math.abs(vp.scrollLeft - next) > 0.5) {\n vp.scrollLeft = next;\n this._scrollLeft = next;\n }\n return;\n }\n\n if (this._viewportHeight <= 0)\n return;\n const line = win.cols > 0 ? Math.floor(index / win.cols) : 0;\n const targetCenter = (line + lineFrac) * win.rowStride;\n const maxScroll = Math.max(0, win.totalHeight - this._viewportHeight);\n const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportHeight / 2));\n if (Math.abs(vp.scrollTop - next) > 0.5) {\n vp.scrollTop = next;\n this._scrollTop = next;\n }\n }\n\n #captureCentreAnchor(prevOffset: number, prevExtent: number, prevItemSize: number, prevGap: number, prevCaptionStyle: GridListCaptionStyle, prevCaptionHeight: number, prevOrientation: GridListOrientation): void {\n const count = this.#source?.count ?? 0;\n if (count === 0)\n return;\n const prevBand = prevCaptionStyle === `separate` || prevCaptionStyle === `under`;\n const prevRowHeight = prevItemSize + (prevBand ? prevCaptionHeight : 0);\n const horizontal = prevOrientation === `row`;\n const prev = computeGridWindow(\n count,\n prevItemSize,\n prevRowHeight,\n prevGap,\n this._viewportWidth,\n this._viewportHeight,\n prevOffset,\n prevOrientation,\n );\n const mainStride = horizontal ? prev.colStride : prev.rowStride;\n const centerLine = (prevOffset + prevExtent / 2) / mainStride;\n const lineFloor = Math.max(0, Math.floor(centerLine));\n const index = horizontal\n ? Math.min(count - 1, lineFloor)\n : Math.min(\n count - 1,\n lineFloor * prev.cols + Math.max(0, Math.floor((prev.cols - 1) / 2)),\n );\n this.#zoomAnchor = { index, lineFrac: centerLine - lineFloor };\n }\n\n /**\n * Re-read the viewport after an ancestor's visibility/layout changed.\n * Safe while hidden (zero-sized reads are ignored); forces a repaint of the\n * virtual window even when the size is unchanged.\n */\n refreshLayout(): void {\n this.#measureViewport(true);\n }\n\n /** Alias of {@link refreshLayout}. */\n remeasure(): void {\n this.#measureViewport(true);\n }\n\n #measureViewport(forceRender = false): void {\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n const w = vp.clientWidth;\n const h = vp.clientHeight;\n if (w <= 0 || h <= 0)\n return;\n const horizontal = this.orientation === `row`;\n const changed = w !== this._viewportWidth || h !== this._viewportHeight;\n if (changed) {\n const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;\n const prevExtent = horizontal ? w : h;\n this.#captureCentreAnchor(\n prevOffset,\n prevExtent,\n this.itemSize,\n this.gap,\n this.captionStyle,\n this.captionHeight,\n this.orientation,\n );\n this._viewportWidth = w;\n this._viewportHeight = h;\n }\n if (forceRender && !changed) {\n this.#captureCentreAnchor(\n horizontal ? this._scrollLeft : this._scrollTop,\n horizontal ? w : h,\n this.itemSize,\n this.gap,\n this.captionStyle,\n this.captionHeight,\n this.orientation,\n );\n this.requestUpdate();\n }\n if (changed || forceRender) {\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n }\n\n /**\n * Element mode only: re-read the light DOM into the source and refresh the\n * `#items` cache + filter. A no-op in data mode (the source is rebuilt through\n * `#rebuildSource` when `items` / `itemAdapter` change).\n */\n #syncItems(): void {\n if (this.#source instanceof ElementGridListSource) {\n this.#source.refresh();\n this.#applyFilters();\n }\n }\n\n get count(): number {\n return this.#source.count;\n }\n\n /**\n * Number of cells currently rendered in the shadow DOM. With virtualization\n * this is roughly the visible rows plus overscan, regardless of how large\n * `count` is — useful for demos/diagnostics.\n */\n get renderedCount(): number {\n return this.renderRoot.querySelectorAll(`.cell`).length;\n }\n\n get selectedItems(): ReadonlySet<Element> {\n const els = new Set<Element>();\n for (const key of this.selection.selectedKeys) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n els.add(el);\n }\n return els;\n }\n\n /**\n * The selection as stable `data-key` / `data-value` strings. Auto-assigned\n * keys for keyless light-DOM items are omitted (they are not a stable contract\n * for the consumer).\n */\n get selectedKeys(): ReadonlySet<string> {\n const out = new Set<string>();\n for (const k of this.selection.selectedKeys) {\n if (!isSyntheticKey(k))\n out.add(k);\n }\n return out;\n }\n\n select(item: Element): void {\n const key = keyForElement(item);\n if (key)\n this.selection.replace(key);\n }\n\n selectMany(items: Iterable<Element>): void {\n const keys: string[] = [];\n for (const item of items) {\n const key = keyForElement(item);\n if (key)\n keys.push(key);\n }\n this.selection.selectMany(keys);\n }\n\n deselect(item: Element): void {\n const key = keyForElement(item);\n if (key)\n this.selection.deselect(key);\n }\n\n clearSelection(): void {\n this.selection.clear();\n }\n\n selectAll(): void {\n if (this.selection.canSelectAll()) {\n this.selection.selectAll();\n }\n }\n\n /**\n * Replace the selection with the items carrying these keys. Unknown keys are\n * ignored; survives the host rebuilding the item set. Requires each item to\n * have a `data-key` (or `data-value`).\n */\n selectKeys(keys: Iterable<string>): void {\n this.selection.selectKeys(keys, k => k);\n }\n\n /** Add items by key to the selection (multi-select modes only). */\n addSelectedKeys(keys: Iterable<string>): void {\n this.selection.addKeys(keys, k => k);\n }\n\n /** Remove items by key from the selection. */\n removeSelectedKeys(keys: Iterable<string>): void {\n this.selection.removeKeys(keys, k => k);\n }\n\n /**\n * Data mode only: raw index of `key` in `this.items`, or `-1`. Data-mode keys\n * come straight from the adapter, so this is exact even under a filter/search.\n */\n #rawIndexOfKey(key: string): number {\n const adapter = this.itemAdapter;\n if (!adapter)\n return -1;\n return this.items.findIndex((it, i) => adapter.key(it, i) === key);\n }\n\n /**\n * Data mode: replace the whole item array. Selection and cursor keep any key\n * that is still present; keys that vanish are dropped (one `list-select`).\n * A no-op in element mode.\n */\n setItems(items: readonly T[]): void {\n if (this.itemAdapter)\n this.items = items;\n }\n\n /**\n * Data mode: append items to the end. Scroll position, selection and cursor\n * are untouched; appended items don't play the mid-list `[reflowing]` slide.\n * A no-op in element mode.\n */\n appendItems(items: readonly T[]): void {\n if (this.itemAdapter && items.length > 0)\n this.items = [...this.items, ...items];\n }\n\n /**\n * Data mode: replace the item carrying `key`. A visible cell re-renders in\n * place (the keyed subtree is kept); an offscreen item shows its new content\n * when scrolled into view. Scroll and selection are untouched. Unknown keys\n * are ignored.\n */\n updateItem(key: string, item: T): void {\n if (!this.itemAdapter)\n return;\n const idx = this.#rawIndexOfKey(key);\n if (idx < 0)\n return;\n const next = [...this.items];\n next[idx] = item;\n this.items = next;\n }\n\n /**\n * Data mode: remove the items carrying these keys. Removed keys are dropped\n * from selection and cursor (via the `items` change). A no-op in element mode.\n */\n removeItems(keys: Iterable<string>): void {\n if (!this.itemAdapter)\n return;\n const adapter = this.itemAdapter;\n const keySet = new Set(keys);\n this.items = this.items.filter((it, i) => !keySet.has(adapter.key(it, i)));\n }\n\n /**\n * Data mode: drop every item. Selection and cursor are reset and one\n * `list-select` with empty sets is emitted. A no-op in element mode.\n */\n clearItems(): void {\n if (!this.itemAdapter)\n return;\n this.selection.reset();\n this.tickled.focus(undefined);\n this.items = [];\n this.#emitSelect(new Set(), new Set());\n }\n\n /** Move the cursor to the item with this key and scroll it into view. */\n focusKey(key: string): void {\n const index = this.#source.indexOfKey(key);\n if (index < 0)\n return;\n this.tickled.focus(key);\n this.#scrollItemIntoView(key);\n }\n\n /** The key of the item under the cursor, or `undefined`. */\n get tickledKey(): string | undefined {\n return this.tickled.tickledId;\n }\n\n /** Element mode: the light-DOM element carrying `key`, or `undefined`. */\n getItem(key: string): Element | undefined {\n return this.#source.resolveKeyToElement(key);\n }\n\n /** Element mode: the light-DOM element at effective index `index`. */\n getItemByIndex(index: number): Element | undefined {\n return this.#items[index];\n }\n\n /** Data mode: the data value carrying `key`, or `undefined`. */\n getData(key: string): T | undefined {\n return this.#source.resolveKeyToData(key) as T | undefined;\n }\n\n getKey(item: Element): string | undefined {\n return keyForElement(item);\n }\n\n /**\n * Keys of items in the rendered window (viewport + overscan) — the priority\n * set for prefetching. Use {@link visibleKeys} for the strict viewport\n * intersection. Auto-assigned keyless-item keys are omitted.\n */\n renderedKeys(): string[] {\n return this.#windowKeys(this.#currentWindow());\n }\n\n /**\n * Keys of items actually intersecting the viewport (no overscan).\n * Auto-assigned keyless-item keys are omitted.\n */\n visibleKeys(): string[] {\n return this.#windowKeys(this.#currentWindow(true));\n }\n\n #windowKeys(win: GridWindow): string[] {\n return this.#source\n .keys()\n .slice(win.startIndex, win.endIndex)\n .filter(k => !isSyntheticKey(k));\n }\n\n #currentWindow(noOverscan = false): GridWindow {\n const overscan = noOverscan ? 0 : 2;\n return computeGridWindow(\n this.#source.count,\n this.itemSize,\n this.#rowHeight(),\n this.gap,\n this._viewportWidth,\n this._viewportHeight,\n this.orientation === `row` ? this._scrollLeft : this._scrollTop,\n this.orientation,\n overscan,\n );\n }\n\n /** Adjust the scroll offset so `key` is fully within the viewport. */\n #scrollItemIntoView(key: string): void {\n const index = this.#source.indexOfKey(key);\n const vp = this.#viewportRef.value;\n if (index < 0 || !vp)\n return;\n const win = this.#currentWindow();\n\n if (win.horizontal) {\n const left = index * win.colStride;\n const right = left + this.itemSize;\n const viewLeft = vp.scrollLeft;\n let next = viewLeft;\n if (left < viewLeft)\n next = left;\n else if (right > viewLeft + this._viewportWidth)\n next = right - this._viewportWidth;\n if (next !== viewLeft) {\n vp.scrollLeft = next;\n this._scrollLeft = next;\n }\n return;\n }\n\n const row = win.cols > 0 ? Math.floor(index / win.cols) : 0;\n const top = row * win.rowStride;\n const bottom = top + this.#rowHeight();\n const viewTop = vp.scrollTop;\n let next = viewTop;\n if (top < viewTop)\n next = top;\n else if (bottom > viewTop + this._viewportHeight)\n next = bottom - this._viewportHeight;\n if (next !== viewTop) {\n vp.scrollTop = next;\n this._scrollTop = next;\n }\n }\n\n private _syncItemStates(): void {\n const selected = this.selection.selectedKeys;\n for (const el of this.#items) {\n const key = keyForElement(el);\n el.toggleAttribute(`data-tickled`, key !== undefined && this.tickled.isTickled(key));\n el.toggleAttribute(`data-selected`, key !== undefined && selected.has(key));\n }\n this.setAttribute(`data-input-mode`, this.tickled.inputMode);\n }\n\n #emitSelect(selected: ReadonlySet<string>, previous: ReadonlySet<string>): void {\n const selectedEls = new Set<Element>();\n const previousEls = new Set<Element>();\n for (const key of selected) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n selectedEls.add(el);\n }\n for (const key of previous) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n previousEls.add(el);\n }\n this._dispatch<GridListSelectDetail>(`list-select`, {\n selected: selectedEls,\n previous: previousEls,\n selectedKeys: this.selectedKeys,\n previousKeys: new Set([...previous].filter(k => !isSyntheticKey(k))),\n });\n }\n\n #emitItemEvent(name: `list-tickle` | `list-item-click` | `list-activate`, key: string): void {\n const index = this.#source.indexOfKey(key);\n const element = this.#source.resolveKeyToElement(key);\n const item = element ?? this.#source.resolveKeyToData(key);\n this._dispatch<GridListItemClickDetail>(name, { item, key, index, element });\n }\n\n private _dispatch<T>(name: string, detail: T, cancelable = false): boolean {\n return this.dispatchEvent(\n new CustomEvent<T>(name, {\n detail,\n bubbles: true,\n composed: true,\n cancelable,\n }),\n );\n }\n\n /** Selected keys, snapshotted once per render so the cell renderers don't each rebuild the set. */\n #selectedSnapshot: ReadonlySet<string> = new Set();\n\n #marqueeStyle(rect: DragSelectRect): string {\n return `left:${rect.x}px;top:${rect.y}px;width:${Math.max(0, rect.width)}px;height:${Math.max(0, rect.height)}px`;\n }\n\n protected override render(): ReturnType<typeof html> {\n const win = this.#currentWindow();\n this.#selectedSnapshot = this.selection.selectedKeys;\n const spacerStyle = win.horizontal\n ? `width:${win.totalWidth}px;height:100%`\n : `height:${win.totalHeight}px`;\n // Fade the edge that can still be scrolled towards (see ../styles/scroll-fade.ts).\n const scrollFade = win.horizontal ? `scroll-fade-x` : `scroll-fade-y`;\n return html`\n <div\n class=\"viewport ${scrollFade}\"\n part=\"viewport\"\n ${ref(this.#viewportRef)}\n data-input-mode=${this.tickled.inputMode}\n @scroll=${this.#onScroll}\n >\n <div class=\"spacer\" style=${spacerStyle}>\n ${this.#source instanceof DataGridListSource\n ? this.#renderDataCells(win)\n : this.#renderElementCells(win)}\n </div>\n ${this.#marqueeRect\n ? html`<div class=\"marquee\" part=\"marquee\" style=${this.#marqueeStyle(this.#marqueeRect)}></div>`\n : ``}\n </div>\n ${this.search?.renderField()}\n `;\n }\n\n #renderDataCells(win: GridWindow): ReturnType<typeof html> {\n const slice = Array.from({ length: win.endIndex - win.startIndex }, (_, i) => win.startIndex + i);\n return repeat(\n slice,\n index => this.#source.keyAt(index),\n index => this.#renderDataCell(index, win),\n ) as ReturnType<typeof html>;\n }\n\n #renderDataCell(index: number, win: GridWindow): ReturnType<typeof html> {\n const key = this.#source.keyAt(index);\n const selected = this.#selectedSnapshot.has(key);\n const marquee = this.#marqueePreview.has(key);\n const tickled = this.tickled.isTickled(key);\n const selectable = this.#source.isSelectable(index);\n const draggable = this.itemsDraggable && selectable;\n const style = this.captionStyle;\n const separate = style === `separate`;\n const caption = style === `hidden` ? `` : this.#source.labelAt(index);\n const showCaption = caption !== ``;\n const cellHeight = win.rowStride - this.gap;\n const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;\n const y = win.horizontal\n ? Math.max(0, (this._viewportHeight - cellHeight) / 2)\n : rowOf(index, win.cols) * win.rowStride;\n const captionCss = separate\n ? `height:${Math.max(0, this.captionHeight - 4)}px`\n : style === `under`\n ? `height:${this.captionHeight}px`\n : ``;\n return html`\n <div\n class=\"cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}${marquee ? ` marquee` : ``}${this.#nativeDragging && key === this.#dragOriginKey ? ` dragging-origin` : ``}\"\n part=\"item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}\"\n role=\"option\"\n aria-selected=${selected ? `true` : `false`}\n style=\"width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)\"\n data-index=${index}\n data-key=${key}\n draggable=${draggable ? `true` : `false`}\n ?data-selected=${selected}\n ?data-tickled=${tickled}\n ?data-marquee=${marquee}\n @click=${(e: MouseEvent) => this.#onCellClick(e, key)}\n @dblclick=${() => this.#onCellActivate(key)}\n @pointerenter=${() => this.tickled.handlePointerEnter(key)}\n >\n <div class=\"content\" part=\"content\">${this.#source.renderCellContent(index)}</div>\n ${showCaption ? this.#renderCaption(caption, captionCss, tickled) : ``}\n </div>\n `;\n }\n\n /**\n * A tickled cell swaps its plain label for an `ixfx-pan-text` in loop mode\n * so a truncated label scrolls instead of staying an ellipsis. Unticked\n * cells keep the cheap plain-text caption.\n */\n #renderCaption(caption: string, captionCss: string, tickled: boolean): ReturnType<typeof html> {\n if (tickled) {\n return html`<div class=\"caption\" part=\"caption\" style=${captionCss} title=${caption}><ixfx-pan-text mode=\"loop\">${caption}</ixfx-pan-text></div>`;\n }\n return html`<div class=\"caption\" part=\"caption\" style=${captionCss} title=${caption}>${caption}</div>`;\n }\n\n /** Stop the active caption pan, if any, and forget it. */\n #stopActiveCaptionPan(): void {\n const active = this.#activeCaptionPan;\n this.#activeCaptionPan = null;\n try {\n active?.stopLoop?.();\n } catch {\n // A disconnected element may throw on update — it is already gone.\n }\n }\n\n /**\n * Enforce a single scrolling caption: the tickled cell's pan-text loops,\n * every other pan-text is stopped. The pan-text also auto-starts when\n * `mode=\"loop\"` is set; this covers the case where the element was already\n * connected before overflow was measured.\n */\n #activateTickledPan(): void {\n const tickledCell = this.renderRoot.querySelector(`.cell[data-tickled]`);\n const pans = [...this.renderRoot.querySelectorAll(`ixfx-pan-text[mode=\"loop\"]`)] as unknown as PanTextElement[];\n const current = (tickledCell?.querySelector(`ixfx-pan-text[mode=\"loop\"]`) ?? null) as unknown as PanTextElement | null;\n\n for (const pan of pans) {\n if (pan !== current) {\n try {\n pan.stopLoop?.();\n } catch {\n // Already disconnected — nothing left to stop.\n }\n }\n }\n\n const active = this.#activeCaptionPan;\n if (active && active !== current) {\n try {\n active.stopLoop?.();\n } catch {\n // Already disconnected — nothing left to stop.\n }\n }\n\n if (!current) {\n this.#activeCaptionPan = null;\n return;\n }\n this.#activeCaptionPan = current;\n current.startLoop?.();\n }\n\n #renderElementCells(win: GridWindow): ReturnType<typeof html> {\n const slice = this.#items.slice(win.startIndex, win.endIndex);\n return repeat(\n slice,\n (_el, i) => this.#source.keyAt(win.startIndex + i),\n (el, i) => this.#renderCell(el, win.startIndex + i, win),\n ) as ReturnType<typeof html>;\n }\n\n #renderCell(el: Element, index: number, win: GridWindow): ReturnType<typeof html> {\n const key = this.#source.keyAt(index);\n const selected = this.#selectedSnapshot.has(key);\n const marquee = this.#marqueePreview.has(key);\n const tickled = this.tickled.isTickled(key);\n const entering = this.#entering.has(el);\n const selectable = this.#source.isSelectable(index);\n const draggable = this.itemsDraggable && selectable;\n const style = this.captionStyle;\n const separate = style === `separate`;\n const caption = style === `hidden` ? `` : this.#captionFor(el);\n const showCaption = caption !== ``;\n const cellHeight = win.rowStride - this.gap;\n const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;\n // `row`: a single row, vertically centred in the viewport.\n const y = win.horizontal\n ? Math.max(0, (this._viewportHeight - cellHeight) / 2)\n : rowOf(index, win.cols) * win.rowStride;\n const thumbStyle = separate ? `height:${this.itemSize}px` : ``;\n const captionCss = separate\n ? `height:${Math.max(0, this.captionHeight - 4)}px`\n : style === `under`\n ? `height:${this.captionHeight}px`\n : ``;\n return html`\n <div\n class=\"cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}${entering ? ` entering` : ``}${marquee ? ` marquee` : ``}${this.#nativeDragging && key === this.#dragOriginKey ? ` dragging-origin` : ``}\"\n part=\"item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}\"\n role=\"option\"\n aria-selected=${selected ? `true` : `false`}\n style=\"width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)\"\n data-index=${index}\n data-key=${key}\n draggable=${draggable ? `true` : `false`}\n ?data-selected=${selected}\n ?data-tickled=${tickled}\n ?data-marquee=${marquee}\n @click=${(e: MouseEvent) => this.#onCellClick(e, key)}\n @dblclick=${() => this.#onCellActivate(key)}\n @pointerenter=${() => this.tickled.handlePointerEnter(key)}\n >\n <div class=\"thumb\" part=\"thumb\" style=${thumbStyle}>\n ${this.#source.renderCellContent(index)}\n </div>\n ${showCaption ? this.#renderCaption(caption, captionCss, tickled) : ``}\n </div>\n `;\n }\n\n #onScroll = (e: Event): void => {\n const el = e.target as HTMLDivElement;\n this.#cancelScrollRaf();\n this.#scrollRaf = requestAnimationFrame(() => {\n this.#scrollRaf = 0;\n this._scrollTop = el.scrollTop;\n this._scrollLeft = el.scrollLeft;\n this.#emitViewportChange();\n });\n };\n\n #cancelScrollRaf(): void {\n if (this.#scrollRaf !== 0) {\n cancelAnimationFrame(this.#scrollRaf);\n this.#scrollRaf = 0;\n }\n }\n\n #onCellClick(e: MouseEvent, key: string): void {\n if (this.#dragSelect.isDragging || this.#nativeDragging || this.#nativeDrag.isDragging || this.#postDragSuppressTimer !== 0)\n return;\n this.selection.handleClick(key, e);\n this.#emitItemEvent(`list-item-click`, key);\n }\n\n #startPostDragSuppressTimer(): void {\n if (this.#postDragSuppressTimer) {\n clearTimeout(this.#postDragSuppressTimer);\n }\n this.#postDragSuppressTimer = window.setTimeout(() => {\n this.#postDragSuppressTimer = 0;\n }, 0);\n }\n\n #clearNativeDragState(): void {\n this.#nativeDragging = false;\n this.#dragOriginKey = undefined;\n this.toggleAttribute(`data-native-dragging`, false);\n this.removeAttribute(`aria-label`);\n }\n\n #onCellActivate(key: string): void {\n if (this.interactionMode !== `manual`) {\n this.selection.replace(key);\n }\n this.#emitItemEvent(`list-activate`, key);\n }\n\n private _onKeyDown = (e: KeyboardEvent): void => {\n if ((e.ctrlKey || e.metaKey) && e.key === `f`) {\n return;\n }\n if ((e.ctrlKey || e.metaKey) && e.key === `a`) {\n if (this.selection.canSelectAll()) {\n e.preventDefault();\n this.selection.selectAll();\n }\n return;\n }\n\n const count = this.#source.count;\n if (count === 0)\n return;\n\n const win = this.#currentWindow();\n const move = (delta: number): void => {\n const from = this.tickled.tickledId\n ? this.#source.indexOfKey(this.tickled.tickledId)\n : -1;\n const nextIndex = Math.max(0, Math.min(count - 1, from + delta));\n const nextKey = this.#source.keyAt(nextIndex);\n if (nextKey) {\n this.tickled.handleKeyboardNavigation(nextKey);\n this.#scrollItemIntoView(nextKey);\n }\n };\n\n // In `grid` a vertical arrow jumps a whole row; in `row`/`column` every\n // arrow just steps one item along the single line.\n const perLine = this.orientation === `grid` ? win.cols : 1;\n\n switch (e.key) {\n case `ArrowLeft`:\n move(-1);\n break;\n case `ArrowRight`:\n move(1);\n break;\n case `ArrowUp`:\n move(-perLine);\n break;\n case `ArrowDown`:\n move(perLine);\n break;\n case `Home`:\n this.tickled.handleKeyboardNavigation(`first`);\n if (this.tickled.tickledId) {\n this.#scrollItemIntoView(this.tickled.tickledId);\n }\n break;\n case `End`:\n this.tickled.handleKeyboardNavigation(`last`);\n if (this.tickled.tickledId) {\n this.#scrollItemIntoView(this.tickled.tickledId);\n }\n break;\n case `PageUp`:\n case `PageDown`: {\n const mainExtent = win.horizontal ? this._viewportWidth : this._viewportHeight;\n const mainStride = win.horizontal ? win.colStride : win.rowStride;\n const visibleLines = Math.max(1, Math.floor(mainExtent / mainStride));\n move((e.key === `PageDown` ? 1 : -1) * visibleLines * perLine);\n break;\n }\n case `Enter`: {\n const id = this.tickled.tickledId;\n if (id) {\n e.preventDefault();\n this.#emitItemEvent(`list-item-click`, id);\n this.#onCellActivate(id);\n }\n break;\n }\n case ` `: {\n const id = this.tickled.tickledId;\n if (id) {\n e.preventDefault();\n this.selection.handleSpace(id);\n }\n break;\n }\n case `Escape`:\n if (this.#nativeDragging) {\n this.#clearNativeDragState();\n }\n this.selection.clear();\n break;\n default:\n return;\n }\n e.preventDefault();\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ixfx-grid-list': GridListElement;\n }\n}\n\nexport interface GridListElement {\n addEventListener<K extends keyof GridListFullElementEventMap>(\n type: K,\n listener: (this: GridListElement, ev: GridListFullElementEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: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AAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,cAAA,KAAA,CAAA;AACN,WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,eAAA,KAAA,CAAA;AACN,WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,mBAAA,KAAA,CAAA;AACN,WAAA,CAAA,MAAM,CAAA,GAAA,gBAAA,WAAA,kBAAA,KAAA,CAAA;AApdR0D,kBAAAA,WAAAA,CAAAA,kBAAc,gBAAgB,CAAA,GAAA,eAAA"}
1
+ {"version":3,"file":"grid-list-mL0GJTQR.js","names":["ITEM_SELECTOR","#host","#effectiveIndices","#items","#itemKey","#keysCache","#captionFor","#predicate","#searchKeys","#recomputeEffective","#slotNames","#seq","#syntheticKeys","#adapter","customElement","#sourceElement","#source","#emitSelect","#stopActiveCaptionPan","#emitItemEvent","#itemWrap","#dragSelect","#nativeDrag","#prepareNativeDrag","#rowHeight","#nativeDragging","#dragOriginKey","#clearNativeDragState","#startPostDragSuppressTimer","#isCellBlankPress","#viewportRef","#marqueeHitTest","#marqueePreview","#marqueeRect","#cancelScrollRaf","#scrollRaf","#emitViewportChange","#currentWindow","#scrollItemIntoView","#onCellActivate","#searchMode","#searchFilterKeys","#searchRegistry","#effectiveSearchModes","#unregisterSearchCommands","#syncAriaMultiselectable","#mutationObserver","#onChildrenChanged","#ensureSearch","#syncSearchCommands","#resizeObserver","#reflowTimer","#items","#syncItems","#noteChildMutation","#entering","#rebuildSource","#measureViewport","#applyFilters","#zoomAnchor","#captureCentreAnchor","#applyZoomAnchor","#activateTickledPan","#rawIndexOfKey","#windowKeys","#selectedSnapshot","#onScroll","#renderDataCells","#renderElementCells","#marqueeStyle","#renderDataCell","#onCellClick","#renderCaption","#activeCaptionPan","#renderCell","#captionFor","#postDragSuppressTimer","customElement"],"sources":["../src/grid-list/grid-list-source.ts","../src/pan-text/pan-text.ts","../src/grid-list/grid-list.ts"],"sourcesContent":["import type { GridListDataAdapter } from './types.js';\nimport { html } from 'lit';\nimport { keyForElement } from '../interaction/keyed-list.js';\n\n/**\n * Uniform view over a grid-list's items, in either mode:\n *\n * - element mode ({@link ElementGridListSource}) — light-DOM children projected\n * through named `<slot>`s;\n * - data mode ({@link DataGridListSource}) — a plain array plus a\n * {@link GridListDataAdapter}.\n *\n * Everything else in `GridListElement` addresses items by **effective index**\n * (0…`count`, after `[hidden]` / filter / search) and **key**, and never\n * branches on the mode.\n */\nexport interface GridListSource {\n /** After `[hidden]`, the filter predicate and the live search filter. */\n readonly count: number;\n /** Before the filter predicate / search filter (element mode still drops `[hidden]`). */\n readonly rawCount: number;\n\n /** Effective index → key. Includes synthetic keys for keyless light-DOM items. */\n keyAt(index: number): string;\n /** Effective index of `key`, or `-1`. First match wins on duplicates. */\n indexOfKey(key: string): number;\n /** Every effective key, in order (synthetic keys included). */\n keys(): string[];\n\n /** Caption text for a cell. */\n labelAt(index: number): string;\n /** Raw (unfiltered) index → key — used by search, which sees the whole collection. */\n rawKeyAt(index: number): string;\n /** Raw (unfiltered) index → fzf haystack (falls back to the label). */\n rawSearchTextAt(index: number): string;\n\n /** `false` for `not-checked` / `disabled` items. */\n isSelectable(index: number): boolean;\n\n /** Lit-renderable cell content (element mode: a named `<slot>`; data mode: `adapter.render`). */\n renderCellContent(index: number): unknown;\n\n /** Push the current filter predicate / search-filter key set; recomputes the effective order. */\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void;\n /** Re-read the underlying data. */\n refresh(): void;\n\n /** The Element for `key`, if this source has one. */\n resolveKeyToElement(key: string): Element | undefined;\n /** The data value for `key`, if this source has one. */\n resolveKeyToData(key: string): unknown;\n}\n\nconst ITEM_SELECTOR = `:scope > *`;\nconst SYNTHETIC_PREFIX = `gl-auto-`;\n\n/** Whether `key` is an auto-assigned key for a keyless light-DOM item. */\nexport function isSyntheticKey(key: string): boolean {\n return key.startsWith(SYNTHETIC_PREFIX);\n}\n\nfunction warnDuplicateKeys(keys: readonly string[]): void {\n const seen = new Set<string>();\n const dupes = new Set<string>();\n for (const k of keys) {\n if (isSyntheticKey(k))\n continue;\n if (seen.has(k))\n dupes.add(k);\n else\n seen.add(k);\n }\n if (dupes.size > 0) {\n console.warn(\n `ixfx-grid-list: duplicate item key(s) ${[...dupes].map(k => `\"${k}\"`).join(`, `)} — the first occurrence wins for key-based operations.`,\n );\n }\n}\n\nexport class ElementGridListSource implements GridListSource {\n readonly #host: HTMLElement;\n #items: Element[] = [];\n #slotNames = new WeakMap<Element, string>();\n #syntheticKeys = new WeakMap<Element, string>();\n #seq = 0;\n #predicate: ((index: number) => boolean) | undefined;\n #searchKeys: ReadonlySet<string> | undefined;\n #effectiveIndices: number[] = [];\n #keysCache: string[] | undefined;\n\n constructor(host: HTMLElement) {\n this.#host = host;\n this.refresh();\n }\n\n get count(): number {\n return this.#effectiveIndices.length;\n }\n\n get rawCount(): number {\n return this.#items.length;\n }\n\n keyAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#itemKey(this.#items[eff]);\n }\n\n indexOfKey(key: string): number {\n return this.#effectiveIndices.findIndex(i => this.#itemKey(this.#items[i]) === key);\n }\n\n keys(): string[] {\n this.#keysCache ??= this.#effectiveIndices.map(i => this.#itemKey(this.#items[i]));\n return this.#keysCache;\n }\n\n labelAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#captionFor(this.#items[eff]);\n }\n\n rawKeyAt(index: number): string {\n const el = this.#items[index];\n return el === undefined ? `` : this.#itemKey(el);\n }\n\n rawSearchTextAt(index: number): string {\n const el = this.#items[index];\n if (el === undefined)\n return ``;\n return (\n el.getAttribute(`data-search-label`)\n ?? el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? el.textContent?.trim()\n ?? ``\n );\n }\n\n isSelectable(index: number): boolean {\n const eff = this.#effectiveIndices[index];\n return eff !== undefined && !this.#items[eff].hasAttribute(`not-checked`);\n }\n\n renderCellContent(index: number): unknown {\n const eff = this.#effectiveIndices[index];\n if (eff === undefined)\n return undefined;\n return html`<slot name=${this.slotNameFor(this.#items[eff])}></slot>`;\n }\n\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void {\n if (`predicate` in opts)\n this.#predicate = opts.predicate;\n if (`searchKeys` in opts)\n this.#searchKeys = opts.searchKeys;\n this.#recomputeEffective();\n }\n\n refresh(): void {\n this.#items = Array.from(this.#host.querySelectorAll(ITEM_SELECTOR)).filter(\n el => !(el as HTMLElement).hidden,\n );\n for (const el of this.#items) {\n const name = this.slotNameFor(el);\n if (el.getAttribute(`slot`) !== name)\n el.setAttribute(`slot`, name);\n }\n warnDuplicateKeys(this.#items.map(el => this.#itemKey(el)));\n this.#recomputeEffective();\n }\n\n /** Effective-order elements — the array `GridListElement` renders and slices. */\n effectiveElements(): Element[] {\n return this.#effectiveIndices.map(i => this.#items[i]);\n }\n\n /** Raw-order element at `index`, or `undefined`. */\n rawElementAt(index: number): Element | undefined {\n return this.#items[index];\n }\n\n /** Stable per-element `<slot>` name. */\n slotNameFor(el: Element): string {\n let name = this.#slotNames.get(el);\n if (name === undefined) {\n this.#seq += 1;\n name = `gl-item-${this.#seq}`;\n this.#slotNames.set(el, name);\n }\n return name;\n }\n\n resolveKeyToElement(key: string): Element | undefined {\n if (isSyntheticKey(key))\n return this.#items.find(el => this.#syntheticKeys.get(el) === key);\n return this.#items.find(el => keyForElement(el) === key);\n }\n\n resolveKeyToData(_key: string): undefined {\n return undefined;\n }\n\n #recomputeEffective(): void {\n const effective: number[] = [];\n for (let i = 0; i < this.#items.length; i++) {\n if (this.#predicate !== undefined && !this.#predicate(i))\n continue;\n if (this.#searchKeys !== undefined) {\n const key = this.#itemKey(this.#items[i]);\n if (!isSyntheticKey(key) && !this.#searchKeys.has(key))\n continue;\n }\n effective.push(i);\n }\n this.#effectiveIndices = effective;\n this.#keysCache = undefined;\n }\n\n #itemKey(el: Element): string {\n const userKey = keyForElement(el);\n if (userKey !== undefined)\n return userKey;\n let synthetic = this.#syntheticKeys.get(el);\n if (synthetic === undefined) {\n this.#seq += 1;\n synthetic = `${SYNTHETIC_PREFIX}${this.#seq}`;\n this.#syntheticKeys.set(el, synthetic);\n }\n return synthetic;\n }\n\n #captionFor(el: Element): string {\n return (\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? ``\n );\n }\n}\n\nexport class DataGridListSource<T> implements GridListSource {\n #items: readonly T[];\n readonly #adapter: GridListDataAdapter<T>;\n #predicate: ((index: number) => boolean) | undefined;\n #searchKeys: ReadonlySet<string> | undefined;\n #effectiveIndices: number[] = [];\n #keysCache: string[] | undefined;\n\n constructor(items: readonly T[], adapter: GridListDataAdapter<T>) {\n this.#items = items;\n this.#adapter = adapter;\n warnDuplicateKeys(items.map((it, i) => adapter.key(it, i)));\n this.#recomputeEffective();\n }\n\n get count(): number {\n return this.#effectiveIndices.length;\n }\n\n get rawCount(): number {\n return this.#items.length;\n }\n\n keyAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? `` : this.#adapter.key(this.#items[eff], eff);\n }\n\n indexOfKey(key: string): number {\n return this.#effectiveIndices.findIndex(i => this.#adapter.key(this.#items[i], i) === key);\n }\n\n keys(): string[] {\n this.#keysCache ??= this.#effectiveIndices.map(i => this.#adapter.key(this.#items[i], i));\n return this.#keysCache;\n }\n\n labelAt(index: number): string {\n const eff = this.#effectiveIndices[index];\n if (eff === undefined)\n return ``;\n return this.#adapter.label?.(this.#items[eff], eff) ?? this.#adapter.key(this.#items[eff], eff);\n }\n\n rawKeyAt(index: number): string {\n return index < 0 || index >= this.#items.length ? `` : this.#adapter.key(this.#items[index], index);\n }\n\n rawSearchTextAt(index: number): string {\n if (index < 0 || index >= this.#items.length)\n return ``;\n const item = this.#items[index];\n return this.#adapter.searchableText?.(item, index) ?? this.#adapter.label?.(item, index) ?? ``;\n }\n\n isSelectable(index: number): boolean {\n const eff = this.#effectiveIndices[index];\n return eff !== undefined && !this.#adapter.disabled?.(this.#items[eff], eff);\n }\n\n renderCellContent(index: number): unknown {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? undefined : this.#adapter.render(this.#items[eff], eff);\n }\n\n setFilters(opts: { predicate?: ((index: number) => boolean) | undefined; searchKeys?: ReadonlySet<string> | undefined }): void {\n if (`predicate` in opts)\n this.#predicate = opts.predicate;\n if (`searchKeys` in opts)\n this.#searchKeys = opts.searchKeys;\n this.#recomputeEffective();\n }\n\n refresh(): void {\n this.#recomputeEffective();\n }\n\n /** Raw-order item at `index`, or `undefined`. */\n rawItemAt(index: number): T | undefined {\n return this.#items[index];\n }\n\n /** Effective-order item at `index`, or `undefined`. */\n getItemAt(index: number): T | undefined {\n const eff = this.#effectiveIndices[index];\n return eff === undefined ? undefined : this.#items[eff];\n }\n\n resolveKeyToElement(_key: string): undefined {\n return undefined;\n }\n\n resolveKeyToData(key: string): T | undefined {\n const idx = this.#items.findIndex((item, i) => this.#adapter.key(item, i) === key);\n return idx >= 0 ? this.#items[idx] : undefined;\n }\n\n #recomputeEffective(): void {\n const effective: number[] = [];\n for (let i = 0; i < this.#items.length; i++) {\n if (this.#predicate !== undefined && !this.#predicate(i))\n continue;\n if (this.#searchKeys !== undefined && !this.#searchKeys.has(this.#adapter.key(this.#items[i], i)))\n continue;\n effective.push(i);\n }\n this.#effectiveIndices = effective;\n this.#keysCache = undefined;\n }\n}\n","import type { PropertyValues } from 'lit';\nimport { css, html, LitElement } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { themeFallbacks } from '../styles/fallbacks.js';\nimport { safeCustomElement as customElement } from '../util/custom-elements.js';\n\nconst SPEED = 45; // px per second\nconst END_PADDING = 4;\nconst START_DELAY = 300; // ms to wait on hover before panning begins\nconst END_DWELL = 2000; // ms to dwell at the end of the text in loop mode\nconst RESET_DURATION = 400; // ms to snap back to the start in loop mode\n// Decelerating curve: moves off fast then eases into the reveal (~easeOutQuad).\nconst PAN_EASING = `cubic-bezier(0.25, 0.46, 0.45, 0.94)`;\n\nexport type PanTextMode = `hover` | `loop`;\n\n@customElement(`ixfx-pan-text`)\nexport class PanTextElement extends LitElement {\n @property({ type: String, attribute: `direction` }) direction: `start` | `end` = `end`;\n @property({ type: Boolean, attribute: `disabled` }) disabled = false;\n /**\n * Interaction mode.\n * - `hover` (default): pans once while hovered.\n * - `loop`: pans repeatedly — dwell 2s at the end, reset to the start,\n * and pan again — until `stopLoop()` is called. Auto-starts when set.\n */\n @property({ type: String, attribute: `mode`, reflect: true }) mode: PanTextMode = `hover`;\n\n @state() private _isOverflowing = false;\n @state() private _isHovering = false;\n @state() private _loopActive = false;\n @state() private _loopAtEnd = false;\n\n @query(`.text`) private _textEl!: HTMLElement | null;\n\n private _overflow = 0;\n private _resizeObserver: ResizeObserver | null = null;\n private _loopTimer = 0;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this._resizeObserver = new ResizeObserver(() => this._measure());\n this.addEventListener(`mouseenter`, this._onMouseEnter);\n this.addEventListener(`mouseleave`, this._onMouseLeave);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this._clearLoopTimer();\n // Reset without requesting an update — the element is leaving the DOM.\n this._loopActive = false;\n this._loopAtEnd = false;\n this._resizeObserver?.disconnect();\n this._resizeObserver = null;\n this.removeEventListener(`mouseenter`, this._onMouseEnter);\n this.removeEventListener(`mouseleave`, this._onMouseLeave);\n }\n\n override firstUpdated(): void {\n this._measure();\n this._resizeObserver?.observe(this);\n // Text metrics change once web fonts load; re-check when they settle.\n document.fonts?.ready.then(() => this._measure());\n if (this.mode === `loop`)\n this.startLoop();\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has(`mode`)) {\n if (this.mode === `loop`)\n this.startLoop();\n else\n this.stopLoop();\n }\n if (changed.has(`disabled`) && this.disabled)\n this.stopLoop();\n this._measure();\n }\n\n /**\n * Whether a loop pan is currently active (between `startLoop()` and `stopLoop()`).\n */\n get looping(): boolean {\n return this._loopActive;\n }\n\n /**\n * Begin looping: pan to the end, dwell there for 2 seconds, reset to the\n * start and pan again, repeating until `stopLoop()` is called. A no-op when\n * `disabled`, when there is nothing to reveal, or under reduced-motion.\n */\n startLoop(): void {\n if (this.disabled || this._prefersReducedMotion())\n return;\n this._loopActive = true;\n this._loopAtEnd = false;\n this.requestUpdate();\n if (this._isOverflowing && this._loopTimer === 0)\n this._scheduleLoopPan(START_DELAY);\n // Otherwise `_measure()` picks it up once overflow is known.\n }\n\n /**\n * Stop a loop started with `startLoop()` and snap back to the rest position.\n */\n stopLoop(): void {\n if (!this._loopActive && !this._loopAtEnd && this._loopTimer === 0)\n return;\n this._clearLoopTimer();\n this._loopActive = false;\n this._loopAtEnd = false;\n this.requestUpdate();\n }\n\n private _prefersReducedMotion(): boolean {\n return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches ?? false;\n }\n\n private _panDuration(): number {\n return Math.max(1.5, (this._overflow + END_PADDING) / SPEED);\n }\n\n private _clearLoopTimer(): void {\n if (this._loopTimer !== 0) {\n clearTimeout(this._loopTimer);\n this._loopTimer = 0;\n }\n }\n\n private _scheduleLoopPan(delay: number): void {\n this._clearLoopTimer();\n this._loopTimer = window.setTimeout(() => {\n this._loopTimer = 0;\n if (!this._loopActive || this.disabled || !this._isOverflowing)\n return;\n this._loopAtEnd = true;\n this.requestUpdate();\n const dwell = this._panDuration() * 1000 + END_DWELL;\n this._loopTimer = window.setTimeout(() => {\n this._loopTimer = 0;\n if (!this._loopActive)\n return;\n this._loopAtEnd = false;\n this.requestUpdate();\n this._scheduleLoopPan(RESET_DURATION + START_DELAY);\n }, dwell);\n }, delay);\n }\n\n private _onMouseEnter = (): void => {\n this._isHovering = true;\n };\n\n private _onMouseLeave = (): void => {\n this._isHovering = false;\n };\n\n /**\n * Measures how far the slotted text overflows its container. The measurement\n * is taken on the inner `.text` span (which clips with an ellipsis), not on\n * the host — the host never overflows, so measuring it always yielded zero\n * and the hover interaction never activated.\n *\n * Skipped while hovering, because the hover styles switch `.text` to\n * `overflow: visible` and the measurement would collapse to zero mid-pan.\n */\n private _measure = (): void => {\n if (this._isHovering || this._loopAtEnd)\n return;\n const el = this._textEl;\n if (!el)\n return;\n\n this._overflow = Math.max(0, el.scrollWidth - el.clientWidth);\n const overflowing = this._overflow > 0;\n\n this.classList.toggle(`is-overflowing`, overflowing);\n if (overflowing !== this._isOverflowing) {\n this._isOverflowing = overflowing;\n }\n // A loop requested before overflow was known (fonts, resize, late slot)\n // starts here once there is something to reveal.\n if (this._loopActive && this.mode === `loop` && !this.disabled && overflowing && this._loopTimer === 0)\n this._scheduleLoopPan(START_DELAY);\n if (!overflowing && this._loopAtEnd) {\n this._loopAtEnd = false;\n this.requestUpdate();\n }\n };\n\n private _textStyle(): string {\n if (!this._isOverflowing)\n return ``;\n\n const distance = this._overflow + END_PADDING;\n const duration = Math.max(1.5, distance / SPEED);\n const revealEnd = this.direction === `end`;\n\n // \"end\": rest shows the start of the text, hover pans left to the end.\n // \"start\": rest shows the end of the text, hover pans right to the start.\n const restX = revealEnd ? 0 : -distance;\n const hoverX = revealEnd ? -distance : 0;\n\n // Loop mode drives the same transform off a timer instead of hover. The\n // dwell/reset delays live in the timeout chain, so the transition itself\n // carries no extra delay.\n if (this._loopActive && this.mode === `loop`) {\n if (this._loopAtEnd) {\n return [\n `transform: translateX(${hoverX}px)`,\n `transition: transform ${duration}s ${PAN_EASING}`,\n `overflow: visible`,\n `text-overflow: clip`,\n ].join(`; `);\n }\n return [\n `transform: translateX(${restX}px)`,\n `transition: transform ${RESET_DURATION}ms ${PAN_EASING}`,\n revealEnd ? `` : `overflow: visible; text-overflow: clip`,\n ].filter(Boolean).join(`; `);\n }\n\n if (this._isHovering) {\n return [\n `transform: translateX(${hoverX}px)`,\n `transition: transform ${duration}s ${PAN_EASING} ${START_DELAY}ms`,\n `overflow: visible`,\n `text-overflow: clip`,\n ].join(`; `);\n }\n\n return [\n `transform: translateX(${restX}px)`,\n `transition: transform 400ms ${PAN_EASING}`,\n // \"start\" mode keeps the tail visible at rest, so it can't clip/ellipsis.\n revealEnd ? `` : `overflow: visible; text-overflow: clip`,\n ].filter(Boolean).join(`; `);\n }\n\n protected override render() {\n const textClasses = {\n 'is-overflowing': this._isOverflowing,\n 'is-hovering': this._isHovering,\n };\n\n return html`\n <span class=\"text ${classMap(textClasses)}\" part=\"text\" style=${this._textStyle()}>\n <slot @slotchange=${this._measure}></slot>\n </span>\n `;\n }\n\n static override styles = [themeFallbacks, css`\n /* Renders like plain inline text: no colours, border, padding or margin\n of its own — it only adds the clipping needed to pan on hover. */\n :host {\n display: inline-block;\n overflow: hidden;\n white-space: nowrap;\n max-width: 100%;\n box-sizing: border-box;\n font: inherit;\n color: inherit;\n }\n\n :host([disabled]) {\n opacity: var(--disabled-opacity, 0.5);\n pointer-events: none;\n }\n\n .text {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n will-change: transform;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .text {\n transition: none !important;\n transform: none !important;\n }\n }\n `];\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ixfx-pan-text': PanTextElement;\n }\n}\n","/* eslint-disable ts/no-unsafe-declaration-merging */\nimport type { CommandRegistry } from '@clinth/ui-commands';\nimport type { PropertyValues } from 'lit';\nimport type { DataListSearchItem, ListSearchMode } from '../incr-search/index.js';\nimport type {\n DragSelectRect,\n ListDragEntry,\n ListDragPreviewRenderer,\n ListNativeDragStartDetail,\n} from '../interaction/index.js';\nimport type { ListInteractionMode, ListSelectionMode } from '../interaction/list-selection-types.js';\nimport type { PanTextElement } from '../pan-text/pan-text.js';\nimport type { GridListSource } from './grid-list-source.js';\nimport type {\n GridListCaptionAlign,\n GridListCaptionBackdrop,\n GridListCaptionPosition,\n GridListCaptionStyle,\n GridListDataAdapter as GridListDataAdapterType,\n GridListFullElementEventMap,\n GridListItemClickDetail,\n GridListOrientation,\n GridListSelectDetail,\n GridListViewportChangeDetail,\n} from './types.js';\nimport { createCommandRegistry } from '@clinth/ui-commands';\nimport { css, html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport {\n createDataListSearchAdapter,\n createElementListSearchAdapter,\n LIST_SEARCH_MODES,\n ListSearchController,\n listSearchStyles,\n registerListSearchCommands,\n} from '../incr-search/index.js';\nimport { listItemFadeKeyframes, tickledItemStyles, tickledStyles } from '../interaction/index.js';\nimport { keyForElement } from '../interaction/keyed-list.js';\nimport { ListDragSelectController } from '../interaction/list-drag-select-controller.js';\nimport { ListNativeDragController } from '../interaction/list-native-drag-controller.js';\nimport { ListSelectionController } from '../interaction/list-selection-controller.js';\nimport { TickledController } from '../interaction/tickled-controller.js';\nimport { themeFallbacks } from '../styles/fallbacks.js';\nimport { scrollFadeStyles } from '../styles/scroll-fade.js';\nimport { safeCustomElement as customElement } from '../util/custom-elements.js';\nimport { DataGridListSource, ElementGridListSource, isSyntheticKey } from './grid-list-source.js';\nimport '../pan-text/pan-text.js';\n\nexport type {\n GridListActivateDetail,\n GridListActivateEvent,\n GridListCaptionAlign,\n GridListCaptionBackdrop,\n GridListCaptionPosition,\n GridListCaptionStyle,\n GridListDataAdapter,\n GridListElementEventMap,\n GridListFullElementEventMap,\n GridListItemClickDetail,\n GridListItemClickEvent,\n GridListItemEventDetail,\n GridListOrientation,\n GridListSelectDetail,\n GridListSelectEvent,\n GridListTickleDetail,\n GridListTickleEvent,\n GridListViewportChangeDetail,\n GridListViewportChangeEvent,\n ListDragEntry,\n ListDragPreview,\n ListDragPreviewContext,\n ListDragPreviewRenderer,\n ListDragSource,\n ListInteractionMode,\n ListNativeDragStartDetail,\n ListNativeDragStartEvent,\n ListSelectionMode,\n} from './types.js';\n\ntype GridWindow = {\n readonly cols: number;\n readonly rows: number;\n /** Spacer height in px (vertical orientations); 0 when CSS controls it. */\n readonly totalHeight: number;\n /** Spacer width in px (`row` orientation); 0 when CSS controls it. */\n readonly totalWidth: number;\n readonly startIndex: number;\n readonly endIndex: number;\n /** Distance between the left edges of adjacent columns (item width + gap). */\n readonly colStride: number;\n /** Distance between the top edges of adjacent rows (row height + gap). */\n readonly rowStride: number;\n /** `true` for `row` orientation — the list scrolls along the x axis. */\n readonly horizontal: boolean;\n};\n\nconst ITEM_SELECTOR = `:scope > *`;\n\nconst MIN_ITEM_SIZE = 16;\n\n/**\n * How long the host keeps the `[reflowing]` attribute after items are inserted\n * mid-list — long enough for the cell move-transition and the enter animation\n * to finish. Kept a touch above the default `--grid-list-item-move-duration`.\n */\nconst REFLOW_WINDOW_MS = 320;\n\n// `itemWidth` is the square's width; `rowHeight` is the full cell height\n// (square, plus the caption band in `labelled` style). `scrollOffset` is\n// `scrollTop` for `grid`/`column` and `scrollLeft` for `row`.\nfunction computeGridWindow(\n count: number,\n itemWidth: number,\n rowHeight: number,\n gap: number,\n viewportWidth: number,\n viewportHeight: number,\n scrollOffset: number,\n orientation: GridListOrientation,\n overscan = 2,\n): GridWindow {\n const w = Math.max(1, itemWidth);\n const h = Math.max(1, rowHeight);\n const g = Math.max(0, gap);\n const colStride = w + g;\n const rowStride = h + g;\n const offset = Math.max(0, scrollOffset);\n\n if (orientation === `row`) {\n const rows = count === 0 ? 0 : 1;\n const totalWidth = count === 0 ? 0 : (count - 1) * colStride + w;\n if (count === 0 || viewportWidth <= 0) {\n return { cols: count, rows, totalHeight: 0, totalWidth, startIndex: 0, endIndex: 0, colStride, rowStride, horizontal: true };\n }\n const firstVisible = Math.max(0, Math.floor(offset / colStride));\n const lastVisible = Math.ceil((offset + viewportWidth) / colStride);\n return {\n cols: count,\n rows,\n totalHeight: 0,\n totalWidth,\n startIndex: Math.max(0, firstVisible - overscan),\n endIndex: Math.min(count, lastVisible + overscan),\n colStride,\n rowStride,\n horizontal: true,\n };\n }\n\n const cols = orientation === `column`\n ? 1\n : Math.max(1, Math.floor((Math.max(0, viewportWidth) + g) / colStride));\n const rows = count === 0 ? 0 : Math.ceil(count / cols);\n const totalHeight = rows === 0 ? 0 : (rows - 1) * rowStride + h;\n\n if (count === 0 || viewportHeight <= 0) {\n return { cols, rows, totalHeight, totalWidth: 0, startIndex: 0, endIndex: 0, colStride, rowStride, horizontal: false };\n }\n\n const firstVisibleRow = Math.max(0, Math.floor(offset / rowStride));\n const lastVisibleRow = Math.ceil((offset + viewportHeight) / rowStride);\n const rowStart = Math.max(0, firstVisibleRow - overscan);\n const rowEnd = Math.min(rows, lastVisibleRow + overscan);\n\n return {\n cols,\n rows,\n totalHeight,\n totalWidth: 0,\n startIndex: rowStart * cols,\n endIndex: Math.min(count, rowEnd * cols),\n colStride,\n rowStride,\n horizontal: false,\n };\n}\n\nfunction columnOf(index: number, cols: number): number {\n return cols <= 1 ? 0 : index % cols;\n}\n\nfunction rowOf(index: number, cols: number): number {\n return cols <= 1 ? index : Math.floor(index / cols);\n}\n\n@customElement(`ixfx-grid-list`)\nexport class GridListElement<T = unknown> extends LitElement {\n static override styles = [\n themeFallbacks,\n tickledStyles,\n tickledItemStyles,\n // Both axes are registered; `render()` applies whichever one matches the\n // current orientation to the viewport (see the `scroll-fade-*` class there).\n scrollFadeStyles(`x`),\n scrollFadeStyles(`y`),\n listItemFadeKeyframes,\n listSearchStyles,\n css`\n :host {\n --grid-list-item-bg: var(--item-bg);\n --grid-list-radius: var(--radius-m);\n --grid-list-gap: var(--space-xs);\n --grid-list-padding: var(--space-xs);\n position: relative;\n display: block;\n height: 100%;\n min-height: 2em;\n overflow: hidden;\n user-select: none;\n background: var(--surface-3);\n color: var(--surface-3-text);\n border-radius: var(--radius-s);\n border: 1px solid var(--border);\n }\n :host(:focus-visible) {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n .viewport {\n position: relative;\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n padding: var(--grid-list-padding);\n /* Consumer control over the native scrollbar (both orientations): set\n --grid-list-scrollbar-width to \"none\" to hide it or \"thin\" to slim it.\n The container is also exposed as ::part(viewport). */\n scrollbar-width: var(--grid-list-scrollbar-width, auto);\n scrollbar-gutter: var(--grid-list-scrollbar-gutter, auto);\n scrollbar-color: var(--grid-list-scrollbar-color, auto);\n }\n :host([orientation=\"row\"]) .viewport {\n overflow-x: auto;\n overflow-y: hidden;\n }\n .spacer {\n position: relative;\n width: 100%;\n }\n .cell {\n position: absolute;\n inset: 0 auto auto 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: stretch;\n contain: layout style;\n border-radius: var(--grid-list-radius);\n }\n\n /* The square that holds the slotted content — the \"image well\". Its\n background is a set of consumer-settable variables so a Finder-style\n look is possible: on selection the caption takes the accent colouring\n while the well takes a tint of the surface colour. Each variable is\n unset by default, so the fallback (today's look) applies until a\n consumer opts in.\n --grid-list-thumb-bg idle well background\n --grid-list-thumb-bg-tickled under the cursor\n --grid-list-thumb-bg-selected when the cell is selected\n --grid-list-thumb-bg-selected-tickled selected + under the cursor\n --grid-list-thumb-selection-wash colour of the box-mode wash (default: --accent)\n --grid-list-thumb-selection-wash-opacity strength of that wash (default: 0.18; set 0 to drop it) */\n .thumb {\n position: relative;\n flex: 1;\n min-height: 0;\n display: flex;\n align-items: stretch;\n box-sizing: border-box;\n overflow: hidden;\n border-radius: 0;\n background: var(--grid-list-thumb-bg, transparent);\n border: 1px solid transparent;\n transition: background var(--transition), border-color var(--transition);\n }\n .thumb ::slotted(*) {\n flex: 1;\n min-width: 0;\n min-height: 0;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n }\n .thumb ::slotted(*:empty)::after {\n content: \"Empty\";\n color: var(--surface-muted-text);\n font-size: var(--text-s);\n }\n ::slotted([hidden]) {\n display: none !important;\n }\n\n /* Selection / cursor wash — sits over the slotted content so it reads\n on photos and arbitrary DOM alike. Set\n --grid-list-thumb-selection-wash-opacity: 0 to drop it in favour of a\n --grid-list-thumb-bg-selected tint. */\n .thumb::after {\n content: \"\";\n position: absolute;\n inset: 0;\n pointer-events: none;\n border-radius: inherit;\n background: var(--grid-list-thumb-selection-wash, var(--accent));\n opacity: 0;\n transition: opacity var(--transition, 0.1s ease-out);\n }\n .cell.selected .thumb::after {\n opacity: var(--grid-list-thumb-selection-wash-opacity, 0.18);\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected .thumb {\n background: var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, transparent));\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected.tickled .thumb {\n background: var(--grid-list-thumb-bg-selected-tickled, var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, transparent)));\n }\n\n /* ---- Caption (base) ---- */\n .caption {\n box-sizing: border-box;\n flex: none;\n padding: 3px 6px;\n font-size: var(--text-s, 0.8rem);\n line-height: 1.3;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: var(--surface-3-text);\n }\n :host([caption-align=\"left\"]) .caption { text-align: left; }\n :host([caption-align=\"right\"]) .caption { text-align: right; }\n /* Tickled captions swap their plain label for an ixfx-pan-text in loop\n mode so a truncated label scrolls instead of staying an ellipsis. The\n pan fills the caption band (flex in 'separate', block otherwise) and\n inherits its alignment. */\n .caption ixfx-pan-text {\n display: block;\n flex: 1;\n min-width: 0;\n max-width: 100%;\n font: inherit;\n color: inherit;\n }\n\n /* ---- Box modes (hidden / under / overlaid): the cell is one box with a\n single selection outline ---- */\n :host(:not([caption-style=\"separate\"])) .cell {\n background: var(--grid-list-item-bg);\n border: 1px solid transparent;\n overflow: hidden;\n transition: background var(--transition), border-color var(--transition);\n }\n :host(:not([caption-style=\"separate\"])) .cell.tickled,\n :host(:not([caption-style=\"separate\"]):not([disable-hover-tickle])) .cell:hover {\n background: var(--item-bg-tickled);\n border: var(--item-border-tickled);\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected {\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n :host(:not([caption-style=\"separate\"])) .cell.selected.tickled {\n background: var(--item-bg-selected-tickled);\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n\n /* under: caption is a strip inside the box, below the content */\n :host([caption-style=\"under\"]) .caption {\n border-top: 1px solid var(--border, rgba(128, 128, 128, 0.3));\n background: var(--surface-4, transparent);\n }\n :host([caption-style=\"under\"][caption-position=\"top\"]) .caption {\n order: -1;\n border-top: none;\n border-bottom: 1px solid var(--border, rgba(128, 128, 128, 0.3));\n }\n\n /* overlaid: caption floats over the content */\n :host([caption-style=\"overlaid\"]) .caption {\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n color: #fff;\n }\n :host([caption-style=\"overlaid\"][caption-position=\"top\"]) .caption {\n top: 0;\n bottom: auto;\n }\n :host([caption-style=\"overlaid\"][caption-position=\"middle\"]) .caption {\n top: 50%;\n bottom: auto;\n transform: translateY(-50%);\n }\n /* overlaid backdrop */\n :host([caption-style=\"overlaid\"][caption-backdrop=\"scrim\"]) .caption {\n background: rgba(0, 0, 0, 0.55);\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"]) .caption {\n background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n padding-block: 10px 4px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"][caption-position=\"top\"]) .caption {\n background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));\n padding-block: 4px 10px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"gradient\"][caption-position=\"middle\"]) .caption {\n background: rgba(0, 0, 0, 0.5);\n padding-block: 3px;\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"blur\"]) .caption {\n background: rgba(20, 20, 20, 0.3);\n backdrop-filter: blur(6px);\n -webkit-backdrop-filter: blur(6px);\n }\n :host([caption-style=\"overlaid\"][caption-backdrop=\"none\"]) .caption {\n background: none;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 6px rgba(0, 0, 0, 0.7);\n }\n\n /* ---- separate mode: square + detached caption, each highlighted ---- */\n :host([caption-style=\"separate\"]) .thumb {\n flex: none;\n border-radius: var(--grid-list-radius);\n background: var(--grid-list-thumb-bg, var(--grid-list-item-bg));\n border: 1px solid transparent;\n }\n :host([caption-style=\"separate\"]) .cell.tickled .thumb,\n :host([caption-style=\"separate\"]:not([disable-hover-tickle])) .cell:hover .thumb {\n background: var(--grid-list-thumb-bg-tickled, var(--item-bg-tickled));\n border: var(--item-border-tickled);\n }\n :host([caption-style=\"separate\"]) .caption {\n display: flex;\n align-items: center;\n align-self: center;\n max-width: 100%;\n margin-top: 4px;\n border-radius: var(--radius-s, 4px);\n }\n :host([caption-style=\"separate\"][caption-align=\"left\"]) .caption { align-self: flex-start; }\n :host([caption-style=\"separate\"][caption-align=\"right\"]) .caption { align-self: flex-end; }\n :host([caption-style=\"separate\"][caption-position=\"top\"]) .caption {\n order: -1;\n margin-top: 0;\n margin-bottom: 4px;\n }\n /* Inset the selection ring (negative offset) so it is never clipped by the\n scroll viewport's overflow when the cell sits against an edge. */\n :host([caption-style=\"separate\"]) .cell.selected .thumb {\n background: var(--grid-list-thumb-bg-selected, var(--grid-list-thumb-bg, var(--grid-list-item-bg)));\n outline: 2px solid var(--accent);\n outline-offset: -2px;\n }\n :host([caption-style=\"separate\"]) .cell.selected.tickled .thumb {\n background: var(--grid-list-thumb-bg-selected-tickled, var(--item-bg-selected-tickled));\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n :host([caption-style=\"separate\"]) .cell.selected .caption {\n background: var(--accent);\n color: var(--accent-text, #000);\n }\n :host([caption-style=\"separate\"]) .cell.tickled .caption {\n background: var(--item-bg-tickled);\n outline: var(--item-border-tickled);\n }\n :host([caption-style=\"separate\"]) .cell.selected.tickled .caption {\n background: var(--item-bg-selected-tickled);\n outline: 2px dashed var(--surface-3);\n outline-offset: -2px;\n }\n\n /* ---- Insertion / removal animation ----\n Active only while the host carries [reflowing] — the ~0.3s window after\n the child list changes mid-list (see #noteChildMutation). Kept out of\n the base rules so it never fires during scroll virtualisation, where\n cells are recycled to wildly different positions every frame. Placed\n last so it wins over the earlier cell transition rule regardless of\n specificity. Survivors slide to their new slot; a freshly inserted cell\n also fades in. (A removed item's element is already gone, so there's\n nothing left to fade — the gap simply closes as the others slide.) */\n :host([reflowing]) .cell {\n transition:\n transform var(--grid-list-item-move-duration, 200ms) cubic-bezier(0.2, 0, 0, 1),\n background var(--transition),\n border-color var(--transition);\n }\n .cell.entering {\n animation: ixfx-list-item-in var(--grid-list-item-move-duration, 200ms) ease both;\n }\n @media (prefers-reduced-motion: reduce) {\n :host([reflowing]) .cell { transition: background var(--transition), border-color var(--transition); }\n .cell.entering { animation: none; }\n }\n\n /* Drag-select (marquee) rectangle + covered-cell preview. The preview\n reuses the selection wash so covered cells read as \"about to be\n selected\". Style hooks: part=\"marquee\", --grid-list-marquee-border,\n --grid-list-marquee-fill. */\n .marquee {\n position: absolute;\n pointer-events: none;\n z-index: 5;\n border: 1px solid var(--grid-list-marquee-border, var(--accent));\n background: var(--grid-list-marquee-fill, color-mix(in srgb, var(--accent) 15%, transparent));\n }\n .cell.marquee .thumb::after {\n opacity: var(--grid-list-thumb-selection-wash-opacity, 0.18);\n }\n\n /* Native item drag origin cell. */\n .cell.dragging-origin {\n opacity: 0.6;\n }\n `,\n ];\n\n @property({ type: String, attribute: `selection-mode` })\n selectionMode: ListSelectionMode = `single`;\n\n @property({ type: String, attribute: `interaction-mode` })\n interactionMode: ListInteractionMode = `standard`;\n\n /**\n * Disable hover tickling: pointer hover no longer moves the cursor, fires\n * `list-tickle`, or changes where keyboard navigation resumes from. Keyboard\n * navigation, selection, and `focusKey()` are unaffected.\n */\n @property({ type: Boolean, attribute: `disable-hover-tickle`, reflect: true })\n disableHoverTickle = false;\n\n @property({ type: Number, attribute: `item-size` })\n itemSize = 160;\n\n @property({ type: Number })\n gap = 8;\n\n /**\n * Layout / scroll direction.\n * - `grid` (default): items wrap across as many columns as fit, scrolls vertically.\n * - `row`: a single row of items, scrolls horizontally.\n * - `column`: a single column of items, scrolls vertically.\n */\n @property({ type: String, reflect: true })\n orientation: GridListOrientation = `grid`;\n\n /**\n * How the caption relates to the content — see {@link GridListCaptionStyle}.\n * - `hidden`: no caption.\n * - `separate`: detached label below the square, each highlighted on its own.\n * - `under` (default): one box, content on top, caption strip below it inside.\n * - `overlaid`: caption floats over the content.\n */\n @property({ type: String, attribute: `caption-style`, reflect: true })\n captionStyle: GridListCaptionStyle = `under`;\n\n /** Horizontal alignment of the caption text: `left`, `middle` (default), `right`. */\n @property({ type: String, attribute: `caption-align`, reflect: true })\n captionAlign: GridListCaptionAlign = `middle`;\n\n /** Vertical placement of caption: `top`, `middle` (default), `bottom`. `middle` only has effect for `overlaid` style. */\n @property({ type: String, attribute: `caption-position`, reflect: true })\n captionPosition: GridListCaptionPosition = `bottom`;\n\n /** `overlaid` only — backdrop behind the caption: `scrim` (default), `gradient`, `blur`, `none`. */\n @property({ type: String, attribute: `caption-backdrop`, reflect: true })\n captionBackdrop: GridListCaptionBackdrop = `scrim`;\n\n /**\n * Height reserved for the caption in `separate` / `under` styles, in pixels.\n * Ignored by `overlaid` and `hidden`.\n */\n @property({ type: Number, attribute: `caption-height` })\n captionHeight = 24;\n\n @property({ type: String, attribute: `item-wrap` })\n itemWrap: `stop` | `wrap` = `stop`;\n\n /**\n * Element-mode filter predicate (also driven by incremental filter-search).\n * Light-DOM items for which it returns `false` are removed from layout and\n * navigation. For data mode use {@link itemFilterPredicate}.\n */\n @property({ attribute: false })\n filterPredicate: ((el: Element) => boolean) | undefined;\n\n /**\n * Data-mode filter predicate. Items for which it returns `false` are removed\n * from layout and navigation without any element being materialised.\n */\n @property({ attribute: false })\n itemFilterPredicate: ((item: T, index: number) => boolean) | undefined;\n\n /**\n * Space-separated subset of `navigate select filter` — limits which\n * incremental-search modes are offered (as commands and in-popover switches).\n * Unset ⇒ all three; empty ⇒ search disabled. See `docs/infra-incremental.md`.\n */\n /**\n * Enable native browser drag-and-drop for selectable items. When true,\n * selectable cells become draggable and the grid emits\n * `list-native-drag-start` when a drag begins.\n */\n @property({ type: Boolean, attribute: `items-draggable`, reflect: true })\n itemsDraggable = false;\n\n /**\n * Allow a marquee (region) selection to start from a cell's blank well area —\n * a press that lands on the cell's content container (`.content` / `.thumb`)\n * itself rather than on the item content, caption, or an interactive control.\n * The same press is prevented from starting the cell's native drag.\n *\n * Off by default. The consumer must ensure blank areas are not covered by\n * pointer-eventful slotted nodes (size content to its box and/or set\n * `pointer-events: none` on filler), otherwise the blank area still counts as\n * content and this has no effect.\n */\n @property({ type: Boolean, attribute: `marquee-from-cell-blank`, reflect: true })\n marqueeFromCellBlank = false;\n\n /**\n * Custom drag preview renderer. Receives the selection snapshot and returns\n * an element for `DataTransfer.setDragImage()` plus an optional pre-painted\n * canvas for native hosts. Synchronous by contract — pre-decode thumbnails\n * as selection changes. Defaults to the shared built-in preview.\n */\n @property({ attribute: false })\n dragPreviewRenderer: ListDragPreviewRenderer<T> | undefined;\n\n @property({ type: String, attribute: `search-modes`, reflect: true })\n searchModes: string | undefined;\n\n /**\n * Data items for data-backed mode. When set along with `itemAdapter`, the\n * component operates in data mode instead of element mode.\n */\n @property({ attribute: false })\n items: readonly T[] = [];\n\n /**\n * Adapter for data-backed mode. When set, the component renders items from\n * the `items` array using this adapter instead of projecting light-DOM children.\n */\n @property({ attribute: false })\n itemAdapter: GridListDataAdapterType<T> | undefined;\n\n @state() private _scrollTop = 0;\n @state() private _scrollLeft = 0;\n @state() private _viewportHeight = 0;\n @state() private _viewportWidth = 0;\n\n #viewportRef = createRef<HTMLDivElement>();\n\n #resizeObserver?: ResizeObserver;\n #mutationObserver?: MutationObserver;\n #scrollRaf = 0;\n #items: Element[] = [];\n #itemWrap: `stop` | `wrap` = `stop`;\n\n /** Items added mid-list that are still playing their enter animation. */\n #entering = new Set<Element>();\n /** Timer that ends the `[reflowing]` window opened by a mid-list insertion. */\n #reflowTimer = 0;\n\n /**\n * When cell geometry changes (zoom), the item nearest the viewport centre is\n * captured here in `willUpdate` and the scroll position is corrected in\n * `updated` so that item stays put — rather than the grid anchoring to its\n * top-left corner.\n */\n #zoomAnchor?: { index: number; lineFrac: number };\n\n /**\n * The active view over the items. Element mode projects light-DOM children\n * through named `<slot>`s (owned by {@link ElementGridListSource}); data mode\n * renders from {@link items} via {@link itemAdapter}. Everything else here\n * addresses items by effective index + key and never branches on the mode.\n *\n * Initialised eagerly (element mode) so the public getters — `count`,\n * `selectedKeys`, … — are safe to touch before the first Lit update. The\n * first `willUpdate` rebuilds it once the light DOM / `itemAdapter` is known.\n */\n #sourceElement: ElementGridListSource | undefined = new ElementGridListSource(this);\n #source: GridListSource = this.#sourceElement!;\n\n readonly selection = new ListSelectionController<string>({\n getOrderedItems: () => this.#source.keys(),\n isSelectable: (k) => {\n const i = this.#source.indexOfKey(k);\n return i >= 0 && this.#source.isSelectable(i);\n },\n getModes: () => ({ selectionMode: this.selectionMode, interactionMode: this.interactionMode }),\n getKey: k => k,\n onChange: (selected, previous) => {\n this._syncItemStates();\n this.requestUpdate();\n this.#emitSelect(selected, previous);\n },\n });\n\n readonly tickled = new TickledController<string>(this, {\n // `keys()` is in effective order, so position === effective index — avoid a\n // per-key `indexOfKey` lookup (that would make this O(n²) for large lists).\n getItems: () =>\n this.#source.keys().map((k, i) => ({\n id: k,\n enabled: this.#source.isSelectable(i),\n })),\n onTickle: (k) => {\n // Stop the previous caption pan immediately so two labels never scroll\n // together during the re-render window; `updated()` starts the new one.\n this.#stopActiveCaptionPan();\n if (k !== undefined)\n this.#emitItemEvent(`list-tickle`, k);\n },\n onStateChange: () => this._syncItemStates(),\n itemWrap: this.#itemWrap,\n hoverDisabled: () => this.disableHoverTickle || this.#dragSelect.isDragging || this.#nativeDrag.isDragging,\n });\n\n /** Live drag-select preview: covered keys + the surface-relative rect. */\n #marqueePreview: ReadonlySet<string> = new Set();\n #marqueeRect: DragSelectRect | undefined;\n\n /** Native item drag state: true while a drag is active. */\n #nativeDragging = false;\n /** Key of the cell that originated the native drag. */\n #dragOriginKey: string | undefined = undefined;\n /** Timer handle for post-drag click suppression. */\n #postDragSuppressTimer = 0;\n\n readonly #nativeDrag = new ListNativeDragController<T>(this, {\n source: `grid-list`,\n isEnabled: () => this.itemsDraggable && this.selectionMode !== `none` && this.#source.count > 0,\n resolveEventToKey: (target) => {\n if (target instanceof Element) {\n const cell = target.closest?.(`.cell`) as HTMLElement | null;\n const key = cell?.dataset.key;\n if (key)\n return key;\n const keyed = (target.closest?.(`[data-key]`) as HTMLElement | null)?.dataset.key\n ?? (target as HTMLElement).dataset?.key\n ?? keyForElement(target);\n if (keyed)\n return keyed;\n }\n return undefined;\n },\n prepareSelection: originKey => this.#prepareNativeDrag(originKey),\n getMetrics: () => ({\n itemSize: this.itemSize,\n captionStyle: this.captionStyle,\n captionHeight: this.captionHeight,\n rowHeight: this.#rowHeight(),\n }),\n getRenderer: () => this.dragPreviewRenderer,\n dispatch: detail => this._dispatch<ListNativeDragStartDetail<T>>(`list-native-drag-start`, detail, true),\n onActiveChange: (active, originKey) => {\n this.#nativeDragging = active;\n this.#dragOriginKey = active ? originKey : undefined;\n this.toggleAttribute(`data-native-dragging`, active);\n if (active) {\n const count = [...this.selection.selectedKeys].filter(k => !isSyntheticKey(k)).length;\n this.setAttribute(`aria-label`, count <= 1 ? `Dragging 1 item` : `Dragging ${count} items`);\n } else {\n this.removeAttribute(`aria-label`);\n }\n this.requestUpdate();\n },\n onEnd: () => {\n this.#clearNativeDragState();\n this.#startPostDragSuppressTimer();\n },\n syncLightDomDraggable: () => {\n for (const child of this.children) {\n if (child instanceof HTMLElement)\n child.draggable = this.itemsDraggable;\n }\n },\n shouldStart: event =>\n !(this.marqueeFromCellBlank && this.#isCellBlankPress(event)),\n });\n\n /** Origin rule + display-ordered entry resolution for native drag-out (both modes). */\n #prepareNativeDrag(originKey: string): { origin: ListDragEntry<T>; selected: Array<ListDragEntry<T>> } | undefined {\n const index = this.#source.indexOfKey(originKey);\n if (index < 0 || !this.#source.isSelectable(index))\n return undefined;\n if (!this.selection.selectedKeys.has(originKey))\n this.selection.replace(originKey);\n const ordered = this.#source.keys().filter(k => !isSyntheticKey(k) && this.selection.selectedKeys.has(k));\n const selected: Array<ListDragEntry<T>> = [];\n for (const key of ordered) {\n const entryIndex = this.#source.indexOfKey(key);\n if (entryIndex < 0)\n continue;\n const data = this.#source.resolveKeyToData(key) as T | undefined;\n const element = this.#source.resolveKeyToElement(key);\n const item = (data ?? element) as T | Element;\n if (item === undefined)\n continue;\n selected.push({\n key,\n index: entryIndex,\n item,\n ...(element ? { element } : {}),\n });\n }\n const origin = selected.find(entry => entry.key === originKey);\n if (!origin)\n return undefined;\n return { origin, selected };\n }\n\n /**\n * The single caption pan-text currently scrolling. At most one caption is\n * a pan-text in loop mode at a time — when tickle moves, the old one is\n * stopped before the new one starts (see `#activateTickledPan`).\n */\n #activeCaptionPan: PanTextElement | null = null;\n\n readonly #dragSelect = new ListDragSelectController<string>(this, {\n getSurface: () => this.#viewportRef.value,\n isEnabled: () =>\n this.selection.canDragSelect()\n && this.#source.count > 0\n && !this.hasAttribute(`disable-drag-select`),\n hitTest: rect => this.#marqueeHitTest(rect),\n getBaseSelection: () => this.selection.selected,\n onPreview: (preview, rect) => {\n this.#marqueePreview = preview;\n this.#marqueeRect = rect;\n this.requestUpdate();\n },\n onCommit: (finalSet) => {\n this.selection.applyDragSelection(finalSet);\n this.#marqueePreview = new Set();\n this.#marqueeRect = undefined;\n this.requestUpdate();\n },\n autoScroll: (dx, dy) => {\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n if (dx !== 0) {\n vp.scrollLeft += dx;\n this._scrollLeft = vp.scrollLeft;\n }\n if (dy !== 0) {\n vp.scrollTop += dy;\n this._scrollTop = vp.scrollTop;\n }\n },\n shouldStart: (event) => {\n if (this.marqueeFromCellBlank && this.#isCellBlankPress(event))\n return true;\n for (const node of event.composedPath()) {\n if (node instanceof Element && node.classList.contains(`cell`))\n return false;\n }\n return true;\n },\n });\n\n /**\n * True when a pointer / drag event landed on a cell's blank well: the event\n * target is the cell's content container itself (`.content` / `.thumb`) — i.e.\n * nothing of the item's own content sat under the pointer. Relies on the\n * consumer setting `pointer-events: none` on the blank filler around its cell\n * content so that filler presses land on the well, not on the item element.\n */\n #isCellBlankPress(event: Event): boolean {\n for (const node of event.composedPath()) {\n if (!(node instanceof Element))\n continue;\n if (node.classList.contains(`caption`))\n return false;\n if (node.matches?.(`input,button,a,select,textarea,[contenteditable]`))\n return false;\n // Reached the well with nothing between it and the event target.\n if (node.classList.contains(`content`) || node.classList.contains(`thumb`))\n return true;\n if (node.classList.contains(`cell`))\n return false; // reached the cell without a well — be conservative\n // Any other element seen before the well is the item's own content\n // (glyph / thumbnail / caption text) — this press belongs to the item.\n return false;\n }\n return false;\n }\n\n /**\n * Map a surface-relative (viewport-visible) rect to covered item keys using\n * the same `computeGridWindow` geometry the renderer uses — pure arithmetic,\n * so virtualized off-screen items are covered without DOM measurement.\n */\n #marqueeHitTest(rect: DragSelectRect): string[] {\n const count = this.#source.count;\n if (count === 0)\n return [];\n const horizontal = this.orientation === `row`;\n const win = computeGridWindow(\n count,\n this.itemSize,\n this.#rowHeight(),\n this.gap,\n Math.max(1, this._viewportWidth),\n Math.max(1, this._viewportHeight),\n horizontal ? this._scrollLeft : this._scrollTop,\n this.orientation,\n 0,\n );\n const out: number[] = [];\n if (horizontal) {\n const x0 = rect.x + this._scrollLeft;\n const x1 = x0 + rect.width;\n const lo = Math.max(0, Math.floor(x0 / win.colStride));\n const hi = Math.min(count - 1, Math.floor(x1 / win.colStride));\n for (let i = lo; i <= hi; i++)\n out.push(i);\n } else {\n const x0 = rect.x + this._scrollLeft;\n const x1 = x0 + rect.width;\n const y0 = rect.y + this._scrollTop;\n const y1 = y0 + rect.height;\n const colLo = Math.max(0, Math.floor(x0 / win.colStride));\n const colHi = Math.min(win.cols - 1, Math.floor(x1 / win.colStride));\n const rowLo = Math.max(0, Math.floor(y0 / win.rowStride));\n const rowHi = Math.floor(y1 / win.rowStride);\n for (let row = rowLo; row <= rowHi; row++) {\n for (let col = colLo; col <= colHi; col++) {\n const index = row * win.cols + col;\n if (index >= 0 && index < count)\n out.push(index);\n }\n }\n }\n const keys: string[] = [];\n for (const index of out) {\n const key = this.#source.keyAt(index);\n if (!key || isSyntheticKey(key))\n continue;\n if (!this.#source.isSelectable(index))\n continue;\n keys.push(key);\n }\n return keys;\n }\n\n /**\n * Incremental search (navigate / select / filter). Element- or data-backed\n * depending on the mode; the mode-agnostic surface (`renderField`, `open`,\n * `close`, `setModes`, …) is the same either way. See `docs/infra-incremental.md`.\n */\n search!: ListSearchController<unknown>;\n\n #searchMode: `element` | `data` | undefined;\n #searchFilterKeys: ReadonlySet<string> | undefined;\n\n /** (Re)build {@link search} for the current mode; a no-op if it already matches. */\n #ensureSearch(): void {\n const mode = this.itemAdapter !== undefined ? `data` : `element`;\n if (this.#searchMode === mode && this.search !== undefined)\n return;\n\n const previous = this.search as ListSearchController<unknown> | undefined;\n if (previous) {\n previous.hostDisconnected();\n this.removeController(previous);\n }\n\n this.search = (mode === `data`\n ? new ListSearchController<DataListSearchItem>(this, {\n adapter: createDataListSearchAdapter(this, {\n rawCount: () => this.#source?.rawCount ?? 0,\n rawKeyAt: i => this.#source?.rawKeyAt(i) ?? ``,\n rawSearchTextAt: i => this.#source?.rawSearchTextAt(i) ?? ``,\n onFilterChange: (keys) => {\n this.#searchFilterKeys = keys;\n this.#source?.setFilters({ searchKeys: keys });\n this.requestUpdate();\n void this.updateComplete.then(() => this.#emitViewportChange());\n },\n onActivate: key => this.#onCellActivate(key),\n getHighlightRoot: () => this.renderRoot as ShadowRoot | Element,\n }),\n })\n : new ListSearchController<Element>(this, {\n adapter: createElementListSearchAdapter(this, {\n itemSelector: ITEM_SELECTOR,\n getLabel: el =>\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? el.getAttribute(`data-search-label`)\n ?? el.textContent?.trim()\n ?? ``,\n highlightKey: `grid-list-search`,\n }),\n })) as ListSearchController<unknown>;\n this.#searchMode = mode;\n }\n\n #searchRegistry: CommandRegistry<unknown> | undefined;\n #unregisterSearchCommands: (() => void) | undefined;\n\n /** Command registry carrying this grid's `list.search.*` commands. */\n get registry(): CommandRegistry<unknown> | undefined {\n return this.#searchRegistry;\n }\n\n /** Effective search modes: this component's capability (all three) ∩ the `search-modes` attribute. */\n #effectiveSearchModes(): ListSearchMode[] {\n const raw = this.searchModes?.trim();\n if (raw === undefined)\n return [...LIST_SEARCH_MODES];\n const requested = new Set(raw.split(/\\s+/));\n return LIST_SEARCH_MODES.filter(m => requested.has(m));\n }\n\n #syncSearchCommands(): void {\n if (!this.#searchRegistry || !this.search)\n return;\n this.search.setModes(this.#effectiveSearchModes());\n this.#unregisterSearchCommands?.();\n this.#unregisterSearchCommands = registerListSearchCommands(this.#searchRegistry, this.search);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute(`tabindex`)) {\n this.tabIndex = 0;\n }\n if (!this.hasAttribute(`role`)) {\n this.setAttribute(`role`, `listbox`);\n }\n this.#syncAriaMultiselectable();\n // Reflect caption defaults up-front so the `:host([caption-*])` style rules\n // apply even when the consumer never sets the attributes.\n for (const [attr, value] of [\n [`caption-style`, this.captionStyle],\n [`caption-align`, this.captionAlign],\n [`caption-position`, this.captionPosition],\n [`caption-backdrop`, this.captionBackdrop],\n ] as const) {\n if (!this.hasAttribute(attr)) {\n this.setAttribute(attr, value);\n }\n }\n this.addEventListener(`keydown`, this._onKeyDown as EventListener);\n this.#mutationObserver ??= new MutationObserver(records => this.#onChildrenChanged(records));\n this.#mutationObserver.observe(this, { childList: true, attributeFilter: [`hidden`] });\n this.#searchRegistry ??= createCommandRegistry();\n this.#ensureSearch();\n this.#syncSearchCommands();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#stopActiveCaptionPan();\n this.removeEventListener(`keydown`, this._onKeyDown as EventListener);\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = undefined;\n this.#mutationObserver?.disconnect();\n this.#cancelScrollRaf();\n this.#unregisterSearchCommands?.();\n this.#unregisterSearchCommands = undefined;\n this.#searchRegistry = undefined;\n if (this.#reflowTimer) {\n clearTimeout(this.#reflowTimer);\n this.#reflowTimer = 0;\n }\n if (this.#nativeDragging || this.#nativeDrag.isDragging) {\n this.#clearNativeDragState();\n }\n }\n\n #onChildrenChanged(records?: MutationRecord[]): void {\n const previousLength = this.#items.length;\n this.#syncItems();\n // Prune selection / cursor for elements that were actually removed. Read the\n // records directly rather than diffing `keys()` before/after: a pending\n // `requestUpdate()` can let `updated()` re-sync the source before this\n // callback runs, which would hide the removal from a diff.\n const removedKeys: string[] = [];\n for (const record of records ?? []) {\n for (const node of record.removedNodes) {\n if (node.nodeType !== Node.ELEMENT_NODE)\n continue;\n const key = keyForElement(node as Element);\n if (key !== undefined)\n removedKeys.push(key);\n }\n }\n if (removedKeys.length > 0) {\n const present = new Set(this.#source.keys());\n const gone = removedKeys.filter(k => !present.has(k));\n if (gone.length > 0)\n this.selection.removeKeys(gone, k => k);\n const tickledId = this.tickled.tickledId;\n if (tickledId && gone.includes(tickledId))\n this.tickled.focus(undefined);\n }\n this._syncItemStates();\n this.#noteChildMutation(previousLength, records);\n this.requestUpdate();\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n\n /**\n * When the child list changes mid-list — not a first populate or a wholesale\n * replace — mark any newcomers for an enter animation and open a short\n * `[reflowing]` window so the cells that shift slide to their new position\n * instead of snapping. Removals get the same window (the survivors slide to\n * close the gap). The window is bounded in time so the transform transition\n * never bleeds into scroll virtualisation.\n *\n * Reads the `MutationRecord`s directly rather than diffing `#items`, because a\n * `requestUpdate()` between the DOM change and this callback (e.g. a caller\n * that clears the selection before removing) lets `updated()` re-sync `#items`\n * first, which would hide the change from a naive diff.\n */\n #noteChildMutation(previousLength: number, records?: MutationRecord[]): void {\n if (!this.hasUpdated || !records || records.length === 0)\n return;\n const currentSet = new Set(this.#items);\n const added: Element[] = [];\n let removedCount = 0;\n for (const record of records) {\n for (const node of record.addedNodes) {\n if (node.nodeType === Node.ELEMENT_NODE && currentSet.has(node as Element))\n added.push(node as Element);\n }\n for (const node of record.removedNodes) {\n if (node.nodeType === Node.ELEMENT_NODE)\n removedCount++;\n }\n }\n // Nothing to animate, a first populate, or a wholesale replace (every\n // current item is new) — leave it alone.\n if (added.length === 0 && removedCount === 0)\n return;\n if (previousLength === 0 && removedCount === 0)\n return;\n if (added.length > 0 && added.length === this.#items.length)\n return;\n for (const el of added)\n this.#entering.add(el);\n this.toggleAttribute(`reflowing`, true);\n if (this.#reflowTimer)\n clearTimeout(this.#reflowTimer);\n this.#reflowTimer = window.setTimeout(() => {\n this.#reflowTimer = 0;\n this.#entering.clear();\n this.toggleAttribute(`reflowing`, false);\n this.requestUpdate();\n }, REFLOW_WINDOW_MS);\n }\n\n #emitViewportChange(): void {\n this._dispatch<GridListViewportChangeDetail>(`grid-list-viewport-change`, {\n renderedKeys: this.renderedKeys(),\n visibleKeys: this.visibleKeys(),\n });\n }\n\n protected override firstUpdated(): void {\n if (!this.#source)\n this.#rebuildSource();\n const el = this.#viewportRef.value;\n if (!el)\n return;\n this.#resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const w = entry.contentRect.width;\n const h = entry.contentRect.height;\n // A zero-sized observation (e.g. an inactive dock tab) must never\n // replace the last usable geometry — see #measureViewport / refreshLayout.\n if (w <= 0 || h <= 0)\n return;\n this._viewportWidth = w;\n this._viewportHeight = h;\n }\n });\n this.#resizeObserver.observe(el);\n this.#measureViewport(false);\n this.#syncItems();\n this.requestUpdate();\n this.#nativeDrag.refreshDraggable();\n }\n\n /** (Re)construct {@link #source} for the current mode and re-apply the filters. */\n #rebuildSource(): void {\n if (this.itemAdapter !== undefined) {\n this.#source = new DataGridListSource<T>(this.items, this.itemAdapter);\n this.#sourceElement = undefined;\n } else {\n this.#sourceElement = new ElementGridListSource(this);\n this.#source = this.#sourceElement;\n }\n this.#applyFilters();\n if (this.#searchFilterKeys)\n this.#source.setFilters({ searchKeys: this.#searchFilterKeys });\n }\n\n /** Push the current filter predicate into whichever source is active. */\n #applyFilters(): void {\n if (this.#source instanceof ElementGridListSource) {\n const fp = this.filterPredicate;\n const src = this.#source;\n src.setFilters({ predicate: fp ? i => fp(src.rawElementAt(i)!) : undefined });\n this.#items = src.effectiveElements();\n } else if (this.#source instanceof DataGridListSource) {\n const ip = this.itemFilterPredicate;\n const src = this.#source as DataGridListSource<T>;\n src.setFilters({ predicate: ip ? i => ip(src.rawItemAt(i) as T, i) : undefined });\n }\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has(`searchModes`)) {\n this.#syncSearchCommands();\n }\n if (changed.has(`filterPredicate`) || changed.has(`itemFilterPredicate`)) {\n this.#applyFilters();\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n\n const dataModeChanged = changed.has(`items`) || changed.has(`itemAdapter`);\n if (dataModeChanged) {\n this.#zoomAnchor = undefined;\n const prevKeys = this.#source?.keys() ?? [];\n const modeFlipped = (this.itemAdapter !== undefined)\n !== (this.#source instanceof DataGridListSource);\n this.#rebuildSource();\n const nextKeys = this.#source.keys();\n const nextKeySet = new Set(nextKeys);\n const removedKeys = prevKeys.filter(k => !nextKeySet.has(k));\n if (removedKeys.length > 0)\n this.selection.removeKeys(removedKeys, k => k);\n const tickledId = this.tickled.tickledId;\n if (tickledId && !nextKeySet.has(tickledId))\n this.tickled.focus(undefined);\n this._syncItemStates();\n // No requestUpdate() here — we're already in willUpdate, the render that\n // follows picks up the rebuilt source.\n void this.updateComplete.then(() => this.#emitViewportChange());\n if (modeFlipped) {\n this.#ensureSearch();\n this.#syncSearchCommands();\n }\n this.search?.refresh();\n }\n\n if (changed.has(`itemSize`) || changed.has(`gap`)) {\n this.itemSize = Math.max(MIN_ITEM_SIZE, Math.round(this.itemSize));\n this.gap = Math.max(0, Math.round(this.gap));\n }\n if (changed.has(`captionHeight`)) {\n this.captionHeight = Math.max(0, Math.round(this.captionHeight));\n }\n if (changed.has(`itemWrap`)) {\n this.#itemWrap = this.itemWrap;\n }\n\n const geometryChanged = changed.has(`itemSize`) || changed.has(`gap`)\n || changed.has(`captionStyle`) || changed.has(`captionHeight`)\n || changed.has(`orientation`);\n if (geometryChanged && this.hasUpdated && this.#source.count > 0) {\n const prevOrientation = (changed.get(`orientation`) as GridListOrientation | undefined) ?? this.orientation;\n const horizontal = prevOrientation === `row`;\n const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;\n const prevExtent = horizontal ? this._viewportWidth : this._viewportHeight;\n if (prevExtent > 0 && prevOffset > 1) {\n const prevItemSize = (changed.get(`itemSize`) as number | undefined) ?? this.itemSize;\n const prevGap = (changed.get(`gap`) as number | undefined) ?? this.gap;\n const prevCaptionStyle = (changed.get(`captionStyle`) as GridListCaptionStyle | undefined) ?? this.captionStyle;\n const prevCaptionHeight = (changed.get(`captionHeight`) as number | undefined) ?? this.captionHeight;\n this.#captureCentreAnchor(prevOffset, prevExtent, prevItemSize, prevGap, prevCaptionStyle, prevCaptionHeight, prevOrientation);\n }\n }\n }\n\n #syncAriaMultiselectable(): void {\n this.setAttribute(\n `aria-multiselectable`,\n this.selection.canSelectMultiple() ? `true` : `false`,\n );\n }\n\n /** Full cell height: the square, plus a caption band in `separate` / `under`. */\n #rowHeight(): number {\n const captionBand = this.captionStyle === `separate` || this.captionStyle === `under`;\n return this.itemSize + (captionBand ? this.captionHeight : 0);\n }\n\n #captionFor(el: Element): string {\n return (\n el.getAttribute(`data-label`)\n ?? el.querySelector(`[data-grid-list-caption]`)?.textContent?.trim()\n ?? ``\n );\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n super.updated(changed);\n this.#syncItems();\n if (changed.has(`selectionMode`) || changed.has(`interactionMode`)) {\n this.selection.clearAnchor();\n this.#syncAriaMultiselectable();\n }\n if (changed.has(`itemsDraggable`)) {\n this.#nativeDrag.refreshDraggable();\n }\n if (changed.has(`orientation`)) {\n // Reset the axis that's no longer scrollable so a later switch back\n // doesn't inherit a stale offset.\n const vp = this.#viewportRef.value;\n if (vp) {\n if (this.orientation === `row`) {\n vp.scrollTop = 0;\n this._scrollTop = 0;\n } else {\n vp.scrollLeft = 0;\n this._scrollLeft = 0;\n }\n }\n }\n const vp = this.#viewportRef.value;\n if (vp) {\n if (Math.abs(vp.scrollTop - this._scrollTop) > 0.5) {\n vp.scrollTop = this._scrollTop;\n }\n if (Math.abs(vp.scrollLeft - this._scrollLeft) > 0.5) {\n vp.scrollLeft = this._scrollLeft;\n }\n }\n this.#applyZoomAnchor();\n this.#activateTickledPan();\n }\n\n /** Re-anchor the scroll so the item captured in `willUpdate` stays centred. */\n #applyZoomAnchor(): void {\n if (!this.#zoomAnchor)\n return;\n const { index, lineFrac } = this.#zoomAnchor;\n this.#zoomAnchor = undefined;\n\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n const win = this.#currentWindow();\n\n if (win.horizontal) {\n if (this._viewportWidth <= 0)\n return;\n const targetCenter = (index + lineFrac) * win.colStride;\n const maxScroll = Math.max(0, win.totalWidth - this._viewportWidth);\n const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportWidth / 2));\n if (Math.abs(vp.scrollLeft - next) > 0.5) {\n vp.scrollLeft = next;\n this._scrollLeft = next;\n }\n return;\n }\n\n if (this._viewportHeight <= 0)\n return;\n const line = win.cols > 0 ? Math.floor(index / win.cols) : 0;\n const targetCenter = (line + lineFrac) * win.rowStride;\n const maxScroll = Math.max(0, win.totalHeight - this._viewportHeight);\n const next = Math.min(maxScroll, Math.max(0, targetCenter - this._viewportHeight / 2));\n if (Math.abs(vp.scrollTop - next) > 0.5) {\n vp.scrollTop = next;\n this._scrollTop = next;\n }\n }\n\n #captureCentreAnchor(prevOffset: number, prevExtent: number, prevItemSize: number, prevGap: number, prevCaptionStyle: GridListCaptionStyle, prevCaptionHeight: number, prevOrientation: GridListOrientation): void {\n const count = this.#source?.count ?? 0;\n if (count === 0)\n return;\n const prevBand = prevCaptionStyle === `separate` || prevCaptionStyle === `under`;\n const prevRowHeight = prevItemSize + (prevBand ? prevCaptionHeight : 0);\n const horizontal = prevOrientation === `row`;\n const prev = computeGridWindow(\n count,\n prevItemSize,\n prevRowHeight,\n prevGap,\n this._viewportWidth,\n this._viewportHeight,\n prevOffset,\n prevOrientation,\n );\n const mainStride = horizontal ? prev.colStride : prev.rowStride;\n const centerLine = (prevOffset + prevExtent / 2) / mainStride;\n const lineFloor = Math.max(0, Math.floor(centerLine));\n const index = horizontal\n ? Math.min(count - 1, lineFloor)\n : Math.min(\n count - 1,\n lineFloor * prev.cols + Math.max(0, Math.floor((prev.cols - 1) / 2)),\n );\n this.#zoomAnchor = { index, lineFrac: centerLine - lineFloor };\n }\n\n /**\n * Re-read the viewport after an ancestor's visibility/layout changed.\n * Safe while hidden (zero-sized reads are ignored); forces a repaint of the\n * virtual window even when the size is unchanged.\n */\n refreshLayout(): void {\n this.#measureViewport(true);\n }\n\n /** Alias of {@link refreshLayout}. */\n remeasure(): void {\n this.#measureViewport(true);\n }\n\n #measureViewport(forceRender = false): void {\n const vp = this.#viewportRef.value;\n if (!vp)\n return;\n const w = vp.clientWidth;\n const h = vp.clientHeight;\n if (w <= 0 || h <= 0)\n return;\n const horizontal = this.orientation === `row`;\n const changed = w !== this._viewportWidth || h !== this._viewportHeight;\n if (changed) {\n const prevOffset = horizontal ? this._scrollLeft : this._scrollTop;\n const prevExtent = horizontal ? w : h;\n this.#captureCentreAnchor(\n prevOffset,\n prevExtent,\n this.itemSize,\n this.gap,\n this.captionStyle,\n this.captionHeight,\n this.orientation,\n );\n this._viewportWidth = w;\n this._viewportHeight = h;\n }\n if (forceRender && !changed) {\n this.#captureCentreAnchor(\n horizontal ? this._scrollLeft : this._scrollTop,\n horizontal ? w : h,\n this.itemSize,\n this.gap,\n this.captionStyle,\n this.captionHeight,\n this.orientation,\n );\n this.requestUpdate();\n }\n if (changed || forceRender) {\n void this.updateComplete.then(() => this.#emitViewportChange());\n }\n }\n\n /**\n * Element mode only: re-read the light DOM into the source and refresh the\n * `#items` cache + filter. A no-op in data mode (the source is rebuilt through\n * `#rebuildSource` when `items` / `itemAdapter` change).\n */\n #syncItems(): void {\n if (this.#source instanceof ElementGridListSource) {\n this.#source.refresh();\n this.#applyFilters();\n }\n }\n\n get count(): number {\n return this.#source.count;\n }\n\n /**\n * Number of cells currently rendered in the shadow DOM. With virtualization\n * this is roughly the visible rows plus overscan, regardless of how large\n * `count` is — useful for demos/diagnostics.\n */\n get renderedCount(): number {\n return this.renderRoot.querySelectorAll(`.cell`).length;\n }\n\n get selectedItems(): ReadonlySet<Element> {\n const els = new Set<Element>();\n for (const key of this.selection.selectedKeys) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n els.add(el);\n }\n return els;\n }\n\n /**\n * The selection as stable `data-key` / `data-value` strings. Auto-assigned\n * keys for keyless light-DOM items are omitted (they are not a stable contract\n * for the consumer).\n */\n get selectedKeys(): ReadonlySet<string> {\n const out = new Set<string>();\n for (const k of this.selection.selectedKeys) {\n if (!isSyntheticKey(k))\n out.add(k);\n }\n return out;\n }\n\n select(item: Element): void {\n const key = keyForElement(item);\n if (key)\n this.selection.replace(key);\n }\n\n selectMany(items: Iterable<Element>): void {\n const keys: string[] = [];\n for (const item of items) {\n const key = keyForElement(item);\n if (key)\n keys.push(key);\n }\n this.selection.selectMany(keys);\n }\n\n deselect(item: Element): void {\n const key = keyForElement(item);\n if (key)\n this.selection.deselect(key);\n }\n\n clearSelection(): void {\n this.selection.clear();\n }\n\n selectAll(): void {\n if (this.selection.canSelectAll()) {\n this.selection.selectAll();\n }\n }\n\n /**\n * Replace the selection with the items carrying these keys. Unknown keys are\n * ignored; survives the host rebuilding the item set. Requires each item to\n * have a `data-key` (or `data-value`).\n */\n selectKeys(keys: Iterable<string>): void {\n this.selection.selectKeys(keys, k => k);\n }\n\n /** Add items by key to the selection (multi-select modes only). */\n addSelectedKeys(keys: Iterable<string>): void {\n this.selection.addKeys(keys, k => k);\n }\n\n /** Remove items by key from the selection. */\n removeSelectedKeys(keys: Iterable<string>): void {\n this.selection.removeKeys(keys, k => k);\n }\n\n /**\n * Data mode only: raw index of `key` in `this.items`, or `-1`. Data-mode keys\n * come straight from the adapter, so this is exact even under a filter/search.\n */\n #rawIndexOfKey(key: string): number {\n const adapter = this.itemAdapter;\n if (!adapter)\n return -1;\n return this.items.findIndex((it, i) => adapter.key(it, i) === key);\n }\n\n /**\n * Data mode: replace the whole item array. Selection and cursor keep any key\n * that is still present; keys that vanish are dropped (one `list-select`).\n * A no-op in element mode.\n */\n setItems(items: readonly T[]): void {\n if (this.itemAdapter)\n this.items = items;\n }\n\n /**\n * Data mode: append items to the end. Scroll position, selection and cursor\n * are untouched; appended items don't play the mid-list `[reflowing]` slide.\n * A no-op in element mode.\n */\n appendItems(items: readonly T[]): void {\n if (this.itemAdapter && items.length > 0)\n this.items = [...this.items, ...items];\n }\n\n /**\n * Data mode: replace the item carrying `key`. A visible cell re-renders in\n * place (the keyed subtree is kept); an offscreen item shows its new content\n * when scrolled into view. Scroll and selection are untouched. Unknown keys\n * are ignored.\n */\n updateItem(key: string, item: T): void {\n if (!this.itemAdapter)\n return;\n const idx = this.#rawIndexOfKey(key);\n if (idx < 0)\n return;\n const next = [...this.items];\n next[idx] = item;\n this.items = next;\n }\n\n /**\n * Data mode: remove the items carrying these keys. Removed keys are dropped\n * from selection and cursor (via the `items` change). A no-op in element mode.\n */\n removeItems(keys: Iterable<string>): void {\n if (!this.itemAdapter)\n return;\n const adapter = this.itemAdapter;\n const keySet = new Set(keys);\n this.items = this.items.filter((it, i) => !keySet.has(adapter.key(it, i)));\n }\n\n /**\n * Data mode: drop every item. Selection and cursor are reset and one\n * `list-select` with empty sets is emitted. A no-op in element mode.\n */\n clearItems(): void {\n if (!this.itemAdapter)\n return;\n this.selection.reset();\n this.tickled.focus(undefined);\n this.items = [];\n this.#emitSelect(new Set(), new Set());\n }\n\n /** Move the cursor to the item with this key and scroll it into view. */\n focusKey(key: string): void {\n const index = this.#source.indexOfKey(key);\n if (index < 0)\n return;\n this.tickled.focus(key);\n this.#scrollItemIntoView(key);\n }\n\n /** The key of the item under the cursor, or `undefined`. */\n get tickledKey(): string | undefined {\n return this.tickled.tickledId;\n }\n\n /** Element mode: the light-DOM element carrying `key`, or `undefined`. */\n getItem(key: string): Element | undefined {\n return this.#source.resolveKeyToElement(key);\n }\n\n /** Element mode: the light-DOM element at effective index `index`. */\n getItemByIndex(index: number): Element | undefined {\n return this.#items[index];\n }\n\n /** Data mode: the data value carrying `key`, or `undefined`. */\n getData(key: string): T | undefined {\n return this.#source.resolveKeyToData(key) as T | undefined;\n }\n\n getKey(item: Element): string | undefined {\n return keyForElement(item);\n }\n\n /**\n * Keys of items in the rendered window (viewport + overscan) — the priority\n * set for prefetching. Use {@link visibleKeys} for the strict viewport\n * intersection. Auto-assigned keyless-item keys are omitted.\n */\n renderedKeys(): string[] {\n return this.#windowKeys(this.#currentWindow());\n }\n\n /**\n * Keys of items actually intersecting the viewport (no overscan).\n * Auto-assigned keyless-item keys are omitted.\n */\n visibleKeys(): string[] {\n return this.#windowKeys(this.#currentWindow(true));\n }\n\n #windowKeys(win: GridWindow): string[] {\n return this.#source\n .keys()\n .slice(win.startIndex, win.endIndex)\n .filter(k => !isSyntheticKey(k));\n }\n\n #currentWindow(noOverscan = false): GridWindow {\n const overscan = noOverscan ? 0 : 2;\n return computeGridWindow(\n this.#source.count,\n this.itemSize,\n this.#rowHeight(),\n this.gap,\n this._viewportWidth,\n this._viewportHeight,\n this.orientation === `row` ? this._scrollLeft : this._scrollTop,\n this.orientation,\n overscan,\n );\n }\n\n /** Adjust the scroll offset so `key` is fully within the viewport. */\n #scrollItemIntoView(key: string): void {\n const index = this.#source.indexOfKey(key);\n const vp = this.#viewportRef.value;\n if (index < 0 || !vp)\n return;\n const win = this.#currentWindow();\n\n if (win.horizontal) {\n const left = index * win.colStride;\n const right = left + this.itemSize;\n const viewLeft = vp.scrollLeft;\n let next = viewLeft;\n if (left < viewLeft)\n next = left;\n else if (right > viewLeft + this._viewportWidth)\n next = right - this._viewportWidth;\n if (next !== viewLeft) {\n vp.scrollLeft = next;\n this._scrollLeft = next;\n }\n return;\n }\n\n const row = win.cols > 0 ? Math.floor(index / win.cols) : 0;\n const top = row * win.rowStride;\n const bottom = top + this.#rowHeight();\n const viewTop = vp.scrollTop;\n let next = viewTop;\n if (top < viewTop)\n next = top;\n else if (bottom > viewTop + this._viewportHeight)\n next = bottom - this._viewportHeight;\n if (next !== viewTop) {\n vp.scrollTop = next;\n this._scrollTop = next;\n }\n }\n\n private _syncItemStates(): void {\n const selected = this.selection.selectedKeys;\n for (const el of this.#items) {\n const key = keyForElement(el);\n el.toggleAttribute(`data-tickled`, key !== undefined && this.tickled.isTickled(key));\n el.toggleAttribute(`data-selected`, key !== undefined && selected.has(key));\n }\n this.setAttribute(`data-input-mode`, this.tickled.inputMode);\n }\n\n #emitSelect(selected: ReadonlySet<string>, previous: ReadonlySet<string>): void {\n const selectedEls = new Set<Element>();\n const previousEls = new Set<Element>();\n for (const key of selected) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n selectedEls.add(el);\n }\n for (const key of previous) {\n const el = this.#source.resolveKeyToElement(key);\n if (el)\n previousEls.add(el);\n }\n this._dispatch<GridListSelectDetail>(`list-select`, {\n selected: selectedEls,\n previous: previousEls,\n selectedKeys: this.selectedKeys,\n previousKeys: new Set([...previous].filter(k => !isSyntheticKey(k))),\n });\n }\n\n #emitItemEvent(name: `list-tickle` | `list-item-click` | `list-activate`, key: string): void {\n const index = this.#source.indexOfKey(key);\n const element = this.#source.resolveKeyToElement(key);\n const item = element ?? this.#source.resolveKeyToData(key);\n this._dispatch<GridListItemClickDetail>(name, { item, key, index, element });\n }\n\n private _dispatch<T>(name: string, detail: T, cancelable = false): boolean {\n return this.dispatchEvent(\n new CustomEvent<T>(name, {\n detail,\n bubbles: true,\n composed: true,\n cancelable,\n }),\n );\n }\n\n /** Selected keys, snapshotted once per render so the cell renderers don't each rebuild the set. */\n #selectedSnapshot: ReadonlySet<string> = new Set();\n\n #marqueeStyle(rect: DragSelectRect): string {\n return `left:${rect.x}px;top:${rect.y}px;width:${Math.max(0, rect.width)}px;height:${Math.max(0, rect.height)}px`;\n }\n\n protected override render(): ReturnType<typeof html> {\n const win = this.#currentWindow();\n this.#selectedSnapshot = this.selection.selectedKeys;\n const spacerStyle = win.horizontal\n ? `width:${win.totalWidth}px;height:100%`\n : `height:${win.totalHeight}px`;\n // Fade the edge that can still be scrolled towards (see ../styles/scroll-fade.ts).\n const scrollFade = win.horizontal ? `scroll-fade-x` : `scroll-fade-y`;\n return html`\n <div\n class=\"viewport ${scrollFade}\"\n part=\"viewport\"\n ${ref(this.#viewportRef)}\n data-input-mode=${this.tickled.inputMode}\n @scroll=${this.#onScroll}\n >\n <div class=\"spacer\" style=${spacerStyle}>\n ${this.#source instanceof DataGridListSource\n ? this.#renderDataCells(win)\n : this.#renderElementCells(win)}\n </div>\n ${this.#marqueeRect\n ? html`<div class=\"marquee\" part=\"marquee\" style=${this.#marqueeStyle(this.#marqueeRect)}></div>`\n : ``}\n </div>\n ${this.search?.renderField()}\n `;\n }\n\n #renderDataCells(win: GridWindow): ReturnType<typeof html> {\n const slice = Array.from({ length: win.endIndex - win.startIndex }, (_, i) => win.startIndex + i);\n return repeat(\n slice,\n index => this.#source.keyAt(index),\n index => this.#renderDataCell(index, win),\n ) as ReturnType<typeof html>;\n }\n\n #renderDataCell(index: number, win: GridWindow): ReturnType<typeof html> {\n const key = this.#source.keyAt(index);\n const selected = this.#selectedSnapshot.has(key);\n const marquee = this.#marqueePreview.has(key);\n const tickled = this.tickled.isTickled(key);\n const selectable = this.#source.isSelectable(index);\n const draggable = this.itemsDraggable && selectable;\n const style = this.captionStyle;\n const separate = style === `separate`;\n const caption = style === `hidden` ? `` : this.#source.labelAt(index);\n const showCaption = caption !== ``;\n const cellHeight = win.rowStride - this.gap;\n const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;\n const y = win.horizontal\n ? Math.max(0, (this._viewportHeight - cellHeight) / 2)\n : rowOf(index, win.cols) * win.rowStride;\n const captionCss = separate\n ? `height:${Math.max(0, this.captionHeight - 4)}px`\n : style === `under`\n ? `height:${this.captionHeight}px`\n : ``;\n return html`\n <div\n class=\"cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}${marquee ? ` marquee` : ``}${this.#nativeDragging && key === this.#dragOriginKey ? ` dragging-origin` : ``}\"\n part=\"item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}\"\n role=\"option\"\n aria-selected=${selected ? `true` : `false`}\n style=\"width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)\"\n data-index=${index}\n data-key=${key}\n draggable=${draggable ? `true` : `false`}\n ?data-selected=${selected}\n ?data-tickled=${tickled}\n ?data-marquee=${marquee}\n @click=${(e: MouseEvent) => this.#onCellClick(e, key)}\n @dblclick=${() => this.#onCellActivate(key)}\n @pointerenter=${() => this.tickled.handlePointerEnter(key)}\n >\n <div class=\"content\" part=\"content\">${this.#source.renderCellContent(index)}</div>\n ${showCaption ? this.#renderCaption(caption, captionCss, tickled) : ``}\n </div>\n `;\n }\n\n /**\n * A tickled cell swaps its plain label for an `ixfx-pan-text` in loop mode\n * so a truncated label scrolls instead of staying an ellipsis. Unticked\n * cells keep the cheap plain-text caption.\n */\n #renderCaption(caption: string, captionCss: string, tickled: boolean): ReturnType<typeof html> {\n if (tickled) {\n return html`<div class=\"caption\" part=\"caption\" style=${captionCss} title=${caption}><ixfx-pan-text mode=\"loop\">${caption}</ixfx-pan-text></div>`;\n }\n return html`<div class=\"caption\" part=\"caption\" style=${captionCss} title=${caption}>${caption}</div>`;\n }\n\n /** Stop the active caption pan, if any, and forget it. */\n #stopActiveCaptionPan(): void {\n const active = this.#activeCaptionPan;\n this.#activeCaptionPan = null;\n try {\n active?.stopLoop?.();\n } catch {\n // A disconnected element may throw on update — it is already gone.\n }\n }\n\n /**\n * Enforce a single scrolling caption: the tickled cell's pan-text loops,\n * every other pan-text is stopped. The pan-text also auto-starts when\n * `mode=\"loop\"` is set; this covers the case where the element was already\n * connected before overflow was measured.\n */\n #activateTickledPan(): void {\n const tickledCell = this.renderRoot.querySelector(`.cell[data-tickled]`);\n const pans = [...this.renderRoot.querySelectorAll(`ixfx-pan-text[mode=\"loop\"]`)] as unknown as PanTextElement[];\n const current = (tickledCell?.querySelector(`ixfx-pan-text[mode=\"loop\"]`) ?? null) as unknown as PanTextElement | null;\n\n for (const pan of pans) {\n if (pan !== current) {\n try {\n pan.stopLoop?.();\n } catch {\n // Already disconnected — nothing left to stop.\n }\n }\n }\n\n const active = this.#activeCaptionPan;\n if (active && active !== current) {\n try {\n active.stopLoop?.();\n } catch {\n // Already disconnected — nothing left to stop.\n }\n }\n\n if (!current) {\n this.#activeCaptionPan = null;\n return;\n }\n this.#activeCaptionPan = current;\n current.startLoop?.();\n }\n\n #renderElementCells(win: GridWindow): ReturnType<typeof html> {\n const slice = this.#items.slice(win.startIndex, win.endIndex);\n return repeat(\n slice,\n (_el, i) => this.#source.keyAt(win.startIndex + i),\n (el, i) => this.#renderCell(el, win.startIndex + i, win),\n ) as ReturnType<typeof html>;\n }\n\n #renderCell(el: Element, index: number, win: GridWindow): ReturnType<typeof html> {\n const key = this.#source.keyAt(index);\n const selected = this.#selectedSnapshot.has(key);\n const marquee = this.#marqueePreview.has(key);\n const tickled = this.tickled.isTickled(key);\n const entering = this.#entering.has(el);\n const selectable = this.#source.isSelectable(index);\n const draggable = this.itemsDraggable && selectable;\n const style = this.captionStyle;\n const separate = style === `separate`;\n const caption = style === `hidden` ? `` : this.#captionFor(el);\n const showCaption = caption !== ``;\n const cellHeight = win.rowStride - this.gap;\n const x = win.horizontal ? index * win.colStride : columnOf(index, win.cols) * win.colStride;\n // `row`: a single row, vertically centred in the viewport.\n const y = win.horizontal\n ? Math.max(0, (this._viewportHeight - cellHeight) / 2)\n : rowOf(index, win.cols) * win.rowStride;\n const thumbStyle = separate ? `height:${this.itemSize}px` : ``;\n const captionCss = separate\n ? `height:${Math.max(0, this.captionHeight - 4)}px`\n : style === `under`\n ? `height:${this.captionHeight}px`\n : ``;\n return html`\n <div\n class=\"cell${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}${entering ? ` entering` : ``}${marquee ? ` marquee` : ``}${this.#nativeDragging && key === this.#dragOriginKey ? ` dragging-origin` : ``}\"\n part=\"item${selected ? ` selected` : ``}${tickled ? ` tickled` : ``}\"\n role=\"option\"\n aria-selected=${selected ? `true` : `false`}\n style=\"width:${this.itemSize}px;height:${cellHeight}px;transform:translate(${x}px,${y}px)\"\n data-index=${index}\n data-key=${key}\n draggable=${draggable ? `true` : `false`}\n ?data-selected=${selected}\n ?data-tickled=${tickled}\n ?data-marquee=${marquee}\n @click=${(e: MouseEvent) => this.#onCellClick(e, key)}\n @dblclick=${() => this.#onCellActivate(key)}\n @pointerenter=${() => this.tickled.handlePointerEnter(key)}\n >\n <div class=\"thumb\" part=\"thumb\" style=${thumbStyle}>\n ${this.#source.renderCellContent(index)}\n </div>\n ${showCaption ? this.#renderCaption(caption, captionCss, tickled) : ``}\n </div>\n `;\n }\n\n #onScroll = (e: Event): void => {\n const el = e.target as HTMLDivElement;\n this.#cancelScrollRaf();\n this.#scrollRaf = requestAnimationFrame(() => {\n this.#scrollRaf = 0;\n this._scrollTop = el.scrollTop;\n this._scrollLeft = el.scrollLeft;\n this.#emitViewportChange();\n });\n };\n\n #cancelScrollRaf(): void {\n if (this.#scrollRaf !== 0) {\n cancelAnimationFrame(this.#scrollRaf);\n this.#scrollRaf = 0;\n }\n }\n\n #onCellClick(e: MouseEvent, key: string): void {\n if (this.#dragSelect.isDragging || this.#nativeDragging || this.#nativeDrag.isDragging || this.#postDragSuppressTimer !== 0)\n return;\n this.selection.handleClick(key, e);\n this.#emitItemEvent(`list-item-click`, key);\n }\n\n #startPostDragSuppressTimer(): void {\n if (this.#postDragSuppressTimer) {\n clearTimeout(this.#postDragSuppressTimer);\n }\n this.#postDragSuppressTimer = window.setTimeout(() => {\n this.#postDragSuppressTimer = 0;\n }, 0);\n }\n\n #clearNativeDragState(): void {\n this.#nativeDragging = false;\n this.#dragOriginKey = undefined;\n this.toggleAttribute(`data-native-dragging`, false);\n this.removeAttribute(`aria-label`);\n }\n\n #onCellActivate(key: string): void {\n if (this.interactionMode !== `manual`) {\n this.selection.replace(key);\n }\n this.#emitItemEvent(`list-activate`, key);\n }\n\n private _onKeyDown = (e: KeyboardEvent): void => {\n if ((e.ctrlKey || e.metaKey) && e.key === `f`) {\n return;\n }\n if ((e.ctrlKey || e.metaKey) && e.key === `a`) {\n if (this.selection.canSelectAll()) {\n e.preventDefault();\n this.selection.selectAll();\n }\n return;\n }\n\n const count = this.#source.count;\n if (count === 0)\n return;\n\n const win = this.#currentWindow();\n const move = (delta: number): void => {\n const from = this.tickled.tickledId\n ? this.#source.indexOfKey(this.tickled.tickledId)\n : -1;\n const nextIndex = Math.max(0, Math.min(count - 1, from + delta));\n const nextKey = this.#source.keyAt(nextIndex);\n if (nextKey) {\n this.tickled.handleKeyboardNavigation(nextKey);\n this.#scrollItemIntoView(nextKey);\n }\n };\n\n // In `grid` a vertical arrow jumps a whole row; in `row`/`column` every\n // arrow just steps one item along the single line.\n const perLine = this.orientation === `grid` ? win.cols : 1;\n\n switch (e.key) {\n case `ArrowLeft`:\n move(-1);\n break;\n case `ArrowRight`:\n move(1);\n break;\n case `ArrowUp`:\n move(-perLine);\n break;\n case `ArrowDown`:\n move(perLine);\n break;\n case `Home`:\n this.tickled.handleKeyboardNavigation(`first`);\n if (this.tickled.tickledId) {\n this.#scrollItemIntoView(this.tickled.tickledId);\n }\n break;\n case `End`:\n this.tickled.handleKeyboardNavigation(`last`);\n if (this.tickled.tickledId) {\n this.#scrollItemIntoView(this.tickled.tickledId);\n }\n break;\n case `PageUp`:\n case `PageDown`: {\n const mainExtent = win.horizontal ? this._viewportWidth : this._viewportHeight;\n const mainStride = win.horizontal ? win.colStride : win.rowStride;\n const visibleLines = Math.max(1, Math.floor(mainExtent / mainStride));\n move((e.key === `PageDown` ? 1 : -1) * visibleLines * perLine);\n break;\n }\n case `Enter`: {\n const id = this.tickled.tickledId;\n if (id) {\n e.preventDefault();\n this.#emitItemEvent(`list-item-click`, id);\n this.#onCellActivate(id);\n }\n break;\n }\n case ` `: {\n const id = this.tickled.tickledId;\n if (id) {\n e.preventDefault();\n this.selection.handleSpace(id);\n }\n break;\n }\n case `Escape`:\n if (this.#nativeDragging) {\n this.#clearNativeDragState();\n }\n this.selection.clear();\n break;\n default:\n return;\n }\n e.preventDefault();\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ixfx-grid-list': GridListElement;\n }\n}\n\nexport interface GridListElement {\n addEventListener<K extends keyof GridListFullElementEventMap>(\n type: K,\n listener: (this: GridListElement, ev: GridListFullElementEventMap[K]) => void,\n options?: boolean | AddEventListenerOptions,\n ): void;\n addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,MAAMA,kBAAgB;AACtB,MAAM,mBAAmB;;AAGzB,SAAgB,eAAe,KAAsB;CACnD,OAAO,IAAI,WAAW,gBAAgB;AACxC;AAEA,SAAS,kBAAkB,MAA+B;CACxD,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,KAAK,MAAM;EACpB,IAAI,eAAe,CAAC,GAClB;EACF,IAAI,KAAK,IAAI,CAAC,GACZ,MAAM,IAAI,CAAC;OAEX,KAAK,IAAI,CAAC;CACd;CACA,IAAI,MAAM,OAAO,GACf,QAAQ,KACN,yCAAyC,CAAC,GAAG,KAAK,CAAC,CAAC,KAAI,MAAK,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK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