desy-html 8.10.2 → 8.12.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 (35) hide show
  1. package/docs/index.html +15 -0
  2. package/package.json +1 -1
  3. package/src/css/styles.css +2 -0
  4. package/src/js/aria/accordion.js +66 -34
  5. package/src/js/aria/notification.js +47 -23
  6. package/src/js/aria/toggle.js +46 -31
  7. package/src/js/aria/tree.js +2 -3
  8. package/src/js/aria/treeitem.js +54 -0
  9. package/src/js/desy-html.js +6 -3
  10. package/src/templates/components/accordion/_examples.accordion.njk +29 -0
  11. package/src/templates/components/accordion/_template.accordion.njk +1 -1
  12. package/src/templates/components/accordion/params.accordion.yaml +5 -1
  13. package/src/templates/components/accordion-history/_examples.accordion-history.njk +29 -0
  14. package/src/templates/components/accordion-history/_template.accordion-history.njk +1 -1
  15. package/src/templates/components/accordion-history/params.accordion-history.yaml +5 -1
  16. package/src/templates/components/footer/_examples.footer.njk +73 -7
  17. package/src/templates/components/footer/_styles.footer.css +37 -0
  18. package/src/templates/components/footer/_template.footer.njk +25 -5
  19. package/src/templates/components/footer/params.footer.yaml +27 -3
  20. package/src/templates/components/header-advanced/_template.header-advanced.njk +2 -2
  21. package/src/templates/components/header-mini/_template.header-mini.njk +2 -2
  22. package/src/templates/components/menu-navigation/params.menu-navigation.yaml +4 -0
  23. package/src/templates/components/menubar/_template.menubar.njk +2 -2
  24. package/src/templates/components/notification/_examples.notification.njk +11 -0
  25. package/src/templates/components/pagination/_template.pagination.njk +1 -1
  26. package/src/templates/components/pagination/params.pagination.yaml +2 -2
  27. package/src/templates/components/table-advanced/_template.table-advanced.njk +1 -1
  28. package/src/templates/components/table-advanced/params.table-advanced.yaml +0 -4
  29. package/src/templates/components/toggle/_examples.toggle.njk +53 -0
  30. package/src/templates/components/toggle/_styles.toggle.css +31 -0
  31. package/src/templates/components/toggle/_template.toggle.njk +1 -0
  32. package/src/templates/components/toggle/params.toggle.yaml +4 -0
  33. package/src/templates/components/tree/_examples.tree.njk +447 -0
  34. package/src/templates/components/tree/_template.tree.njk +1 -1
  35. package/src/templates/components/tree/params.tree.yaml +5 -1
