desy-html 5.3.0 → 6.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.
- package/config/tailwind.config.js +10 -10
- package/docs/_include.template-header.njk +8 -0
- package/docs/_macro.example-render.njk +8 -0
- package/docs/componentes.html +6 -0
- package/docs/ds/_ds.example.accordion.njk +61 -0
- package/docs/ds/_ds.example.footer.njk +7 -128
- package/docs/ds/_ds.example.header.njk +118 -0
- package/docs/ds/_ds.example.layout.njk +16 -6
- package/docs/ds/_ds.example.menu-navigation.njk +494 -0
- package/docs/ds/_ds.example.searchbar.njk +39 -0
- package/docs/ds/_ds.example.table.njk +432 -0
- package/docs/ds/_ds.example.toggle.njk +55 -35
- package/docs/ds/_ds.section.layout.njk +12 -12
- package/docs/ds/_ds.section.navigation.njk +5 -0
- package/docs/ds/_ds.section.textos.njk +27 -0
- package/docs/examples-accordion-history.html +5 -0
- package/docs/examples-menu-navigation.html +5 -0
- package/docs/index.html +39 -0
- package/gulpfile.js +7 -6
- package/package.json +6 -7
- package/src/css/base.css +4 -0
- package/src/css/styles.css +1 -0
- package/src/js/aria/accordion.js +16 -5
- package/src/js/aria/disclosureMenu.js +153 -0
- package/src/js/desy-html.js +15 -0
- package/src/js/index.js +2 -0
- package/src/templates/components/accordion/_examples.accordion.njk +70 -2
- package/src/templates/components/accordion/_template.accordion.njk +18 -8
- package/src/templates/components/accordion/params.accordion.yaml +38 -0
- package/src/templates/components/accordion-history/_examples.accordion-history.njk +356 -0
- package/src/templates/components/accordion-history/_macro.accordion-history.njk +3 -0
- package/src/templates/components/accordion-history/_template.accordion-history.njk +209 -0
- package/src/templates/components/accordion-history/params.accordion-history.yaml +125 -0
- package/src/templates/components/button/_examples.button.njk +7 -0
- package/src/templates/components/button/_styles.button.css +27 -0
- package/src/templates/components/button/_template.button.njk +1 -1
- package/src/templates/components/button-loader/_template.button-loader.njk +6 -6
- package/src/templates/components/file-upload/_template.file-upload.njk +1 -1
- package/src/templates/components/footer/_examples.footer.njk +46 -136
- package/src/templates/components/footer/_template.footer.njk +35 -28
- package/src/templates/components/footer/params.footer.yaml +18 -0
- package/src/templates/components/header/_examples.header.njk +166 -0
- package/src/templates/components/header/_template.header.header__navigation.njk +2 -2
- package/src/templates/components/header/_template.header.njk +7 -3
- package/src/templates/components/header/params.header.yaml +24 -0
- package/src/templates/components/item/_examples.item.njk +1 -1
- package/src/templates/components/item/_template.item.njk +3 -3
- package/src/templates/components/listbox/_styles.listbox.css +7 -4
- package/src/templates/components/menu-horizontal/_examples.menu-horizontal.njk +25 -0
- package/src/templates/components/menu-horizontal/_styles.menu-horizontal.css +26 -0
- package/src/templates/components/menu-horizontal/_template.menu-horizontal.njk +1 -1
- package/src/templates/components/menu-navigation/_examples.menu-navigation.njk +1080 -0
- package/src/templates/components/menu-navigation/_macro.menu-navigation.njk +3 -0
- package/src/templates/components/menu-navigation/_styles.menu-navigation.css +216 -0
- package/src/templates/components/menu-navigation/_template.menu-navigation.njk +116 -0
- package/src/templates/components/menu-navigation/params.menu-navigation.yaml +93 -0
- package/src/templates/components/menubar/_examples.menubar.njk +1 -1
- package/src/templates/components/menubar/_styles.menubar.css +26 -5
- package/src/templates/components/modal/_examples.modal.njk +62 -0
- package/src/templates/components/modal/_template.modal.njk +21 -4
- package/src/templates/components/modal/params.modal.yaml +2 -2
- package/src/templates/components/searchbar/_examples.searchbar.njk +12 -1
- package/src/templates/components/searchbar/_template.searchbar.njk +8 -8
- package/src/templates/components/spinner/_styles.spinner.css +1 -0
- package/src/templates/components/spinner/_template.spinner.njk +4 -4
- package/src/templates/components/table-advanced/_examples.table-advanced.njk +182 -5
- package/src/templates/components/table-advanced/_template.table-advanced.njk +26 -2
- package/src/templates/components/table-advanced/params.table-advanced.yaml +5 -0
- package/src/templates/components/toggle/_examples.toggle.njk +33 -11
- package/src/templates/components/toggle/_template.toggle.njk +3 -1
- package/src/templates/components/toggle/params.toggle.yaml +4 -0
- package/src/templates/components/tree/_examples.tree.njk +580 -32
- package/src/templates/components/tree/_template.tree.njk +1 -1
- package/config/clean-css.js +0 -25
package/docs/index.html
CHANGED
|
@@ -38,6 +38,45 @@
|
|
|
38
38
|
|
|
39
39
|
<h2>Changelog (English)</h2>
|
|
40
40
|
<p>What's new in the latest version of desy-html</p>
|
|
41
|
+
<h3>v.6.0.0</h3>
|
|
42
|
+
<ul class="text-sm">
|
|
43
|
+
<li>Compilation
|
|
44
|
+
<ul>
|
|
45
|
+
<li>Updated to TailwindCSS v3.0.24</li>
|
|
46
|
+
<li>Improved file compilation with TailwindCSS v.3 just-in-time mode by default. Now it's simpler and compiles all in any file changes. Removed cleancss. Now compiles css in Nunjucks, html or js changes.</li>
|
|
47
|
+
<li>Improved headings styles in prose with the tailwind typography plugin.</li>
|
|
48
|
+
</ul>
|
|
49
|
+
</li>
|
|
50
|
+
<li>Components
|
|
51
|
+
<ul>
|
|
52
|
+
<li>Added new component Menu navigation</li>
|
|
53
|
+
<li>Table advanced: Added selects in table head for filtering in columns</li>
|
|
54
|
+
<li>Modal: Added button loaders in items if param isButtonLoader is provided</li>
|
|
55
|
+
<li>Header: Added 2 zones to nest HTML content (customLogoHtml, customNavigationHtml). One after the logo and the other after the navigation. Added a param to hide the default GA logo (noLogo). Added target param to navigation items</li>
|
|
56
|
+
<li>Added new component Accordion history.</li>
|
|
57
|
+
<li>Footer: Added custom description, noLogo params. Improvements in logo position and navigation items position in mobile.</li>
|
|
58
|
+
<li>Toggle: now uses aria-expanded instead of aria-pressed by default.</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</li>
|
|
61
|
+
<li>Improvements
|
|
62
|
+
<ul>
|
|
63
|
+
<li>Searchbar: improvements and example for visible label.</li>
|
|
64
|
+
<li>File upload: added button styles.</li>
|
|
65
|
+
<li>Tree: fixed acc. Improved examples.</li>
|
|
66
|
+
<li>Toggle examples: accesibility fixes.</li>
|
|
67
|
+
<li>Button: Added new modifier class for has selection as Dropdown. Improved dropdown has selection class.</li>
|
|
68
|
+
<li>Item: improved icons and text for screenreaders.</li>
|
|
69
|
+
<li>Button loader: fixed a bug that makes an error when no loader.text is provided</li>
|
|
70
|
+
<li>improved the check icon for Button loader, Listbox and Menubar: now it's the same in all browsers.</li>
|
|
71
|
+
<li>Accordion: Added disabled param to items. Now the show/hide info can be customized. Fixed item.classes not applied. Added cursor not allowed in disabled items.</li>
|
|
72
|
+
<li>Menu horizontal: Added new styles for tabs in mobile.</li>
|
|
73
|
+
<li>Header: Improvements in header active items and menu navigation active items.</li>
|
|
74
|
+
<li>Strong tag in base styles is font-semibold instead of font-bold.</li>
|
|
75
|
+
</ul>
|
|
76
|
+
</li>
|
|
77
|
+
<li>Fixed validation errors in Footer examples, Spinner, Button loader and Button.</li>
|
|
78
|
+
<li>Docs: Improved grid example. Added font-bold example for headings style, font-semibold for strong example, and em example.</li>
|
|
79
|
+
</ul>
|
|
41
80
|
<h3>v.5.3.0</h3>
|
|
42
81
|
<ul class="text-sm">
|
|
43
82
|
<li>Added missing params in input-group for inputs.</li>
|
package/gulpfile.js
CHANGED
|
@@ -10,13 +10,11 @@ const postcss = require('gulp-postcss');
|
|
|
10
10
|
const atimport = require('postcss-import');
|
|
11
11
|
const tailwindnesting = require('tailwindcss/nesting');
|
|
12
12
|
const stripCssComments = require('gulp-strip-css-comments');
|
|
13
|
-
const cleanCSS = require('gulp-clean-css');
|
|
14
13
|
const footer = require('gulp-footer');
|
|
15
14
|
const tailwindcss = require('tailwindcss');
|
|
16
15
|
const autoprefixer = require('autoprefixer');
|
|
17
16
|
|
|
18
17
|
const TAILWIND_CONFIG = './config/tailwind.config.js';
|
|
19
|
-
const CLEANCSS_CONFIG = './config/clean-css.js';
|
|
20
18
|
const SOURCE_HTML_DIR = './docs/**.html';
|
|
21
19
|
const SOURCE_NUNJUCKS_PATHS = ['./src/templates/','./docs/'];
|
|
22
20
|
const SOURCE_NUNJUCKS_FILES = ['./src/templates/**/*','./docs/**/*'];
|
|
@@ -36,9 +34,12 @@ function bs(cb) {
|
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
cb();
|
|
38
|
+
}
|
|
39
|
+
|
|
41
40
|
|
|
41
|
+
function watchFiles(cb) {
|
|
42
|
+
gulp.watch([TAILWIND_CONFIG, SOURCE_STYLESHEET_DIR, SOURCE_HTML_DIR, SOURCE_JS_DIR, SOURCE_NUNJUCKS_DIR, ...SOURCE_NUNJUCKS_FILES], gulp.series(html, nunjucks, js, css, reload));
|
|
42
43
|
cb();
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -60,7 +61,6 @@ function css() {
|
|
|
60
61
|
])
|
|
61
62
|
)
|
|
62
63
|
.pipe(stripCssComments({preserve: false}))
|
|
63
|
-
.pipe(cleanCSS(require(CLEANCSS_CONFIG)))
|
|
64
64
|
.pipe(footer('\n'))
|
|
65
65
|
.pipe(gulp.dest(DESTINATION_STYLESHEET));
|
|
66
66
|
}
|
|
@@ -111,4 +111,5 @@ function cleanFolder() {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
exports.default = series(cleanFolder,
|
|
114
|
+
exports.default = series(cleanFolder, html, nunjucks, js, css, license, version, bs, watchFiles);
|
|
115
|
+
exports.prod = series(cleanFolder, html, nunjucks, js, css, license, version, bs);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desy-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
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)",
|
|
@@ -26,20 +26,19 @@
|
|
|
26
26
|
"main": "src/js/index.js",
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev": "gulp",
|
|
29
|
-
"prod": "NODE_ENV=production gulp"
|
|
29
|
+
"prod": "NODE_ENV=production gulp prod"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tailwindcss/aspect-ratio": "^0.
|
|
33
|
-
"@tailwindcss/forms": "^0.
|
|
34
|
-
"@tailwindcss/typography": "^0.
|
|
32
|
+
"@tailwindcss/aspect-ratio": "^0.4.0",
|
|
33
|
+
"@tailwindcss/forms": "^0.5.0",
|
|
34
|
+
"@tailwindcss/typography": "^0.5.2",
|
|
35
35
|
"autoprefixer": "^10.0.2",
|
|
36
|
-
"cssnano": "^4.1.10",
|
|
37
36
|
"hex-rgb": "^4.2.0",
|
|
38
37
|
"npm-run-all": "^4.1.5",
|
|
39
38
|
"postcss": "^8.2.15",
|
|
40
39
|
"postcss-cli": "^8.3.1",
|
|
41
40
|
"postcss-import": "^14.0.2",
|
|
42
|
-
"tailwindcss": "^
|
|
41
|
+
"tailwindcss": "^3.0.24"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"browser-sync": "^2.26.13",
|
package/src/css/base.css
CHANGED
package/src/css/styles.css
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
@import "../templates/components/input/_styles.input.css";
|
|
27
27
|
@import "../templates/components/listbox/_styles.listbox.css";
|
|
28
28
|
@import "../templates/components/menubar/_styles.menubar.css";
|
|
29
|
+
@import "../templates/components/menu-navigation/_styles.menu-navigation.css";
|
|
29
30
|
@import "../templates/components/menu-horizontal/_styles.menu-horizontal.css";
|
|
30
31
|
@import "../templates/components/notification/_styles.notification.css";
|
|
31
32
|
@import "../templates/components/pill/_styles.pill.css";
|
package/src/js/aria/accordion.js
CHANGED
|
@@ -32,7 +32,9 @@ export function accordion(aria) {
|
|
|
32
32
|
if (!allowMultiple && active && active !== target) {
|
|
33
33
|
// Set the expanded state on the triggering element
|
|
34
34
|
active.setAttribute('aria-expanded', 'false');
|
|
35
|
-
active.querySelector('span').innerText = 'Mostrar';
|
|
35
|
+
//active.querySelector('span').innerText = 'Mostrar';
|
|
36
|
+
active.querySelector('.Accordion-show').classList.remove('hidden');
|
|
37
|
+
active.querySelector('.Accordion-hide').classList.add('hidden');
|
|
36
38
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
37
39
|
document.getElementById(active.getAttribute('aria-controls')).setAttribute('hidden', '');
|
|
38
40
|
|
|
@@ -45,20 +47,27 @@ export function accordion(aria) {
|
|
|
45
47
|
if (!isExpanded) {
|
|
46
48
|
// Set the expanded state on the triggering element
|
|
47
49
|
target.setAttribute('aria-expanded', 'true');
|
|
48
|
-
target.querySelector('span').innerText = 'Ocultar';
|
|
50
|
+
//target.querySelector('span').innerText = 'Ocultar';
|
|
51
|
+
target.querySelector('.Accordion-show').classList.add('hidden');
|
|
52
|
+
target.querySelector('.Accordion-hide').classList.remove('hidden');
|
|
49
53
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
50
54
|
document.getElementById(target.getAttribute('aria-controls')).removeAttribute('hidden');
|
|
51
55
|
|
|
52
56
|
// If toggling is not allowed, set disabled state on trigger
|
|
53
57
|
if (!allowToggle) {
|
|
54
58
|
target.setAttribute('aria-disabled', 'true');
|
|
55
|
-
target.querySelector('span').innerText = '';
|
|
59
|
+
//target.querySelector('span').innerText = '';
|
|
60
|
+
target.querySelector('.Accordion-show').classList.add('hidden');
|
|
61
|
+
target.querySelector('.Accordion-hide').classList.add('hidden');
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
else if (allowToggle && isExpanded) {
|
|
59
65
|
// Set the expanded state on the triggering element
|
|
60
66
|
target.setAttribute('aria-expanded', 'false');
|
|
61
|
-
target.querySelector('span').innerText = 'Mostrar';
|
|
67
|
+
// target.querySelector('span').innerText = 'Mostrar';
|
|
68
|
+
active.querySelector('.Accordion-show').classList.remove('hidden');
|
|
69
|
+
active.querySelector('.Accordion-hide').classList.add('hidden');
|
|
70
|
+
|
|
62
71
|
// Hide the accordion sections, using aria-controls to specify the desired section
|
|
63
72
|
document.getElementById(target.getAttribute('aria-controls')).setAttribute('hidden', '');
|
|
64
73
|
}
|
|
@@ -133,7 +142,9 @@ export function accordion(aria) {
|
|
|
133
142
|
// If an expanded/ active accordion is found, disable
|
|
134
143
|
if (expanded) {
|
|
135
144
|
expanded.setAttribute('aria-disabled', 'true');
|
|
136
|
-
expanded.querySelector('span').innerText = '';
|
|
145
|
+
//expanded.querySelector('span').innerText = '';
|
|
146
|
+
expanded.querySelector('.Accordion-show').classList.add('hidden');
|
|
147
|
+
expanded.querySelector('.Accordion-hide').classList.add('hidden');
|
|
137
148
|
}
|
|
138
149
|
}
|
|
139
150
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
export function DisclosureNav(aria) {
|
|
2
|
+
/*
|
|
3
|
+
* This content is licensed according to the W3C Software License at
|
|
4
|
+
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
5
|
+
*
|
|
6
|
+
* Supplemental JS for the disclosure menu keyboard behavior
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
aria.DisclosureNav = function (domNode) {
|
|
11
|
+
this.rootNode = domNode;
|
|
12
|
+
this.triggerNodes = [];
|
|
13
|
+
this.controlledNodes = [];
|
|
14
|
+
this.openIndex = null;
|
|
15
|
+
this.useArrowKeys = true;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
aria.DisclosureNav.prototype.init = function () {
|
|
19
|
+
var buttons = this.rootNode.querySelectorAll('button[aria-expanded][aria-controls]');
|
|
20
|
+
for (var i = 0; i < buttons.length; i++) {
|
|
21
|
+
var button = buttons[i];
|
|
22
|
+
var menu = button.parentNode.querySelector('ul');
|
|
23
|
+
if (menu) {
|
|
24
|
+
// save ref to button and controlled menu
|
|
25
|
+
this.triggerNodes.push(button);
|
|
26
|
+
this.controlledNodes.push(menu);
|
|
27
|
+
|
|
28
|
+
// collapse menus
|
|
29
|
+
button.setAttribute('aria-expanded', 'false');
|
|
30
|
+
this.toggleMenu(menu, false);
|
|
31
|
+
|
|
32
|
+
// attach event listeners
|
|
33
|
+
menu.addEventListener('keydown', this.handleMenuKeyDown.bind(this));
|
|
34
|
+
button.addEventListener('click', this.handleButtonClick.bind(this));
|
|
35
|
+
button.addEventListener('keydown', this.handleButtonKeyDown.bind(this));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.rootNode.addEventListener('focusout', this.handleBlur.bind(this));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
aria.DisclosureNav.prototype.toggleMenu = function (domNode, show) {
|
|
43
|
+
if (domNode) {
|
|
44
|
+
domNode.style.display = show ? 'block' : 'none';
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
aria.DisclosureNav.prototype.toggleExpand = function (index, expanded) {
|
|
49
|
+
// close open menu, if applicable
|
|
50
|
+
if (this.openIndex !== index) {
|
|
51
|
+
this.toggleExpand(this.openIndex, false);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// handle menu at called index
|
|
55
|
+
if (this.triggerNodes[index]) {
|
|
56
|
+
this.openIndex = expanded ? index : null;
|
|
57
|
+
this.triggerNodes[index].setAttribute('aria-expanded', expanded);
|
|
58
|
+
this.toggleMenu(this.controlledNodes[index], expanded);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
aria.DisclosureNav.prototype.controlFocusByKey = function (keyboardEvent, nodeList, currentIndex) {
|
|
63
|
+
switch (keyboardEvent.key) {
|
|
64
|
+
case 'ArrowUp':
|
|
65
|
+
case 'ArrowLeft':
|
|
66
|
+
keyboardEvent.preventDefault();
|
|
67
|
+
if (currentIndex > -1) {
|
|
68
|
+
var prevIndex = Math.max(0, currentIndex - 1);
|
|
69
|
+
nodeList[prevIndex].focus();
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case 'ArrowDown':
|
|
73
|
+
case 'ArrowRight':
|
|
74
|
+
keyboardEvent.preventDefault();
|
|
75
|
+
if (currentIndex > -1) {
|
|
76
|
+
var nextIndex = Math.min(nodeList.length - 1, currentIndex + 1);
|
|
77
|
+
nodeList[nextIndex].focus();
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case 'Home':
|
|
81
|
+
keyboardEvent.preventDefault();
|
|
82
|
+
nodeList[0].focus();
|
|
83
|
+
break;
|
|
84
|
+
case 'End':
|
|
85
|
+
keyboardEvent.preventDefault();
|
|
86
|
+
nodeList[nodeList.length - 1].focus();
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/* Event Handlers */
|
|
92
|
+
aria.DisclosureNav.prototype.handleBlur = function (event) {
|
|
93
|
+
var menuContainsFocus = this.rootNode.contains(event.relatedTarget);
|
|
94
|
+
if (!menuContainsFocus && this.openIndex !== null) {
|
|
95
|
+
this.toggleExpand(this.openIndex, false);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
aria.DisclosureNav.prototype.handleButtonKeyDown = function (event) {
|
|
100
|
+
var targetButtonIndex = this.triggerNodes.indexOf(document.activeElement);
|
|
101
|
+
|
|
102
|
+
// close on escape
|
|
103
|
+
if (event.key === 'Escape') {
|
|
104
|
+
this.toggleExpand(this.openIndex, false);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// move focus into the open menu if the current menu is open
|
|
108
|
+
else if (this.useArrowKeys && this.openIndex === targetButtonIndex && event.key === 'ArrowDown') {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
this.controlledNodes[this.openIndex].querySelector('a').focus();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// handle arrow key navigation between top-level buttons, if set
|
|
114
|
+
else if (this.useArrowKeys) {
|
|
115
|
+
this.controlFocusByKey(event, this.triggerNodes, targetButtonIndex);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
aria.DisclosureNav.prototype.handleButtonClick = function (event) {
|
|
120
|
+
var button = event.target;
|
|
121
|
+
console.log(button);
|
|
122
|
+
var buttonIndex = this.triggerNodes.indexOf(button);
|
|
123
|
+
var buttonExpanded = button.getAttribute('aria-expanded') === 'true';
|
|
124
|
+
this.toggleExpand(buttonIndex, !buttonExpanded);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
aria.DisclosureNav.prototype.handleMenuKeyDown = function (event) {
|
|
128
|
+
if (this.openIndex === null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var menuLinks = Array.prototype.slice.call(this.controlledNodes[this.openIndex].querySelectorAll('a'));
|
|
133
|
+
var currentIndex = menuLinks.indexOf(document.activeElement);
|
|
134
|
+
|
|
135
|
+
// close on escape
|
|
136
|
+
if (event.key === 'Escape') {
|
|
137
|
+
this.triggerNodes[this.openIndex].focus();
|
|
138
|
+
this.toggleExpand(this.openIndex, false);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// handle arrow key navigation within menu links, if set
|
|
142
|
+
else if (this.useArrowKeys) {
|
|
143
|
+
this.controlFocusByKey(event, menuLinks, currentIndex);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// switch on/off arrow key navigation
|
|
148
|
+
aria.DisclosureNav.prototype.updateKeyControls = function (useArrowKeys) {
|
|
149
|
+
this.useArrowKeys = useArrowKeys;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
}
|
package/src/js/desy-html.js
CHANGED
|
@@ -7,6 +7,7 @@ import { PopupMenuItemAction } from './aria/PopupMenuItemAction.js';
|
|
|
7
7
|
import { PopupMenuAction } from './aria/PopupMenuAction.js';
|
|
8
8
|
import { MenubarItemAction } from './aria/MenubarItemAction.js';
|
|
9
9
|
import { MenubarAction } from './aria/MenubarAction.js';
|
|
10
|
+
import { DisclosureNav } from './aria/disclosureMenu.js';
|
|
10
11
|
import { listbox } from './aria/listbox.js';
|
|
11
12
|
import { alert } from './aria/alert.js';
|
|
12
13
|
import { Treeitem } from './aria/treeitem.js';
|
|
@@ -215,6 +216,20 @@ export function menubarComponent(aria) {
|
|
|
215
216
|
}
|
|
216
217
|
}
|
|
217
218
|
|
|
219
|
+
export function menuNavigationComponent(aria) {
|
|
220
|
+
DisclosureNav(aria);
|
|
221
|
+
const modules = document.querySelectorAll('[data-module]');
|
|
222
|
+
for (const item in modules) if (modules.hasOwnProperty(item)) {
|
|
223
|
+
const moduleValue = modules[item].getAttribute('data-module');
|
|
224
|
+
|
|
225
|
+
if (moduleValue == 'c-menu-navigation'){
|
|
226
|
+
console.log(modules[item]);
|
|
227
|
+
const menuNavigation = new aria.DisclosureNav(modules[item]);
|
|
228
|
+
menuNavigation.init();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
218
233
|
export function tableAdvancedComponent(aria) {
|
|
219
234
|
utils(aria);
|
|
220
235
|
dataGrid(aria);
|
package/src/js/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
dropdownComponent,
|
|
11
11
|
listboxComponent,
|
|
12
12
|
menubarComponent,
|
|
13
|
+
menuNavigationComponent,
|
|
13
14
|
tableAdvancedComponent,
|
|
14
15
|
tabsComponent,
|
|
15
16
|
tooltipComponent,
|
|
@@ -24,6 +25,7 @@ dialogComponent(aria);
|
|
|
24
25
|
dropdownComponent(aria);
|
|
25
26
|
listboxComponent(aria);
|
|
26
27
|
menubarComponent(aria);
|
|
28
|
+
menuNavigationComponent(aria);
|
|
27
29
|
tableAdvancedComponent(aria);
|
|
28
30
|
tabsComponent(aria);
|
|
29
31
|
tooltipComponent(aria);
|
|
@@ -115,6 +115,33 @@
|
|
|
115
115
|
]
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
|
+
{
|
|
119
|
+
"name": "disabled and allowToggle and allowMultiple",
|
|
120
|
+
"description": "will hide the show/hide info and disable click in items",
|
|
121
|
+
"data": {
|
|
122
|
+
"idPrefix": "accordion-disabled",
|
|
123
|
+
"headingLevel": 3,
|
|
124
|
+
"allowToggle": true,
|
|
125
|
+
"allowMultiple": true,
|
|
126
|
+
"items": [
|
|
127
|
+
{
|
|
128
|
+
"headerText": "Accordion Item not disabled",
|
|
129
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"headerText": "Accordion Item disabled",
|
|
133
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
134
|
+
"disabled": true
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"headerText": "Accordion Item disabled and open",
|
|
138
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
139
|
+
"disabled": true,
|
|
140
|
+
"open": true
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
118
145
|
{
|
|
119
146
|
"name": "With heading",
|
|
120
147
|
"data": {
|
|
@@ -191,13 +218,54 @@
|
|
|
191
218
|
]
|
|
192
219
|
}
|
|
193
220
|
},
|
|
221
|
+
{
|
|
222
|
+
"name": "with custom show/hide info",
|
|
223
|
+
"description": "The last item has empty strings to don't show any info",
|
|
224
|
+
"data": {
|
|
225
|
+
"idPrefix": "accordion-show-hide",
|
|
226
|
+
"headingLevel": 3,
|
|
227
|
+
"allowMultiple": true,
|
|
228
|
+
"items": [
|
|
229
|
+
{
|
|
230
|
+
"headerText": "Accordion Item 1",
|
|
231
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
232
|
+
"show": {
|
|
233
|
+
"text": "Expandir detalles"
|
|
234
|
+
},
|
|
235
|
+
"hide": {
|
|
236
|
+
"text": "Contraer"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"headerText": "Accordion Item 2",
|
|
241
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
242
|
+
"show": {
|
|
243
|
+
"html": '<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M14 7a1 1 0 0 0-1-1H8.25A.25.25 0 0 1 8 5.75V1a1 1 0 0 0-2 0v4.75a.25.25 0 0 1-.25.25H1a1 1 0 0 0 0 2h4.75a.25.25 0 0 1 .25.25V13a1 1 0 0 0 2 0V8.25A.25.25 0 0 1 8.25 8H13a1 1 0 0 0 1-1Z" fill="currentColor" transform="scale(3.42857)"/></svg>'
|
|
244
|
+
},
|
|
245
|
+
"hide": {
|
|
246
|
+
"html": '<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path d="M13 8H1a1 1 0 0 1 0-2h12a1 1 0 0 1 0 2Z" fill="currentColor" transform="scale(3.42857)"/></svg>'
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"headerText": "Accordion Item 3",
|
|
251
|
+
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
252
|
+
"show": {
|
|
253
|
+
"text": ""
|
|
254
|
+
},
|
|
255
|
+
"hide": {
|
|
256
|
+
"text": ""
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
},
|
|
194
262
|
{
|
|
195
263
|
"name": "With classes applied",
|
|
196
264
|
"description": "Show code to display the classes applied in html",
|
|
197
265
|
"data": {
|
|
198
266
|
"idPrefix": "classes-example",
|
|
199
267
|
"headingLevel": 3,
|
|
200
|
-
"classes": "
|
|
268
|
+
"classes": "px-lg pt-base border-t border-b border-neutral-base",
|
|
201
269
|
"heading": {
|
|
202
270
|
"text": "Accordion example",
|
|
203
271
|
"classes": "c-h2 mb-lg uppercase"
|
|
@@ -210,7 +278,7 @@
|
|
|
210
278
|
{
|
|
211
279
|
"headerText": "Accordion Item 2",
|
|
212
280
|
"html": "<div class=\" w-48 p-2 \"><div class=\" border-4 border-dashed border-gray-200 rounded-lg h-40 \"></div></div>",
|
|
213
|
-
"classes": "py-sm bg-
|
|
281
|
+
"classes": "py-sm bg-neutral-light border border-neutral-base rounded-lg",
|
|
214
282
|
"open": true
|
|
215
283
|
},
|
|
216
284
|
{
|
|
@@ -97,22 +97,32 @@ x-data="{
|
|
|
97
97
|
{% set insideContent %}
|
|
98
98
|
<button
|
|
99
99
|
id="{{ id }}-title"
|
|
100
|
-
class="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"
|
|
100
|
+
class="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 %}"
|
|
101
101
|
aria-controls="{{ id }}"
|
|
102
102
|
{% if item.open %}
|
|
103
103
|
aria-expanded = "true"
|
|
104
104
|
{% else %}
|
|
105
105
|
aria-expanded = "false"
|
|
106
106
|
{% endif %}
|
|
107
|
+
{% if item.disabled %} disabled{% endif %}
|
|
107
108
|
>
|
|
108
109
|
{{ item.headerHtml | safe if item.headerHtml else item.headerText }}
|
|
109
110
|
<span
|
|
110
|
-
class="absolute inset-y-0 right-0 py-sm font-normal text-sm text-neutral-dark underline group-focus:text-black pointer-events-none" aria-hidden="true">
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
class="absolute inset-y-0 right-0 py-sm font-normal text-sm text-neutral-dark underline group-focus:text-black pointer-events-none {%- if item.disabled %} hidden{% endif %}" aria-hidden="true">
|
|
112
|
+
<span class="Accordion-show {%- if item.open %} hidden{%else%}{%endif%} {%- if item.show.classes %} {{ item.show.classes }}{%endif%}">
|
|
113
|
+
{% if item.show %}
|
|
114
|
+
{{ item.show.html | safe if item.show.html else item.show.text }}
|
|
115
|
+
{% else %}
|
|
116
|
+
Mostrar
|
|
117
|
+
{% endif %}
|
|
118
|
+
</span>
|
|
119
|
+
<span class="Accordion-hide {%- if item.open %}{%else%} hidden{%endif%} {%- if item.hide.classes %} {{ item.hide.classes }}{%endif%}">
|
|
120
|
+
{% if item.hide %}
|
|
121
|
+
{{ item.hide.html | safe if item.hide.html else item.hide.text }}
|
|
122
|
+
{% else %}
|
|
123
|
+
Ocultar
|
|
124
|
+
{% endif %}
|
|
125
|
+
</span>
|
|
116
126
|
</span>
|
|
117
127
|
</button>
|
|
118
128
|
{% endset %}
|
|
@@ -137,7 +147,7 @@ x-data="{
|
|
|
137
147
|
{%- if id %}
|
|
138
148
|
id="{{ id }}"
|
|
139
149
|
{% endif %}
|
|
140
|
-
class="Accordion-panel"
|
|
150
|
+
class="Accordion-panel {%- if item.classes %} {{ item.classes }}{% endif %}"
|
|
141
151
|
{%- for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
|
|
142
152
|
{{ item.html | safe if item.html else item.text }}
|
|
143
153
|
</div>
|
|
@@ -65,6 +65,44 @@ params:
|
|
|
65
65
|
type: boolean
|
|
66
66
|
required: false
|
|
67
67
|
description: If true, accordion item will be expanded.
|
|
68
|
+
- name: disabled
|
|
69
|
+
type: boolean
|
|
70
|
+
required: false
|
|
71
|
+
description: If true, accordion item will be disabled and will not show the show/hide control.
|
|
72
|
+
- name: show
|
|
73
|
+
type: object
|
|
74
|
+
required: false
|
|
75
|
+
description: Options to customize the show info
|
|
76
|
+
params:
|
|
77
|
+
- name: text
|
|
78
|
+
type: string
|
|
79
|
+
required: true
|
|
80
|
+
description: If `html` is set, this is not required. Text to use in show info. If `html` is provided, the `text` argument will be ignored.
|
|
81
|
+
- name: html
|
|
82
|
+
type: string
|
|
83
|
+
required: true
|
|
84
|
+
description: If `text` is set, this is not required. HTML to use within the show info. If `html` is provided, the `text` argument will be ignored.
|
|
85
|
+
- name: classes
|
|
86
|
+
type: string
|
|
87
|
+
required: false
|
|
88
|
+
description: Classes to add to the show info.
|
|
89
|
+
- name: hide
|
|
90
|
+
type: object
|
|
91
|
+
required: false
|
|
92
|
+
description: Options to customize the hide info
|
|
93
|
+
params:
|
|
94
|
+
- name: text
|
|
95
|
+
type: string
|
|
96
|
+
required: true
|
|
97
|
+
description: If `html` is set, this is not required. Text to use in hide info. If `html` is provided, the `text` argument will be ignored.
|
|
98
|
+
- name: html
|
|
99
|
+
type: string
|
|
100
|
+
required: true
|
|
101
|
+
description: If `text` is set, this is not required. HTML to use within the hide info. If `html` is provided, the `text` argument will be ignored.
|
|
102
|
+
- name: classes
|
|
103
|
+
type: string
|
|
104
|
+
required: false
|
|
105
|
+
description: Classes to add to the hide info.
|
|
68
106
|
- name: classes
|
|
69
107
|
type: string
|
|
70
108
|
required: false
|