fix: phones render plain data tables as stacked cards (1.5.8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 20:30:18 -03:00
1 parent 393a31cebe
commit bc3ce09088
8 files changed
+123 -2

No files matched your search

+33
View File
@@ -2011,6 +2011,39 @@
}
if (current) { try { current.page.unmount(); } catch (e) { console.error(e); } }
var view = $('#view');
// Mobile tables: every plain data table of a page gets data-label on its cells (from the header)
// and the class "mc"; style.css turns those rows into stacked cards under 768 px. Tables that
// already handle phones (stack, tbl-cards, eg-table, ipx-tbl, no-mc) and the sr-only chart tables are skipped.
function cardTables() {
var tabs = view.querySelectorAll('table:not(.sr-only):not(.stack):not(.tbl-cards):not(.eg-table):not(.ipx-tbl):not(.no-mc):not(.mc)');
for (var i = 0; i < tabs.length; i++) {
var tb = tabs[i], hr = tb.querySelector('thead tr');
if (!hr) continue;
var labels = [].map.call(hr.children, function (c) { return (c.textContent || '').trim(); });
[].forEach.call(tb.tBodies, function (body) {
[].forEach.call(body.rows, function (r) {
var k = 0;
[].forEach.call(r.cells, function (c) {
if (!c.hasAttribute('data-label')) c.setAttribute('data-label', labels[k] || '');
if (c.childNodes.length > 1) { // one flex item per cell, so mixed content flows as text
var w = document.createElement('span');
w.className = 'mc-v';
while (c.firstChild) w.appendChild(c.firstChild);
c.appendChild(w);
}
k += c.colSpan || 1;
});
});
});
tb.classList.add('mc');
}
}
var cardQueued = false;
new MutationObserver(function () {
if (cardQueued) return;
cardQueued = true;
requestAnimationFrame(function () { cardQueued = false; cardTables(); });
}).observe(view, { childList: true, subtree: true });
clear(view);
state.note = '';
var page = pages[id];