@@ -5,6 +5,7 @@
5
5
  "data": {
6
6
  "name": "por defecto",
7
7
  "classes": "mt-base",
8
+ "id": "tree-default",
8
9
  "fieldset": {
9
10
  "legend": {
10
11
  "text": "Selecciona organismo"
@@ -990,6 +991,7 @@
990
991
  "data": {
991
992
  "name": "with-many-depth-levels",
992
993
  "classes": "mt-base",
994
+ "id": "tree-item-deep",
993
995
  "fieldset": {
994
996
  "legend": {
995
997
  "text": "Selecciona organismo"
@@ -1810,5 +1812,450 @@
1810
1812
  }
1811
1813
  ]
1812
1814
  }
1815
+ },
1816
+ {
1817
+ "name": "Mostrar u ocultar un item con JavaScript",
1818
+ "description": 'Puedes usar con javascript la función global <code>activateItemsTree(tree, element, show)</code>, para mostrar u ocultar todos los items, usando el id del elemento, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se se mostrará el item expandido, y si le pasamos false se mostrará cerrado. Ej: Abre la consola del navegador y escribe <code>activateItemsTree("tree-item-js", "tree-item-js-example-item-1", true)</code> para mostrar todos los items expandidos.',
1819
+ "data": {
1820
+ "name": "por defecto",
1821
+ "classes": "mt-base",
1822
+ "id": "tree-item-js",
1823
+ "fieldset": {
1824
+ "legend": {
1825
+ "text": "Selecciona organismo"
1826
+ }
1827
+ },
1828
+ "idPrefix": "tree-item-js-example",
1829
+ "items": [
1830
+ {
1831
+ "text": "Item 1",
1832
+ "id": "tree-item-js-example-item-1",
1833
+ "sub": {
1834
+ "items": [
1835
+ {
1836
+ "text": "Subitem 1",
1837
+ "value": "subitem-1"
1838
+ },
1839
+ {
1840
+ "text": "Subitem 2",
1841
+ "value": "subitem-2"
1842
+ },
1843
+ {
1844
+ "text": "Subitem 3",
1845
+ "value": "subitem-3"
1846
+ }
1847
+ ],
1848
+ "attributes": {
1849
+ "aria-labelledby": "tree-item-js-example-item-1"
1850
+ }
1851
+ }
1852
+ },
1853
+ {
1854
+ "text": "Item 2",
1855
+ "id": "tree-item-js-example-item-2",
1856
+ "sub": {
1857
+ "items": [
1858
+ {
1859
+ "text": "Subitem 1",
1860
+ "value": "subitem-1"
1861
+ },
1862
+ {
1863
+ "text": "Subitem 2",
1864
+ "value": "subitem-2"
1865
+ },
1866
+ {
1867
+ "text": "Subitem 3",
1868
+ "value": "subitem-3"
1869
+ }
1870
+ ],
1871
+ "attributes": {
1872
+ "aria-labelledby": "tree-item-js-example-item-2"
1873
+ }
1874
+ }
1875
+ },
1876
+ {
1877
+ "text": "Item 3",
1878
+ "id": "tree-item-js-example-item-3",
1879
+ "sub": {
1880
+ "items": [
1881
+ {
1882
+ "text": "Subitem 1",
1883
+ "value": "subitem-1"
1884
+ },
1885
+ {
1886
+ "text": "Subitem 2",
1887
+ "value": "subitem-2"
1888
+ },
1889
+ {
1890
+ "text": "Subitem 3",
1891
+ "value": "subitem-3"
1892
+ }
1893
+ ],
1894
+ "attributes": {
1895
+ "aria-labelledby": "tree-item-js-example-item-3"
1896
+ }
1897
+ }
1898
+ }
1899
+ ]
1900
+ }
1901
+ },
1902
+ {
1903
+ "name": "Mostrar u ocultar todos los items con JavaScript",
1904
+ "description": 'Puedes usar con javascript la función global <code>activateItemsTree(tree, elements, show)</code>, para mostrar u ocultar todos los items, usando los id de los elementos, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se se mostrarán todos los items expandidos, y si le pasamos false se mostrarán cerrados. Ej: Abre la consola del navegador y escribe <code>activateItemsTree("tree-multiple-items-js", ["tree-multiple-items-js-1", "tree-multiple-items-js-2"], true)</code> para mostrar todos los items expandidos.',
1905
+ "data": {
1906
+ "name": "por defecto",
1907
+ "classes": "mt-base",
1908
+ "id": "tree-multiple-items-js",
1909
+ "fieldset": {
1910
+ "legend": {
1911
+ "text": "Selecciona organismo"
1912
+ }
1913
+ },
1914
+ "idPrefix": "tree-multiple-items-js-example",
1915
+ "items": [
1916
+ {
1917
+ "text": "Item 1",
1918
+ "id": "tree-multiple-items-js-1",
1919
+ "sub": {
1920
+ "items": [
1921
+ {
1922
+ "text": "Subitem 1",
1923
+ "value": "subitem-1"
1924
+ },
1925
+ {
1926
+ "text": "Subitem 2",
1927
+ "value": "subitem-2"
1928
+ },
1929
+ {
1930
+ "text": "Subitem 3",
1931
+ "value": "subitem-3"
1932
+ }
1933
+ ],
1934
+ "attributes": {
1935
+ "aria-labelledby": "tree-multiple-items-js-1"
1936
+ }
1937
+ }
1938
+ },
1939
+ {
1940
+ "text": "Item 2",
1941
+ "id": "tree-multiple-items-js-2",
1942
+ "sub": {
1943
+ "items": [
1944
+ {
1945
+ "text": "Subitem 1",
1946
+ "value": "subitem-1"
1947
+ },
1948
+ {
1949
+ "text": "Subitem 2",
1950
+ "value": "subitem-2"
1951
+ },
1952
+ {
1953
+ "text": "Subitem 3",
1954
+ "value": "subitem-3"
1955
+ }
1956
+ ],
1957
+ "attributes": {
1958
+ "aria-labelledby": "tree-multiple-items-js-2"
1959
+ }
1960
+ }
1961
+ },
1962
+ {
1963
+ "text": "Item 3",
1964
+ "id": "tree-multiple-items-js-3",
1965
+ "sub": {
1966
+ "items": [
1967
+ {
1968
+ "text": "Subitem 1",
1969
+ "value": "subitem-1"
1970
+ },
1971
+ {
1972
+ "text": "Subitem 2",
1973
+ "value": "subitem-2"
1974
+ },
1975
+ {
1976
+ "text": "Subitem 3",
1977
+ "value": "subitem-3"
1978
+ }
1979
+ ],
1980
+ "attributes": {
1981
+ "aria-labelledby": "tree-multiple-items-js-3"
1982
+ }
1983
+ }
1984
+ }
1985
+ ]
1986
+ }
1987
+ },
1988
+ {
1989
+ "name": "Mostrar u ocultar todos los items con JavaScript con diferentes estados",
1990
+ "description": 'Puedes usar con javascript la función global <code>activateItemsTree(tree, elements)</code>, para mostrar u ocultar todos los items, usando los id de los elementos, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se se mostrarán todos los items expandidos, y si le pasamos false se mostrarán cerrados. Ej: Abre la consola del navegador y escribe <code>activateItemsTree("tree-multiple-items-states-js", [["tree-multiple-items-states-item-1", true], ["tree-multiple-items-states-item-3", false]])</code> para mostrar todos los items expandidos.',
1991
+ "data": {
1992
+ "name": "por defecto",
1993
+ "classes": "mt-base",
1994
+ "id": "tree-multiple-items-states-js",
1995
+ "fieldset": {
1996
+ "legend": {
1997
+ "text": "Selecciona organismo"
1998
+ }
1999
+ },
2000
+ "idPrefix": "tree-multiple-items-states-example",
2001
+ "items": [
2002
+ {
2003
+ "text": "Item 1",
2004
+ "id": "tree-multiple-items-states-item-1",
2005
+ "sub": {
2006
+ "items": [
2007
+ {
2008
+ "text": "Subitem 1",
2009
+ "value": "subitem-1"
2010
+ },
2011
+ {
2012
+ "text": "Subitem 2",
2013
+ "value": "subitem-2"
2014
+ },
2015
+ {
2016
+ "text": "Subitem 3",
2017
+ "value": "subitem-3"
2018
+ }
2019
+ ],
2020
+ "attributes": {
2021
+ "aria-labelledby": "tree-multiple-items-states-item-1"
2022
+ }
2023
+ }
2024
+ },
2025
+ {
2026
+ "text": "Item 2",
2027
+ "id": "tree-multiple-items-states-item-2",
2028
+ "sub": {
2029
+ "items": [
2030
+ {
2031
+ "text": "Subitem 1",
2032
+ "value": "subitem-1"
2033
+ },
2034
+ {
2035
+ "text": "Subitem 2",
2036
+ "value": "subitem-2"
2037
+ },
2038
+ {
2039
+ "text": "Subitem 3",
2040
+ "value": "subitem-3"
2041
+ }
2042
+ ],
2043
+ "attributes": {
2044
+ "aria-labelledby": "tree-multiple-items-states-item-2"
2045
+ }
2046
+ }
2047
+ },
2048
+ {
2049
+ "text": "Item 3",
2050
+ "id": "tree-multiple-items-states-item-3",
2051
+ "sub": {
2052
+ "items": [
2053
+ {
2054
+ "text": "Subitem 1",
2055
+ "value": "subitem-1"
2056
+ },
2057
+ {
2058
+ "text": "Subitem 2",
2059
+ "value": "subitem-2"
2060
+ },
2061
+ {
2062
+ "text": "Subitem 3",
2063
+ "value": "subitem-3"
2064
+ }
2065
+ ],
2066
+ "attributes": {
2067
+ "aria-labelledby": "tree-multiple-items-states-item-3"
2068
+ }
2069
+ }
2070
+ }
2071
+ ]
2072
+ }
2073
+ },
2074
+ {
2075
+ "name": "Mostrar u ocultar un item con muchos niveles de profundidad con JavaScript ",
2076
+ "description": 'Puedes usar con javascript la función global <code>activateItemsTree(tree, element, show)</code>, para mostrar u ocultar un item, usando el id del elemento, el parámetro <code>show</code> admite <code>true</code> o <code>false</code>, si le pasamos true se se mostrará el item expandido, y si le pasamos false se mostrará cerrado. Ej: Abre la consola del navegador y escribe <code>activateItemsTree("tree-item-deep-js", "sub-sub-sub-tree-item-nodes-2-2-2-2", true)</code> se abrirá el último elemento del arbol, y el resto de elementos superiores.',
2077
+ "data": {
2078
+ "name": "with-many-depth-levels",
2079
+ "classes": "mt-base",
2080
+ "id": "tree-item-deep-js",
2081
+ "fieldset": {
2082
+ "legend": {
2083
+ "text": "Selecciona organismo"
2084
+ }
2085
+ },
2086
+ "hint": {
2087
+ "text": "Selecciona el organismo al que perteneces."
2088
+ },
2089
+ "idPrefix": "tree-item-nodes",
2090
+ "items": [
2091
+ {
2092
+ "text": "Item 1",
2093
+ "sub": {
2094
+ "items": [
2095
+ {
2096
+ "text": "Subitem 1",
2097
+ "value": "subitem-1"
2098
+ },
2099
+ {
2100
+ "text": "Subitem 2",
2101
+ "value": "subitem-2"
2102
+ },
2103
+ {
2104
+ "text": "Subitem 3",
2105
+ "value": "subitem-3"
2106
+ }
2107
+ ]
2108
+ }
2109
+ },
2110
+ {
2111
+ "text": "Item 2",
2112
+ "sub": {
2113
+ "items": [
2114
+ {
2115
+ "text": "Subitem 1",
2116
+ "value": "subitem-1"
2117
+ },
2118
+ {
2119
+ "text": "Subitem 2",
2120
+ "value": "subitem-2"
2121
+ },
2122
+ {
2123
+ "text": "Subitem 3",
2124
+ "value": "subitem-3"
2125
+ }
2126
+ ]
2127
+ }
2128
+ },
2129
+ {
2130
+ "text": "Item 3",
2131
+ "expanded": false,
2132
+ "sub": {
2133
+ "items": [
2134
+ {
2135
+ "text": "Subitem 1",
2136
+ "sub": {
2137
+ "items": [
2138
+ {
2139
+ "text": "Subitem 1",
2140
+ "value": "subitem-1"
2141
+ },
2142
+ {
2143
+ "text": "Subitem 2",
2144
+ "value": "subitem-2"
2145
+ },
2146
+ {
2147
+ "text": "Subitem 3",
2148
+ "value": "subitem-3"
2149
+ }
2150
+ ]
2151
+ }
2152
+ },
2153
+ {
2154
+ "text": "Subitem 2",
2155
+ "sub": {
2156
+ "items": [
2157
+ {
2158
+ "text": "Subitem 1",
2159
+ "value": "subitem-1"
2160
+ },
2161
+ {
2162
+ "text": "Subitem 2",
2163
+ "value": "subitem-2"
2164
+ },
2165
+ {
2166
+ "text": "Subitem 3",
2167
+ "value": "subitem-3"
2168
+ }
2169
+ ]
2170
+ }
2171
+ },
2172
+ {
2173
+ "text": "Subitem 3",
2174
+ "expanded": true,
2175
+ "sub": {
2176
+ "items": [
2177
+ {
2178
+ "text": "Subitem 1",
2179
+ "value": "subitem-1"
2180
+ },
2181
+ {
2182
+ "text": "Subitem 2",
2183
+ "value": "subitem-2"
2184
+ },
2185
+ {
2186
+ "text": "Subitem 3",
2187
+ "value": "subitem-3",
2188
+ "expanded": true,
2189
+ "sub": {
2190
+ "items": [
2191
+ {
2192
+ "text": "Subitem 1",
2193
+ "sub": {
2194
+ "items": [
2195
+ {
2196
+ "text": "Subitem 1",
2197
+ "value": "subitem-1"
2198
+ },
2199
+ {
2200
+ "text": "Subitem 2",
2201
+ "value": "subitem-2"
2202
+ },
2203
+ {
2204
+ "text": "Subitem 3",
2205
+ "value": "subitem-3"
2206
+ }
2207
+ ]
2208
+ }
2209
+ },
2210
+ {
2211
+ "text": "Subitem 2",
2212
+ "sub": {
2213
+ "items": [
2214
+ {
2215
+ "text": "Subitem 1",
2216
+ "value": "subitem-1"
2217
+ },
2218
+ {
2219
+ "text": "Subitem 2",
2220
+ "value": "subitem-2"
2221
+ },
2222
+ {
2223
+ "text": "Subitem 3",
2224
+ "value": "subitem-3"
2225
+ }
2226
+ ]
2227
+ }
2228
+ },
2229
+ {
2230
+ "text": "Subitem 3",
2231
+ "expanded": true,
2232
+ "sub": {
2233
+ "items": [
2234
+ {
2235
+ "text": "Subitem 1",
2236
+ "value": "subitem-1"
2237
+ },
2238
+ {
2239
+ "text": "Subitem 2",
2240
+ "value": "subitem-2"
2241
+ },
2242
+ {
2243
+ "text": "Subitem 3",
2244
+ "value": "subitem-3"
2245
+ }
2246
+ ]
2247
+ }
2248
+ }
2249
+ ]
2250
+ }
2251
+ }
2252
+ ]
2253
+ }
2254
+ }
2255
+ ]
2256
+ }
2257
+ }
2258
+ ]
2259
+ }
1813
2260
  }
1814
2261
  ] %}
