Add a finder and a section index to Data Layers

The Data Layers panel gains a search field, an All / On / Off and category
filter, and a tick index down its side for jumping between sections. Both
sit beside the Data Library browse control.

Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
Manjunath PaparajuandSameh Khamis authored and Sameh Khamis committed 2026-11-14 16:12:59 -08:00
1 parent b7160492e0
commit 584e77dc4f
5 files changed
+512

No files matched your search

+74
View File
@@ -0,0 +1,74 @@
<script setup>
import { onBeforeUnmount, onMounted, ref } from 'vue';
import { t } from '../../../i18n/index.js';
// A slim index beside the Data Layers list: one tick per group (Movement,
// Cameras, Infrastructure…). Hovering a tick names its group, clicking it
// scrolls the list there, and the tick for the group in view is lit. It reads
// the list's group headings, which LayerRows renders, so it follows whatever
// groups the layers bring.
const sections = ref([]);
const current = ref(0);
let list = null;
let observer = null;
let resize = null;
function headings() {
return list ? [...list.querySelectorAll('.data-layer-group-heading:not(.is-filtered)')] : [];
}
function readSections() {
sections.value = headings().map((h, i) => ({ i, label: h.textContent.trim() }));
syncCurrent();
}
function syncCurrent() {
if (!list) return;
const top = list.getBoundingClientRect().top + 8;
let index = 0;
headings().forEach((h, i) => {
if (h.getBoundingClientRect().top <= top + 4) index = i;
});
// At the very end of the list the last group is the one in view.
const scrolls = list.clientHeight > 0 && list.scrollHeight > list.clientHeight + 2;
if (scrolls && list.scrollTop + list.clientHeight >= list.scrollHeight - 2) index = sections.value.length - 1;
current.value = Math.max(0, index);
}
function jump(i) {
const h = headings()[i];
if (!h || !list) return;
list.scrollTo({ top: h.offsetTop - list.offsetTop - 4, behavior: 'smooth' });
}
onMounted(() => {
list = document.getElementById('data-toggles');
if (!list) return;
observer = new MutationObserver(readSections);
observer.observe(list, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['class'] });
list.addEventListener('scroll', syncCurrent, { passive: true });
// The list is hidden while the panel is shut; read again when it opens.
resize = new ResizeObserver(syncCurrent);
resize.observe(list);
readSections();
});
onBeforeUnmount(() => {
observer?.disconnect();
resize?.disconnect();
list?.removeEventListener('scroll', syncCurrent);
});
</script>
<template>
<nav v-if="sections.length > 1" class="layer-section-index" :aria-label="t('Layer groups')">
<button
v-for="section in sections"
:key="section.i"
type="button"
class="layer-section-index__tick"
:class="{ 'is-current': section.i === current }"
:aria-label="t('Jump to {name}', { name: section.label })"
:aria-current="section.i === current ? 'true' : undefined"
@click="jump(section.i)"
>
<span class="layer-section-index__label" aria-hidden="true">{{ section.label }}</span>
</button>
</nav>
</template>