{#- Shared dashboard components, ported 1:1 from the Dragon shell.dr so dash.js / dg.js work unchanged. Import with: {% import 'ui/kit.html' as kit %} cols are lists of (key, label) pairs. Row templates must emit cells and a leading for bulk select. -#} {% macro search_svg() %}{% endmacro %} {#- search (left) + filters + spacer + selection actions + Columns menu. Pass filters / selactions as already-rendered HTML strings (e.g. from a {% set x %}...{% endset %} block). -#} {% macro toolbar(tkey, placeholder, cols, filters='', selactions='', q='') %}
{{ search_svg() }}
{{ filters|safe }}
{% endmacro %} {#- A {%- for value, label in options %}{% endfor %} {% endmacro %} {% macro pager(tkey, page, per, total) %} {%- if total > 0 %} {%- set pages = (total + per - 1) // per %} {%- set frm = (page - 1) * per + 1 %} {%- set to = [total, page * per]|min %} {%- set lo = [1, page - 2]|max %} {%- set hi = [pages, page + 2]|min %} {%- endif %} {% endmacro %} {#- table-wrap + rows + pager: the swap target #list-. Rows come from caller(). -#} {% macro list(tkey, cols, page, per, total, empty='Nothing here yet.') %}
{%- for key, label in cols %}{% endfor %} {%- if total == 0 %} {%- else %}{{ caller() }}{% endif %}
{{ label }}
{{ empty }}
{{ pager(tkey, page, per, total) }} {% endmacro %} {#- A full list section. `add` is the header's right-side HTML (e.g. a "New" button). -#} {% macro list_page(tkey, title, sub, add='', toolbar_html='', list_html='') %}

{{ title }}

{{ sub }}

{{ add|safe }}
{{ toolbar_html|safe }}
{{ list_html|safe }}
{% endmacro %} {% macro modal(title, eyebrow='') %}
{% endmacro %} {% macro drawer(eyebrow, title) %}
{% endmacro %} {#- Emit after a save/delete so dg.js closes the modal / drawer out of band. -#} {% macro close_modal() %}{% endmacro %} {% macro close_drawer() %}
{% endmacro %} {% macro kv(pairs) %}
{% for k, v in pairs %}
{{ k }}
{{ v }}
{% endfor %}
{% endmacro %} {% macro stat(id, value, label, tone='') %}
{{ value }}
{{ label }}
{% endmacro %} {% macro chart_panel(title, sub, cid) %}

{{ title }} {{ sub }}

{% endmacro %} {#- inline notice; dash.css has no toast, so use the login-err look via a .pill-toned banner -#} {% macro flash(message, tone='ok') %}
{{ tone }} {{ message }}
{% endmacro %} {% macro active_pill(active) %}{% if active %}active{% else %}inactive{% endif %}{% endmacro %}