desy-html 13.0.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/docs/_include.template-header.njk +5 -0
  2. package/docs/_macro.example-render.njk +5 -0
  3. package/docs/componentes.html +3 -0
  4. package/docs/ds/_ds.example.checkboxes.njk +1 -1
  5. package/docs/ds/_ds.example.date-input.njk +3 -3
  6. package/docs/ds/_ds.example.file-upload.njk +1 -1
  7. package/docs/ds/_ds.example.input-group.njk +1 -1
  8. package/docs/ds/_ds.example.input.njk +5 -5
  9. package/docs/ds/_ds.example.radios.njk +1 -1
  10. package/docs/ds/_ds.example.searchbar.njk +1 -1
  11. package/docs/ds/_ds.example.select.njk +5 -5
  12. package/docs/ds/_ds.example.textarea.njk +7 -7
  13. package/docs/examples-treegrid.html +8 -0
  14. package/docs/index.html +8 -0
  15. package/gulpfile.js +15 -1
  16. package/package.json +2 -1
  17. package/src/css/styles.css +1 -0
  18. package/src/js/aria/MenuNavigation.js +12 -3
  19. package/src/js/aria/tree.js +320 -31
  20. package/src/js/aria/treegrid.js +508 -0
  21. package/src/js/aria/treeitem.js +25 -19
  22. package/src/js/desy-html.js +37 -31
  23. package/src/js/index.js +12 -10
  24. package/src/templates/components/character-count/_examples.character-count.njk +3 -15
  25. package/src/templates/components/checkboxes/_examples.checkboxes.njk +67 -86
  26. package/src/templates/components/date-input/_examples.date-input.njk +15 -15
  27. package/src/templates/components/datepicker/_examples.datepicker.njk +7 -6
  28. package/src/templates/components/datepicker/_template.datepicker.njk +0 -1
  29. package/src/templates/components/description-list/_examples.description-list.njk +2 -2
  30. package/src/templates/components/dialog/_examples.dialog.njk +2 -2
  31. package/src/templates/components/dropdown/_examples.dropdown.njk +3 -3
  32. package/src/templates/components/error-message/_examples.error-message.njk +4 -2
  33. package/src/templates/components/error-summary/params.error-summary.yaml +0 -3
  34. package/src/templates/components/fieldset/_examples.fieldset.njk +2 -29
  35. package/src/templates/components/file-upload/_examples.file-upload.njk +4 -15
  36. package/src/templates/components/header-advanced/_template.header-advanced.njk +1 -0
  37. package/src/templates/components/hint/params.hint.yaml +0 -14
  38. package/src/templates/components/input/_examples.input.njk +9 -45
  39. package/src/templates/components/input-group/_examples.input-group.njk +19 -18
  40. package/src/templates/components/item/_examples.item.njk +1 -0
  41. package/src/templates/components/media-object/_examples.media-object.njk +6 -5
  42. package/src/templates/components/menubar/_template.menubar.njk +2 -2
  43. package/src/templates/components/menubar/params.menubar.yaml +0 -10
  44. package/src/templates/components/modal/_examples.modal.njk +1 -1
  45. package/src/templates/components/notification/_examples.notification.njk +8 -2
  46. package/src/templates/components/pill/_examples.pill.njk +2 -1
  47. package/src/templates/components/radios/_examples.radios.njk +56 -91
  48. package/src/templates/components/searchbar/_examples.searchbar.njk +2 -1
  49. package/src/templates/components/select/_examples.select.njk +3 -29
  50. package/src/templates/components/status-item/_examples.status-item.njk +1 -0
  51. package/src/templates/components/table-advanced/params.table-advanced.yaml +1 -1
  52. package/src/templates/components/textarea/_examples.textarea.njk +3 -14
  53. package/src/templates/components/tree/_examples.tree.njk +157 -3
  54. package/src/templates/components/tree/_template.tree.njk +112 -101
  55. package/src/templates/components/tree/params.tree.yaml +4 -0
  56. package/src/templates/components/treegrid/_examples.treegrid.njk +1240 -0
  57. package/src/templates/components/treegrid/_macro.treegrid.njk +3 -0
  58. package/src/templates/components/treegrid/_styles.treegrid.css +39 -0
  59. package/src/templates/components/treegrid/_template.treegrid.njk +91 -0
  60. package/src/templates/components/treegrid/params.treegrid.yaml +132 -0
