.
columns: the column header labels, in order. The FIRST entry labels the
row-header column (the category axis, e.g. "Month"); the rest
label the series columns.
rows: a list of lists. Each row's first cell is that row's header
(| ), the remaining cells are data ( | ).
table_html: the rendered table itself, a SafeString the tag composes by
rendering this file's own ``table`` partial (below) and then
handing the result to the wrapper branch it needs. Markup by
construction, never a consumer value: every caption, header
and cell inside it was escaped exactly once, in text position,
by this template's own auto-escaping during that partial
render. The branches below only ever WRAP it, so nothing here
escapes anything a second time (the double-escape trap,
ADR-084).
toggle_label: the text in "toggle" mode. The tag supplies a
translated default when it is blank, so it is never empty
here, and it lands in text position inside _disclosure.html.
Semver-public partial (BR-BW-TPL-001), reachable cross-file the same way
_data_table.html's own table_rows partial is:
{% include "brickwork/components/_chart_data_table.html#table" %}
table: the markup on its own, with no mode wrapper around it.
The tag renders THIS partial to build table_html, so the disclosure's
pre-rendered `content` requirement is met without a second template
file and without the tag ever assembling markup in Python. A consumer
that wants the table alone, in its own chrome, reaches for it here
rather than re-implementing the caption/scope contract.
States: three, one per data_table_mode. "visible" is the BASE state and
deliberately emits no wrapper and no modifier class at all, matching
_chart_card.html's own legend_position="top" doctrine: a class carrying
no rule is a false affordance, and the package gates against exactly
that (tests/test_option_vocabularies.py). "hidden" wraps the table in
bw-visually-hidden (the clip-path pattern, NEVER display:none, which
would remove the table from the accessibility tree and defeat the entire
contract). "toggle" composes _disclosure.html's native .
Accessibility: this component IS an accessibility contract, not a component
that merely has one. The table carries a real (its accessible
name, announced when a screen reader enters the table), |
column headers and | row headers, so every data cell is
announced with both of its coordinates rather than as a bare number. In
"hidden" mode the table is present in the accessibility tree and absent
from the visual render; in "toggle" mode the no-JS floor holds BY
CONSTRUCTION (BR-BW-HTMX-001), because _disclosure.html ships no
JavaScript at all and the browser owns the open/close entirely. The
table is inert in every mode (no links, no controls, no sort affordance,
nothing focusable), because the chart beside it is the interactive
surface and this is its transcript.
Responsive: no breakpoint switch of its own. The table wrapper scrolls
horizontally rather than reflowing, so a many-series matrix never
overflows its card; in "hidden" mode there is no visual box at all, so
that overflow is inert.
{% endcomment %}
{% partialdef table %}
{{ caption }}
{% for column in columns %}| {{ column }} | {% endfor %}
{% for row in rows %}
{% for cell in row %}{% if forloop.first %}| {{ cell }} | {% else %}{{ cell }} | {% endif %}{% endfor %}
{% endfor %}
{% endpartialdef %}
{% if mode == "toggle" %}{% include "brickwork/components/_disclosure.html" with label=toggle_label content=table_html only %}{% elif mode == "hidden" %}{{ table_html }} {% else %}{{ table_html }}{% endif %}
| |