Treegrid por defecto #
El Treegrid usa una tabla que se considera tabla compleja a nivel de accesibilidad. Así que tendría que tener una descripción con un details asociado a la tabla con el atributo aria-describedby.
Ejemplo: "Treegrid por defecto", de código HTML, para maquetar el componente: "Treegrid", versión: 14.0.0, del sistema de diseño DESY
Para compilar el css del siguiente código deberás instalar Tailwind CSS y usar el archivo tailwind.config.js del proyecto: https://bitbucket.org/sdaragon/desy-html/
Para que funcione el comportamiento del siguiente código deberás importar el archivo index.js y todos los archivos javascript de la carpeta /src/js y /src/js/aria del proyecto: https://bitbucket.org/sdaragon/desy-html/
Usar sólo el código que está dentro de la siguiente etiqueta <code>.
<!-- treegrid -->
<div class="relative overflow-x-auto pb-base focus:outline-none focus:shadow-outline-black" tabindex="0" role="region" aria-label="Treegrid con scroll del ejemplo Treegrid con wrapper">
<table data-module="c-treegrid" class="c-treegrid w-full" id="treegrid" aria-describedby="treegrid-desc" role="treegrid">
<caption class="sr-only mb-base font-bold text-left text-lg">Caption de la treegrid</caption>
<colgroup>
<col class="treegrid-col-1">
<col class="treegrid-col-2">
<col class="treegrid-col-3">
<col class="treegrid-col-4">
</colgroup>
<thead>
<tr class="border-t border-b border-neutral-base">
<th scope="col" class="align-top px-base py-sm text-left font-normal text-sm text-neutral-dark">Documento</th>
<th scope="col" class="align-top px-base py-sm text-left font-normal text-sm text-neutral-dark lg:text-right">Importe</th>
<th scope="col" class="align-top px-base py-sm text-left font-normal text-sm text-neutral-dark">Fecha</th>
<th scope="col" class="align-top px-base py-sm text-left font-normal text-sm text-neutral-dark">Acciones</th>
</tr>
</thead>
<tbody>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="1" style="--level: 1" aria-posinset="1" aria-setsize="1" aria-expanded="false">
<td role="gridcell" class="text-left px-base py-sm flex items-start" data-label="Documento"
id="A0001">
<span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" fill="none" />
<path d="M15.0111 12.387C15.0621 12.3362 15.1025 12.2759 15.13 12.2094C15.1576 12.143 15.1718 12.0718 15.1718 11.9998C15.1718 11.9279 15.1576 11.8567 15.13 11.7903C15.1025 11.7238 15.0621 11.6635 15.0111 11.6127L11.1839 7.78547C11.1074 7.70887 11.0099 7.65669 10.9038 7.63554C10.7976 7.61439 10.6875 7.62522 10.5875 7.66666C10.4875 7.70811 10.4021 7.77829 10.342 7.86834C10.2819 7.95838 10.2499 8.06423 10.25 8.17248L10.25 15.8272C10.2498 15.9355 10.2818 16.0414 10.3419 16.1315C10.4019 16.2216 10.4874 16.2918 10.5874 16.3333C10.6874 16.3748 10.7975 16.3856 10.9037 16.3645C11.0099 16.3433 11.1074 16.2911 11.1839 16.2145L15.0111 12.387Z" fill="currentColor" />
</svg>
</span>
A0001
</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
3.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
05/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-action" class="c-link" aria-labelledby="A0001-action A0001">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="2" style="--level: 2" aria-posinset="1" aria-setsize="3">
<td role="gridcell" class="text-left px-base py-sm" data-label="Documento"
id="A0001-1">
A0001-1</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
1.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
05/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-1-action" class="c-link" aria-labelledby="A0001-1-action A0001-1">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="2" style="--level: 2" aria-posinset="2" aria-setsize="3" aria-expanded="false">
<td role="gridcell" class="text-left px-base py-sm flex items-start" data-label="Documento"
id="A0001-2">
<span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" fill="none" />
<path d="M15.0111 12.387C15.0621 12.3362 15.1025 12.2759 15.13 12.2094C15.1576 12.143 15.1718 12.0718 15.1718 11.9998C15.1718 11.9279 15.1576 11.8567 15.13 11.7903C15.1025 11.7238 15.0621 11.6635 15.0111 11.6127L11.1839 7.78547C11.1074 7.70887 11.0099 7.65669 10.9038 7.63554C10.7976 7.61439 10.6875 7.62522 10.5875 7.66666C10.4875 7.70811 10.4021 7.77829 10.342 7.86834C10.2819 7.95838 10.2499 8.06423 10.25 8.17248L10.25 15.8272C10.2498 15.9355 10.2818 16.0414 10.3419 16.1315C10.4019 16.2216 10.4874 16.2918 10.5874 16.3333C10.6874 16.3748 10.7975 16.3856 10.9037 16.3645C11.0099 16.3433 11.1074 16.2911 11.1839 16.2145L15.0111 12.387Z" fill="currentColor" />
</svg>
</span>
A0001-2
</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
2.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
05/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-2-action" class="c-link" aria-labelledby="A0001-2-action A0001-2">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="3" style="--level: 3" aria-posinset="1" aria-setsize="1">
<td role="gridcell" class="text-left px-base py-sm" data-label="Documento"
id="A0001-2-1">
A0001-2-1</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
1.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
05/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-2-1-action" class="c-link" aria-labelledby="A0001-2-1-action A0001-2-1">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="2" style="--level: 2" aria-posinset="3" aria-setsize="3" aria-expanded="false">
<td role="gridcell" class="text-left px-base py-sm flex items-start" data-label="Documento"
id="A0001-3">
<span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" fill="none" />
<path d="M15.0111 12.387C15.0621 12.3362 15.1025 12.2759 15.13 12.2094C15.1576 12.143 15.1718 12.0718 15.1718 11.9998C15.1718 11.9279 15.1576 11.8567 15.13 11.7903C15.1025 11.7238 15.0621 11.6635 15.0111 11.6127L11.1839 7.78547C11.1074 7.70887 11.0099 7.65669 10.9038 7.63554C10.7976 7.61439 10.6875 7.62522 10.5875 7.66666C10.4875 7.70811 10.4021 7.77829 10.342 7.86834C10.2819 7.95838 10.2499 8.06423 10.25 8.17248L10.25 15.8272C10.2498 15.9355 10.2818 16.0414 10.3419 16.1315C10.4019 16.2216 10.4874 16.2918 10.5874 16.3333C10.6874 16.3748 10.7975 16.3856 10.9037 16.3645C11.0099 16.3433 11.1074 16.2911 11.1839 16.2145L15.0111 12.387Z" fill="currentColor" />
</svg>
</span>
A0001-3
</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
2.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
05/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-3-action" class="c-link" aria-labelledby="A0001-3-action A0001-3">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="3" style="--level: 3" aria-posinset="1" aria-setsize="1" aria-expanded="false">
<td role="gridcell" class="text-left px-base py-sm flex items-start" data-label="Documento"
id="A0001-3-1">
<span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
<svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" fill="none" />
<path d="M15.0111 12.387C15.0621 12.3362 15.1025 12.2759 15.13 12.2094C15.1576 12.143 15.1718 12.0718 15.1718 11.9998C15.1718 11.9279 15.1576 11.8567 15.13 11.7903C15.1025 11.7238 15.0621 11.6635 15.0111 11.6127L11.1839 7.78547C11.1074 7.70887 11.0099 7.65669 10.9038 7.63554C10.7976 7.61439 10.6875 7.62522 10.5875 7.66666C10.4875 7.70811 10.4021 7.77829 10.342 7.86834C10.2819 7.95838 10.2499 8.06423 10.25 8.17248L10.25 15.8272C10.2498 15.9355 10.2818 16.0414 10.3419 16.1315C10.4019 16.2216 10.4874 16.2918 10.5874 16.3333C10.6874 16.3748 10.7975 16.3856 10.9037 16.3645C11.0099 16.3433 11.1074 16.2911 11.1839 16.2145L15.0111 12.387Z" fill="currentColor" />
</svg>
</span>
A0001-3-1
</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
5.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
15/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-3-1-action" class="c-link" aria-labelledby="A0001-3-1-action A0001-3-1">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="4" style="--level: 4" aria-posinset="1" aria-setsize="2">
<td role="gridcell" class="text-left px-base py-sm" data-label="Documento"
id="A0001-3-1-1">
A0001-3-1-1</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
95€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
15/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-3-1-1-action" class="c-link" aria-labelledby="A0001-3-1-1-action A0001-3-1-1">Ver</a>
</td>
</tr>
<tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" aria-level="4" style="--level: 4" aria-posinset="2" aria-setsize="2">
<td role="gridcell" class="text-left px-base py-sm" data-label="Documento"
id="A0001-3-1-2">
A0001-3-1-2</td>
<td role="gridcell" class="text-left px-base py-sm lg:text-right" data-label="Importe">
5.000,00€</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Fecha">
15/01/2024</td>
<td role="gridcell" class="text-left px-base py-sm" data-label="Acciones">
<a href="#" id="A0001-3-1-2-action" class="c-link" aria-labelledby="A0001-3-1-2-action A0001-3-1-2">Ver</a>
</td>
</tr>
</tbody>
</table>
</div>
<!-- /treegrid -->
Ejemplo: "Treegrid por defecto", de código Nunjucks, para maquetar el componente: "Treegrid", versión: 14.0.0, del sistema de diseño DESY
Pegar en la página: pagina-prueba-EDITA-PARA-EMPEZAR.html del proyecto: https://bitbucket.org/sdaragon/desy-html-starter/
Usar sólo el código que está dentro de la siguiente etiqueta <code>.
{% from "components/treegrid/_macro.treegrid.njk" import componentTreegrid %}
{{ componentTreegrid({
"caption": "Caption de la treegrid",
"captionClasses": "sr-only mb-base font-bold text-left text-lg",
"head": [
{
"text": "Documento"
},
{
"text": "Importe",
"classes": "lg:text-right"
},
{
"text": "Fecha"
},
{
"text": "Acciones"
}
],
"rows": [
{
"level": 1,
"posinset": 1,
"setsize": 1,
"expanded": false,
"cells": [
{
"text": "A0001",
"attributes": {
"id": "A0001"
}
},
{
"text": "3.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-action' class='c-link' aria-labelledby='A0001-action A0001'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 1,
"setsize": 3,
"cells": [
{
"text": "A0001-1",
"attributes": {
"id": "A0001-1"
}
},
{
"text": "1.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-1-action' class='c-link' aria-labelledby='A0001-1-action A0001-1'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 2,
"setsize": 3,
"expanded": false,
"cells": [
{
"text": "A0001-2",
"attributes": {
"id": "A0001-2"
}
},
{
"text": "2.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-2-action' class='c-link' aria-labelledby='A0001-2-action A0001-2'>Ver</a>"
}
]
},
{
"level": 3,
"posinset": 1,
"setsize": 1,
"cells": [
{
"text": "A0001-2-1",
"attributes": {
"id": "A0001-2-1"
}
},
{
"text": "1.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-2-1-action' class='c-link' aria-labelledby='A0001-2-1-action A0001-2-1'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 3,
"setsize": 3,
"expanded": false,
"cells": [
{
"text": "A0001-3",
"attributes": {
"id": "A0001-3"
}
},
{
"text": "2.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-3-action' class='c-link' aria-labelledby='A0001-3-action A0001-3'>Ver</a>"
}
]
},
{
"level": 3,
"posinset": 1,
"setsize": 1,
"expanded": false,
"cells": [
{
"text": "A0001-3-1",
"attributes": {
"id": "A0001-3-1"
}
},
{
"text": "5.000,00€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-action' class='c-link' aria-labelledby='A0001-3-1-action A0001-3-1'>Ver</a>"
}
]
},
{
"level": 4,
"posinset": 1,
"setsize": 2,
"cells": [
{
"text": "A0001-3-1-1",
"attributes": {
"id": "A0001-3-1-1"
}
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-1-action' class='c-link' aria-labelledby='A0001-3-1-1-action A0001-3-1-1'>Ver</a>"
}
]
},
{
"level": 4,
"posinset": 2,
"setsize": 2,
"cells": [
{
"text": "A0001-3-1-2",
"attributes": {
"id": "A0001-3-1-2"
}
},
{
"text": "5.000,00€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-2-action' class='c-link' aria-labelledby='A0001-3-1-2-action A0001-3-1-2'>Ver</a>"
}
]
}
],
"wrapper": {
"classes": "relative overflow-x-auto pb-base focus:outline-none focus:shadow-outline-black",
"attributes": {
"tabindex": "0",
"role": "region",
"aria-label": "Treegrid con scroll del ejemplo Treegrid con wrapper"
}
},
"classes": "w-full",
"attributes": {
"id": "treegrid",
"aria-describedby": "treegrid-desc"
}
}) }}
Documento | Importe | Fecha | Acciones |
---|---|---|---|
A0001 | 3.000,00€ | 05/01/2024 | Ver |
A0001-1 | 1.000,00€ | 05/01/2024 | Ver |
A0001-2 | 2.000,00€ | 05/01/2024 | Ver |
A0001-2-1 | 1.000,00€ | 05/01/2024 | Ver |
A0001-3 | 2.000,00€ | 05/01/2024 | Ver |
A0001-3-1 | 5.000,00€ | 15/01/2024 | Ver |
A0001-3-1-1 | 95€ | 15/01/2024 | Ver |
A0001-3-1-2 | 5.000,00€ | 15/01/2024 | Ver |
Mostrar códigodel ejemplo: Treegrid por defecto
Contenido
Nunjucks macro
{% from "components/treegrid/_macro.treegrid.njk" import componentTreegrid %}
{{ componentTreegrid({
"caption": "Caption de la treegrid",
"captionClasses": "sr-only mb-base font-bold text-left text-lg",
"head": [
{
"text": "Documento"
},
{
"text": "Importe",
"classes": "lg:text-right"
},
{
"text": "Fecha"
},
{
"text": "Acciones"
}
],
"rows": [
{
"level": 1,
"posinset": 1,
"setsize": 1,
"expanded": false,
"cells": [
{
"text": "A0001",
"attributes": {
"id": "A0001"
}
},
{
"text": "3.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-action' class='c-link' aria-labelledby='A0001-action A0001'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 1,
"setsize": 3,
"cells": [
{
"text": "A0001-1",
"attributes": {
"id": "A0001-1"
}
},
{
"text": "1.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-1-action' class='c-link' aria-labelledby='A0001-1-action A0001-1'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 2,
"setsize": 3,
"expanded": false,
"cells": [
{
"text": "A0001-2",
"attributes": {
"id": "A0001-2"
}
},
{
"text": "2.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-2-action' class='c-link' aria-labelledby='A0001-2-action A0001-2'>Ver</a>"
}
]
},
{
"level": 3,
"posinset": 1,
"setsize": 1,
"cells": [
{
"text": "A0001-2-1",
"attributes": {
"id": "A0001-2-1"
}
},
{
"text": "1.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-2-1-action' class='c-link' aria-labelledby='A0001-2-1-action A0001-2-1'>Ver</a>"
}
]
},
{
"level": 2,
"posinset": 3,
"setsize": 3,
"expanded": false,
"cells": [
{
"text": "A0001-3",
"attributes": {
"id": "A0001-3"
}
},
{
"text": "2.000,00€",
"classes": "lg:text-right"
},
{
"text": "05/01/2024"
},
{
"html": "<a href='#' id='A0001-3-action' class='c-link' aria-labelledby='A0001-3-action A0001-3'>Ver</a>"
}
]
},
{
"level": 3,
"posinset": 1,
"setsize": 1,
"expanded": false,
"cells": [
{
"text": "A0001-3-1",
"attributes": {
"id": "A0001-3-1"
}
},
{
"text": "5.000,00€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-action' class='c-link' aria-labelledby='A0001-3-1-action A0001-3-1'>Ver</a>"
}
]
},
{
"level": 4,
"posinset": 1,
"setsize": 2,
"cells": [
{
"text": "A0001-3-1-1",
"attributes": {
"id": "A0001-3-1-1"
}
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-1-action' class='c-link' aria-labelledby='A0001-3-1-1-action A0001-3-1-1'>Ver</a>"
}
]
},
{
"level": 4,
"posinset": 2,
"setsize": 2,
"cells": [
{
"text": "A0001-3-1-2",
"attributes": {
"id": "A0001-3-1-2"
}
},
{
"text": "5.000,00€",
"classes": "lg:text-right"
},
{
"text": "15/01/2024"
},
{
"html": "<a href='#' id='A0001-3-1-2-action' class='c-link' aria-labelledby='A0001-3-1-2-action A0001-3-1-2'>Ver</a>"
}
]
}
],
"wrapper": {
"classes": "relative overflow-x-auto pb-base focus:outline-none focus:shadow-outline-black",
"attributes": {
"tabindex": "0",
"role": "region",
"aria-label": "Treegrid con scroll del ejemplo Treegrid con wrapper"
}
},
"classes": "w-full",
"attributes": {
"id": "treegrid",
"aria-describedby": "treegrid-desc"
}
}) }}