desy-html 8.2.0 → 8.2.2
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.
- package/docs/index.html +9 -0
- package/package.json +1 -1
- package/src/js/aria/MenuVertical.js +34 -22
- package/src/templates/components/accordion/_template.accordion.njk +2 -12
- package/src/templates/components/accordion-history/_template.accordion-history.njk +2 -12
- package/src/templates/components/header/_template.header.header__navigation.njk +7 -12
- package/src/templates/components/links-list/_template.links-list.njk +1 -6
- package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +0 -5
- package/src/templates/components/menu-navigation/_template.menu-navigation.njk +2 -12
- package/src/templates/components/menu-vertical/_examples.menu-vertical.njk +2 -0
- package/src/templates/components/menu-vertical/_template.menu-vertical.njk +2 -12
- package/src/templates/components/menubar/_template.menubar.njk +3 -18
- package/src/templates/components/nav/_template.nav.njk +0 -5
- package/src/templates/components/pagination/_template.pagination.njk +0 -5
package/docs/index.html
CHANGED
|
@@ -37,6 +37,15 @@
|
|
|
37
37
|
|
|
38
38
|
<h2>Changelog (English)</h2>
|
|
39
39
|
<p>What's new in the latest version of desy-html</p>
|
|
40
|
+
<h3>v.8.2.2</h3>
|
|
41
|
+
<ul class="text-sm">
|
|
42
|
+
<li>Fixed duplicate ids in subitems in components with subitems.</li>
|
|
43
|
+
<li>Minor fixes.</li>
|
|
44
|
+
</ul>
|
|
45
|
+
<h3>v.8.2.1</h3>
|
|
46
|
+
<ul class="text-sm">
|
|
47
|
+
<li>Minor fixes.</li>
|
|
48
|
+
</ul>
|
|
40
49
|
<h3>v.8.2.0</h3>
|
|
41
50
|
<ul class="text-sm">
|
|
42
51
|
<li>Added global function to select an item in Menu vertical.</li>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desy-html",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.2",
|
|
4
4
|
"description": "desy-html contains the code you need to start building a user interface for Gobierno de Aragón government webapps.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Desy (SDA Servicios Digitales de Aragón)",
|
|
@@ -34,7 +34,7 @@ export function MenuVertical(aria) {
|
|
|
34
34
|
|
|
35
35
|
aria.MenuVertical.prototype.wrapActiveElement = function (elementActive) {
|
|
36
36
|
const getText = elementActive.textContent;
|
|
37
|
-
const strongElement = `<strong
|
|
37
|
+
const strongElement = `<strong>${getText}</strong>`;
|
|
38
38
|
elementActive.innerHTML = strongElement;
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -44,28 +44,40 @@ export function MenuVertical(aria) {
|
|
|
44
44
|
elementDeactivated.innerHTML = strongElement;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
window.activateItemMenuVertical = function (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
window.activateItemMenuVertical = function (menuId, activeItemId) {
|
|
48
|
+
if (document.getElementById(menuId)) {
|
|
49
|
+
if (document.querySelector('#' + menuId + ' #' + activeItemId)) {
|
|
50
|
+
const menu = document.getElementById(menuId);
|
|
51
|
+
let selectedItem = null;
|
|
52
|
+
menu.querySelectorAll('li').forEach((element, index) => {
|
|
53
|
+
const processElement = function (elem) {
|
|
54
|
+
let getId = elem.id;
|
|
55
|
+
if(getId == activeItemId){
|
|
56
|
+
const getText = elem.textContent;
|
|
57
|
+
const strongElement = `<strong>${getText}</strong>`;
|
|
58
|
+
elem.innerHTML = strongElement;
|
|
59
|
+
selectedItem = elem;
|
|
60
|
+
} else {
|
|
61
|
+
const getText = elem.textContent;
|
|
62
|
+
const strongElement = `${getText}`;
|
|
63
|
+
elem.innerHTML = strongElement;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (element.querySelector('a')) {
|
|
67
|
+
let getLink = element.querySelector('a');
|
|
68
|
+
processElement(getLink);
|
|
69
|
+
} else if (element.querySelector('span')) {
|
|
70
|
+
let getLink = element.querySelector('span');
|
|
71
|
+
processElement(getLink);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return([menu,selectedItem]);
|
|
75
|
+
} else {
|
|
76
|
+
console.log('There is no element with this id in the menu.');
|
|
60
77
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
} else if (element.querySelector('span')) {
|
|
65
|
-
let getLink = element.querySelector('span');
|
|
66
|
-
processElement(getLink);
|
|
67
|
-
}
|
|
68
|
-
})
|
|
78
|
+
} else {
|
|
79
|
+
console.log('There is no menu with this id in the document.');
|
|
80
|
+
}
|
|
69
81
|
};
|
|
70
82
|
}());
|
|
71
83
|
}
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
{%- if item.id -%}
|
|
6
6
|
{%- set id = item.id -%}
|
|
7
7
|
{%- else -%}
|
|
8
|
-
{
|
|
9
|
-
{%- if loop.first -%}
|
|
10
|
-
{%- set id = idPrefix %}
|
|
11
|
-
{%- else -%}
|
|
12
|
-
{%- set id = idPrefix + "-" + loop.index0 -%}
|
|
13
|
-
{%- endif -%}
|
|
8
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
14
9
|
{%- endif -%}
|
|
15
10
|
{%- if item.open -%}
|
|
16
11
|
{%- set conditionalValue = id -%}
|
|
@@ -54,12 +49,7 @@
|
|
|
54
49
|
{%- if item.id -%}
|
|
55
50
|
{%- set id = item.id -%}
|
|
56
51
|
{%- else -%}
|
|
57
|
-
{
|
|
58
|
-
{%- if loop.first -%}
|
|
59
|
-
{%- set id = idPrefix %}
|
|
60
|
-
{%- else -%}
|
|
61
|
-
{%- set id = idPrefix + "-" + loop.index0 -%}
|
|
62
|
-
{%- endif -%}
|
|
52
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
63
53
|
{%- endif %}
|
|
64
54
|
|
|
65
55
|
<div class="-my-px px-xs py-sm border-t border-b border-neutral-base">
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
{%- if item.id -%}
|
|
6
6
|
{%- set id = item.id -%}
|
|
7
7
|
{%- else -%}
|
|
8
|
-
{
|
|
9
|
-
{%- if loop.first -%}
|
|
10
|
-
{%- set id = idPrefix %}
|
|
11
|
-
{%- else -%}
|
|
12
|
-
{%- set id = idPrefix + "-" + loop.index0 -%}
|
|
13
|
-
{%- endif -%}
|
|
8
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
14
9
|
{%- endif -%}
|
|
15
10
|
{%- if item.open -%}
|
|
16
11
|
{%- set conditionalValue = id -%}
|
|
@@ -55,12 +50,7 @@
|
|
|
55
50
|
{%- if item.id -%}
|
|
56
51
|
{%- set id = item.id -%}
|
|
57
52
|
{%- else -%}
|
|
58
|
-
{
|
|
59
|
-
{%- if loop.first -%}
|
|
60
|
-
{%- set id = idPrefix %}
|
|
61
|
-
{%- else -%}
|
|
62
|
-
{%- set id = idPrefix + "-" + loop.index0 -%}
|
|
63
|
-
{%- endif -%}
|
|
53
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
64
54
|
{%- endif %}
|
|
65
55
|
|
|
66
56
|
<div class="relative -my-px px-xs py-sm border-t border-b border-neutral-base">
|
|
@@ -5,19 +5,14 @@
|
|
|
5
5
|
<nav class="{{ params.classes if params.classes else 'hidden lg:block' }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
6
6
|
<ul class="ml-sm flex flex-wrap items-baseline">
|
|
7
7
|
{% for item in params.items %}
|
|
8
|
-
|
|
8
|
+
{% if item %}
|
|
9
9
|
<li>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{% set id = idPrefix %}
|
|
17
|
-
{% else %}
|
|
18
|
-
{% set id = idPrefix + "-" + loop.index %}
|
|
19
|
-
{% endif %}
|
|
20
|
-
{% endif %}
|
|
10
|
+
{#- If the user explicitly sets an id, use this instead of the regular idPrefix -#}
|
|
11
|
+
{% if item.id %}
|
|
12
|
+
{% set id = item.id %}
|
|
13
|
+
{% else %}
|
|
14
|
+
{% set id = idPrefix + "-" + loop.index %}
|
|
15
|
+
{% endif %}
|
|
21
16
|
{% if item.active %}
|
|
22
17
|
|
|
23
18
|
<a {%- if id %} id="{{ id }}"{% endif %} href="{{ item.href }}" class="max-w-40 lg:max-w-xs px-3 py-4 font-bold text-sm text-black hover:underline truncate focus:outline-none focus:ring-4 focus:ring-inset focus:ring-black focus:bg-warning-base" aria-current="page" {%- if item.target %} target="{{ item.target }}"{% endif %}><strong class="font-bold">{{ item.html | safe if item.html else item.text }}</strong></a>
|
|
@@ -15,12 +15,7 @@
|
|
|
15
15
|
{%- if item.id -%}
|
|
16
16
|
{%- set id = item.id -%}
|
|
17
17
|
{%- else -%}
|
|
18
|
-
{
|
|
19
|
-
{%- if loop.first -%}
|
|
20
|
-
{%- set id = idPrefix %}
|
|
21
|
-
{% else %}
|
|
22
|
-
{%- set id = idPrefix + "-" + loop.index -%}
|
|
23
|
-
{%- endif -%}
|
|
18
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
24
19
|
{%- endif -%}
|
|
25
20
|
{% set subId = "sub-" + id %}
|
|
26
21
|
<li class="{% if item.containerClasses %}{{ item.containerClasses }}{% else %}px-base border-y border-neutral-base -my-px{% endif %}">
|
|
@@ -12,13 +12,8 @@
|
|
|
12
12
|
{% if item.id %}
|
|
13
13
|
{% set id = item.id %}
|
|
14
14
|
{% else %}
|
|
15
|
-
{#- The first id should not have a number suffix so it's easy to link to from the error summary component -#}
|
|
16
|
-
{% if loop.first %}
|
|
17
|
-
{% set id = idPrefix %}
|
|
18
|
-
{% else %}
|
|
19
15
|
{% set id = idPrefix + "-" + loop.index %}
|
|
20
16
|
{% endif %}
|
|
21
|
-
{% endif %}
|
|
22
17
|
<li>
|
|
23
18
|
{% if item.active %}
|
|
24
19
|
<span {%- if id %} id="{{ id }}"{% endif %} class="c-menu-horizontal__active flex items-center relative py-sm lg:px-lg lg:py-base border border-transparent truncate font-semibold {%- if item.classes %} {{ item.classes }}{% endif -%}" {%- if item.title %} title="{{ item.title }}"{% endif %} aria-current="page" {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
|
|
@@ -21,12 +21,7 @@
|
|
|
21
21
|
{%- if item.id -%}
|
|
22
22
|
{%- set id = item.id -%}
|
|
23
23
|
{%- else -%}
|
|
24
|
-
{
|
|
25
|
-
{%- if loop.first -%}
|
|
26
|
-
{%- set id = idPrefix %}
|
|
27
|
-
{% else %}
|
|
28
|
-
{%- set id = idPrefix + "-" + loop.index -%}
|
|
29
|
-
{%- endif -%}
|
|
24
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
30
25
|
{%- endif -%}
|
|
31
26
|
{% set subId = "sub-" + id %}
|
|
32
27
|
<li class="relative">
|
|
@@ -50,12 +45,7 @@
|
|
|
50
45
|
{%- if subitem.id -%}
|
|
51
46
|
{%- set subId = subitem.id -%}
|
|
52
47
|
{%- else -%}
|
|
53
|
-
{
|
|
54
|
-
{%- if loop.first -%}
|
|
55
|
-
{%- set subId = "sub-" + id %}
|
|
56
|
-
{% else %}
|
|
57
|
-
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
58
|
-
{%- endif -%}
|
|
48
|
+
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
59
49
|
{%- endif %}
|
|
60
50
|
{% set commonSubItemAttributes %}{% if subId %} id="{{ subId }}"{% endif %} {%- if subitem.title %} title="{{ subitem.title }}"{% endif %} {%- for attribute, value in subitem.attributes %} {{ attribute }}="{{ value }}"{% endfor %}{% endset %}
|
|
61
51
|
<li>
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
"name": "con item activo",
|
|
51
|
+
"description": 'Añade <code>active: true</code> a un item para mostrarlo activo inicialmente. También puedes usar con javascript la función global <code>activateItemMenuVertical(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemMenuVertical("mi-menu", "active-item-3")</code> para desactivar el item actual y activar el tercer item de este ejemplo.',
|
|
51
52
|
"data": {
|
|
52
53
|
"idPrefix": "active-item",
|
|
53
54
|
"items": [
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
}
|
|
67
68
|
],
|
|
68
69
|
"attributes": {
|
|
70
|
+
"id": "mi-menu",
|
|
69
71
|
"aria-label": "Menu vertical"
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -10,12 +10,7 @@
|
|
|
10
10
|
{%- if item.id -%}
|
|
11
11
|
{%- set id = item.id -%}
|
|
12
12
|
{%- else -%}
|
|
13
|
-
{
|
|
14
|
-
{%- if loop.first -%}
|
|
15
|
-
{%- set id = idPrefix %}
|
|
16
|
-
{% else %}
|
|
17
|
-
{%- set id = idPrefix + "-" + loop.index -%}
|
|
18
|
-
{%- endif -%}
|
|
13
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
19
14
|
{%- endif -%}
|
|
20
15
|
{% set subId = "sub-" + id %}
|
|
21
16
|
<li class="m-base">
|
|
@@ -44,12 +39,7 @@
|
|
|
44
39
|
{%- if subitem.id -%}
|
|
45
40
|
{%- set subId = subitem.id -%}
|
|
46
41
|
{%- else -%}
|
|
47
|
-
{
|
|
48
|
-
{%- if loop.first -%}
|
|
49
|
-
{%- set subId = "sub-" + id %}
|
|
50
|
-
{% else %}
|
|
51
|
-
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
52
|
-
{%- endif -%}
|
|
42
|
+
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
53
43
|
{%- endif %}
|
|
54
44
|
<li class="m-base origin-top-left text-sm">
|
|
55
45
|
{% if subitem.href %}
|
|
@@ -18,12 +18,7 @@
|
|
|
18
18
|
{%- if item.id -%}
|
|
19
19
|
{%- set id = item.id -%}
|
|
20
20
|
{%- else -%}
|
|
21
|
-
{
|
|
22
|
-
{%- if loop.first -%}
|
|
23
|
-
{%- set id = idPrefix %}
|
|
24
|
-
{% else %}
|
|
25
|
-
{%- set id = idPrefix + "-" + loop.index -%}
|
|
26
|
-
{%- endif -%}
|
|
21
|
+
{%- set id = idPrefix + "-" + loop.index -%}
|
|
27
22
|
{%- endif -%}
|
|
28
23
|
{% set subId = "sub-" + id %}
|
|
29
24
|
<li class="relative" role="none">
|
|
@@ -49,12 +44,7 @@
|
|
|
49
44
|
{%- if subitem.id -%}
|
|
50
45
|
{%- set subId = subitem.id -%}
|
|
51
46
|
{%- else -%}
|
|
52
|
-
{
|
|
53
|
-
{%- if loop.first -%}
|
|
54
|
-
{%- set subId = "sub-" + id %}
|
|
55
|
-
{% else %}
|
|
56
|
-
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
57
|
-
{%- endif -%}
|
|
47
|
+
{%- set subId = "sub-" + id + "-" + loop.index -%}
|
|
58
48
|
{%- endif %}
|
|
59
49
|
{% if subitem.role == 'none' %}
|
|
60
50
|
<li role="none" id="{{ subId }}" data-option="{{ subId }}">
|
|
@@ -69,12 +59,7 @@
|
|
|
69
59
|
{%- if subsubitem.id -%}
|
|
70
60
|
{%- set subsubId = subsubitem.id -%}
|
|
71
61
|
{%- else -%}
|
|
72
|
-
{
|
|
73
|
-
{%- if loop.first -%}
|
|
74
|
-
{%- set subsubId = "sub-" + subId %}
|
|
75
|
-
{% else %}
|
|
76
|
-
{%- set subsubId = "sub-" + subId + "-" + loop.index -%}
|
|
77
|
-
{%- endif -%}
|
|
62
|
+
{%- set subsubId = "sub-" + subId + "-" + loop.index -%}
|
|
78
63
|
{%- endif %}
|
|
79
64
|
<li {%- if subsubitem.role %} role="{{ subsubitem.role}}"{% endif %}{% if subsubitem.role == 'menuitemcheckbox' or subsubitem.role == 'menuitemradio' %} aria-checked="{% if subsubitem.checked %}{{ subsubitem.checked }}{% else %}false{% endif %}"{% endif %} class="flex items-center pr-base pl-lg py-sm cursor-pointer hover:bg-primary-base hover:text-white" id="{{ subsubId }}" data-option="{{ subsubId }}">
|
|
80
65
|
{{ subsubitem.html | safe if subsubitem.html else subsubitem.text }}
|
|
@@ -15,13 +15,8 @@
|
|
|
15
15
|
{% if item.id %}
|
|
16
16
|
{% set id = item.id %}
|
|
17
17
|
{% else %}
|
|
18
|
-
{#- The first id should not have a number suffix so it's easy to link to from the error summary component -#}
|
|
19
|
-
{% if loop.first %}
|
|
20
|
-
{% set id = idPrefix %}
|
|
21
|
-
{% else %}
|
|
22
18
|
{% set id = idPrefix + "-" + loop.index %}
|
|
23
19
|
{% endif %}
|
|
24
|
-
{% endif %}
|
|
25
20
|
{% set commonItemAttributes %}{% if id %} id="{{ id }}"{% endif %} {%- if item.title %} title="{{ item.title }}"{% endif %} {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}{% endset %}
|
|
26
21
|
<li>
|
|
27
22
|
{% if item.active %}
|
|
@@ -27,12 +27,7 @@
|
|
|
27
27
|
{% set innerHtml %}
|
|
28
28
|
{% for item in params.items %}
|
|
29
29
|
{% if item %}
|
|
30
|
-
{#- The first id should not have a number suffix so it's easy to link to from the error summary component -#}
|
|
31
|
-
{% if loop.first %}
|
|
32
|
-
{% set id = idPrefix %}
|
|
33
|
-
{% else %}
|
|
34
30
|
{% set id = idPrefix + "-" + loop.index %}
|
|
35
|
-
{% endif %}
|
|
36
31
|
<li>
|
|
37
32
|
{% set prefix %}<span class="sr-only">Página </span>{% endset %}
|
|
38
33
|
{% set suffix %}<span class="sr-only"> (resultados del {{ loop.index | int * params.itemsPerPage | int }} al {% if ((loop.index | int + 1) * params.itemsPerPage | int) > ( params.totalItems | int ) %}{{ params.totalItems }}{% else %}{{ (loop.index | int + 1) * params.itemsPerPage | int }}{% endif %})</span>{% endset %}
|