desy-html 13.0.2 → 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.
- package/docs/_include.template-header.njk +5 -0
- package/docs/_macro.example-render.njk +5 -0
- package/docs/componentes.html +3 -0
- package/docs/examples-treegrid.html +8 -0
- package/docs/index.html +4 -0
- package/gulpfile.js +15 -1
- package/package.json +2 -1
- package/src/css/styles.css +1 -0
- package/src/js/aria/tree.js +320 -31
- package/src/js/aria/treegrid.js +508 -0
- package/src/js/aria/treeitem.js +25 -19
- package/src/js/desy-html.js +37 -31
- package/src/js/index.js +12 -10
- package/src/templates/components/error-summary/params.error-summary.yaml +0 -3
- package/src/templates/components/hint/params.hint.yaml +0 -14
- package/src/templates/components/menubar/params.menubar.yaml +0 -10
- package/src/templates/components/table-advanced/params.table-advanced.yaml +1 -1
- package/src/templates/components/tree/_examples.tree.njk +155 -1
- package/src/templates/components/tree/_template.tree.njk +112 -101
- package/src/templates/components/tree/params.tree.yaml +4 -0
- package/src/templates/components/treegrid/_examples.treegrid.njk +1240 -0
- package/src/templates/components/treegrid/_macro.treegrid.njk +3 -0
- package/src/templates/components/treegrid/_styles.treegrid.css +39 -0
- package/src/templates/components/treegrid/_template.treegrid.njk +91 -0
- package/src/templates/components/treegrid/params.treegrid.yaml +132 -0
package/src/js/desy-html.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { utils, formatDateToDDMMYYYY, convertToISOFormat } from './aria/utils.js';
|
|
2
1
|
import { accordion } from './aria/accordion.js';
|
|
2
|
+
import { alert } from './aria/alert.js';
|
|
3
|
+
import { CheckBox } from './aria/checkBoxes.js';
|
|
4
|
+
import { Collapsible } from './aria/collapsible.js';
|
|
3
5
|
import { dataGrid } from './aria/dataGrid.js';
|
|
4
6
|
import { dialog } from './aria/dialog.js';
|
|
5
|
-
import { tabs } from './aria/tabs.js';
|
|
6
|
-
import { PopupMenuItemAction } from './aria/PopupMenuItemAction.js';
|
|
7
|
-
import { PopupMenuAction } from './aria/PopupMenuAction.js';
|
|
8
|
-
import { MenubarItemAction } from './aria/MenubarItemAction.js';
|
|
9
|
-
import { MenubarAction } from './aria/MenubarAction.js';
|
|
10
|
-
import { listbox } from './aria/listbox.js';
|
|
11
7
|
import { LinksList } from './aria/linksList.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { Toggle } from './aria/toggle.js';
|
|
16
|
-
import { Collapsible } from './aria/collapsible.js';
|
|
17
|
-
import { Notification } from './aria/notification.js';
|
|
18
|
-
import { RadioButton } from './aria/radioButton.js';
|
|
19
|
-
import { CheckBox } from './aria/checkBoxes.js';
|
|
20
|
-
import { MenuVertical } from './aria/MenuVertical.js';
|
|
8
|
+
import { listbox } from './aria/listbox.js';
|
|
9
|
+
import { MenubarAction } from './aria/MenubarAction.js';
|
|
10
|
+
import { MenubarItemAction } from './aria/MenubarItemAction.js';
|
|
21
11
|
import { MenuHorizontal } from './aria/MenuHorizontal.js';
|
|
22
12
|
import { MenuNavigation } from './aria/MenuNavigation.js';
|
|
13
|
+
import { MenuVertical } from './aria/MenuVertical.js';
|
|
23
14
|
import { Nav } from './aria/Nav.js';
|
|
24
|
-
|
|
15
|
+
import { Notification } from './aria/notification.js';
|
|
16
|
+
import { PopupMenuAction } from './aria/PopupMenuAction.js';
|
|
17
|
+
import { PopupMenuItemAction } from './aria/PopupMenuItemAction.js';
|
|
18
|
+
import { RadioButton } from './aria/radioButton.js';
|
|
19
|
+
import { tabs } from './aria/tabs.js';
|
|
20
|
+
import { Toggle } from './aria/toggle.js';
|
|
21
|
+
import { Tree } from './aria/tree.js';
|
|
22
|
+
import { TreeGrid } from './aria/treegrid.js';
|
|
23
|
+
import { Treeitem } from './aria/treeitem.js';
|
|
24
|
+
import { convertToISOFormat, formatDateToDDMMYYYY, utils } from './aria/utils.js';
|
|
25
25
|
export function accordionComponent(aria) {
|
|
26
26
|
accordion(aria);
|
|
27
27
|
}
|
|
@@ -54,14 +54,14 @@ export function dropdownComponent(aria) {
|
|
|
54
54
|
const moduleValue = modules[item].getAttribute('data-module');
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
if (moduleValue == 'c-dropdown'){
|
|
57
|
+
if (moduleValue == 'c-dropdown') {
|
|
58
58
|
const buttonDropdown = modules[item].querySelector('[data-module = "c-dropdown-button"]');
|
|
59
59
|
const tooltip = modules[item].querySelector('[data-module = "c-dropdown-tooltip"]');
|
|
60
60
|
const roleCustom = buttonDropdown.getAttribute('data-role');
|
|
61
61
|
const ariaLabel = buttonDropdown.getAttribute('data-aria-label');
|
|
62
62
|
const ariaModal = buttonDropdown.getAttribute('data-aria-modal');
|
|
63
63
|
const ariaHasPopup = buttonDropdown.getAttribute('data-aria-haspopup');
|
|
64
|
-
if(buttonDropdown && tooltip) {
|
|
64
|
+
if (buttonDropdown && tooltip) {
|
|
65
65
|
const hideOnPopperBlur = {
|
|
66
66
|
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonpopperblur */
|
|
67
67
|
name: 'hideOnPopperBlur',
|
|
@@ -73,7 +73,7 @@ export function dropdownComponent(aria) {
|
|
|
73
73
|
if (
|
|
74
74
|
instance.props.hideOnPopperBlur &&
|
|
75
75
|
event.relatedTarget &&
|
|
76
|
-
!instance.popper.contains(event.relatedTarget)
|
|
76
|
+
!instance.popper.contains(event.relatedTarget) &&
|
|
77
77
|
event.relatedTarget !== instance.reference
|
|
78
78
|
) {
|
|
79
79
|
instance.hide();
|
|
@@ -87,7 +87,7 @@ export function dropdownComponent(aria) {
|
|
|
87
87
|
/* https://atomiks.github.io/tippyjs/v6/plugins/#hideonesc */
|
|
88
88
|
name: 'hideOnEsc',
|
|
89
89
|
defaultValue: true,
|
|
90
|
-
fn({hide}) {
|
|
90
|
+
fn({ hide }) {
|
|
91
91
|
function onKeyDown(event) {
|
|
92
92
|
if (event.keyCode === 27) {
|
|
93
93
|
hide();
|
|
@@ -117,22 +117,22 @@ export function dropdownComponent(aria) {
|
|
|
117
117
|
arrow: false,
|
|
118
118
|
offset: [0, -10],
|
|
119
119
|
theme: '',
|
|
120
|
-
plugins: [hideOnEsc,hideOnPopperBlur],
|
|
120
|
+
plugins: [hideOnEsc, hideOnPopperBlur],
|
|
121
121
|
role: roleCustom ? roleCustom : false,
|
|
122
122
|
aria: {
|
|
123
123
|
content: 'auto'
|
|
124
124
|
},
|
|
125
125
|
onCreate(instance) {
|
|
126
|
-
if(ariaHasPopup){
|
|
126
|
+
if (ariaHasPopup) {
|
|
127
127
|
instance.reference.setAttribute('aria-haspopup', ariaHasPopup);
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
130
|
onShown(instance) {
|
|
131
131
|
aria.Utils.focusFirstDescendant(tooltip);
|
|
132
|
-
if(ariaLabel){
|
|
132
|
+
if (ariaLabel) {
|
|
133
133
|
instance.popper.firstElementChild.setAttribute('aria-label', ariaLabel);
|
|
134
134
|
}
|
|
135
|
-
if(ariaModal){
|
|
135
|
+
if (ariaModal) {
|
|
136
136
|
instance.popper.firstElementChild.setAttribute('aria-modal', ariaModal);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -244,7 +244,7 @@ export function listboxComponent(aria) {
|
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
listbox.setHandleFocusChange(function(evt) {
|
|
247
|
+
listbox.setHandleFocusChange(function (evt) {
|
|
248
248
|
if ((!list.hasAttribute('aria-multiselectable')) && (buttonListbox.getAttribute('data-change') == 'change')) {
|
|
249
249
|
buttonListbox.firstElementChild.innerHTML = evt.innerHTML;
|
|
250
250
|
}
|
|
@@ -390,7 +390,7 @@ export function treeComponent(aria) {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
if (moduleValue == 'c-tree__item') {
|
|
393
|
-
modules[item].addEventListener('click', function(event) {
|
|
393
|
+
modules[item].addEventListener('click', function (event) {
|
|
394
394
|
event.stopPropagation();
|
|
395
395
|
});
|
|
396
396
|
}
|
|
@@ -485,7 +485,7 @@ export function DatepickerComponent(aria) {
|
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
if (datepickerSelect != undefined) {
|
|
488
|
-
datepickerSelect.addEventListener('change', function() {
|
|
488
|
+
datepickerSelect.addEventListener('change', function () {
|
|
489
489
|
const selectedValue = this.value;
|
|
490
490
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
491
491
|
datepickerCalendar.max = selectedValue + "-12-31";
|
|
@@ -498,7 +498,7 @@ export function DatepickerComponent(aria) {
|
|
|
498
498
|
const datepickerSubmit = module.querySelector('#' + dropdownId + '-submit');
|
|
499
499
|
|
|
500
500
|
if (datepickerCancel != undefined) {
|
|
501
|
-
datepickerCancel.onclick = function() {
|
|
501
|
+
datepickerCancel.onclick = function () {
|
|
502
502
|
// Restore values according to original format
|
|
503
503
|
if (storedInitialFormat === 'iso') {
|
|
504
504
|
datepickerCalendar.value = storedInitialValue;
|
|
@@ -514,7 +514,7 @@ export function DatepickerComponent(aria) {
|
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
if (datepickerSubmit != undefined) {
|
|
517
|
-
datepickerSubmit.onclick = function() {
|
|
517
|
+
datepickerSubmit.onclick = function () {
|
|
518
518
|
// On submit, clear stored value for next opening
|
|
519
519
|
storedInitialValue = '';
|
|
520
520
|
storedInitialFormat = '';
|
|
@@ -552,7 +552,7 @@ export function DatepickerComponent(aria) {
|
|
|
552
552
|
const datepickerSelect = module.querySelector(':is(select)');
|
|
553
553
|
const datepickerCalendar = module.querySelector(':is(calendar-date, calendar-multi, calendar-range)');
|
|
554
554
|
if (datepickerSelect != undefined) {
|
|
555
|
-
datepickerSelect.addEventListener('change', function() {
|
|
555
|
+
datepickerSelect.addEventListener('change', function () {
|
|
556
556
|
const selectedValue = this.value;
|
|
557
557
|
datepickerCalendar.min = selectedValue + "-01-01";
|
|
558
558
|
datepickerCalendar.max = selectedValue + "-12-31";
|
|
@@ -561,4 +561,10 @@ export function DatepickerComponent(aria) {
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
});
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export function TreegridComponent(aria) {
|
|
567
|
+
const doAllowRowFocus = true;
|
|
568
|
+
const doStartRowFocus = true;
|
|
569
|
+
document.querySelectorAll('[data-module="c-treegrid"]').forEach((treegridEl) => TreeGrid(treegridEl, doAllowRowFocus, doStartRowFocus));
|
|
564
570
|
}
|
package/src/js/index.js
CHANGED
|
@@ -6,25 +6,26 @@
|
|
|
6
6
|
import {
|
|
7
7
|
accordionComponent,
|
|
8
8
|
alertComponent,
|
|
9
|
+
checkBoxComponent,
|
|
9
10
|
collapsibleComponent,
|
|
11
|
+
DatepickerComponent,
|
|
10
12
|
dialogComponent,
|
|
11
13
|
dropdownComponent,
|
|
12
|
-
listboxComponent,
|
|
13
14
|
linksListComponent,
|
|
15
|
+
listboxComponent,
|
|
14
16
|
menubarComponent,
|
|
17
|
+
MenuHorizontalComponent,
|
|
18
|
+
MenuNavigationComponent,
|
|
19
|
+
MenuVerticalComponent,
|
|
20
|
+
NavComponent,
|
|
21
|
+
notificationComponent,
|
|
22
|
+
radioButtonComponent,
|
|
15
23
|
tableAdvancedComponent,
|
|
16
24
|
tabsComponent,
|
|
17
|
-
tooltipComponent,
|
|
18
25
|
toggleComponent,
|
|
26
|
+
tooltipComponent,
|
|
19
27
|
treeComponent,
|
|
20
|
-
|
|
21
|
-
radioButtonComponent,
|
|
22
|
-
checkBoxComponent,
|
|
23
|
-
MenuVerticalComponent,
|
|
24
|
-
MenuHorizontalComponent,
|
|
25
|
-
MenuNavigationComponent,
|
|
26
|
-
NavComponent,
|
|
27
|
-
DatepickerComponent
|
|
28
|
+
TreegridComponent
|
|
28
29
|
} from './desy-html.js';
|
|
29
30
|
|
|
30
31
|
var aria = aria || {};
|
|
@@ -50,6 +51,7 @@ MenuHorizontalComponent(aria);
|
|
|
50
51
|
MenuNavigationComponent(aria);
|
|
51
52
|
NavComponent(aria);
|
|
52
53
|
DatepickerComponent(aria);
|
|
54
|
+
TreegridComponent(aria);
|
|
53
55
|
|
|
54
56
|
//Using the browser API to copy code to the clipboard
|
|
55
57
|
const copyButtons = document.querySelectorAll('[data-module = "c-button-copy"]');
|
|
@@ -19,17 +19,3 @@ params:
|
|
|
19
19
|
type: object
|
|
20
20
|
required: false
|
|
21
21
|
description: HTML attributes (for example data attributes) to add to the hint span tag.
|
|
22
|
-
|
|
23
|
-
accessibilityCriteria: |
|
|
24
|
-
When used with a single input, the hint MUST:
|
|
25
|
-
- be announced by screen readers when the input is focussed
|
|
26
|
-
|
|
27
|
-
When used with a group of multiple inputs (such as within a fieldset), the
|
|
28
|
-
hint MUST:
|
|
29
|
-
- be announced by screen readers when focussing the first input within the
|
|
30
|
-
group (first in this case refers to the focus order, not the DOM - if the
|
|
31
|
-
user is traversing backwards through the page then this would be the last
|
|
32
|
-
input within the group in the DOM)
|
|
33
|
-
|
|
34
|
-
When used with a group of multiple inputs, the hint SHOULD NOT:
|
|
35
|
-
- be announced every time for each individual input
|
|
@@ -128,13 +128,3 @@ params:
|
|
|
128
128
|
type: object
|
|
129
129
|
required: false
|
|
130
130
|
description: HTML attributes (for example data attributes) to add to the menubar container.
|
|
131
|
-
|
|
132
|
-
accessibilityCriteria: |
|
|
133
|
-
## sub reveals
|
|
134
|
-
Must:
|
|
135
|
-
- be visible as static content if JavaScript is unavailable or fails
|
|
136
|
-
- be hidden if JavaScript is available and is collapsed
|
|
137
|
-
- indicate if content is expanded or collapsed
|
|
138
|
-
- indicate that there is collapsed content to interact with
|
|
139
|
-
|
|
140
|
-
Note that alphagov have known issues against this criteria: https://github.com/alphagov/govuk_elements/issues/575
|
|
@@ -150,7 +150,7 @@ params:
|
|
|
150
150
|
description: HTML attributes (for example data attributes) to add to the table container.
|
|
151
151
|
|
|
152
152
|
accessibilityCriteria: |
|
|
153
|
-
|
|
153
|
+
## Las tablas deben:
|
|
154
154
|
1. Debe tener al menos una celda de encabezado (TH) en las filas o columnas exteriores.
|
|
155
155
|
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).
|
|
156
156
|
3. El título de la tabla debe estar marcado como <caption>
|
|
@@ -2675,5 +2675,159 @@
|
|
|
2675
2675
|
}
|
|
2676
2676
|
]
|
|
2677
2677
|
}
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
"name": "lazy rendering",
|
|
2681
|
+
"description": "No pinta los nodos hijos hasta que el usuario no lo pide desplegando un nodo padre. Usalo sólo si el arbol tiene una cantidad enorme de items.",
|
|
2682
|
+
"data": {
|
|
2683
|
+
"name": "type-lazy-rendering",
|
|
2684
|
+
"classes": "mt-base",
|
|
2685
|
+
"type": "checkbox",
|
|
2686
|
+
"fieldset": {
|
|
2687
|
+
"legend": {
|
|
2688
|
+
"text": "Selecciona organismo"
|
|
2689
|
+
}
|
|
2690
|
+
},
|
|
2691
|
+
"idPrefix": "type-lazy-rendering",
|
|
2692
|
+
"lazyRendering": true,
|
|
2693
|
+
"items": [
|
|
2694
|
+
{
|
|
2695
|
+
"text": "Item A",
|
|
2696
|
+
"id": "item-a",
|
|
2697
|
+
"sub": {
|
|
2698
|
+
"items": [
|
|
2699
|
+
{
|
|
2700
|
+
"text": "Subitem A1",
|
|
2701
|
+
"value": "subitem-a1",
|
|
2702
|
+
"sub": {
|
|
2703
|
+
"items": [
|
|
2704
|
+
{
|
|
2705
|
+
"text": "SubSubitem A1.1",
|
|
2706
|
+
"value": "subsubitem-a1-1",
|
|
2707
|
+
"sub": {
|
|
2708
|
+
"items": [
|
|
2709
|
+
{
|
|
2710
|
+
"text": "Level 4 A1.1.1",
|
|
2711
|
+
"value": "lvl4-a1-1-1",
|
|
2712
|
+
"sub": {
|
|
2713
|
+
"items": [
|
|
2714
|
+
{
|
|
2715
|
+
"text": "Level 5 A1.1.1.1",
|
|
2716
|
+
"value": "lvl5-a1-1-1-1"
|
|
2717
|
+
},
|
|
2718
|
+
{
|
|
2719
|
+
"text": "Level 5 A1.1.1.2",
|
|
2720
|
+
"value": "lvl5-a1-1-1-2"
|
|
2721
|
+
}
|
|
2722
|
+
]
|
|
2723
|
+
}
|
|
2724
|
+
},
|
|
2725
|
+
{
|
|
2726
|
+
"text": "Level 4 A1.1.2",
|
|
2727
|
+
"value": "lvl4-a1-1-2"
|
|
2728
|
+
}
|
|
2729
|
+
]
|
|
2730
|
+
}
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
"text": "SubSubitem A1.2",
|
|
2734
|
+
"value": "subsubitem-a1-2"
|
|
2735
|
+
}
|
|
2736
|
+
]
|
|
2737
|
+
}
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
"text": "Subitem A2",
|
|
2741
|
+
"value": "subitem-a2"
|
|
2742
|
+
},
|
|
2743
|
+
{
|
|
2744
|
+
"text": "Subitem A3",
|
|
2745
|
+
"value": "subitem-a3"
|
|
2746
|
+
}
|
|
2747
|
+
]
|
|
2748
|
+
}
|
|
2749
|
+
},
|
|
2750
|
+
{
|
|
2751
|
+
"text": "Item B",
|
|
2752
|
+
"id": "item-b",
|
|
2753
|
+
"sub": {
|
|
2754
|
+
"items": [
|
|
2755
|
+
{
|
|
2756
|
+
"text": "Subitem B1",
|
|
2757
|
+
"value": "subitem-b1",
|
|
2758
|
+
"sub": {
|
|
2759
|
+
"items": [
|
|
2760
|
+
{
|
|
2761
|
+
"text": "SubSubitem B1.1",
|
|
2762
|
+
"value": "subsubitem-b1-1",
|
|
2763
|
+
"sub": {
|
|
2764
|
+
"items": [
|
|
2765
|
+
{
|
|
2766
|
+
"text": "Level 4 B1.1.1",
|
|
2767
|
+
"value": "lvl4-b1-1-1"
|
|
2768
|
+
},
|
|
2769
|
+
{
|
|
2770
|
+
"text": "Level 4 B1.1.2",
|
|
2771
|
+
"value": "lvl4-b1-1-2"
|
|
2772
|
+
},
|
|
2773
|
+
{
|
|
2774
|
+
"text": "Level 4 B1.1.3",
|
|
2775
|
+
"value": "lvl4-b1-1-3"
|
|
2776
|
+
}
|
|
2777
|
+
]
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
]
|
|
2781
|
+
}
|
|
2782
|
+
},
|
|
2783
|
+
{
|
|
2784
|
+
"text": "Subitem B2",
|
|
2785
|
+
"value": "subitem-b2"
|
|
2786
|
+
},
|
|
2787
|
+
{
|
|
2788
|
+
"text": "Subitem B3",
|
|
2789
|
+
"value": "subitem-b3"
|
|
2790
|
+
}
|
|
2791
|
+
]
|
|
2792
|
+
}
|
|
2793
|
+
},
|
|
2794
|
+
{
|
|
2795
|
+
"text": "Item C",
|
|
2796
|
+
"id": "item-c",
|
|
2797
|
+
"sub": {
|
|
2798
|
+
"items": [
|
|
2799
|
+
{
|
|
2800
|
+
"text": "Subitem C1",
|
|
2801
|
+
"value": "subitem-c1",
|
|
2802
|
+
"sub": {
|
|
2803
|
+
"items": [
|
|
2804
|
+
{
|
|
2805
|
+
"text": "SubSubitem C1.1",
|
|
2806
|
+
"value": "subsubitem-c1-1"
|
|
2807
|
+
},
|
|
2808
|
+
{
|
|
2809
|
+
"text": "SubSubitem C1.2",
|
|
2810
|
+
"value": "subsubitem-c1-2"
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
"text": "SubSubitem C1.3",
|
|
2814
|
+
"value": "subsubitem-c1-3"
|
|
2815
|
+
}
|
|
2816
|
+
]
|
|
2817
|
+
}
|
|
2818
|
+
},
|
|
2819
|
+
{
|
|
2820
|
+
"text": "Subitem C2",
|
|
2821
|
+
"value": "subitem-c2"
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
"text": "Subitem C3",
|
|
2825
|
+
"value": "subitem-c3"
|
|
2826
|
+
}
|
|
2827
|
+
]
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
]
|
|
2831
|
+
}
|
|
2678
2832
|
}
|
|
2679
|
-
] %}
|
|
2833
|
+
] %}
|