From: Javier Sagredo Date: Sun, 3 May 2026 23:36:23 +0000 (+0200) Subject: Data families: (data) label, hide synthetic RHS, per-family filter; fix instance... X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=fd66da4600fd5ccafdf27a2af4c57375fe34603b;p=classgraph.git Data families: (data) label, hide synthetic RHS, per-family filter; fix instance source spans --- diff --git a/data/viewer.js b/data/viewer.js index 514f6c2..0eb256f 100644 --- a/data/viewer.js +++ b/data/viewer.js @@ -149,13 +149,26 @@ } // ------------------------------------------------------------------------- - // Instance filter (right-hand side panel) + // Visibility filter (right-hand side panel) — used in *both* the instance + // view (per-class instance checkboxes) and the family view (per-family + // type-instance checkboxes). The DOM is shared; each row carries a + // data-kind ("inst" or "fam") so the change handler routes the toggle + // to the right per-target hidden-set Map. const filterEl = document.getElementById('instance-filter'); const filterListEl = document.getElementById('filter-list'); const filterSummary = document.getElementById('filter-summary'); const filterSearch = document.getElementById('filter-search'); + // Per-family set of hidden fam-instance _idx values. Independent from + // hiddenInstancesByClass; persists across navigation. + const hiddenFamInstancesByFamily = new Map(); + function getHiddenFamInsts(familyId) { + let s = hiddenFamInstancesByFamily.get(familyId); + if (!s) { s = new Set(); hiddenFamInstancesByFamily.set(familyId, s); } + return s; + } + function renderInstanceFilter(classId) { const insts = instancesByClass.get(classId) || []; if (insts.length === 0) { @@ -169,7 +182,30 @@ filterListEl.innerHTML = insts.map(inst => { const head = renderInstanceHead(inst); const isHidden = hidden.has(inst._idx); - return `
  • + return `
  • + +
  • `; + }).join(''); + applyFilterSearch(); + } + + function renderFamilyFilter(familyId) { + const fis = famInstsByFamily.get(familyId) || []; + if (fis.length === 0) { + filterEl.hidden = true; + return; + } + filterEl.hidden = false; + const hidden = getHiddenFamInsts(familyId); + const visible = fis.length - hidden.size; + filterSummary.textContent = `Type instances (${visible} / ${fis.length})`; + filterListEl.innerHTML = fis.map(fi => { + const head = renderFamInstHead(fi); + const isHidden = hidden.has(fi._idx); + return `