@@ -0,0 +1,3 @@
1
+ {% macro componentTreegrid(params) %}
2
+ {% include "./_template.treegrid.njk" %}
3
+ {% endmacro %}
@@ -0,0 +1,39 @@
1
+ /* ==========================================================================
2
+ _styles.treegrid.css
3
+ ========================================================================== */
4
+
5
+ @layer components {
6
+ .c-treegrid {
7
+ /* Indentation based on level that comes from html style (--level)*/
8
+ tr[aria-level] > :is(td, th):first-child {
9
+ padding-left: calc(var(--level) * 2.5ch);
10
+ @apply relative;
11
+ }
12
+
13
+ .c-treegrid__icon {
14
+ left: calc((var(--level) - 1) * 2.5ch);
15
+ width: 2.5ch;
16
+ height: 2.5ch;
17
+ @apply text-primary-base transition-transform duration-200 ease-out cursor-pointer select-none absolute;
18
+ }
19
+
20
+ :is(tr, th, td):focus .c-treegrid__icon {
21
+ @apply text-black;
22
+ }
23
+
24
+ :is(
25
+ tr[aria-expanded="true"] > td:first-child,
26
+ tr[aria-expanded="true"] > th:first-child,
27
+ td[aria-expanded="true"]:first-child,
28
+ th[aria-expanded="true"]:first-child
29
+ )
30
+ .c-treegrid__icon
31
+ svg {
32
+ @apply rotate-90;
33
+ }
34
+
35
+ :is(tr, th, td):focus {
36
+ @apply bg-warning-base outline-none shadow-outline-focus text-black;
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,91 @@
1
+ {% set headArray = [] %}
2
+
3
+ {#- Capture the HTML so we can optionally nest it in a wrapper -#}
4
+ {% set innerHtml %}
5
+ <table data-module="c-treegrid" class="c-treegrid
6
+ {%- if params.classes %} {{ params.classes }}{% endif %}"{% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %} role="treegrid">
7
+ {% if params.caption %}
8
+ <caption {%- if params.captionClasses %} class="{{ params.captionClasses }}"{% endif %}>{{ params.caption }}</caption>
9
+ {% endif %}
10
+ {% if params.head %}
11
+ <colgroup>
12
+ {% for item in params.head %}
13
+ <col class="treegrid-col-{{ loop.index }}">
14
+ {% endfor %}
15
+ </colgroup>
16
+ <thead>
17
+ <tr class="border-t border-b border-neutral-base">
18
+ {% for item in params.head %}
19
+ {% set headArray = (headArray.push(item.html | safe | striptags if item.html else
20
+ item.text), headArray) %}
21
+ <th scope="col" class="align-top px-base py-sm text-left font-normal text-sm text-neutral-dark {%- if item.classes %} {{ item.classes }}{% endif %}"
22
+ {% for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>{{ item.html |safe if item.html else item.text }}</th>
23
+ {% endfor %}
24
+ </tr>
25
+ </thead>
26
+ {% endif %}
27
+ <tbody>
28
+ {% for row in params.rows %}
29
+ {% if row %}
30
+ <tr role="row" class="mb-0 text-left border-t border-b border-neutral-base" {%- if row.level %} aria-level="{{ row.level }}" style="--level: {{ row.level }}"{% endif %} {%- if row.posinset %} aria-posinset="{{ row.posinset }}"{% endif %} {%- if row.setsize %} aria-setsize="{{ row.setsize }}"{% endif %} {%- if row.expanded != undefined %} aria-expanded="{{ row.expanded }}"{% endif %} {% for attribute, value in row.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
31
+ {% for cell in row.cells %}
32
+ {% set commonAttributes %}
33
+ data-label="{{ headArray[loop.index0] }}"
34
+ {% for attribute, value in cell.attributes %}
35
+ {{ attribute }}="{{ value }}"{% endfor %}
36
+ {% endset %}
37
+
38
+ {% if loop.first and params.firstCellIsHeader %}
39
+ <th scope="row" class="align-top px-base py-sm text-left font-normal text-sm leading-relaxed text-neutral-dark{%- if cell.classes %} {{ cell.classes }}{% endif %}{% if row.expanded is defined and loop.first %} flex items-start{% endif %}"
40
+ {{- commonAttributes | safe -}}
41
+ >
42
+ {% if row.expanded is defined and loop.first %}
43
+ <span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
44
+ <svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
45
+ <rect width="24" height="24" fill="none"/>
46
+ <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"/>
47
+ </svg>
48
+ </span>
49
+ {% endif %}
50
+ {{ cell.html | filterquotes | safe if cell.html else cell.text }}</th>
51
+ {% else %}
52
+ <td role="gridcell" class="text-left px-base py-sm {%- if cell.classes %} {{ cell.classes }}{% endif %}{% if row.expanded is defined and loop.first %} flex items-start{% endif %}"
53
+ {{- commonAttributes | safe -}}
54
+ >
55
+ {% if row.expanded is defined and loop.first %}
56
+ <span class="c-treegrid__icon inline-block relative after:content-[''] after:absolute after:-top-1 after:-left-2 after:p-4" role="presentation">
57
+ <svg width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
58
+ <rect width="24" height="24" fill="none"/>
59
+ <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"/>
60
+ </svg>
61
+ </span>
62
+ {% endif %}
63
+ {{ cell.html | filterquotes | safe if cell.html else cell.text }}</td>
64
+ {% endif %}
65
+ {% endfor %}
66
+ </tr>
67
+ {% endif %}
68
+ {% endfor %}
69
+ </tbody>
70
+ {% if params.foot %}
71
+ <tfoot>
72
+ <tr class="border-t-2 border-b border-neutral-base">
73
+ {% for item in params.foot %}
74
+ <td class="text-left px-base py-sm {%- if item.classes %} {{ item.classes }}{% endif %}"
75
+ {% for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %} data-label="{{ headArray[loop.index0] }}">{{ item.html |safe if item.html else item.text }}</td>
76
+ {% endfor %}
77
+ </tr>
78
+ </tfoot>
79
+ {% endif %}
80
+ </table>
81
+ {% endset %}
82
+
83
+ <!-- treegrid -->
84
+ {% if params.wrapper %}
85
+ <div {%- if params.wrapper.classes %} class="{{ params.wrapper.classes }}"{% endif %} {% for attribute, value in params.wrapper.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
86
+ {{ innerHtml | trim | safe }}
87
+ </div>
88
+ {% else %}
89
+ {{ innerHtml | trim | safe }}
90
+ {% endif %}
91
+ <!-- /treegrid -->
@@ -0,0 +1,132 @@
1
+ params:
2
+ - name: rows
3
+ type: object
4
+ required: true
5
+ description: table rows in treegrid.
6
+ params:
7
+ - name: level
8
+ type: integer
9
+ required: false
10
+ description: Specify the hierarchical level of the row. Level 1 is the top level. This will add the appropriate aria-level attribute to the row.
11
+ - name: posinset
12
+ type: integer
13
+ required: false
14
+ description: Specify the position of the row within its current level, starting at 1. This will add the appropriate aria-posinset attribute to the row.
15
+ - name: setsize
16
+ type: integer
17
+ required: false
18
+ description: Specify the number of rows within the current level. This will add the appropriate aria-setsize attribute to the row.
19
+ - name: expanded
20
+ type: boolean
21
+ required: false
22
+ description: If true, row sub will be expanded.
23
+ - name: cells
24
+ type: array
25
+ required: false
26
+ description: Provide cells for the row.
27
+ params:
28
+ - name: text
29
+ type: string
30
+ required: true
31
+ description: If `html` is set, this is not required. Text for cells in table rows. If `html` is provided, the `text` argument will be ignored.
32
+ - name: html
33
+ type: string
34
+ required: true
35
+ description: If `text` is set, this is not required. HTML for cells in table rows. If `html` is provided, the `text` argument will be ignore
36
+ - name: classes
37
+ type: string
38
+ required: false
39
+ description: Classes to add to the table cell.
40
+ - name: attributes
41
+ type: object
42
+ required: false
43
+ description: HTML attributes (for example data attributes) to add to the table cell.
44
+ - name: attributes
45
+ type: object
46
+ required: false
47
+ description: HTML attributes (for example data attributes) to add to the table row.
48
+ - name: head
49
+ type: array
50
+ required: false
51
+ description: Array of table head cells.
52
+ params:
53
+ - name: text
54
+ type: string
55
+ required: false
56
+ description: If `html` is set, this is not required. Text for table head cells. If `html` is provided, the `text` argument will be ignored.
57
+ - name: html
58
+ type: string
59
+ required: false
60
+ description: If `text` is set, this is not required. HTML for table head cells. If `html` is provided, the `text` argument will be ignore
61
+ - name: classes
62
+ type: string
63
+ required: false
64
+ description: Classes to add to the table head cell.
65
+ - name: attributes
66
+ type: object
67
+ required: false
68
+ description: HTML attributes (for example data attributes) to add to the table cell.
69
+ - name: foot
70
+ type: array
71
+ required: false
72
+ description: Array of table tfoot cells.
73
+ params:
74
+ - name: text
75
+ type: string
76
+ required: false
77
+ description: If `html` is set, this is not required. Text for table tfoot cells. If `html` is provided, the `text` argument will be ignored.
78
+ - name: html
79
+ type: string
80
+ required: false
81
+ description: If `text` is set, this is not required. HTML for table tfoot cells. If `html` is provided, the `text` argument will be ignore
82
+ - name: classes
83
+ type: string
84
+ required: false
85
+ description: Classes to add to the table tfoot cell.
86
+ - name: attributes
87
+ type: object
88
+ required: false
89
+ description: HTML attributes (for example data attributes) to add to the table cell.
90
+ - name: caption
91
+ type: string
92
+ required: false
93
+ description: Caption text
94
+ - name: captionClasses
95
+ type: string
96
+ required: false
97
+ description: Classes for caption text size. Classes should correspond to the available typography heading classes.
98
+ - name: firstCellIsHeader
99
+ type: boolean
100
+ required: false
101
+ description: If set to true, first cell in table row will be a TH instead of a TD.
102
+ - name: wrapper
103
+ type: object
104
+ required: false
105
+ description: Options for a wrapper div outside the table
106
+ params:
107
+ - name: classes
108
+ type: string
109
+ required: false
110
+ description: Classes to add to the wrapper (e.g. to show an horizontal scrollbar it there are many columns or in mobile)
111
+ - name: attributes
112
+ type: object
113
+ required: false
114
+ description: HTML attributes to add to the wrapper div. For accessibility it needs tabindex=0, role=section and aria-label or aria-labelledby.
115
+ - name: classes
116
+ type: string
117
+ required: false
118
+ description: Classes to add to the table container.
119
+ - name: attributes
120
+ type: object
121
+ required: false
122
+ description: HTML attributes (for example data attributes) to add to the table container.
123
+
124
+ accessibilityCriteria: |
125
+ ## Las tablas deben:
126
+ 1. Debe tener al menos una celda de encabezado (TH) en las filas o columnas exteriores.
127
+ 2. Si la tabla tiene más de un nivel de encabezado (si hay elementos th en dos filas o en dos columnas) las celdas de datos y de encabezado deben estar asociadas con los atributos id (en los th) /headers (en los td).
128
+ 3. El título de la tabla debe estar marcado como <caption>
129
+ 4. La primera fila de la tabla no puede tener todas las celdas unidas, o se interpreta que se está simulando un caption.
130
+ 5. Después de un encabezado (h1, h2…) no puede ir directamente una tabla, o se entiende que se está usando el encabezado para lo que debería ser el <caption>
131
+ 6. La tabla debe tener una descripción especialmente si la tabla es grande o compleja, tiene varios niveles de encabezados, tiene totales o enlaces, etc. La descripción intenta suplir la primera impresión que tienen de la tabla las personas que pueden verla, por ejemplo, vemos que en la última columna hay enlaces o en la última fila hay totales. Como en HTML 5 ya no está admitido el atributo summary en las tablas, lo que se hace es poner la descripción en un párrafo antes de la tabla y asociarlo a la tabla con aria-describedby (así se evita también el error 5). El caption y la descripción no deben ser iguales.
132
+ 7. El validador del OAW dará error si hay tablas de una única columna y 3 o más filas con texto menor de 150 caracteres, pues considerará que se está simulando una lista.