{#- chirp-ui: Data Table Composition wrapper for filter controls, table records, and pagination. Usage: from "chirpui/data_table.html" import data_table data_table( title="Users", headers=["Name", "Status"], rows=[["Ada", "Active"]], filter_action="/users", current=1, total=4, url_pattern="/users?page={page}", ) -#} {% from "chirpui/filter_bar.html" import filter_row %} {% from "chirpui/pagination.html" import pagination %} {% from "chirpui/table.html" import table, table_empty %} {% def data_table(title=none, description=none, headers=none, rows=none, filter_action=none, filter_method="get", current=1, total=1, url_pattern="", empty_message="No records found", compact=false, striped=false, sticky_header=false, cls="", attrs_map=none) %}
{% if title or description %}
{% if title %}

{{ title }}

{% end %} {% if description %}

{{ description }}

{% end %}
{% end %} {% if filter_action %}
{% call filter_row(action=filter_action, method=filter_method) %}{% slot %}{% end %}{% end %}
{% end %}
{% if rows %} {{ table(headers=headers, rows=rows, compact=compact, striped=striped, sticky_header=sticky_header) }} {% else %} {% call table(headers=headers, compact=compact, striped=striped, sticky_header=sticky_header) %} {{ table_empty(empty_message) }} {% end %} {% end %}
{% if total > 1 and url_pattern %} {% end %}
{% end %}