@@ -135,7 +135,7 @@
135
135
  {% if params.searchbar %}
136
136
  {{ componentSearchbar(params.searchbar) }}
137
137
  {% endif %}
138
- <ul class="c-tree {%- if params.classes %} {{ params.classes }}{% endif %}" role="tree" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %} data-module="c-tree">
138
+ <ul class="c-tree {%- if params.classes %} {{ params.classes }}{% endif %}" id="{%- if params.id %}{{ params.id }}{% endif %}" role="tree" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %} data-module="c-tree">
139
139
  {% for item in params.items %}
140
140
  {% if item %}
141
141
  {#- If the user explicitly sets an id, use this instead of the regular idPrefix -#}
@@ -60,6 +60,10 @@ params:
60
60
  type: string
61
61
  required: false
62
62
  description: Classes to add to the heading.
63
+ - name: id
64
+ type: string
65
+ required: false
66
+ description: Specific id attribute for the component. If omitted, then idPrefix option will be applied.
63
67
  - name: headingLevel
64
68
  type: number
65
69
  required: false
@@ -160,4 +164,4 @@ accessibilityCriteria: |
160
164
  - indicate if content is expanded or collapsed
161
165
  - indicate that there is collapsed content to interact with
162
166
 
163
- Note that alphagov have known issues against this criteria: https://github.com/alphagov/govuk_elements/issues/575
167
+ Note that alphagov have known issues against this criteria: https://github.com/alphagov/govuk_elements/issues/575