desy-html 8.6.0 → 8.7.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.
- package/docs/_macro.show-code-from-file.njk +3 -3
- package/docs/_macro.show-html-from-file.njk +3 -2
- package/docs/ds/_ds.example.layout-escritorio.njk +12 -12
- package/docs/ds/_ds.example.layout-movil.njk +4 -4
- package/docs/ds/_ds.example.layout-sidebar.njk +1 -1
- package/docs/ds/_ds.example.typography.njk +1 -1
- package/docs/ds/_ds.macro.code-snippet.njk +1 -1
- package/docs/ds/_ds.macro.section-title.njk +1 -1
- package/docs/ds/_ds.macro.subsection-title.njk +1 -1
- package/docs/ds/_ds.section.espaciado.njk +154 -16
- package/docs/ds/_ds.section.textos.njk +216 -142
- package/docs/index.html +6 -0
- package/package.json +1 -1
- package/src/js/aria/MenuHorizontal.js +58 -0
- package/src/js/aria/MenubarAction.js +210 -164
- package/src/js/aria/tabs.js +4 -4
- package/src/js/desy-html.js +12 -2
- package/src/js/index.js +2 -0
- package/src/templates/components/accordion/_template.accordion.njk +2 -1
- package/src/templates/components/accordion-history/_template.accordion-history.njk +2 -1
- package/src/templates/components/header/_template.header.header__offcanvas.njk +1 -0
- package/src/templates/components/header/_template.header.header__offcanvasButton.njk +1 -0
- package/src/templates/components/menu-horizontal/_examples.menu-horizontal.njk +5 -3
- package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +2 -2
- package/src/templates/components/menubar/_examples.menubar.njk +156 -3
- package/src/templates/components/menubar/_template.menubar.njk +2 -2
- package/src/templates/components/modal/_template.modal.njk +1 -1
- package/src/templates/components/notification/_template.notification.njk +1 -1
- package/src/templates/components/pagination/_template.pagination.njk +12 -6
|
@@ -19,192 +19,238 @@ export function MenubarAction(aria) {
|
|
|
19
19
|
* Each child element of domNode that represents a menubaritem
|
|
20
20
|
* must be an A element.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
(function () {
|
|
23
|
+
aria.MenubarAction = function (domNode) {
|
|
24
|
+
var msgPrefix = 'Menubar constructor argument domNode ';
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Check whether domNode is a DOM element
|
|
27
|
+
if (!domNode instanceof Element) {
|
|
28
|
+
throw new TypeError(msgPrefix + 'is not a DOM Element.');
|
|
29
|
+
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// Check whether domNode has descendant elements
|
|
32
|
+
if (domNode.childElementCount === 0) {
|
|
33
|
+
throw new Error(msgPrefix + 'has no element children.');
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (menubarItem && menubarItem.tagName !== 'A') {
|
|
40
|
-
throw new Error(msgPrefix + 'has child elements that are not A elements.');
|
|
36
|
+
// Check whether domNode's descendant elements contain A elements
|
|
37
|
+
var e = domNode.firstElementChild;
|
|
38
|
+
while (e) {
|
|
39
|
+
e = e.nextElementSibling;
|
|
41
40
|
}
|
|
42
|
-
e = e.nextElementSibling;
|
|
43
|
-
}
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
this.domNode = domNode;
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
this.menubarItems = []; // see Menubar init method
|
|
45
|
+
this.firstChars = []; // see Menubar init method
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
this.firstItem = null; // see Menubar init method
|
|
48
|
+
this.lastItem = null; // see Menubar init method
|
|
49
|
+
};
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
/*
|
|
52
|
+
* @method MenubarAction.prototype.init
|
|
53
|
+
*
|
|
54
|
+
* @desc
|
|
55
|
+
* Adds ARIA role to the menubar node
|
|
56
|
+
* Traverse menubar children for A elements to configure each A element as an ARIA menuitem
|
|
57
|
+
* and populate menuitems array. Initialize firstItem and lastItem properties.
|
|
58
|
+
*/
|
|
59
|
+
aria.MenubarAction.prototype.init = function (actionManager) {
|
|
60
|
+
var menubarItem, menuElement, textContent, numItems;
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
this.actionManager = actionManager;
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
this.domNode.setAttribute('role', 'menubar');
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
this.domNode.addEventListener('focusin', this.handleFocusin.bind(this));
|
|
67
|
+
this.domNode.addEventListener('focusout', this.handleFocusout.bind(this));
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
// Traverse the element children of the menubar domNode: configure each with
|
|
70
|
+
// menuitem role behavior and store reference in menuitems array.
|
|
71
|
+
var e = this.domNode.firstElementChild;
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
while (e) {
|
|
74
|
+
menuElement = e.firstElementChild;
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
if (menuElement && menuElement.tagName === 'A') {
|
|
77
|
+
menubarItem = new aria.MenubarItemAction(menuElement, this);
|
|
78
|
+
menubarItem.init();
|
|
79
|
+
this.menubarItems.push(menubarItem);
|
|
80
|
+
textContent = menuElement.textContent.trim();
|
|
81
|
+
this.firstChars.push(textContent.substring(0, 1).toLowerCase());
|
|
82
|
+
}
|
|
86
83
|
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
e = e.nextElementSibling;
|
|
85
|
+
}
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
// Use populated menuitems array to initialize firstItem and lastItem.
|
|
88
|
+
numItems = this.menubarItems.length;
|
|
89
|
+
if (numItems > 0) {
|
|
90
|
+
this.firstItem = this.menubarItems[0];
|
|
91
|
+
this.lastItem = this.menubarItems[numItems - 1];
|
|
92
|
+
}
|
|
93
|
+
this.firstItem.domNode.tabIndex = 0;
|
|
94
|
+
};
|
|
98
95
|
|
|
99
|
-
|
|
96
|
+
/* FOCUS MANAGEMENT METHODS */
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (var i = 0; i < this.menubarItems.length; i++) {
|
|
105
|
-
var mbi = this.menubarItems[i];
|
|
106
|
-
isOpen = isOpen || (mbi.popupMenu && mbi.popupMenu.isOpen());
|
|
107
|
-
if (!hover || hasFocus) {
|
|
108
|
-
mbi.domNode.tabIndex = -1;
|
|
109
|
-
}
|
|
110
|
-
if (mbi.popupMenu) {
|
|
111
|
-
mbi.popupMenu.close();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (!hover || hasFocus) {
|
|
115
|
-
newItem.domNode.focus();
|
|
116
|
-
newItem.domNode.tabIndex = 0;
|
|
117
|
-
}
|
|
118
|
-
if (isOpen && newItem.popupMenu) {
|
|
119
|
-
newItem.popupMenu.open();
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
aria.MenubarAction.prototype.setFocusToFirstItem = function () {
|
|
124
|
-
this.setFocusToItem(this.firstItem);
|
|
125
|
-
};
|
|
126
|
-
aria.MenubarAction.prototype.setFocusToLastItem = function () {
|
|
127
|
-
this.setFocusToItem(this.lastItem);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
aria.MenubarAction.prototype.setFocusToPreviousItem = function (currentItem) {
|
|
131
|
-
var newItem, index;
|
|
132
|
-
|
|
133
|
-
if (currentItem === this.firstItem) {
|
|
134
|
-
newItem = this.lastItem;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
index = this.menubarItems.indexOf(currentItem);
|
|
138
|
-
newItem = this.menubarItems[ index - 1 ];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.setFocusToItem(newItem);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
aria.MenubarAction.prototype.setFocusToNextItem = function (currentItem) {
|
|
145
|
-
var newItem, index;
|
|
146
|
-
|
|
147
|
-
if (currentItem === this.lastItem) {
|
|
148
|
-
newItem = this.firstItem;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
index = this.menubarItems.indexOf(currentItem);
|
|
152
|
-
newItem = this.menubarItems[ index + 1 ];
|
|
153
|
-
}
|
|
154
|
-
this.setFocusToItem(newItem);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
aria.MenubarAction.prototype.setFocusByFirstCharacter = function (currentItem, char) {
|
|
158
|
-
var start, index, char = char.toLowerCase();
|
|
159
|
-
|
|
160
|
-
// Get start index for search based on position of currentItem
|
|
161
|
-
start = this.menubarItems.indexOf(currentItem) + 1;
|
|
162
|
-
if (start === this.menubarItems.length) {
|
|
163
|
-
start = 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Check remaining slots in the menu
|
|
167
|
-
index = this.getIndexFirstChars(start, char);
|
|
168
|
-
|
|
169
|
-
// If not found in remaining slots, check from beginning
|
|
170
|
-
if (index === -1) {
|
|
171
|
-
index = this.getIndexFirstChars(0, char);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// If match was found...
|
|
175
|
-
if (index > -1) {
|
|
176
|
-
this.menubarItems[index].domNode.focus();
|
|
177
|
-
this.menubarItems[index].domNode.tabIndex = 0;
|
|
178
|
-
currentItem.tabIndex = -1;
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
aria.MenubarAction.prototype.getIndexFirstChars = function (startIndex, char) {
|
|
183
|
-
for (var i = startIndex; i < this.firstChars.length; i++) {
|
|
184
|
-
if (char === this.firstChars[i]) {
|
|
185
|
-
return i;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return -1;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
aria.MenubarAction.prototype.handleFocusin = function (event) {
|
|
192
|
-
// if the menubar or any of its menus has focus, add styling hook for hover
|
|
193
|
-
this.domNode.classList.add('focus');
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
aria.MenubarAction.prototype.handleFocusout = function (event) {
|
|
197
|
-
// if the next element to get focus is not in the menubar or its menus, then close menu
|
|
198
|
-
if (!this.domNode.contains(event.relatedTarget)) {
|
|
98
|
+
aria.MenubarAction.prototype.setFocusToItem = function (newItem, hover) {
|
|
99
|
+
var isOpen = false;
|
|
100
|
+
var hasFocus = this.domNode.contains(document.activeElement);
|
|
199
101
|
for (var i = 0; i < this.menubarItems.length; i++) {
|
|
200
102
|
var mbi = this.menubarItems[i];
|
|
201
|
-
|
|
103
|
+
isOpen = isOpen || (mbi.popupMenu && mbi.popupMenu.isOpen());
|
|
104
|
+
if (!hover || hasFocus) {
|
|
105
|
+
mbi.domNode.tabIndex = -1;
|
|
106
|
+
}
|
|
107
|
+
if (mbi.popupMenu) {
|
|
202
108
|
mbi.popupMenu.close();
|
|
203
109
|
}
|
|
204
110
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
111
|
+
if (!hover || hasFocus) {
|
|
112
|
+
newItem.domNode.focus();
|
|
113
|
+
newItem.domNode.tabIndex = 0;
|
|
114
|
+
}
|
|
115
|
+
if (isOpen && newItem.popupMenu) {
|
|
116
|
+
newItem.popupMenu.open();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
aria.MenubarAction.prototype.setFocusToFirstItem = function () {
|
|
121
|
+
this.setFocusToItem(this.firstItem);
|
|
122
|
+
};
|
|
123
|
+
aria.MenubarAction.prototype.setFocusToLastItem = function () {
|
|
124
|
+
this.setFocusToItem(this.lastItem);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
aria.MenubarAction.prototype.setFocusToPreviousItem = function (currentItem) {
|
|
128
|
+
var newItem, index;
|
|
129
|
+
|
|
130
|
+
if (currentItem === this.firstItem) {
|
|
131
|
+
newItem = this.lastItem;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
index = this.menubarItems.indexOf(currentItem);
|
|
135
|
+
newItem = this.menubarItems[ index - 1 ];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.setFocusToItem(newItem);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
aria.MenubarAction.prototype.setFocusToNextItem = function (currentItem) {
|
|
142
|
+
var newItem, index;
|
|
143
|
+
|
|
144
|
+
if (currentItem === this.lastItem) {
|
|
145
|
+
newItem = this.firstItem;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
index = this.menubarItems.indexOf(currentItem);
|
|
149
|
+
newItem = this.menubarItems[ index + 1 ];
|
|
150
|
+
}
|
|
151
|
+
this.setFocusToItem(newItem);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
aria.MenubarAction.prototype.setFocusByFirstCharacter = function (currentItem, char) {
|
|
155
|
+
var start, index, char = char.toLowerCase();
|
|
156
|
+
|
|
157
|
+
// Get start index for search based on position of currentItem
|
|
158
|
+
start = this.menubarItems.indexOf(currentItem) + 1;
|
|
159
|
+
if (start === this.menubarItems.length) {
|
|
160
|
+
start = 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Check remaining slots in the menu
|
|
164
|
+
index = this.getIndexFirstChars(start, char);
|
|
165
|
+
|
|
166
|
+
// If not found in remaining slots, check from beginning
|
|
167
|
+
if (index === -1) {
|
|
168
|
+
index = this.getIndexFirstChars(0, char);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// If match was found...
|
|
172
|
+
if (index > -1) {
|
|
173
|
+
this.menubarItems[index].domNode.focus();
|
|
174
|
+
this.menubarItems[index].domNode.tabIndex = 0;
|
|
175
|
+
currentItem.tabIndex = -1;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
aria.MenubarAction.prototype.getIndexFirstChars = function (startIndex, char) {
|
|
180
|
+
for (var i = startIndex; i < this.firstChars.length; i++) {
|
|
181
|
+
if (char === this.firstChars[i]) {
|
|
182
|
+
return i;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return -1;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
aria.MenubarAction.prototype.handleFocusin = function (event) {
|
|
189
|
+
// if the menubar or any of its menus has focus, add styling hook for hover
|
|
190
|
+
this.domNode.classList.add('focus');
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
aria.MenubarAction.prototype.handleFocusout = function (event) {
|
|
194
|
+
// if the next element to get focus is not in the menubar or its menus, then close menu
|
|
195
|
+
if (!this.domNode.contains(event.relatedTarget)) {
|
|
196
|
+
for (var i = 0; i < this.menubarItems.length; i++) {
|
|
197
|
+
var mbi = this.menubarItems[i];
|
|
198
|
+
if (mbi.popupMenu && mbi.popupMenu.isOpen()) {
|
|
199
|
+
mbi.popupMenu.close();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// remove styling hook for hover on menubar item
|
|
204
|
+
this.domNode.classList.remove('focus');
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
window.activateItemMenuBarAction = function (menuId, itemsIds) {
|
|
208
|
+
const menu = document.getElementById(menuId);
|
|
209
|
+
if (menu) {
|
|
210
|
+
const menuInstance = new aria.MenubarAction(menu);
|
|
211
|
+
menuInstance.activateElements(menuId, itemsIds);
|
|
212
|
+
return [menu, itemsIds];
|
|
213
|
+
} else {
|
|
214
|
+
console.log('There is no menu with this id in the document.');
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
aria.MenubarAction.prototype.activateElements = function (menuId, activateElements) {
|
|
220
|
+
const getAllElements = this.domNode.querySelectorAll(`#${menuId} ul > li `);
|
|
221
|
+
const filterElements = [...getAllElements].filter((element) => element.id !== '' && element.getAttribute('role') !== 'separator');
|
|
222
|
+
[...filterElements].forEach((element) => {
|
|
223
|
+
if(isActive(element)) {
|
|
224
|
+
element.setAttribute('aria-checked', 'true');
|
|
225
|
+
element.innerHTML = `<strong class="font-bold">${element.textContent}</strong>`;
|
|
226
|
+
} else {
|
|
227
|
+
const getElementParent = element.parentElement.getAttribute('role') === 'group'
|
|
228
|
+
? element.parentElement.parentElement.parentElement.parentElement.querySelector('a')
|
|
229
|
+
: element.parentElement.parentElement.querySelector('a');
|
|
230
|
+
|
|
231
|
+
getElementParent.classList.remove('c-menubar__button--has-selection');
|
|
232
|
+
getElementParent.firstChild.innerHTML = `${getElementParent.textContent}`;
|
|
233
|
+
element.setAttribute('aria-checked', 'false');
|
|
234
|
+
element.innerHTML = `${element.textContent}`;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
[...filterElements].forEach((element) => {
|
|
238
|
+
if(element.getAttribute("aria-checked") === "true"){
|
|
239
|
+
const getElementParent = element.parentElement.getAttribute('role') === 'group'
|
|
240
|
+
? element.parentElement.parentElement.parentElement.parentElement.querySelector('a')
|
|
241
|
+
: element.parentElement.parentElement.querySelector('a');
|
|
242
|
+
getElementParent.classList.add('c-menubar__button--has-selection');
|
|
243
|
+
getElementParent.firstChild.innerHTML = `<strong class="font-bold">${getElementParent.textContent}</strong>`;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
function isActive(element){
|
|
248
|
+
const { id } = element;
|
|
249
|
+
return typeof activateElements === "string"
|
|
250
|
+
? id === activateElements
|
|
251
|
+
: activateElements.includes(id);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}());
|
|
209
255
|
}
|
|
210
256
|
|
package/src/js/aria/tabs.js
CHANGED
|
@@ -281,13 +281,13 @@ export function tabs(aria) {
|
|
|
281
281
|
//Add active class to current tab
|
|
282
282
|
element.classList.add("c-tabs__link--is-active");
|
|
283
283
|
element.setAttribute('role', 'tab');
|
|
284
|
-
element.innerHTML = `<strong class="font-bold">${element.
|
|
284
|
+
element.innerHTML = `<strong class="font-bold">${element.innerHTML}</strong>`;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
function removeActiveClass(element) {
|
|
288
288
|
element.classList.remove("c-tabs__link--is-active");
|
|
289
289
|
element.removeAttribute('role');
|
|
290
|
-
element.innerHTML = element.
|
|
290
|
+
element.innerHTML = element.innerHTML;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
window.activateItemTabs = function (menuId, tabItemId) {
|
|
@@ -298,12 +298,12 @@ export function tabs(aria) {
|
|
|
298
298
|
if (activeItemTab) {
|
|
299
299
|
document.querySelectorAll('.c-tabs__link').forEach((tab) => {
|
|
300
300
|
tab.classList.remove("c-tabs__link--is-active");
|
|
301
|
-
tab.innerHTML = tab.
|
|
301
|
+
tab.innerHTML = tab.innerHTML;
|
|
302
302
|
})
|
|
303
303
|
|
|
304
304
|
activeItemTab.classList.add("c-tabs__link--is-active");
|
|
305
305
|
activeItemTab.setAttribute('role', 'tab');
|
|
306
|
-
activeItemTab.innerHTML = `<strong class="font-bold">${activeItemTab.
|
|
306
|
+
activeItemTab.innerHTML = `<strong class="font-bold">${activeItemTab.innerHTML}</strong>`;
|
|
307
307
|
|
|
308
308
|
document.querySelectorAll('.c-tabs__panel').forEach((panel) => {
|
|
309
309
|
panel.setAttribute('hidden', 'hidden')
|
package/src/js/desy-html.js
CHANGED
|
@@ -18,8 +18,9 @@ import { notification } from './aria/notification.js';
|
|
|
18
18
|
import { RadioButton } from './aria/radioButton.js';
|
|
19
19
|
import { CheckBox } from './aria/checkBoxes.js';
|
|
20
20
|
import { MenuVertical } from './aria/MenuVertical.js';
|
|
21
|
-
import { MenuNavigation } from './aria/MenuNavigation.js';
|
|
22
21
|
import { HeaderNavigation } from './aria/HeaderNavigation.js';
|
|
22
|
+
import { MenuHorizontal } from './aria/MenuHorizontal.js';
|
|
23
|
+
import { MenuNavigation } from './aria/MenuNavigation.js';
|
|
23
24
|
import { Nav } from './aria/Nav.js';
|
|
24
25
|
|
|
25
26
|
|
|
@@ -375,12 +376,21 @@ export function MenuVerticalComponent(aria) {
|
|
|
375
376
|
});
|
|
376
377
|
}
|
|
377
378
|
|
|
379
|
+
export function MenuHorizontalComponent(aria) {
|
|
380
|
+
MenuHorizontal(aria);
|
|
381
|
+
const modules = document.querySelectorAll('[data-module="c-menu-horizontal"]');
|
|
382
|
+
[...modules].forEach((module) => {
|
|
383
|
+
const MenuHorizontal = new aria.MenuHorizontal(module);
|
|
384
|
+
MenuHorizontal.init(null);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
378
388
|
export function MenuNavigationComponent(aria) {
|
|
379
389
|
MenuNavigation(aria);
|
|
380
390
|
const modules = document.querySelectorAll('[data-module="c-menu-navigation"]');
|
|
381
391
|
[...modules].forEach((module) => {
|
|
382
392
|
const menuNavigation = new aria.MenuNavigation(module);
|
|
383
|
-
menuNavigation.init();
|
|
393
|
+
menuNavigation.init(null);
|
|
384
394
|
});
|
|
385
395
|
}
|
|
386
396
|
|
package/src/js/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
radioButtonComponent,
|
|
22
22
|
checkBoxComponent,
|
|
23
23
|
MenuVerticalComponent,
|
|
24
|
+
MenuHorizontalComponent,
|
|
24
25
|
MenuNavigationComponent,
|
|
25
26
|
HeaderNavigationComponent,
|
|
26
27
|
NavComponent
|
|
@@ -45,6 +46,7 @@ notificationComponent(aria);
|
|
|
45
46
|
radioButtonComponent(aria);
|
|
46
47
|
checkBoxComponent(aria);
|
|
47
48
|
MenuVerticalComponent(aria);
|
|
49
|
+
MenuHorizontalComponent(aria);
|
|
48
50
|
MenuNavigationComponent(aria);
|
|
49
51
|
HeaderNavigationComponent(aria);
|
|
50
52
|
NavComponent(aria);
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
{% endif %}
|
|
39
39
|
{% endif %}
|
|
40
40
|
{% if params.showControl %}
|
|
41
|
-
<button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right">
|
|
41
|
+
<button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
|
|
42
42
|
Mostrar todo
|
|
43
43
|
</button>
|
|
44
44
|
{% endif %}
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
<button
|
|
59
59
|
id="{{ id }}-title"
|
|
60
|
+
type="button"
|
|
60
61
|
class="c-accordion__trigger group relative w-full py-sm font-semibold text-left cursor-pointer focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black {%- if item.disabled %} cursor-not-allowed{% endif %}"
|
|
61
62
|
aria-controls="{{ id }}"
|
|
62
63
|
{% if item.open %}
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
{% endif %}
|
|
40
40
|
{% endif %}
|
|
41
41
|
{% if params.showControl %}
|
|
42
|
-
<button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right">
|
|
42
|
+
<button class="c-accordion__toggle-all ml-auto py-base text-sm text-neutral-dark underline focus:text-black focus:bg-warning-base focus:outline-none focus:shadow-outline-focus text-right" type="button">
|
|
43
43
|
Mostrar todo
|
|
44
44
|
</button>
|
|
45
45
|
{% endif %}
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
|
|
59
59
|
<button
|
|
60
60
|
id="{{ id }}-title"
|
|
61
|
+
type="button"
|
|
61
62
|
class="c-accordion__trigger group relative w-full py-sm font-semibold text-left cursor-pointer focus:bg-warning-base focus:outline-none focus:shadow-outline-focus focus:text-black {%- if item.disabled %} cursor-not-allowed{% endif %}"
|
|
62
63
|
aria-controls="{{ id }}"
|
|
63
64
|
{% if item.open %}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
<button
|
|
7
7
|
onclick="closeDialog(this)"
|
|
8
8
|
id="header-offcanvas-button-close"
|
|
9
|
+
type="button"
|
|
9
10
|
class="c-button c-button--sm c-button--transparent m-sm">{{ params.text }} <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="14" height="14" class="self-center ml-2" aria-hidden="true"><path fill="currentColor" d="M8.591 7.177a.25.25 0 010-.354l4.616-4.616A1 1 0 1011.793.793L7.177 5.409a.25.25 0 01-.354 0L2.207.793A1 1 0 00.793 2.207l4.616 4.616a.25.25 0 010 .354L.793 11.793a1 1 0 001.414 1.414l4.616-4.616a.25.25 0 01.354 0l4.616 4.616a1 1 0 001.414-1.414z"/></svg></button>
|
|
10
11
|
</div>
|
|
11
12
|
{% if caller %}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- header__offcanvasButton -->
|
|
2
2
|
<div class="{{ params.classes if params.classes else '-mr-2 flex lg:hidden' }}">
|
|
3
3
|
<button id="header-offcanvas-button"
|
|
4
|
+
type="button"
|
|
4
5
|
onclick="openDialog('header-offcanvas', this)"
|
|
5
6
|
tabindex="0"
|
|
6
7
|
class="inline-flex items-center px-3 py-4 text-sm text-black focus:outline-none focus:shadow-outline-black focus:bg-warning-base" aria-haspopup="true">
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": "con item activo",
|
|
66
|
+
"description": 'Añade active: true a un item para mostrarlo activo inicialmente. También puedes usar con javascript la función global <code>activateItemMenuHorizontal(elementMenu, idItemSeleccionado)</code> para seleccionar un item de un menú, usando sus ids. Ej: Abre la consola del navegador y escribe <code>activateItemMenuHorizontal("mi-menu-horizontal", "menu-item-2")</code> para desactivar el item actual y activar el segundo item de este ejemplo.',
|
|
66
67
|
"data": {
|
|
67
68
|
"items": [
|
|
68
69
|
{
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
},
|
|
80
81
|
{
|
|
81
82
|
"href": "http://www.google.com",
|
|
82
|
-
"text": "Opción 4
|
|
83
|
+
"text": "Opción 4",
|
|
83
84
|
"active": true
|
|
84
85
|
},
|
|
85
86
|
{
|
|
@@ -88,7 +89,8 @@
|
|
|
88
89
|
}
|
|
89
90
|
],
|
|
90
91
|
"attributes": {
|
|
91
|
-
"aria-label": "Menu horizontal"
|
|
92
|
+
"aria-label": "Menu horizontal",
|
|
93
|
+
"id":"mi-menu-horizontal"
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
},
|
|
@@ -311,4 +313,4 @@
|
|
|
311
313
|
]
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
|
-
] %}
|
|
316
|
+
] %}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% set idPrefix = params.idPrefix if params.idPrefix else "menu-item" %}
|
|
4
4
|
|
|
5
5
|
<!-- menu-horizontal -->
|
|
6
|
-
<nav class="c-menu-horizontal {%- if params.classes %} {{ params.classes }}{% endif -%}"
|
|
6
|
+
<nav data-module="c-menu-horizontal" class="c-menu-horizontal {%- if params.classes %} {{ params.classes }}{% endif -%}"
|
|
7
7
|
{%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor -%}>
|
|
8
8
|
<ul class="c-menu-horizontal__list lg:flex lg:flex-wrap">
|
|
9
9
|
{% for item in params.items %}
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
{% endfor %}
|
|
34
34
|
</ul>
|
|
35
35
|
</nav>
|
|
36
|
-
<!-- /menu-horizontal -->
|
|
36
|
+
<!-- /menu-horizontal -->
|